More admin clock time increments

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
 Update contrib/admin/media/js/admin/DateTimeShortcuts addClock function, replace all "quickElement" lines with the following 
*/
        var interval_mins = 30; // minutes between displayed times
        var columns = 4;        // number of columns in popup
        var total_intervals = 24 * 60 / interval_mins;
        var time = new Date(0,0,0,0,0,0,0);
        var midnight = new Date(0,0,0,0,0,0,0); 
        var noon = new Date(0,0,0,12,0,0,0);
        for (var si=0; si<columns; si++) {
            time_list = quickElement('ul', clock_box, '');
            time_list.className = 'timelist';
            if (si == columns-1) {
                time_list.id = 'timelist-end';
            }
            var this_col_count = total_intervals / columns;
            for (var sj=0; sj<this_col_count; sj++) {
                var time_text = null;
                if (time.getTime() == midnight.getTime())
                    time_text = gettext("Midnight");
                else if (time.getTime() == noon.getTime())
                    time_text = gettext("Noon");
                else {
                    var hours = time.getHours();
                    hours = hours > 12 ? hours - 12 : hours;
                    time_text = "" + (hours == 0 ? 12 : hours);
                    var mins = time.getMinutes();
                    time_text += ":" + (mins > 9 ? "" : "0") + mins;
                    time_text += (hours >= 12 ? " PM" : " AM");
                } 
                quickElement("a", quickElement("li", time_list, ""), time_text, "href", "javascript:DateTimeShortcuts.handleClockQuicklink(" + num + ", '" + time.getHourMinute() + "');");
                time = new Date(time.getTime() + (interval_mins * 60 * 1000)); // interval * seconds in a minute * millis in second
            }
        }

More like this

  1. Increment a variable in a Template by sachingupta006 2 years, 1 month ago
  2. Django Incremental Counter Tag by gwrtheyrn 2 years, 4 months ago
  3. More informative error mailings by kcarnold 6 years, 1 month ago
  4. SelectTimeWidget by bradmontgomery 5 years, 5 months ago
  5. Hidden Date Display Widget for Admin by andrew.schoen 4 years, 9 months ago

Comments

robharvey (on April 17, 2007):

CSS changes required to support columns:

.clockbox {
    width:              25em;
}

.clockbox h2 {
    text-align:         center;
}

ul.timelist {
    float:              left;
    padding-right:      5px;
    padding-left:       5px;
    border-right:       1px solid lightblue;
}

ul.timelist a:visited {
    color:              black;
}

ul#timelist-end {
    float:              none;
}

#

(Forgotten your password?)