1 /* ---------------------------------------------------------------------------
2 * Copyright (C) 2008 Georgia Public Library Service
3 * Bill Erickson <erickson@esilibrary.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * ---------------------------------------------------------------------------
17 if(!dojo._hasResource["openils.Event"]) {
19 dojo._hasResource["openils.Event"] = true;
20 dojo.provide("openils.Event");
21 dojo.declare('openils.Event', null, {
23 constructor : function(kwargs) {
24 this.code = kwargs.ilsevent;
25 this.textcode = kwargs.textcode;
26 this.desc = kwargs.desc;
27 this.payload = kwargs.payload;
28 this.debug = kwargs.stacktrace;
29 this.servertime = kwargs.servertime;
30 this.ilsperm = kwargs.ilsperm;
31 this.ilspermloc = kwargs.ilspermloc;
32 this.note = kwargs.note;
35 toString : function() {
36 var s = 'Event: ' + (this.code || '') + ':' + this.textcode + ' -> ' + new String(this.desc);
38 s += ' ' + this.ilsperm + '@' + this.ilspermloc;
40 s += '\n' + this.note;
46 * Parses a proposed event object. If this object is an
47 * event, a new openils.Event is returned. Otherwise,
50 openils.Event.parse = function(evt) {
51 if(evt && typeof evt == 'object' && 'ilsevent' in evt && 'textcode' in evt)
52 return new openils.Event(evt);
57 * If the provided object is a non-success event, the
58 * event is thrown as an exception.
60 openils.Event.parse_and_raise = function(evt) {
61 var e = openils.Event.parse(evt);
62 if(e && e.ilsevent != 0)