local-time.js: make it work with thread expand etc; BEWARE IT NOW NEEDS JQUERY TO BE LOADED BEFORE
This commit is contained in:
parent
f98d5bdd18
commit
46ebcbf51d
@ -6,6 +6,7 @@
|
|||||||
* Copyright (c) 2012 Michael Save <savetheinternet@tinyboard.org>
|
* Copyright (c) 2012 Michael Save <savetheinternet@tinyboard.org>
|
||||||
*
|
*
|
||||||
* Usage:
|
* Usage:
|
||||||
|
* $config['additional_javascript'][] = 'js/jquery.min.js';
|
||||||
* $config['additional_javascript'][] = 'js/local-time.js';
|
* $config['additional_javascript'][] = 'js/local-time.js';
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -22,7 +23,8 @@ onready(function(){
|
|||||||
return [Math.pow(10, count - num.toString().length), num].join('').substr(1);
|
return [Math.pow(10, count - num.toString().length), num].join('').substr(1);
|
||||||
};
|
};
|
||||||
|
|
||||||
var times = document.getElementsByTagName('time');
|
var do_localtime = function(elem) {
|
||||||
|
var times = elem.getElementsByTagName('time');
|
||||||
|
|
||||||
for(var i = 0; i < times.length; i++) {
|
for(var i = 0; i < times.length; i++) {
|
||||||
if(typeof times[i].getAttribute('data-local') == 'undefined')
|
if(typeof times[i].getAttribute('data-local') == 'undefined')
|
||||||
@ -39,5 +41,13 @@ onready(function(){
|
|||||||
// time
|
// 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);
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
do_localtime(document);
|
||||||
|
|
||||||
|
// allow to work with auto-reload.js, etc.
|
||||||
|
$(document).bind('new_post', function(e, post) {
|
||||||
|
do_localtime(post);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user