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.
 
 
 
 
 
 

69 lines
1.3 KiB

function Session(sId)
{
this.eSid = $(sId + " span");
this.canvas = $(sId + " canvas").get(0);
this.context = this.canvas.getContext("2d");
this.id = "none"
this.timeout = 0;
this.timeleft = 0;
this.interval = null;
this.draw();
}
Session.prototype.loadJSON = function(data)
{
this.id = ("0" == data.id)? "none" : data.id;
this.timeout = data.timeout;
this.timeleft = data.timeleft;
this.draw();
if (0 < this.timeleft)
this.start();
}
Session.prototype.draw = function()
{
this.eSid.empty().append(this.id);
this.context.fillStyle = "rgb(255, 0, 0)";
this.context.fillRect(0, 0, this.canvas.width, this.canvas.height);
this.context.fillStyle = "rgb(0, 255, 0)";
this.context.fillRect(0, 0,
this.canvas.width / this.timeout * this.timeleft,
this.canvas.height);
}
Session.prototype.start = function()
{
if (null === this.interval) {
this.interval = setInterval($.proxy(this.process, this), 1000);
}
}
Session.prototype.process = function()
{
if (0 >= this.timeleft) {
this.stop();
}
else {
this.timeleft--;
this.draw();
}
}
Session.prototype.stop = function()
{
clearInterval(this.interval);
this.interval = null;
this.id = "none";
this.timeout = 0;
this.timeleft = 0;
this.draw();
}
// vim: set ts=4 sw=4: