function server_request(page, sess)
{
var xhr_wr = createXMLHttpRequest();
+ var tout = -1;
var i, collect = "", post_collect = null, is_post = false;
if (arguments.length > 0) {
collect += (i == 0 ? "" : "&") + arguments[i] + "=" + encodeURIComponent(arguments[i+1]);
}
}
- // alert("Args: "+arguments.length);
-
var uri = page + '?' + (sess != null ? 'sess=' + sess + '&' : '') + collect;
if (is_post) {
xhr_wr.open('POST', uri, false);
else {
xhr_wr.open('GET', uri, false);
}
- xhr_wr.onreadystatechange = function() { return; };
+ if (tout > 0) {
+ xhr_wr.timeout = tout;
+ }
+
+ xhr_wr.onreadystatechange = function() {
+ console.log('we are here');
+ return; };
xhr_wr.send(post_collect);
if (xhr_wr.responseText != null) {
return (null);
}
+
+function server_asyncreq(async_req, page, sess)
+{
+ var xhr_wr = createXMLHttpRequest();
+ var tout = -1;
+ var i, collect = "", post_collect = null, is_post = false;
+
+ if (arguments.length > 0) {
+ for (i = 3 ; i < arguments.length ; i+= 2) {
+ if (arguments[i] == "__POST__") {
+ is_post = true;
+ post_collect = "";
+ i -= 1;
+ continue;
+ }
+ else if (arguments[i] == "__TOUT__") {
+ tout = arguments[i+1];
+ continue;
+ }
+ if (is_post)
+ post_collect += (post_collect == "" ? "" : "&") + arguments[i] + "=" + encodeURIComponent(arguments[i+1]);
+ else
+ collect += (i == 0 ? "" : "&") + arguments[i] + "=" + encodeURIComponent(arguments[i+1]);
+ }
+ }
+ var already_quest = (page.indexOf('?') != -1);
+ var uri = page + (already_quest ? '&' : '?') + (sess != null ? 'sess=' + sess + '&' : '') + collect;
+ if (is_post) {
+ xhr_wr.open('POST', uri, true);
+ xhr_wr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
+ }
+ else {
+ xhr_wr.open('GET', uri, true);
+ }
+ if (tout > 0) {
+ xhr_wr.timeout = tout;
+ }
+
+ xhr_wr.onreadystatechange = async_req;
+ xhr_wr.send(post_collect);
+
+ return;
+}
+
/* Stat: CHAT and TABLE */
function chatt_checksend(obj,e)
class_add(item, cls_in);
}
+function nexst(after)
+{
+ if (after != undefined) {
+ this._after = after;
+ }
+}
+
+nexst.next = function(st)
+{
+ if (st === null || st === undefined)
+ st = new nexst();
+ st._step++;
+
+ return st;
+};
+
+nexst.prev = function(st)
+{
+ st._step--;
+}
+
+nexst.reprise = function ()
+{
+ var thiz, args_in, args = [];
+
+ if (arguments.length > 1) {
+ thiz = arguments[0];
+ args_in = arguments[1];
+ }
+ else {
+ thiz = null;
+ args_in = arguments[0];
+ }
+
+ for (var i = 0 ; i < args_in.length ; i++) {
+ args[i] = args_in[i];
+ }
+ return args_in.callee.apply(thiz, args);
+};
+
+nexst.prototype = {
+ _step: 0, // current step for the async multistep command
+ _data: null, // data returned at the end of the async command
+ _subst: null, // substatus for nested async command
+ _after: null, // callback (as 'arguments' object) to run at the end
+ // of last step
+
+ step_set: function(step) {
+ this._step = step;
+ },
+
+ step_get: function() {
+ return this._step;
+ },
+
+ data_set: function(data) {
+ this._data = data;
+ },
+
+ data_get: function() {
+ return this._data;
+ },
+
+ subst_set: function(subst) {
+ this._subst = subst;
+ },
+
+ subst_get: function() {
+ return this._subst;
+ },
+
+ after_set: function(after) {
+ this._after = after;
+ },
+
+ after_get: function() {
+ return this._after;
+ },
+
+ done_set: function() {
+ this.done = true;
+ },
+
+ done_get: function() {
+ return (this.done);
+ }
+};