Script Include Prototypes
var Skeleton = function() {
// Ensure new is always called
if (!(this instanceof Skeleton)) {
return new Skeleton();
}
this.type = 'Skeleton';
// Set up logging for the instance
this._log = (new GSLog(null, this.type)).setLog4J();
this._log.setLevel(GSLog.TRACE);
this._debugging = (gs.getProperty("debug.SI." + this.type) === 'true');
if (gs.getProperty("instance_name").match(/test$/)) {
this._debugging = true;
}
if (gs.getProperty("instance_name").match(/translog$/)) {
this._debugging = true;
}
};
Skeleton.prototype._padZero = function(_num) {
var numberString = "0" + _num;
return numberString.slice(-2);
};
Skeleton.prototype._debug = function(_msg, _flush) {
if (this._debugging) {
var localtime = new Date();
if (this.debugStartTime == 0) {
this.debugStartTime = localtime.getTime();
}
var ms = '000' + localtime.getMilliseconds();
ms = ms.slice(-3);
var dateString = this.type + ' ' + localtime.getFullYear() + '-' +
this._padZero((localtime.getMonth() + 1)) + '-' +
this._padZero(localtime.getDate()) + ' ' +
this._padZero(localtime.getHours()) + ':' +
this._padZero(localtime.getMinutes()) + ':' +
this._padZero(localtime.getSeconds()) + '.' +
ms + ': ';
if (_flush) {
this._log.debug(dateString + this.debugMessage);
} else {
this._log.debug(dateString + _msg);
var delta = localtime.getTime() - this.debugStartTime;
var sec = this._padZero(parseInt(delta / 1000));
if (sec > 60) {
min = String("0" + parseInt(sec / 60)).slice(-2);
sec = String("0" + parseInt(sec - (min * 60))).slice(-2);
} else {
min = "00";
}
var ms = String("00" + (parseInt(delta) - (sec * 1000))).slice(-3);
this.debugMessage += "\n" + min + ':' + sec + ':' + ms + ": " + _msg;
}
}
};
Skeleton.prototype.flush = function() {
this._debug('', true);
};
Skeleton.prototype.newFunction = function() {
}
var SkeletonAjax = Class.create();
SkeletonAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {
_initialize: function() {
this.type = 'SkeletonAjax';
this._log = (new GSLog(null, 'SkeletonAjax')).setLog4J();
this._log.setLevel(GSLog.TRACE);
this._debugging = (gs.getProperty("debug.SI." + this.type) === 'true');
if (gs.getProperty("instance_name").match(/dev$/)) {
this._debugging = true;
}
if (gs.getProperty("instance_name").match(/translog$/)) {
this._debugging = true;
}
},
_debug: function(_msg) {
if (this._debugging) {
var localtime = new Date();
var ms = '000' + localtime.getMilliseconds();
ms = ms.slice(-3);
this._log.debug(this.type + ' ' + localtime.getFullYear() + '-' + this._padZero((localtime.getMonth() + 1), 2) + '-' + this._padZero(localtime.getDate(), 2) + ' ' + this._padZero(localtime.getHours(), 2) + ':' + this._padZero(localtime.getMinutes(), 2) + ':' + this._padZero(localtime.getSeconds(), 2) + '.' + ms + ': ' + _msg);
}
},
_padZero: function(num) {
var numberString = "0" + num;
return numberString.slice(-2);
},
function1: function() {
this._initialize();
var answer = {
error: false,
records: []
};
var param1 = this.getParameter('sysparm_p1');
var json = new JSON();
var jsonString = json.encode(answer);
this._debug('JSON: ' + jsonString);
return (jsonString);
}
});