81 | | time_list = quickElement('ul', clock_box, ''); |
82 | | time_list.className = 'timelist'; |
83 | | quickElement("a", quickElement("li", time_list, ""), gettext("Now"), "href", "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", new Date().getHourMinuteSecond());") |
84 | | quickElement("a", quickElement("li", time_list, ""), gettext("Midnight"), "href", "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", '00:00:00');") |
85 | | quickElement("a", quickElement("li", time_list, ""), gettext("6 a.m."), "href", "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", '06:00:00');") |
86 | | quickElement("a", quickElement("li", time_list, ""), gettext("Noon"), "href", "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", '12:00:00');") |
87 | | |
| 84 | var interval_mins = 30; // minutes between displayed times |
| 85 | var columns = 4; // number of columns in popup |
| 86 | var total_intervals = 24 * 60 / interval_mins; |
| 87 | var time = new Date(0,0,0,0,0,0,0); |
| 88 | var midnight = new Date(0,0,0,0,0,0,0); |
| 89 | var noon = new Date(0,0,0,12,0,0,0); |
| 90 | for (var si=0; si<columns; si++) { |
| 91 | time_list = quickElement('ul', clock_box, ''); |
| 92 | time_list.className = 'timelist'; |
| 93 | if (si == columns-1) { |
| 94 | time_list.id = 'timelist-end'; |
| 95 | } |
| 96 | var this_col_count = total_intervals / columns; |
| 97 | for (var sj=0; sj<this_col_count; sj++) { |
| 98 | var time_text = null; |
| 99 | if (time.getTime() == midnight.getTime()) |
| 100 | time_text = gettext("Midnight"); |
| 101 | else if (time.getTime() == noon.getTime()) |
| 102 | time_text = gettext("Noon"); |
| 103 | else { |
| 104 | var hrs = time.getHours(); |
| 105 | if (hrs > 12) { |
| 106 | hrs -= 12; |
| 107 | } |
| 108 | else if (hrs == 0) { |
| 109 | hrs = 12; |
| 110 | } |
| 111 | var mins = "" + time.getMinutes(); |
| 112 | if (mins == "0") { |
| 113 | mins = "00" |
| 114 | } |
| 115 | var ap = time.getHours() >= 12 ? "PM" : "AM"; |
| 116 | time_text = "" + hrs + ":" + mins + " " + ap; |
| 117 | } |
| 118 | quickElement("a", quickElement("li", time_list, ""), time_text, "href", "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", '" + time.getHourMinute() + "');"); |
| 119 | time = new Date(time.getTime() + (interval_mins * 60 * 1000)); // interval * seconds in a minute * millis in second |
| 120 | } |
| 121 | } |