Dodawanie licznika w języku java do panelu
|
domi_122 |
Dodany dnia 19.04.2008 07:26:46
|
Przedszkolak
Postów: 30 Ostrzeżeń: 2
Data rejestracji: 12.04.2008 14:21
|
function countdown_clock(year, month, day, hour, minute, format)
{
//I chose a div as the container for the timer, but
//it can be an input tag inside a form, or anything
//who's displayed content can be changed through
//client-side scripting.
html_code = '<div id="countdown"></div>';
document.write(html_code);
countdown(year, month, day, hour, minute, format);
}
function countdown(year, month, day, hour, minute, format)
{
Today = new Date();
Todays_Year = Today.getFullYear() - 2000;
Todays_Month = Today.getMonth();
//Convert both today's date and the target date into miliseconds.
Todays_Date = (new Date(Todays_Year, Todays_Month, Today.getDate(),
Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime();
Target_Date = (new Date(year, month - 1, day, hour, minute, 00)).getTime();
//Find their difference, and convert that into seconds.
Time_Left = Math.round((Target_Date - Todays_Date) / 1000);
if(Time_Left < 0)
Time_Left = 0;
switch(format)
{
case 0:
//The simplest way to display the time left.
document.all.countdown.innerHTML = Time_Left + ' seconds';
break;
case 1:
//More datailed.
days = Math.floor(Time_Left / (60 * 60 * 24));
Time_Left %= (60 * 60 * 24);
hours = Math.floor(Time_Left / (60 * 60));
Time_Left %= (60 * 60);
minutes = Math.floor(Time_Left / 60);
Time_Left %= 60;
seconds = Time_Left;
dps = 's'; hps = 's'; mps = 's'; sps = 's';
//ps is short for plural suffix.
if(days == 1) dps ='';
if(hours == 1) hps ='';
if(minutes == 1) mps ='';
if(seconds == 1) sps ='';
document.all.countdown.innerHTML = days + ' day' + dps + ' ';
document.all.countdown.innerHTML += hours + ' hour' + hps + ' ';
document.all.countdown.innerHTML += minutes + ' minute' + mps + ' and ';
document.all.countdown.innerHTML += seconds + ' second' + sps;
break;
default:
document.all.countdown.innerHTML = Time_Left + ' seconds';
}
//Recursive call, keeps the clock ticking.
setTimeout('countdown(' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + format + ');', 1000);
}
To jest właśnie skrypt który chcę dodać do panelu
1. Jak to zrobić
2. Gdzie jest ta linijka odpowiedzialna za odliczanie od podanej daty?
pomoże mi ktos
PW od moderatora:
- Zmiana nazwy tematu - bartek124 19.04 - 08:21
Edytowane przez domi_122 dnia 19.04.2008 10:04:00
|
|
|
|
Wścibski Gość |
Dodany dnia 25.11.2024 20:36:56
|
Pan Kontekstualny
Postów: n^x
Data rejestracji: Zawsze
|
|
IP: localhost |
|
|
bartek124 |
Dodany dnia 19.04.2008 08:28:08
|
Weteran
Postów: 3264 Pomógł: 236
v7.02.06 Data rejestracji: 26.05.2007 12:25
|
1. Temat przyklejony: Wstawianie Kodu w Panelu!
Nie zapomnij dodać tagów <script>.
2. Tak możesz wyświetlić datę:
<script type="text/javascript">countdown_clock(rok, miesiac, dzien, godzina, minuta, 1);</script>
Nie pomagam na komunikatorach oraz PW!
|
|
|
|
domi_122 |
Dodany dnia 19.04.2008 10:05:39
|
Przedszkolak
Postów: 30 Ostrzeżeń: 2
Data rejestracji: 12.04.2008 14:21
|
<script type=\"text/javascript\">
function countdown_clock(year, month, day, hour, minute, format)
{
//I chose a div as the container for the timer, but
//it can be an input tag inside a form, or anything
//who's displayed content can be changed through
//client-side scripting.
html_code = '<div id=\"countdown\"></div>';
document.write(html_code);
countdown(year, month, day, hour, minute, format);
}
function countdown(year, month, day, hour, minute, format)
{
Today = new Date();
Todays_Year = Today.getFullYear() - 2000;
Todays_Month = Today.getMonth();
//Convert both today's date and the target date into miliseconds.
Todays_Date = (new Date(Todays_Year, Todays_Month, Today.getDate(),
Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime();
Target_Date = (new Date(year, month - 1, day, hour, minute, 00)).getTime();
//Find their difference, and convert that into seconds.
Time_Left = Math.round((Target_Date - Todays_Date) / 1000);
if(Time_Left < 0)
Time_Left = 0;
switch(format)
{
case 0:
//The simplest way to display the time left.
document.all.countdown.innerHTML = Time_Left + ' seconds';
break;
case 1:
//More datailed.
days = Math.floor(Time_Left / (60 * 60 * 24));
Time_Left %= (60 * 60 * 24);
hours = Math.floor(Time_Left / (60 * 60));
Time_Left %= (60 * 60);
minutes = Math.floor(Time_Left / 60);
Time_Left %= 60;
seconds = Time_Left;
dps = 's'; hps = 's'; mps = 's'; sps = 's';
//ps is short for plural suffix.
if(days == 1) dps ='';
if(hours == 1) hps ='';
if(minutes == 1) mps ='';
if(seconds == 1) sps ='';
document.all.countdown.innerHTML = days + ' day' + dps + ' ';
document.all.countdown.innerHTML += hours + ' hour' + hps + ' ';
document.all.countdown.innerHTML += minutes + ' minute' + mps + ' and ';
document.all.countdown.innerHTML += seconds + ' second' + sps;
break;
default:
document.all.countdown.innerHTML = Time_Left + ' seconds';
}
//Recursive call, keeps the clock ticking.
setTimeout('countdown(' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + format + ');', 1000);
}
</script>
<script type=\"text/javascript\">
countdown_clock(2008, 4, 16, 13, 0, 0);
</script>
Co źle zrobiłem dlaczego nie wyświetla mi rok mesiąc dzień godzina minuta sekunda? |
|
|
|
bartek124 |
Dodany dnia 19.04.2008 10:28:41
|
Weteran
Postów: 3264 Pomógł: 236
v7.02.06 Data rejestracji: 26.05.2007 12:25
|
echo "<script type=\"text/javascript\">
function countdown_clock(year, month, day, hour, minute, format)
{
//I chose a div as the container for the timer, but
//it can be an input tag inside a form, or anything
//who's displayed content can be changed through
//client-side scripting.
html_code = '<div id=\"countdown\"></div>';
document.write(html_code);
countdown(year, month, day, hour, minute, format);
}
function countdown(year, month, day, hour, minute, format)
{
Today = new Date();
Todays_Year = Today.getYear() - 2000;
Todays_Month = Today.getMonth() + 1;
//Convert both today's date and the target date into miliseconds.
Todays_Date = (new Date(Todays_Year, Todays_Month, Today.getDate(),
Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime();
Target_Date = (new Date(year, month, day, hour, minute, 00)).getTime();
//Find their difference, and convert that into seconds.
Time_Left = Math.round((Target_Date - Todays_Date) / 1000);
if(Time_Left < 0)
Time_Left = 0;
switch(format)
{
case 0:
//The simplest way to display the time left.
document.all.countdown.innerHTML = Time_Left + ' seconds';
break;
case 1:
//More datailed.
days = Math.floor(Time_Left / (60 * 60 * 24));
Time_Left %= (60 * 60 * 24);
hours = Math.floor(Time_Left / (60 * 60));
Time_Left %= (60 * 60);
minutes = Math.floor(Time_Left / 60);
Time_Left %= 60;
seconds = Time_Left;
dps = 's'; hps = 's'; mps = 's'; sps = 's';
//ps is short for plural suffix.
if(days == 1) dps ='';
if(hours == 1) hps ='';
if(minutes == 1) mps ='';
if(seconds == 1) sps ='';
document.all.countdown.innerHTML = days + ' day' + dps + '<br>';
document.all.countdown.innerHTML += hours + ' hour' + hps + '<br>';
document.all.countdown.innerHTML += minutes + ' minute' + mps + '<br>';
document.all.countdown.innerHTML += seconds + ' second' + sps;
break;
default:
document.all.countdown.innerHTML = Time_Left + ' seconds';
}
//Recursive call, keeps the clock ticking.
setTimeout('countdown(' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + format + ');', 1000);
}
</script>
<script type=\"text/javascript\">
countdown_clock(2008, 4, 16, 13, 0, [b]1[/b]);
</script>";
Masz gotowca i nie zmieniaj tej pogrubionej jedynki zmieniając czas!
Nie pomagam na komunikatorach oraz PW!
|
|
|
|
domi_122 |
Dodany dnia 19.04.2008 10:32:20
|
Przedszkolak
Postów: 30 Ostrzeżeń: 2
Data rejestracji: 12.04.2008 14:21
|
Jak zmienianiem na 1 to wyświetla
36522 days 0 hours 28 minutes and 5 seconds |
|
|
|
bartek124 |
Dodany dnia 19.04.2008 10:36:28
|
Weteran
Postów: 3264 Pomógł: 236
v7.02.06 Data rejestracji: 26.05.2007 12:25
|
To źle? A zresztą... Ja Ci dałem gotowca, Ty zrób z nim co chcesz .
Nie pomagam na komunikatorach oraz PW!
|
|
|
|
domi_122 |
Dodany dnia 19.04.2008 10:40:44
|
Przedszkolak
Postów: 30 Ostrzeżeń: 2
Data rejestracji: 12.04.2008 14:21
|
A nie powinno być 0 days? |
|
|