Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > Web программирование > HTML и CSS
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 23.04.2011, 11:52   #1
Unique
Пользователь
 
Регистрация: 27.08.2010
Сообщений: 16
По умолчанию Доведение до ума виджета

Если не в тот раздел попал - перенесите пожалуйста...
Допиливаю для виджета код (для айфона)

Кто что может сказать? Можно ли как нибудь ускорить? Что то отрезать, что то добавить, что то изменить.....

Сопсна код:
Код:
<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;
}

Последний раз редактировалось Unique; 23.04.2011 в 12:23.
Unique вне форума Ответить с цитированием
Старый 23.04.2011, 11:54   #2
Unique
Пользователь
 
Регистрация: 27.08.2010
Сообщений: 16
По умолчанию

продолжение кода
Код:
function calendarDate ( )
{
var this_weekday_name_array = new Array("Воскресенье","Понедельник","Вторник","Среда","Четверг","Пятница","Суббота")
var this_month_name_array = new Array("Января,","Февраля,","Марта,","Апреля,","Мая,","Июня,","Июля,","Августа,","Сентября,","Октября,","Ноября,","Декабря,")	  //predefine month names
    
  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()    
Current_Month = this_month

document.getElementById("calendar").firstChild.nodeValue = this_date + " " + this_month_name_array[this_month] + " " + this_weekday_name_array[this_weekday] 


}

// -->
</script>

</head>


<body style="margin-left: 0">
<img src="lockscreen.png" height="480" width="320" style="position: absolute; top: 0px; left: 0px; z-index:-10;">
<img src="bg.png" style="position: absolute; z-index:-1;top:25; left: 0px;" height="227" width="320">
<img src="" id="ampm" style="position: absolute; z-index:-1;top:112; left: 40px;" width="20">
<table border=0 style="position: absolute; z-index:-1;top:51; left: 42px;"><tr><td id="hr1block"><img src="" width="45" height="80" border=0 id="hr1"></td><td id="hr1block"><img src="" width="45" height="80" border=0 id="hr2"></td>
<td width=35 id="spaceblock"></td>
<td id="min1block"><img src="" width="45" height="80" border=0 id="min1"></td><td id="min2block"><img src="" width="45" height="80" border=0 id="min2"></td>
</tr>
</table>

<span id="calendar" align=right>
	<script language="JavaScript">calendarDate(); setInterval('calendarDate()', 100 )</script>
	</span>
    <span id="clock">
	<script language="JavaScript">updateClock(); setInterval('updateClock()', 100 )</script></span> <span id="ampm">
    </span>

</body>
</html>

Последний раз редактировалось Unique; 23.04.2011 в 12:24.
Unique вне форума Ответить с цитированием
Старый 25.04.2011, 08:39   #3
Unique
Пользователь
 
Регистрация: 27.08.2010
Сообщений: 16
По умолчанию

Ага, понятно
Unique вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Довести до ума БД в delphi Харламов Юрий Помощь студентам 6 28.12.2010 02:34
Помогите довести до ума andresan Assembler - Ассемблер (FASM, MASM, WASM, NASM, GoASM, Gas, RosAsm, HLA) и не рекомендуем TASM 2 27.11.2009 07:46
Мир сошёл с ума?!?! Вавел из ГМТУ Свободное общение 22 31.08.2009 11:36
схожу с ума!!!!!!!! Mariya181818181818 Паскаль, Turbo Pascal, PascalABC.NET 1 01.06.2009 23:16
я схожу с ума!!!! Mariya181818181818 Помощь студентам 6 01.06.2009 22:33