Repository: kbwood/countdown Branch: master Commit: 02cf0a204b94 Files: 133 Total size: 308.5 KB Directory structure: gitextract_yy6pun_3/ ├── .bowerrc ├── .gitignore ├── .jshintrc ├── Gruntfile.js ├── README.md ├── bower.json ├── dist/ │ ├── css/ │ │ └── jquery.countdown.css │ ├── index.html │ └── js/ │ ├── jquery.countdown-ar.js │ ├── jquery.countdown-bg.js │ ├── jquery.countdown-bn.js │ ├── jquery.countdown-bs.js │ ├── jquery.countdown-ca.js │ ├── jquery.countdown-cs.js │ ├── jquery.countdown-cy.js │ ├── jquery.countdown-da.js │ ├── jquery.countdown-de.js │ ├── jquery.countdown-el.js │ ├── jquery.countdown-es.js │ ├── jquery.countdown-et.js │ ├── jquery.countdown-fa.js │ ├── jquery.countdown-fi.js │ ├── jquery.countdown-fo.js │ ├── jquery.countdown-fr.js │ ├── jquery.countdown-gl.js │ ├── jquery.countdown-gu.js │ ├── jquery.countdown-he.js │ ├── jquery.countdown-hr.js │ ├── jquery.countdown-hu.js │ ├── jquery.countdown-hy.js │ ├── jquery.countdown-id.js │ ├── jquery.countdown-is.js │ ├── jquery.countdown-it.js │ ├── jquery.countdown-ja.js │ ├── jquery.countdown-kn.js │ ├── jquery.countdown-ko.js │ ├── jquery.countdown-lt.js │ ├── jquery.countdown-lv.js │ ├── jquery.countdown-mk.js │ ├── jquery.countdown-ml.js │ ├── jquery.countdown-ms.js │ ├── jquery.countdown-my.js │ ├── jquery.countdown-nb.js │ ├── jquery.countdown-nl.js │ ├── jquery.countdown-pl.js │ ├── jquery.countdown-pt-BR.js │ ├── jquery.countdown-ro.js │ ├── jquery.countdown-ru.js │ ├── jquery.countdown-sk.js │ ├── jquery.countdown-sl.js │ ├── jquery.countdown-sq.js │ ├── jquery.countdown-sr-SR.js │ ├── jquery.countdown-sr.js │ ├── jquery.countdown-sv.js │ ├── jquery.countdown-th.js │ ├── jquery.countdown-tr.js │ ├── jquery.countdown-uk.js │ ├── jquery.countdown-ur.js │ ├── jquery.countdown-uz.js │ ├── jquery.countdown-vi.js │ ├── jquery.countdown-zh-CN.js │ ├── jquery.countdown-zh-TW.js │ ├── jquery.countdown.js │ └── jquery.plugin.js ├── doc/ │ ├── global.html │ ├── index.html │ ├── jquery.countdown.js.html │ ├── module-Countdown.html │ └── styles/ │ ├── jsdoc-default.css │ ├── prettify-jsdoc.css │ └── prettify-tomorrow.css ├── kbw.countdown.jquery.json ├── package.json ├── src/ │ ├── css/ │ │ └── jquery.countdown.css │ ├── index.html │ └── js/ │ ├── jquery.countdown-ar.js │ ├── jquery.countdown-bg.js │ ├── jquery.countdown-bn.js │ ├── jquery.countdown-bs.js │ ├── jquery.countdown-ca.js │ ├── jquery.countdown-cs.js │ ├── jquery.countdown-cy.js │ ├── jquery.countdown-da.js │ ├── jquery.countdown-de.js │ ├── jquery.countdown-el.js │ ├── jquery.countdown-es.js │ ├── jquery.countdown-et.js │ ├── jquery.countdown-fa.js │ ├── jquery.countdown-fi.js │ ├── jquery.countdown-fo.js │ ├── jquery.countdown-fr.js │ ├── jquery.countdown-gl.js │ ├── jquery.countdown-gu.js │ ├── jquery.countdown-he.js │ ├── jquery.countdown-hr.js │ ├── jquery.countdown-hu.js │ ├── jquery.countdown-hy.js │ ├── jquery.countdown-id.js │ ├── jquery.countdown-is.js │ ├── jquery.countdown-it.js │ ├── jquery.countdown-ja.js │ ├── jquery.countdown-kk.js │ ├── jquery.countdown-kn.js │ ├── jquery.countdown-ko.js │ ├── jquery.countdown-lt.js │ ├── jquery.countdown-lv.js │ ├── jquery.countdown-mk.js │ ├── jquery.countdown-ml.js │ ├── jquery.countdown-ms.js │ ├── jquery.countdown-my.js │ ├── jquery.countdown-nb.js │ ├── jquery.countdown-nl.js │ ├── jquery.countdown-pl.js │ ├── jquery.countdown-pt-BR.js │ ├── jquery.countdown-ro.js │ ├── jquery.countdown-ru.js │ ├── jquery.countdown-sk.js │ ├── jquery.countdown-sl.js │ ├── jquery.countdown-sq.js │ ├── jquery.countdown-sr-SR.js │ ├── jquery.countdown-sr.js │ ├── jquery.countdown-sv.js │ ├── jquery.countdown-th.js │ ├── jquery.countdown-tr.js │ ├── jquery.countdown-uk.js │ ├── jquery.countdown-ur.js │ ├── jquery.countdown-uz.js │ ├── jquery.countdown-vi.js │ ├── jquery.countdown-zh-CN.js │ ├── jquery.countdown-zh-TW.js │ └── jquery.countdown.js └── test/ ├── countdown.tests.html └── js/ └── jquery.countdown.tests.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: .bowerrc ================================================ { "directory": "src/bower_components" } ================================================ FILE: .gitignore ================================================ dist/*.zip doc/fonts doc/scripts node_modules report src/bower_components ================================================ FILE: .jshintrc ================================================ { "bitwise": true, "browser": true, "camelcase": true, "curly": true, "eqeqeq": true, "forin": true, "freeze": true, "immed": true, "indent": 4, "jquery": true, "latedef": true, "newcap": true, "noarg": true, "nonew": true, "quotmark": "single", "strict": true, "undef": true, "unused": true } ================================================ FILE: Gruntfile.js ================================================ 'use strict'; module.exports = function (grunt) { require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); var config = { pkg: grunt.file.readJSON('package.json'), clean: { build: ['dist/*', 'doc/*', 'report/*', 'temp/*'], tests: ['test/*.min.tests.html'] }, copy: { dist: { files: [ { expand: true, cwd: 'src', src: ['*.html', 'css/*.*', 'img/*.*', 'js/*.*'], dest: 'dist' }, { expand: true, cwd: 'src/bower_components/kbw-plugin/dist/js', src: ['*.*'], dest: 'dist/js' } ] } }, jsdoc: { options: { destination: 'doc' }, all: ['src/js/*.js', '!src/js/*-*.js'] }, jshint: { options: { jshintrc: true }, all: ['src/js/*.js'] }, qunit: { options: { coverage: { disposeCollector: true, src: ['src/js/*.js', '!src/js/*-*.js'], instrumentedFiles: 'temp/', htmlReport: 'report/', linesThresholdPct: 95, statementsThresholdPct: 95, functionsThresholdPct: 95, branchesThresholdPct: 80 } }, all: ['test/*.html'] }, replace: { dist: { src: ['dist/index.html'], dest: 'dist/index.html', replacements: [ { from: /bower_components\/jquery\/dist\/jquery.min.js/, to: 'http://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js' }, { from: /bower_components\/kbw-plugin\/dist\/js\/jquery.plugin.min.js/, to: 'js/jquery.plugin.min.js' } ] }, testmin: { src: ['test/countdown.tests.html'], dest: 'test/countdown.min.tests.html', replacements: [ { from: /src\/js\/jquery\.(.*)\.js/g, to: 'dist/js/jquery.$1.min.js' } ] } }, uglify: { options: { preserveComments: 'some', sourceMap: true }, plugin: { files: [ { expand: true, cwd: 'src/js', src: ['*.js', '!*-*.js'], dest: 'dist/js', ext: '.min.js', extDot: 'last' } ] } }, zip: { all: { cwd: 'dist', src: ['dist/*.html', 'dist/css/*.*', 'dist/img/*.*', 'dist/js/*.*'], dest: 'dist/jquery.countdown.package-<%= pkg.version %>.zip' } } }; grunt.initConfig(config); grunt.registerTask('dist', [ 'copy:dist', 'replace:dist', 'zip' ]); grunt.registerTask('test', [ 'replace:testmin', 'qunit', 'clean:tests' ]); grunt.registerTask('default', [ 'clean:build', 'jshint', 'uglify', 'test', 'jsdoc', 'dist' ]); }; ================================================ FILE: README.md ================================================ jQuery Countdown ================ This plugin sets a div or span to show a countdown to a given time. * Standard or compact formats, or create your own layout. * Decide which periods to show. * Count up from a date/time instead. * Cater for timezone differences and synchronise with server time. * Over 50 localisations. Have a look at the plugin Web site, http://keith-wood.name/countdown.html, for demonstrations of its abilities. For documentation on the functionality see http://keith-wood.name/countdownRef.html. ================================================ FILE: bower.json ================================================ { "name": "kbw-countdown", "description": "This plugin sets a div or span to show a countdown to a given time.", "keywords": [ "countdown", "jQuery", "localisation", "timer" ], "homepage": "https://github.com/kbwood/countdown", "authors": [ "Keith Wood (http://keith-wood.name)" ], "licence": "MIT", "main": [ "src/css/jquery.countdown.css", "src/js/jquery.countdown.js" ], "ignore": [ "**/.*", "node_modules", "src/bower_components" ], "dependencies": { "jquery": ">=1.12.0", "kbw-plugin": "~1.0.3" }, "devDependencies": { "qunit": "~1.23", "sinon": "http://sinonjs.org/releases/sinon-1.17.5.js" } } ================================================ FILE: dist/css/jquery.countdown.css ================================================ /* jQuery Countdown styles 2.0.0. */ .is-countdown { border: 1px solid #ccc; background-color: #eee; } .countdown-rtl { direction: rtl; } .countdown-holding span { color: #888; } .countdown-row { clear: both; width: 100%; padding: 0px 2px; text-align: center; } .countdown-show1 .countdown-section { width: 98%; } .countdown-show2 .countdown-section { width: 48%; } .countdown-show3 .countdown-section { width: 32.5%; } .countdown-show4 .countdown-section { width: 24.5%; } .countdown-show5 .countdown-section { width: 19.5%; } .countdown-show6 .countdown-section { width: 16.25%; } .countdown-show7 .countdown-section { width: 14%; } .countdown-section { display: block; float: left; font-size: 75%; text-align: center; } .countdown-amount { font-size: 200%; } .countdown-period { display: block; } .countdown-descr { display: block; width: 100%; } ================================================ FILE: dist/index.html ================================================ jQuery Countdown

jQuery Countdown Basics

This page demonstrates the very basics of the jQuery Countdown plugin. It contains the minimum requirements for using the plugin and can be used as the basis for your own experimentation.

For more detail see the documentation reference page.

Counting down to 26 January 2014.

Github
https://github.com/kbwood/countdown
Bower
kbw-countdown
================================================ FILE: dist/js/jquery.countdown-ar.js ================================================ /* http://keith-wood.name/countdown.html Arabic (عربي) initialisation for the jQuery countdown extension Translated by Talal Al Asmari (talal@psdgroups.com), April 2009. */ (function($) { 'use strict'; $.countdown.regionalOptions.ar = { labels: ['سنوات','أشهر','أسابيع','أيام','ساعات','دقائق','ثواني'], labels1: ['سنة','شهر','أسبوع','يوم','ساعة','دقيقة','ثانية'], compactLabels: ['س','ش','أ','ي'], whichLabels: null, digits: ['٠','١','٢','٣','٤','٥','٦','٧','٨','٩'], timeSeparator: ':', isRTL: true }; $.countdown.setDefaults($.countdown.regionalOptions.ar); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-bg.js ================================================ /* http://keith-wood.name/countdown.html * Bulgarian initialisation for the jQuery countdown extension * Written by Manol Trendafilov manol@rastermania.com (2010) */ (function($) { 'use strict'; $.countdown.regionalOptions.bg = { labels: ['Години','Месеца','Седмица','Дни','Часа','Минути','Секунди'], labels1: ['Година','Месец','Седмица','Ден','Час','Минута','Секунда'], compactLabels: ['l','m','n','d'], compactLabels1: ['g','m','n','d'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.bg); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-bn.js ================================================ /* http://keith-wood.name/countdown.html * Bengali/Bangla initialisation for the jQuery countdown extension * Written by Mohammed Tajuddin (tajuddin@chittagong-it.com) Jan 2011. */ (function($) { 'use strict'; $.countdown.regionalOptions.bn = { labels: ['বছর','মাস','সপ্তাহ','দিন','ঘন্টা','মিনিট','সেকেন্ড'], labels1: ['বছর','মাস','সপ্তাহ','দিন','ঘন্টা','মিনিট','সেকেন্ড'], compactLabels: ['ব','মা','স','দি'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.bn); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-bs.js ================================================ /* http://keith-wood.name/countdown.html * Bosnian Latin initialisation for the jQuery countdown extension * Written by Miralem Mehic miralem@mehic.info (2011) */ (function($) { 'use strict'; $.countdown.regionalOptions.bs = { labels: ['Godina','Mjeseci','Sedmica','Dana','Sati','Minuta','Sekundi'], labels1: ['Godina','Mjesec','Sedmica','Dan','Sat','Minuta','Sekunda'], labels2: ['Godine','Mjeseca','Sedmica','Dana','Sata','Minute','Sekunde'], compactLabels: ['g','m','t','d'], whichLabels: function(amount) { return (amount === 1 ? 1 : (amount >= 2 && amount <= 4 ? 2 : 0)); }, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.bs); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-ca.js ================================================ /* http://keith-wood.name/countdown.html Catalan initialisation for the jQuery countdown extension Written by Amanida Media www.amanidamedia.com (2010) */ (function($) { 'use strict'; $.countdown.regionalOptions.ca = { labels: ['Anys','Mesos','Setmanes','Dies','Hores','Minuts','Segons'], labels1: ['Anys','Mesos','Setmanes','Dies','Hores','Minuts','Segons'], compactLabels: ['a','m','s','g'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.ca); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-cs.js ================================================ /* http://keith-wood.name/countdown.html * Czech initialisation for the jQuery countdown extension * Written by Roman Chlebec (creamd@c64.sk) (2008) */ (function($) { 'use strict'; $.countdown.regionalOptions.cs = { labels: ['Roků','Měsíců','Týdnů','Dní','Hodin','Minut','Sekund'], labels1: ['Rok','Měsíc','Týden','Den','Hodina','Minuta','Sekunda'], labels2: ['Roky','Měsíce','Týdny','Dny','Hodiny','Minuty','Sekundy'], compactLabels: ['r','m','t','d'], whichLabels: function(amount) { return (amount === 1 ? 1 : (amount >= 2 && amount <= 4 ? 2 : 0)); }, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.cs); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-cy.js ================================================ /* http://keith-wood.name/countdown.html Welsh initialisation for the jQuery countdown extension Written by Gareth Jones | http://garethvjones.com | October 2011. */ (function($) { 'use strict'; $.countdown.regionalOptions.cy = { labels: ['Blynyddoedd','Mis','Wythnosau','Diwrnodau','Oriau','Munudau','Eiliadau'], labels1: ['Blwyddyn','Mis','Wythnos','Diwrnod','Awr','Munud','Eiliad'], compactLabels: ['b','m','w','d'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.cy); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-da.js ================================================ /* http://keith-wood.name/countdown.html Danish initialisation for the jQuery countdown extension Written by Buch (admin@buch90.dk). */ (function($) { 'use strict'; $.countdown.regionalOptions.da = { labels: ['År','Måneder','Uger','Dage','Timer','Minutter','Sekunder'], labels1: ['År','Måned','Uge','Dag','Time','Minut','Sekund'], compactLabels: ['Å','M','U','D'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.da); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-de.js ================================================ /* http://keith-wood.name/countdown.html German initialisation for the jQuery countdown extension Written by Samuel Wulf. */ (function($) { 'use strict'; $.countdown.regionalOptions.de = { labels: ['Jahre','Monate','Wochen','Tage','Stunden','Minuten','Sekunden'], labels1: ['Jahr','Monat','Woche','Tag','Stunde','Minute','Sekunde'], compactLabels: ['J','M','W','T'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.de); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-el.js ================================================ /* http://keith-wood.name/countdown.html Greek initialisation for the jQuery countdown extension Written by Philip. */ (function($) { 'use strict'; $.countdown.regionalOptions.el = { labels: ['Χρόνια','Μήνες','Εβδομάδες','Μέρες','Ώρες','Λεπτά','Δευτερόλεπτα'], labels1: ['Χρόνος','Μήνας','Εβδομάδα','Ημέρα','Ώρα','Λεπτό','Δευτερόλεπτο'], compactLabels: ['Χρ.','Μην.','Εβδ.','Ημ.'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.el); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-es.js ================================================ /* http://keith-wood.name/countdown.html * Spanish initialisation for the jQuery countdown extension * Written by Sergio Carracedo Martinez webmaster@neodisenoweb.com (2008) */ (function($) { 'use strict'; $.countdown.regionalOptions.es = { labels: ['Años','Meses','Semanas','Días','Horas','Minutos','Segundos'], labels1: ['Año','Mes','Semana','Día','Hora','Minuto','Segundo'], compactLabels: ['a','m','s','d'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.es); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-et.js ================================================ /* http://keith-wood.name/countdown.html Estonian initialisation for the jQuery countdown extension Written by Helmer */ (function($) { 'use strict'; $.countdown.regionalOptions.et = { labels: ['Aastat','Kuud','Nädalat','Päeva','Tundi','Minutit','Sekundit'], labels1: ['Aasta','Kuu','Nädal','Päev','Tund','Minut','Sekund'], compactLabels: ['a','k','n','p'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.et); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-fa.js ================================================ /* http://keith-wood.name/countdown.html Persian (فارسی) initialisation for the jQuery countdown extension Written by Alireza Ziaie (ziai@magfa.com) Oct 2008. Digits corrected by Hamed Ramezanian Feb 2013. */ (function($) { 'use strict'; $.countdown.regionalOptions.fa = { labels: ['سال','ماه','هفته','روز','ساعت','دقیقه','ثانیه'], labels1: ['سال','ماه','هفته','روز','ساعت','دقیقه','ثانیه'], compactLabels: ['س','م','ه','ر'], whichLabels: null, digits: ['۰','۱','۲','۳','۴','۵','۶','۷','۸','۹'], timeSeparator: ':', isRTL: true }; $.countdown.setDefaults($.countdown.regionalOptions.fa); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-fi.js ================================================ /* http://keith-wood.name/countdown.html Finnish initialisation for the jQuery countdown extension Written by Kalle Vänskä and Juha Suni (juhis.suni@gmail.com). Corrected by Olli. */ (function($) { 'use strict'; $.countdown.regionalOptions.fi = { labels: ['vuotta','kuukautta','viikkoa','päivää','tuntia','minuuttia','sekuntia'], labels1: ['vuosi','kuukausi','viikko','päivä','tunti','minuutti','sekunti'], compactLabels: ['v','kk','vk','pv'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.fi); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-fo.js ================================================ /* http://keith-wood.name/countdown.html Faroese initialisation for the jQuery countdown extension Written by Kasper Friis Christensen (kasper@friischristensen.com). */ (function($) { 'use strict'; $.countdown.regionalOptions.fo = { labels: ['Ár','Mánaðir','Vikur','Dagar','Tímar','Minuttir','Sekund'], labels1: ['Ár','Mánaður','Vika','Dagur','Tími','Minuttur','Sekund'], compactLabels: ['Á','M','V','D'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.fo); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-fr.js ================================================ /* http://keith-wood.name/countdown.html French initialisation for the jQuery countdown extension Written by Keith Wood (wood.keith{at}optusnet.com.au) Jan 2008. */ (function($) { 'use strict'; $.countdown.regionalOptions.fr = { labels: ['Années','Mois','Semaines','Jours','Heures','Minutes','Secondes'], labels1: ['Année','Mois','Semaine','Jour','Heure','Minute','Seconde'], compactLabels: ['a','m','s','j'], whichLabels: function(amount) { return (amount > 1 ? 0 : 1); }, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.fr); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-gl.js ================================================ /* http://keith-wood.name/countdown.html * Galician initialisation for the jQuery countdown extension * Written by Moncho Pena ramon.pena.rodriguez@gmail.com (2009) and Angel Farrapeira */ (function($) { 'use strict'; $.countdown.regionalOptions.gl = { labels: ['Anos','Meses','Semanas','Días','Horas','Minutos','Segundos'], labels1: ['Ano','Mes','Semana','Día','Hora','Minuto','Segundo'], compactLabels: ['a','m','s','g'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.gl); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-gu.js ================================================ /* http://keith-wood.name/countdown.html * Gujarati initialization for the jQuery countdown extension * Written by Sahil Jariwala jariwala.sahil@gmail.com (2012) */ (function($) { 'use strict'; $.countdown.regionalOptions.gu = { labels: ['વર્ષ','મહિનો','અઠવાડિયા','દિવસ','કલાક','મિનિટ','સેકન્ડ'], labels1: ['વર્ષ','મહિનો','અઠવાડિયા','દિવસ','કલાક','મિનિટ','સેકન્ડ'], compactLabels: ['વ','મ','અ','દિ'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.gu); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-he.js ================================================ /* http://keith-wood.name/countdown.html * Hebrew initialisation for the jQuery countdown extension * Translated by Nir Livne, Dec 2008 */ (function($) { 'use strict'; $.countdown.regionalOptions.he = { labels: ['שנים','חודשים','שבועות','ימים','שעות','דקות','שניות'], labels1: ['שנה','חודש','שבוע','יום','שעה','דקה','שנייה'], compactLabels: ['שנ','ח','שב','י'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: true }; $.countdown.setDefaults($.countdown.regionalOptions.he); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-hr.js ================================================ /* http://keith-wood.name/countdown.html * Croatian l10n for the jQuery countdown plugin * Written by Dejan Broz info@hqfactory.com (2011) * Improved by zytzagoo (2014) */ (function($) { 'use strict'; $.countdown.regionalOptions.hr = { labels: ['Godina','Mjeseci','Tjedana','Dana','Sati','Minuta','Sekundi'], // plurals labels1: ['Godina','Mjesec','Tjedan','Dan','Sat','Minutu','Sekundu'], // singles labels2: ['Godine','Mjeseca','Tjedana','Dana','Sata','Minute','Sekunde'], // paucals compactLabels: ['g','m','t','d'], whichLabels: function(amount){ amount = parseInt(amount, 10); if (amount % 10 === 1 && amount % 100 !== 11) { return 1; // singles (/.*1$/ && ! /.*11$/) } if (amount % 10 >= 2 && amount % 10 <= 4 && (amount % 100 < 10 || amount % 100 >= 20)) { return 2; // paucals (/.*[234]$/ && ! /.*1[234]$/ } return 0; // default plural (most common case) }, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.hr); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-hu.js ================================================ /* http://keith-wood.name/countdown.html * Hungarian initialisation for the jQuery countdown extension * Written by Edmond L. (webmond@gmail.com). */ (function($) { 'use strict'; $.countdown.regionalOptions.hu = { labels: ['Év','Hónap','Hét','Nap','Óra','Perc','Másodperc'], labels1: ['Év','Hónap','Hét','Nap','Óra','Perc','Másodperc'], compactLabels: ['É','H','Hé','N'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.hu); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-hy.js ================================================ /* http://keith-wood.name/countdown.html * Armenian initialisation for the jQuery countdown extension * Written by Artur Martirosyan. (artur{at}zoom.am) October 2011. */ (function($) { 'use strict'; $.countdown.regionalOptions.hy = { labels: ['Տարի','Ամիս','Շաբաթ','Օր','Ժամ','Րոպե','Վարկյան'], labels1: ['Տարի','Ամիս','Շաբաթ','Օր','Ժամ','Րոպե','Վարկյան'], compactLabels: ['տ','ա','շ','օ'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.hy); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-id.js ================================================ /* http://keith-wood.name/countdown.html Indonesian initialisation for the jQuery countdown extension Written by Erwin Yonathan Jan 2009. */ (function($) { 'use strict'; $.countdown.regionalOptions.id = { labels: ['tahun','bulan','minggu','hari','jam','menit','detik'], labels1: ['tahun','bulan','minggu','hari','jam','menit','detik'], compactLabels: ['t','b','m','h'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.id); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-is.js ================================================ /* http://keith-wood.name/countdown.html Icelandic initialisation for the jQuery countdown extension Written by Róbert K. L. */ (function($) { 'use strict'; $.countdown.regionalOptions.is = { labels: ['Ár','Mánuðir','Vikur','Dagar','Klukkustundir','Mínútur','Sekúndur'], labels1: ['Ár','Mánuður','Vika','Dagur','Klukkustund','Mínúta','Sekúnda'], compactLabels: ['ár.','mán.','vik.','dag.','klst.','mín.','sek.'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.is); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-it.js ================================================ /* http://keith-wood.name/countdown.html * Italian initialisation for the jQuery countdown extension * Written by Davide Bellettini and Roberto Chiaveri Feb 2008. */ (function($) { 'use strict'; $.countdown.regionalOptions.it = { labels: ['Anni','Mesi','Settimane','Giorni','Ore','Minuti','Secondi'], labels1: ['Anno','Mese','Settimana','Giorno','Ora','Minuto','Secondo'], compactLabels: ['a','m','s','g'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.it); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-ja.js ================================================ /* http://keith-wood.name/countdown.html Japanese initialisation for the jQuery countdown extension Written by Ken Ishimoto (ken@ksroom.com) Aug 2009. */ (function($) { 'use strict'; $.countdown.regionalOptions.ja = { labels: ['年','月','週','日','時','分','秒'], labels1: ['年','月','週','日','時','分','秒'], compactLabels: ['年','月','週','日'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.ja); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-kn.js ================================================ /* http://keith-wood.name/countdown.html * Kannada initialization for the jQuery countdown extension * Written by Guru Chaturvedi guru@gangarasa.com (2011) */ (function($) { 'use strict'; $.countdown.regionalOptions.kn = { labels: ['ವರ್ಷಗಳು','ತಿಂಗಳು','ವಾರಗಳು','ದಿನಗಳು','ಘಂಟೆಗಳು','ನಿಮಿಷಗಳು','ಕ್ಷಣಗಳು'], labels1: ['ವರ್ಷ','ತಿಂಗಳು','ವಾರ','ದಿನ','ಘಂಟೆ','ನಿಮಿಷ','ಕ್ಷಣ'], compactLabels: ['ವ','ತಿ','ವಾ','ದಿ'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.kn); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-ko.js ================================================ /* http://keith-wood.name/countdown.html Korean initialisation for the jQuery countdown extension Written by Ryan Yu (ryanyu79@gmail.com). */ (function($) { 'use strict'; $.countdown.regionalOptions.ko = { labels: ['년','월','주','일','시','분','초'], labels1: ['년','월','주','일','시','분','초'], compactLabels: ['년','월','주','일'], compactLabels1: ['년','월','주','일'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.ko); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-lt.js ================================================ /* http://keith-wood.name/countdown.html * Lithuanian localisation for the jQuery countdown extension * Written by Moacir P. de Sá Pereira (moacir{at}gmail.com) (2009) */ (function($) { 'use strict'; $.countdown.regionalOptions.lt = { labels: ['Metų','Mėnesių','Savaičių','Dienų','Valandų','Minučių','Sekundžių'], labels1: ['Metai','Mėnuo','Savaitė','Diena','Valanda','Minutė','Sekundė'], compactLabels: ['m','m','s','d'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.lt); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-lv.js ================================================ /* http://keith-wood.name/countdown.html * Latvian initialisation for the jQuery countdown extension * Written by Jānis Peisenieks janis.peisenieks@gmail.com (2010) */ (function($) { 'use strict'; $.countdown.regionalOptions.lv = { labels: ['Gadi','Mēneši','Nedēļas','Dienas','Stundas','Minūtes','Sekundes'], labels1: ['Gads','Mēnesis','Nedēļa','Diena','Stunda','Minūte','Sekunde'], compactLabels: ['l','m','n','d'], compactLabels1: ['g','m','n','d'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.lv); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-mk.js ================================================ /* http://keith-wood.name/countdown.html * Macedonian initialisation for the jQuery countdown extension * Written by Gorast Cvetkovski cvetkovski@gorast.com (2016) */ (function($) { 'use strict'; $.countdown.regionalOptions.mk = { labels: ['Години','Месеци','Недели','Дена','Часа','Минути','Секунди'], labels1: ['Година','Месец','Недела','Ден','Час','Минута','Секунда'], compactLabels: ['l','m','n','d'], compactLabels1: ['g','m','n','d'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.mk); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-ml.js ================================================ /* http://keith-wood.name/countdown.html * Malayalam/(Indian>>Kerala) initialisation for the jQuery countdown extension * Written by Harilal.B (harilal1234@gmail.com) Feb 2013. */ (function($) { 'use strict'; /* jshint -W100 */ $.countdown.regionalOptions.ml = { labels: ['വര്‍ഷങ്ങള്‍','മാസങ്ങള്‍','ആഴ്ചകള്‍','ദിവസങ്ങള്‍','മണിക്കൂറുകള്‍','മിനിറ്റുകള്‍','സെക്കന്റുകള്‍'], labels1: ['വര്‍ഷം','മാസം','ആഴ്ച','ദിവസം','മണിക്കൂര്‍','മിനിറ്റ്','സെക്കന്റ്'], compactLabels: ['വ','മ','ആ','ദി'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], // digits: ['൦','൧','൨','൩','൪','൫','൬','൭','൮','൯'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.ml); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-ms.js ================================================ /* http://keith-wood.name/countdown.html Malay initialisation for the jQuery countdown extension Written by Jason Ong (jason{at}portalgroove.com) May 2010. */ (function($) { 'use strict'; $.countdown.regionalOptions.ms = { labels: ['Tahun','Bulan','Minggu','Hari','Jam','Minit','Saat'], labels1: ['Tahun','Bulan','Minggu','Hari','Jam','Minit','Saat'], compactLabels: ['t','b','m','h'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.ms); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-my.js ================================================ /* http://keith-wood.name/countdown.html Burmese initialisation for the jQuery countdown extension Written by Win Lwin Moe (winnlwinmoe@gmail.com) Dec 2009. */ (function($) { 'use strict'; $.countdown.regionalOptions.my = { labels: ['နွစ္','လ','ရက္သတဿတပတ္','ရက္','နာရီ','မိနစ္','စကဿကန့္'], labels1: ['နွစ္','လ','ရက္သတဿတပတ္','ရက္','နာရီ','မိနစ္','စကဿကန့္'], compactLabels: ['နွစ္','လ','ရက္သတဿတပတ္','ရက္'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.my); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-nb.js ================================================ /* http://keith-wood.name/countdown.html Norwegian Bokmål translation Written by Kristian Ravnevand */ (function($) { 'use strict'; $.countdown.regionalOptions.nb = { labels: ['År','Måneder','Uker','Dager','Timer','Minutter','Sekunder'], labels1: ['År','Måned','Uke','Dag','Time','Minutt','Sekund'], compactLabels: ['Å','M','U','D'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.nb); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-nl.js ================================================ /* http://keith-wood.name/countdown.html Dutch initialisation for the jQuery countdown extension Written by Mathias Bynens Mar 2008. */ (function($) { 'use strict'; $.countdown.regionalOptions.nl = { labels: ['Jaren','Maanden','Weken','Dagen','Uren','Minuten','Seconden'], labels1: ['Jaar','Maand','Week','Dag','Uur','Minuut','Seconde'], compactLabels: ['j','m','w','d'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.nl); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-pl.js ================================================ /* http://keith-wood.name/countdown.html * Polish initialisation for the jQuery countdown extension * Written by Pawel Lewtak lewtak@gmail.com (2008) */ (function($) { 'use strict'; $.countdown.regionalOptions.pl = { labels: ['lat','miesięcy','tygodni','dni','godzin','minut','sekund'], labels1: ['rok','miesiąc','tydzień','dzień','godzina','minuta','sekunda'], labels2: ['lata','miesiące','tygodnie','dni','godziny','minuty','sekundy'], compactLabels: ['l','m','t','d'], compactLabels1: ['r','m','t','d'], whichLabels: function(amount) { var units = amount % 10; var tens = Math.floor((amount % 100) / 10); return (amount === 1 ? 1 : (units >= 2 && units <= 4 && tens !== 1 ? 2 : 0)); }, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.pl); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-pt-BR.js ================================================ /* http://keith-wood.name/countdown.html Brazilian initialisation for the jQuery countdown extension Translated by Marcelo Pellicano de Oliveira (pellicano@gmail.com) Feb 2008. and Juan Roldan (juan.roldan[at]relayweb.com.br) Mar 2012. */ (function($) { 'use strict'; $.countdown.regionalOptions['pt-BR'] = { labels: ['Anos','Meses','Semanas','Dias','Horas','Minutos','Segundos'], labels1: ['Ano','Mês','Semana','Dia','Hora','Minuto','Segundo'], compactLabels: ['a','m','s','d'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions['pt-BR']); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-ro.js ================================================ /* http://keith-wood.name/countdown.html * Romanian initialisation for the jQuery countdown extension * Written by Edmond L. (webmond@gmail.com). */ (function($) { 'use strict'; $.countdown.regionalOptions.ro = { labels: ['Ani','Luni','Saptamani','Zile','Ore','Minute','Secunde'], labels1: ['An','Luna','Saptamana','Ziua','Ora','Minutul','Secunda'], compactLabels: ['A','L','S','Z'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.ro); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-ru.js ================================================ /* http://keith-wood.name/countdown.html * Russian initialisation for the jQuery countdown extension * Written by Sergey K. (xslade{at}gmail.com) June 2010. */ (function($) { 'use strict'; $.countdown.regionalOptions.ru = { labels: ['Лет','Месяцев','Недель','Дней','Часов','Минут','Секунд'], labels1: ['Год','Месяц','Неделя','День','Час','Минута','Секунда'], labels2: ['Года','Месяца','Недели','Дня','Часа','Минуты','Секунды'], compactLabels: ['л','м','н','д'], compactLabels1: ['г','м','н','д'], whichLabels: function(amount) { var units = amount % 10; var tens = Math.floor((amount % 100) / 10); return (amount === 1 ? 1 : (units >= 2 && units <= 4 && tens !== 1 ? 2 : (units === 1 && tens !== 1 ? 1 : 0))); }, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.ru); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-sk.js ================================================ /* http://keith-wood.name/countdown.html * Slovak initialisation for the jQuery countdown extension * Written by Roman Chlebec (creamd@c64.sk) (2008) */ (function($) { 'use strict'; $.countdown.regionalOptions.sk = { labels: ['Rokov','Mesiacov','Týždňov','Dní','Hodín','Minút','Sekúnd'], labels1: ['Rok','Mesiac','Týždeň','Deň','Hodina','Minúta','Sekunda'], labels2: ['Roky','Mesiace','Týždne','Dni','Hodiny','Minúty','Sekundy'], compactLabels: ['r','m','t','d'], whichLabels: function(amount) { return (amount === 1 ? 1 : (amount >= 2 && amount <= 4 ? 2 : 0)); }, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.sk); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-sl.js ================================================ /* http://keith-wood.name/countdown.html * Slovenian localisation for the jQuery countdown extension * Written by Borut Tomažin (debijan{at}gmail.com) (2011) * updated by Jan Zavrl (jan@iuvo.si) (2015) */ (function($) { 'use strict'; $.countdown.regionalOptions.sl = { labels: ['Let','Mesecev','Tednov','Dni','Ur','Minut','Sekund'], // Plurals labels1: ['Leto','Mesec','Teden','Dan','Ura','Minuta','Sekunda'], // Singles labels2: ['Leti','Meseca','Tedna','Dneva','Uri','Minuti','Sekundi'], // Doubles labels3: ['Leta','Meseci','Tedni','Dnevi','Ure','Minute','Sekunde'], // 3's labels4: ['Leta','Meseci','Tedni','Dnevi','Ure','Minute','Sekunde'], // 4's compactLabels: ['l','m','t','d'], whichLabels: function(amount) { return (amount > 4 ? 0 : amount); }, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.sl); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-sq.js ================================================ /* http://keith-wood.name/countdown.html Albanian initialisation for the jQuery countdown extension Written by Erzen Komoni. */ (function($) { 'use strict'; $.countdown.regionalOptions.sq = { labels: ['Vite','Muaj','Javë','Ditë','Orë','Minuta','Sekonda'], labels1: ['Vit','Muaj','Javë','Dit','Orë','Minutë','Sekond'], compactLabels: ['V','M','J','D'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.sq); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-sr-SR.js ================================================ /* http://keith-wood.name/countdown.html * Serbian Latin initialisation for the jQuery countdown extension * Written by Predrag Leka lp@lemurcake.com (2010) */ (function($) { 'use strict'; $.countdown.regionalOptions['sr-SR'] = { labels: ['Godina','Meseci','Nedelja','Dana','Časova','Minuta','Sekundi'], labels1: ['Godina','Mesec','Nedelja','Dan','Čas','Minut','Sekunda'], labels2: ['Godine','Meseca','Nedelje','Dana','Časa','Minuta','Sekunde'], compactLabels: ['g','m','n','d'], whichLabels: function(amount) { return (amount === 1 ? 1 : (amount >= 2 && amount <= 4 ? 2 : 0)); }, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions['sr-SR']); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-sr.js ================================================ /* http://keith-wood.name/countdown.html * Serbian Cyrillic initialisation for the jQuery countdown extension * Written by Predrag Leka lp@lemurcake.com (2010) */ (function($) { 'use strict'; $.countdown.regionalOptions.sr = { labels: ['Година','Месеци','Недеља','Дана','Часова','Минута','Секунди'], labels1: ['Година','месец','Недеља','Дан','Час','Минут','Секунда'], labels2: ['Године','Месеца','Недеље','Дана','Часа','Минута','Секунде'], compactLabels: ['г','м','н','д'], whichLabels: function(amount) { return (amount === 1 ? 1 : (amount >= 2 && amount <= 4 ? 2 : 0)); }, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.sr); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-sv.js ================================================ /* http://keith-wood.name/countdown.html Swedish initialisation for the jQuery countdown extension Written by Carl (carl@nordenfelt.com). */ (function($) { 'use strict'; $.countdown.regionalOptions.sv = { labels: ['År','Månader','Veckor','Dagar','Timmar','Minuter','Sekunder'], labels1: ['År','Månad','Vecka','Dag','Timme','Minut','Sekund'], compactLabels: ['Å','M','V','D'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.sv); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-th.js ================================================ /* http://keith-wood.name/countdown.html Thai initialisation for the jQuery countdown extension Written by Pornchai Sakulsrimontri (li_sin_th@yahoo.com). */ (function($) { 'use strict'; $.countdown.regionalOptions.th = { labels: ['ปี','เดือน','สัปดาห์','วัน','ชั่วโมง','นาที','วินาที'], labels1: ['ปี','เดือน','สัปดาห์','วัน','ชั่วโมง','นาที','วินาที'], compactLabels: ['ปี','เดือน','สัปดาห์','วัน'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.th); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-tr.js ================================================ /* http://keith-wood.name/countdown.html * Turkish initialisation for the jQuery countdown extension * Written by Bekir Ahmetoğlu (bekir@cerek.com) Aug 2008. */ (function($) { 'use strict'; $.countdown.regionalOptions.tr = { labels: ['Yıl','Ay','Hafta','Gün','Saat','Dakika','Saniye'], labels1: ['Yıl','Ay','Hafta','Gün','Saat','Dakika','Saniye'], compactLabels: ['y','a','h','g'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.tr); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-uk.js ================================================ /* http://keith-wood.name/countdown.html * Ukrainian initialisation for the jQuery countdown extension * Written by Goloborodko M misha.gm@gmail.com (2009), corrections by Iгор Kоновал */ (function($) { 'use strict'; $.countdown.regionalOptions.uk = { labels: ['Років','Місяців','Тижнів','Днів','Годин','Хвилин','Секунд'], labels1: ['Рік','Місяць','Тиждень','День','Година','Хвилина','Секунда'], labels2: ['Роки','Місяці','Тижні','Дні','Години','Хвилини','Секунди'], compactLabels: ['r','m','t','d'], whichLabels: function(amount) { return (amount === 1 ? 1 : (amount >=2 && amount <= 4 ? 2 : 0)); }, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.uk); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-ur.js ================================================ /* http://keith-wood.name/countdown.html Urdu (اردو) initialisation for the jQuery countdown extension Translated by Azhar Rasheed (azhar.rasheed19@gmail.com), November 2013. */ (function($) { 'use strict'; $.countdown.regionalOptions.ur = { labels: ['سال','مہينے','ہفتے','دن','گھنٹے','منٹس','سيکنڑز'], labels1: ['سال','ماہ','ہفتہ','دن','گھنٹہ','منٹ','سیکنڈز'], compactLabels: ['(ق)','سینٹ','ایک','J'], whichLabels: null, digits: ['٠','١','٢','٣','۴','۵','۶','۷','٨','٩'], timeSeparator: ':', isRTL: true }; $.countdown.setDefaults($.countdown.regionalOptions.ur); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-uz.js ================================================ /* http://keith-wood.name/countdown.html * Uzbek initialisation for the jQuery countdown extension * Written by Alisher U. (ulugbekov{at}gmail.com) August 2012. */ (function($) { 'use strict'; $.countdown.regionalOptions.uz = { labels: ['Yil','Oy','Hafta','Kun','Soat','Daqiqa','Soniya'], labels1: ['Yil','Oy','Hafta','Kun','Soat','Daqiqa','Soniya'], compactLabels: ['y','o','h','k'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.uz); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-vi.js ================================================ /* http://keith-wood.name/countdown.html * Vietnamese initialisation for the jQuery countdown extension * Written by Pham Tien Hung phamtienhung@gmail.com (2010) */ (function($) { 'use strict'; $.countdown.regionalOptions.vi = { labels: ['Năm','Tháng','Tuần','Ngày','Giờ','Phút','Giây'], labels1: ['Năm','Tháng','Tuần','Ngày','Giờ','Phút','Giây'], compactLabels: ['năm','th','tu','ng'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.vi); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-zh-CN.js ================================================ /* http://keith-wood.name/countdown.html Simplified Chinese initialisation for the jQuery countdown extension Written by Cloudream (cloudream@gmail.com). */ (function($) { 'use strict'; $.countdown.regionalOptions['zh-CN'] = { labels: ['年','月','周','天','时','分','秒'], labels1: ['年','月','周','天','时','分','秒'], compactLabels: ['年','月','周','天'], compactLabels1: ['年','月','周','天'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions['zh-CN']); })(jQuery); ================================================ FILE: dist/js/jquery.countdown-zh-TW.js ================================================ /* http://keith-wood.name/countdown.html Traditional Chinese initialisation for the jQuery countdown extension Written by Cloudream (cloudream@gmail.com). */ (function($) { 'use strict'; $.countdown.regionalOptions['zh-TW'] = { labels: ['年','月','周','天','時','分','秒'], labels1: ['年','月','周','天','時','分','秒'], compactLabels: ['年','月','周','天'], compactLabels1: ['年','月','周','天'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions['zh-TW']); })(jQuery); ================================================ FILE: dist/js/jquery.countdown.js ================================================ /*! http://keith-wood.name/countdown.html Countdown for jQuery v2.1.0. Written by Keith Wood (wood.keith{at}optusnet.com.au) January 2008. Available under the MIT (http://keith-wood.name/licence.html) license. Please attribute the author if you use it. */ (function($) { // Hide scope, no $ conflict 'use strict'; var pluginName = 'countdown'; var Y = 0; // Years var O = 1; // Months var W = 2; // Weeks var D = 3; // Days var H = 4; // Hours var M = 5; // Minutes var S = 6; // Seconds /** Create the countdown plugin.

Sets an element to show the time remaining until a given instant.

Expects HTML like:

<div></div>

Provide inline configuration like:

<div data-countdown="name: 'value', ..."></div>
@module Countdown @augments JQPlugin @example $(selector).countdown({until: +300}) */ $.JQPlugin.createPlugin({ /** The name of the plugin. @default 'countdown' */ name: pluginName, /** Countdown expiry callback. Used with the {@linkcode module:Countdown~defaultOptions|onExpiry} option and triggered when the countdown expires. @global @callback CountdownExpiryCallback @this Element @example onExpiry: function() { alert('Done'); } */ /** Countdown server synchronisation callback. Used with the {@linkcode module:Countdown~defaultOptions|serverSync} option and triggered when the countdown is initialised. @global @callback CountdownServerSyncCallback @return {Date} The current date/time on the server as expressed in the local timezone. @this $.countdown @example serverSync: function() { var time = null; $.ajax({url: 'http://myserver.com/serverTime.php', async: false, dataType: 'text', success: function(text) { time = new Date(text); }, error: function(http, message, exc) { time = new Date(); }); return time; } */ /** Countdown tick callback. Used with the {@linkcode module:Countdown~defaultOptions|onTick} option and triggered on every {@linkcode module:Countdown~defaultOptions|tickInterval} ticks of the countdown. @global @callback CountdownTickCallback @this Element @param {number[]} periods The breakdown by period (years, months, weeks, days, hours, minutes, seconds) of the time remaining/passed. @example onTick: function(periods) { $('#altTime').text(periods[4] + ':' + twoDigits(periods[5]) + ':' + twoDigits(periods[6])); } */ /** Countdown which labels callback. Used with the {@linkcode module:Countdown~regionalOptions|whichLabels} option and triggered when the countdown is being display to determine which set of labels (labels, labels1, ...) are to be used for the current period value. @global @callback CountdownWhichLabelsCallback @param {number} num The current period value. @return {number} The suffix for the label set to use, or zero for the default labels. @example whichLabels: function(num) { return (num === 1 ? 1 : (num >= 2 && num <= 4 ? 2 : 0)); } */ /** Default settings for the plugin. @property {Date|number|string} [until] The date/time to count down to, or number of seconds offset from now, or string of amounts and units for offset(s) from now: 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds. One of until or since must be specified. If both are given since takes precedence. @example until: new Date(2013, 12-1, 25, 13, 30) until: +300 until: '+1O -2D' @property {Date|number|string} [since] The date/time to count up from, or number of seconds offset from now, or string of amounts and units for offset(s) from now: 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds. One of until or since must be specified. If both are given since takes precedence. @example since: new Date(2013, 1-1, 1) since: -300 since: '-1O +2D' @property {number} [timezone=null] The timezone (hours or minutes from GMT) for the target times, or null for client local timezone. @example timezone: +10 timezone: -60 @property {CountdownServerSyncCallback} [serverSync=null] A function to retrieve the current server time for synchronisation. @property {string} [format='dHMS'] The format for display - upper case to always show, lower case to show only if non-zero, 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds. @property {string} [layout='']

Build your own layout for the countdown.

Indicate substitution points with '{desc}' for the description, '{sep}' for the time separator, '{pv}' where p is 'y' for years, 'o' for months, 'w' for weeks, 'd' for days, 'h' for hours, 'm' for minutes, or 's' for seconds and v is 'n' for the period value, 'nn' for the period value with a minimum of two digits, 'nnn' for the period value with a minimum of three digits, or 'l' for the period label (long or short form depending on the compact setting), or '{pd}' where p is as above and d is '1' for the units digit, '10' for the tens digit, '100' for the hundreds digit, or '1000' for the thousands digit.

If you need to exclude entire sections when the period value is zero and you have specified the period as optional, surround these sections with '{p<}' and '{p>}', where p is the same as above.

Your layout can just be simple text, or can contain HTML markup as well.

@example layout: '{d<}{dn} {dl}{d>} {hnn}:{mnn}:{snn}' @property {boolean} [compact=false] true to display in a compact format, false for an expanded one. @property {boolean} [padZeroes=false] true to add leading zeroes. @property {number} [significant=0] The maximum number of periods with non-zero values to show, zero for all. @property {string} [description=''] The description displayed for the countdown. @property {string} [expiryUrl=''] A URL to load upon expiry, replacing the current page. @property {string} [expiryText=''] Text to display upon expiry, replacing the countdown. This may be HTML. @property {boolean} [alwaysExpire=false] true to trigger onExpiry even if the target time has passed. @property {CountdownExpiryCallback} [onExpiry=null] Callback when the countdown expires - receives no parameters and this is the containing element. @example onExpiry: function() { ... } @property {CountdownTickCallback} [onTick=null] Callback when the countdown is updated - receives number[7] being the breakdown by period (years, months, weeks, days, hours, minutes, seconds - based on format) and this is the containing element. @example onTick: function(periods) { var secs = $.countdown.periodsToSeconds(periods); if (secs < 300) { // Last five minutes ... } } @property {number} [tickInterval=1] The interval (seconds) between onTick callbacks. */ defaultOptions: { until: null, since: null, timezone: null, serverSync: null, format: 'dHMS', layout: '', compact: false, padZeroes: false, significant: 0, description: '', expiryUrl: '', expiryText: '', alwaysExpire: false, onExpiry: null, onTick: null, tickInterval: 1 }, /** Localisations for the plugin. Entries are objects indexed by the language code ('' being the default US/English). Each object has the following attributes. @property {string[]} [labels=['Years','Months','Weeks','Days','Hours','Minutes','Seconds']] The display texts for the counter periods. @property {string[]} [labels1=['Year','Month','Week','Day','Hour','Minute','Second']] The display texts for the counter periods if they have a value of 1. Add other labelsn attributes as necessary to cater for other numeric idiosyncrasies of the localisation. @property {string[]}[compactLabels=['y','m','w','d']] The compact texts for the counter periods. @property {CountdownWhichLabelsCallback} [whichLabels=null] A function to determine which labelsn to use. @example whichLabels: function(num) { return (num > 1 ? 0 : 1); } @property {string[]} [digits=['0','1',...,'9']] The digits to display (0-9). @property {string} [timeSeparator=':'] Separator for time periods in the compact layout. @property {boolean} [isRTL=false] true for right-to-left languages, false for left-to-right. */ regionalOptions: { // Available regional settings, indexed by language/country code '': { // Default regional settings - English/US labels: ['Years', 'Months', 'Weeks', 'Days', 'Hours', 'Minutes', 'Seconds'], labels1: ['Year', 'Month', 'Week', 'Day', 'Hour', 'Minute', 'Second'], compactLabels: ['y', 'm', 'w', 'd'], whichLabels: null, digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], timeSeparator: ':', isRTL: false } }, /* Class name for the right-to-left marker. */ _rtlClass: pluginName + '-rtl', /* Class name for the countdown section marker. */ _sectionClass: pluginName + '-section', /* Class name for the period amount marker. */ _amountClass: pluginName + '-amount', /* Class name for the period name marker. */ _periodClass: pluginName + '-period', /* Class name for the countdown row marker. */ _rowClass: pluginName + '-row', /* Class name for the holding countdown marker. */ _holdingClass: pluginName + '-holding', /* Class name for the showing countdown marker. */ _showClass: pluginName + '-show', /* Class name for the description marker. */ _descrClass: pluginName + '-descr', /* List of currently active countdown elements. */ _timerElems: [], /** Additional setup for the countdown. Apply default localisations. Create the timer. @private */ _init: function() { var self = this; this._super(); this._serverSyncs = []; var now = (typeof Date.now === 'function' ? Date.now : function() { return new Date().getTime(); }); var perfAvail = (window.performance && typeof window.performance.now === 'function'); // Shared timer for all countdowns function timerCallBack(timestamp) { var drawStart = (timestamp < 1e12 ? // New HTML5 high resolution timer (perfAvail ? (window.performance.now() + window.performance.timing.navigationStart) : now()) : // Integer milliseconds since unix epoch timestamp || now()); if (drawStart - animationStartTime >= 1000) { self._updateElems(); animationStartTime = drawStart; } requestAnimationFrame(timerCallBack); } var requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || null; // This is when we expect a fall-back to setInterval as it's much more fluid var animationStartTime = 0; if (!requestAnimationFrame || $.noRequestAnimationFrame) { $.noRequestAnimationFrame = null; // Fall back to good old setInterval $.countdown._timer = setInterval(function() { self._updateElems(); }, 1000); } else { animationStartTime = window.animationStartTime || window.webkitAnimationStartTime || window.mozAnimationStartTime || window.oAnimationStartTime || window.msAnimationStartTime || now(); requestAnimationFrame(timerCallBack); } }, /** Convert a date/time to UTC. @param {number} tz The hour or minute offset from GMT, e.g. +9, -360. @param {Date|number} year the date/time in that timezone or the year in that timezone. @param {number} [month] The month (0 - 11) (omit if year is a Date). @param {number} [day] The day (omit if year is a Date). @param {number} [hours] The hour (omit if year is a Date). @param {number} [mins] The minute (omit if year is a Date). @param {number} [secs] The second (omit if year is a Date). @param {number} [ms] The millisecond (omit if year is a Date). @return {Date} The equivalent UTC date/time. @example $.countdown.UTCDate(+10, 2013, 12-1, 25, 12, 0) $.countdown.UTCDate(-7, new Date(2013, 12-1, 25, 12, 0)) */ UTCDate: function(tz, year, month, day, hours, mins, secs, ms) { if (typeof year === 'object' && year instanceof Date) { ms = year.getMilliseconds(); secs = year.getSeconds(); mins = year.getMinutes(); hours = year.getHours(); day = year.getDate(); month = year.getMonth(); year = year.getFullYear(); } var d = new Date(); d.setUTCFullYear(year); d.setUTCDate(1); d.setUTCMonth(month || 0); d.setUTCDate(day || 1); d.setUTCHours(hours || 0); d.setUTCMinutes((mins || 0) - (Math.abs(tz) < 30 ? tz * 60 : tz)); d.setUTCSeconds(secs || 0); d.setUTCMilliseconds(ms || 0); return d; }, /** Convert a set of periods into seconds. Averaged for months and years. @param {number[]} periods The periods per year/month/week/day/hour/minute/second. @return {number} The corresponding number of seconds. @example var secs = $.countdown.periodsToSeconds(periods) */ periodsToSeconds: function(periods) { return periods[0] * 31557600 + periods[1] * 2629800 + periods[2] * 604800 + periods[3] * 86400 + periods[4] * 3600 + periods[5] * 60 + periods[6]; }, /** Resynchronise the countdowns with the server. @example $.countdown.resync() */ resync: function() { var self = this; $('.' + this._getMarker()).each(function() { // Each countdown var inst = $.data(this, self.name); if (inst.options.serverSync) { // If synced var serverSync = null; for (var i = 0; i < self._serverSyncs.length; i++) { if (self._serverSyncs[i][0] === inst.options.serverSync) { // Find sync details serverSync = self._serverSyncs[i]; break; } } if (self._eqNull(serverSync[2])) { // Recalculate if missing var serverResult = ($.isFunction(inst.options.serverSync) ? inst.options.serverSync.apply(this, []) : null); serverSync[2] = (serverResult ? new Date().getTime() - serverResult.getTime() : 0) - serverSync[1]; } if (inst._since) { // Apply difference inst._since.setMilliseconds(inst._since.getMilliseconds() + serverSync[2]); } inst._until.setMilliseconds(inst._until.getMilliseconds() + serverSync[2]); } }); for (var i = 0; i < self._serverSyncs.length; i++) { // Update sync details if (!self._eqNull(self._serverSyncs[i][2])) { self._serverSyncs[i][1] += self._serverSyncs[i][2]; delete self._serverSyncs[i][2]; } } }, _instSettings: function(elem, options) { // jshint unused:false return {_periods: [0, 0, 0, 0, 0, 0, 0]}; }, /** Add an element to the list of active ones. @private @param {Element} elem The countdown element. */ _addElem: function(elem) { if (!this._hasElem(elem)) { this._timerElems.push(elem); } }, /** See if an element is in the list of active ones. @private @param {Element} elem The countdown element. @return {boolean} true if present, false if not. */ _hasElem: function(elem) { return ($.inArray(elem, this._timerElems) > -1); }, /** Remove an element from the list of active ones. @private @param {Element} elem The countdown element. */ _removeElem: function(elem) { this._timerElems = $.map(this._timerElems, function(value) { return (value === elem ? null : value); }); // delete entry }, /** Update each active timer element. @private */ _updateElems: function() { for (var i = this._timerElems.length - 1; i >= 0; i--) { this._updateCountdown(this._timerElems[i]); } }, _optionsChanged: function(elem, inst, options) { if (options.layout) { options.layout = options.layout.replace(/</g, '<').replace(/>/g, '>'); } this._resetExtraLabels(inst.options, options); var timezoneChanged = (inst.options.timezone !== options.timezone); $.extend(inst.options, options); this._adjustSettings(elem, inst, !this._eqNull(options.until) || !this._eqNull(options.since) || timezoneChanged); var now = new Date(); if ((inst._since && inst._since < now) || (inst._until && inst._until > now)) { this._addElem(elem[0]); } this._updateCountdown(elem, inst); }, /** Redisplay the countdown with an updated display. @private @param {Element|jQuery} elem The containing element. @param {object} inst The current settings for this instance. */ _updateCountdown: function(elem, inst) { elem = elem.jquery ? elem : $(elem); inst = inst || this._getInst(elem); if (!inst) { return; } elem.html(this._generateHTML(inst)).toggleClass(this._rtlClass, inst.options.isRTL); if (inst._hold !== 'pause' && $.isFunction(inst.options.onTick)) { var periods = inst._hold !== 'lap' ? inst._periods : this._calculatePeriods(inst, inst._show, inst.options.significant, new Date()); if (inst.options.tickInterval === 1 || this.periodsToSeconds(periods) % inst.options.tickInterval === 0) { inst.options.onTick.apply(elem[0], [periods]); } } var expired = inst._hold !== 'pause' && (inst._since ? inst._now.getTime() < inst._since.getTime() : inst._now.getTime() >= inst._until.getTime()); if (expired && !inst._expiring) { inst._expiring = true; if (this._hasElem(elem[0]) || inst.options.alwaysExpire) { this._removeElem(elem[0]); if ($.isFunction(inst.options.onExpiry)) { inst.options.onExpiry.apply(elem[0], []); } if (inst.options.expiryText) { var layout = inst.options.layout; inst.options.layout = inst.options.expiryText; this._updateCountdown(elem[0], inst); inst.options.layout = layout; } if (inst.options.expiryUrl) { window.location = inst.options.expiryUrl; } } inst._expiring = false; } else if (inst._hold === 'pause') { this._removeElem(elem[0]); } }, /** Reset any extra labelsn and compactLabelsn entries if changing labels. @private @param {object} base The options to be updated. @param {object} options The new option values. */ _resetExtraLabels: function(base, options) { var n = null; for (n in options) { if (n.match(/[Ll]abels[02-9]|compactLabels1/)) { base[n] = options[n]; } } for (n in base) { // Remove custom numbered labels if (n.match(/[Ll]abels[02-9]|compactLabels1/) && typeof options[n] === 'undefined') { base[n] = null; } } }, /** Determine whether or not a value is equivalent to null. @private @param {object} value The value to test. @return {boolean} true if equivalent to null, false if not. */ _eqNull: function(value) { return typeof value === 'undefined' || value === null; }, /** Calculate internal settings for an instance. @private @param {jQuery} elem The containing element. @param {object} inst The current settings for this instance. @param {boolean} recalc true if until or since are set. */ _adjustSettings: function(elem, inst, recalc) { var serverEntry = null; for (var i = 0; i < this._serverSyncs.length; i++) { if (this._serverSyncs[i][0] === inst.options.serverSync) { serverEntry = this._serverSyncs[i][1]; break; } } var now = null; var serverOffset = null; if (!this._eqNull(serverEntry)) { now = new Date(); serverOffset = (inst.options.serverSync ? serverEntry : 0); } else { var serverResult = ($.isFunction(inst.options.serverSync) ? inst.options.serverSync.apply(elem[0], []) : null); now = new Date(); serverOffset = (serverResult ? now.getTime() - serverResult.getTime() : 0); this._serverSyncs.push([inst.options.serverSync, serverOffset]); } var timezone = inst.options.timezone; timezone = (this._eqNull(timezone) ? -now.getTimezoneOffset() : timezone); if (recalc || (!recalc && this._eqNull(inst._until) && this._eqNull(inst._since))) { inst._since = inst.options.since; if (!this._eqNull(inst._since)) { inst._since = this.UTCDate(timezone, this._determineTime(inst._since, null)); if (inst._since && serverOffset) { inst._since.setMilliseconds(inst._since.getMilliseconds() + serverOffset); } } inst._until = this.UTCDate(timezone, this._determineTime(inst.options.until, now)); if (serverOffset) { inst._until.setMilliseconds(inst._until.getMilliseconds() + serverOffset); } } inst._show = this._determineShow(inst); }, /** Remove the countdown widget from an element. @private @param {jQuery} elem The containing element. @param {object} inst The current instance object. */ _preDestroy: function(elem, inst) { // jshint unused:false this._removeElem(elem[0]); elem.empty(); }, /** Pause a countdown widget at the current time. Stop it running but remember and display the current time. @param {Element} elem The containing element. @example $(selector).countdown('pause') */ pause: function(elem) { this._hold(elem, 'pause'); }, /** Pause a countdown widget at the current time. Stop the display but keep the countdown running. @param {Element} elem The containing element. @example $(selector).countdown('lap') */ lap: function(elem) { this._hold(elem, 'lap'); }, /** Resume a paused countdown widget. @param {Element} elem The containing element. @example $(selector).countdown('resume') */ resume: function(elem) { this._hold(elem, null); }, /** Toggle a paused countdown widget. @param {Element} elem The containing element. @example $(selector).countdown('toggle') */ toggle: function(elem) { var inst = $.data(elem, this.name) || {}; this[!inst._hold ? 'pause' : 'resume'](elem); }, /** Toggle a lapped countdown widget. @param {Element} elem The containing element. @example $(selector).countdown('toggleLap') */ toggleLap: function(elem) { var inst = $.data(elem, this.name) || {}; this[!inst._hold ? 'lap' : 'resume'](elem); }, /** Pause or resume a countdown widget. @private @param {Element} elem The containing element. @param {string} hold The new hold setting. */ _hold: function(elem, hold) { var inst = $.data(elem, this.name); if (inst) { if (inst._hold === 'pause' && !hold) { inst._periods = inst._savePeriods; var sign = (inst._since ? '-' : '+'); inst[inst._since ? '_since' : '_until'] = this._determineTime(sign + inst._periods[0] + 'y' + sign + inst._periods[1] + 'o' + sign + inst._periods[2] + 'w' + sign + inst._periods[3] + 'd' + sign + inst._periods[4] + 'h' + sign + inst._periods[5] + 'm' + sign + inst._periods[6] + 's'); this._addElem(elem); } inst._hold = hold; inst._savePeriods = (hold === 'pause' ? inst._periods : null); $.data(elem, this.name, inst); this._updateCountdown(elem, inst); } }, /** Return the current time periods, broken down by years, months, weeks, days, hours, minutes, and seconds. @param {Element} elem The containing element. @return {number[]} The current periods for the countdown. @example var periods = $(selector).countdown('getTimes') */ getTimes: function(elem) { var inst = $.data(elem, this.name); return (!inst ? null : (inst._hold === 'pause' ? inst._savePeriods : (!inst._hold ? inst._periods : this._calculatePeriods(inst, inst._show, inst.options.significant, new Date())))); }, /** A time may be specified as an exact value or a relative one. @private @param {string|number|Date} setting The date/time value as a relative or absolute value. @param {Date} defaultTime The date/time to use if no other is supplied. @return {Date} The corresponding date/time. */ _determineTime: function(setting, defaultTime) { var self = this; var offsetNumeric = function(offset) { // e.g. +300, -2 var time = new Date(); time.setTime(time.getTime() + offset * 1000); return time; }; var offsetString = function(offset) { // e.g. '+2d', '-4w', '+3h +30m' offset = offset.toLowerCase(); var time = new Date(); var year = time.getFullYear(); var month = time.getMonth(); var day = time.getDate(); var hour = time.getHours(); var minute = time.getMinutes(); var second = time.getSeconds(); var pattern = /([+-]?[0-9]+)\s*(s|m|h|d|w|o|y)?/g; var matches = pattern.exec(offset); while (matches) { switch (matches[2] || 's') { case 's': second += parseInt(matches[1], 10); break; case 'm': minute += parseInt(matches[1], 10); break; case 'h': hour += parseInt(matches[1], 10); break; case 'd': day += parseInt(matches[1], 10); break; case 'w': day += parseInt(matches[1], 10) * 7; break; case 'o': month += parseInt(matches[1], 10); day = Math.min(day, self._getDaysInMonth(year, month)); break; case 'y': year += parseInt(matches[1], 10); day = Math.min(day, self._getDaysInMonth(year, month)); break; } matches = pattern.exec(offset); } return new Date(year, month, day, hour, minute, second, 0); }; var time = (this._eqNull(setting) ? defaultTime : (typeof setting === 'string' ? offsetString(setting) : (typeof setting === 'number' ? offsetNumeric(setting) : setting))); if (time) { time.setMilliseconds(0); } return time; }, /** Determine the number of days in a month. @private @param {number} year The year. @param {number} month The month. @return {number} The days in that month. */ _getDaysInMonth: function(year, month) { return 32 - new Date(year, month, 32).getDate(); }, /** Default implementation to determine which set of labels should be used for an amount. Use the labels attribute with the same numeric suffix (if it exists). @private @param {number} num The amount to be displayed. @return {number} The set of labels to be used for this amount. */ _normalLabels: function(num) { return num; }, /** Generate the HTML to display the countdown widget. @private @param {object} inst The current settings for this instance. @return {string} The new HTML for the countdown display. */ _generateHTML: function(inst) { var self = this; // Determine what to show inst._periods = (inst._hold ? inst._periods : this._calculatePeriods(inst, inst._show, inst.options.significant, new Date())); // Show all 'asNeeded' after first non-zero value var shownNonZero = false; var showCount = 0; var sigCount = inst.options.significant; var show = $.extend({}, inst._show); var period = null; for (period = Y; period <= S; period++) { shownNonZero = shownNonZero || (inst._show[period] === '?' && inst._periods[period] > 0); show[period] = (inst._show[period] === '?' && !shownNonZero ? null : inst._show[period]); showCount += (show[period] ? 1 : 0); sigCount -= (inst._periods[period] > 0 ? 1 : 0); } var showSignificant = [false, false, false, false, false, false, false]; for (period = S; period >= Y; period--) { // Determine significant periods if (inst._show[period]) { if (inst._periods[period]) { showSignificant[period] = true; } else { showSignificant[period] = sigCount > 0; sigCount--; } } } var labels = (inst.options.compact ? inst.options.compactLabels : inst.options.labels); var whichLabels = inst.options.whichLabels || this._normalLabels; var showCompact = function(period) { var labelsNum = inst.options['compactLabels' + whichLabels(inst._periods[period])]; return (show[period] ? self._translateDigits(inst, inst._periods[period]) + (labelsNum ? labelsNum[period] : labels[period]) + ' ' : ''); }; var minDigits = (inst.options.padZeroes ? 2 : 1); var showFull = function(period) { var labelsNum = inst.options['labels' + whichLabels(inst._periods[period])]; return ((!inst.options.significant && show[period]) || (inst.options.significant && showSignificant[period]) ? '' + '' + self._minDigits(inst, inst._periods[period], minDigits) + '' + '' + (labelsNum ? labelsNum[period] : labels[period]) + '' : ''); }; return (inst.options.layout ? this._buildLayout(inst, show, inst.options.layout, inst.options.compact, inst.options.significant, showSignificant) : ((inst.options.compact ? // Compact version '' + showCompact(Y) + showCompact(O) + showCompact(W) + showCompact(D) + (show[H] ? this._minDigits(inst, inst._periods[H], 2) : '') + (show[M] ? (show[H] ? inst.options.timeSeparator : '') + this._minDigits(inst, inst._periods[M], 2) : '') + (show[S] ? (show[H] || show[M] ? inst.options.timeSeparator : '') + this._minDigits(inst, inst._periods[S], 2) : '') : // Full version '' + showFull(Y) + showFull(O) + showFull(W) + showFull(D) + showFull(H) + showFull(M) + showFull(S)) + '' + (inst.options.description ? '' + inst.options.description + '' : ''))); }, /** Construct a custom layout. @private @param {object} inst The current settings for this instance. @param {boolean[]} show Flags indicating which periods are requested. @param {string} layout The customised layout. @param {boolean} compact true if using compact labels. @param {number} significant The number of periods with values to show, zero for all. @param {boolean[]} showSignificant Other periods to show for significance. @return {string} The custom HTML. */ _buildLayout: function(inst, show, layout, compact, significant, showSignificant) { var labels = inst.options[compact ? 'compactLabels' : 'labels']; var whichLabels = inst.options.whichLabels || this._normalLabels; var labelFor = function(index) { return (inst.options[(compact ? 'compactLabels' : 'labels') + whichLabels(inst._periods[index])] || labels)[index]; }; var digit = function(value, position) { return inst.options.digits[Math.floor(value / position) % 10]; }; var subs = {desc: inst.options.description, sep: inst.options.timeSeparator, yl: labelFor(Y), yn: this._minDigits(inst, inst._periods[Y], 1), ynn: this._minDigits(inst, inst._periods[Y], 2), ynnn: this._minDigits(inst, inst._periods[Y], 3), y1: digit(inst._periods[Y], 1), y10: digit(inst._periods[Y], 10), y100: digit(inst._periods[Y], 100), y1000: digit(inst._periods[Y], 1000), ol: labelFor(O), on: this._minDigits(inst, inst._periods[O], 1), onn: this._minDigits(inst, inst._periods[O], 2), onnn: this._minDigits(inst, inst._periods[O], 3), o1: digit(inst._periods[O], 1), o10: digit(inst._periods[O], 10), o100: digit(inst._periods[O], 100), o1000: digit(inst._periods[O], 1000), wl: labelFor(W), wn: this._minDigits(inst, inst._periods[W], 1), wnn: this._minDigits(inst, inst._periods[W], 2), wnnn: this._minDigits(inst, inst._periods[W], 3), w1: digit(inst._periods[W], 1), w10: digit(inst._periods[W], 10), w100: digit(inst._periods[W], 100), w1000: digit(inst._periods[W], 1000), dl: labelFor(D), dn: this._minDigits(inst, inst._periods[D], 1), dnn: this._minDigits(inst, inst._periods[D], 2), dnnn: this._minDigits(inst, inst._periods[D], 3), d1: digit(inst._periods[D], 1), d10: digit(inst._periods[D], 10), d100: digit(inst._periods[D], 100), d1000: digit(inst._periods[D], 1000), hl: labelFor(H), hn: this._minDigits(inst, inst._periods[H], 1), hnn: this._minDigits(inst, inst._periods[H], 2), hnnn: this._minDigits(inst, inst._periods[H], 3), h1: digit(inst._periods[H], 1), h10: digit(inst._periods[H], 10), h100: digit(inst._periods[H], 100), h1000: digit(inst._periods[H], 1000), ml: labelFor(M), mn: this._minDigits(inst, inst._periods[M], 1), mnn: this._minDigits(inst, inst._periods[M], 2), mnnn: this._minDigits(inst, inst._periods[M], 3), m1: digit(inst._periods[M], 1), m10: digit(inst._periods[M], 10), m100: digit(inst._periods[M], 100), m1000: digit(inst._periods[M], 1000), sl: labelFor(S), sn: this._minDigits(inst, inst._periods[S], 1), snn: this._minDigits(inst, inst._periods[S], 2), snnn: this._minDigits(inst, inst._periods[S], 3), s1: digit(inst._periods[S], 1), s10: digit(inst._periods[S], 10), s100: digit(inst._periods[S], 100), s1000: digit(inst._periods[S], 1000)}; var html = layout; // Replace period containers: {p<}...{p>} for (var i = Y; i <= S; i++) { var period = 'yowdhms'.charAt(i); var re = new RegExp('\\{' + period + '<\\}([\\s\\S]*)\\{' + period + '>\\}', 'g'); html = html.replace(re, ((!significant && show[i]) || (significant && showSignificant[i]) ? '$1' : '')); } // Replace period values: {pn} $.each(subs, function(n, v) { var re = new RegExp('\\{' + n + '\\}', 'g'); html = html.replace(re, v); }); return html; }, /** Ensure a numeric value has at least n digits for display. @private @param {object} inst The current settings for this instance. @param {number} value The value to display. @param {number} len The minimum length. @return {string} The display text. */ _minDigits: function(inst, value, len) { value = '' + value; if (value.length >= len) { return this._translateDigits(inst, value); } value = '0000000000' + value; return this._translateDigits(inst, value.substr(value.length - len)); }, /** Translate digits into other representations. @private @param {object} inst The current settings for this instance. @param {string} value The text to translate. @return {string} The translated text. */ _translateDigits: function(inst, value) { return ('' + value).replace(/[0-9]/g, function(digit) { return inst.options.digits[digit]; }); }, /** Translate the format into flags for each period. @private @param {object} inst The current settings for this instance. @return {string[]} Flags indicating which periods are requested (?) or required (!) by year, month, week, day, hour, minute, second. */ _determineShow: function(inst) { var format = inst.options.format; var show = []; show[Y] = (format.match('y') ? '?' : (format.match('Y') ? '!' : null)); show[O] = (format.match('o') ? '?' : (format.match('O') ? '!' : null)); show[W] = (format.match('w') ? '?' : (format.match('W') ? '!' : null)); show[D] = (format.match('d') ? '?' : (format.match('D') ? '!' : null)); show[H] = (format.match('h') ? '?' : (format.match('H') ? '!' : null)); show[M] = (format.match('m') ? '?' : (format.match('M') ? '!' : null)); show[S] = (format.match('s') ? '?' : (format.match('S') ? '!' : null)); return show; }, /** Calculate the requested periods between now and the target time. @private @param {object} inst The current settings for this instance. @param {string[]} show Flags indicating which periods are requested/required. @param {number} significant The number of periods with values to show, zero for all. @param {Date} now The current date and time. @return {number[]} The current time periods (always positive) by year, month, week, day, hour, minute, second. */ _calculatePeriods: function(inst, show, significant, now) { // Find endpoints inst._now = now; inst._now.setMilliseconds(0); var until = new Date(inst._now.getTime()); if (inst._since) { if (now.getTime() < inst._since.getTime()) { inst._now = now = until; } else { now = inst._since; } } else { until.setTime(inst._until.getTime()); if (now.getTime() > inst._until.getTime()) { inst._now = now = until; } } // Calculate differences by period var periods = [0, 0, 0, 0, 0, 0, 0]; if (show[Y] || show[O]) { // Treat end of months as the same var lastNow = this._getDaysInMonth(now.getFullYear(), now.getMonth()); var lastUntil = this._getDaysInMonth(until.getFullYear(), until.getMonth()); var sameDay = (until.getDate() === now.getDate() || (until.getDate() >= Math.min(lastNow, lastUntil) && now.getDate() >= Math.min(lastNow, lastUntil))); var getSecs = function(date) { return (date.getHours() * 60 + date.getMinutes()) * 60 + date.getSeconds(); }; var months = Math.max(0, (until.getFullYear() - now.getFullYear()) * 12 + until.getMonth() - now.getMonth() + ((until.getDate() < now.getDate() && !sameDay) || (sameDay && getSecs(until) < getSecs(now)) ? -1 : 0)); periods[Y] = (show[Y] ? Math.floor(months / 12) : 0); periods[O] = (show[O] ? months - periods[Y] * 12 : 0); // Adjust for months difference and end of month if necessary now = new Date(now.getTime()); var wasLastDay = (now.getDate() === lastNow); var lastDay = this._getDaysInMonth(now.getFullYear() + periods[Y], now.getMonth() + periods[O]); if (now.getDate() > lastDay) { now.setDate(lastDay); } now.setFullYear(now.getFullYear() + periods[Y]); now.setMonth(now.getMonth() + periods[O]); if (wasLastDay) { now.setDate(lastDay); } } var diff = Math.floor((until.getTime() - now.getTime()) / 1000); var period = null; var extractPeriod = function(period, numSecs) { periods[period] = (show[period] ? Math.floor(diff / numSecs) : 0); diff -= periods[period] * numSecs; }; extractPeriod(W, 604800); extractPeriod(D, 86400); extractPeriod(H, 3600); extractPeriod(M, 60); extractPeriod(S, 1); if (diff > 0 && !inst._since) { // Round up if left overs var multiplier = [1, 12, 4.3482, 7, 24, 60, 60]; var lastShown = S; var max = 1; for (period = S; period >= Y; period--) { if (show[period]) { if (periods[lastShown] >= max) { periods[lastShown] = 0; diff = 1; } if (diff > 0) { periods[period]++; diff = 0; lastShown = period; max = 1; } } max *= multiplier[period]; } } if (significant) { // Zero out insignificant periods for (period = Y; period <= S; period++) { if (significant && periods[period]) { significant--; } else if (!significant) { periods[period] = 0; } } } return periods; } }); })(jQuery); ================================================ FILE: dist/js/jquery.plugin.js ================================================ /* globals JQClass */ /*! Simple JavaScript Inheritance * By John Resig http://ejohn.org/ * MIT Licensed. */ // Inspired by base2 and Prototype (function(){ 'use strict'; var initializing = false; // The base JQClass implementation (does nothing) window.JQClass = function(){}; // Collection of derived classes JQClass.classes = {}; // Create a new JQClass that inherits from this class JQClass.extend = function extender(prop) { var base = this.prototype; // Instantiate a base class (but only create the instance, don't run the init constructor) initializing = true; var prototype = new this(); initializing = false; // Copy the properties over onto the new prototype for (var name in prop) { // jshint loopfunc:true // Check if we're overwriting an existing function if (typeof prop[name] === 'function' && typeof base[name] === 'function') { prototype[name] = (function (name, fn) { return function () { var __super = this._super; // Add a new ._super() method that is the same method but on the super-class this._super = function (args) { return base[name].apply(this, args || []); }; var ret = fn.apply(this, arguments); // The method only needs to be bound temporarily, so we remove it when we're done executing this._super = __super; return ret; }; })(name, prop[name]); // Check if we're overwriting existing default options. } else if (typeof prop[name] === 'object' && typeof base[name] === 'object' && name === 'defaultOptions') { var obj1 = base[name]; var obj2 = prop[name]; var obj3 = {}; var key; for (key in obj1) { // jshint forin:false obj3[key] = obj1[key]; } for (key in obj2) { // jshint forin:false obj3[key] = obj2[key]; } prototype[name] = obj3; } else { prototype[name] = prop[name]; } } // The dummy class constructor function JQClass() { // All construction is actually done in the init method if (!initializing && this._init) { this._init.apply(this, arguments); } } // Populate our constructed prototype object JQClass.prototype = prototype; // Enforce the constructor to be what we expect JQClass.prototype.constructor = JQClass; // And make this class extendable JQClass.extend = extender; return JQClass; }; })(); /*! Abstract base class for collection plugins v1.0.2. Written by Keith Wood (wood.keith{at}optusnet.com.au) December 2013. Licensed under the MIT license (http://keith-wood.name/licence.html). */ (function($) { // Ensure $, encapsulate 'use strict'; /**

Abstract base class for collection plugins v1.0.2.

Written by Keith Wood (wood.keith{at}optusnet.com.au) December 2013.

Licensed under the MIT license (http://keith-wood.name/licence.html).

Use {@link $.JQPlugin.createPlugin} to create new plugins using this framework.

This base class provides common functionality such as:

  • Creates jQuery bridge - allowing you to invoke your plugin on a collection of elements.
  • Handles initialisation including reading settings from metadata - an instance object is attached to the affected element(s) containing all the necessary data.
  • Handles option retrieval and update - options can be set through default values, through inline metadata, or through instantiation settings.
    Metadata is specified as an attribute on the element: data-<pluginName>="<option name>: '<value>', ...". Dates should be specified as strings in this format: 'new Date(y, m-1, d)'.
  • Handles method calling - inner functions starting with '_'are inaccessible, whereas others can be called via $(selector).pluginName('functionName').
  • Handles plugin destruction - removing all trace of the plugin.
@module JQPlugin @abstract */ JQClass.classes.JQPlugin = JQClass.extend({ /** Name to identify this plugin. @example name: 'tabs' */ name: 'plugin', /** Default options for instances of this plugin (default: {}). @example defaultOptions: { selectedClass: 'selected', triggers: 'click' } */ defaultOptions: {}, /** Options dependent on the locale. Indexed by language and (optional) country code, with '' denoting the default language (English/US). Normally additional languages would be provided as separate files to all them to be included as needed. @example regionalOptions: { '': { greeting: 'Hi' } } */ regionalOptions: {}, /** Whether or not a deep merge should be performed when accumulating options. The default is true but can be overridden in a sub-class. */ deepMerge: true, /** Retrieve a marker class for affected elements. In the format: is-<pluginName>. @protected @return {string} The marker class. */ _getMarker: function() { return 'is-' + this.name; }, /** Initialise the plugin. Create the jQuery bridge - plugin name xyz produces singleton $.xyz and collection function $.fn.xyz. @protected */ _init: function() { // Apply default localisations $.extend(this.defaultOptions, (this.regionalOptions && this.regionalOptions['']) || {}); // Camel-case the name var jqName = camelCase(this.name); // Expose jQuery singleton manager $[jqName] = this; // Expose jQuery collection plugin $.fn[jqName] = function(options) { var otherArgs = Array.prototype.slice.call(arguments, 1); var inst = this; var returnValue = this; this.each(function () { if (typeof options === 'string') { if (options[0] === '_' || !$[jqName][options]) { throw 'Unknown method: ' + options; } var methodValue = $[jqName][options].apply($[jqName], [this].concat(otherArgs)); if (methodValue !== inst && methodValue !== undefined) { returnValue = methodValue; return false; } } else { $[jqName]._attach(this, options); } }); return returnValue; }; }, /** Set default options for all subsequent instances. @param {object} options The new default options. @example $.pluginName.setDefaults({name: value, ...}) */ setDefaults: function(options) { $.extend(this.defaultOptions, options || {}); }, /** Initialise an element. Called internally only. Adds an instance object as data named for the plugin. Override {@linkcode module:JQPlugin~_postAttach|_postAttach} for plugin-specific processing. @private @param {Element} elem The element to enhance. @param {object} options Overriding settings. */ _attach: function(elem, options) { elem = $(elem); if (elem.hasClass(this._getMarker())) { return; } elem.addClass(this._getMarker()); options = $.extend(this.deepMerge, {}, this.defaultOptions, this._getMetadata(elem), options || {}); var inst = $.extend({name: this.name, elem: elem, options: options}, this._instSettings(elem, options)); elem.data(this.name, inst); // Save instance against element this._postAttach(elem, inst); this.option(elem, options); }, /** Retrieve additional instance settings. Override this in a sub-class to provide extra settings. These are added directly to the instance object. Default attributes of an instance object are shown as properties below: @protected @param {jQuery} elem The current jQuery element. @param {object} options The instance options. @return {object} Any extra instance values. @property {Element} elem The element to which this instance applies. @property {string} name The name of this plugin. @property {object} options The accumulated options for this instance. @example _instSettings: function(elem, options) { return {nav: elem.find(options.navSelector)}; } */ _instSettings: function(elem, options) { // jshint unused:false return {}; }, /** Plugin specific post initialisation. Override this in a sub-class to perform extra activities. This is where you would implement your plugin's main functionality. @protected @param {jQuery} elem The current jQuery element. @param {object} inst The instance settings. @example _postAttach: function(elem, inst) { elem.on('click.' + this.name, function() { ... }); } */ _postAttach: function(elem, inst) { // jshint unused:false }, /** Retrieve metadata configuration from the element. Metadata is specified as an attribute: data-<pluginName>="<option name>: '<value>', ...". Dates should be specified as strings in this format: 'new Date(y, m-1, d)'. @private @param {jQuery} elem The source element. @return {object} The inline configuration or {}. */ _getMetadata: function(elem) { try { var data = elem.data(this.name.toLowerCase()) || ''; data = data.replace(/(\\?)'/g, function(e, t) { return t ? '\'' : '"'; }).replace(/([a-zA-Z0-9]+):/g, function(match, group, i) { var count = data.substring(0, i).match(/"/g); // Handle embedded ':' return (!count || count.length % 2 === 0 ? '"' + group + '":' : group + ':'); }).replace(/\\:/g, ':'); data = $.parseJSON('{' + data + '}'); for (var key in data) { if (data.hasOwnProperty(key)) { var value = data[key]; if (typeof value === 'string' && value.match(/^new Date\(([-0-9,\s]*)\)$/)) { // Convert dates data[key] = eval(value); // jshint ignore:line } } } return data; } catch (e) { return {}; } }, /** Retrieve the instance data for element. @protected @param {Element} elem The source element. @return {object} The instance data or {} if none. */ _getInst: function(elem) { return $(elem).data(this.name) || {}; }, /** Retrieve or reconfigure the settings for a plugin. If new settings are provided they are applied to the instance options. If an option name only is provided the value of that option is returned. If no name or value is provided, all options are returned. Override {@linkcode module:JQPlugin~_optionsChanged|_optionsChanged} for plugin-specific processing when option values change. @param {Element} elem The source element. @param {object|string} [name] The collection of new option values or the name of a single option. @param {any} [value] The value for a single named option. @return {any|object} If retrieving a single value or all options. @example $(selector).plugin('option', 'name', value) // Set one option $(selector).plugin('option', {name: value, ...}) // Set multiple options var value = $(selector).plugin('option', 'name') // Get one option var options = $(selector).plugin('option') // Get all options */ option: function(elem, name, value) { elem = $(elem); var inst = elem.data(this.name); var options = name || {}; if (!name || (typeof name === 'string' && typeof value === 'undefined')) { options = (inst || {}).options; return (options && name ? options[name] : options); } if (!elem.hasClass(this._getMarker())) { return; } if (typeof name === 'string') { options = {}; options[name] = value; } this._optionsChanged(elem, inst, options); $.extend(inst.options, options); }, /** Plugin specific options processing. Old value available in inst.options[name], new value in options[name]. Override this in a sub-class to perform extra activities. @protected @param {jQuery} elem The current jQuery element. @param {object} inst The instance settings. @param {object} options The new options. @example _optionsChanged: function(elem, inst, options) { if (options.name != inst.options.name) { elem.removeClass(inst.options.name).addClass(options.name); } } */ _optionsChanged: function(elem, inst, options) { // jshint unused:false }, /** Remove all trace of the plugin. Override {@linkcode module:JQPlugin~_preDestroy|_preDestroy} for plugin-specific processing. @param {Element} elem The source element. @example $(selector).plugin('destroy') */ destroy: function(elem) { elem = $(elem); if (!elem.hasClass(this._getMarker())) { return; } this._preDestroy(elem, this._getInst(elem)); elem.removeData(this.name).removeClass(this._getMarker()); }, /** Plugin specific pre destruction. It is invoked as part of the {@linkcode module:JQPlugin~destroy|destroy} processing. Override this in a sub-class to perform extra activities and undo everything that was done in the {@linkcode module:JQPlugin~_postAttach|_postAttach} or {@linkcode module:JQPlugin~_optionsChanged|_optionsChanged} functions. @protected @param {jQuery} elem The current jQuery element. @param {object} inst The instance settings. @example _preDestroy: function(elem, inst) { elem.off('.' + this.name); } */ _preDestroy: function(elem, inst) { // jshint unused:false } }); /** Convert names from hyphenated to camel-case. @private @param {string} value The original hyphenated name. @return {string} The camel-case version. */ function camelCase(name) { return name.replace(/-([a-z])/g, function(match, group) { return group.toUpperCase(); }); } /** Expose the plugin base. @namespace $.JQPlugin */ $.JQPlugin = { /** Create a new collection plugin. @memberof $.JQPlugin @param {string} [superClass='JQPlugin'] The name of the parent class to inherit from. @param {object} overrides The property/function overrides for the new class. See {@link module:JQPlugin|JQPlugin} for the base functionality. @example $.JQPlugin.createPlugin({ // Define the plugin name: 'tabs', defaultOptions: {selectedClass: 'selected'}, _initSettings: function(elem, options) { return {...}; }, _postAttach: function(elem, inst) { ... } }); $('selector').tabs(); // And instantiate it */ createPlugin: function(superClass, overrides) { if (typeof superClass === 'object') { overrides = superClass; superClass = 'JQPlugin'; } superClass = camelCase(superClass); var className = camelCase(overrides.name); JQClass.classes[className] = JQClass.classes[superClass].extend(overrides); new JQClass.classes[className](); // jshint ignore:line } }; })(jQuery); ================================================ FILE: doc/global.html ================================================ JSDoc: Global

Global

Type Definitions

CountdownExpiryCallback()

Countdown expiry callback. Used with the onExpiry option and triggered when the countdown expires.
This:
  • Element
Source:
Example
onExpiry: function() {
  alert('Done');
}

CountdownServerSyncCallback() → {Date}

Countdown server synchronisation callback. Used with the serverSync option and triggered when the countdown is initialised.
This:
  • $.countdown
Source:
Returns:
The current date/time on the server as expressed in the local timezone.
Type
Date
Example
serverSync: function() {
  var time = null;
  $.ajax({url: 'http://myserver.com/serverTime.php',
    async: false, dataType: 'text',
    success: function(text) {
      time = new Date(text);
    }, error: function(http, message, exc) {
      time = new Date();
  });
  return time;
}

CountdownTickCallback(periods)

Countdown tick callback. Used with the onTick option and triggered on every tickInterval ticks of the countdown.
This:
  • Element
Parameters:
Name Type Description
periods Array.<number> The breakdown by period (years, months, weeks, days, hours, minutes, seconds) of the time remaining/passed.
Source:
Example
onTick: function(periods) {
  $('#altTime').text(periods[4] + ':' + twoDigits(periods[5]) +
    ':' + twoDigits(periods[6]));
}

CountdownWhichLabelsCallback(num) → {number}

Countdown which labels callback. Used with the whichLabels option and triggered when the countdown is being display to determine which set of labels (labels, labels1, ...) are to be used for the current period value.
Parameters:
Name Type Description
num number The current period value.
Source:
Returns:
The suffix for the label set to use, or zero for the default labels.
Type
number
Example
whichLabels: function(num) {
  return (num === 1 ? 1 : (num >= 2 && num <= 4 ? 2 : 0));
}

Documentation generated by JSDoc 3.4.1 on Sat Nov 19 2016 20:51:10 GMT+1100 (AUS Eastern Daylight Time)
================================================ FILE: doc/index.html ================================================ JSDoc: Home

Home


Documentation generated by JSDoc 3.4.1 on Sat Nov 19 2016 20:51:10 GMT+1100 (AUS Eastern Daylight Time)
================================================ FILE: doc/jquery.countdown.js.html ================================================ JSDoc: Source: jquery.countdown.js

Source: jquery.countdown.js

/*! http://keith-wood.name/countdown.html
	Countdown for jQuery v2.1.0.
	Written by Keith Wood (wood.keith{at}optusnet.com.au) January 2008.
	Available under the MIT (http://keith-wood.name/licence.html) license. 
	Please attribute the author if you use it. */

(function($) { // Hide scope, no $ conflict
	'use strict';

	var pluginName = 'countdown';

	var Y = 0; // Years
	var O = 1; // Months
	var W = 2; // Weeks
	var D = 3; // Days
	var H = 4; // Hours
	var M = 5; // Minutes
	var S = 6; // Seconds

	/** Create the countdown plugin.
		<p>Sets an element to show the time remaining until a given instant.</p>
		<p>Expects HTML like:</p>
		<pre>&lt;div>&lt;/div></pre>
		<p>Provide inline configuration like:</p>
		<pre>&lt;div data-countdown="name: 'value', ...">&lt;/div></pre>
		@module Countdown
		@augments JQPlugin
		@example $(selector).countdown({until: +300}) */
	$.JQPlugin.createPlugin({
	
		/** The name of the plugin.
			@default 'countdown' */
		name: pluginName,

		/** Countdown expiry callback.
			Used with the {@linkcode module:Countdown~defaultOptions|onExpiry} option and
			triggered when the countdown expires.
			@global
			@callback CountdownExpiryCallback
			@this <code>Element</code>
			@example onExpiry: function() {
  alert('Done');
} */

		/** Countdown server synchronisation callback.
			Used with the {@linkcode module:Countdown~defaultOptions|serverSync} option and
			triggered when the countdown is initialised.
			@global
			@callback CountdownServerSyncCallback
			@return {Date} The current date/time on the server as expressed in the local timezone.
			@this <code>$.countdown</code>
			@example serverSync: function() {
  var time = null;
  $.ajax({url: 'http://myserver.com/serverTime.php',
    async: false, dataType: 'text',
    success: function(text) {
      time = new Date(text);
    }, error: function(http, message, exc) {
      time = new Date();
  });
  return time;
} */
			
		/** Countdown tick callback.
			Used with the {@linkcode module:Countdown~defaultOptions|onTick} option and
			triggered on every {@linkcode module:Countdown~defaultOptions|tickInterval} ticks of the countdown.
			@global
			@callback CountdownTickCallback
			@this <code>Element</code>
			@param {number[]} periods The breakdown by period (years, months, weeks, days,
					hours, minutes, seconds) of the time remaining/passed.
			@example onTick: function(periods) {
  $('#altTime').text(periods[4] + ':' + twoDigits(periods[5]) +
    ':' + twoDigits(periods[6]));
} */

		/** Countdown which labels callback.
			Used with the {@linkcode module:Countdown~regionalOptions|whichLabels} option and
			triggered when the countdown is being display to determine which set of labels
			(<code>labels</code>, <code>labels1</code>, ...) are to be used for the current period value.
			@global
			@callback CountdownWhichLabelsCallback
			@param {number} num The current period value.
			@return {number} The suffix for the label set to use, or zero for the default labels.
			@example whichLabels: function(num) {
  return (num === 1 ? 1 : (num >= 2 && num <= 4 ? 2 : 0));
} */
			
		/** Default settings for the plugin.
			@property {Date|number|string} [until] The date/time to count down to, or number of seconds
						offset from now, or string of amounts and units for offset(s) from now:
						'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds.
						One of <code>until</code> or <code>since</code> must be specified.
						If both are given <code>since</code> takes precedence.
			@example until: new Date(2013, 12-1, 25, 13, 30)
until: +300
until: '+1O -2D'
			@property {Date|number|string} [since] The date/time to count up from, or number of seconds
						offset from now, or string of amounts and units for offset(s) from now:
						'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds.
						One of <code>until</code> or <code>since</code> must be specified.
						If both are given <code>since</code> takes precedence.
			@example since: new Date(2013, 1-1, 1)
since: -300
since: '-1O +2D'
			@property {number} [timezone=null] The timezone (hours or minutes from GMT) for the target times,
						or <code>null</code> for client local timezone.
			@example timezone: +10
timezone: -60
			@property {CountdownServerSyncCallback} [serverSync=null] A function to retrieve the current server time
						for synchronisation.
			@property {string} [format='dHMS'] The format for display - upper case to always show,
						lower case to show only if non-zero,
						'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds.
			@property {string} [layout=''] <p>Build your own layout for the countdown.</p>
						<p>Indicate substitution points with '{desc}' for the description, '{sep}' for the time separator,
						'{pv}' where p is 'y' for years, 'o' for months, 'w' for weeks, 'd' for days,
						'h' for hours, 'm' for minutes, or 's' for seconds and v is 'n' for the period value,
						'nn' for the period value with a minimum of two digits,
						'nnn' for the period value with a minimum of three digits, or
						'l' for the period label (long or short form depending on the compact setting), or
						'{pd}' where p is as above and d is '1' for the units digit, '10' for the tens digit,
						'100' for the hundreds digit, or '1000' for the thousands digit.</p>
						<p>If you need to exclude entire sections when the period value is zero and
						you have specified the period as optional, surround these sections with
						'{p<}' and '{p>}', where p is the same as above.</p>
						<p>Your layout can just be simple text, or can contain HTML markup as well.</p>
			@example layout: '{d<}{dn} {dl}{d>} {hnn}:{mnn}:{snn}'
			@property {boolean} [compact=false] <code>true</code> to display in a compact format,
						<code>false</code> for an expanded one.
			@property {boolean} [padZeroes=false] <code>true</code> to add leading zeroes.
			@property {number} [significant=0] The maximum number of periods with non-zero values to show, zero for all.
			@property {string} [description=''] The description displayed for the countdown.
			@property {string} [expiryUrl=''] A URL to load upon expiry, replacing the current page.
			@property {string} [expiryText=''] Text to display upon expiry, replacing the countdown. This may be HTML.
			@property {boolean} [alwaysExpire=false] <code>true</code> to trigger <code>onExpiry</code>
						even if the target time has passed.
			@property {CountdownExpiryCallback} [onExpiry=null] Callback when the countdown expires -
						receives no parameters and <code>this</code> is the containing element.
			@example onExpiry: function() {
  ...
}
			@property {CountdownTickCallback} [onTick=null] Callback when the countdown is updated -
						receives <code>number[7]</code> being the breakdown by period
						(years, months, weeks, days, hours, minutes, seconds - based on
						<code>format</code>) and <code>this</code> is the containing element.
			@example onTick: function(periods) {
  var secs = $.countdown.periodsToSeconds(periods);
  if (secs < 300) { // Last five minutes
    ...
  }
}
			@property {number} [tickInterval=1] The interval (seconds) between <code>onTick</code> callbacks. */
		defaultOptions: {
			until: null,
			since: null,
			timezone: null,
			serverSync: null,
			format: 'dHMS',
			layout: '',
			compact: false,
			padZeroes: false,
			significant: 0,
			description: '',
			expiryUrl: '',
			expiryText: '',
			alwaysExpire: false,
			onExpiry: null,
			onTick: null,
			tickInterval: 1
		},

		/** Localisations for the plugin.
			Entries are objects indexed by the language code ('' being the default US/English).
			Each object has the following attributes.
			@property {string[]} [labels=['Years','Months','Weeks','Days','Hours','Minutes','Seconds']]
						The display texts for the counter periods.
			@property {string[]} [labels1=['Year','Month','Week','Day','Hour','Minute','Second']]
						The display texts for the counter periods if they have a value of 1.
						Add other <code>labels<em>n</em></code> attributes as necessary to
						cater for other numeric idiosyncrasies of the localisation.
			@property {string[]}[compactLabels=['y','m','w','d']] The compact texts for the counter periods.
			@property {CountdownWhichLabelsCallback} [whichLabels=null] A function to determine which
						<code>labels<em>n</em></code> to use.
			@example whichLabels: function(num) {
  return (num > 1 ? 0 : 1);
}
			@property {string[]} [digits=['0','1',...,'9']] The digits to display (0-9).
			@property {string} [timeSeparator=':'] Separator for time periods in the compact layout.
			@property {boolean} [isRTL=false] <code>true</code> for right-to-left languages,
						<code>false</code> for left-to-right. */
		regionalOptions: { // Available regional settings, indexed by language/country code
			'': { // Default regional settings - English/US
				labels: ['Years', 'Months', 'Weeks', 'Days', 'Hours', 'Minutes', 'Seconds'],
				labels1: ['Year', 'Month', 'Week', 'Day', 'Hour', 'Minute', 'Second'],
				compactLabels: ['y', 'm', 'w', 'd'],
				whichLabels: null,
				digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
				timeSeparator: ':',
				isRTL: false
			}
		},

		/* Class name for the right-to-left marker. */
		_rtlClass: pluginName + '-rtl',
		/* Class name for the countdown section marker. */
		_sectionClass: pluginName + '-section',
		/* Class name for the period amount marker. */
		_amountClass: pluginName + '-amount',
		/* Class name for the period name marker. */
		_periodClass: pluginName + '-period',
		/* Class name for the countdown row marker. */
		_rowClass: pluginName + '-row',
		/* Class name for the holding countdown marker. */
		_holdingClass: pluginName + '-holding',
		/* Class name for the showing countdown marker. */
		_showClass: pluginName + '-show',
		/* Class name for the description marker. */
		_descrClass: pluginName + '-descr',

		/* List of currently active countdown elements. */
		_timerElems: [],

		/** Additional setup for the countdown.
			Apply default localisations.
			Create the timer.
			@private */
		_init: function() {
			var self = this;
			this._super();
			this._serverSyncs = [];
			var now = (typeof Date.now === 'function' ? Date.now : function() { return new Date().getTime(); });
			var perfAvail = (window.performance && typeof window.performance.now === 'function');
			// Shared timer for all countdowns
			function timerCallBack(timestamp) {
				var drawStart = (timestamp < 1e12 ? // New HTML5 high resolution timer
					(perfAvail ? (window.performance.now() + window.performance.timing.navigationStart) : now()) :
					// Integer milliseconds since unix epoch
					timestamp || now());
				if (drawStart - animationStartTime >= 1000) {
					self._updateElems();
					animationStartTime = drawStart;
				}
				requestAnimationFrame(timerCallBack);
			}
			var requestAnimationFrame = window.requestAnimationFrame ||
				window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame ||
				window.oRequestAnimationFrame || window.msRequestAnimationFrame || null;
				// This is when we expect a fall-back to setInterval as it's much more fluid
			var animationStartTime = 0;
			if (!requestAnimationFrame || $.noRequestAnimationFrame) {
				$.noRequestAnimationFrame = null;
				// Fall back to good old setInterval
				$.countdown._timer = setInterval(function() { self._updateElems(); }, 1000);
			}
			else {
				animationStartTime = window.animationStartTime ||
					window.webkitAnimationStartTime || window.mozAnimationStartTime ||
					window.oAnimationStartTime || window.msAnimationStartTime || now();
				requestAnimationFrame(timerCallBack);
			}
		},

		/** Convert a date/time to UTC.
			@param {number} tz The hour or minute offset from GMT, e.g. +9, -360.
			@param {Date|number} year the date/time in that timezone or the year in that timezone.
			@param {number} [month] The month (0 - 11) (omit if <code>year</code> is a <code>Date</code>).
			@param {number} [day] The day (omit if <code>year</code> is a <code>Date</code>).
			@param {number} [hours] The hour (omit if <code>year</code> is a <code>Date</code>).
			@param {number} [mins] The minute (omit if <code>year</code> is a <code>Date</code>).
			@param {number} [secs] The second (omit if <code>year</code> is a <code>Date</code>).
			@param {number} [ms] The millisecond (omit if <code>year</code> is a <code>Date</code>).
			@return {Date} The equivalent UTC date/time.
			@example $.countdown.UTCDate(+10, 2013, 12-1, 25, 12, 0)
$.countdown.UTCDate(-7, new Date(2013, 12-1, 25, 12, 0)) */
		UTCDate: function(tz, year, month, day, hours, mins, secs, ms) {
			if (typeof year === 'object' && year instanceof Date) {
				ms = year.getMilliseconds();
				secs = year.getSeconds();
				mins = year.getMinutes();
				hours = year.getHours();
				day = year.getDate();
				month = year.getMonth();
				year = year.getFullYear();
			}
			var d = new Date();
			d.setUTCFullYear(year);
			d.setUTCDate(1);
			d.setUTCMonth(month || 0);
			d.setUTCDate(day || 1);
			d.setUTCHours(hours || 0);
			d.setUTCMinutes((mins || 0) - (Math.abs(tz) < 30 ? tz * 60 : tz));
			d.setUTCSeconds(secs || 0);
			d.setUTCMilliseconds(ms || 0);
			return d;
		},

		/** Convert a set of periods into seconds.
			Averaged for months and years.
			@param {number[]} periods The periods per year/month/week/day/hour/minute/second.
			@return {number} The corresponding number of seconds.
			@example var secs = $.countdown.periodsToSeconds(periods) */
		periodsToSeconds: function(periods) {
			return periods[0] * 31557600 + periods[1] * 2629800 + periods[2] * 604800 +
				periods[3] * 86400 + periods[4] * 3600 + periods[5] * 60 + periods[6];
		},

		/** Resynchronise the countdowns with the server.
			@example $.countdown.resync() */
		resync: function() {
			var self = this;
			$('.' + this._getMarker()).each(function() { // Each countdown
				var inst = $.data(this, self.name);
				if (inst.options.serverSync) { // If synced
					var serverSync = null;
					for (var i = 0; i < self._serverSyncs.length; i++) {
						if (self._serverSyncs[i][0] === inst.options.serverSync) { // Find sync details
							serverSync = self._serverSyncs[i];
							break;
						}
					}
					if (self._eqNull(serverSync[2])) { // Recalculate if missing
						var serverResult = ($.isFunction(inst.options.serverSync) ?
							inst.options.serverSync.apply(this, []) : null);
						serverSync[2] =
							(serverResult ? new Date().getTime() - serverResult.getTime() : 0) - serverSync[1];
					}
					if (inst._since) { // Apply difference
						inst._since.setMilliseconds(inst._since.getMilliseconds() + serverSync[2]);
					}
					inst._until.setMilliseconds(inst._until.getMilliseconds() + serverSync[2]);
				}
			});
			for (var i = 0; i < self._serverSyncs.length; i++) { // Update sync details
				if (!self._eqNull(self._serverSyncs[i][2])) {
					self._serverSyncs[i][1] += self._serverSyncs[i][2];
					delete self._serverSyncs[i][2];
				}
			}
		},

		_instSettings: function(elem, options) { // jshint unused:false
			return {_periods: [0, 0, 0, 0, 0, 0, 0]};
		},

		/** Add an element to the list of active ones.
			@private
			@param {Element} elem The countdown element. */
		_addElem: function(elem) {
			if (!this._hasElem(elem)) {
				this._timerElems.push(elem);
			}
		},

		/** See if an element is in the list of active ones.
			@private
			@param {Element} elem The countdown element.
			@return {boolean} <code>true</code> if present, <code>false</code> if not. */
		_hasElem: function(elem) {
			return ($.inArray(elem, this._timerElems) > -1);
		},

		/** Remove an element from the list of active ones.
			@private
			@param {Element} elem The countdown element. */
		_removeElem: function(elem) {
			this._timerElems = $.map(this._timerElems,
				function(value) { return (value === elem ? null : value); }); // delete entry
		},

		/** Update each active timer element.
			@private */
		_updateElems: function() {
			for (var i = this._timerElems.length - 1; i >= 0; i--) {
				this._updateCountdown(this._timerElems[i]);
			}
		},

		_optionsChanged: function(elem, inst, options) {
			if (options.layout) {
				options.layout = options.layout.replace(/&lt;/g, '<').replace(/&gt;/g, '>');
			}
			this._resetExtraLabels(inst.options, options);
			var timezoneChanged = (inst.options.timezone !== options.timezone);
			$.extend(inst.options, options);
			this._adjustSettings(elem, inst,
				!this._eqNull(options.until) || !this._eqNull(options.since) || timezoneChanged);
			var now = new Date();
			if ((inst._since && inst._since < now) || (inst._until && inst._until > now)) {
				this._addElem(elem[0]);
			}
			this._updateCountdown(elem, inst);
		},

		/** Redisplay the countdown with an updated display.
			@private
			@param {Element|jQuery} elem The containing element.
			@param {object} inst The current settings for this instance. */
		_updateCountdown: function(elem, inst) {
			elem = elem.jquery ? elem : $(elem);
			inst = inst || this._getInst(elem);
			if (!inst) {
				return;
			}
			elem.html(this._generateHTML(inst)).toggleClass(this._rtlClass, inst.options.isRTL);
			if (inst._hold !== 'pause' && $.isFunction(inst.options.onTick)) {
				var periods = inst._hold !== 'lap' ? inst._periods :
					this._calculatePeriods(inst, inst._show, inst.options.significant, new Date());
				if (inst.options.tickInterval === 1 ||
						this.periodsToSeconds(periods) % inst.options.tickInterval === 0) {
					inst.options.onTick.apply(elem[0], [periods]);
				}
			}
			var expired = inst._hold !== 'pause' &&
				(inst._since ? inst._now.getTime() < inst._since.getTime() :
				inst._now.getTime() >= inst._until.getTime());
			if (expired && !inst._expiring) {
				inst._expiring = true;
				if (this._hasElem(elem[0]) || inst.options.alwaysExpire) {
					this._removeElem(elem[0]);
					if ($.isFunction(inst.options.onExpiry)) {
						inst.options.onExpiry.apply(elem[0], []);
					}
					if (inst.options.expiryText) {
						var layout = inst.options.layout;
						inst.options.layout = inst.options.expiryText;
						this._updateCountdown(elem[0], inst);
						inst.options.layout = layout;
					}
					if (inst.options.expiryUrl) {
						window.location = inst.options.expiryUrl;
					}
				}
				inst._expiring = false;
			}
			else if (inst._hold === 'pause') {
				this._removeElem(elem[0]);
			}
		},

		/** Reset any extra labelsn and compactLabelsn entries if changing labels.
			@private
			@param {object} base The options to be updated.
			@param {object} options The new option values. */
		_resetExtraLabels: function(base, options) {
			var n = null;
			for (n in options) {
				if (n.match(/[Ll]abels[02-9]|compactLabels1/)) {
					base[n] = options[n];
				}
			}
			for (n in base) { // Remove custom numbered labels
				if (n.match(/[Ll]abels[02-9]|compactLabels1/) && typeof options[n] === 'undefined') {
					base[n] = null;
				}
			}
		},
		
		/** Determine whether or not a value is equivalent to <code>null</code>.
			@private
			@param {object} value The value to test.
			@return {boolean} <code>true</code> if equivalent to <code>null</code>, <code>false</code> if not. */
		_eqNull: function(value) {
			return typeof value === 'undefined' || value === null;
		},


		/** Calculate internal settings for an instance.
			@private
			@param {jQuery} elem The containing element.
			@param {object} inst The current settings for this instance.
			@param {boolean} recalc <code>true</code> if until or since are set. */
		_adjustSettings: function(elem, inst, recalc) {
			var serverEntry = null;
			for (var i = 0; i < this._serverSyncs.length; i++) {
				if (this._serverSyncs[i][0] === inst.options.serverSync) {
					serverEntry = this._serverSyncs[i][1];
					break;
				}
			}
			var now = null;
			var serverOffset = null;
			if (!this._eqNull(serverEntry)) {
				now = new Date();
				serverOffset = (inst.options.serverSync ? serverEntry : 0);
			}
			else {
				var serverResult = ($.isFunction(inst.options.serverSync) ?
					inst.options.serverSync.apply(elem[0], []) : null);
				now = new Date();
				serverOffset = (serverResult ? now.getTime() - serverResult.getTime() : 0);
				this._serverSyncs.push([inst.options.serverSync, serverOffset]);
			}
			var timezone = inst.options.timezone;
			timezone = (this._eqNull(timezone) ? -now.getTimezoneOffset() : timezone);
			if (recalc || (!recalc && this._eqNull(inst._until) && this._eqNull(inst._since))) {
				inst._since = inst.options.since;
				if (!this._eqNull(inst._since)) {
					inst._since = this.UTCDate(timezone, this._determineTime(inst._since, null));
					if (inst._since && serverOffset) {
						inst._since.setMilliseconds(inst._since.getMilliseconds() + serverOffset);
					}
				}
				inst._until = this.UTCDate(timezone, this._determineTime(inst.options.until, now));
				if (serverOffset) {
					inst._until.setMilliseconds(inst._until.getMilliseconds() + serverOffset);
				}
			}
			inst._show = this._determineShow(inst);
		},

		/** Remove the countdown widget from an element.
			@private
			@param {jQuery} elem The containing element.
			@param {object} inst The current instance object. */
		_preDestroy: function(elem, inst) { // jshint unused:false
			this._removeElem(elem[0]);
			elem.empty();
		},

		/** Pause a countdown widget at the current time.
			Stop it running but remember and display the current time.
			@param {Element} elem The containing element.
			@example $(selector).countdown('pause') */
		pause: function(elem) {
			this._hold(elem, 'pause');
		},

		/** Pause a countdown widget at the current time.
			Stop the display but keep the countdown running.
			@param {Element} elem The containing element.
			@example $(selector).countdown('lap') */
		lap: function(elem) {
			this._hold(elem, 'lap');
		},

		/** Resume a paused countdown widget.
			@param {Element} elem The containing element.
			@example $(selector).countdown('resume') */
		resume: function(elem) {
			this._hold(elem, null);
		},

		/** Toggle a paused countdown widget.
			@param {Element} elem The containing element.
			@example $(selector).countdown('toggle') */
		toggle: function(elem) {
			var inst = $.data(elem, this.name) || {};
			this[!inst._hold ? 'pause' : 'resume'](elem);
		},

		/** Toggle a lapped countdown widget.
			@param {Element} elem The containing element.
			@example $(selector).countdown('toggleLap') */
		toggleLap: function(elem) {
			var inst = $.data(elem, this.name) || {};
			this[!inst._hold ? 'lap' : 'resume'](elem);
		},

		/** Pause or resume a countdown widget.
			@private
			@param {Element} elem The containing element.
			@param {string} hold The new hold setting. */
		_hold: function(elem, hold) {
			var inst = $.data(elem, this.name);
			if (inst) {
				if (inst._hold === 'pause' && !hold) {
					inst._periods = inst._savePeriods;
					var sign = (inst._since ? '-' : '+');
					inst[inst._since ? '_since' : '_until'] =
						this._determineTime(sign + inst._periods[0] + 'y' +
							sign + inst._periods[1] + 'o' + sign + inst._periods[2] + 'w' +
							sign + inst._periods[3] + 'd' + sign + inst._periods[4] + 'h' + 
							sign + inst._periods[5] + 'm' + sign + inst._periods[6] + 's');
					this._addElem(elem);
				}
				inst._hold = hold;
				inst._savePeriods = (hold === 'pause' ? inst._periods : null);
				$.data(elem, this.name, inst);
				this._updateCountdown(elem, inst);
			}
		},

		/** Return the current time periods, broken down by years, months, weeks, days, hours, minutes, and seconds.
			@param {Element} elem The containing element.
			@return {number[]} The current periods for the countdown.
			@example var periods = $(selector).countdown('getTimes') */
		getTimes: function(elem) {
			var inst = $.data(elem, this.name);
			return (!inst ? null : (inst._hold === 'pause' ? inst._savePeriods : (!inst._hold ? inst._periods :
				this._calculatePeriods(inst, inst._show, inst.options.significant, new Date()))));
		},

		/** A time may be specified as an exact value or a relative one.
			@private
			@param {string|number|Date} setting The date/time value as a relative or absolute value.
			@param {Date} defaultTime The date/time to use if no other is supplied.
			@return {Date} The corresponding date/time. */
		_determineTime: function(setting, defaultTime) {
			var self = this;
			var offsetNumeric = function(offset) { // e.g. +300, -2
				var time = new Date();
				time.setTime(time.getTime() + offset * 1000);
				return time;
			};
			var offsetString = function(offset) { // e.g. '+2d', '-4w', '+3h +30m'
				offset = offset.toLowerCase();
				var time = new Date();
				var year = time.getFullYear();
				var month = time.getMonth();
				var day = time.getDate();
				var hour = time.getHours();
				var minute = time.getMinutes();
				var second = time.getSeconds();
				var pattern = /([+-]?[0-9]+)\s*(s|m|h|d|w|o|y)?/g;
				var matches = pattern.exec(offset);
				while (matches) {
					switch (matches[2] || 's') {
						case 's':
							second += parseInt(matches[1], 10);
							break;
						case 'm':
							minute += parseInt(matches[1], 10);
							break;
						case 'h':
							hour += parseInt(matches[1], 10);
							break;
						case 'd':
							day += parseInt(matches[1], 10);
							break;
						case 'w':
							day += parseInt(matches[1], 10) * 7;
							break;
						case 'o':
							month += parseInt(matches[1], 10); 
							day = Math.min(day, self._getDaysInMonth(year, month));
							break;
						case 'y':
							year += parseInt(matches[1], 10);
							day = Math.min(day, self._getDaysInMonth(year, month));
							break;
					}
					matches = pattern.exec(offset);
				}
				return new Date(year, month, day, hour, minute, second, 0);
			};
			var time = (this._eqNull(setting) ? defaultTime :
				(typeof setting === 'string' ? offsetString(setting) :
				(typeof setting === 'number' ? offsetNumeric(setting) : setting)));
			if (time) {
				time.setMilliseconds(0);
			}
			return time;
		},

		/** Determine the number of days in a month.
			@private
			@param {number} year The year.
			@param {number} month The month.
			@return {number} The days in that month. */
		_getDaysInMonth: function(year, month) {
			return 32 - new Date(year, month, 32).getDate();
		},

		/** Default implementation to determine which set of labels should be used for an amount.
			Use the <code>labels</code> attribute with the same numeric suffix (if it exists).
			@private
			@param {number} num The amount to be displayed.
			@return {number} The set of labels to be used for this amount. */
		_normalLabels: function(num) {
			return num;
		},

		/** Generate the HTML to display the countdown widget.
			@private
			@param {object} inst The current settings for this instance.
			@return {string} The new HTML for the countdown display. */
		_generateHTML: function(inst) {
			var self = this;
			// Determine what to show
			inst._periods = (inst._hold ? inst._periods :
				this._calculatePeriods(inst, inst._show, inst.options.significant, new Date()));
			// Show all 'asNeeded' after first non-zero value
			var shownNonZero = false;
			var showCount = 0;
			var sigCount = inst.options.significant;
			var show = $.extend({}, inst._show);
			var period = null;
			for (period = Y; period <= S; period++) {
				shownNonZero = shownNonZero || (inst._show[period] === '?' && inst._periods[period] > 0);
				show[period] = (inst._show[period] === '?' && !shownNonZero ? null : inst._show[period]);
				showCount += (show[period] ? 1 : 0);
				sigCount -= (inst._periods[period] > 0 ? 1 : 0);
			}
			var showSignificant = [false, false, false, false, false, false, false];
			for (period = S; period >= Y; period--) { // Determine significant periods
				if (inst._show[period]) {
					if (inst._periods[period]) {
						showSignificant[period] = true;
					}
					else {
						showSignificant[period] = sigCount > 0;
						sigCount--;
					}
				}
			}
			var labels = (inst.options.compact ? inst.options.compactLabels : inst.options.labels);
			var whichLabels = inst.options.whichLabels || this._normalLabels;
			var showCompact = function(period) {
				var labelsNum = inst.options['compactLabels' + whichLabels(inst._periods[period])];
				return (show[period] ? self._translateDigits(inst, inst._periods[period]) +
					(labelsNum ? labelsNum[period] : labels[period]) + ' ' : '');
			};
			var minDigits = (inst.options.padZeroes ? 2 : 1);
			var showFull = function(period) {
				var labelsNum = inst.options['labels' + whichLabels(inst._periods[period])];
				return ((!inst.options.significant && show[period]) ||
					(inst.options.significant && showSignificant[period]) ?
						'<span class="' + self._sectionClass + '">' +
						'<span class="' + self._amountClass + '">' +
					self._minDigits(inst, inst._periods[period], minDigits) + '</span>' +
					'<span class="' + self._periodClass + '">' +
					(labelsNum ? labelsNum[period] : labels[period]) + '</span></span>' : '');
			};
			return (inst.options.layout ? this._buildLayout(inst, show, inst.options.layout,
				inst.options.compact, inst.options.significant, showSignificant) :
				((inst.options.compact ? // Compact version
				'<span class="' + this._rowClass + ' ' + this._amountClass +
				(inst._hold ? ' ' + this._holdingClass : '') + '">' + 
				showCompact(Y) + showCompact(O) + showCompact(W) + showCompact(D) + 
				(show[H] ? this._minDigits(inst, inst._periods[H], 2) : '') +
				(show[M] ? (show[H] ? inst.options.timeSeparator : '') +
				this._minDigits(inst, inst._periods[M], 2) : '') +
				(show[S] ? (show[H] || show[M] ? inst.options.timeSeparator : '') +
				this._minDigits(inst, inst._periods[S], 2) : '') :
				// Full version
				'<span class="' + this._rowClass + ' ' + this._showClass + (inst.options.significant || showCount) +
				(inst._hold ? ' ' + this._holdingClass : '') + '">' +
				showFull(Y) + showFull(O) + showFull(W) + showFull(D) +
				showFull(H) + showFull(M) + showFull(S)) + '</span>' +
				(inst.options.description ? '<span class="' + this._rowClass + ' ' + this._descrClass + '">' +
				inst.options.description + '</span>' : '')));
		},

		/** Construct a custom layout.
			@private
			@param {object} inst The current settings for this instance.
			@param {boolean[]} show Flags indicating which periods are requested.
			@param {string} layout The customised layout.
			@param {boolean} compact <code>true</code> if using compact labels.
			@param {number} significant The number of periods with values to show, zero for all.
			@param {boolean[]} showSignificant Other periods to show for significance.
			@return {string} The custom HTML. */
		_buildLayout: function(inst, show, layout, compact, significant, showSignificant) {
			var labels = inst.options[compact ? 'compactLabels' : 'labels'];
			var whichLabels = inst.options.whichLabels || this._normalLabels;
			var labelFor = function(index) {
				return (inst.options[(compact ? 'compactLabels' : 'labels') +
					whichLabels(inst._periods[index])] || labels)[index];
			};
			var digit = function(value, position) {
				return inst.options.digits[Math.floor(value / position) % 10];
			};
			var subs = {desc: inst.options.description, sep: inst.options.timeSeparator,
				yl: labelFor(Y), yn: this._minDigits(inst, inst._periods[Y], 1),
				ynn: this._minDigits(inst, inst._periods[Y], 2),
				ynnn: this._minDigits(inst, inst._periods[Y], 3), y1: digit(inst._periods[Y], 1),
				y10: digit(inst._periods[Y], 10), y100: digit(inst._periods[Y], 100),
				y1000: digit(inst._periods[Y], 1000),
				ol: labelFor(O), on: this._minDigits(inst, inst._periods[O], 1),
				onn: this._minDigits(inst, inst._periods[O], 2),
				onnn: this._minDigits(inst, inst._periods[O], 3), o1: digit(inst._periods[O], 1),
				o10: digit(inst._periods[O], 10), o100: digit(inst._periods[O], 100),
				o1000: digit(inst._periods[O], 1000),
				wl: labelFor(W), wn: this._minDigits(inst, inst._periods[W], 1),
				wnn: this._minDigits(inst, inst._periods[W], 2),
				wnnn: this._minDigits(inst, inst._periods[W], 3), w1: digit(inst._periods[W], 1),
				w10: digit(inst._periods[W], 10), w100: digit(inst._periods[W], 100),
				w1000: digit(inst._periods[W], 1000),
				dl: labelFor(D), dn: this._minDigits(inst, inst._periods[D], 1),
				dnn: this._minDigits(inst, inst._periods[D], 2),
				dnnn: this._minDigits(inst, inst._periods[D], 3), d1: digit(inst._periods[D], 1),
				d10: digit(inst._periods[D], 10), d100: digit(inst._periods[D], 100),
				d1000: digit(inst._periods[D], 1000),
				hl: labelFor(H), hn: this._minDigits(inst, inst._periods[H], 1),
				hnn: this._minDigits(inst, inst._periods[H], 2),
				hnnn: this._minDigits(inst, inst._periods[H], 3), h1: digit(inst._periods[H], 1),
				h10: digit(inst._periods[H], 10), h100: digit(inst._periods[H], 100),
				h1000: digit(inst._periods[H], 1000),
				ml: labelFor(M), mn: this._minDigits(inst, inst._periods[M], 1),
				mnn: this._minDigits(inst, inst._periods[M], 2),
				mnnn: this._minDigits(inst, inst._periods[M], 3), m1: digit(inst._periods[M], 1),
				m10: digit(inst._periods[M], 10), m100: digit(inst._periods[M], 100),
				m1000: digit(inst._periods[M], 1000),
				sl: labelFor(S), sn: this._minDigits(inst, inst._periods[S], 1),
				snn: this._minDigits(inst, inst._periods[S], 2),
				snnn: this._minDigits(inst, inst._periods[S], 3), s1: digit(inst._periods[S], 1),
				s10: digit(inst._periods[S], 10), s100: digit(inst._periods[S], 100),
				s1000: digit(inst._periods[S], 1000)};
			var html = layout;
			// Replace period containers: {p<}...{p>}
			for (var i = Y; i <= S; i++) {
				var period = 'yowdhms'.charAt(i);
				var re = new RegExp('\\{' + period + '<\\}([\\s\\S]*)\\{' + period + '>\\}', 'g');
				html = html.replace(re, ((!significant && show[i]) ||
					(significant && showSignificant[i]) ? '$1' : ''));
			}
			// Replace period values: {pn}
			$.each(subs, function(n, v) {
				var re = new RegExp('\\{' + n + '\\}', 'g');
				html = html.replace(re, v);
			});
			return html;
		},

		/** Ensure a numeric value has at least n digits for display.
			@private
			@param {object} inst The current settings for this instance.
			@param {number} value The value to display.
			@param {number} len The minimum length.
			@return {string} The display text. */
		_minDigits: function(inst, value, len) {
			value = '' + value;
			if (value.length >= len) {
				return this._translateDigits(inst, value);
			}
			value = '0000000000' + value;
			return this._translateDigits(inst, value.substr(value.length - len));
		},

		/** Translate digits into other representations.
			@private
			@param {object} inst The current settings for this instance.
			@param {string} value The text to translate.
			@return {string} The translated text. */
		_translateDigits: function(inst, value) {
			return ('' + value).replace(/[0-9]/g, function(digit) {
					return inst.options.digits[digit];
				});
		},

		/** Translate the format into flags for each period.
			@private
			@param {object} inst The current settings for this instance.
			@return {string[]} Flags indicating which periods are requested (?) or
					required (!) by year, month, week, day, hour, minute, second. */
		_determineShow: function(inst) {
			var format = inst.options.format;
			var show = [];
			show[Y] = (format.match('y') ? '?' : (format.match('Y') ? '!' : null));
			show[O] = (format.match('o') ? '?' : (format.match('O') ? '!' : null));
			show[W] = (format.match('w') ? '?' : (format.match('W') ? '!' : null));
			show[D] = (format.match('d') ? '?' : (format.match('D') ? '!' : null));
			show[H] = (format.match('h') ? '?' : (format.match('H') ? '!' : null));
			show[M] = (format.match('m') ? '?' : (format.match('M') ? '!' : null));
			show[S] = (format.match('s') ? '?' : (format.match('S') ? '!' : null));
			return show;
		},

		/** Calculate the requested periods between now and the target time.
			@private
			@param {object} inst The current settings for this instance.
			@param {string[]} show Flags indicating which periods are requested/required.
			@param {number} significant The number of periods with values to show, zero for all.
			@param {Date} now The current date and time.
			@return {number[]} The current time periods (always positive)
					by year, month, week, day, hour, minute, second. */
		_calculatePeriods: function(inst, show, significant, now) {
			// Find endpoints
			inst._now = now;
			inst._now.setMilliseconds(0);
			var until = new Date(inst._now.getTime());
			if (inst._since) {
				if (now.getTime() < inst._since.getTime()) {
					inst._now = now = until;
				}
				else {
					now = inst._since;
				}
			}
			else {
				until.setTime(inst._until.getTime());
				if (now.getTime() > inst._until.getTime()) {
					inst._now = now = until;
				}
			}
			// Calculate differences by period
			var periods = [0, 0, 0, 0, 0, 0, 0];
			if (show[Y] || show[O]) {
				// Treat end of months as the same
				var lastNow = this._getDaysInMonth(now.getFullYear(), now.getMonth());
				var lastUntil = this._getDaysInMonth(until.getFullYear(), until.getMonth());
				var sameDay = (until.getDate() === now.getDate() ||
					(until.getDate() >= Math.min(lastNow, lastUntil) &&
					now.getDate() >= Math.min(lastNow, lastUntil)));
				var getSecs = function(date) {
					return (date.getHours() * 60 + date.getMinutes()) * 60 + date.getSeconds();
				};
				var months = Math.max(0,
					(until.getFullYear() - now.getFullYear()) * 12 + until.getMonth() - now.getMonth() +
					((until.getDate() < now.getDate() && !sameDay) ||
					(sameDay && getSecs(until) < getSecs(now)) ? -1 : 0));
				periods[Y] = (show[Y] ? Math.floor(months / 12) : 0);
				periods[O] = (show[O] ? months - periods[Y] * 12 : 0);
				// Adjust for months difference and end of month if necessary
				now = new Date(now.getTime());
				var wasLastDay = (now.getDate() === lastNow);
				var lastDay = this._getDaysInMonth(now.getFullYear() + periods[Y],
					now.getMonth() + periods[O]);
				if (now.getDate() > lastDay) {
					now.setDate(lastDay);
				}
				now.setFullYear(now.getFullYear() + periods[Y]);
				now.setMonth(now.getMonth() + periods[O]);
				if (wasLastDay) {
					now.setDate(lastDay);
				}
			}
			var diff = Math.floor((until.getTime() - now.getTime()) / 1000);
			var period = null;
			var extractPeriod = function(period, numSecs) {
				periods[period] = (show[period] ? Math.floor(diff / numSecs) : 0);
				diff -= periods[period] * numSecs;
			};
			extractPeriod(W, 604800);
			extractPeriod(D, 86400);
			extractPeriod(H, 3600);
			extractPeriod(M, 60);
			extractPeriod(S, 1);
			if (diff > 0 && !inst._since) { // Round up if left overs
				var multiplier = [1, 12, 4.3482, 7, 24, 60, 60];
				var lastShown = S;
				var max = 1;
				for (period = S; period >= Y; period--) {
					if (show[period]) {
						if (periods[lastShown] >= max) {
							periods[lastShown] = 0;
							diff = 1;
						}
						if (diff > 0) {
							periods[period]++;
							diff = 0;
							lastShown = period;
							max = 1;
						}
					}
					max *= multiplier[period];
				}
			}
			if (significant) { // Zero out insignificant periods
				for (period = Y; period <= S; period++) {
					if (significant && periods[period]) {
						significant--;
					}
					else if (!significant) {
						periods[period] = 0;
					}
				}
			}
			return periods;
		}
	});

})(jQuery);

Documentation generated by JSDoc 3.4.1 on Sat Nov 19 2016 20:51:10 GMT+1100 (AUS Eastern Daylight Time)
================================================ FILE: doc/module-Countdown.html ================================================ JSDoc: Module: Countdown

Module: Countdown

Create the countdown plugin.

Sets an element to show the time remaining until a given instant.

Expects HTML like:

<div></div>

Provide inline configuration like:

<div data-countdown="name: 'value', ..."></div>
Source:
Example
$(selector).countdown({until: +300})

Extends

  • JQPlugin

Members

(inner) defaultOptions

Default settings for the plugin.
Properties:
Name Type Attributes Default Description
until Date | number | string <optional>
The date/time to count down to, or number of seconds offset from now, or string of amounts and units for offset(s) from now: 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds. One of until or since must be specified. If both are given since takes precedence.
since Date | number | string <optional>
The date/time to count up from, or number of seconds offset from now, or string of amounts and units for offset(s) from now: 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds. One of until or since must be specified. If both are given since takes precedence.
timezone number <optional>
null The timezone (hours or minutes from GMT) for the target times, or null for client local timezone.
serverSync CountdownServerSyncCallback <optional>
null A function to retrieve the current server time for synchronisation.
format string <optional>
'dHMS' The format for display - upper case to always show, lower case to show only if non-zero, 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds.
layout string <optional>
''

Build your own layout for the countdown.

Indicate substitution points with '{desc}' for the description, '{sep}' for the time separator, '{pv}' where p is 'y' for years, 'o' for months, 'w' for weeks, 'd' for days, 'h' for hours, 'm' for minutes, or 's' for seconds and v is 'n' for the period value, 'nn' for the period value with a minimum of two digits, 'nnn' for the period value with a minimum of three digits, or 'l' for the period label (long or short form depending on the compact setting), or '{pd}' where p is as above and d is '1' for the units digit, '10' for the tens digit, '100' for the hundreds digit, or '1000' for the thousands digit.

If you need to exclude entire sections when the period value is zero and you have specified the period as optional, surround these sections with '{p<}' and '{p>}', where p is the same as above.

Your layout can just be simple text, or can contain HTML markup as well.

compact boolean <optional>
false true to display in a compact format, false for an expanded one.
padZeroes boolean <optional>
false true to add leading zeroes.
significant number <optional>
0 The maximum number of periods with non-zero values to show, zero for all.
description string <optional>
'' The description displayed for the countdown.
expiryUrl string <optional>
'' A URL to load upon expiry, replacing the current page.
expiryText string <optional>
'' Text to display upon expiry, replacing the countdown. This may be HTML.
alwaysExpire boolean <optional>
false true to trigger onExpiry even if the target time has passed.
onExpiry CountdownExpiryCallback <optional>
null Callback when the countdown expires - receives no parameters and this is the containing element.
onTick CountdownTickCallback <optional>
null Callback when the countdown is updated - receives number[7] being the breakdown by period (years, months, weeks, days, hours, minutes, seconds - based on format) and this is the containing element.
tickInterval number <optional>
1 The interval (seconds) between onTick callbacks.
Source:
Examples
until: new Date(2013, 12-1, 25, 13, 30)
until: +300
until: '+1O -2D'
			
since: new Date(2013, 1-1, 1)
since: -300
since: '-1O +2D'
			
timezone: +10
timezone: -60
			
layout: '{d<}{dn} {dl}{d>} {hnn}:{mnn}:{snn}'
			
onExpiry: function() {
  ...
}
			
onTick: function(periods) {
  var secs = $.countdown.periodsToSeconds(periods);
  if (secs < 300) { // Last five minutes
    ...
  }
}
			

(inner) name

The name of the plugin.
Default Value:
  • 'countdown'
Source:

(inner) regionalOptions

Localisations for the plugin. Entries are objects indexed by the language code ('' being the default US/English). Each object has the following attributes.
Properties:
Name Type Attributes Default Description
labels Array.<string> <optional>
['Years','Months','Weeks','Days','Hours','Minutes','Seconds'] The display texts for the counter periods.
labels1 Array.<string> <optional>
['Year','Month','Week','Day','Hour','Minute','Second'] The display texts for the counter periods if they have a value of 1. Add other labelsn attributes as necessary to cater for other numeric idiosyncrasies of the localisation.
compactLabels Array.<string> <optional>
['y','m','w','d'] The compact texts for the counter periods.
whichLabels CountdownWhichLabelsCallback <optional>
null A function to determine which labelsn to use.
digits Array.<string> <optional>
['0','1',...,'9'] The digits to display (0-9).
timeSeparator string <optional>
':' Separator for time periods in the compact layout.
isRTL boolean <optional>
false true for right-to-left languages, false for left-to-right.
Source:
Example
whichLabels: function(num) {
  return (num > 1 ? 0 : 1);
}
			

Methods

(inner) getTimes(elem) → {Array.<number>}

Return the current time periods, broken down by years, months, weeks, days, hours, minutes, and seconds.
Parameters:
Name Type Description
elem Element The containing element.
Source:
Returns:
The current periods for the countdown.
Type
Array.<number>
Example
var periods = $(selector).countdown('getTimes')

(inner) lap(elem)

Pause a countdown widget at the current time. Stop the display but keep the countdown running.
Parameters:
Name Type Description
elem Element The containing element.
Source:
Example
$(selector).countdown('lap')

(inner) pause(elem)

Pause a countdown widget at the current time. Stop it running but remember and display the current time.
Parameters:
Name Type Description
elem Element The containing element.
Source:
Example
$(selector).countdown('pause')

(inner) periodsToSeconds(periods) → {number}

Convert a set of periods into seconds. Averaged for months and years.
Parameters:
Name Type Description
periods Array.<number> The periods per year/month/week/day/hour/minute/second.
Source:
Returns:
The corresponding number of seconds.
Type
number
Example
var secs = $.countdown.periodsToSeconds(periods)

(inner) resume(elem)

Resume a paused countdown widget.
Parameters:
Name Type Description
elem Element The containing element.
Source:
Example
$(selector).countdown('resume')

(inner) resync()

Resynchronise the countdowns with the server.
Source:
Example
$.countdown.resync()

(inner) toggle(elem)

Toggle a paused countdown widget.
Parameters:
Name Type Description
elem Element The containing element.
Source:
Example
$(selector).countdown('toggle')

(inner) toggleLap(elem)

Toggle a lapped countdown widget.
Parameters:
Name Type Description
elem Element The containing element.
Source:
Example
$(selector).countdown('toggleLap')

(inner) UTCDate(tz, year, monthopt, dayopt, hoursopt, minsopt, secsopt, msopt) → {Date}

Convert a date/time to UTC.
Parameters:
Name Type Attributes Description
tz number The hour or minute offset from GMT, e.g. +9, -360.
year Date | number the date/time in that timezone or the year in that timezone.
month number <optional>
The month (0 - 11) (omit if year is a Date).
day number <optional>
The day (omit if year is a Date).
hours number <optional>
The hour (omit if year is a Date).
mins number <optional>
The minute (omit if year is a Date).
secs number <optional>
The second (omit if year is a Date).
ms number <optional>
The millisecond (omit if year is a Date).
Source:
Returns:
The equivalent UTC date/time.
Type
Date
Example
$.countdown.UTCDate(+10, 2013, 12-1, 25, 12, 0)
$.countdown.UTCDate(-7, new Date(2013, 12-1, 25, 12, 0))

Documentation generated by JSDoc 3.4.1 on Sat Nov 19 2016 20:51:10 GMT+1100 (AUS Eastern Daylight Time)
================================================ FILE: doc/styles/jsdoc-default.css ================================================ @font-face { font-family: 'Open Sans'; font-weight: normal; font-style: normal; src: url('../fonts/OpenSans-Regular-webfont.eot'); src: local('Open Sans'), local('OpenSans'), url('../fonts/OpenSans-Regular-webfont.eot?#iefix') format('embedded-opentype'), url('../fonts/OpenSans-Regular-webfont.woff') format('woff'), url('../fonts/OpenSans-Regular-webfont.svg#open_sansregular') format('svg'); } @font-face { font-family: 'Open Sans Light'; font-weight: normal; font-style: normal; src: url('../fonts/OpenSans-Light-webfont.eot'); src: local('Open Sans Light'), local('OpenSans Light'), url('../fonts/OpenSans-Light-webfont.eot?#iefix') format('embedded-opentype'), url('../fonts/OpenSans-Light-webfont.woff') format('woff'), url('../fonts/OpenSans-Light-webfont.svg#open_sanslight') format('svg'); } html { overflow: auto; background-color: #fff; font-size: 14px; } body { font-family: 'Open Sans', sans-serif; line-height: 1.5; color: #4d4e53; background-color: white; } a, a:visited, a:active { color: #0095dd; text-decoration: none; } a:hover { text-decoration: underline; } header { display: block; padding: 0px 4px; } tt, code, kbd, samp { font-family: Consolas, Monaco, 'Andale Mono', monospace; } .class-description { font-size: 130%; line-height: 140%; margin-bottom: 1em; margin-top: 1em; } .class-description:empty { margin: 0; } #main { float: left; width: 70%; } article dl { margin-bottom: 40px; } section { display: block; background-color: #fff; padding: 12px 24px; border-bottom: 1px solid #ccc; margin-right: 30px; } .variation { display: none; } .signature-attributes { font-size: 60%; color: #aaa; font-style: italic; font-weight: lighter; } nav { display: block; float: right; margin-top: 28px; width: 30%; box-sizing: border-box; border-left: 1px solid #ccc; padding-left: 16px; } nav ul { font-family: 'Lucida Grande', 'Lucida Sans Unicode', arial, sans-serif; font-size: 100%; line-height: 17px; padding: 0; margin: 0; list-style-type: none; } nav ul a, nav ul a:visited, nav ul a:active { font-family: Consolas, Monaco, 'Andale Mono', monospace; line-height: 18px; color: #4D4E53; } nav h3 { margin-top: 12px; } nav li { margin-top: 6px; } footer { display: block; padding: 6px; margin-top: 12px; font-style: italic; font-size: 90%; } h1, h2, h3, h4 { font-weight: 200; margin: 0; } h1 { font-family: 'Open Sans Light', sans-serif; font-size: 48px; letter-spacing: -2px; margin: 12px 24px 20px; } h2, h3.subsection-title { font-size: 30px; font-weight: 700; letter-spacing: -1px; margin-bottom: 12px; } h3 { font-size: 24px; letter-spacing: -0.5px; margin-bottom: 12px; } h4 { font-size: 18px; letter-spacing: -0.33px; margin-bottom: 12px; color: #4d4e53; } h5, .container-overview .subsection-title { font-size: 120%; font-weight: bold; letter-spacing: -0.01em; margin: 8px 0 3px 0; } h6 { font-size: 100%; letter-spacing: -0.01em; margin: 6px 0 3px 0; font-style: italic; } table { border-spacing: 0; border: 0; border-collapse: collapse; } td, th { border: 1px solid #ddd; margin: 0px; text-align: left; vertical-align: top; padding: 4px 6px; display: table-cell; } thead tr { background-color: #ddd; font-weight: bold; } th { border-right: 1px solid #aaa; } tr > th:last-child { border-right: 1px solid #ddd; } .ancestors { color: #999; } .ancestors a { color: #999 !important; text-decoration: none; } .clear { clear: both; } .important { font-weight: bold; color: #950B02; } .yes-def { text-indent: -1000px; } .type-signature { color: #aaa; } .name, .signature { font-family: Consolas, Monaco, 'Andale Mono', monospace; } .details { margin-top: 14px; border-left: 2px solid #DDD; } .details dt { width: 120px; float: left; padding-left: 10px; padding-top: 6px; } .details dd { margin-left: 70px; } .details ul { margin: 0; } .details ul { list-style-type: none; } .details li { margin-left: 30px; padding-top: 6px; } .details pre.prettyprint { margin: 0 } .details .object-value { padding-top: 0; } .description { margin-bottom: 1em; margin-top: 1em; } .code-caption { font-style: italic; font-size: 107%; margin: 0; } .prettyprint { border: 1px solid #ddd; width: 80%; overflow: auto; } .prettyprint.source { width: inherit; } .prettyprint code { font-size: 100%; line-height: 18px; display: block; padding: 4px 12px; margin: 0; background-color: #fff; color: #4D4E53; } .prettyprint code span.line { display: inline-block; } .prettyprint.linenums { padding-left: 70px; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } .prettyprint.linenums ol { padding-left: 0; } .prettyprint.linenums li { border-left: 3px #ddd solid; } .prettyprint.linenums li.selected, .prettyprint.linenums li.selected * { background-color: lightyellow; } .prettyprint.linenums li * { -webkit-user-select: text; -moz-user-select: text; -ms-user-select: text; user-select: text; } .params .name, .props .name, .name code { color: #4D4E53; font-family: Consolas, Monaco, 'Andale Mono', monospace; font-size: 100%; } .params td.description > p:first-child, .props td.description > p:first-child { margin-top: 0; padding-top: 0; } .params td.description > p:last-child, .props td.description > p:last-child { margin-bottom: 0; padding-bottom: 0; } .disabled { color: #454545; } ================================================ FILE: doc/styles/prettify-jsdoc.css ================================================ /* JSDoc prettify.js theme */ /* plain text */ .pln { color: #000000; font-weight: normal; font-style: normal; } /* string content */ .str { color: #006400; font-weight: normal; font-style: normal; } /* a keyword */ .kwd { color: #000000; font-weight: bold; font-style: normal; } /* a comment */ .com { font-weight: normal; font-style: italic; } /* a type name */ .typ { color: #000000; font-weight: normal; font-style: normal; } /* a literal value */ .lit { color: #006400; font-weight: normal; font-style: normal; } /* punctuation */ .pun { color: #000000; font-weight: bold; font-style: normal; } /* lisp open bracket */ .opn { color: #000000; font-weight: bold; font-style: normal; } /* lisp close bracket */ .clo { color: #000000; font-weight: bold; font-style: normal; } /* a markup tag name */ .tag { color: #006400; font-weight: normal; font-style: normal; } /* a markup attribute name */ .atn { color: #006400; font-weight: normal; font-style: normal; } /* a markup attribute value */ .atv { color: #006400; font-weight: normal; font-style: normal; } /* a declaration */ .dec { color: #000000; font-weight: bold; font-style: normal; } /* a variable name */ .var { color: #000000; font-weight: normal; font-style: normal; } /* a function name */ .fun { color: #000000; font-weight: bold; font-style: normal; } /* Specify class=linenums on a pre to get line numbering */ ol.linenums { margin-top: 0; margin-bottom: 0; } ================================================ FILE: doc/styles/prettify-tomorrow.css ================================================ /* Tomorrow Theme */ /* Original theme - https://github.com/chriskempson/tomorrow-theme */ /* Pretty printing styles. Used with prettify.js. */ /* SPAN elements with the classes below are added by prettyprint. */ /* plain text */ .pln { color: #4d4d4c; } @media screen { /* string content */ .str { color: #718c00; } /* a keyword */ .kwd { color: #8959a8; } /* a comment */ .com { color: #8e908c; } /* a type name */ .typ { color: #4271ae; } /* a literal value */ .lit { color: #f5871f; } /* punctuation */ .pun { color: #4d4d4c; } /* lisp open bracket */ .opn { color: #4d4d4c; } /* lisp close bracket */ .clo { color: #4d4d4c; } /* a markup tag name */ .tag { color: #c82829; } /* a markup attribute name */ .atn { color: #f5871f; } /* a markup attribute value */ .atv { color: #3e999f; } /* a declaration */ .dec { color: #f5871f; } /* a variable name */ .var { color: #c82829; } /* a function name */ .fun { color: #4271ae; } } /* Use higher contrast and text-weight for printable form. */ @media print, projection { .str { color: #060; } .kwd { color: #006; font-weight: bold; } .com { color: #600; font-style: italic; } .typ { color: #404; font-weight: bold; } .lit { color: #044; } .pun, .opn, .clo { color: #440; } .tag { color: #006; font-weight: bold; } .atn { color: #404; } .atv { color: #060; } } /* Style */ /* pre.prettyprint { background: white; font-family: Consolas, Monaco, 'Andale Mono', monospace; font-size: 12px; line-height: 1.5; border: 1px solid #ccc; padding: 10px; } */ /* Specify class=linenums on a pre to get line numbering */ ol.linenums { margin-top: 0; margin-bottom: 0; } /* IE indents via margin-left */ li.L0, li.L1, li.L2, li.L3, li.L4, li.L5, li.L6, li.L7, li.L8, li.L9 { /* */ } /* Alternate shading for lines */ li.L1, li.L3, li.L5, li.L7, li.L9 { /* */ } ================================================ FILE: kbw.countdown.jquery.json ================================================ { "name": "kbw.countdown", "title": "jQuery Countdown", "description": "This plugin sets a div or span to show a countdown to a given time. * Standard or compact formats, or create your own layout. * Decide which periods to show. * Count up from a date/time instead. * Cater for timezone differences and synchronise with server time. * Over 50 localisations.", "keywords": [ "countdown", "i18n", "timer", "timezone", "ui" ], "version": "2.1.0", "author": { "name": "Keith Wood", "email": "wood.keith@optusnet.com.au", "url": "http://keith-wood.name/" }, "licenses": [ { "type": "MIT", "url": "http://keith-wood.name/licence.html" } ], "bugs": "https://github.com/kbwood/countdown/issues", "homepage": "http://keith-wood.name/countdown.html", "docs": "http://keith-wood.name/countdownRef.html", "download": "http://keith-wood.name/countdown.html", "dependencies": { "jquery": ">=1.4" } } ================================================ FILE: package.json ================================================ { "name": "kbw-countdown", "version": "2.1.0", "license" : "MIT", "dependencies": {}, "devDependencies": { "grunt": "~0.4.2", "grunt-contrib-clean": "~0.5.0", "grunt-contrib-copy": "~1.0.0", "grunt-contrib-jshint": "~0.8.0", "grunt-contrib-qunit": "~1.2.0", "grunt-contrib-uglify": "~0.4.0", "grunt-jsdoc": "~2.1.0", "grunt-qunit-istanbul": "~0.6.0", "grunt-text-replace": "~0.4.0", "grunt-zip": "~0.17.1", "matchdep": "~0.3.0" }, "engines": { "node": ">=0.8.0" }, "repository": { "type": "git", "url": "https://github.com/kbwood/countdown.git" } } ================================================ FILE: src/css/jquery.countdown.css ================================================ /* jQuery Countdown styles 2.0.0. */ .is-countdown { border: 1px solid #ccc; background-color: #eee; } .countdown-rtl { direction: rtl; } .countdown-holding span { color: #888; } .countdown-row { clear: both; width: 100%; padding: 0px 2px; text-align: center; } .countdown-show1 .countdown-section { width: 98%; } .countdown-show2 .countdown-section { width: 48%; } .countdown-show3 .countdown-section { width: 32.5%; } .countdown-show4 .countdown-section { width: 24.5%; } .countdown-show5 .countdown-section { width: 19.5%; } .countdown-show6 .countdown-section { width: 16.25%; } .countdown-show7 .countdown-section { width: 14%; } .countdown-section { display: block; float: left; font-size: 75%; text-align: center; } .countdown-amount { font-size: 200%; } .countdown-period { display: block; } .countdown-descr { display: block; width: 100%; } ================================================ FILE: src/index.html ================================================  jQuery Countdown

jQuery Countdown Basics

This page demonstrates the very basics of the jQuery Countdown plugin. It contains the minimum requirements for using the plugin and can be used as the basis for your own experimentation.

For more detail see the documentation reference page.

Counting down to 26 January 2014.

Github
https://github.com/kbwood/countdown
Bower
kbw-countdown
================================================ FILE: src/js/jquery.countdown-ar.js ================================================ /* http://keith-wood.name/countdown.html Arabic (عربي) initialisation for the jQuery countdown extension Translated by Talal Al Asmari (talal@psdgroups.com), April 2009. */ (function($) { 'use strict'; $.countdown.regionalOptions.ar = { labels: ['سنوات','أشهر','أسابيع','أيام','ساعات','دقائق','ثواني'], labels1: ['سنة','شهر','أسبوع','يوم','ساعة','دقيقة','ثانية'], compactLabels: ['س','ش','أ','ي'], whichLabels: null, digits: ['٠','١','٢','٣','٤','٥','٦','٧','٨','٩'], timeSeparator: ':', isRTL: true }; $.countdown.setDefaults($.countdown.regionalOptions.ar); })(jQuery); ================================================ FILE: src/js/jquery.countdown-bg.js ================================================ /* http://keith-wood.name/countdown.html * Bulgarian initialisation for the jQuery countdown extension * Written by Manol Trendafilov manol@rastermania.com (2010) */ (function($) { 'use strict'; $.countdown.regionalOptions.bg = { labels: ['Години','Месеца','Седмица','Дни','Часа','Минути','Секунди'], labels1: ['Година','Месец','Седмица','Ден','Час','Минута','Секунда'], compactLabels: ['l','m','n','d'], compactLabels1: ['g','m','n','d'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.bg); })(jQuery); ================================================ FILE: src/js/jquery.countdown-bn.js ================================================ /* http://keith-wood.name/countdown.html * Bengali/Bangla initialisation for the jQuery countdown extension * Written by Mohammed Tajuddin (tajuddin@chittagong-it.com) Jan 2011. */ (function($) { 'use strict'; $.countdown.regionalOptions.bn = { labels: ['বছর','মাস','সপ্তাহ','দিন','ঘন্টা','মিনিট','সেকেন্ড'], labels1: ['বছর','মাস','সপ্তাহ','দিন','ঘন্টা','মিনিট','সেকেন্ড'], compactLabels: ['ব','মা','স','দি'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.bn); })(jQuery); ================================================ FILE: src/js/jquery.countdown-bs.js ================================================ /* http://keith-wood.name/countdown.html * Bosnian Latin initialisation for the jQuery countdown extension * Written by Miralem Mehic miralem@mehic.info (2011) */ (function($) { 'use strict'; $.countdown.regionalOptions.bs = { labels: ['Godina','Mjeseci','Sedmica','Dana','Sati','Minuta','Sekundi'], labels1: ['Godina','Mjesec','Sedmica','Dan','Sat','Minuta','Sekunda'], labels2: ['Godine','Mjeseca','Sedmica','Dana','Sata','Minute','Sekunde'], compactLabels: ['g','m','t','d'], whichLabels: function(amount) { return (amount === 1 ? 1 : (amount >= 2 && amount <= 4 ? 2 : 0)); }, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.bs); })(jQuery); ================================================ FILE: src/js/jquery.countdown-ca.js ================================================ /* http://keith-wood.name/countdown.html Catalan initialisation for the jQuery countdown extension Written by Amanida Media www.amanidamedia.com (2010) */ (function($) { 'use strict'; $.countdown.regionalOptions.ca = { labels: ['Anys','Mesos','Setmanes','Dies','Hores','Minuts','Segons'], labels1: ['Anys','Mesos','Setmanes','Dies','Hores','Minuts','Segons'], compactLabels: ['a','m','s','g'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.ca); })(jQuery); ================================================ FILE: src/js/jquery.countdown-cs.js ================================================ /* http://keith-wood.name/countdown.html * Czech initialisation for the jQuery countdown extension * Written by Roman Chlebec (creamd@c64.sk) (2008) */ (function($) { 'use strict'; $.countdown.regionalOptions.cs = { labels: ['Roků','Měsíců','Týdnů','Dní','Hodin','Minut','Sekund'], labels1: ['Rok','Měsíc','Týden','Den','Hodina','Minuta','Sekunda'], labels2: ['Roky','Měsíce','Týdny','Dny','Hodiny','Minuty','Sekundy'], compactLabels: ['r','m','t','d'], whichLabels: function(amount) { return (amount === 1 ? 1 : (amount >= 2 && amount <= 4 ? 2 : 0)); }, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.cs); })(jQuery); ================================================ FILE: src/js/jquery.countdown-cy.js ================================================ /* http://keith-wood.name/countdown.html Welsh initialisation for the jQuery countdown extension Written by Gareth Jones | http://garethvjones.com | October 2011. */ (function($) { 'use strict'; $.countdown.regionalOptions.cy = { labels: ['Blynyddoedd','Mis','Wythnosau','Diwrnodau','Oriau','Munudau','Eiliadau'], labels1: ['Blwyddyn','Mis','Wythnos','Diwrnod','Awr','Munud','Eiliad'], compactLabels: ['b','m','w','d'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.cy); })(jQuery); ================================================ FILE: src/js/jquery.countdown-da.js ================================================ /* http://keith-wood.name/countdown.html Danish initialisation for the jQuery countdown extension Written by Buch (admin@buch90.dk). */ (function($) { 'use strict'; $.countdown.regionalOptions.da = { labels: ['År','Måneder','Uger','Dage','Timer','Minutter','Sekunder'], labels1: ['År','Måned','Uge','Dag','Time','Minut','Sekund'], compactLabels: ['Å','M','U','D'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.da); })(jQuery); ================================================ FILE: src/js/jquery.countdown-de.js ================================================ /* http://keith-wood.name/countdown.html German initialisation for the jQuery countdown extension Written by Samuel Wulf. */ (function($) { 'use strict'; $.countdown.regionalOptions.de = { labels: ['Jahre','Monate','Wochen','Tage','Stunden','Minuten','Sekunden'], labels1: ['Jahr','Monat','Woche','Tag','Stunde','Minute','Sekunde'], compactLabels: ['J','M','W','T'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.de); })(jQuery); ================================================ FILE: src/js/jquery.countdown-el.js ================================================ /* http://keith-wood.name/countdown.html Greek initialisation for the jQuery countdown extension Written by Philip. */ (function($) { 'use strict'; $.countdown.regionalOptions.el = { labels: ['Χρόνια','Μήνες','Εβδομάδες','Μέρες','Ώρες','Λεπτά','Δευτερόλεπτα'], labels1: ['Χρόνος','Μήνας','Εβδομάδα','Ημέρα','Ώρα','Λεπτό','Δευτερόλεπτο'], compactLabels: ['Χρ.','Μην.','Εβδ.','Ημ.'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.el); })(jQuery); ================================================ FILE: src/js/jquery.countdown-es.js ================================================ /* http://keith-wood.name/countdown.html * Spanish initialisation for the jQuery countdown extension * Written by Sergio Carracedo Martinez webmaster@neodisenoweb.com (2008) */ (function($) { 'use strict'; $.countdown.regionalOptions.es = { labels: ['Años','Meses','Semanas','Días','Horas','Minutos','Segundos'], labels1: ['Año','Mes','Semana','Día','Hora','Minuto','Segundo'], compactLabels: ['a','m','s','d'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.es); })(jQuery); ================================================ FILE: src/js/jquery.countdown-et.js ================================================ /* http://keith-wood.name/countdown.html Estonian initialisation for the jQuery countdown extension Written by Helmer */ (function($) { 'use strict'; $.countdown.regionalOptions.et = { labels: ['Aastat','Kuud','Nädalat','Päeva','Tundi','Minutit','Sekundit'], labels1: ['Aasta','Kuu','Nädal','Päev','Tund','Minut','Sekund'], compactLabels: ['a','k','n','p'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.et); })(jQuery); ================================================ FILE: src/js/jquery.countdown-fa.js ================================================ /* http://keith-wood.name/countdown.html Persian (فارسی) initialisation for the jQuery countdown extension Written by Alireza Ziaie (ziai@magfa.com) Oct 2008. Digits corrected by Hamed Ramezanian Feb 2013. */ (function($) { 'use strict'; $.countdown.regionalOptions.fa = { labels: ['سال','ماه','هفته','روز','ساعت','دقیقه','ثانیه'], labels1: ['سال','ماه','هفته','روز','ساعت','دقیقه','ثانیه'], compactLabels: ['س','م','ه','ر'], whichLabels: null, digits: ['۰','۱','۲','۳','۴','۵','۶','۷','۸','۹'], timeSeparator: ':', isRTL: true }; $.countdown.setDefaults($.countdown.regionalOptions.fa); })(jQuery); ================================================ FILE: src/js/jquery.countdown-fi.js ================================================ /* http://keith-wood.name/countdown.html Finnish initialisation for the jQuery countdown extension Written by Kalle Vänskä and Juha Suni (juhis.suni@gmail.com). Corrected by Olli. */ (function($) { 'use strict'; $.countdown.regionalOptions.fi = { labels: ['vuotta','kuukautta','viikkoa','päivää','tuntia','minuuttia','sekuntia'], labels1: ['vuosi','kuukausi','viikko','päivä','tunti','minuutti','sekunti'], compactLabels: ['v','kk','vk','pv'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.fi); })(jQuery); ================================================ FILE: src/js/jquery.countdown-fo.js ================================================ /* http://keith-wood.name/countdown.html Faroese initialisation for the jQuery countdown extension Written by Kasper Friis Christensen (kasper@friischristensen.com). */ (function($) { 'use strict'; $.countdown.regionalOptions.fo = { labels: ['Ár','Mánaðir','Vikur','Dagar','Tímar','Minuttir','Sekund'], labels1: ['Ár','Mánaður','Vika','Dagur','Tími','Minuttur','Sekund'], compactLabels: ['Á','M','V','D'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.fo); })(jQuery); ================================================ FILE: src/js/jquery.countdown-fr.js ================================================ /* http://keith-wood.name/countdown.html French initialisation for the jQuery countdown extension Written by Keith Wood (wood.keith{at}optusnet.com.au) Jan 2008. */ (function($) { 'use strict'; $.countdown.regionalOptions.fr = { labels: ['Années','Mois','Semaines','Jours','Heures','Minutes','Secondes'], labels1: ['Année','Mois','Semaine','Jour','Heure','Minute','Seconde'], compactLabels: ['a','m','s','j'], whichLabels: function(amount) { return (amount > 1 ? 0 : 1); }, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.fr); })(jQuery); ================================================ FILE: src/js/jquery.countdown-gl.js ================================================ /* http://keith-wood.name/countdown.html * Galician initialisation for the jQuery countdown extension * Written by Moncho Pena ramon.pena.rodriguez@gmail.com (2009) and Angel Farrapeira */ (function($) { 'use strict'; $.countdown.regionalOptions.gl = { labels: ['Anos','Meses','Semanas','Días','Horas','Minutos','Segundos'], labels1: ['Ano','Mes','Semana','Día','Hora','Minuto','Segundo'], compactLabels: ['a','m','s','g'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.gl); })(jQuery); ================================================ FILE: src/js/jquery.countdown-gu.js ================================================ /* http://keith-wood.name/countdown.html * Gujarati initialization for the jQuery countdown extension * Written by Sahil Jariwala jariwala.sahil@gmail.com (2012) */ (function($) { 'use strict'; $.countdown.regionalOptions.gu = { labels: ['વર્ષ','મહિનો','અઠવાડિયા','દિવસ','કલાક','મિનિટ','સેકન્ડ'], labels1: ['વર્ષ','મહિનો','અઠવાડિયા','દિવસ','કલાક','મિનિટ','સેકન્ડ'], compactLabels: ['વ','મ','અ','દિ'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.gu); })(jQuery); ================================================ FILE: src/js/jquery.countdown-he.js ================================================ /* http://keith-wood.name/countdown.html * Hebrew initialisation for the jQuery countdown extension * Translated by Nir Livne, Dec 2008 */ (function($) { 'use strict'; $.countdown.regionalOptions.he = { labels: ['שנים','חודשים','שבועות','ימים','שעות','דקות','שניות'], labels1: ['שנה','חודש','שבוע','יום','שעה','דקה','שנייה'], compactLabels: ['שנ','ח','שב','י'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: true }; $.countdown.setDefaults($.countdown.regionalOptions.he); })(jQuery); ================================================ FILE: src/js/jquery.countdown-hr.js ================================================ /* http://keith-wood.name/countdown.html * Croatian l10n for the jQuery countdown plugin * Written by Dejan Broz info@hqfactory.com (2011) * Improved by zytzagoo (2014) */ (function($) { 'use strict'; $.countdown.regionalOptions.hr = { labels: ['Godina','Mjeseci','Tjedana','Dana','Sati','Minuta','Sekundi'], // plurals labels1: ['Godina','Mjesec','Tjedan','Dan','Sat','Minutu','Sekundu'], // singles labels2: ['Godine','Mjeseca','Tjedana','Dana','Sata','Minute','Sekunde'], // paucals compactLabels: ['g','m','t','d'], whichLabels: function(amount){ amount = parseInt(amount, 10); if (amount % 10 === 1 && amount % 100 !== 11) { return 1; // singles (/.*1$/ && ! /.*11$/) } if (amount % 10 >= 2 && amount % 10 <= 4 && (amount % 100 < 10 || amount % 100 >= 20)) { return 2; // paucals (/.*[234]$/ && ! /.*1[234]$/ } return 0; // default plural (most common case) }, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.hr); })(jQuery); ================================================ FILE: src/js/jquery.countdown-hu.js ================================================ /* http://keith-wood.name/countdown.html * Hungarian initialisation for the jQuery countdown extension * Written by Edmond L. (webmond@gmail.com). */ (function($) { 'use strict'; $.countdown.regionalOptions.hu = { labels: ['Év','Hónap','Hét','Nap','Óra','Perc','Másodperc'], labels1: ['Év','Hónap','Hét','Nap','Óra','Perc','Másodperc'], compactLabels: ['É','H','Hé','N'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.hu); })(jQuery); ================================================ FILE: src/js/jquery.countdown-hy.js ================================================ /* http://keith-wood.name/countdown.html * Armenian initialisation for the jQuery countdown extension * Written by Artur Martirosyan. (artur{at}zoom.am) October 2011. */ (function($) { 'use strict'; $.countdown.regionalOptions.hy = { labels: ['Տարի','Ամիս','Շաբաթ','Օր','Ժամ','Րոպե','Վարկյան'], labels1: ['Տարի','Ամիս','Շաբաթ','Օր','Ժամ','Րոպե','Վարկյան'], compactLabels: ['տ','ա','շ','օ'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.hy); })(jQuery); ================================================ FILE: src/js/jquery.countdown-id.js ================================================ /* http://keith-wood.name/countdown.html Indonesian initialisation for the jQuery countdown extension Written by Erwin Yonathan Jan 2009. */ (function($) { 'use strict'; $.countdown.regionalOptions.id = { labels: ['tahun','bulan','minggu','hari','jam','menit','detik'], labels1: ['tahun','bulan','minggu','hari','jam','menit','detik'], compactLabels: ['t','b','m','h'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.id); })(jQuery); ================================================ FILE: src/js/jquery.countdown-is.js ================================================ /* http://keith-wood.name/countdown.html Icelandic initialisation for the jQuery countdown extension Written by Róbert K. L. */ (function($) { 'use strict'; $.countdown.regionalOptions.is = { labels: ['Ár','Mánuðir','Vikur','Dagar','Klukkustundir','Mínútur','Sekúndur'], labels1: ['Ár','Mánuður','Vika','Dagur','Klukkustund','Mínúta','Sekúnda'], compactLabels: ['ár.','mán.','vik.','dag.','klst.','mín.','sek.'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.is); })(jQuery); ================================================ FILE: src/js/jquery.countdown-it.js ================================================ /* http://keith-wood.name/countdown.html * Italian initialisation for the jQuery countdown extension * Written by Davide Bellettini and Roberto Chiaveri Feb 2008. */ (function($) { 'use strict'; $.countdown.regionalOptions.it = { labels: ['Anni','Mesi','Settimane','Giorni','Ore','Minuti','Secondi'], labels1: ['Anno','Mese','Settimana','Giorno','Ora','Minuto','Secondo'], compactLabels: ['a','m','s','g'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.it); })(jQuery); ================================================ FILE: src/js/jquery.countdown-ja.js ================================================ /* http://keith-wood.name/countdown.html Japanese initialisation for the jQuery countdown extension Written by Ken Ishimoto (ken@ksroom.com) Aug 2009. */ (function($) { 'use strict'; $.countdown.regionalOptions.ja = { labels: ['年','月','週','日','時','分','秒'], labels1: ['年','月','週','日','時','分','秒'], compactLabels: ['年','月','週','日'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.ja); })(jQuery); ================================================ FILE: src/js/jquery.countdown-kk.js ================================================ /* http://keith-wood.name/countdown.html * Kazakh initialisation for the jQuery countdown extension * Written by Veaceslav Grimalschi grimalschi@yandex.ru (2019) */ (function($) { 'use strict'; $.countdown.regionalOptions['kk'] = { labels: ['Жыл','Ай','Апта','Күн','Сағат','Минут','Секунд'], labels1: ['Жыл','Ай','Апта','Күн','Сағат','Минут','Секунд'], compactLabels: ['ж','а','а','к'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions['kk']); })(jQuery); ================================================ FILE: src/js/jquery.countdown-kn.js ================================================ /* http://keith-wood.name/countdown.html * Kannada initialization for the jQuery countdown extension * Written by Guru Chaturvedi guru@gangarasa.com (2011) */ (function($) { 'use strict'; $.countdown.regionalOptions.kn = { labels: ['ವರ್ಷಗಳು','ತಿಂಗಳು','ವಾರಗಳು','ದಿನಗಳು','ಘಂಟೆಗಳು','ನಿಮಿಷಗಳು','ಕ್ಷಣಗಳು'], labels1: ['ವರ್ಷ','ತಿಂಗಳು','ವಾರ','ದಿನ','ಘಂಟೆ','ನಿಮಿಷ','ಕ್ಷಣ'], compactLabels: ['ವ','ತಿ','ವಾ','ದಿ'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.kn); })(jQuery); ================================================ FILE: src/js/jquery.countdown-ko.js ================================================ /* http://keith-wood.name/countdown.html Korean initialisation for the jQuery countdown extension Written by Ryan Yu (ryanyu79@gmail.com). */ (function($) { 'use strict'; $.countdown.regionalOptions.ko = { labels: ['년','월','주','일','시','분','초'], labels1: ['년','월','주','일','시','분','초'], compactLabels: ['년','월','주','일'], compactLabels1: ['년','월','주','일'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.ko); })(jQuery); ================================================ FILE: src/js/jquery.countdown-lt.js ================================================ /* http://keith-wood.name/countdown.html * Lithuanian localisation for the jQuery countdown extension * Written by Moacir P. de Sá Pereira (moacir{at}gmail.com) (2009) */ (function($) { 'use strict'; $.countdown.regionalOptions.lt = { labels: ['Metų','Mėnesių','Savaičių','Dienų','Valandų','Minučių','Sekundžių'], labels1: ['Metai','Mėnuo','Savaitė','Diena','Valanda','Minutė','Sekundė'], compactLabels: ['m','m','s','d'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.lt); })(jQuery); ================================================ FILE: src/js/jquery.countdown-lv.js ================================================ /* http://keith-wood.name/countdown.html * Latvian initialisation for the jQuery countdown extension * Written by Jānis Peisenieks janis.peisenieks@gmail.com (2010) */ (function($) { 'use strict'; $.countdown.regionalOptions.lv = { labels: ['Gadi','Mēneši','Nedēļas','Dienas','Stundas','Minūtes','Sekundes'], labels1: ['Gads','Mēnesis','Nedēļa','Diena','Stunda','Minūte','Sekunde'], compactLabels: ['l','m','n','d'], compactLabels1: ['g','m','n','d'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.lv); })(jQuery); ================================================ FILE: src/js/jquery.countdown-mk.js ================================================ /* http://keith-wood.name/countdown.html * Macedonian initialisation for the jQuery countdown extension * Written by Gorast Cvetkovski cvetkovski@gorast.com (2016) */ (function($) { 'use strict'; $.countdown.regionalOptions.mk = { labels: ['Години','Месеци','Недели','Дена','Часа','Минути','Секунди'], labels1: ['Година','Месец','Недела','Ден','Час','Минута','Секунда'], compactLabels: ['l','m','n','d'], compactLabels1: ['g','m','n','d'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.mk); })(jQuery); ================================================ FILE: src/js/jquery.countdown-ml.js ================================================ /* http://keith-wood.name/countdown.html * Malayalam/(Indian>>Kerala) initialisation for the jQuery countdown extension * Written by Harilal.B (harilal1234@gmail.com) Feb 2013. */ (function($) { 'use strict'; /* jshint -W100 */ $.countdown.regionalOptions.ml = { labels: ['വര്‍ഷങ്ങള്‍','മാസങ്ങള്‍','ആഴ്ചകള്‍','ദിവസങ്ങള്‍','മണിക്കൂറുകള്‍','മിനിറ്റുകള്‍','സെക്കന്റുകള്‍'], labels1: ['വര്‍ഷം','മാസം','ആഴ്ച','ദിവസം','മണിക്കൂര്‍','മിനിറ്റ്','സെക്കന്റ്'], compactLabels: ['വ','മ','ആ','ദി'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], // digits: ['൦','൧','൨','൩','൪','൫','൬','൭','൮','൯'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.ml); })(jQuery); ================================================ FILE: src/js/jquery.countdown-ms.js ================================================ /* http://keith-wood.name/countdown.html Malay initialisation for the jQuery countdown extension Written by Jason Ong (jason{at}portalgroove.com) May 2010. */ (function($) { 'use strict'; $.countdown.regionalOptions.ms = { labels: ['Tahun','Bulan','Minggu','Hari','Jam','Minit','Saat'], labels1: ['Tahun','Bulan','Minggu','Hari','Jam','Minit','Saat'], compactLabels: ['t','b','m','h'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.ms); })(jQuery); ================================================ FILE: src/js/jquery.countdown-my.js ================================================ /* http://keith-wood.name/countdown.html Burmese initialisation for the jQuery countdown extension Written by Win Lwin Moe (winnlwinmoe@gmail.com) Dec 2009. */ (function($) { 'use strict'; $.countdown.regionalOptions.my = { labels: ['နွစ္','လ','ရက္သတဿတပတ္','ရက္','နာရီ','မိနစ္','စကဿကန့္'], labels1: ['နွစ္','လ','ရက္သတဿတပတ္','ရက္','နာရီ','မိနစ္','စကဿကန့္'], compactLabels: ['နွစ္','လ','ရက္သတဿတပတ္','ရက္'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.my); })(jQuery); ================================================ FILE: src/js/jquery.countdown-nb.js ================================================ /* http://keith-wood.name/countdown.html Norwegian Bokmål translation Written by Kristian Ravnevand */ (function($) { 'use strict'; $.countdown.regionalOptions.nb = { labels: ['År','Måneder','Uker','Dager','Timer','Minutter','Sekunder'], labels1: ['År','Måned','Uke','Dag','Time','Minutt','Sekund'], compactLabels: ['Å','M','U','D'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.nb); })(jQuery); ================================================ FILE: src/js/jquery.countdown-nl.js ================================================ /* http://keith-wood.name/countdown.html Dutch initialisation for the jQuery countdown extension Written by Mathias Bynens Mar 2008. */ (function($) { 'use strict'; $.countdown.regionalOptions.nl = { labels: ['Jaren','Maanden','Weken','Dagen','Uren','Minuten','Seconden'], labels1: ['Jaar','Maand','Week','Dag','Uur','Minuut','Seconde'], compactLabels: ['j','m','w','d'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.nl); })(jQuery); ================================================ FILE: src/js/jquery.countdown-pl.js ================================================ /* http://keith-wood.name/countdown.html * Polish initialisation for the jQuery countdown extension * Written by Pawel Lewtak lewtak@gmail.com (2008) */ (function($) { 'use strict'; $.countdown.regionalOptions.pl = { labels: ['lat','miesięcy','tygodni','dni','godzin','minut','sekund'], labels1: ['rok','miesiąc','tydzień','dzień','godzina','minuta','sekunda'], labels2: ['lata','miesiące','tygodnie','dni','godziny','minuty','sekundy'], compactLabels: ['l','m','t','d'], compactLabels1: ['r','m','t','d'], whichLabels: function(amount) { var units = amount % 10; var tens = Math.floor((amount % 100) / 10); return (amount === 1 ? 1 : (units >= 2 && units <= 4 && tens !== 1 ? 2 : 0)); }, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.pl); })(jQuery); ================================================ FILE: src/js/jquery.countdown-pt-BR.js ================================================ /* http://keith-wood.name/countdown.html Brazilian initialisation for the jQuery countdown extension Translated by Marcelo Pellicano de Oliveira (pellicano@gmail.com) Feb 2008. and Juan Roldan (juan.roldan[at]relayweb.com.br) Mar 2012. */ (function($) { 'use strict'; $.countdown.regionalOptions['pt-BR'] = { labels: ['Anos','Meses','Semanas','Dias','Horas','Minutos','Segundos'], labels1: ['Ano','Mês','Semana','Dia','Hora','Minuto','Segundo'], compactLabels: ['a','m','s','d'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions['pt-BR']); })(jQuery); ================================================ FILE: src/js/jquery.countdown-ro.js ================================================ /* http://keith-wood.name/countdown.html * Romanian initialisation for the jQuery countdown extension * Written by Edmond L. (webmond@gmail.com). */ (function($) { 'use strict'; $.countdown.regionalOptions.ro = { labels: ['Ani','Luni','Saptamani','Zile','Ore','Minute','Secunde'], labels1: ['An','Luna','Saptamana','Ziua','Ora','Minutul','Secunda'], compactLabels: ['A','L','S','Z'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.ro); })(jQuery); ================================================ FILE: src/js/jquery.countdown-ru.js ================================================ /* http://keith-wood.name/countdown.html * Russian initialisation for the jQuery countdown extension * Written by Sergey K. (xslade{at}gmail.com) June 2010. */ (function($) { 'use strict'; $.countdown.regionalOptions.ru = { labels: ['Лет','Месяцев','Недель','Дней','Часов','Минут','Секунд'], labels1: ['Год','Месяц','Неделя','День','Час','Минута','Секунда'], labels2: ['Года','Месяца','Недели','Дня','Часа','Минуты','Секунды'], compactLabels: ['л','м','н','д'], compactLabels1: ['г','м','н','д'], whichLabels: function(amount) { var units = amount % 10; var tens = Math.floor((amount % 100) / 10); return (amount === 1 ? 1 : (units >= 2 && units <= 4 && tens !== 1 ? 2 : (units === 1 && tens !== 1 ? 1 : 0))); }, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.ru); })(jQuery); ================================================ FILE: src/js/jquery.countdown-sk.js ================================================ /* http://keith-wood.name/countdown.html * Slovak initialisation for the jQuery countdown extension * Written by Roman Chlebec (creamd@c64.sk) (2008) */ (function($) { 'use strict'; $.countdown.regionalOptions.sk = { labels: ['Rokov','Mesiacov','Týždňov','Dní','Hodín','Minút','Sekúnd'], labels1: ['Rok','Mesiac','Týždeň','Deň','Hodina','Minúta','Sekunda'], labels2: ['Roky','Mesiace','Týždne','Dni','Hodiny','Minúty','Sekundy'], compactLabels: ['r','m','t','d'], whichLabels: function(amount) { return (amount === 1 ? 1 : (amount >= 2 && amount <= 4 ? 2 : 0)); }, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.sk); })(jQuery); ================================================ FILE: src/js/jquery.countdown-sl.js ================================================ /* http://keith-wood.name/countdown.html * Slovenian localisation for the jQuery countdown extension * Written by Borut Tomažin (debijan{at}gmail.com) (2011) * updated by Jan Zavrl (jan@iuvo.si) (2015) */ (function($) { 'use strict'; $.countdown.regionalOptions.sl = { labels: ['Let','Mesecev','Tednov','Dni','Ur','Minut','Sekund'], // Plurals labels1: ['Leto','Mesec','Teden','Dan','Ura','Minuta','Sekunda'], // Singles labels2: ['Leti','Meseca','Tedna','Dneva','Uri','Minuti','Sekundi'], // Doubles labels3: ['Leta','Meseci','Tedni','Dnevi','Ure','Minute','Sekunde'], // 3's labels4: ['Leta','Meseci','Tedni','Dnevi','Ure','Minute','Sekunde'], // 4's compactLabels: ['l','m','t','d'], whichLabels: function(amount) { return (amount > 4 ? 0 : amount); }, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.sl); })(jQuery); ================================================ FILE: src/js/jquery.countdown-sq.js ================================================ /* http://keith-wood.name/countdown.html Albanian initialisation for the jQuery countdown extension Written by Erzen Komoni. */ (function($) { 'use strict'; $.countdown.regionalOptions.sq = { labels: ['Vite','Muaj','Javë','Ditë','Orë','Minuta','Sekonda'], labels1: ['Vit','Muaj','Javë','Dit','Orë','Minutë','Sekond'], compactLabels: ['V','M','J','D'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.sq); })(jQuery); ================================================ FILE: src/js/jquery.countdown-sr-SR.js ================================================ /* http://keith-wood.name/countdown.html * Serbian Latin initialisation for the jQuery countdown extension * Written by Predrag Leka lp@lemurcake.com (2010) */ (function($) { 'use strict'; $.countdown.regionalOptions['sr-SR'] = { labels: ['Godina','Meseci','Nedelja','Dana','Časova','Minuta','Sekundi'], labels1: ['Godina','Mesec','Nedelja','Dan','Čas','Minut','Sekunda'], labels2: ['Godine','Meseca','Nedelje','Dana','Časa','Minuta','Sekunde'], compactLabels: ['g','m','n','d'], whichLabels: function(amount) { return (amount === 1 ? 1 : (amount >= 2 && amount <= 4 ? 2 : 0)); }, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions['sr-SR']); })(jQuery); ================================================ FILE: src/js/jquery.countdown-sr.js ================================================ /* http://keith-wood.name/countdown.html * Serbian Cyrillic initialisation for the jQuery countdown extension * Written by Predrag Leka lp@lemurcake.com (2010) */ (function($) { 'use strict'; $.countdown.regionalOptions.sr = { labels: ['Година','Месеци','Недеља','Дана','Часова','Минута','Секунди'], labels1: ['Година','месец','Недеља','Дан','Час','Минут','Секунда'], labels2: ['Године','Месеца','Недеље','Дана','Часа','Минута','Секунде'], compactLabels: ['г','м','н','д'], whichLabels: function(amount) { return (amount === 1 ? 1 : (amount >= 2 && amount <= 4 ? 2 : 0)); }, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.sr); })(jQuery); ================================================ FILE: src/js/jquery.countdown-sv.js ================================================ /* http://keith-wood.name/countdown.html Swedish initialisation for the jQuery countdown extension Written by Carl (carl@nordenfelt.com). */ (function($) { 'use strict'; $.countdown.regionalOptions.sv = { labels: ['År','Månader','Veckor','Dagar','Timmar','Minuter','Sekunder'], labels1: ['År','Månad','Vecka','Dag','Timme','Minut','Sekund'], compactLabels: ['Å','M','V','D'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.sv); })(jQuery); ================================================ FILE: src/js/jquery.countdown-th.js ================================================ /* http://keith-wood.name/countdown.html Thai initialisation for the jQuery countdown extension Written by Pornchai Sakulsrimontri (li_sin_th@yahoo.com). */ (function($) { 'use strict'; $.countdown.regionalOptions.th = { labels: ['ปี','เดือน','สัปดาห์','วัน','ชั่วโมง','นาที','วินาที'], labels1: ['ปี','เดือน','สัปดาห์','วัน','ชั่วโมง','นาที','วินาที'], compactLabels: ['ปี','เดือน','สัปดาห์','วัน'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.th); })(jQuery); ================================================ FILE: src/js/jquery.countdown-tr.js ================================================ /* http://keith-wood.name/countdown.html * Turkish initialisation for the jQuery countdown extension * Written by Bekir Ahmetoğlu (bekir@cerek.com) Aug 2008. */ (function($) { 'use strict'; $.countdown.regionalOptions.tr = { labels: ['Yıl','Ay','Hafta','Gün','Saat','Dakika','Saniye'], labels1: ['Yıl','Ay','Hafta','Gün','Saat','Dakika','Saniye'], compactLabels: ['y','a','h','g'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.tr); })(jQuery); ================================================ FILE: src/js/jquery.countdown-uk.js ================================================ /* http://keith-wood.name/countdown.html * Ukrainian initialisation for the jQuery countdown extension * Written by Goloborodko M misha.gm@gmail.com (2009), corrections by Iгор Kоновал */ (function($) { 'use strict'; $.countdown.regionalOptions.uk = { labels: ['Років','Місяців','Тижнів','Днів','Годин','Хвилин','Секунд'], labels1: ['Рік','Місяць','Тиждень','День','Година','Хвилина','Секунда'], labels2: ['Роки','Місяці','Тижні','Дні','Години','Хвилини','Секунди'], compactLabels: ['r','m','t','d'], whichLabels: function(amount) { return (amount === 1 ? 1 : (amount >=2 && amount <= 4 ? 2 : 0)); }, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.uk); })(jQuery); ================================================ FILE: src/js/jquery.countdown-ur.js ================================================ /* http://keith-wood.name/countdown.html Urdu (اردو) initialisation for the jQuery countdown extension Translated by Azhar Rasheed (azhar.rasheed19@gmail.com), November 2013. */ (function($) { 'use strict'; $.countdown.regionalOptions.ur = { labels: ['سال','مہينے','ہفتے','دن','گھنٹے','منٹس','سيکنڑز'], labels1: ['سال','ماہ','ہفتہ','دن','گھنٹہ','منٹ','سیکنڈز'], compactLabels: ['(ق)','سینٹ','ایک','J'], whichLabels: null, digits: ['٠','١','٢','٣','۴','۵','۶','۷','٨','٩'], timeSeparator: ':', isRTL: true }; $.countdown.setDefaults($.countdown.regionalOptions.ur); })(jQuery); ================================================ FILE: src/js/jquery.countdown-uz.js ================================================ /* http://keith-wood.name/countdown.html * Uzbek initialisation for the jQuery countdown extension * Written by Alisher U. (ulugbekov{at}gmail.com) August 2012. */ (function($) { 'use strict'; $.countdown.regionalOptions.uz = { labels: ['Yil','Oy','Hafta','Kun','Soat','Daqiqa','Soniya'], labels1: ['Yil','Oy','Hafta','Kun','Soat','Daqiqa','Soniya'], compactLabels: ['y','o','h','k'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.uz); })(jQuery); ================================================ FILE: src/js/jquery.countdown-vi.js ================================================ /* http://keith-wood.name/countdown.html * Vietnamese initialisation for the jQuery countdown extension * Written by Pham Tien Hung phamtienhung@gmail.com (2010) */ (function($) { 'use strict'; $.countdown.regionalOptions.vi = { labels: ['Năm','Tháng','Tuần','Ngày','Giờ','Phút','Giây'], labels1: ['Năm','Tháng','Tuần','Ngày','Giờ','Phút','Giây'], compactLabels: ['năm','th','tu','ng'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions.vi); })(jQuery); ================================================ FILE: src/js/jquery.countdown-zh-CN.js ================================================ /* http://keith-wood.name/countdown.html Simplified Chinese initialisation for the jQuery countdown extension Written by Cloudream (cloudream@gmail.com). */ (function($) { 'use strict'; $.countdown.regionalOptions['zh-CN'] = { labels: ['年','月','周','天','时','分','秒'], labels1: ['年','月','周','天','时','分','秒'], compactLabels: ['年','月','周','天'], compactLabels1: ['年','月','周','天'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions['zh-CN']); })(jQuery); ================================================ FILE: src/js/jquery.countdown-zh-TW.js ================================================ /* http://keith-wood.name/countdown.html Traditional Chinese initialisation for the jQuery countdown extension Written by Cloudream (cloudream@gmail.com). */ (function($) { 'use strict'; $.countdown.regionalOptions['zh-TW'] = { labels: ['年','月','周','天','時','分','秒'], labels1: ['年','月','周','天','時','分','秒'], compactLabels: ['年','月','周','天'], compactLabels1: ['年','月','周','天'], whichLabels: null, digits: ['0','1','2','3','4','5','6','7','8','9'], timeSeparator: ':', isRTL: false }; $.countdown.setDefaults($.countdown.regionalOptions['zh-TW']); })(jQuery); ================================================ FILE: src/js/jquery.countdown.js ================================================ /*! http://keith-wood.name/countdown.html Countdown for jQuery v2.1.0. Written by Keith Wood (wood.keith{at}optusnet.com.au) January 2008. Available under the MIT (http://keith-wood.name/licence.html) license. Please attribute the author if you use it. */ (function($) { // Hide scope, no $ conflict 'use strict'; var pluginName = 'countdown'; var Y = 0; // Years var O = 1; // Months var W = 2; // Weeks var D = 3; // Days var H = 4; // Hours var M = 5; // Minutes var S = 6; // Seconds /** Create the countdown plugin.

Sets an element to show the time remaining until a given instant.

Expects HTML like:

<div></div>

Provide inline configuration like:

<div data-countdown="name: 'value', ..."></div>
@module Countdown @augments JQPlugin @example $(selector).countdown({until: +300}) */ $.JQPlugin.createPlugin({ /** The name of the plugin. @default 'countdown' */ name: pluginName, /** Countdown expiry callback. Used with the {@linkcode module:Countdown~defaultOptions|onExpiry} option and triggered when the countdown expires. @global @callback CountdownExpiryCallback @this Element @example onExpiry: function() { alert('Done'); } */ /** Countdown server synchronisation callback. Used with the {@linkcode module:Countdown~defaultOptions|serverSync} option and triggered when the countdown is initialised. @global @callback CountdownServerSyncCallback @return {Date} The current date/time on the server as expressed in the local timezone. @this $.countdown @example serverSync: function() { var time = null; $.ajax({url: 'http://myserver.com/serverTime.php', async: false, dataType: 'text', success: function(text) { time = new Date(text); }, error: function(http, message, exc) { time = new Date(); }); return time; } */ /** Countdown tick callback. Used with the {@linkcode module:Countdown~defaultOptions|onTick} option and triggered on every {@linkcode module:Countdown~defaultOptions|tickInterval} ticks of the countdown. @global @callback CountdownTickCallback @this Element @param {number[]} periods The breakdown by period (years, months, weeks, days, hours, minutes, seconds) of the time remaining/passed. @example onTick: function(periods) { $('#altTime').text(periods[4] + ':' + twoDigits(periods[5]) + ':' + twoDigits(periods[6])); } */ /** Countdown which labels callback. Used with the {@linkcode module:Countdown~regionalOptions|whichLabels} option and triggered when the countdown is being display to determine which set of labels (labels, labels1, ...) are to be used for the current period value. @global @callback CountdownWhichLabelsCallback @param {number} num The current period value. @return {number} The suffix for the label set to use, or zero for the default labels. @example whichLabels: function(num) { return (num === 1 ? 1 : (num >= 2 && num <= 4 ? 2 : 0)); } */ /** Default settings for the plugin. @property {Date|number|string} [until] The date/time to count down to, or number of seconds offset from now, or string of amounts and units for offset(s) from now: 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds. One of until or since must be specified. If both are given since takes precedence. @example until: new Date(2013, 12-1, 25, 13, 30) until: +300 until: '+1O -2D' @property {Date|number|string} [since] The date/time to count up from, or number of seconds offset from now, or string of amounts and units for offset(s) from now: 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds. One of until or since must be specified. If both are given since takes precedence. @example since: new Date(2013, 1-1, 1) since: -300 since: '-1O +2D' @property {number} [timezone=null] The timezone (hours or minutes from GMT) for the target times, or null for client local timezone. @example timezone: +10 timezone: -60 @property {CountdownServerSyncCallback} [serverSync=null] A function to retrieve the current server time for synchronisation. @property {string} [format='dHMS'] The format for display - upper case to always show, lower case to show only if non-zero, 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds. @property {string} [layout='']

Build your own layout for the countdown.

Indicate substitution points with '{desc}' for the description, '{sep}' for the time separator, '{pv}' where p is 'y' for years, 'o' for months, 'w' for weeks, 'd' for days, 'h' for hours, 'm' for minutes, or 's' for seconds and v is 'n' for the period value, 'nn' for the period value with a minimum of two digits, 'nnn' for the period value with a minimum of three digits, or 'l' for the period label (long or short form depending on the compact setting), or '{pd}' where p is as above and d is '1' for the units digit, '10' for the tens digit, '100' for the hundreds digit, or '1000' for the thousands digit.

If you need to exclude entire sections when the period value is zero and you have specified the period as optional, surround these sections with '{p<}' and '{p>}', where p is the same as above.

Your layout can just be simple text, or can contain HTML markup as well.

@example layout: '{d<}{dn} {dl}{d>} {hnn}:{mnn}:{snn}' @property {boolean} [compact=false] true to display in a compact format, false for an expanded one. @property {boolean} [padZeroes=false] true to add leading zeroes. @property {number} [significant=0] The maximum number of periods with non-zero values to show, zero for all. @property {string} [description=''] The description displayed for the countdown. @property {string} [expiryUrl=''] A URL to load upon expiry, replacing the current page. @property {string} [expiryText=''] Text to display upon expiry, replacing the countdown. This may be HTML. @property {boolean} [alwaysExpire=false] true to trigger onExpiry even if the target time has passed. @property {CountdownExpiryCallback} [onExpiry=null] Callback when the countdown expires - receives no parameters and this is the containing element. @example onExpiry: function() { ... } @property {CountdownTickCallback} [onTick=null] Callback when the countdown is updated - receives number[7] being the breakdown by period (years, months, weeks, days, hours, minutes, seconds - based on format) and this is the containing element. @example onTick: function(periods) { var secs = $.countdown.periodsToSeconds(periods); if (secs < 300) { // Last five minutes ... } } @property {number} [tickInterval=1] The interval (seconds) between onTick callbacks. */ defaultOptions: { until: null, since: null, timezone: null, serverSync: null, format: 'dHMS', layout: '', compact: false, padZeroes: false, significant: 0, description: '', expiryUrl: '', expiryText: '', alwaysExpire: false, onExpiry: null, onTick: null, tickInterval: 1 }, /** Localisations for the plugin. Entries are objects indexed by the language code ('' being the default US/English). Each object has the following attributes. @property {string[]} [labels=['Years','Months','Weeks','Days','Hours','Minutes','Seconds']] The display texts for the counter periods. @property {string[]} [labels1=['Year','Month','Week','Day','Hour','Minute','Second']] The display texts for the counter periods if they have a value of 1. Add other labelsn attributes as necessary to cater for other numeric idiosyncrasies of the localisation. @property {string[]}[compactLabels=['y','m','w','d']] The compact texts for the counter periods. @property {CountdownWhichLabelsCallback} [whichLabels=null] A function to determine which labelsn to use. @example whichLabels: function(num) { return (num > 1 ? 0 : 1); } @property {string[]} [digits=['0','1',...,'9']] The digits to display (0-9). @property {string} [timeSeparator=':'] Separator for time periods in the compact layout. @property {boolean} [isRTL=false] true for right-to-left languages, false for left-to-right. */ regionalOptions: { // Available regional settings, indexed by language/country code '': { // Default regional settings - English/US labels: ['Years', 'Months', 'Weeks', 'Days', 'Hours', 'Minutes', 'Seconds'], labels1: ['Year', 'Month', 'Week', 'Day', 'Hour', 'Minute', 'Second'], compactLabels: ['y', 'm', 'w', 'd'], whichLabels: null, digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], timeSeparator: ':', isRTL: false } }, /* Class name for the right-to-left marker. */ _rtlClass: pluginName + '-rtl', /* Class name for the countdown section marker. */ _sectionClass: pluginName + '-section', /* Class name for the period amount marker. */ _amountClass: pluginName + '-amount', /* Class name for the period name marker. */ _periodClass: pluginName + '-period', /* Class name for the countdown row marker. */ _rowClass: pluginName + '-row', /* Class name for the holding countdown marker. */ _holdingClass: pluginName + '-holding', /* Class name for the showing countdown marker. */ _showClass: pluginName + '-show', /* Class name for the description marker. */ _descrClass: pluginName + '-descr', /* List of currently active countdown elements. */ _timerElems: [], /** Additional setup for the countdown. Apply default localisations. Create the timer. @private */ _init: function() { var self = this; this._super(); this._serverSyncs = []; var now = (typeof Date.now === 'function' ? Date.now : function() { return new Date().getTime(); }); var perfAvail = (window.performance && typeof window.performance.now === 'function'); // Shared timer for all countdowns function timerCallBack(timestamp) { var drawStart = (timestamp < 1e12 ? // New HTML5 high resolution timer (perfAvail ? (window.performance.now() + window.performance.timing.navigationStart) : now()) : // Integer milliseconds since unix epoch timestamp || now()); if (drawStart - animationStartTime >= 1000) { self._updateElems(); animationStartTime = drawStart; } requestAnimationFrame(timerCallBack); } var requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || null; // This is when we expect a fall-back to setInterval as it's much more fluid var animationStartTime = 0; if (!requestAnimationFrame || $.noRequestAnimationFrame) { $.noRequestAnimationFrame = null; // Fall back to good old setInterval $.countdown._timer = setInterval(function() { self._updateElems(); }, 1000); } else { animationStartTime = window.animationStartTime || window.webkitAnimationStartTime || window.mozAnimationStartTime || window.oAnimationStartTime || window.msAnimationStartTime || now(); requestAnimationFrame(timerCallBack); } }, /** Convert a date/time to UTC. @param {number} tz The hour or minute offset from GMT, e.g. +9, -360. @param {Date|number} year the date/time in that timezone or the year in that timezone. @param {number} [month] The month (0 - 11) (omit if year is a Date). @param {number} [day] The day (omit if year is a Date). @param {number} [hours] The hour (omit if year is a Date). @param {number} [mins] The minute (omit if year is a Date). @param {number} [secs] The second (omit if year is a Date). @param {number} [ms] The millisecond (omit if year is a Date). @return {Date} The equivalent UTC date/time. @example $.countdown.UTCDate(+10, 2013, 12-1, 25, 12, 0) $.countdown.UTCDate(-7, new Date(2013, 12-1, 25, 12, 0)) */ UTCDate: function(tz, year, month, day, hours, mins, secs, ms) { if (typeof year === 'object' && year instanceof Date) { ms = year.getMilliseconds(); secs = year.getSeconds(); mins = year.getMinutes(); hours = year.getHours(); day = year.getDate(); month = year.getMonth(); year = year.getFullYear(); } var d = new Date(); d.setUTCFullYear(year); d.setUTCDate(1); d.setUTCMonth(month || 0); d.setUTCDate(day || 1); d.setUTCHours(hours || 0); d.setUTCMinutes((mins || 0) - (Math.abs(tz) < 30 ? tz * 60 : tz)); d.setUTCSeconds(secs || 0); d.setUTCMilliseconds(ms || 0); return d; }, /** Convert a set of periods into seconds. Averaged for months and years. @param {number[]} periods The periods per year/month/week/day/hour/minute/second. @return {number} The corresponding number of seconds. @example var secs = $.countdown.periodsToSeconds(periods) */ periodsToSeconds: function(periods) { return periods[0] * 31557600 + periods[1] * 2629800 + periods[2] * 604800 + periods[3] * 86400 + periods[4] * 3600 + periods[5] * 60 + periods[6]; }, /** Resynchronise the countdowns with the server. @example $.countdown.resync() */ resync: function() { var self = this; $('.' + this._getMarker()).each(function() { // Each countdown var inst = $.data(this, self.name); if (inst.options.serverSync) { // If synced var serverSync = null; for (var i = 0; i < self._serverSyncs.length; i++) { if (self._serverSyncs[i][0] === inst.options.serverSync) { // Find sync details serverSync = self._serverSyncs[i]; break; } } if (self._eqNull(serverSync[2])) { // Recalculate if missing var serverResult = ($.isFunction(inst.options.serverSync) ? inst.options.serverSync.apply(this, []) : null); serverSync[2] = (serverResult ? new Date().getTime() - serverResult.getTime() : 0) - serverSync[1]; } if (inst._since) { // Apply difference inst._since.setMilliseconds(inst._since.getMilliseconds() + serverSync[2]); } inst._until.setMilliseconds(inst._until.getMilliseconds() + serverSync[2]); } }); for (var i = 0; i < self._serverSyncs.length; i++) { // Update sync details if (!self._eqNull(self._serverSyncs[i][2])) { self._serverSyncs[i][1] += self._serverSyncs[i][2]; delete self._serverSyncs[i][2]; } } }, _instSettings: function(elem, options) { // jshint unused:false return {_periods: [0, 0, 0, 0, 0, 0, 0]}; }, /** Add an element to the list of active ones. @private @param {Element} elem The countdown element. */ _addElem: function(elem) { if (!this._hasElem(elem)) { this._timerElems.push(elem); } }, /** See if an element is in the list of active ones. @private @param {Element} elem The countdown element. @return {boolean} true if present, false if not. */ _hasElem: function(elem) { return ($.inArray(elem, this._timerElems) > -1); }, /** Remove an element from the list of active ones. @private @param {Element} elem The countdown element. */ _removeElem: function(elem) { this._timerElems = $.map(this._timerElems, function(value) { return (value === elem ? null : value); }); // delete entry }, /** Update each active timer element. @private */ _updateElems: function() { for (var i = this._timerElems.length - 1; i >= 0; i--) { this._updateCountdown(this._timerElems[i]); } }, _optionsChanged: function(elem, inst, options) { if (options.layout) { options.layout = options.layout.replace(/</g, '<').replace(/>/g, '>'); } this._resetExtraLabels(inst.options, options); var timezoneChanged = (inst.options.timezone !== options.timezone); $.extend(inst.options, options); this._adjustSettings(elem, inst, !this._eqNull(options.until) || !this._eqNull(options.since) || timezoneChanged); var now = new Date(); if ((inst._since && inst._since < now) || (inst._until && inst._until > now)) { this._addElem(elem[0]); } this._updateCountdown(elem, inst); }, /** Redisplay the countdown with an updated display. @private @param {Element|jQuery} elem The containing element. @param {object} inst The current settings for this instance. */ _updateCountdown: function(elem, inst) { elem = elem.jquery ? elem : $(elem); inst = inst || this._getInst(elem); if (!inst) { return; } elem.html(this._generateHTML(inst)).toggleClass(this._rtlClass, inst.options.isRTL); if (inst._hold !== 'pause' && $.isFunction(inst.options.onTick)) { var periods = inst._hold !== 'lap' ? inst._periods : this._calculatePeriods(inst, inst._show, inst.options.significant, new Date()); if (inst.options.tickInterval === 1 || this.periodsToSeconds(periods) % inst.options.tickInterval === 0) { inst.options.onTick.apply(elem[0], [periods]); } } var expired = inst._hold !== 'pause' && (inst._since ? inst._now.getTime() < inst._since.getTime() : inst._now.getTime() >= inst._until.getTime()); if (expired && !inst._expiring) { inst._expiring = true; if (this._hasElem(elem[0]) || inst.options.alwaysExpire) { this._removeElem(elem[0]); if ($.isFunction(inst.options.onExpiry)) { inst.options.onExpiry.apply(elem[0], []); } if (inst.options.expiryText) { var layout = inst.options.layout; inst.options.layout = inst.options.expiryText; this._updateCountdown(elem[0], inst); inst.options.layout = layout; } if (inst.options.expiryUrl) { window.location = inst.options.expiryUrl; } } inst._expiring = false; } else if (inst._hold === 'pause') { this._removeElem(elem[0]); } }, /** Reset any extra labelsn and compactLabelsn entries if changing labels. @private @param {object} base The options to be updated. @param {object} options The new option values. */ _resetExtraLabels: function(base, options) { var n = null; for (n in options) { if (n.match(/[Ll]abels[02-9]|compactLabels1/)) { base[n] = options[n]; } } for (n in base) { // Remove custom numbered labels if (n.match(/[Ll]abels[02-9]|compactLabels1/) && typeof options[n] === 'undefined') { base[n] = null; } } }, /** Determine whether or not a value is equivalent to null. @private @param {object} value The value to test. @return {boolean} true if equivalent to null, false if not. */ _eqNull: function(value) { return typeof value === 'undefined' || value === null; }, /** Calculate internal settings for an instance. @private @param {jQuery} elem The containing element. @param {object} inst The current settings for this instance. @param {boolean} recalc true if until or since are set. */ _adjustSettings: function(elem, inst, recalc) { var serverEntry = null; for (var i = 0; i < this._serverSyncs.length; i++) { if (this._serverSyncs[i][0] === inst.options.serverSync) { serverEntry = this._serverSyncs[i][1]; break; } } var now = null; var serverOffset = null; if (!this._eqNull(serverEntry)) { now = new Date(); serverOffset = (inst.options.serverSync ? serverEntry : 0); } else { var serverResult = ($.isFunction(inst.options.serverSync) ? inst.options.serverSync.apply(elem[0], []) : null); now = new Date(); serverOffset = (serverResult ? now.getTime() - serverResult.getTime() : 0); this._serverSyncs.push([inst.options.serverSync, serverOffset]); } var timezone = inst.options.timezone; timezone = (this._eqNull(timezone) ? -now.getTimezoneOffset() : timezone); if (recalc || (!recalc && this._eqNull(inst._until) && this._eqNull(inst._since))) { inst._since = inst.options.since; if (!this._eqNull(inst._since)) { inst._since = this.UTCDate(timezone, this._determineTime(inst._since, null)); if (inst._since && serverOffset) { inst._since.setMilliseconds(inst._since.getMilliseconds() + serverOffset); } } inst._until = this.UTCDate(timezone, this._determineTime(inst.options.until, now)); if (serverOffset) { inst._until.setMilliseconds(inst._until.getMilliseconds() + serverOffset); } } inst._show = this._determineShow(inst); }, /** Remove the countdown widget from an element. @private @param {jQuery} elem The containing element. @param {object} inst The current instance object. */ _preDestroy: function(elem, inst) { // jshint unused:false this._removeElem(elem[0]); elem.empty(); }, /** Pause a countdown widget at the current time. Stop it running but remember and display the current time. @param {Element} elem The containing element. @example $(selector).countdown('pause') */ pause: function(elem) { this._hold(elem, 'pause'); }, /** Pause a countdown widget at the current time. Stop the display but keep the countdown running. @param {Element} elem The containing element. @example $(selector).countdown('lap') */ lap: function(elem) { this._hold(elem, 'lap'); }, /** Resume a paused countdown widget. @param {Element} elem The containing element. @example $(selector).countdown('resume') */ resume: function(elem) { this._hold(elem, null); }, /** Toggle a paused countdown widget. @param {Element} elem The containing element. @example $(selector).countdown('toggle') */ toggle: function(elem) { var inst = $.data(elem, this.name) || {}; this[!inst._hold ? 'pause' : 'resume'](elem); }, /** Toggle a lapped countdown widget. @param {Element} elem The containing element. @example $(selector).countdown('toggleLap') */ toggleLap: function(elem) { var inst = $.data(elem, this.name) || {}; this[!inst._hold ? 'lap' : 'resume'](elem); }, /** Pause or resume a countdown widget. @private @param {Element} elem The containing element. @param {string} hold The new hold setting. */ _hold: function(elem, hold) { var inst = $.data(elem, this.name); if (inst) { if (inst._hold === 'pause' && !hold) { inst._periods = inst._savePeriods; var sign = (inst._since ? '-' : '+'); inst[inst._since ? '_since' : '_until'] = this._determineTime(sign + inst._periods[0] + 'y' + sign + inst._periods[1] + 'o' + sign + inst._periods[2] + 'w' + sign + inst._periods[3] + 'd' + sign + inst._periods[4] + 'h' + sign + inst._periods[5] + 'm' + sign + inst._periods[6] + 's'); this._addElem(elem); } inst._hold = hold; inst._savePeriods = (hold === 'pause' ? inst._periods : null); $.data(elem, this.name, inst); this._updateCountdown(elem, inst); } }, /** Return the current time periods, broken down by years, months, weeks, days, hours, minutes, and seconds. @param {Element} elem The containing element. @return {number[]} The current periods for the countdown. @example var periods = $(selector).countdown('getTimes') */ getTimes: function(elem) { var inst = $.data(elem, this.name); return (!inst ? null : (inst._hold === 'pause' ? inst._savePeriods : (!inst._hold ? inst._periods : this._calculatePeriods(inst, inst._show, inst.options.significant, new Date())))); }, /** A time may be specified as an exact value or a relative one. @private @param {string|number|Date} setting The date/time value as a relative or absolute value. @param {Date} defaultTime The date/time to use if no other is supplied. @return {Date} The corresponding date/time. */ _determineTime: function(setting, defaultTime) { var self = this; var offsetNumeric = function(offset) { // e.g. +300, -2 var time = new Date(); time.setTime(time.getTime() + offset * 1000); return time; }; var offsetString = function(offset) { // e.g. '+2d', '-4w', '+3h +30m' offset = offset.toLowerCase(); var time = new Date(); var year = time.getFullYear(); var month = time.getMonth(); var day = time.getDate(); var hour = time.getHours(); var minute = time.getMinutes(); var second = time.getSeconds(); var pattern = /([+-]?[0-9]+)\s*(s|m|h|d|w|o|y)?/g; var matches = pattern.exec(offset); while (matches) { switch (matches[2] || 's') { case 's': second += parseInt(matches[1], 10); break; case 'm': minute += parseInt(matches[1], 10); break; case 'h': hour += parseInt(matches[1], 10); break; case 'd': day += parseInt(matches[1], 10); break; case 'w': day += parseInt(matches[1], 10) * 7; break; case 'o': month += parseInt(matches[1], 10); day = Math.min(day, self._getDaysInMonth(year, month)); break; case 'y': year += parseInt(matches[1], 10); day = Math.min(day, self._getDaysInMonth(year, month)); break; } matches = pattern.exec(offset); } return new Date(year, month, day, hour, minute, second, 0); }; var time = (this._eqNull(setting) ? defaultTime : (typeof setting === 'string' ? offsetString(setting) : (typeof setting === 'number' ? offsetNumeric(setting) : setting))); if (time) { time.setMilliseconds(0); } return time; }, /** Determine the number of days in a month. @private @param {number} year The year. @param {number} month The month. @return {number} The days in that month. */ _getDaysInMonth: function(year, month) { return 32 - new Date(year, month, 32).getDate(); }, /** Default implementation to determine which set of labels should be used for an amount. Use the labels attribute with the same numeric suffix (if it exists). @private @param {number} num The amount to be displayed. @return {number} The set of labels to be used for this amount. */ _normalLabels: function(num) { return num; }, /** Generate the HTML to display the countdown widget. @private @param {object} inst The current settings for this instance. @return {string} The new HTML for the countdown display. */ _generateHTML: function(inst) { var self = this; // Determine what to show inst._periods = (inst._hold ? inst._periods : this._calculatePeriods(inst, inst._show, inst.options.significant, new Date())); // Show all 'asNeeded' after first non-zero value var shownNonZero = false; var showCount = 0; var sigCount = inst.options.significant; var show = $.extend({}, inst._show); var period = null; for (period = Y; period <= S; period++) { shownNonZero = shownNonZero || (inst._show[period] === '?' && inst._periods[period] > 0); show[period] = (inst._show[period] === '?' && !shownNonZero ? null : inst._show[period]); showCount += (show[period] ? 1 : 0); sigCount -= (inst._periods[period] > 0 ? 1 : 0); } var showSignificant = [false, false, false, false, false, false, false]; for (period = S; period >= Y; period--) { // Determine significant periods if (inst._show[period]) { if (inst._periods[period]) { showSignificant[period] = true; } else { showSignificant[period] = sigCount > 0; sigCount--; } } } var labels = (inst.options.compact ? inst.options.compactLabels : inst.options.labels); var whichLabels = inst.options.whichLabels || this._normalLabels; var showCompact = function(period) { var labelsNum = inst.options['compactLabels' + whichLabels(inst._periods[period])]; return (show[period] ? self._translateDigits(inst, inst._periods[period]) + (labelsNum ? labelsNum[period] : labels[period]) + ' ' : ''); }; var minDigits = (inst.options.padZeroes ? 2 : 1); var showFull = function(period) { var labelsNum = inst.options['labels' + whichLabels(inst._periods[period])]; return ((!inst.options.significant && show[period]) || (inst.options.significant && showSignificant[period]) ? '' + '' + self._minDigits(inst, inst._periods[period], minDigits) + '' + '' + (labelsNum ? labelsNum[period] : labels[period]) + '' : ''); }; return (inst.options.layout ? this._buildLayout(inst, show, inst.options.layout, inst.options.compact, inst.options.significant, showSignificant) : ((inst.options.compact ? // Compact version '' + showCompact(Y) + showCompact(O) + showCompact(W) + showCompact(D) + (show[H] ? this._minDigits(inst, inst._periods[H], 2) : '') + (show[M] ? (show[H] ? inst.options.timeSeparator : '') + this._minDigits(inst, inst._periods[M], 2) : '') + (show[S] ? (show[H] || show[M] ? inst.options.timeSeparator : '') + this._minDigits(inst, inst._periods[S], 2) : '') : // Full version '' + showFull(Y) + showFull(O) + showFull(W) + showFull(D) + showFull(H) + showFull(M) + showFull(S)) + '' + (inst.options.description ? '' + inst.options.description + '' : ''))); }, /** Construct a custom layout. @private @param {object} inst The current settings for this instance. @param {boolean[]} show Flags indicating which periods are requested. @param {string} layout The customised layout. @param {boolean} compact true if using compact labels. @param {number} significant The number of periods with values to show, zero for all. @param {boolean[]} showSignificant Other periods to show for significance. @return {string} The custom HTML. */ _buildLayout: function(inst, show, layout, compact, significant, showSignificant) { var labels = inst.options[compact ? 'compactLabels' : 'labels']; var whichLabels = inst.options.whichLabels || this._normalLabels; var labelFor = function(index) { return (inst.options[(compact ? 'compactLabels' : 'labels') + whichLabels(inst._periods[index])] || labels)[index]; }; var digit = function(value, position) { return inst.options.digits[Math.floor(value / position) % 10]; }; var subs = {desc: inst.options.description, sep: inst.options.timeSeparator, yl: labelFor(Y), yn: this._minDigits(inst, inst._periods[Y], 1), ynn: this._minDigits(inst, inst._periods[Y], 2), ynnn: this._minDigits(inst, inst._periods[Y], 3), y1: digit(inst._periods[Y], 1), y10: digit(inst._periods[Y], 10), y100: digit(inst._periods[Y], 100), y1000: digit(inst._periods[Y], 1000), ol: labelFor(O), on: this._minDigits(inst, inst._periods[O], 1), onn: this._minDigits(inst, inst._periods[O], 2), onnn: this._minDigits(inst, inst._periods[O], 3), o1: digit(inst._periods[O], 1), o10: digit(inst._periods[O], 10), o100: digit(inst._periods[O], 100), o1000: digit(inst._periods[O], 1000), wl: labelFor(W), wn: this._minDigits(inst, inst._periods[W], 1), wnn: this._minDigits(inst, inst._periods[W], 2), wnnn: this._minDigits(inst, inst._periods[W], 3), w1: digit(inst._periods[W], 1), w10: digit(inst._periods[W], 10), w100: digit(inst._periods[W], 100), w1000: digit(inst._periods[W], 1000), dl: labelFor(D), dn: this._minDigits(inst, inst._periods[D], 1), dnn: this._minDigits(inst, inst._periods[D], 2), dnnn: this._minDigits(inst, inst._periods[D], 3), d1: digit(inst._periods[D], 1), d10: digit(inst._periods[D], 10), d100: digit(inst._periods[D], 100), d1000: digit(inst._periods[D], 1000), hl: labelFor(H), hn: this._minDigits(inst, inst._periods[H], 1), hnn: this._minDigits(inst, inst._periods[H], 2), hnnn: this._minDigits(inst, inst._periods[H], 3), h1: digit(inst._periods[H], 1), h10: digit(inst._periods[H], 10), h100: digit(inst._periods[H], 100), h1000: digit(inst._periods[H], 1000), ml: labelFor(M), mn: this._minDigits(inst, inst._periods[M], 1), mnn: this._minDigits(inst, inst._periods[M], 2), mnnn: this._minDigits(inst, inst._periods[M], 3), m1: digit(inst._periods[M], 1), m10: digit(inst._periods[M], 10), m100: digit(inst._periods[M], 100), m1000: digit(inst._periods[M], 1000), sl: labelFor(S), sn: this._minDigits(inst, inst._periods[S], 1), snn: this._minDigits(inst, inst._periods[S], 2), snnn: this._minDigits(inst, inst._periods[S], 3), s1: digit(inst._periods[S], 1), s10: digit(inst._periods[S], 10), s100: digit(inst._periods[S], 100), s1000: digit(inst._periods[S], 1000)}; var html = layout; // Replace period containers: {p<}...{p>} for (var i = Y; i <= S; i++) { var period = 'yowdhms'.charAt(i); var re = new RegExp('\\{' + period + '<\\}([\\s\\S]*)\\{' + period + '>\\}', 'g'); html = html.replace(re, ((!significant && show[i]) || (significant && showSignificant[i]) ? '$1' : '')); } // Replace period values: {pn} $.each(subs, function(n, v) { var re = new RegExp('\\{' + n + '\\}', 'g'); html = html.replace(re, v); }); return html; }, /** Ensure a numeric value has at least n digits for display. @private @param {object} inst The current settings for this instance. @param {number} value The value to display. @param {number} len The minimum length. @return {string} The display text. */ _minDigits: function(inst, value, len) { value = '' + value; if (value.length >= len) { return this._translateDigits(inst, value); } value = '0000000000' + value; return this._translateDigits(inst, value.substr(value.length - len)); }, /** Translate digits into other representations. @private @param {object} inst The current settings for this instance. @param {string} value The text to translate. @return {string} The translated text. */ _translateDigits: function(inst, value) { return ('' + value).replace(/[0-9]/g, function(digit) { return inst.options.digits[digit]; }); }, /** Translate the format into flags for each period. @private @param {object} inst The current settings for this instance. @return {string[]} Flags indicating which periods are requested (?) or required (!) by year, month, week, day, hour, minute, second. */ _determineShow: function(inst) { var format = inst.options.format; var show = []; show[Y] = (format.match('y') ? '?' : (format.match('Y') ? '!' : null)); show[O] = (format.match('o') ? '?' : (format.match('O') ? '!' : null)); show[W] = (format.match('w') ? '?' : (format.match('W') ? '!' : null)); show[D] = (format.match('d') ? '?' : (format.match('D') ? '!' : null)); show[H] = (format.match('h') ? '?' : (format.match('H') ? '!' : null)); show[M] = (format.match('m') ? '?' : (format.match('M') ? '!' : null)); show[S] = (format.match('s') ? '?' : (format.match('S') ? '!' : null)); return show; }, /** Calculate the requested periods between now and the target time. @private @param {object} inst The current settings for this instance. @param {string[]} show Flags indicating which periods are requested/required. @param {number} significant The number of periods with values to show, zero for all. @param {Date} now The current date and time. @return {number[]} The current time periods (always positive) by year, month, week, day, hour, minute, second. */ _calculatePeriods: function(inst, show, significant, now) { // Find endpoints inst._now = now; inst._now.setMilliseconds(0); var until = new Date(inst._now.getTime()); if (inst._since) { if (now.getTime() < inst._since.getTime()) { inst._now = now = until; } else { now = inst._since; } } else { until.setTime(inst._until.getTime()); if (now.getTime() > inst._until.getTime()) { inst._now = now = until; } } // Calculate differences by period var periods = [0, 0, 0, 0, 0, 0, 0]; if (show[Y] || show[O]) { // Treat end of months as the same var lastNow = this._getDaysInMonth(now.getFullYear(), now.getMonth()); var lastUntil = this._getDaysInMonth(until.getFullYear(), until.getMonth()); var sameDay = (until.getDate() === now.getDate() || (until.getDate() >= Math.min(lastNow, lastUntil) && now.getDate() >= Math.min(lastNow, lastUntil))); var getSecs = function(date) { return (date.getHours() * 60 + date.getMinutes()) * 60 + date.getSeconds(); }; var months = Math.max(0, (until.getFullYear() - now.getFullYear()) * 12 + until.getMonth() - now.getMonth() + ((until.getDate() < now.getDate() && !sameDay) || (sameDay && getSecs(until) < getSecs(now)) ? -1 : 0)); periods[Y] = (show[Y] ? Math.floor(months / 12) : 0); periods[O] = (show[O] ? months - periods[Y] * 12 : 0); // Adjust for months difference and end of month if necessary now = new Date(now.getTime()); var wasLastDay = (now.getDate() === lastNow); var lastDay = this._getDaysInMonth(now.getFullYear() + periods[Y], now.getMonth() + periods[O]); if (now.getDate() > lastDay) { now.setDate(lastDay); } now.setFullYear(now.getFullYear() + periods[Y]); now.setMonth(now.getMonth() + periods[O]); if (wasLastDay) { now.setDate(lastDay); } } var diff = Math.floor((until.getTime() - now.getTime()) / 1000); var period = null; var extractPeriod = function(period, numSecs) { periods[period] = (show[period] ? Math.floor(diff / numSecs) : 0); diff -= periods[period] * numSecs; }; extractPeriod(W, 604800); extractPeriod(D, 86400); extractPeriod(H, 3600); extractPeriod(M, 60); extractPeriod(S, 1); if (diff > 0 && !inst._since) { // Round up if left overs var multiplier = [1, 12, 4.3482, 7, 24, 60, 60]; var lastShown = S; var max = 1; for (period = S; period >= Y; period--) { if (show[period]) { if (periods[lastShown] >= max) { periods[lastShown] = 0; diff = 1; } if (diff > 0) { periods[period]++; diff = 0; lastShown = period; max = 1; } } max *= multiplier[period]; } } if (significant) { // Zero out insignificant periods for (period = Y; period <= S; period++) { if (significant && periods[period]) { significant--; } else if (!significant) { periods[period] = 0; } } } return periods; } }); })(jQuery); ================================================ FILE: test/countdown.tests.html ================================================  jQuery Countdown Tests
================================================ FILE: test/js/jquery.countdown.tests.js ================================================ $(function() { clearInterval($.countdown._timer); var clock = sinon.useFakeTimers(new Date(2016, 7-1, 1, 12, 0, 0, 0).getTime()); $.noRequestAnimationFrame = true; // Use setInterval which is faked by Sinon $.JQPlugin.createPlugin('countdown', { // Reinitialise name: 'countdown' }); test('Set defaults', function() { expect(3); equal($.countdown.defaultOptions.alwaysExpire, false, 'Initial alwaysExpire'); $.extend($.countdown.defaultOptions, {alwaysExpire: true}); equal($.countdown.defaultOptions.alwaysExpire, true, 'Changed alwaysExpire'); $.countdown.setDefaults({alwaysExpire: false}); equal($.countdown.defaultOptions.alwaysExpire, false, 'Set defaults alwaysExpire'); }); test('UTC date', function() { expect(10); var time = new Date(2009, 1 - 1, 26, 11, 30); var offset = 600 + time.getTimezoneOffset(); // Brisbane GMT+10 equalTime($.countdown.UTCDate(-time.getTimezoneOffset(), time), time, 'UTC date - local offset'); equalTime($.countdown.UTCDate(+7, time), new Date(2009, 1 - 1, 26, 14, 30 - offset), 'UTC date - +7'); equalTime($.countdown.UTCDate(+60, time), new Date(2009, 1 - 1, 26, 20, 30 - offset), 'UTC date - +60'); equalTime($.countdown.UTCDate(-300, time), new Date(2009, 1 - 1, 27, 2, 30 - offset), 'UTC date - -300'); equalTime($.countdown.UTCDate(-8, time), new Date(2009, 1 - 1, 27, 5, 30 - offset), 'UTC date - -8'); equalTime($.countdown.UTCDate(-time.getTimezoneOffset(), 2009, 1 - 1, 26, 11, 30), time, 'UTC date - local offset'); equalTime($.countdown.UTCDate(+7, 2009, 1 - 1, 26, 11, 30), new Date(2009, 1 - 1, 26, 14, 30 - offset), 'UTC date - +7'); equalTime($.countdown.UTCDate(+60, 2009, 1 - 1, 26, 11, 30), new Date(2009, 1 - 1, 26, 20, 30 - offset), 'UTC date - +60'); equalTime($.countdown.UTCDate(-300, 2009, 1 - 1, 26, 11, 30), new Date(2009, 1 - 1, 27, 2, 30 - offset), 'UTC date - -300'); equalTime($.countdown.UTCDate(-8, 2009, 1 - 1, 26, 11, 30), new Date(2009, 1 - 1, 27, 5, 30 - offset), 'UTC date - -8'); }); test('Destroy', function() { expect(6); var cd = init(); ok(typeof cd.data('countdown') !== 'undefined', 'Instance present'); ok(cd.html() !== '', 'Content present'); ok(cd.is('.is-countdown'), 'Marker class present'); cd.countdown('destroy'); cd = $('#cd'); ok(typeof cd.data('countdown') === 'undefined', 'Instance gone'); ok(cd.html() === '', 'Content gone'); ok(!(cd.is('.is-countdown')), 'Marker class gone'); }); test('Content', function() { expect(23); var cd = init(); equal(cd.text(), '0Hours0Minutes0Secondsdescr', 'Content - default'); // Full cd.countdown('option', {until: +5, description: ''}); equal(cd.text(), '0Hours0Minutes5Seconds', 'Content full - +5'); cd.countdown('option', {until: +3665}); equal(cd.text(), '1Hour1Minute5Seconds', 'Content full - +3665'); cd.countdown('option', {until: +5, format: 'MS'}); equal(cd.text(), '0Minutes5Seconds', 'Content full - +5 MS'); cd.countdown('option', {until: +65, format: 'MS'}); equal(cd.text(), '1Minute5Seconds', 'Content full - +65 MS'); cd.countdown('option', {until: +5, format: 'S'}); equal(cd.text(), '5Seconds', 'Content full - +5 S'); cd.countdown('option', {until: +65, format: 'S'}); equal(cd.text(), '65Seconds', 'Content full - +65 S'); cd.countdown('option', {until: +5, format: 'M'}); equal(cd.text(), '1Minute', 'Content full - +5 M'); cd.countdown('option', {until: +65, format: 'M'}); equal(cd.text(), '2Minutes', 'Content full - +65 M'); cd.countdown('option', {until: +5, format: 'H'}); equal(cd.text(), '1Hour', 'Content full - +5 H'); cd.countdown('option', {until: +3665, format: 'H'}); equal(cd.text(), '2Hours', 'Content full - +3665 H'); cd.countdown('option', {until: '+1y+2o+3d+4h+5m+6s', format: 'yodHMS'}); equal(cd.text(), '1Year2Months3Days4Hours5Minutes6Seconds', 'Content full - +1y+2o+3d+4h+5m+6s yodHMS'); // Compact cd.countdown('option', {until: +5, compact: true, format: 'dHMS'}); equal(cd.text(), '00:00:05', 'Content compact - +5'); cd.countdown('option', {until: +3665}); equal(cd.text(), '01:01:05', 'Content compact - +3665'); cd.countdown('option', {until: +5, format: 'MS'}); equal(cd.text(), '00:05', 'Content compact - +5 MS'); cd.countdown('option', {until: +65, format: 'MS'}); equal(cd.text(), '01:05', 'Content compact - +65 MS'); cd.countdown('option', {until: +5, format: 'S'}); equal(cd.text(), '05', 'Content compact - +5 S'); cd.countdown('option', {until: +65, format: 'S'}); equal(cd.text(), '65', 'Content compact - +65 S'); cd.countdown('option', {until: +5, format: 'M'}); equal(cd.text(), '01', 'Content compact - +5 M'); cd.countdown('option', {until: +65, format: 'M'}); equal(cd.text(), '02', 'Content compact - +65 M'); cd.countdown('option', {until: +5, format: 'H'}); equal(cd.text(), '01', 'Content compact - +5 H'); cd.countdown('option', {until: +3665, format: 'H'}); equal(cd.text(), '02', 'Content compact - +3665 H'); cd.countdown('option', {until: '+1y+2o+3d+4h+5m+6s', format: 'yodHMS'}); equal(cd.text(), '1y 2m 3d 04:05:06', 'Content compact - +1y+2o+3d+4h+5m+6s yodHMS'); }); test('Option', function() { expect(9); var cd = init(); var inst = cd.data('countdown'); equal(inst.options.description, 'descr', 'Default description - descr'); cd.countdown('option', {description: 'abcdef'}); equal(inst.options.description, 'abcdef', 'Change description - abcdef'); $('#cd:first').countdown('option', {description: 'uvwxyz'}); equal(inst.options.description, 'uvwxyz', 'Change description - uvwxyz'); cd.countdown('option', {description: 'descr'}); equal(inst.options.description, 'descr', 'Change description - descr'); cd.countdown('option', 'description', 'abcdef'); equal(inst.options.description, 'abcdef', 'Change description - abcdef'); cd.countdown('option', 'description', 'descr'); equal(inst.options.description, 'descr', 'Change description - descr'); // Settings deepEqual(cd.countdown('option'), {labels: ['Years', 'Months', 'Weeks', 'Days', 'Hours', 'Minutes', 'Seconds'], labels1: ['Year', 'Month', 'Week', 'Day', 'Hour', 'Minute', 'Second'], compactLabels: ['y', 'm', 'w', 'd'], whichLabels: null, digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], timeSeparator: ':', isRTL: false, until: null, since: null, timezone: null, serverSync: null, format: 'dHMS', layout: '', compact: false, padZeroes: false, significant: 0, description: 'descr', expiryUrl: '', expiryText: '', alwaysExpire: false, onExpiry: null, onTick: null, tickInterval: 1}, 'Settings - instance'); equal(cd.countdown('option', 'description'), 'descr', 'Settings - description'); equal(cd.countdown('option', 'layout'), '', 'Settings - layout'); }); test('Timezones', function() { expect(6); var cd = init(); var inst = cd.data('countdown'); var time = new Date(); time.setHours(time.getHours() + 3); var offset = 600 + time.getTimezoneOffset(); // BNE GMT+10 var timez = new Date(); timez.setHours(timez.getHours() + 3); cd.countdown('option', {until: time}); equalTime(inst._until, timez, 'Timezone - null'); cd.countdown('option', {timezone: +7}); timez.setHours(timez.getHours() + 3); timez.setMinutes(timez.getMinutes() - offset); equalTime(inst._until, timez, 'Timezone - +7'); cd.countdown('option', {timezone: +240}); timez.setHours(timez.getHours() + 3); equalTime(inst._until, timez, 'Timezone - +240'); cd.countdown('option', {timezone: -2}); timez.setHours(timez.getHours() + 6); equalTime(inst._until, timez, 'Timezone - -2'); cd.countdown('option', {timezone: -480}); timez.setHours(timez.getHours() + 6); equalTime(inst._until, timez, 'Timezone - -480'); cd.countdown('option', {timezone: null}); timez.setHours(timez.getHours() - 18); timez.setMinutes(timez.getMinutes() + offset); equalTime(inst._until, timez, 'Timezone - null'); }); test('Server sync', function() { expect(2); var cd = init(); var inst = cd.data('countdown'); var serverTime = function(offset) { return function() { var time = new Date(); time.setMinutes(time.getMinutes() + offset); return time; }; }; var time = new Date(); time.setHours(time.getHours() + 3); var timesync = new Date(); timesync.setHours(timesync.getHours() + 3); timesync.setMinutes(timesync.getMinutes() - 5); cd.countdown('option', {until: time, serverSync: serverTime(+5)}); equalTime(inst._until, timesync, 'Server sync - +5'); timesync.setMinutes(timesync.getMinutes() + 10); cd.countdown('option', {until: time, serverSync: serverTime(-5)}); equalTime(inst._until, timesync, 'Server sync - -5'); }); test('Server resync', function() { expect(3); var cd = init(); var inst = cd.data('countdown'); var offset = 0; var serverTime = function() { var time = new Date(); time.setMinutes(time.getMinutes() + offset); return time; }; var time = new Date(); time.setHours(time.getHours() + 3); var timesync = new Date(); timesync.setHours(timesync.getHours() + 3); cd.countdown('option', {until: time, serverSync: serverTime}); equalTime(inst._until, timesync, 'Server resync - 0'); offset = 10; timesync.setMinutes(timesync.getMinutes() - 10); $.countdown.resync(); equalTime(inst._until, timesync, 'Server resync - +10'); offset = -5; timesync.setMinutes(timesync.getMinutes() + 15); $.countdown.resync(); equalTime(inst._until, timesync, 'Server resync - -5'); }); test('Until', function() { expect(19); var cd = init(); var inst = cd.data('countdown'); var now = new Date(); equalTime(inst._until, now, 'Until - null'); var until = new Date(); until.setHours(until.getHours() + 1); cd.countdown('option', {until: until}); equalTime(inst._until, until, 'Until - absolute +1H'); // relative numeric until = new Date(); until.setSeconds(until.getSeconds() + 200); cd.countdown('option', {until: +200}); equalTime(inst._until, until, 'Until - +200'); // relative alpha until = new Date(); until.setSeconds(until.getSeconds() + 20); cd.countdown('option', {until: '+20s'}); equalTime(inst._until, until, 'Until - +20s'); until = new Date(); until.setSeconds(until.getSeconds() + 40); cd.countdown('option', {until: ' +40 S '}); equalTime(inst._until, until, 'Until - +40 S'); until = new Date(); until.setMinutes(until.getMinutes() + 10); cd.countdown('option', {until: '+10m'}); equalTime(inst._until, until, 'Until - +10m'); until = new Date(); until.setMinutes(until.getMinutes() + 25); cd.countdown('option', {until: ' +25 M '}); equalTime(inst._until, until, 'Until - +25 M'); until = new Date(); until.setHours(until.getHours() + 3); cd.countdown('option', {until: '+3h'}); equalTime(inst._until, until, 'Until - +3h'); until = new Date(); until.setHours(until.getHours() + 15); cd.countdown('option', {until: ' +15 H '}); equalTime(inst._until, until, 'Until - +15 H'); until = new Date(); until.setDate(until.getDate() + 4); cd.countdown('option', {until: '+4d'}); equalTime(inst._until, until, 'Until - +4d'); until = new Date(); until.setDate(until.getDate() + 30); cd.countdown('option', {until: ' +30 D '}); equalTime(inst._until, until, 'Until - +30 D'); until = new Date(); until.setDate(until.getDate() + 7 * 2); cd.countdown('option', {until: '+2w'}); equalTime(inst._until, until, 'Until - +2w'); until = new Date(); until.setDate(until.getDate() + 7 * 10); cd.countdown('option', {until: ' +10 W '}); equalTime(inst._until, until, 'Until - +10 W'); until = new Date(); until.setMonth(until.getMonth() + 2); cd.countdown('option', {until: '+2o'}); equalTime(inst._until, until, 'Until - +2o'); until = new Date(); until.setMonth(until.getMonth() + 12); cd.countdown('option', {until: ' +12 O '}); equalTime(inst._until, until, 'Until - +12 O'); until = new Date(); until.setFullYear(until.getFullYear() + 2); cd.countdown('option', {until: '+2y'}); equalTime(inst._until, until, 'Until - +2y'); until = new Date(); until.setFullYear(until.getFullYear() + 5); cd.countdown('option', {until: ' +5 Y '}); equalTime(inst._until, until, 'Until - +5 Y'); until = new Date(); until.setDate(until.getDate() + 7 * 2); until.setHours(until.getHours() + 2); cd.countdown('option', {until: '+2w +2h'}); equalTime(inst._until, until, 'Until - +2w +2h'); until = new Date(); until.setFullYear(until.getFullYear() + 5); until.setMonth(until.getMonth() + 1); cd.countdown('option', {until: ' +5 Y +1 O'}); equalTime(inst._until, until, 'Until - until +5 Y +1 O'); // reset cd.countdown('option', {until: null}); }); test('Since', function() { expect(20); var cd = init(); var inst = cd.data('countdown'); var now = new Date(); ok(inst._since === null, 'Since - null'); var since = new Date(); since.setHours(since.getHours() - 1); cd.countdown('option', {since: since}); equalTime(inst._since, since, 'Since - absolute -1H'); // relative numeric since = new Date(); cd.countdown('option', {since: 0}); equalTime(inst._since, since, 'Since - 0'); since.setSeconds(since.getSeconds() - 200); cd.countdown('option', {since: -200}); equalTime(inst._since, since, 'Since - -200'); // relative alpha since = new Date(); since.setSeconds(since.getSeconds() - 20); cd.countdown('option', {since: '-20s'}); equalTime(inst._since, since, 'Since - -20s'); since = new Date(); since.setSeconds(since.getSeconds() - 40); cd.countdown('option', {since: ' -40 S '}); equalTime(inst._since, since, 'Since - -40 S'); since = new Date(); since.setMinutes(since.getMinutes() - 10); cd.countdown('option', {since: '-10m'}); equalTime(inst._since, since, 'Since - -10m'); since = new Date(); since.setMinutes(since.getMinutes() - 25); cd.countdown('option', {since: ' -25 M '}); equalTime(inst._since, since, 'Since - -25 M'); since = new Date(); since.setHours(since.getHours() - 3); cd.countdown('option', {since: '-3h'}); equalTime(inst._since, since, 'Since - -3h'); since = new Date(); since.setHours(since.getHours() - 15); cd.countdown('option', {since: ' -15 H '}); equalTime(inst._since, since, 'Since - -15 H'); since = new Date(); since.setDate(since.getDate() - 4); cd.countdown('option', {since: '-4d'}); equalTime(inst._since, since, 'Since - -4d'); since = new Date(); since.setDate(since.getDate() - 30); cd.countdown('option', {since: ' -30 D '}); equalTime(inst._since, since, 'Since - -30 D'); since = new Date(); since.setDate(since.getDate() - 7 * 2); cd.countdown('option', {since: '-2w'}); equalTime(inst._since, since, 'Since - -2w'); since = new Date(); since.setDate(since.getDate() - 7 * 10); cd.countdown('option', {since: ' -10 W '}); equalTime(inst._since, since, 'Since - -10 W'); since = new Date(); since.setMonth(since.getMonth() - 2); cd.countdown('option', {since: '-2o'}); equalTime(inst._since, since, 'Since - -2o'); since = new Date(); since.setMonth(since.getMonth() - 12); cd.countdown('option', {since: ' -12 O '}); equalTime(inst._since, since, 'Since - -12 O'); since = new Date(); since.setFullYear(since.getFullYear() - 2); cd.countdown('option', {since: '-2y'}); equalTime(inst._since, since, 'Since - -2y'); since = new Date(); since.setFullYear(since.getFullYear() - 5); cd.countdown('option', {since: ' -5 Y '}); equalTime(inst._since, since, 'Since - -5 Y'); since = new Date(); since.setDate(since.getDate() - 7 * 2); since.setHours(since.getHours() - 2); cd.countdown('option', {since: '-2w -2h'}); equalTime(inst._since, since, 'Since - -2w -2h'); since = new Date(); since.setFullYear(since.getFullYear() - 5); since.setMonth(since.getMonth() - 1); cd.countdown('option', {since: ' -5 Y -1 O'}); equalTime(inst._since, since, 'Since - -5 Y -1 O'); // reset cd.countdown('option', {since: null}); }); test('Get', function() { expect(2); var cd = init(); var inst = cd.data('countdown'); equal($.countdown.defaultOptions.description, '', 'Default description'); equal(inst.options.description, 'descr', 'Instance description'); }); test('Get times', function() { expect(7); var cd = init(); var inst = cd.data('countdown'); cd.countdown('option', {format: 'YOWDHMS'}); deepEqual(cd.countdown('getTimes'), [0, 0, 0, 0, 0, 0, 0], 'Get time - nothing set'); cd.countdown('option', {until: '+1y +2o +3w +4d +5h +6m +7s'}); deepEqual(cd.countdown('getTimes'), [1, 2, 3, 4, 5, 6, 7], 'Get time - until +1y +2o +3w +4d +5h +6m +7s'); cd.countdown('option', {until: '+1y +3w +5h +7s'}); deepEqual(cd.countdown('getTimes'), [1, 0, 3, 0, 5, 0, 7], 'Get time - until +1y +3w +5h +7s'); cd.countdown('option', {until: '+2o +4d +6m'}); deepEqual(cd.countdown('getTimes'), [0, 2, 0, 4, 0, 6, 0], 'Get time - until +2o +4d +6m'); cd.countdown('option', {since: '-1y -2o -3w -4d -5h -6m -7s'}); deepEqual(cd.countdown('getTimes'), [1, 2, 3, 4, 5, 6, 7], 'Get time - since -1y -2o -3w -4d -5h -6m -7s'); cd.countdown('option', {since: '-1y -3w -5h -7s'}); deepEqual(cd.countdown('getTimes'), [1, 0, 3, 0, 5, 0, 7], 'Get time - since -1y -3w -5h -7s'); cd.countdown('option', {since: '-2o -4d -6m'}); deepEqual(cd.countdown('getTimes'), [0, 2, 0, 4, 0, 6, 0], 'Get time - since -2o -4d -6m'); }); test('Calculate periods', function() { expect(38); var cd = init(); var inst = cd.data('countdown'); // Until cd.countdown('option', {until: '+1y +2o +3d +4h +5m +6s'}); var now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('yodHMS'), 0, now), [1, 2, 0, 3, 4, 5, 6], 'Calculate periods - yodHMS until +1y +2o +3d +4h +5m +6s'); now.setMilliseconds(0); var days = Math.floor((inst._until.getTime() - now.getTime()) / (24 * 60 * 60 * 1000)); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('YODHMS'), 0, now), [1, 2, 0, 3, 4, 5, 6], 'Calculate periods - YODHMS until +1y +2o +3d +4h +5m +6s'); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('odHMS'), 0, now), [0, 14, 0, 3, 4, 5, 6], 'Calculate periods - odHMS until +1y +2o +3d +4h +5m +6s'); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('wHMS'), 0, now), [0, 0, Math.floor(days / 7), 0, (days % 7) * 24 + 4, 5, 6], 'Calculate periods - wHMS until +1y +2o +3d +4h +5m +6s'); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('dHMS'), 0, now), [0, 0, 0, days, 4, 5, 6], 'Calculate periods - dHMS until +1y +2o +3d +4h +5m +6s'); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('hms'), 0, now), [0, 0, 0, 0, days * 24 + 4, 5, 6], 'Calculate periods - hms until +1y +2o +3d +4h +5m +6s'); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('MS'), 0, now), [0, 0, 0, 0, 0, (days * 24 + 4) * 60 + 5, 6], 'Calculate periods - MS until +1y +2o +3d +4h +5m +6s'); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('s'), 0, now), [0, 0, 0, 0, 0, 0, ((days * 24 + 4) * 60 + 5) * 60 + 6], 'Calculate periods - s until +1y +2o +3d +4h +5m +6s'); now = new Date(); now.setFullYear(now.getFullYear() + 1); now.setMilliseconds(0); days = Math.floor((inst._until.getTime() - now.getTime()) / (24 * 60 * 60 * 1000)); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('YDS'), 0, now), [1, 0, 0, days, 0, 0, 14706], 'Calculate periods - YDS until +1y +2o +3d +4h +5m +6s'); cd.countdown('option', {until: new Date(2009, 7 - 1, 20)}); now = new Date(2009, 4 - 1, 20, 11); deepEqual($.countdown._calculatePeriods(inst, generateShow('OWDHM'), 0, now), [0, 2, 4, 1, 13, 0, 0], 'Calculate periods - OWDHM until start of today + 3 months'); cd.countdown('option', {until: new Date(2009, 6 - 1, 30)}); now = new Date(2009, 3 - 1, 31); deepEqual($.countdown._calculatePeriods(inst, generateShow('OWDHM'), 0, now), [0, 3, 0, 0, 0, 0, 0], 'Calculate periods - OWDHM until 31/03 to 30/06'); now = new Date(2009, 3 - 1, 31, 11); deepEqual($.countdown._calculatePeriods(inst, generateShow('OWDHM'), 0, now), [0, 2, 4, 1, 13, 0, 0], 'Calculate periods - OWDHM until 31/03 11:00 to 30/06 00:00'); cd.countdown('option', {until: new Date(2009, 8 - 1, 31)}); now = new Date(2009, 6 - 1, 30); deepEqual($.countdown._calculatePeriods(inst, generateShow('OWDHM'), 0, now), [0, 2, 0, 0, 0, 0, 0], 'Calculate periods - OWDHM until 30/06 to 31/08'); now = new Date(2009, 6 - 1, 30, 11); deepEqual($.countdown._calculatePeriods(inst, generateShow('OWDHM'), 0, now), [0, 1, 4, 2, 13, 0, 0], 'Calculate periods - OWDHM until 30/06 11:00 to 31/08 00:00'); // With rounding cd.countdown('option', {until: '13d 23h 59m 10s', format: 'YOWDHM'}); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('YOWDHM'), 0, now), [0, 0, 2, 0, 0, 0, 0], 'Calculate periods - YOWDHM until 13d 23h 59m 10s'); cd.countdown('option', {until: '13d 23h 59m -10s', format: 'YOWDHM'}); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('YOWDHM'), 0, now), [0, 0, 1, 6, 23, 59, 0], 'Calculate periods - YOWDHM until 13d 23h 59m -10s'); cd.countdown('option', {until: '13d 23h 10s', format: 'YOWDH'}); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('YOWDH'), 0, now), [0, 0, 2, 0, 0, 0, 0], 'Calculate periods - YOWDH until 13d 23h 10s'); cd.countdown('option', {until: '13d 23h -10s', format: 'YOWDH'}); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('YOWDH'), 0, now), [0, 0, 1, 6, 23, 0, 0], 'Calculate periods - YOWDH until 13d 23h -10s'); cd.countdown('option', {until: '13d 23h 59m 10s', format: 'YOWDM'}); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('YOWDM'), 0, now), [0, 0, 2, 0, 0, 0, 0], 'Calculate periods - YOWDM until 13d 23h 59m 10s'); cd.countdown('option', {until: '13d 23h 59m -10s', format: 'YOWDM'}); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('YOWDM'), 0, now), [0, 0, 1, 6, 0, 1439, 0], 'Calculate periods - YOWDM until 13d 23h 59m -10s'); cd.countdown('option', {until: '13d 23h 59m 10s', format: 'YOWD'}); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('YOWD'), 0, now), [0, 0, 2, 0, 0, 0, 0], 'Calculate periods - YOWD until 13d 23h 59m 10s'); cd.countdown('option', {until: '13d 23h 59m -10s', format: 'YOWD'}); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('YOWD'), 0, now), [0, 0, 2, 0, 0, 0, 0], 'Calculate periods - YOWD until 13d 23h 59m -10s'); // Since cd.countdown('option', {since: '-1y -2o -3d -4h -5m -6s', until: null}); var now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('yodHMS'), 0, now), [1, 2, 0, 3, 4, 5, 6], 'Calculate periods - yodHMS since -1y -2o -3d -4h -5m -6s'); now.setMilliseconds(0); days = Math.floor((now.getTime() - inst._since.getTime()) / (24 * 60 * 60 * 1000)); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('YODHMS'), 0, now), [1, 2, 0, 3, 4, 5, 6], 'Calculate periods - YODHMS since -1y -2o -3d -4h -5m -6s'); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('odHMS'), 0, now), [0, 14, 0, 3, 4, 5, 6], 'Calculate periods - odHMS since -1y -2o -3d -4h -5m -6s'); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('wHMS'), 0, now), [0, 0, Math.floor(days / 7), 0, (days % 7) * 24 + 4, 5, 6], 'Calculate periods - wHMS since -1y -2o -3d -4h -5m -6s'); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('dHMS'), 0, now), [0, 0, 0, days, 4, 5, 6], 'Calculate periods - dHMS since -1y -2o -3d -4h -5m -6s'); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('hms'), 0, now), [0, 0, 0, 0, days * 24 + 4, 5, 6], 'Calculate periods - hms since -1y -2o -3d -4h -5m -6s'); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('MS'), 0, now), [0, 0, 0, 0, 0, (days * 24 + 4) * 60 + 5, 6], 'Calculate periods - MS since -1y -2o -3d -4h -5m -6s'); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('s'), 0, now), [0, 0, 0, 0, 0, 0, ((days * 24 + 4) * 60 + 5) * 60 + 6], 'Calculate periods - s since -1y -2o -3d -4h -5m -6s'); now = new Date(); now.setHours(0); now.setMinutes(0); now.setSeconds(0); now.setMilliseconds(0); var then = new Date(inst._since.getTime()); then.setFullYear(then.getFullYear() + 1); then.setHours(0); then.setMinutes(0); then.setSeconds(0); then.setMilliseconds(0); days = Math.ceil((now.getTime() - then.getTime()) / (24 * 60 * 60 * 1000)); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('YDS'), 0, now), [1, 0, 0, days, 0, 0, 14706], 'Calculate periods - YDS since -1y -2o -3d -4h -5m -6s'); cd.countdown('option', {since: new Date(2009, 4 - 1, 20, 11)}); now = new Date(2009, 7 - 1, 20); deepEqual($.countdown._calculatePeriods(inst, generateShow('OWDHM'), 0, now), [0, 2, 4, 1, 13, 0, 0], 'Calculate periods - OWDHM since start of today - 3 months'); cd.countdown('option', {since: new Date(2009, 7 - 1, 31)}); now = new Date(2009, 9 - 1, 30); deepEqual($.countdown._calculatePeriods(inst, generateShow('OWDHM'), 0, now), [0, 2, 0, 0, 0, 0, 0], 'Calculate periods - OWDHM since 31/07 to 30/09'); cd.countdown('option', {since: new Date(2009, 7 - 1, 31, 11)}); deepEqual($.countdown._calculatePeriods(inst, generateShow('OWDHM'), 0, now), [0, 1, 4, 1, 13, 0, 0], 'Calculate periods - OWDHM since 31/07 11:00 to 30/09 00:00'); cd.countdown('option', {since: new Date(2009, 6 - 1, 30)}); now = new Date(2009, 8 - 1, 31); deepEqual($.countdown._calculatePeriods(inst, generateShow('OWDHM'), 0, now), [0, 2, 0, 0, 0, 0, 0], 'Calculate periods - OWDHM since 30/06 to 31/08'); cd.countdown('option', {since: new Date(2009, 6 - 1, 30, 11)}); deepEqual($.countdown._calculatePeriods(inst, generateShow('OWDHM'), 0, now), [0, 1, 4, 2, 13, 0, 0], 'Calculate periods - OWDHM since 30/06 11:00 to 31/08 00:00'); // With rounding cd.countdown('option', {since: '-13d -23h -59m 10s', format: 'YOWDHM'}); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('YOWDHM'), 0, now), [0, 0, 1, 6, 23, 58, 0], 'Calculate periods - YOWDHM since -13d -23h -59m 10s'); cd.countdown('option', {since: '-13d -23h -59m -10s', format: 'YOWDHM'}); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('YOWDHM'), 0, now), [0, 0, 1, 6, 23, 59, 0], 'Calculate periods - YOWDHM since -13d -23h -59m -10s'); }); test('Significant', function() { expect(11); var cd = init({format: 'yowdHMS', description: ''}); var inst = cd.data('countdown'); // Until cd.countdown('option', {until: '+1y +2o +3d +4h +5m +6s', significant: 2}); var now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('yodHMS'), 2, now), [1, 2, 0, 0, 0, 0, 0], 'Significant periods - 2 yodHMS until +1y +2o +3d +4h +5m +6s'); equal(cd.text(), '1Year2Months', 'Significant text - 2'); cd.countdown('option', {until: '+1y +2o +3d +4h +5m +6s', significant: 3}); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('yodHMS'), 3, now), [1, 2, 0, 3, 0, 0, 0], 'Significant periods - 3 yodHMS until +1y +2o +3d +4h +5m +6s'); equal(cd.text(), '1Year2Months3Days', 'Significant text - 3'); cd.countdown('option', {until: '+4h', significant: 2}); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('yodHMS'), 2, now), [0, 0, 0, 0, 4, 0, 0], 'Significant periods - 2 yodHMS until +4h'); equal(cd.text(), '4Hours0Seconds', 'Significant text - 2'); cd.countdown('option', {until: '+4h', format: 'dHM', significant: 2}); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('dHM'), 2, now), [0, 0, 0, 0, 4, 0, 0], 'Significant periods - 2 dHM until +4h'); equal(cd.text(), '4Hours0Minutes', 'Significant text - 2'); cd.countdown('option', {until: '+4h', format: 'dHM', significant: 3}); now = new Date(); deepEqual($.countdown._calculatePeriods(inst, generateShow('dHM'), 3, now), [0, 0, 0, 0, 4, 0, 0], 'Significant periods - 3 dHM until +4h'); equal(cd.text(), '0Days4Hours0Minutes', 'Significant text - 3'); cd.countdown('option', {until: '+1y +2o +3d +4h +5m +6s', format: 'yodHMS', significant: 3, layout: '{y<}{yn} {yl} {y>}{o<}{on} {ol} {o>}{w<}{wn} {wl} {w>}' + '{d<}{dn} {dl} {d>}{h<}{hn} {hl} {h>}{m<}{mn} {ml} {m>}{s<}{sn} {sl}{s>}'}); now = new Date(); equal(cd.text(), '1 Year 2 Months 3 Days ', 'Significant layout - 3'); }); test('Periods to seconds', function() { expect(3); equal($.countdown.periodsToSeconds([0, 0, 0, 0, 1, 2, 3]), 3723, 'Periods to seconds - 0, 0, 0, 0, 1, 2, 3'); equal($.countdown.periodsToSeconds([0, 0, 1, 2, 0, 0, 0]), 777600, 'Periods to seconds - 0, 0, 1, 2, 0, 0, 0'); equal($.countdown.periodsToSeconds([1, 2, 0, 3, 4, 5, 6]), 37091106, 'Periods to seconds - 1, 2, 0, 3, 4, 5, 6'); }); test('Layouts', function() { expect(16); var cd = init(); var inst = cd.data('countdown'); var show = generateShow('YODHMS'); cd.countdown('option', {until: '+1y +2o +3d +4h +5m +6s', format: 'YODHMS', description: 'until then'}); equal($.countdown._buildLayout(inst, show, '{yn} {yl}', false), '1 Year', 'Layout - {yn} {yl}'); equal($.countdown._buildLayout(inst, show, '{on} {ol}', false), '2 Months', 'Layout - {on} {ol}'); equal($.countdown._buildLayout(inst, show, '{wn} {wl}', false), '0 Weeks', 'Layout - {wn} {wl}'); equal($.countdown._buildLayout(inst, show, '{dn} {dl}', false), '3 Days', 'Layout - {dn} {dl}'); equal($.countdown._buildLayout(inst, show, '{hn} {hl}', false), '4 Hours', 'Layout - {hn} {hl}'); equal($.countdown._buildLayout(inst, show, '{mn} {ml}', false), '5 Minutes', 'Layout - {mn} {ml}'); equal($.countdown._buildLayout(inst, show, '{sn} {sl}', false), '6 Seconds', 'Layout - {sn} {sl}'); equal($.countdown._buildLayout(inst, show, '{yn} {yl}, {on} {ol}, {dn} {dl}, ' + '{hn} {hl}, {mn} {ml}, {sn} {sl}', false), '1 Year, 2 Months, 3 Days, 4 Hours, 5 Minutes, 6 Seconds', 'Layout - {yn} {yl}, {on} {ol}, {dn} {dl}, {hn} {hl}, {mn} {ml}, {sn} {sl}'); equal($.countdown._buildLayout(inst, show, '{ynn} {yl} + {onn} {ol} + {dnn} {dl} and ' + '{hnn} {hl}:{mnn} {ml}:{snn} {sl}', false), '01 Year + 02 Months + 03 Days and 04 Hours:05 Minutes:06 Seconds', 'Layout - {ynn} {yl} + {onn} {ol} + {dnn} {dl} and ' + '{hnn} {hl}:{mnn} {ml}:{snn} {sl}'); equal($.countdown._buildLayout(inst, show, '{ynnn} {yl} + {onnn} {ol} + {dnnn} {dl} and ' + '{hnnn} {hl}:{mnnn} {ml}:{snnn} {sl}', false), '001 Year + 002 Months + 003 Days and 004 Hours:005 Minutes:006 Seconds', 'Layout - {ynnn} {yl} + {onnn} {ol} + {dnnn} {dl} and ' + '{hnnn} {hl}:{mnnn} {ml}:{snnn} {sl}'); equal($.countdown._buildLayout(inst, show, '
  • {yn} {yl}
  • {on} {ol}
  • {dn} {dl}
  • ' + '
  • {hn} {hl}
  • {mn} {ml}
  • {sn} {sl}
', false), '
  • 1 Year
  • 2 Months
  • 3 Days
  • ' + '
  • 4 Hours
  • 5 Minutes
  • 6 Seconds
', 'Layout -
  • {yn} {yl}
  • {on} {ol}
  • {dn} {dl}
  • ' + '
  • {hn} {hl}
  • {mn} {ml}
  • {sn} {sl}
'); equal($.countdown._buildLayout(inst, show, '{hn} {hl}, {mn} {ml}, {sn} {sl} ({hnn}:{mnn}:{snn})', false), '4 Hours, 5 Minutes, 6 Seconds (04:05:06)', 'Layout - {hn} {hl}, {mn} {ml}, {sn} {sl} ({hnn}:{mnn}:{snn})'); cd.countdown('option', {compactLabels1: ['Yr', 'Mn', 'W', 'Dy']}); equal($.countdown._buildLayout(inst, show, '{yn} {yl}, {on} {ol}, {dn} {dl}, ' + '{hnn}{sep}{mnn}{sep}{snn} {desc}', true), '1 Yr, 2 m, 3 d, 04:05:06 until then', 'Layout - {yn} {yl}, {on} {ol}, {dn} {dl}, {hnn}{sep}{mnn}{sep}{snn} {desc}'); show = generateShow('OHMS'); cd.countdown('option', {format: 'OHMS'}); equal($.countdown._buildLayout(inst, show, '{y<}{yn} {yl}, {y>}{o<}{on} {ol}, {o>}{d<}{dn} {dl}, {d>}' + '{h<}{hn} {hl}, {h>}{m<}{mn} {ml}, {m>}{s<}{sn} {sl}{s>}', false), '14 Months, 76 Hours, 5 Minutes, 6 Seconds', 'Layout - {y<}{yn} {yl}, {y>}{o<}{on} {ol}, {o>}{d<}{dn} {dl}, {d>}' + '{h<}{hn} {hl}, {h>}{m<}{mn} {ml}, {m>}{s<}{sn} {sl}{s>}'); show = generateShow('YODHMS'); cd.countdown('option', {format: 'YODHMS', until: '+123y +2o +15d +16h +37m +48s'}); equal($.countdown._buildLayout(inst, show, '{y100} {y10} {y1} {o100} {o10} {o1} {w100} {w10} {w1} {d100} {d10} {d1} ' + '{h100} {h10} {h1} {m100} {m10} {m1} {s100} {s10} {s1}', false), '1 2 3 0 0 2 0 0 0 0 1 5 0 1 6 0 3 7 0 4 8', 'Layout - {y100} {y10} {y1} {o100} {o10} {o1} {w100} {w10} {w1} ' + '{d100} {d10} {d1} {h100} {h10} {h1} {m100} {m10} {m1} {s100} {s10} {s1}'); equal($.countdown._buildLayout(inst, show, '{} {x100} {xn} {xl}', false), '{} {x100} {xn} {xl}', 'Layout - {} {x100} {xn} {xl}'); }); test('Labels', function() { expect(4); var cd = init(); var plurals2 = ['Y2ars', 'M2nths', 'W2eks', 'D2ys', 'H2urs', 'M2nutes', 'S2conds']; var plurals3 = ['Y3ars', 'M3nths', 'W3eks', 'D3ys', 'H3urs', 'M3nutes', 'S3conds']; cd.countdown('option', {until: '+1y+2o+3d+4h+5m+6s', format: 'yodHMS', description: ''}); equal(cd.text(), '1Year2Months3Days4Hours5Minutes6Seconds', 'Labels standard - +1y+2o+3d+4h+5m+6s yodHMS'); cd.countdown('option', {until: '+1y+2o+3d+4h+5m+6s', labels2: plurals2, labels3: plurals3}); equal(cd.text(), '1Year2M2nths3D3ys4Hours5Minutes6Seconds', 'Labels custom - +1y+2o+3d+4h+5m+6s yodHMS'); cd.countdown('option', {until: '+1y+2o+3d+4h+5m+6s', labels: $.countdown.defaultOptions.labels}); equal(cd.text(), '1Year2Months3Days4Hours5Minutes6Seconds', 'Labels reset - +1y+2o+3d+4h+5m+6s yodHMS'); cd.countdown('option', {until: '+1y+2o+3d+4h+5m+6s', labels2: plurals2, labels3: plurals3, whichLabels: function(amount) { return amount % 2 + 2; }}); equal(cd.text(), '1Y3ars2M2nths3D3ys4H2urs5M3nutes6S2conds', 'Labels which - +1y+2o+3d+4h+5m+6s yodHMS'); }); test('Digits', function() { expect(3); var cd = init({digits: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']}); cd.countdown('option', {until: '+1y+2o+3d+4h+5m+6s', format: 'yodHMS', description: ''}); equal(cd.text(), 'BYearCMonthsDDaysEHoursFMinutesGSeconds', 'Digits - +1y+2o+3d+4h+5m+6s yodHMS'); cd.countdown('option', {until: '+1y+2o+3d+4h+5m+6s', compact: true}); equal(cd.text(), 'By Cm Dd AE:AF:AG', 'Digits compact - +1y+2o+3d+4h+5m+6s yodHMS'); cd.countdown('option', {until: '+1y+2o+3d+4h+5m+6s', layout: '{ynnn} {onn} {dn} {h10}{h1}:{m10}{m1}:{s10}{s1}'}); equal(cd.text(), 'AAB AC D AE:AF:AG', 'Digits layout - +1y+2o+3d+4h+5m+6s yodHMS'); }); test('Expiry', function() { expect(4); var expired = false; var doExpiry = function() { expired = true; }; var cd = init({onExpiry: doExpiry, alwaysExpire: true, description: ''}); equal(expired, true, 'Expiry - onExpiry'); equal(cd.text(), '0Hours0Minutes0Seconds', 'Expiry - no expiryText'); expired = false; cd.countdown('option', {onExpiry: null, expiryText: 'All over'}); equal(expired, false, 'Expiry - no onExpiry'); equal(cd.text(), 'All over', 'Expiry - expiryText'); }); test('Pause', function() { expect(4); var cd = init({until: +5, description: ''}); equal(cd.text(), '0Hours0Minutes5Seconds', 'Pause - initial'); clock.tick(1000); equal(cd.text(), '0Hours0Minutes4Seconds', 'Pause - tick'); cd.countdown('pause'); clock.tick(2000); equal(cd.text(), '0Hours0Minutes4Seconds', 'Pause - paused'); cd.countdown('resume'); clock.tick(2000); equal(cd.text(), '0Hours0Minutes2Seconds', 'Pause - resumed'); }); test('Pause toggle', function() { expect(4); var cd = init({until: +5, description: ''}); equal(cd.text(), '0Hours0Minutes5Seconds', 'Pause toggle - initial'); clock.tick(1000); equal(cd.text(), '0Hours0Minutes4Seconds', 'Pause toggle - tick'); cd.countdown('toggle'); clock.tick(2000); equal(cd.text(), '0Hours0Minutes4Seconds', 'Pause toggle - paused'); cd.countdown('toggle'); clock.tick(2000); equal(cd.text(), '0Hours0Minutes2Seconds', 'Pause toggle - resumed'); }); test('Lap', function() { expect(4); var cd = init({until: +5, description: ''}); equal(cd.text(), '0Hours0Minutes5Seconds', 'Lap - initial'); clock.tick(1000); equal(cd.text(), '0Hours0Minutes4Seconds', 'Lap - tick'); cd.countdown('lap'); clock.tick(2000); equal(cd.text(), '0Hours0Minutes4Seconds', 'Lap - paused'); cd.countdown('resume'); clock.tick(2000); equal(cd.text(), '0Hours0Minutes0Seconds', 'Lap - resumed'); }); test('Lap toggle', function() { expect(4); var cd = init({until: +5, description: ''}); equal(cd.text(), '0Hours0Minutes5Seconds', 'Lap toggle - initial'); clock.tick(1000); equal(cd.text(), '0Hours0Minutes4Seconds', 'Lap toggle - tick'); cd.countdown('toggleLap'); clock.tick(2000); equal(cd.text(), '0Hours0Minutes4Seconds', 'Lap toggle - paused'); cd.countdown('toggleLap'); clock.tick(2000); equal(cd.text(), '0Hours0Minutes0Seconds', 'Lap toggle - resumed'); }); function init(settings) { if ($('#cd').hasClass('is-countdown')) { $('#cd').countdown('destroy'); } return $('#cd').countdown($.extend({description: 'descr'}, settings || {})); } function generateShow(format) { var show = []; show[0] = (format.match('y') ? '?' : (format.match('Y') ? '!' : null)); show[1] = (format.match('o') ? '?' : (format.match('O') ? '!' : null)); show[2] = (format.match('w') ? '?' : (format.match('W') ? '!' : null)); show[3] = (format.match('d') ? '?' : (format.match('D') ? '!' : null)); show[4] = (format.match('h') ? '?' : (format.match('H') ? '!' : null)); show[5] = (format.match('m') ? '?' : (format.match('M') ? '!' : null)); show[6] = (format.match('s') ? '?' : (format.match('S') ? '!' : null)); return show; } function equalTime(time1, time2, msg) { if (typeof time1 === 'undefined' || time1 === null || typeof time2 === 'undefined' || time2 === null) { ok(false, msg + ' - null time'); return; } time1.setMilliseconds(0); time2.setMilliseconds(0); equal(time1.toString(), time2.toString(), msg); } });