Browse Source

be somewhat more verbose in frontend and update session live bar every 10th second (looks much more fluent *G*)

master
Georg Hopp 14 years ago
parent
commit
27457db468
  1. 16
      assets/js/serverval.js
  2. 6
      assets/js/session.js

16
assets/js/serverval.js

@ -42,7 +42,21 @@ ServerVal.prototype.process = function()
{ {
if (0 >= this.vnext) { if (0 >= this.vnext) {
$.getJSON("/randval/", $.proxy(this.loadJSON, this)) $.getJSON("/randval/", $.proxy(this.loadJSON, this))
.error($.proxy(function() {this.stop();}, this));
.error($.proxy(function(xhr) {
this.stop();
$("#msg").append("AJAX error (" + xhr.status + "): ");
switch(xhr.status) {
case 403:
$("#msg").append(
"Please log in to access this function.<br />");
break;
default:
$("#msg").append(
"Unhandled - " + xhr.responseText + "<br />");
break;
}
}, this));
$.getJSON("/sessinfo/", $.proxy(sess.loadJSON, sess)); $.getJSON("/sessinfo/", $.proxy(sess.loadJSON, sess));
} }

6
assets/js/session.js

@ -15,8 +15,8 @@ function Session(sId)
Session.prototype.loadJSON = function(data) Session.prototype.loadJSON = function(data)
{ {
this.id = ("0" == data.id)? "none" : data.id; this.id = ("0" == data.id)? "none" : data.id;
this.timeout = data.timeout;
this.timeleft = data.timeleft;
this.timeout = data.timeout * 10;
this.timeleft = data.timeleft * 10;
this.draw(); this.draw();
if (0 < this.timeleft) if (0 < this.timeleft)
@ -39,7 +39,7 @@ Session.prototype.draw = function()
Session.prototype.start = function() Session.prototype.start = function()
{ {
if (null === this.interval) { if (null === this.interval) {
this.interval = setInterval($.proxy(this.process, this), 1000);
this.interval = setInterval($.proxy(this.process, this), 100);
} }
} }

Loading…
Cancel
Save