I'm trying to create a clock that allows me to use a completely different set of images for the hours minutes and seconds for the iPhone. This is what I currently have which works correctly in Google Chrome, but doesn't work on the iPhone. If there is a completely different, better, or more efficient way to do this, then that would be great. I'm completely new to javascript hence the reason I;m using this already built code.
Basically I get only the minutes and the second images to show up and they are sporadic. Kinda hard to explain because everytime I respring the phone, something different happens, as in the second images not displaying past 25 seconds or so, or the time/images just freeze. Any help to get this to work would be great. Thanks
Edit: I was able to get it to work on the iPhone using the previous code. For anyone else that wants to do this, I'll post the revised code that worked for me. I also added code to display a LockBackground image.
To make a theme for the iPhone using this code, make a new folder in the Themes section of the phone, name it yourname.theme (yourname being whatever name you choose). Go to this link and download the attachments.
Now rename the jsclock.htm.txt file to LockBackground. html, then place it in the yourname.theme folder. Next, take all the images from the folders and place them all in the yourname.theme folder (they have to be loose and not in the folders they came in). All that's left is to place your image that you want as your background image, just name it LockBackground. png and place it in the theme folder as well. That's it!
Now you can have separate images for each individual hour, minute, and second.
Thank you Dormilich for your responses. I was still having problems with the code you gave me (I'm sure it was just my fault), but I found this to work so I'll just stick with it.
Here's the revised code:
Code:
<?xml version="1.0" encoding="UTF-16"?>
<html>
<head>
<script type="text/javascript">
/***********************************************
* JavaScript Image Clock- by JavaScript Kit (www.javascriptkit.com)
* This notice must stay intact for usage
* Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and 100s more
***********************************************/
function show()
{
var Digital=new Date();
var sec=Digital.getSeconds();
var min=Digital.getMinutes();
var hrs=Digital.getHours();
if (hrs>=12)
{hrs=hrs-12
}
if (min>=30)
hrs=hrs*2+1
else
hrs=hrs*2
var pics="<img style='position: absolute; left: 25px; top: 25px' src='s" + sec + ".gif' height='100' width='100'>"
var picm="<img style='position: absolute; left: 25px; top: 25px' src='m" + min + ".gif' height='100' width='100'>"
var pich="<img style='position:absolute; top: 25px; left: 25px' src='h" + hrs + ".gif' height='100' width='100'>"
document.getElementById('timesec').innerHTML=(pics);
document.getElementById('timemin').innerHTML=(picm);
document.getElementById('timehour').innerHTML=(pich);
//location.reload();
}
</script>
</head>
<body onload="setInterval('show()',1000);">
<div id="timesec"></div>
<div id="timemin"></div>
<div id="timehour"></div>
</body>
</html>
Edit: I was able to get it to work on the iPhone using the previous code. For anyone else that wants to do this, I'll post the revised code that worked for me. I also added code to display a LockBackground image.
To make a theme for the iPhone using this code, make a new folder in the Themes section of the phone, name it yourname.theme (yourname being whatever name you choose). Go to this link and download the attachments.
Now rename the jsclock.htm.txt file to LockBackground. html, then place it in the yourname.theme folder. Next, take all the images from the folders and place them all in the yourname.theme folder (they have to be loose and not in the folders they came in). All that's left is to place your image that you want as your background image, just name it LockBackground. png and place it in the theme folder as well. That's it!
Now you can have separate images for each individual hour, minute, and second.
Thank you Dormilich for your responses. I was still having problems with the code you gave me (I'm sure it was just my fault), but I found this to work so I'll just stick with it.
Here's the revised code:
Code:
<?xml version="1.0" encoding="UTF-16"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>LCD Style Analogue Clock</title>
<style>
#Layer{width: 320px; height: 480px; position: absolute; top: 0px; right: 0px; down: 0px; left: 0px;}
.stretch {width:100%; height:100%;}
</style>
<script type="text/javascript">
function show()
{
var Digital=new Date();
var sec=Digital.getSeconds();
var min=Digital.getMinutes();
var hrs=Digital.getHours();
if (hrs>=12)
{hrs=hrs-12
}
if (min>=30)
hrs=hrs*2+1
else
hrs=hrs*2
var pics="<img style='position: absolute; left: 110px; top: 350px' src='s" + sec + ".gif' height='100' width='100'>"
var picm="<img style='position: absolute; left: 110px; top: 350px' src='m" + min + ".gif' height='100' width='100'>"
var pich="<img style='position:absolute; left: 110px; top: 350px' src='h" + hrs + ".gif' height='100' width='100'>"
document.getElementById('timesec').innerHTML=(pics);
document.getElementById('timemin').innerHTML=(picm);
document.getElementById('timehour').innerHTML=(pich);
//location.reload();
}
</script>
</head>
<div id="Layer"><img src="LockBackground.png" class="stretch"/></div>
<body onload="setInterval('show()',1000);">
<div id="timesec"></div>
<div id="timemin"></div>
<div id="timehour"></div>
</body>
</html>
Comment