我在主题森林模板中有一些计时器。它就像事件的倒计时一样,但我需要将其转回,例如“实验的持续时间”。所以,我试图找到一个指标,如“i--”,并将其更改为“i++”,计时器开始在 plus-mide 工作,但重新加载页面后,所有更改都消失了。
所以,如果你告诉我一个地方,在哪里更改代码,我将非常感激:)
源代码(主文件):
(function (h) {
h.fn.countdown = function (a, l) {
function m(a, d) {
return function () {
return d.call(a)
}
}
var k = "seconds minutes hours days weeks daysLeft".split(" ");
return this.each(function () {
function j() {
if (0 === e.closest("html").length)clearInterval(f), d("removed"); else {
c--;
0 > c && (c = 0);
g = {seconds: c % 60, minutes: Math.floor(c / 60) % 60, hours: Math.floor(c / 60 / 60) % 24, days: Math.floor(c / 60 / 60 / 24), weeks: Math.floor(c / 60 / 60 / 24 / 7), daysLeft: Math.floor(c / 60 / 60 / 24) % 7};
for (var a = 0; a < k.length; a++) {
var b = k[a];
i[b] != g[b] && (i[b] = g[b], d(b))
}
0 == c && (clearInterval(f), d("finished"))
}
}
function d(d) {
var b = h.Event(d);
b.date = new Date((new Date).valueOf() + c);
b.value = i[d] || "0";
b.toDate = a;
b.lasting = g;
switch (d) {
case "seconds":
case "minutes":
case "hours":
b.value = 10 > b.value ? "0" + b.value.toString() : b.value.toString();
break;
default:
b.value && (b.value = b.value.toString())
}
l.call(e, b)
}
if (!(a instanceof Date))if (String(a).match(/^[0-9]*$/))a = new Date(a); else if (a.match(/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{2,4})\s([0-9]{1,2})\:([0-9]{2})\:([0-9]{2})/) || a.match(/([0-9]{2,4})\/([0-9]{1,2})\/([0-9]{1,2})\s([0-9]{1,2})\:([0-9]{2})\:([0-9]{2})/))a = new Date(a); else if (a.match(/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{2,4})/) || a.match(/([0-9]{2,4})\/([0-9]{1,2})\/([0-9]{1,2})/))a = new Date(a); else throw Error("Doesn't seen to be a valid date object or string");
var e = h(this), i = {}, g = {}, f = e.data("countdownInterval"), c = Math.floor((a.valueOf() - (new Date).valueOf()) / 1E3);
j();
f && clearInterval(f);
e.data("countdownInterval", setInterval(m(e, j), 1E3));
f = e.data("countdownInterval")
})
}
})(jQuery);
源代码(配置文件):
//countdown setting
$(function() {
$('.countdown').countdown("2008/06/28", function(event) {
var $this = $(this);
switch(event.type) {
case "seconds":
case "minutes":
case "hours":
case "days":
$this.find('span#'+event.type).html(event.value);
break;
case "finished":
$this.hide();
break;
}
});
});