summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Save <savetheinternet@tinyboard.org>2012-03-31 19:12:08 +1100
committerMichael Save <savetheinternet@tinyboard.org>2012-03-31 19:12:08 +1100
commitc0876c4e86080b71c80414de6db25f42b5bbaa42 (patch)
treec5e972c87a087c75a2057ffa40b81000e53c6ffc
parent2faaacd0f2981b6653974a40786dd90c1ef07882 (diff)
local-time.js: don't use jQuery
-rw-r--r--js/local-time.js21
1 files changed, 12 insertions, 9 deletions
diff --git a/js/local-time.js b/js/local-time.js
index 2c047e31..4a3b4deb 100644
--- a/js/local-time.js
+++ b/js/local-time.js
@@ -12,7 +12,7 @@
*
*/
-$(document).ready(function(){
+onload(function(){
var iso8601 = function(s) {
s = s.replace(/\.\d\d\d+/,""); // remove milliseconds
s = s.replace(/-/,"/").replace(/-/,"/");
@@ -24,19 +24,22 @@ $(document).ready(function(){
return [Math.pow(10, count - num.toString().length), num].join('').substr(1);
};
- $('time').each(function() {
- if(!$(this).text().match(/^\d+\/\d+\/\d+ \(\w+\) \d+:\d+:\d+$/))
- return;
+ var times = document.getElementsByTagName('time');
+
+ for(var i = 0; i < times.length; i++) {
+ if(!times[i].innerHTML.match(/^\d+\/\d+\/\d+ \(\w+\) \d+:\d+:\d+$/))
+ continue;
+
+ var t = iso8601(times[i].getAttribute('datetime'));
- var t = iso8601($(this).attr('datetime'));
- $(this).text(
+
+ times[i].innerHTML =
// date
zeropad(t.getMonth() + 1, 2) + "/" + zeropad(t.getDate(), 2) + "/" + t.getFullYear().toString().substring(2) +
" (" + ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"][t.getDay()] + ") " +
// time
- zeropad(t.getHours(), 2) + ":" + zeropad(t.getMinutes(), 2) + ":" + zeropad(t.getSeconds(), 2)
- );
- });
+ zeropad(t.getHours(), 2) + ":" + zeropad(t.getMinutes(), 2) + ":" + zeropad(t.getSeconds(), 2);
+ };
});