Если не в тот раздел попал - перенесите пожалуйста...
Допиливаю для виджета код (для айфона)
Кто что может сказать? Можно ли как нибудь ускорить? Что то отрезать, что то добавить, что то изменить.....
Сопсна код:
Код:
<html>
<head><title>newclock</title>
<base href="Private/" />
<style>
#clock, #ampm, #dateString, #CalendarTable, #calendar
{
font-family: Helvetica,Arial;
font-weight: bold;
color: #EEE685;
text-shadow: 1px 1px 1px rgba(0, 0, 0, 1);
}
#clock {font-size: 26px;}
#ampm { font-size: 15px; display:none; }
#dateString { font-size: 14px; text-align:center; }
#CalendarTable { font-size: 16px; text-align:center; margin-top:6px; }
#calendar { font-size: 20px; position:absolute; top:190px; text-align:center; width:320px; }
body {background-image: url('../lockscreen.png');}
</style>
<script type="text/javascript">
<!--
var this_weekday_name_array = ["Воскресенье","Понедельник","Вторник","Среда","Четверг","Пятница","Суббота"];
var this_month_name_array = ["Января,","Февраля,","Марта,","Апреля,","Мая,","Июня,","Июля,","Августа,","Сентября,","Октября,","Ноября,","Декабря,"];
var this_date_timestamp = new Date()
var this_weekday = this_date_timestamp.getDay()
var this_date = this_date_timestamp.getDate()
var this_month = this_date_timestamp.getMonth()
var this_year = this_date_timestamp.getYear()
if (this_year < 1000)
this_year+= 1900;
if (this_year==101)
this_year=2001;
var this_date_string = this_date + " " + this_month_name_array[this_month] + " " + this_weekday_name_array[this_weekday]//concat long date string
// -->
function init ( )
{
timeDisplay = document.createTextNode ( "" );
document.getElementById("clock").appendChild ( timeDisplay );
}
function updateClock ( )
{
var TwentyFourHourClock = true
var currentTime = new Date ( );
var currentHours = currentTime.getHours ( );
var currentMinutes = currentTime.getMinutes ( );
var currentSeconds = currentTime.getSeconds ( );
// Pad the minutes and seconds with leading zeros, if required
currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;
if (TwentyFourHourClock == false){
var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM"
currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;
currentHours = ( currentHours == 0 ) ? 12 : currentHours;
if (timeOfDay == "PM"){
document.getElementById("ampm").src="pm.png"
}
else
{
document.getElementById("ampm").src="am.png"
}
}
// Compose the string for display
var currentTimeString = currentHours + ":" + currentMinutes;
// Update the time display
currentHours = ( currentHours < 10 ? "0" : "" ) + currentHours;
document.getElementById("hr1").src="Digits/"+currentHours.charAt(0)+".png";
document.getElementById("hr2").src="Digits/"+currentHours.charAt(1)+".png";
document.getElementById("min1").src="Digits/"+currentMinutes.charAt(0)+".png";
document.getElementById("min2").src="Digits/"+currentMinutes.charAt(1)+".png";
//Removes leading zero from the hours. Set showLeadingZero to false to remove leading zeros, set it to true to leave zeros
var showLeadingZero = true
if (showLeadingZero == false){
if (currentHours.charAt(0)=="0"){
document.getElementById("hr1").style.display='none';
document.getElementById("hr1block").width=15
document.getElementById("spaceblock").width=46
}
else
{
document.getElementById("hr1").style.display='';
document.getElementById("hr1block").width=0
document.getElementById("spaceblock").width=40
}
}
//End leading zero removal code
}
function init2 ( )
{
timeDisplay = document.createTextNode ( "" );
document.getElementById("ampm").appendChild ( timeDisplay );
}
function amPm ( )
{
var currentTime = new Date ( );
var currentHours = currentTime.getHours ( );
// Choose either "AM" or "PM" as appropriate
var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";
// Convert the hours component to 12-hour format if needed
currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;
// Convert an hours component of "0" to "12"
currentHours = ( currentHours == 0 ) ? 12 : currentHours;
// Compose the string for display
var currentTimeString = timeOfDay;
// Update the time display
document.getElementById("ampm").firstChild.nodeValue = currentTimeString;
}
function init3 ( )
{
timeDisplay = document.createTextNode ( "" );
document.getElementById("calendar").appendChild ( timeDisplay );
}
function daysInMonth(iMonth, iYear)
{
return 32 - new Date(iYear, iMonth, 32).getDate();
}
function zeroPad(num,count)
{
var numZeropad = num + '';
while(numZeropad.length < count) {
numZeropad = "0" + numZeropad;
}
return numZeropad;
}