Source code for /src/CookieCommunicator.js.txt
// =====================================================================//
// Author: Mark Qian <markqian@hotmail.com> //
// WWW: http://www.coolshare.com/ //
// Copyright (c) 2006, Mark Qian //
// //
// You must contact Mark Qian to get a permission of use //
// in case you want to make any use of the codes except viewing it //
// on Mark's site. //
//======================================================================//
function CookieCommunicator() {
this.id = ""+(idCount++);
this.type = "Cookie";
this.RSLite = new RSLiteObject(this);
///////////////////////////////////////////////////////////////////
//
// Pattern "Template Method" is used here: implement its own concrete
// "send" here.
//
/////////////////////////////////////////////////////////////////////
this.send = function () {
try {
this.preSend();
this.RSLite.call(this.url, this.params);
this.postSend();
} catch (e) {
if (this.errHandler)
this.errHandler(e);
}
}
this.postInit = function () {
if (this.form)
this.params = this.buildParaForForm(this.form);
}
///////////////// Wrapping the concrete callback ///////////
//
// I don't invoke the real callback function, "handler",
// directly when dynamic script onloading. Instead, I wrapped
// the "handler" with a wrapper, "process" so
// that I can do some system level tasks before and
// after the "handler" is carried out.
//
////////////////////////////////////////////////////////////
this.RSLite.callback = (function() {
var res = function (response) {
this.parent.res = response;
// do the preprocess here...
this.parent.handler();
// do any clear up here...
this.parent.state = 0;
}
return res;
})();
}
///////////////////////////////////////////////////////////////
//
// Subclass Communicator
//
//////////////////////////////////////////////////////////////
CookieCommunicator.prototype = new Communicator();