Felix Meschberger | 2247fd4 | 2010-02-17 09:12:34 +0000 | [diff] [blame] | 1 | /* shuts down server after [num] seconds */ |
| 2 | function 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] */ |
| 18 | function abort(target) { |
| 19 | top.location.href=target; |
| 20 | } |
| 21 | |
| 22 | /* displays a date in the user's local timezone */ |
| 23 | function 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 | }); |