pyc-website

main website for pyc inc.

git clone https://9o.is/git/pyc-website.git

commit c31017107f587ef921224ffed08cbb4f6a800d1a
parent 0371b6bba2fb74772397f9c96627a3b1f177b6cd
Author: Jul <jul@9o.is>
Date:   Wed, 26 Mar 2014 23:02:04 -0400

updated liftajax.js to 3.0-SNAPSHOT

Diffstat:
Msrc/main/webapp/vendor/liftAjax.js | 57++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 52 insertions(+), 5 deletions(-)

diff --git a/src/main/webapp/vendor/liftAjax.js b/src/main/webapp/vendor/liftAjax.js @@ -35,10 +35,56 @@ }, + knownPromises: {}, + + randStr: function() { + return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);}, + + makeGuid: function() {return this.randStr() + this.randStr() + '-' + this.randStr() + '-' + this.randStr() + '-' + + this.randStr() + '-' + this.randStr() + this.randStr() + this.randStr();}, + + Promise: function() { + return { + guid: liftAjax.makeGuid(), + "_values": [], + '_events': [], + '_failMsg': "", + '_valueFuncs': [], + '_doneFuncs': [], + '_failureFuncs': [], + '_eventFuncs': [], + '_done': false, + '_failed': false, + processMsg: function(evt) {if (this._done || this._failed) return; + this._events.push(evt); + for (var v in this._eventFuncs) {try {this._eventFuncs[v](evt);} catch (e) {liftAjax.lift_defaultLogError(e);}}; + if (evt.done != null) {this.doneMsg();} else if (evt.success != null) {this.successMsg(evt.success);} else if (evt.failure != null) {this.failMsg(evt.failure);}}, + successMsg: function(value) {if (this._done || this._failed) return; this._values.push(value); for (var f in this._valueFuncs) {this._valueFuncs[f](value);}}, + failMsg: function(msg) {if (this._done || this._failed) return; liftAjax._removeIt(this.guid); this._failed = true; this._failMsg = msg; for (var f in this._failureFuncs) {this._failureFuncs[f](msg);}}, + doneMsg: function() {if (this._done || this._failed) return; liftAjax._removeIt(this.guid); this._done = true; for (var f in this._doneFuncs) {this._doneFuncs[f]();}}, + then: function(f) {this._valueFuncs.push(f); for (var v in this._values) {try {f(this._values[v]);} catch (e) {liftAjax.lift_defaultLogError(e);;}} return this;}, + fail: function(f) {this._failureFuncs.push(f); if (this._failed) {try {f(this._failMsg);} catch (e) {liftAjax.lift_defaultLogError(e);;}}; return this;}, + done: function(f) {this._doneFuncs.push(f); if (this._done) {try {f();} catch (e) {liftAjax.lift_defaultLogError(e);;}} return this;}, + onEvent: function(f) {this._eventFuncs.push(f); for (var v in this._events) {try {f(this._events[v]);} catch (e) {liftAjax.lift_defaultLogError(e);;}}; return this;}, + map: function(f) {var ret = new liftAjax.Promise(); this.done(function() {ret.doneMsg();}); this.fail(function (m) {ret.failMsg(m);}); this.then(function (v) {ret.successMsg(f(v));}); return ret;} + }; + }, + + _removeIt: function(g) {this.knownPromises[g] = undefined;}, + + sendEvent: function(g, evt) { + var p = this.knownPromises[g]; + if (p) { + p.processMsg(evt); + } + }, + + associate: function(promise) {this.knownPromises[promise.guid] = promise;}, + lift_uriSuffix: undefined, lift_logError: function(msg) { - liftAjax.lift_defaultLogError(msg); + liftAjax.lift_defaultLogError(msg); }, lift_defaultLogError: function(msg) { @@ -47,7 +93,7 @@ else alert(msg); }, - + lift_ajaxQueueSort: function() { liftAjax.lift_ajaxQueue.sort(function (a, b) {return a.when - b.when;}); }, @@ -128,7 +174,7 @@ if (arguments.length == 3 && arguments[1] == 'parsererror') { liftAjax.lift_logError('The server call succeeded, but the returned Javascript contains an error: '+arguments[2]) } else - + if (cnt < liftAjax.lift_ajaxRetryCount) { aboutToSend.retryCnt = cnt + 1; var now = (new Date()).getTime(); @@ -171,7 +217,7 @@ lift_ajaxVersion: 0, addPageNameAndVersion: function(url, version) { - + var replacement = 'ajax_request/'+lift_page; if (version!=null) replacement += ('-'+version.toString(36)) + (liftAjax.lift_ajaxQueue.length > 35 ? 35 : liftAjax.lift_ajaxQueue.length).toString(36); @@ -207,4 +253,4 @@ })(); - jQuery(document).ready(function() {liftAjax.lift_doCycleIn200();}); + jQuery(document).ready(function() {liftAjax.lift_doCycleIn200();}); +\ No newline at end of file