blob: 684b68a3428e63380c05b5a00a2e153420384a1a [file] [log] [blame]
Felix Meschberger2247fd42010-02-17 09:12:34 +00001/* shuts down server after [num] seconds */
2function shutdown(num, formname, elemid) {
3 var elem = $('#' + elemid);
4 var secs=" second";
5 var ellipsis="...";
6 if (num > 0) {
7 if (num != 1) {
8 secs+="s";
9 }
10 elem.html(num+secs+ellipsis);
11 setTimeout('shutdown('+(--num)+', "'+formname+'", "'+elemid+'")',1000);
12 } else {
13 $('#' + formname).submit();
14 }
15}
16
17/* aborts server shutdown and redirects to [target] */
18function abort(target) {
19 top.location.href=target;
20}
21
22/* displays a date in the user's local timezone */
23function localTm(time) {
24 return (time ? new Date(time) : new Date()).toLocaleString();
25}
26/* fill in the data */
27$(document).ready(function() {
28 if(typeof statData == 'undefined') return;
29 for(i in statData) {
30 var target = $('#' + i);
31 if (target.val()) {
32 target.val(statData[i]);
33 } else {
34 target.text(statData[i]);
35 }
36 }
37 $('#lastStarted').text(localTm(statData.lastStarted));
38 var st = statData.shutdownTimer;
39 $('#shutdownform').css('display', st ? 'none' : 'block');
40 $('#shutdownform2').css('display', st ? 'block' : 'none');
41 $('#shutdown_type').val(statData.shutdownType);
42});