[projects/pld-builder.new] convert timezone script to jQuery

glen glen at pld-linux.org
Sat Apr 20 18:08:48 CEST 2013


commit c25f6a1a39372b6cbbccddc29968cbeacc5238c4
Author: Elan Ruusamäe <glen at pld-linux.org>
Date:   Sat Apr 20 19:07:59 2013 +0300

    convert timezone script to jQuery

 PLD_Builder/bqueue.py |  1 +
 PLD_Builder/script.js | 23 ++++++++++-------------
 2 files changed, 11 insertions(+), 13 deletions(-)
---
diff --git a/PLD_Builder/bqueue.py b/PLD_Builder/bqueue.py
index aff32e9..65546bf 100644
--- a/PLD_Builder/bqueue.py
+++ b/PLD_Builder/bqueue.py
@@ -43,6 +43,7 @@ class B_Queue:
     <link rel="Shortcut Icon" href="http://www.pld-linux.org/favicon.ico"/>
         <title>PLD builder queue</title>
         <link rel="stylesheet" type="text/css" charset="utf-8" media="all" href="style.css">
+        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
         <script type="text/javascript" src="script.js"></script>
     </head>
 <body>\n"""
diff --git a/PLD_Builder/script.js b/PLD_Builder/script.js
index 8c9c017..e6bd098 100644
--- a/PLD_Builder/script.js
+++ b/PLD_Builder/script.js
@@ -1,20 +1,17 @@
+jQuery(function($) {
+	update_tz();
 
-// update date stamps to reflect viewers timezone
-function update_tz(t) {
-	var el, off, dt,
-		collection = document.getElementsByTagName('span');
-	for (off in collection) {
-		el = collection[off];
-		if (el.id == 'tz') {
-			dt = new Date(el.innerHTML).toString();
+	// update date stamps to reflect viewers timezone
+	function update_tz() {
+		$('span#tz').each(function(i, el) {
+			var $el = $(el);
+			dt = new Date($el.text()).toString();
 			// strip timezone name, it is usually wrong when not initialized
 			// from TZ env, but reverse calculated from os data
 			dt = dt.replace(/\s+\(.+\)/, "");
 			// strip "GMT"
 			dt = dt.replace(/GMT/, "");
-			el.innerHTML = dt;
-		}
+			$el.text(dt);
+		});
 	}
-}
-
-window.onload = update_tz;
+});
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/pld-builder.new.git/commitdiff/c25f6a1a39372b6cbbccddc29968cbeacc5238c4



More information about the pld-cvs-commit mailing list