gitweb.js: Add UI for selecting common timezone to display dates
This will modify HTML, add CSS rules and add DOM event handlers so that clicking on any date (the common part, not the localtime part) will display a drop down menu to choose the timezone to change to. Currently menu displays only the following timezones: utc local -1200 -1100 ... +1100 +1200 +1300 +1400 In timezone selection menu each timezone is +1hr to the previous. The code is capable of handling fractional timezones, but those have not been added to the menu. All changes are saved to a cookie, so page changes and closing / reopening browser retains the last known timezone setting used. [jn: Changed from innerHTML to DOM, moved to event delegation for onclick to trigger menu, added close button and cookie refreshing] Helped-by: Kevin Cernekee <cernekee@gmail.com> Signed-off-by: John 'Warthog9' Hawley <warthog9@eaglescrag.net> Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
291e52bd19
commit
2ae8da2552
@ -64,7 +64,7 @@ function padLeft(input, width, ch) {
|
||||
|
||||
|
||||
/* ............................................................ */
|
||||
/* Ajax */
|
||||
/* Handling browser incompatibilities */
|
||||
|
||||
/**
|
||||
* Create XMLHttpRequest object in cross-browser way
|
||||
@ -88,6 +88,31 @@ function createRequestObject() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert rule giving specified STYLE to given SELECTOR at the end of
|
||||
* first CSS stylesheet.
|
||||
*
|
||||
* @param {String} selector: CSS selector, e.g. '.class'
|
||||
* @param {String} style: rule contents, e.g. 'background-color: red;'
|
||||
*/
|
||||
function addCssRule(selector, style) {
|
||||
var stylesheet = document.styleSheets[0];
|
||||
|
||||
var theRules = [];
|
||||
if (stylesheet.cssRules) { // W3C way
|
||||
theRules = stylesheet.cssRules;
|
||||
} else if (stylesheet.rules) { // IE way
|
||||
theRules = stylesheet.rules;
|
||||
}
|
||||
|
||||
if (stylesheet.insertRule) { // W3C way
|
||||
stylesheet.insertRule(selector + ' { ' + style + ' }', theRules.length);
|
||||
} else if (stylesheet.addRule) { // IE way
|
||||
stylesheet.addRule(selector, style);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ............................................................ */
|
||||
/* Support for legacy browsers */
|
||||
|
||||
|
Reference in New Issue
Block a user