/* appjet:version 0.1 */
/* appjet:library */
// Copyright (c) 2009, Herbert Vojčík
// Licensed by MIT license (http://www.opensource.org/licenses/mit-license.php)
var _re = /
]*id=['"]appjetfooter['"][^>]*>/;
/**@ignore*/
function replaceTheFooter(f) {
var _oldrender = page.render;
/**@ignore*/
page.render = function() {
page.render = _oldrender;
var result = page.render();
var index = _findFooterIndex(result);
if (index !== -1) { result[index] = f(result[index]); }
return result;
};
function _findFooterIndex(array) {
for (var i = array.length - 1; i >= 0; --i) {
if (array[i].match(_re)) {
return i;
}
}
return -1;
}
}
/**
* At render time, inserts the content provided
* by the supplied function into the footer.
*/
function extendTheFooter(f) {
replaceTheFooter(function(footer) {
return footer.replace(_re, function(a) {
return a+toHTML(DIV(f()));
});
});
}
/**
* Hides the footer at render time.
*/
function hideTheFooter(f) {
replaceTheFooter(function() { return ""; });
}
/* appjet:server */
import(appjet.appName);
extendTheFooter(function() {
return SPAN(
"Server time is: ",
new Date(),
" ",
SPAN({style:"color:silver"}, "(this line extends the footer)")
);
});
//hideTheFooter();