2006-10-25 02:41:41 +00:00
< ?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website : http :// www . sfiab . ca
Copyright ( C ) 2005 Sci - Tech Ontario Inc < info @ scitechontario . org >
Copyright ( C ) 2005 James Grant < james @ lightbox . org >
This program is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation , version 2.
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
General Public License for more details .
You should have received a copy of the GNU General Public License
along with this pr < input type = \ " submit \" value= \" " . i18n ( " Save Configuration " ) . " \" /> \n " ;
ogram ; see the file COPYING . If not , write to
the Free Software Foundation , Inc . , 59 Temple Place - Suite 330 ,
Boston , MA 02111 - 1307 , USA .
*/
?>
< ?
require ( " ../common.inc.php " );
2007-11-18 23:50:23 +00:00
send_header ( " Scheduler Status " ,
array ( 'Committee Main' => 'committee_main.php' ,
'Administration' => 'admin/index.php' ,
'Judges' => 'admin/judges.php' )
);
2006-10-25 02:41:41 +00:00
?>
< script type = " text/javascript " >
2006-10-25 19:10:27 +00:00
var starttime = 0 ;
var startpercent = 0 ;
var deltatime = 0 ;
var deltapercent = 0 ;
var avgtimeperpercent = 0 ;
var remainingpercent = 0 ;
var remainingtime = 0 ;
2006-10-25 02:41:41 +00:00
2010-02-18 15:54:31 +00:00
$ ( document ) . ready ( function () {
updateStatus ();
});
2006-10-25 03:19:54 +00:00
2010-02-18 15:54:31 +00:00
function updateStatus () {
var url = " judges_scheduler_status_output.php " ;
$ ( " #updatestatus " ) . html ( " Updating... " );
$ . get ( url , null , function ( data ) {
var obj = data . split ( " : " );
$ ( " #schedulerstatus " ) . html ( obj [ 1 ]);
if ( obj [ 0 ] == " -1 " ) {
$ ( " #schedulerpercent " ) . html ( " 100% " );
$ ( " #updatestatus " ) . html ( " Scheduling Complete " );
$ ( " #schedulereta " ) . html ( " Complete " );
2006-10-25 03:19:54 +00:00
}
2010-02-18 15:54:31 +00:00
else {
$ ( " #schedulerpercent " ) . html ( obj [ 0 ] + " % " );
2006-10-25 03:19:54 +00:00
setTimeout ( 'updateStatus()' , 5000 );
2010-02-18 15:54:31 +00:00
$ ( " #updatestatus " ) . html ( " Updating... Done! " );
2006-10-25 03:19:54 +00:00
setTimeout ( 'clearUpdatingMessage()' , 500 );
2006-10-25 19:10:27 +00:00
var currentTime = new Date ();
2010-02-18 15:54:31 +00:00
if ( starttime == 0 ) {
2006-10-25 19:10:27 +00:00
starttime = currentTime . getTime ();
startpercent = obj [ 0 ];
}
deltatime = currentTime . getTime () - starttime ;
deltapercent = obj [ 0 ] - startpercent ;
avgtimeperpercent = deltatime / deltapercent ;
remainingpercent = 100 - obj [ 0 ];
remainingtime = remainingpercent * avgtimeperpercent ;
2010-03-25 21:22:40 +00:00
if ( remainingtime > 0 && remainingtime != " Infinity " && obj [ 0 ] > 0 ) {
2010-02-18 15:54:31 +00:00
$ ( " #schedulereta " ) . html ( format_duration ( Math . round ( remainingtime / 1000 )));
2010-03-25 21:22:40 +00:00
}
2006-10-25 19:10:27 +00:00
else
2010-02-18 15:54:31 +00:00
$ ( " #schedulereta " ) . html ( " Calculating... " );
2006-10-25 03:19:54 +00:00
}
2010-02-18 15:54:31 +00:00
});
}
function clearUpdatingMessage () {
$ ( " #updatestatus " ) . html ( " Waiting... " );
}
function format_duration ( seconds ) {
/*
'1 year|:count years' => 31536000 ,
'1 week|:count weeks' => 604800 ,
'1 day|:count days' => 86400 ,
'1 hour|:count hours' => 3600 ,
'1 min|:count min' => 60 ,
'1 sec|:count sec' => 1 );
*/
var s = seconds ;
2010-02-18 16:01:46 +00:00
var output = '' ;
var pl = '' ;
2010-02-18 15:54:31 +00:00
if ( s > 86400 ) {
var days = Math . floor ( s / 86400 )
s -= days * 86400 ;
2010-02-18 16:01:46 +00:00
if ( days > 1 ) pl = 's' ; else pl = '' ;
output += days + ' day' + pl + ' ' ;
2010-02-18 15:54:31 +00:00
}
if ( s > 3600 ) {
var hours = Math . floor ( s / 3600 )
s -= hours * 3600 ;
2010-02-18 16:01:46 +00:00
if ( hours > 1 ) pl = 's' ; else pl = '' ;
output += hours + ' hour' + pl + ' ' ;
2006-10-25 02:41:41 +00:00
}
2010-02-18 15:54:31 +00:00
if ( s > 60 ) {
var minutes = Math . floor ( s / 60 )
s -= minutes * 60 ;
2010-02-18 16:01:46 +00:00
if ( minutes > 1 ) pl = 's' ; else pl = '' ;
output += minutes + ' minute' + pl + ' ' ;
2006-10-25 02:41:41 +00:00
}
2010-02-18 16:01:46 +00:00
if ( s > 1 ) pl = 's' ; else pl = '' ;
2010-03-25 22:11:19 +00:00
output += s + ' second' + pl
2010-02-18 15:54:31 +00:00
return output ;
2006-10-25 02:41:41 +00:00
}
2010-02-18 15:54:31 +00:00
2006-10-25 02:41:41 +00:00
</ script >
< ?
2010-02-18 15:54:31 +00:00
if ( $config [ 'judge_scheduler_percent' ] == " -1 " ) {
2006-10-25 02:41:41 +00:00
echo i18n ( " The judge scheduler is not currently running " );
echo " <br /> " ;
echo " <br /> " ;
echo " <a href= \" judges_schedulerconfig.php \" > " . i18n ( " Judges Scheduler Configuration " ) . " </a> " ;
}
2010-02-18 15:54:31 +00:00
else {
2006-10-25 02:41:41 +00:00
echo " <table> " ;
echo " <tr><td> " . i18n ( " Scheduler status " ) . " :</td><td><div id= \" schedulerstatus \" style= \" font-weight: bold; \" ></div></td></tr> " ;
echo " <tr><td> " . i18n ( " Scheduler percent " ) . " :</td><td><div id= \" schedulerpercent \" style= \" font-weight: bold; \" ></div></td></tr> " ;
2006-10-25 19:10:27 +00:00
echo " <tr><td> " . i18n ( " Scheduler ETA " ) . " :</td><td><div id= \" schedulereta \" style= \" font-weight: bold; \" ></div></td></tr> " ;
2006-10-25 03:19:54 +00:00
echo " <tr><td align= \" center \" colspan= \" 2 \" ><div id= \" updatestatus \" style= \" font-weight: bold; text-align: center; \" ></div></td></tr> " ;
2006-10-25 02:41:41 +00:00
echo " </table> " ;
2006-10-25 03:19:54 +00:00
echo " <br /> " ;
2007-12-27 00:40:59 +00:00
echo i18n ( " When scheduling is finished, the following links will be useful " );
2006-10-25 03:19:54 +00:00
echo " <br /> " ;
echo " <a href= \" judges_teams.php \" > " . i18n ( " Manage Judge Teams " ) . " </a> " ;
echo " <br /> " ;
echo " <a href= \" judges_teams_members.php \" > " . i18n ( " Manage Judge Members " ) . " </a> " ;
echo " <br /> " ;
echo " <a href= \" reports.php \" > " . i18n ( " Print/Export Reports " ) . " </a> " ;
echo " <br /> " ;
echo " <br /> " ;
2011-03-15 20:28:10 +00:00
echo " Note: If you are using Windows Internet Explorer and do not see status updates do this:<br /> Click menu bar 'Tools' then 'Internet Options'.<br /> In the 'General' Tab under 'Browsing history' click 'Settings'.<br /> Under 'Check for newer versions of stored pages:'<br /> Select the option 'Every time I visit the webpage'.<br /> Click OK then OK " ;
2006-10-25 02:41:41 +00:00
}
send_footer ();
?>