Inanis Glass theme for Wordpress: Set the clock to 24hr format
I have installed Inanis Glass theme (v. 1.2) for my Wordpress blog and it is really an amazing theme. It was very easy to install (unlike other themes where something is always missing or not fitting). I made small changes here and there to make it work the way I want. For example, it showed a message on the pages or articles where I turned off the comments that the comments are off etc. I modified it to remove that. Made few more CSS changes.
When I visited the author’s website I found few requests to show the clock in 24hrs format. When I looked at the javascript (functions.js) for the theme I found that the “clock” function is compressed by http://javascriptcompressor.com/. When I visited that site to see if they have any decompressor then I found a contribution on their forum which unpacks/decompresses the javascript – read about it on their forum http://javascriptcompressor.com/forums/p/9/42.aspx – and decompressed the “clock” function.
Decompressed/unpacked function looks like:
function init() {
timeDisplay=document.createTextNode("");
document.getElementById("clockhr").appendChild(timeDisplay);
timeDisplay1=document.createTextNode("");
document.getElementById("clockmin").appendChild(timeDisplay1);
timeDisplay2=document.createTextNode("");
document.getElementById("clockpart").appendChild(timeDisplay2)
}
function updateClock() {
var currentTime=new Date();
var currentHours=currentTime.getHours();
var currentMinutes=currentTime.getMinutes();
currentMinutes=(currentMinutes<10?"0":"")+currentMinutes;
var timeOfDay=(currentHours<12)?"AM":"PM";
currentHours=(currentHours>12)?currentHours-12:currentHours;
currentHours=(currentHours===0)?12:currentHours;
document.getElementById("clockhr").firstChild.nodeValue=currentHours;
document.getElementById("clockmin").firstChild.nodeValue=currentMinutes;
document.getElementById("clockpart").firstChild.nodeValue=timeOfDay
}
Basically the Javascript function used to find the current time – getHours() – returns the hour in 24hrs format. But to display the clock in 12hrs format the author has done some math. So if anyone wants to display 24hrs format clock comment out line number 14, 15, 16 and 19. To replace the function you can use the site above to re-compress the function or comment the existing function in functions.js file (clock function) and paste this decompressed version in the file.
Note: As I understand javascriptcompressor.com is used to pack/compress your javascript, not to encrypt it or hide it by any means. It is compressed so that it is either unreadable or smaller in size.
![[del.icio.us]](http://ehsan.bdwebwork.com/wp-content/plugins/bookmarkify/delicious.png)
![[Digg]](http://ehsan.bdwebwork.com/wp-content/plugins/bookmarkify/digg.png)
![[Facebook]](http://ehsan.bdwebwork.com/wp-content/plugins/bookmarkify/facebook.png)
![[Feed Me Links]](http://ehsan.bdwebwork.com/wp-content/plugins/bookmarkify/feedmelinks.png)
![[Google]](http://ehsan.bdwebwork.com/wp-content/plugins/bookmarkify/google.png)
![[LinkedIn]](http://ehsan.bdwebwork.com/wp-content/plugins/bookmarkify/linkedin.png)
![[StumbleUpon]](http://ehsan.bdwebwork.com/wp-content/plugins/bookmarkify/stumbleupon.png)
![[Technorati]](http://ehsan.bdwebwork.com/wp-content/plugins/bookmarkify/technorati.png)
![[Twitter]](http://ehsan.bdwebwork.com/wp-content/plugins/bookmarkify/twitter.png)


