git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCHv3 00/13] gitweb: Change timezone in dates using JavaScript

From
Jakub Narebski <jnareb@gmail.com>
Date
Apr 28, 2011, 19:03 UTC
Message-ID
<1304017451-12283-1-git-send-email-jnareb@gmail.com>
This is third version of this series.
First version was sent as
  [PATCH 00/11] gitweb: Change timezone
  http://thread.gmane.org/gmane.comp.version-control.git/171212
Second version was sent as
  [PATCHv2 00/11] gitweb: Change timezone in dates using JavaScript
  http://thread.gmane.org/gmane.comp.version-control.git/171600

This version fixes the issue with Chrome / Chromium that was known in previous version of this series (reported by Kevin Cernekee). Additionally gitweb.js (or rather js/adjust-timezone.js that composes part of gitweb.js) uses safer techique. This patch was sent as [PATCHv3 10/11] amending original [PATCHv2/RFC 10/11] in previous version of series.

This version of series also include 01/13 patch that fixes issue with git-instaweb target (reported by Junio C Hamano). Also new 02/13 patch is a cleanup noticed while writing 01/13. Those two patches were sent as [PATCH -01/11] and [PATCH 12/11] in thread with previous version of this series.

Some patches include additional Helped-by lines.

This is split version (with assorted cleanups) of J.H. patch adding JavaScript-base ability to change timezone in which dates are displayed.

  [PATCH 0/1] Gitweb: Change timezone
    [PATCH 1/1] gitweb: javascript ability to adjust time based on timezone
  Message-Id: <1300925335-3212-1-git-send-email-warthog9@eaglescrag.net>
  http://thread.gmane.org/gmane.comp.version-control.git/169384/focus=169881

Below there is copy of original J.H. announcement: JH> JH> This is just a javascript implementation of Kevin's localtime JH> feature. It's pretty straight forward, though date handling in JH> Javascript is, special (head bangingly so). JH> JH> This should be good to run on any browser, with the safe fallback JH> of UTC being the default output should Javascript not work / be JH> available.

Interdiff to a174d61 ('jn/gitweb-js' from Apr 27, 2011): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It is not really necessary to replace it with this series, as can be seen from the interdiff below:

diff --git a/gitweb/static/js/adjust-timezone.js b/gitweb/static/js/adjust-timezone.js
index a6e55d5..0c67779 100644
--- a/gitweb/static/js/adjust-timezone.js
+++ b/gitweb/static/js/adjust-timezone.js
@@ -67,10 +67,11 @@ function fixDatetimeTZ(tz, tzClassName, nochange) {
 
 		curElement.title = 'Click to change timezone';
 		if (!nochange) {
-			var epoch = parseRFC2822Date(curElement.innerHTML);
+			// we use *.firstChild.data (W3C DOM) instead of *.innerHTML
+			// as the latter doesn't always work everywhere in every browser
+			var epoch = parseRFC2822Date(curElement.firstChild.data);
 			var adjusted = formatDateRFC2882(epoch, tz);
 
-			// curElement.innerHTML = adjusted; // does not work for Mozilla 1.17.2
 			curElement.firstChild.data = adjusted;
 		}
 	}
@@ -196,12 +197,13 @@ function removeChangeTZForm(documentFragment, target, tzClassName) {
 
 	// timezone selection UI was appended as last child
 	// see also displayChangeTZForm function
-	var removed = container.removeChild(popup);
+	var removed = popup.parentNode.removeChild(popup);
 	if (documentFragment.firstChild !== removed) { // the only child
 		// re-append it so it would be available for next time
 		documentFragment.appendChild(removed);
 	}
 	// all of inline style was added by this script
+	// it is not really needed to remove it, but it is a good practice
 	container.removeAttribute('style');
 
 	return documentFragment;


Table of contents:
~~~~~~~~~~~~~~~~~~
* [PATCH 01/13] git-instaweb: Simplify build dependency on gitweb
  [PATCH 02/13] Remove gitweb/gitweb.cgi and other legacy targets from main Makefile

  New in this series, previously appeared as reply-to add-ons to
  previous version of series:
    http://thread.gmane.org/gmane.comp.version-control.git/171600/focus=171792
    http://thread.gmane.org/gmane.comp.version-control.git/171600/focus=171802

* [PATCH 03/13] gitweb: Split JavaScript for maintability, combining on build
  [PATCH 04/13] gitweb.js: Update and improve comments in JavaScript files
  [PATCH 05/13] gitweb.js: Provide default values for padding in padLeftStr and padLeft
  [PATCH 06/13] gitweb.js: Extract and improve datetime handling
  [PATCH 07/13] gitweb.js: Introduce code to handle cookies from JavaScript
  [PATCH 08/13] gitweb.js: Provide getElementsByClassName method (if it not exists)
  [PATCH 09/13] gitweb: Refactor generating of long dates into format_timestamp_html
  [PATCH 10/13] gitweb: Unify the way long timestamp is displayed

  Minor cosmetic changes in commit messages.

* [PATCH 11/13] gitweb: JavaScript ability to adjust time based on timezone

  Futureproofing against possible changes in gitweb output layout by
  using curElement.firstChild.data and not curElement.innerHTML... and
  we are more consistent as we need to use the former way for setting,
  see added comment in the code.

* [PATCH 12/13] gitweb.js: Add UI for selecting common timezone to display dates

  Includes fix for Chromium / Google Chrome behavior by not using
  'onblur' handler (which doesn't work anyway) from

    [PATCHv3 10/11] gitweb.js: Add UI for selecting common timezone to display dates
    http://thread.gmane.org/gmane.comp.version-control.git/171600/focus=171632

  It additionaly uses safe form of DOM manipulation:

    element.parentNode.removeChild(element);

* [PATCH 13/13] gitweb: Make JavaScript ability to adjust timezones configurable

  Patch unchanged compared to previous version.

Shortlog:
~~~~~~~~~
Jakub Narebski (11):
  git-instaweb: Simplify build dependency on gitweb
  Remove gitweb/gitweb.cgi and other legacy targets from main Makefile
  gitweb: Split JavaScript for maintability, combining on build
  gitweb.js: Update and improve comments in JavaScript files
  gitweb.js: Provide default values for padding in padLeftStr and
    padLeft
  gitweb.js: Extract and improve datetime handling
  gitweb.js: Introduce code to handle cookies from JavaScript
  gitweb.js: Provide getElementsByClassName method (if it not exists)
  gitweb: Refactor generating of long dates into format_timestamp_html
  gitweb: Unify the way long timestamp is displayed
  gitweb: Make JavaScript ability to adjust timezones configurable

John 'Warthog9' Hawley (2):
  gitweb: JavaScript ability to adjust time based on timezone
  gitweb.js: Add UI for selecting common timezone to display dates

Diffstat:
~~~~~~~~~
 .gitignore                                         |    1 +
 Makefile                                           |   28 +--
 gitweb/Makefile                                    |   19 +-
 gitweb/gitweb.perl                                 |   76 +++--
 gitweb/static/gitweb.css                           |   33 ++
 gitweb/static/js/README                            |   20 ++
 gitweb/static/js/adjust-timezone.js                |  330 ++++++++++++++++++++
 .../static/{gitweb.js => js/blame_incremental.js}  |  228 +-------------
 gitweb/static/js/javascript-detection.js           |   43 +++
 gitweb/static/js/lib/common-lib.js                 |  224 +++++++++++++
 gitweb/static/js/lib/cookies.js                    |  114 +++++++
 gitweb/static/js/lib/datetime.js                   |  176 +++++++++++
 12 files changed, 1024 insertions(+), 268 deletions(-)
 create mode 100644 gitweb/static/js/README
 create mode 100644 gitweb/static/js/adjust-timezone.js
 rename gitweb/static/{gitweb.js => js/blame_incremental.js} (74%)
 create mode 100644 gitweb/static/js/javascript-detection.js
 create mode 100644 gitweb/static/js/lib/common-lib.js
 create mode 100644 gitweb/static/js/lib/cookies.js
 create mode 100644 gitweb/static/js/lib/datetime.js

Dirstat:
~~~~~~~~
  39.2% gitweb/static/js/lib/
  32.0% gitweb/static/js/
  17.9% gitweb/static/
   8.5% gitweb/
-- 
1.7.3
Next: Jakub Narebski
Message 1 of 14 in “[PATCHv3 00/13] gitweb: Change timezone in dates using JavaScript”
  1. Jakub NarebskiApr 28, 2011
  2. 01/13 git-instaweb: Simplify build dependency on gitwebJakub Narebski, Apr 28, 2011
  3. 02/13 Remove gitweb/gitweb.cgi and other legacy targets from main MakefileJakub Narebski, Apr 28, 2011
  4. 03/13 gitweb: Split JavaScript for maintability, combining on buildJakub Narebski, Apr 28, 2011
  5. 04/13 gitweb.js: Update and improve comments in JavaScript filesJakub Narebski, Apr 28, 2011
  6. 05/13 gitweb.js: Provide default values for padding in padLeftStr and padLeftJakub Narebski, Apr 28, 2011
  7. 06/13 gitweb.js: Extract and improve datetime handlingJakub Narebski, Apr 28, 2011
  8. 07/13 gitweb.js: Introduce code to handle cookies from JavaScriptJakub Narebski, Apr 28, 2011
  9. 08/13 gitweb.js: Provide getElementsByClassName method (if it not exists)Jakub Narebski, Apr 28, 2011
  10. 09/13 gitweb: Refactor generating of long dates into format_timestamp_htmlJakub Narebski, Apr 28, 2011
  11. 10/13 gitweb: Unify the way long timestamp is displayedJakub Narebski, Apr 28, 2011
  12. 11/13 gitweb: JavaScript ability to adjust time based on timezoneJakub Narebski, Apr 28, 2011
  13. 12/13 gitweb.js: Add UI for selecting common timezone to display datesJakub Narebski, Apr 28, 2011
  14. 13/13 gitweb: Make JavaScript ability to adjust timezones configurableJakub Narebski, Apr 28, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.