Jump to content
  • 0

Ошибка в штмл счетчике. куда копать.


Njax
 Share

Question

Проблема следующая. счетчик отсчитывает 10 часов . после чего начинает считать заново. но не с 10 часов а с 31 дня.

<div class="ps_countdown_wrap">    <div id="ps_counter"></div>    <div class="ps_counter_desc">        <div>Дней</div>        <div>Часов</div>        <div>Минут</div>        <div style="margin: 0;">Секунд</div>    </div></div><style type="text/css">    .ps_countdown_wrap {        width: 550px;        margin: auto;    }    .cntSeparator {        font-size: 54px;        color: #000;        margin: 10px 7px    }    .ps_counter_desc {        clear: both;    }    .ps_counter_desc div {        float: left;        width: 100px;        font: 26px arial;        text-align: center;        margin: 0 37px 0 0;    }</style><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script><script type="text/javascript" src="http://cdn.jsdelivr.net/jquery.cookie/1.3.1/jquery.cookie.js"></script><script type="text/javascript">    Date.prototype.addHours = function(e) {        this.setHours(this.getHours() + e);        return this    };    Date.prototype.addMinutes = function(e) {        this.setMinutes(this.getMinutes() + e);        return this    };    var createDigits = function(e, t) {        var n = 0;        var r, i;        digits = [];        intervals = [];        for (var s = 0; s < t.startTime.length; s++) {            if (parseInt(t.startTime[s]) >= 0) {                elem = $('<div id="cnt_' + n + '" class="cntDigit" />').css({                    height: t.digitHeight,                    "float": "left",                    background: "url('" + t.image + "')",                    width: t.digitWidth                });                elem.current = parseInt(t.startTime[s]);                digits.push(elem);                margin(n, -elem.current * t.digitHeight * t.digitImages);                if (t.continuous === true) {                    digits[n]._max = function() {                        return 9                    }                } else {                    switch (t.format[s]) {                        case "h":                            digits[n]._max = function(e, t) {                                if (e % 2 == 0) return 2;                                else return t ? 3 : 9                            };                            break;                        case "d":                            digits[n]._max = function() {                                return 9                            };                            break;                        case "m":                            digits[n]._max = function(e) {                                if (!r) {                                    r = e                                }                                return e == r ? 9 : 5                            };                            break;                        case "s":                            digits[n]._max = function(e) {                                if (!i) {                                    i = e                                }                                return e == i ? 9 : 5                            }                    }                }                n += 1            } else {                elem = $('<div class="cntSeparator"/>').css({                    "float": "left"                }).text(t.startTime[s])            }            e.append(elem)        }    };    var makeMovement = function(e, t, n, r) {        if (intervals[e]) window.clearInterval(intervals[e]);        var i = -(r.digitHeight * r.digitImages * digits[e].current);        margin(e, i);        digits[e].current = digits[e].current + (n ? t : -t);        var s = 0;        intervals[e] = setInterval(function() {            if (s++ === r.digitImages * t) {                window.clearInterval(intervals[e]);                delete intervals[e];                return            }            var o = n ? -r.digitHeight : r.digitHeight;            margin(e, i + s * o)        }, r.stepTime / t)    };    var margin = function(e, t) {        if (t !== undefined) {            digits[e].margin = t;            return digits[e].css({                backgroundPosition: "0 " + t + "px"            })        }        return digits[e].margin || 0    };    var moveDigit = function(e, t) {        if (digits[e].current == 0) {            if (e > 0) {                var n = digits[e - 1].current == 0;                makeMovement(e, digits[e]._max(e, n), true, t);                moveDigit(e - 1, t)            } else {                for (var r = 0; r < digits.length; r++) {                    clearInterval(intervals[r]);                    clearInterval(intervals.main);                    margin(r, 0)                }                t.timerEnd()            }            return        }        makeMovement(e, 1, false, t)    };    var parseRelativeDate = function(e, t) {        var n = new Date;        var r = n.getDate();        var i = n.getMonth() + 1;        var s = n.getFullYear();        var o = n.getHours(),            u, a;        var f = t.format;        var l = e.split(":");        if (f.indexOf("dd") == 0) {            r = l[0];            l = l.slice(1);            f = f.substr(3)        }        if (f.indexOf("hh") == 0) {            o = l[0];            l = l.slice(1);            f = f.substr(3)        }        if (f.indexOf("mm") == 0) {            u = l[0];            l = l.slice(1);            f = f.substr(3)        }        if (f.indexOf("ss") == 0) {            a = l[0];            l = l.slice(1);            f = f.substr(3)        }        return new Date([i, r, s].join("/") + " " + [o, u, a].map(pad).join(":") + " GMT-0900")    };    var formatCompute = function(e, t) {        var n = t.format;        var r = {            d: e.getUTCDate() - 1,            h: e.getUTCHours(),            m: e.getUTCMinutes(),            s: e.getUTCSeconds()        };        return n.replace(/(dd|hh|mm|ss)/g, function(e, t) {            return pad(r[t[0]])        })    };    var pad = function(e) {        return (1e15 + "" + e).substr(-2)    };    var digits = [];    var intervals = [];    jQuery.fn.countdown = function(e) {        var t = {            stepTime: 60,            format: "dd:hh:mm:ss",            startTime: "01:12:32:55",            digitImages: 6,            digitWidth: 67,            digitHeight: 90,            timerEnd: function() {},            image: "digits.png",            continuous: false        };        $.extend(t, e);        if (e.endTime) {            var n = e.endTime instanceof Date ? e.endTime : parseRelativeDate(e.endTime, t);            var r = n.getTime() - (new Date).getTime();            e.startTime = formatCompute(new Date(r), t);            delete e.endTime        }        $.extend(t, e);        if (this.length) {            clearInterval(intervals.main);            createDigits(this, t);            intervals.main = setInterval(function() {                moveDigit(digits.length - 1, t)            }, 1e3)        }    };    jQuery(function(e) {        var t = e.cookie("deadline");        if (t === null) {            t = (new Date).addHours(10);            e.cookie("deadline", t)        } else {            t = new Date(t)        }        e("#ps_counter").countdown({            image: "http://jquery-countdown.googlecode.com/svn/trunk/img/digits.png",            digitWidth: 53,            digitHeight: 77,            endTime: t,            timerEnd: function() {                alert("АКЦИЯ. УСПЕЙ ЗАКАЗАТЬ")            }        })    })</script>
Edited by Njax
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy