1 dump('entering util/network.js\n');
3 if (typeof util == 'undefined') util = {};
4 util.network = function () {
6 JSAN.use('util.error'); this.error = new util.error();
7 // Place a test here for network connectivity
8 // this.offline = true;
13 util.network.prototype = {
15 // Flag for whether the staff client should act as if it were offline or not
20 'simple_request' : function(id,params,f) {
21 return this.request(api[id].app,api[id].method,params,f);
24 'request' : function (app,name,params,f) {
27 var sparams = js2JSON(params);
28 obj.error.sdump('D_SES','request '+app+' '+name+' '+sparams.slice(1,sparams.length-1)+
29 '\nResult #' + (++obj.link_id) + ( f ? ' asynced' : ' synced' ) );
30 var request = new RemoteRequest( app, name );
31 for(var index in params) {
32 request.addParam(params[index]);
36 request.setCompleteCallback(
38 obj.error.sdump('D_SES_RESULT','asynced result #' + obj.link_id + '\n\n' +
39 js2JSON(req.getResultObject()));
40 obj.test_session_timeout(req);
48 obj.test_session_timeout(request);
49 var result = request.getResultObject();
50 this.error.sdump('D_SES_RESULT','synced result #' + obj.link_id + '\n\n' + js2JSON(result));
55 if (instanceOf(E,perm_ex)) {
56 alert('permission exception: ' + js2JSON(E));
62 'test_session_timeout' : function(req) {
64 var robj = req.getResultObject();
65 if (robj.ilsevent && robj.ilsevent == 1001) {
66 alert("Your session has timed out. In the future we may give you the ability to log back in without losing your work, but for now, the behavior at this point is undefined and this message will almost certainly be followed by error messages. Please logout of the staff client and then back in.");
69 this.error.sdump('D_ERROR',E);
75 function sample_callback(request) {
76 var result = request.getResultObject();
80 dump('exiting util/network.js\n');