Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / mod / quiz / jsclock.php
blobca2ff1cca26f93b82d45be2b62e671058e76cf37
1 <?php // $Id$
2 defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
3 ?>
5 <script text="text/javascript">
6 //<![CDATA[
7 /// This Javascript clock provides a little countdown in the title bar
9 var timerID = null;
10 var timerRunning = false;
11 var secondsleft = <?php echo $secondsleft ?>;
12 var titleafter = '<?php echo format_string($quiz->name) ?>';
13 var titlebefore = '<?php echo get_string("countdown", "quiz").": " ?>';
14 var alertmessage = '<?php print_string("countdownfinished", "quiz") ?>';
15 var alertmessage10 = '<?php print_string("countdowntenminutes", "quiz") ?>';
17 function stopclock() {
18 if (timerRunning) {
19 clearTimeout(timerID);
20 timerRunning = false;
24 function startclock() {
25 stopclock();
26 showtime();
29 function showtime() {
31 secondsleft = secondsleft - 1;
33 if (secondsleft == 600) {
34 alert(alertmessage10);
37 if (secondsleft == 0) {
38 stopclock();
39 document.title = titleafter;
40 return alert(alertmessage);
42 } else {
43 current = secondsleft;
45 var hours = Math.floor( current / 3600 );
46 current = current - (hours*3600);
48 var minutes = Math.floor( current / 60 );
49 current = current - (minutes*60);
51 var seconds = current;
53 var timeValue = "" + hours;
54 timeValue += ((minutes < 10) ? ":0" : ":") + minutes;
55 timeValue += ((seconds < 10) ? ":0" : ":") + seconds;
57 document.title = titlebefore+timeValue+' '+titleafter;
58 timerID = setTimeout("showtime()",1000);
59 timerRunning = true;
63 document.onLoad = startclock();
66 //]]>
67 </script>