uhr/dist/jquery.uhr.base.min.js

4 lines
12 KiB
JavaScript
Raw Normal View History

/*! uhr - v7.0.0-next - 2015-01-16
* http://bärneruhr.ch/
* Copyright (c) 2015 Manuel Friedli; Licensed GPLv3 */
!function(a){"use strict";function b(a,b){this.render=function(d){if(void 0===a.parsed)switch(a.version){case 2:var e=new c(a),f=e.parse();Object.defineProperty(a,"parsed",{value:f,writable:!1,configurable:!1});break;default:return void console.warn("Unknown layout version: '"+a.version+"'")}var g=a.parsed;b.fadeOut("fast",function(){b.empty(),g.forEach(function(a,c,d){a.forEach(function(a){b.append(a.toString())}),c<d.length-1&&b.append("<br/>")}),"function"==typeof d&&d(),b.fadeIn("fast")})}}function c(a){function b(a,b,d){"undefined"!=typeof d&&null!==d&&(Array.isArray(d)?d.forEach(function(d){c(a,b,d)}):c(a,b,d))}function c(a,b,c){"undefined"!=typeof c&&null!==c&&Object.keys(c).forEach(function(d){var e=c[d];e.forEach(function(c){a[d-1][c-1].addStyle(b)})})}function e(a,c,d){"undefined"!=typeof d&&null!==d&&Object.keys(d).forEach(function(e){var f=e.split(","),g=d[e];f.forEach(function(d){b(a,c+d,g)})})}var f={3:[2,3,4],4:[1,5],5:[1,4,5],6:[1,3,5],7:[1,2,5],8:[1,5],9:[2,3,4]},g={3:[8,9,10],4:[7,11],5:[7,10,11],6:[7,9,11],7:[7,8,11],8:[7,11],9:[8,9,10]},h={3:[3],4:[2,3],5:[3],6:[3],7:[3],8:[3],9:[2,3,4]},i={3:[9],4:[8,9],5:[9],6:[9],7:[9],8:[9],9:[8,9,10]},j={3:[2,3,4],4:[1,5],5:[5],6:[4],7:[3],8:[2],9:[1,2,3,4,5]},k={3:[8,9,10],4:[7,11],5:[11],6:[10],7:[9],8:[8],9:[7,8,9,10,11]},l={3:[1,2,3,4,5],4:[4],5:[3],6:[4],7:[5],8:[1,5],9:[2,3,4]},m={3:[7,8,9,10,11],4:[10],5:[9],6:[10],7:[11],8:[7,11],9:[8,9,10]},n={3:[4],4:[3,4],5:[2,4],6:[1,4],7:[1,2,3,4,5],8:[4],9:[4]},o={3:[10],4:[9,10],5:[8,10],6:[7,10],7:[7,8,9,10,11],8:[10],9:[10]},p={3:[1,2,3,4,5],4:[1],5:[1,2,3,4],6:[5],7:[5],8:[1,5],9:[2,3,4]},q={3:[7,8,9,10,11],4:[7],5:[7,8,9,10],6:[11],7:[11],8:[7,11],9:[8,9,10]},r={3:[9,10],4:[8],5:[7],6:[7,8,9,10],7:[7,11],8:[7,11],9:[8,9,10]},s={3:[7,8,9,10,11],4:[11],5:[10],6:[9],7:[8],8:[8],9:[8]},t={3:[8,9,10],4:[7,11],5:[7,11],6:[8,9,10],7:[7,11],8:[7,11],9:[8,9,10]},u={3:[8,9,10],4:[7,11],5:[7,11],6:[8,9,10,11],7:[11],8:[10],9:[8,9]},v={0:[f,g],1:[f,i],2:[f,k],3:[f,m],4:[f,o],5:[f,q],6:[f,r],7:[f,s],8:[f,t],9:[f,u],10:[h,g],11:[h,i],12:[h,k],13:[h,m],14:[h,o],15:[h,q],16:[h,r],17:[h,s],18:[h,t],19:[h,u],20:[j,g],21:[j,i],22:[j,k],23:[j,m],24:[j,o],25:[j,q],26:[j,r],27:[j,s],28:[j,t],29:[j,u],30:[l,g],31:[l,i],32:[l,k],33:[l,m],34:[l,o],35:[l,q],36:[l,r],37:[l,s],38:[l,t],39:[l,u],40:[n,g],41:[n,i],42:[n,k],43:[n,m],44:[n,o],45:[n,q],46:[n,r],47:[n,s],48:[n,t],49:[n,u],50:[p,g],51:[p,i],52:[p,k],53:[p,m],54:[p,o],55:[p,q],56:[p,r],57:[p,s],58:[p,t],59:[p,u]};this.parse=function(){var c=[];return a.letters.forEach(function(a){for(var b=[],e=0;e<a.length;e++){var f=new d(a[e]);b.push(f)}c.push(b)}),b(c,"on",a.permanent),"undefined"!=typeof a.seconds&&null!==a.seconds?e(c,"second",a.seconds):e(c,"second",v),e(c,"minute",a.minutes),e(c,"hour",a.hours),c}}function d(a,b){var c=a,d=b||"";this.addStyle=function(a){""===d?d=a:d+=" "+a},this.toString=function(){return'<span class="item letter '+d+'">'+c+"</span>"}}var e={id:0,languages:[],themes:[],registerLanguage:function(a,b){var c=e.languages.some(function(c){return a===c.code?(console.error("Error: Language code '"+a+"' cannot be registered for language '"+b.language+"' because it is already registered for language '"+c.language+"'!"),!0):!1});c||(b.code=a,e.languages.push(b))}};a("link[rel=stylesheet]").each(function(b,c){var d=a(c),f=d.attr("data-class");if(void 0!==f){var g=d.attr("data-name");void 0===g&&(g=f),e.themes.push({styleClass:f,name:g})}}),0===e.themes.length&&e.themes.push({});var f=function(){t.bind(this)()||(this.timer=window.setInterval(function(){this.options.time=new Date,u.bind(this)()}.bind(this),1e3),u.bind(this)(),s.bind(this)("uhr-status","on"))},g=function(){t.bind(this)()&&(window.clearInterval(this.timer),this.timer=null,u.bind(this)(),s.bind(this)("uhr-status","off"))},h=function(){t.bind(this)()?this.stop():this.start()},i=function(a){if(a!==this.options.language){this.options.language=a;var c=new b(C.bind(this)(),this.element.find(".letterarea"));c.render.bind(this)(function(){this.currentMinute=-1,u.bind(this)()}.bind(this)),s.bind(this)("uhr-lan