Witam.
Próbuje stworzyć licznik odliczający czas do pewnego wydarzenia opierający się na
takim zegarku. Wzorowałem się na tym skrypcie:
<script LANGUAGE="JAVASCRIPT"> today = new
Date();
BigDay = new Date("January 1, 2001") //tutaj podajemy datę
msPerDay = 24 * 60 * 60 * 1000 ;
timeLeft = (BigDay.getTime() - today.getTime());
e_daysLeft = timeLeft / msPerDay;
daysLeft = Math.floor(e_daysLeft);
tdays = Math.floor(e_daysLeft);
e_hrsLeft = (e_daysLeft - daysLeft)*24;
hrsLeft = Math.floor(e_hrsLeft);
minsLeft = Math.floor((e_hrsLeft - hrsLeft)*60);
var id,pause=0,position=0;
function imascroller() {
// variables declaration
var i,k,msg="Zostało " +daysLeft+" dni, "+hrsLeft+" godzin(y) i "+minsLeft+" minut(y) do czegośtam! ";
// increase msg
k=(150/msg.length)+1;
for(i=0;i<=k;i++) msg+=" "+msg;
// show it to the window
document.form2.imascroller.value=msg.substring(position,position+300);
// set new position
if(position++==300) position=0;
// repeat at entered speed
id=setTimeout("imascroller()",200); }
// -- End Hiding Here -->
W body:
<input type="text" name="imascroller" size="60" value=""> <script language=javascript1.1> timerID = setTimeout("location.reload()",60000)
timerID = setTimeout("history.go(0)",60000)
Próbując go połączyć z innym licznikiem (wejść na strone który miał już, że tak powiem wsparcie graficzne):
<?php
// En: Begin PHP Code / Fr: Debut code PHP
/******************************************************************************\
* Digital Access Counter Version 1.0 *
* Copyright 2000 Frederic TYNDIUK (FTLS) All Rights Reserved. *
* E-Mail: tyndiuk@ftls.org Script License: GPL *
* Created 02/28/2000 Last Modified 02/28/2000 *
* Scripts Archive at: <a href="http://www.ftls.org/php/" target="_blank">http://www.ftls.org/php/</a> *
*******************************************************************************/
// Necessary Variables:
$COUNT_FILE = "count_data.txt";
// En: Absolute path and name to count data file.
// Fr: Chemin absolu (complet) et Nom du fichier compteur.
$IMG_DIR_URL = "./digits/";
// En: URL Directory of digits (0.gif ... 9.gif).
// Fr: URL du repertoire des images (0.gif ... 9.gif).
$NB_DIGITS = 8;
// En: Minimum number of digits to display (0, to not use 0 left).
// Fr: Nombre minimum de chiffre ŕ afficher (0 pour ne pas avoir de 0 devant).
// End Necessary Variables section
/******************************************************************************/
// En: Open, read, increment, save and close file.
// Fr: Ouvre, lit, incrémente, sauve et ferme le fichier.
$fp = fopen("$COUNT_FILE", "r+"); $count = fgets($fp, 4096
); $count += 1;
} else {
// En: Display a error message if file does not exist.
// Fr: Affiche un message d'erreur si le fichier n'existe pas.
echo "Can't find file, check '\$file' var...<BR>"; }
// En: Display count value
// Fr: Affiche le nombre de visiteur.
$nb_digits = max(strlen($count), $NB_DIGITS); $count = substr("0000000000".$count, -$nb_digits);
for($i = 0; $i <= $nb_digits; $i++) {
if ($digits[$i] != "") {
$html_result .= "<IMG SRC=\"$IMG_DIR_URL$digits[$i].gif\">";
}
}
// En: End PHP code / Fr: Fin du code PHP
?>
Jednak z połączenia Javy i PHP nie wyszło nic dobrego stąd muszę prosić was o pomoc. Dodatkowo macie może jakąś rade lub możliwość do rozwiązania mojego problemu z ty ,,opadaniem'' tych cyfr próbowałem to zrobić jakoś w gif ale dalej zabrakło pomysłu. Możę najlepiej odwzoruje efekt ten filmik na youtube:
http://www.youtube.com/watch?v=Kg2YQn66wMgcała ,,akcja'' zaczyna się od 27 do 33 sek.