Home > Panele > Ile strona istnieje

Ile strona istnieje

Dodane przez: piciu
opis:
Dni -godz -min -sek
Kod:
  1. openside("Strona");
  2. ?>
  3. <style style="text/css">
  4. .dcountstyle{
  5. font: bold 16px Arial;
  6. padding: 3px;
  7. }
  8. .dcountstyle sup{
  9. font-size: 90%
  10. }
  11. </style>
  12. <script type="text/javascript">
  13. function dcountup(startingdate, baseunit){
  14. this.currentTime=new Date()
  15. this.startingdate=new Date(startingdate)
  16. this.timesup=false
  17. this.baseunit=baseunit
  18. this.start()
  19. }
  20.  
  21. dcountup.prototype.oncountup=function(){}
  22. dcountup.prototype.start=function(){
  23. var thisobj=this
  24. this.currentTime.setSeconds(this.currentTime.getSeconds()+1)
  25. var timediff=(this.currentTime-this.startingdate)/1000 //difference btw target date and current date, in seconds
  26. var oneMinute=60 //minute unit in seconds
  27. var oneHour=60*60 //hour unit in seconds
  28. var oneDay=60*60*24 //day unit in seconds
  29. var dayfield=Math.floor(timediff/oneDay)
  30. var hourfield=Math.floor((timediff-dayfield*oneDay)/oneHour)
  31. var minutefield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour)/oneMinute)
  32. var secondfield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour-minutefield*oneMinute))
  33. if (this.baseunit=="hours"){ //if base unit is hours, set "hourfield" to be topmost level
  34. hourfield=dayfield*24+hourfield
  35. dayfield="n/a"
  36. }
  37. else if (this.baseunit=="minutes"){ //if base unit is minutes, set "minutefield" to be topmost level
  38. minutefield=dayfield*24*60+hourfield*60+minutefield
  39. dayfield=hourfield="n/a"
  40. }
  41. else if (this.baseunit=="seconds"){ //if base unit is seconds, set "secondfield" to be topmost level
  42. var secondfield=timediff
  43. dayfield=hourfield=minutefield="n/a"
  44. }
  45. var result={days: dayfield, hours:hourfield, minutes:minutefield, seconds:secondfield}
  46. this.oncountup(result)
  47. setTimeout(function(){thisobj.start()}, 1000) //update results every second
  48. }
  49.  
  50. </script>
  51. <div id="cpcontainer">&nbsp;</div>
  52.  
  53. <script type="text/javascript">
  54.  
  55. //SYNTAX: myvariable=new dcountup(past_date_and_time_string, "baseunit")
  56. //nurodote savo data, menesi anglu kalba
  57. var princewedding=new dcountup("April 27, 2013 17:38:33", "days")
  58.  
  59. princewedding.oncountup=function(result){
  60. //result is an object containing the current count up date/time, updated every second
  61. //Available properties: result["days"], result["hours"], result["minutes"], and result["seconds"]
  62. var mycountainer=document.getElementById("cpcontainer")
  63. mycountainer.innerHTML="Strona istnieje już: <br /><span class='dcountstyle'>"+result['days']+" <sup>dni</sup> "+result['hours']+" <sup>godzin</sup> "+result['minutes']+" <sup>minut</sup> "+result['seconds']+" <sup>s</sup></span>"
  64. }
  65.  
  66. </script>
  67. <?
  68. closeside();

©