JS dan biliyim az oldugunnan bacara bilmedim :(
Burda sehife yenilendikce vaxtin basdan baslamamasi ucun ne etmek lazimdi?
boutiqueCloseCountDown6932.CurrentDate = "02/25/2012 17:11:17" ;
boutiqueCloseCountDown6932.TargetDate = "02/29/2012 10:30:00" ;
Bunları dəyişmək lazımdır, TargetDate-ə hansı vaxt hədəfdir onu yazın. Currentdate-in qiymətinsə silin, əvəzinə
burdakı funksiyalardan istifadə edib dəyişən ilə qiymət mənimsədin. Javascriptdən bilginiz varsa, çox asandır, yoxdursa, gərək bir az öyrənəsiniz :)
Bu isimi gore biler.ama ki sehife yenilendikce vaxt basdan basliyir .problem budu
[code]$(function(){
var note = $('#note'),
ts = new Date(2012, 0, 1),
newYear = true;
if((new Date()) > ts){
// The new year is here! Count towards something else.
// Notice the *1000 at the end - time must be in milliseconds
ts = (new Date()).getTime() + 50*24*60*60*1000;
newYear = false;
}
$('#countdown').countdown({
timestamp : ts,
callback : function(days, hours, minutes, seconds){
var message = "";
message += days + " day" + ( days==1 ? '':'s' ) + ", ";
message += hours + " hour" + ( hours==1 ? '':'s' ) + ", ";
message += minutes + " minute" + ( minutes==1 ? '':'s' ) + " and ";
message += seconds + " second" + ( seconds==1 ? '':'s' ) + " <br />";
if(newYear){
message += "left until the new year!";
}
else {
message += "left to 10 days from now!";
}
note.html(message);
}
});
});[/code]
c.js
[code]function countdown(obj) {
this.obj = obj;
this.Div = "clock";
this.BackColor = "white";
this.ForeColor = "black";
this.CurrentDate = "12/31/2020 5:00:00 AM"; //rramaiah: pass in current date (down to the second) so that it can be set by server
this.TargetDate = "12/31/2020 5:00 AM";
this.DisplayFormat = "%%D%% gün %%H%%:%%M%%:%%S%%";
this.CountActive = true;
this.Prefix = "";
this.DisplayStr;
this.Calcage = cd_Calcage;
this.CountBack = cd_CountBack;
this.Setup = cd_Setup;
}
function cd_Calcage(secs, num1, num2, compact) //rramaiah: "compact" means do not pad with zeros
{
s = ((Math.floor(secs / num1)) % num2).toString();
if (!compact) {
if (s.length < 2) s = "0" + s;
}
return (s);
}
function cd_CountBack(secs) {
if (secs <= 0) {
this.CountActive = false;
this.DisplayStr = '';
if (window.location.toString().indexOf("Basket", 0) > 0) {
//mdernek --BasketService ile senkron değildi. Serviste ürün olduğu halde burası 0 olup redirect oluyordu. Loopa giriyordu. Kaldırıldı. 16.12.2010 16:42
//window.location = window.location + "?msg=timeout" ;
}
}
else {
var days = this.Calcage(secs, 86400, 100000, true); //rramaiah: do not pad days with zeros
this.DisplayStr = this.Prefix + " " + this.DisplayFormat.replace(/%%D%%/g, days);
if (days == 1) { //rramaiah: if days is 1, replace "Days" with "Day"
this.DisplayStr = this.DisplayStr.replace(/Days/g, 'gün');
}
this.DisplayStr = this.DisplayStr.replace(/%%H%%/g, this.Calcage(secs, 3600, 24));
this.DisplayStr = this.DisplayStr.replace(/%%M%%/g, this.Calcage(secs, 60, 60));
this.DisplayStr = this.DisplayStr.replace(/%%S%%/g, this.Calcage(secs, 1, 60));
}
var tmpDiv = document.getElementById(this.Div);
if (tmpDiv) tmpDiv.innerHTML = this.DisplayStr;
if (this.CountActive) setTimeout("if (" + this.obj + ") " + this.obj + ".CountBack(" + (secs - 1) + ")", 990);
}
function cd_Setup() {
var dthen = new Date(this.TargetDate);
var dnow = new Date(this.CurrentDate);
ddiff = new Date(dthen - dnow);
gsecs = Math.floor(ddiff.valueOf() / 1000);
this.CountBack(gsecs);
}
function myCd(bas, bit, myid) {
var myGCD = new countdown(myid);
myGCD.Div = myid;
myGCD.Prefix = "";
myGCD.CurrentDate = bas;
myGCD.TargetDate = bit;
myGCD.Setup();
}[/code]
index.html
[code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="c.js"></script>
</head>
<body>
<span>Butik Kapanış :</span>
<h1 id="boutiqueCloseCountDown6932"></h1>
<script language="javascript" type="text/javascript">
var boutiqueCloseCountDown6932 = new countdown('boutiqueCloseCountDown6932');
boutiqueCloseCountDown6932.Div = "boutiqueCloseCountDown6932" ;
boutiqueCloseCountDown6932.Prefix = "" ;
boutiqueCloseCountDown6932.CurrentDate = "02/25/2012 17:11:17" ;
boutiqueCloseCountDown6932.TargetDate = "02/29/2012 10:30:00" ;
boutiqueCloseCountDown6932.Setup();
</script>
</body>
</html>[/code]
Hele ki localhostdadi.ama kodlari ataram bura baxarsiz.
Salam. Siz kodda bəzi dəyişikliklər etməlisiniz bunun üçün. İstəsəniz ünvanı verin, baxaq