Another abandoned server code base... this is kind of an ancestor of taskrambler.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

60 lines
1.1 KiB

function ServerVal(eId)
{
this.eId = eId;
this.eCtime = eId + " span:eq(1)";
this.eVnext = eId + " span:eq(2)";
this.eValue = eId + " span:eq(3)";
this.interval = null;
this.ctime = null;
this.vnext = 0;
this.value = null;
}
ServerVal.prototype.loadJSON = function(data)
{
this.ctime = new Date(data.ctime * 1000);
this.vnext = data.vnext;
this.value = data.value;
this.show();
}
ServerVal.prototype.show = function()
{
$(this.eCtime).empty().append(this.ctime.toString());
$(this.eVnext).empty().append(this.vnext);
$(this.eValue).empty().append(this.value);
if ($(this.eId).hasClass("hide")) {
$(this.eId).removeClass("hide");
}
}
ServerVal.prototype.start = function()
{
this.interval = setInterval($.proxy(this.process, this), 1000);
}
ServerVal.prototype.process = function()
{
if (0 >= this.vnext) {
$.getJSON("/randval/", $.proxy(this.loadJSON, this));
}
else {
this.vnext--;
$(this.eVnext).empty().append(this.vnext);
}
}
ServerVal.prototype.stop = function()
{
$(this.eId).addClass("hide");
clearInterval(this.interval);
this.interval = null;
this.vnext = 0;
}
// vim: set ts=4 sw=4: