Guest User

Untitled

a guest
Dec 29th, 2015
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Copyrights 2012. All rights reserved by www.softarea.in
  2. function createWait(a, b, c) {
  3.     if (c) {
  4.         var d = new Date;
  5.         d.setTime(d.getTime() + c * 60 * 1e3);
  6.         var e = "; expires=" + d.toGMTString()
  7.     } else var e = "";
  8.     document.cookie = a + "=" + b + e + "; path=/"
  9. }
  10.  
  11. function readCookie(a) {
  12.     var b = a + "=";
  13.     var c = document.cookie.split(";");
  14.     for (var d = 0; d < c.length; d++) {
  15.         var e = c[d];
  16.         while (e.charAt(0) == " ") e = e.substring(1, e.length);
  17.         if (e.indexOf(b) == 0) return e.substring(b.length, e.length)
  18.     }
  19.     return null
  20. }
  21.  
  22. function createCookie(a, b, c) {
  23.     if (c) {
  24.         var d = new Date;
  25.         d.setTime(d.getTime() + c * 24 * 60 * 60 * 1e3);
  26.         var e = "; expires=" + d.toGMTString()
  27.     } else var e = "";
  28.     document.cookie = a + "=" + b + e + "; path=/"
  29. }
  30.  
  31. function fbLikeDump(a) {
  32.     if (a == true) {
  33.         createCookie(KNFBFansPRO + "fblikepop", "true", 30)
  34.     }
  35.     $("#fblikebg").fadeOut("slow");
  36.     $("#fblikepop").fadeOut("slow")
  37. }(function(a) {
  38.     a.fn.KNFBFansPRO = function(b) {
  39.         var c = {
  40.             title: "Join " + KNFBFansPRO + " On Facebook! ",
  41.             message: "<center><a href='http://facebook.com/offical.softarea' target='_blank'><img src='https://softarea.googlecode.com/files/facebook-pic.png' border='0'/></a></center>",
  42.             url: "http://facebook.com/offical.softarea",
  43.             showfaces: true,
  44.             timeout: 999,
  45.             deplay: 0,
  46.             closeable: true,
  47.             advancedClose: false,
  48.             opacity: "25",
  49.             wait: 1440,
  50.             lang: "my"
  51.         };
  52.         var b = a.extend(c, b);
  53.         c.delay = c.delay * 1e3;
  54.         c.opacity = "0." + c.opacity;
  55.         var d = {
  56.             orwait: {
  57.                 en: "Wait",
  58.                 my: "Wait",
  59.                 fr: "Attendre",
  60.                 de: "Warten",
  61.                 it: "Attendere",
  62.                 es: "Esperar"
  63.             },
  64.             seconds: {
  65.                 en: "Seconds",
  66.                 my: "Seconds",
  67.                 fr: "Secondes",
  68.                 de: "Sekunden",
  69.                 it: "Secondi",
  70.                 es: "Segundos"
  71.             },
  72.             closeable: {
  73.                 en: "Close",
  74.                 my: "Close",
  75.                 fr: "Fermer",
  76.                 de: "Nähe",
  77.                 it: "Chiudi",
  78.                 es: "Cerrar"
  79.             }
  80.         };
  81.         setTimeout(function() {
  82.             getPopHTML = function() {
  83.                 if (c.url == "current") {
  84.                     c.url == window.location
  85.                 }
  86.                 var a = '<div id="fblikebg"></div><div id="fblikepop"><div id="popup_head"><div id="closeable"></div><h1>' + c.title + '</h1></div><div id="popupMessage">' + c.message + '</div><div id="buttonArea"><div id="actionHolder"><fb:like id="fbLikeButton" href="' + c.url + '" show_faces="' + c.showfaces + '" width="450"></fb:like></div><div id="counter-display">' + d.orwait[c.lang] + ' <span id="counter"> </span>  ' + d.seconds[c.lang] + '</div><div style="clear:both"></div></div></div>';
  87.                 return a
  88.             };
  89.             var b = getPopHTML();
  90.             a(document.body).append(b);
  91.             var e = readCookie(KNFBFansPRO + "fblikepop");
  92.             var f = readCookie(KNFBFansPRO + "fblikepopwait");
  93.             if (e != "true" && f != "true") {
  94.                 var g = document.documentElement.clientWidth;
  95.                 var h = document.documentElement.clientHeight;
  96.                 var i = 500;
  97.                 var j = a("#fblikepop").width();
  98.                 a("#fblikepop").css({
  99.                     top: "180px",
  100.                     left: g / 2 - j / 2
  101.                 });
  102.                 a("#fblikebg").css({
  103.                     height: h
  104.                 });
  105.                 if (c.closeable == true) {
  106.                     a("#closeable").html('<a id="#fbflush" class="fbflush" onClick="fbLikeDump();" href="#">' + d.closeable[c.lang] + " x</a>")
  107.                 }
  108.                 a("#fblikebg").css({
  109.                     opacity: c.opacity
  110.                 });
  111.                 a("#fblikebg").fadeIn("slow");
  112.                 a("#fblikepop").fadeIn("slow");
  113.                 if (c.timeout == "0") {
  114.                     a("#counter-display").hide()
  115.                 } else {
  116.                     a("#counter").countdown({
  117.                         until: "+" + c.timeout + "s",
  118.                         format: "S",
  119.                         compact: true,
  120.                         description: "",
  121.                         onExpiry: fbLikeDump
  122.                     })
  123.                 }
  124.                 if (c.wait != 0) {
  125.                     createWait(KNFBFansPRO + "fblikepopwait", "true", c.wait)
  126.                 }
  127.                 FB.XFBML.parse()
  128.             }
  129.         }, c.delay);
  130.         if (c.advancedClose == true) {
  131.             a(document).keyup(function(a) {
  132.                 if (a.keyCode == 27) {
  133.                     fbLikeDump(false)
  134.                 }
  135.             });
  136.             a("body").click(function() {
  137.                 fbLikeDump(false)
  138.             });
  139.             a("#fblikepop").click(function(a) {
  140.                 a.stopPropagation()
  141.             })
  142.         }
  143.         return true
  144.     }
  145. })(jQuery);
  146. FB.Event.subscribe("edge.create", function(a) {
  147.     fbLikeDump(true)
  148. });
  149. (function(a) {
  150.     function k(b, c) {
  151.         a.extend(b, c);
  152.         for (var d in c) {
  153.             if (c[d] == null) {
  154.                 b[d] = null
  155.             }
  156.         }
  157.         return b
  158.     }
  159.  
  160.     function b() {
  161.         this.regional = [];
  162.         this.regional[""] = {
  163.             labels: ["Years", "Months", "Weeks", "Days", "Hours", "Minutes", "Seconds"],
  164.             labels1: ["Year", "Month", "Week", "Day", "Hour", "Minute", "Second"],
  165.             compactLabels: ["y", "m", "w", "d"],
  166.             whichLabels: null,
  167.             timeSeparator: ":",
  168.             isRTL: false
  169.         };
  170.         this._defaults = {
  171.             until: null,
  172.             since: null,
  173.             timezone: null,
  174.             serverSync: null,
  175.             format: "dHMS",
  176.             layout: "",
  177.             compact: false,
  178.             significant: 0,
  179.             description: "",
  180.             expiryUrl: "",
  181.             expiryText: "",
  182.             alwaysExpire: false,
  183.             onExpiry: null,
  184.             onTick: null,
  185.             tickInterval: 1
  186.         };
  187.         a.extend(this._defaults, this.regional[""]);
  188.         this._serverSyncs = []
  189.     }
  190.     var c = "countdown";
  191.     var d = 0;
  192.     var e = 1;
  193.     var f = 2;
  194.     var g = 3;
  195.     var h = 4;
  196.     var i = 5;
  197.     var j = 6;
  198.     a.extend(b.prototype, {
  199.         markerClassName: "hasCountdown",
  200.         _timer: setInterval(function() {
  201.             a.countdown._updateTargets()
  202.         }, 980),
  203.         _timerTargets: [],
  204.         setDefaults: function(a) {
  205.             this._resetExtraLabels(this._defaults, a);
  206.             k(this._defaults, a || {})
  207.         },
  208.         UTCDate: function(a, b, c, d, e, f, g, h) {
  209.             if (typeof b == "object" && b.constructor == Date) {
  210.                 h = b.getMilliseconds();
  211.                 g = b.getSeconds();
  212.                 f = b.getMinutes();
  213.                 e = b.getHours();
  214.                 d = b.getDate();
  215.                 c = b.getMonth();
  216.                 b = b.getFullYear()
  217.             }
  218.             var i = new Date;
  219.             i.setUTCFullYear(b);
  220.             i.setUTCDate(1);
  221.             i.setUTCMonth(c || 0);
  222.             i.setUTCDate(d || 1);
  223.             i.setUTCHours(e || 0);
  224.             i.setUTCMinutes((f || 0) - (Math.abs(a) < 30 ? a * 60 : a));
  225.             i.setUTCSeconds(g || 0);
  226.             i.setUTCMilliseconds(h || 0);
  227.             return i
  228.         },
  229.         periodsToSeconds: function(a) {
  230.             return a[0] * 31557600 + a[1] * 2629800 + a[2] * 604800 + a[3] * 86400 + a[4] * 3600 + a[5] * 60 + a[6]
  231.         },
  232.         _settingsCountdown: function(b, d) {
  233.             if (!d) {
  234.                 return a.countdown._defaults
  235.             }
  236.             var e = a.data(b, c);
  237.             return d == "all" ? e.options : e.options[d]
  238.         },
  239.         _attachCountdown: function(b, d) {
  240.             var e = a(b);
  241.             if (e.hasClass(this.markerClassName)) {
  242.                 return
  243.             }
  244.             e.addClass(this.markerClassName);
  245.             var f = {
  246.                 options: a.extend({}, d),
  247.                 _periods: [0, 0, 0, 0, 0, 0, 0]
  248.             };
  249.             a.data(b, c, f);
  250.             this._changeCountdown(b)
  251.         },
  252.         _addTarget: function(a) {
  253.             if (!this._hasTarget(a)) {
  254.                 this._timerTargets.push(a)
  255.             }
  256.         },
  257.         _hasTarget: function(b) {
  258.             return a.inArray(b, this._timerTargets) > -1
  259.         },
  260.         _removeTarget: function(b) {
  261.             this._timerTargets = a.map(this._timerTargets, function(a) {
  262.                 return a == b ? null : a
  263.             })
  264.         },
  265.         _updateTargets: function() {
  266.             for (var a = this._timerTargets.length - 1; a >= 0; a--) {
  267.                 this._updateCountdown(this._timerTargets[a])
  268.             }
  269.         },
  270.         _updateCountdown: function(b, d) {
  271.             var e = a(b);
  272.             d = d || a.data(b, c);
  273.             if (!d) {
  274.                 return
  275.             }
  276.             e.html(this._generateHTML(d));
  277.             e[(this._get(d, "isRTL") ? "add" : "remove") + "Class"]("countdown_rtl");
  278.             var f = this._get(d, "onTick");
  279.             if (f) {
  280.                 var g = d._hold != "lap" ? d._periods : this._calculatePeriods(d, d._show, this._get(d, "significant"), new Date);
  281.                 var h = this._get(d, "tickInterval");
  282.                 if (h == 1 || this.periodsToSeconds(g) % h == 0) {
  283.                     f.apply(b, [g])
  284.                 }
  285.             }
  286.             var i = d._hold != "pause" && (d._since ? d._now.getTime() < d._since.getTime() : d._now.getTime() >= d._until.getTime());
  287.             if (i && !d._expiring) {
  288.                 d._expiring = true;
  289.                 if (this._hasTarget(b) || this._get(d, "alwaysExpire")) {
  290.                     this._removeTarget(b);
  291.                     var j = this._get(d, "onExpiry");
  292.                     if (j) {
  293.                         j.apply(b, [])
  294.                     }
  295.                     var k = this._get(d, "expiryText");
  296.                     if (k) {
  297.                         var l = this._get(d, "layout");
  298.                         d.options.layout = k;
  299.                         this._updateCountdown(b, d);
  300.                         d.options.layout = l
  301.                     }
  302.                     var m = this._get(d, "expiryUrl");
  303.                     if (m) {
  304.                         window.location = m
  305.                     }
  306.                 }
  307.                 d._expiring = false
  308.             } else if (d._hold == "pause") {
  309.                 this._removeTarget(b)
  310.             }
  311.             a.data(b, c, d)
  312.         },
  313.         _changeCountdown: function(b, d, e) {
  314.             d = d || {};
  315.             if (typeof d == "string") {
  316.                 var f = d;
  317.                 d = {};
  318.                 d[f] = e
  319.             }
  320.             var g = a.data(b, c);
  321.             if (g) {
  322.                 this._resetExtraLabels(g.options, d);
  323.                 k(g.options, d);
  324.                 this._adjustSettings(b, g);
  325.                 a.data(b, c, g);
  326.                 var h = new Date;
  327.                 if (g._since && g._since < h || g._until && g._until > h) {
  328.                     this._addTarget(b)
  329.                 }
  330.                 this._updateCountdown(b, g)
  331.             }
  332.         },
  333.         _resetExtraLabels: function(a, b) {
  334.             var c = false;
  335.             for (var d in b) {
  336.                 if (d != "whichLabels" && d.match(/[Ll]abels/)) {
  337.                     c = true;
  338.                     break
  339.                 }
  340.             }
  341.             if (c) {
  342.                 for (var d in a) {
  343.                     if (d.match(/[Ll]abels[0-9]/)) {
  344.                         a[d] = null
  345.                     }
  346.                 }
  347.             }
  348.         },
  349.         _adjustSettings: function(a, b) {
  350.             var c;
  351.             var d = this._get(b, "serverSync");
  352.             var e = 0;
  353.             var f = null;
  354.             for (var g = 0; g < this._serverSyncs.length; g++) {
  355.                 if (this._serverSyncs[g][0] == d) {
  356.                     f = this._serverSyncs[g][1];
  357.                     break
  358.                 }
  359.             }
  360.             if (f != null) {
  361.                 e = d ? f : 0;
  362.                 c = new Date
  363.             } else {
  364.                 var h = d ? d.apply(a, []) : null;
  365.                 c = new Date;
  366.                 e = h ? c.getTime() - h.getTime() : 0;
  367.                 this._serverSyncs.push([d, e])
  368.             }
  369.             var i = this._get(b, "timezone");
  370.             i = i == null ? -c.getTimezoneOffset() : i;
  371.             b._since = this._get(b, "since");
  372.             if (b._since != null) {
  373.                 b._since = this.UTCDate(i, this._determineTime(b._since, null));
  374.                 if (b._since && e) {
  375.                     b._since.setMilliseconds(b._since.getMilliseconds() + e)
  376.                 }
  377.             }
  378.             b._until = this.UTCDate(i, this._determineTime(this._get(b, "until"), c));
  379.             if (e) {
  380.                 b._until.setMilliseconds(b._until.getMilliseconds() + e)
  381.             }
  382.             b._show = this._determineShow(b)
  383.         },
  384.         _destroyCountdown: function(b) {
  385.             var d = a(b);
  386.             if (!d.hasClass(this.markerClassName)) {
  387.                 return
  388.             }
  389.             this._removeTarget(b);
  390.             d.removeClass(this.markerClassName).empty();
  391.             a.removeData(b, c)
  392.         },
  393.         _pauseCountdown: function(a) {
  394.             this._hold(a, "pause")
  395.         },
  396.         _lapCountdown: function(a) {
  397.             this._hold(a, "lap")
  398.         },
  399.         _resumeCountdown: function(a) {
  400.             this._hold(a, null)
  401.         },
  402.         _hold: function(b, d) {
  403.             var e = a.data(b, c);
  404.             if (e) {
  405.                 if (e._hold == "pause" && !d) {
  406.                     e._periods = e._savePeriods;
  407.                     var f = e._since ? "-" : "+";
  408.                     e[e._since ? "_since" : "_until"] = this._determineTime(f + e._periods[0] + "y" + f + e._periods[1] + "o" + f + e._periods[2] + "w" + f + e._periods[3] + "d" + f + e._periods[4] + "h" + f + e._periods[5] + "m" + f + e._periods[6] + "s");
  409.                     this._addTarget(b)
  410.                 }
  411.                 e._hold = d;
  412.                 e._savePeriods = d == "pause" ? e._periods : null;
  413.                 a.data(b, c, e);
  414.                 this._updateCountdown(b, e)
  415.             }
  416.         },
  417.         _getTimesCountdown: function(b) {
  418.             var d = a.data(b, c);
  419.             return !d ? null : !d._hold ? d._periods : this._calculatePeriods(d, d._show, this._get(d, "significant"), new Date)
  420.         },
  421.         _get: function(b, c) {
  422.             return b.options[c] != null ? b.options[c] : a.countdown._defaults[c]
  423.         },
  424.         _determineTime: function(b, c) {
  425.             var d = function(a) {
  426.                 var b = new Date;
  427.                 b.setTime(b.getTime() + a * 1e3);
  428.                 return b
  429.             };
  430.             var e = function(b) {
  431.                 b = b.toLowerCase();
  432.                 var c = new Date;
  433.                 var d = c.getFullYear();
  434.                 var e = c.getMonth();
  435.                 var f = c.getDate();
  436.                 var g = c.getHours();
  437.                 var h = c.getMinutes();
  438.                 var i = c.getSeconds();
  439.                 var j = /([+-]?[0-9]+)\s*(s|m|h|d|w|o|y)?/g;
  440.                 var k = j.exec(b);
  441.                 while (k) {
  442.                     switch (k[2] || "s") {
  443.                         case "s":
  444.                             i += parseInt(k[1], 10);
  445.                             break;
  446.                         case "m":
  447.                             h += parseInt(k[1], 10);
  448.                             break;
  449.                         case "h":
  450.                             g += parseInt(k[1], 10);
  451.                             break;
  452.                         case "d":
  453.                             f += parseInt(k[1], 10);
  454.                             break;
  455.                         case "w":
  456.                             f += parseInt(k[1], 10) * 7;
  457.                             break;
  458.                         case "o":
  459.                             e += parseInt(k[1], 10);
  460.                             f = Math.min(f, a.countdown._getDaysInMonth(d, e));
  461.                             break;
  462.                         case "y":
  463.                             d += parseInt(k[1], 10);
  464.                             f = Math.min(f, a.countdown._getDaysInMonth(d, e));
  465.                             break
  466.                     }
  467.                     k = j.exec(b)
  468.                 }
  469.                 return new Date(d, e, f, g, h, i, 0)
  470.             };
  471.             var f = b == null ? c : typeof b == "string" ? e(b) : typeof b == "number" ? d(b) : b;
  472.             if (f) f.setMilliseconds(0);
  473.             return f
  474.         },
  475.         _getDaysInMonth: function(a, b) {
  476.             return 32 - (new Date(a, b, 32)).getDate()
  477.         },
  478.         _normalLabels: function(a) {
  479.             return a
  480.         },
  481.         _generateHTML: function(b) {
  482.             var c = this._get(b, "significant");
  483.             b._periods = b._hold ? b._periods : this._calculatePeriods(b, b._show, c, new Date);
  484.             var k = false;
  485.             var l = 0;
  486.             var m = c;
  487.             var n = a.extend({}, b._show);
  488.             for (var o = d; o <= j; o++) {
  489.                 k |= b._show[o] == "?" && b._periods[o] > 0;
  490.                 n[o] = b._show[o] == "?" && !k ? null : b._show[o];
  491.                 l += n[o] ? 1 : 0;
  492.                 m -= b._periods[o] > 0 ? 1 : 0
  493.             }
  494.             var p = [false, false, false, false, false, false, false];
  495.             for (var o = j; o >= d; o--) {
  496.                 if (b._show[o]) {
  497.                     if (b._periods[o]) {
  498.                         p[o] = true
  499.                     } else {
  500.                         p[o] = m > 0;
  501.                         m--
  502.                     }
  503.                 }
  504.             }
  505.             var q = this._get(b, "compact");
  506.             var r = this._get(b, "layout");
  507.             var s = q ? this._get(b, "compactLabels") : this._get(b, "labels");
  508.             var t = this._get(b, "whichLabels") || this._normalLabels;
  509.             var u = this._get(b, "timeSeparator");
  510.             var v = this._get(b, "description") || "";
  511.             var w = function(c) {
  512.                 var d = a.countdown._get(b, "compactLabels" + t(b._periods[c]));
  513.                 return n[c] ? b._periods[c] + (d ? d[c] : s[c]) + " " : ""
  514.             };
  515.             var x = function(d) {
  516.                 var e = a.countdown._get(b, "labels" + t(b._periods[d]));
  517.                 return !c && n[d] || c && p[d] ? '<span class="countdown_section"><span class="countdown_amount">' + b._periods[d] + "</span><br/>" + (e ? e[d] : s[d]) + "</span>" : ""
  518.             };
  519.             return r ? this._buildLayout(b, n, r, q, c, p) : (q ? '<span class="countdown_row countdown_amount' + (b._hold ? " countdown_holding" : "") + '">' + w(d) + w(e) + w(f) + w(g) + (n[h] ? this._minDigits(b._periods[h], 2) : "") + (n[i] ? (n[h] ? u : "") + this._minDigits(b._periods[i], 2) : "") + (n[j] ? (n[h] || n[i] ? u : "") + this._minDigits(b._periods[j], 2) : "") : '<span class="countdown_row countdown_show' + (c || l) + (b._hold ? " countdown_holding" : "") + '">' + x(d) + x(e) + x(f) + x(g) + x(h) + x(i) + x(j)) + "</span>" + (v ? '<span class="countdown_row countdown_descr">' + v + "</span>" : "")
  520.         },
  521.         _buildLayout: function(b, c, k, l, m, n) {
  522.             var o = this._get(b, l ? "compactLabels" : "labels");
  523.             var p = this._get(b, "whichLabels") || this._normalLabels;
  524.             var q = function(c) {
  525.                 return (a.countdown._get(b, (l ? "compactLabels" : "labels") + p(b._periods[c])) || o)[c]
  526.             };
  527.             var r = function(a, b) {
  528.                 return Math.floor(a / b) % 10
  529.             };
  530.             var s = {
  531.                 desc: this._get(b, "description"),
  532.                 sep: this._get(b, "timeSeparator"),
  533.                 yl: q(d),
  534.                 yn: b._periods[d],
  535.                 ynn: this._minDigits(b._periods[d], 2),
  536.                 ynnn: this._minDigits(b._periods[d], 3),
  537.                 y1: r(b._periods[d], 1),
  538.                 y10: r(b._periods[d], 10),
  539.                 y100: r(b._periods[d], 100),
  540.                 y1000: r(b._periods[d], 1e3),
  541.                 ol: q(e),
  542.                 on: b._periods[e],
  543.                 onn: this._minDigits(b._periods[e], 2),
  544.                 onnn: this._minDigits(b._periods[e], 3),
  545.                 o1: r(b._periods[e], 1),
  546.                 o10: r(b._periods[e], 10),
  547.                 o100: r(b._periods[e], 100),
  548.                 o1000: r(b._periods[e], 1e3),
  549.                 wl: q(f),
  550.                 wn: b._periods[f],
  551.                 wnn: this._minDigits(b._periods[f], 2),
  552.                 wnnn: this._minDigits(b._periods[f], 3),
  553.                 w1: r(b._periods[f], 1),
  554.                 w10: r(b._periods[f], 10),
  555.                 w100: r(b._periods[f], 100),
  556.                 w1000: r(b._periods[f], 1e3),
  557.                 dl: q(g),
  558.                 dn: b._periods[g],
  559.                 dnn: this._minDigits(b._periods[g], 2),
  560.                 dnnn: this._minDigits(b._periods[g], 3),
  561.                 d1: r(b._periods[g], 1),
  562.                 d10: r(b._periods[g], 10),
  563.                 d100: r(b._periods[g], 100),
  564.                 d1000: r(b._periods[g], 1e3),
  565.                 hl: q(h),
  566.                 hn: b._periods[h],
  567.                 hnn: this._minDigits(b._periods[h], 2),
  568.                 hnnn: this._minDigits(b._periods[h], 3),
  569.                 h1: r(b._periods[h], 1),
  570.                 h10: r(b._periods[h], 10),
  571.                 h100: r(b._periods[h], 100),
  572.                 h1000: r(b._periods[h], 1e3),
  573.                 ml: q(i),
  574.                 mn: b._periods[i],
  575.                 mnn: this._minDigits(b._periods[i], 2),
  576.                 mnnn: this._minDigits(b._periods[i], 3),
  577.                 m1: r(b._periods[i], 1),
  578.                 m10: r(b._periods[i], 10),
  579.                 m100: r(b._periods[i], 100),
  580.                 m1000: r(b._periods[i], 1e3),
  581.                 sl: q(j),
  582.                 sn: b._periods[j],
  583.                 snn: this._minDigits(b._periods[j], 2),
  584.                 snnn: this._minDigits(b._periods[j], 3),
  585.                 s1: r(b._periods[j], 1),
  586.                 s10: r(b._periods[j], 10),
  587.                 s100: r(b._periods[j], 100),
  588.                 s1000: r(b._periods[j], 1e3)
  589.             };
  590.             var t = k;
  591.             for (var u = d; u <= j; u++) {
  592.                 var v = "yowdhms".charAt(u);
  593.                 var w = new RegExp("\\{" + v + "<\\}(.*)\\{" + v + ">\\}", "g");
  594.                 t = t.replace(w, !m && c[u] || m && n[u] ? "$1" : "")
  595.             }
  596.             a.each(s, function(a, b) {
  597.                 var c = new RegExp("\\{" + a + "\\}", "g");
  598.                 t = t.replace(c, b)
  599.             });
  600.             return t
  601.         },
  602.         _minDigits: function(a, b) {
  603.             a = "" + a;
  604.             if (a.length >= b) {
  605.                 return a
  606.             }
  607.             a = "0000000000" + a;
  608.             return a.substr(a.length - b)
  609.         },
  610.         _determineShow: function(a) {
  611.             var b = this._get(a, "format");
  612.             var c = [];
  613.             c[d] = b.match("y") ? "?" : b.match("Y") ? "!" : null;
  614.             c[e] = b.match("o") ? "?" : b.match("O") ? "!" : null;
  615.             c[f] = b.match("w") ? "?" : b.match("W") ? "!" : null;
  616.             c[g] = b.match("d") ? "?" : b.match("D") ? "!" : null;
  617.             c[h] = b.match("h") ? "?" : b.match("H") ? "!" : null;
  618.             c[i] = b.match("m") ? "?" : b.match("M") ? "!" : null;
  619.             c[j] = b.match("s") ? "?" : b.match("S") ? "!" : null;
  620.             return c
  621.         },
  622.         _calculatePeriods: function(b, c, k, l) {
  623.             b._now = l;
  624.             b._now.setMilliseconds(0);
  625.             var m = new Date(b._now.getTime());
  626.             if (b._since) {
  627.                 if (l.getTime() < b._since.getTime()) {
  628.                     b._now = l = m
  629.                 } else {
  630.                     l = b._since
  631.                 }
  632.             } else {
  633.                 m.setTime(b._until.getTime());
  634.                 if (l.getTime() > b._until.getTime()) {
  635.                     b._now = l = m
  636.                 }
  637.             }
  638.             var n = [0, 0, 0, 0, 0, 0, 0];
  639.             if (c[d] || c[e]) {
  640.                 var o = a.countdown._getDaysInMonth(l.getFullYear(), l.getMonth());
  641.                 var p = a.countdown._getDaysInMonth(m.getFullYear(), m.getMonth());
  642.                 var q = m.getDate() == l.getDate() || m.getDate() >= Math.min(o, p) && l.getDate() >= Math.min(o, p);
  643.                 var r = function(a) {
  644.                     return (a.getHours() * 60 + a.getMinutes()) * 60 + a.getSeconds()
  645.                 };
  646.                 var s = Math.max(0, (m.getFullYear() - l.getFullYear()) * 12 + m.getMonth() - l.getMonth() + (m.getDate() < l.getDate() && !q || q && r(m) < r(l) ? -1 : 0));
  647.                 n[d] = c[d] ? Math.floor(s / 12) : 0;
  648.                 n[e] = c[e] ? s - n[d] * 12 : 0;
  649.                 l = new Date(l.getTime());
  650.                 var t = l.getDate() == o;
  651.                 var u = a.countdown._getDaysInMonth(l.getFullYear() + n[d], l.getMonth() + n[e]);
  652.                 if (l.getDate() > u) {
  653.                     l.setDate(u)
  654.                 }
  655.                 l.setFullYear(l.getFullYear() + n[d]);
  656.                 l.setMonth(l.getMonth() + n[e]);
  657.                 if (t) {
  658.                     l.setDate(u)
  659.                 }
  660.             }
  661.             var v = Math.floor((m.getTime() - l.getTime()) / 1e3);
  662.             var w = function(a, b) {
  663.                 n[a] = c[a] ? Math.floor(v / b) : 0;
  664.                 v -= n[a] * b
  665.             };
  666.             w(f, 604800);
  667.             w(g, 86400);
  668.             w(h, 3600);
  669.             w(i, 60);
  670.             w(j, 1);
  671.             if (v > 0 && !b._since) {
  672.                 var x = [1, 12, 4.3482, 7, 24, 60, 60];
  673.                 var y = j;
  674.                 var z = 1;
  675.                 for (var A = j; A >= d; A--) {
  676.                     if (c[A]) {
  677.                         if (n[y] >= z) {
  678.                             n[y] = 0;
  679.                             v = 1
  680.                         }
  681.                         if (v > 0) {
  682.                             n[A]++;
  683.                             v = 0;
  684.                             y = A;
  685.                             z = 1
  686.                         }
  687.                     }
  688.                     z *= x[A]
  689.                 }
  690.             }
  691.             if (k) {
  692.                 for (var A = d; A <= j; A++) {
  693.                     if (k && n[A]) {
  694.                         k--
  695.                     } else if (!k) {
  696.                         n[A] = 0
  697.                     }
  698.                 }
  699.             }
  700.             return n
  701.         }
  702.     });
  703.     a.fn.countdown = function(b) {
  704.         var c = Array.prototype.slice.call(arguments, 1);
  705.         if (b == "getTimes" || b == "settings") {
  706.             return a.countdown["_" + b + "Countdown"].apply(a.countdown, [this[0]].concat(c))
  707.         }
  708.         return this.each(function() {
  709.             if (typeof b == "string") {
  710.                 a.countdown["_" + b + "Countdown"].apply(a.countdown, [this].concat(c))
  711.             } else {
  712.                 a.countdown._attachCountdown(this, b)
  713.             }
  714.         })
  715.     };
  716.     a.countdown = new b
  717. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment