2 lines
No EOL
17 KiB
JavaScript
2 lines
No EOL
17 KiB
JavaScript
var uhr=function(t){var e={};function n(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(i,o,function(e){return t[e]}.bind(null,o));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=12)}({0:function(t,e){t.exports=Cookies},1:function(t,e){t.exports=jQuery},12:function(t,e,n){"use strict";n.r(e);var i=function(){function t(){}return t.registerTheme=function(e,n){t.themes.some(function(t){return t.name===e})?console.log("Theme with name '"+e+"' already registered; ignoring register request for styleClass '"+n+"'."):t.themes.push({name:e,styleClass:n})},t.hasThemes=function(){return t.themes.length>0},t.hasMultipleThemes=function(){return t.themes.length>1},t.getFirstTheme=function(){return t.getTheme(0)},t.getTheme=function(e){return t.themes[e]},t.getThemes=function(){return t.themes},t.registerLayout=function(e){!t.layouts.some(function(t){return e.code===t.code&&(e.prettyName!==t.prettyName&&console.error("Error: Language code '"+e.code+"' cannot be registered for layout '"+e.prettyName+"' because it is already registered for layout '"+t.prettyName+"'!"),!0)})&&(t.layouts.push(e),t.layouts.sort(function(t,e){return t.prettyName.localeCompare(e.prettyName)}))},t.hasLayouts=function(){return t.layouts.length>0},t.hasMultipleLayouts=function(){return t.layouts.length>1},t.getFirstLayout=function(){return t.layouts[0]},t.getLayouts=function(){return t.layouts},t.layouts=[],t.themes=[],t}(),o=n(0),s={code:null,hours:null,letters:[],minutes:null,permanent:[],prettyName:null,version:2},r=function(){function t(t,e){this.style="",this.value=t,e&&(this.style=e)}return t.prototype.addStyle=function(t){""===this.style?this.style=t:this.style+=" "+t},t.prototype.toString=function(){return'<span class="item letter '+this.style+'">'+this.value+"</span>"},t}(),a=function(){function t(t){this.layout=t}return t.prototype.parse=function(){var e=[];return this.layout.letters.forEach(function(t){for(var n=[],i=0;i<t.length;i++)n.push(new r(t[i]));e.push(n)}),this.parseArrayOrObject(e,"on",this.layout.permanent),void 0!==this.layout.seconds&&null!==this.layout.seconds?this.parseTimeDefinition(e,"second",this.layout.seconds):this.parseTimeDefinition(e,"second",t.seconds),this.parseTimeDefinition(e,"minute",this.layout.minutes),this.parseTimeDefinition(e,"hour",this.layout.hours),e},t.prototype.parseObject=function(t,e,n){null!=n&&Object.keys(n).map(function(t){return Number(t)}).forEach(function(i){return n[i].forEach(function(n){return t[i-1][n-1].addStyle(e)})})},t.prototype.parseArrayOrObject=function(t,e,n){var i=this;null!=n&&(Array.isArray(n)?n.forEach(function(n){return i.parseObject(t,e,n)}):this.parseObject(t,e,n))},t.prototype.parseTimeDefinition=function(t,e,n){var i=this;null!=n&&Object.keys(n).forEach(function(o){var s=o.split(","),r=n[o];s.forEach(function(n){return i.parseArrayOrObject(t,e+n,r)})})},t.vorne0={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]},t.hinten0={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]},t.vorne1={3:[3],4:[2,3],5:[3],6:[3],7:[3],8:[3],9:[2,3,4]},t.hinten1={3:[9],4:[8,9],5:[9],6:[9],7:[9],8:[9],9:[8,9,10]},t.vorne2={3:[2,3,4],4:[1,5],5:[5],6:[4],7:[3],8:[2],9:[1,2,3,4,5]},t.hinten2={3:[8,9,10],4:[7,11],5:[11],6:[10],7:[9],8:[8],9:[7,8,9,10,11]},t.vorne3={3:[1,2,3,4,5],4:[4],5:[3],6:[4],7:[5],8:[1,5],9:[2,3,4]},t.hinten3={3:[7,8,9,10,11],4:[10],5:[9],6:[10],7:[11],8:[7,11],9:[8,9,10]},t.vorne4={3:[4],4:[3,4],5:[2,4],6:[1,4],7:[1,2,3,4,5],8:[4],9:[4]},t.hinten4={3:[10],4:[9,10],5:[8,10],6:[7,10],7:[7,8,9,10,11],8:[10],9:[10]},t.vorne5={3:[1,2,3,4,5],4:[1],5:[1,2,3,4],6:[5],7:[5],8:[1,5],9:[2,3,4]},t.hinten5={3:[7,8,9,10,11],4:[7],5:[7,8,9,10],6:[11],7:[11],8:[7,11],9:[8,9,10]},t.hinten6={3:[9,10],4:[8],5:[7],6:[7,8,9,10],7:[7,11],8:[7,11],9:[8,9,10]},t.hinten7={3:[7,8,9,10,11],4:[11],5:[10],6:[9],7:[8],8:[8],9:[8]},t.hinten8={3:[8,9,10],4:[7,11],5:[7,11],6:[8,9,10],7:[7,11],8:[7,11],9:[8,9,10]},t.hinten9={3:[8,9,10],4:[7,11],5:[7,11],6:[8,9,10,11],7:[11],8:[10],9:[8,9]},t.seconds={0:[t.vorne0,t.hinten0],1:[t.vorne0,t.hinten1],2:[t.vorne0,t.hinten2],3:[t.vorne0,t.hinten3],4:[t.vorne0,t.hinten4],5:[t.vorne0,t.hinten5],6:[t.vorne0,t.hinten6],7:[t.vorne0,t.hinten7],8:[t.vorne0,t.hinten8],9:[t.vorne0,t.hinten9],10:[t.vorne1,t.hinten0],11:[t.vorne1,t.hinten1],12:[t.vorne1,t.hinten2],13:[t.vorne1,t.hinten3],14:[t.vorne1,t.hinten4],15:[t.vorne1,t.hinten5],16:[t.vorne1,t.hinten6],17:[t.vorne1,t.hinten7],18:[t.vorne1,t.hinten8],19:[t.vorne1,t.hinten9],20:[t.vorne2,t.hinten0],21:[t.vorne2,t.hinten1],22:[t.vorne2,t.hinten2],23:[t.vorne2,t.hinten3],24:[t.vorne2,t.hinten4],25:[t.vorne2,t.hinten5],26:[t.vorne2,t.hinten6],27:[t.vorne2,t.hinten7],28:[t.vorne2,t.hinten8],29:[t.vorne2,t.hinten9],30:[t.vorne3,t.hinten0],31:[t.vorne3,t.hinten1],32:[t.vorne3,t.hinten2],33:[t.vorne3,t.hinten3],34:[t.vorne3,t.hinten4],35:[t.vorne3,t.hinten5],36:[t.vorne3,t.hinten6],37:[t.vorne3,t.hinten7],38:[t.vorne3,t.hinten8],39:[t.vorne3,t.hinten9],40:[t.vorne4,t.hinten0],41:[t.vorne4,t.hinten1],42:[t.vorne4,t.hinten2],43:[t.vorne4,t.hinten3],44:[t.vorne4,t.hinten4],45:[t.vorne4,t.hinten5],46:[t.vorne4,t.hinten6],47:[t.vorne4,t.hinten7],48:[t.vorne4,t.hinten8],49:[t.vorne4,t.hinten9],50:[t.vorne5,t.hinten0],51:[t.vorne5,t.hinten1],52:[t.vorne5,t.hinten2],53:[t.vorne5,t.hinten3],54:[t.vorne5,t.hinten4],55:[t.vorne5,t.hinten5],56:[t.vorne5,t.hinten6],57:[t.vorne5,t.hinten7],58:[t.vorne5,t.hinten8],59:[t.vorne5,t.hinten9]},t}(),h=function(){function t(t,e){this.layout=t,this.renderarea=e}return t.prototype.render=function(t){var e=this;if(void 0===this.layout.parsed){if(2!==this.layout.version)return void console.warn("Unknown layout version: '"+this.layout.version+"', expecting '2'");var n=new a(this.layout).parse();Object.defineProperty(this.layout,"parsed",{value:n,writable:!1,configurable:!1})}var i=this.layout.parsed;this.renderarea.fadeOut("fast",function(){e.renderarea.empty(),i.forEach(function(t,n,i){t.forEach(function(t){return e.renderarea.append(t.toString())}),n<i.length-1&&e.renderarea.append("<br/>")}),t&&t(),e.renderarea.fadeIn("fast")})},t}(),u=function(){function t(t){this.widgetInstance=t,this.timer=null,this.currentMinute=null;var e=this.widgetInstance.options.time;void 0===this.widgetInstance.options.time&&(this.widgetInstance.options.time=new Date),this.parseHash(),this.setupHTML(),this.wireFunctionality(),void 0!==e&&this.setTime(e)}return t.prototype.destroy=function(){this.timer&&(window.clearInterval(this.timer),this.timer=null),this.widgetInstance.element.removeAttr("style").removeAttr("class").empty(),$("#uhr-configlink"+this.widgetInstance.uuid).remove(),$("#uhr-controlpanel"+this.widgetInstance.uuid).remove()},t.prototype.start=function(){var t=this;this.isOn()||(this.timer=window.setInterval(function(){t.widgetInstance.options.time=new Date,t.update()},1e3),this.update(),this.setCookie("uhr-status","on"))},t.prototype.stop=function(){this.isOn()&&(window.clearInterval(this.timer),this.timer=null,this.update(),this.setCookie("uhr-status","off"))},t.prototype.toggle=function(){this.isOn()?this.stop():this.start()},t.prototype.setLanguage=function(t){var e=this;t!==this.widgetInstance.options.language&&(this.widgetInstance.options.language=t,new h(this.getCurrentLayout(),this.widgetInstance.element.find(".letterarea")).render(function(){e.currentMinute=-1,e.update()}),this.setCookie("uhr-language",t),this.update())},t.prototype.setTheme=function(t){t!==this.widgetInstance.options.theme&&(this.widgetInstance.element.removeClass(this.widgetInstance.options.theme).addClass(t),$("#uhr-onoffswitch"+this.widgetInstance.uuid).removeClass(this.widgetInstance.options.theme).addClass(t),this.widgetInstance.options.theme=t,this.setCookie("uhr-theme",t))},t.prototype.setTime=function(t){this.currentMinute=null,null===t?this.widgetInstance.options.time=new Date:(null!==this.timer&&window.clearInterval(this.timer),this.widgetInstance.options.time=t),this.update()},t.prototype.setMode=function(t){this.widgetInstance.options.mode=t,this.currentMinute=null,this.update(),this.setCookie("uhr-mode",t)},t.prototype.setWidth=function(t){var e=this.widgetInstance.element;e.css("width",t);var n=e.width();e.width(n),e.height(n),e.css("font-size",n/40+"px")},t.prototype.setupHTML=function(){var t=this,e=this.widgetInstance.element;if(e.addClass("uhr").empty().append('<span class="item dot dot1"></span>').append('<span class="item dot dot2"></span>').append('<span class="item dot dot3"></span>').append('<span class="item dot dot4"></span>').append('<div class="letterarea"></div>').append('<div class="reflection"></div>'),this.setWidth(this.widgetInstance.options.width),this.widgetInstance.options.controls){var n=$('<div class="uhr-controlpanel" id="uhr-controlpanel'+this.widgetInstance.uuid+'"></div>'),o=$('<div class="content"></div>');n.append(o);var s=$('<div class="onoffswitch" id="uhr-onoffswitch'+this.widgetInstance.uuid+'"></div>');s.append('<input type="checkbox" class="onoffswitch-checkbox" id="uhr-onoffswitch-checkbox'+this.widgetInstance.uuid+'" checked="checked" />'),s.append('<label class="onoffswitch-label" for="uhr-onoffswitch-checkbox'+this.widgetInstance.uuid+'"><div class="onoffswitch-inner"></div><div class="onoffswitch-switch"></div></label>'),o.append(s);var r=$('<div class="onoffswitch" id="uhr-modeswitch'+this.widgetInstance.uuid+'"></div>');if(r.append('<input type="checkbox" class="onoffswitch-checkbox" id="uhr-modeswitch-checkbox'+this.widgetInstance.uuid+'" checked="checked" />'),r.append('<label class="onoffswitch-label" for="uhr-modeswitch-checkbox'+this.widgetInstance.uuid+'"><div class="modeswitch-inner"></div><div class="onoffswitch-switch"></div></label>'),o.append(r),i.hasMultipleLayouts()){var a=$('<select id="uhr-languagechooser'+this.widgetInstance.uuid+'"></select>');i.getLayouts().forEach(function(t){a.append('<option value="'+t.code+'">'+t.prettyName+"</option>")}),o.append(a)}if(i.hasMultipleThemes()){var h=$('<select id="uhr-themechooser'+this.widgetInstance.uuid+'"></select>');i.getThemes().forEach(function(t){h.append('<option value="'+t.styleClass+'">'+t.name+"</option>")}),o.append(h)}var u=$('<a class="uhr-closecontrolpanel" id="uhr-closecontrolpanel'+this.widgetInstance.uuid+'"></a>');u.on("click",function(){return $("#uhr-controlpanel"+t.widgetInstance.uuid).hide("fast")}),o.append(u),e.after(n),n.hide();var c=$('<a class="uhr-configlink" id="uhr-configlink'+this.widgetInstance.uuid+'"></a>');c.on({click:function(){return t.toggleConfigScreen()}}),e.after(c)}},t.prototype.wireFunctionality=function(){var t=this,e=$("#uhr-onoffswitch-checkbox"+this.widgetInstance.uuid);e.on({click:function(){return t.toggle()}});var n=this.getCookie("uhr-status");(void 0===n||this.widgetInstance.options.force)&&(n=this.widgetInstance.options.status),e.prop("checked","on"===n),"on"===n?this.start():this.stop();var o=$("#uhr-modeswitch-checkbox"+this.widgetInstance.uuid);o.on({click:function(){"seconds"===t.widgetInstance.options.mode?t.setMode("normal"):t.setMode("seconds")}});var s=this.getCookie("uhr-mode");(void 0===s||this.widgetInstance.options.force)&&(s=this.widgetInstance.options.mode),o.prop("checked","seconds"!==s),"seconds"===s?this.setMode("seconds"):this.setMode("normal");var r=$("#uhr-languagechooser"+this.widgetInstance.uuid);r.on({change:function(){var e=$("#uhr-languagechooser"+t.widgetInstance.uuid).val();t.setLanguage(e)}});var a=this.getCookie("uhr-language");(void 0===a||this.widgetInstance.options.force)&&(a=this.widgetInstance.options.language);var h=i.getLayouts().some(function(t){return a===t.code});if(!h){var u=void 0;u=i.hasLayouts()?i.getFirstLayout().code:"",console.warn("Language '"+a+"' not found! Using fallback '"+u+"'."),a=u}r.val(a),this.widgetInstance.options.language="",this.setLanguage(a);var c=$("#uhr-themechooser"+this.widgetInstance.uuid);c.on({change:function(){var e=$("#uhr-themechooser"+t.widgetInstance.uuid).val();t.setTheme(e)}});var d=this.getCookie("uhr-theme");if((void 0===d||this.widgetInstance.options.force)&&(d=this.widgetInstance.options.theme),!(h=i.getThemes().some(function(t){return d===t.styleClass}))){var l=i.getFirstTheme().styleClass;console.warn("Theme '"+d+"' not found! Using fallback '"+l+"'."),d=l}c.val(d),this.widgetInstance.options.theme="",this.setTheme(d),this.widgetInstance.options.autoresize&&$(window).on({resize:function(){var e=t.widgetInstance.element.parent(),n=$(window),i=e.width(),o=e.height(),s=n.width(),r=n.height(),a=Math.min(i,o,s,r)+"px";t.setWidth(a)}})},t.prototype.isOn=function(){return null!==this.timer},t.prototype.getCookie=function(t){return o.get(t+this.widgetInstance.uuid)},t.prototype.setCookie=function(t,e){var n;n=void 0!==this.widgetInstance.options.cookiePath?{expires:365,path:this.widgetInstance.options.cookiePath}:{expires:365},o.set(t+this.widgetInstance.uuid,e,n)},t.prototype.update=function(){if(this.isOn()){var t=this.widgetInstance.options.time;if(!this.getCurrentLayout().hasOwnProperty("seconds")&&"seconds"!==this.widgetInstance.options.mode){if(t.getMinutes()===this.currentMinute)return;this.currentMinute=t.getMinutes()}this.show(t)}else this.clear(),this.currentMinute=-1},t.prototype.show=function(t){var e=this.getSecond(t),n=this.getDotMinute(t),i=this.getHour(t),o=this.getCoarseMinute(t);if(this.clear(),"seconds"===this.widgetInstance.options.mode)this.highlight("second"+e);else{this.highlight("on");for(var s=1;s<=n;s++)this.highlight("dot"+s);this.highlight("minute"+o),this.highlight("hour"+i)}},t.prototype.clear=function(){this.widgetInstance.element.find(".item").removeClass("active")},t.prototype.highlight=function(t){this.widgetInstance.element.find(".item."+t).addClass("active")},t.prototype.getSecond=function(t){return"function"==typeof this.getCurrentLayout().getSeconds?this.getCurrentLayout().getSeconds(t):t.getSeconds()},t.prototype.getDotMinute=function(t){return"function"==typeof this.getCurrentLayout().getDotMinute?this.getCurrentLayout().getDotMinute(t):t.getMinutes()%5},t.prototype.getCoarseMinute=function(t){return"function"==typeof this.getCurrentLayout().getCoarseMinute?this.getCurrentLayout().getCoarseMinute(t):t.getMinutes()},t.prototype.getHour=function(t){if("function"==typeof this.getCurrentLayout().getHour)return this.getCurrentLayout().getHour(t);var e=t.getHours();return t.getMinutes()>=25?(e+1)%24:e},t.prototype.toggleConfigScreen=function(){$("#uhr-controlpanel"+this.widgetInstance.uuid).toggle("fast")},t.prototype.parseHash=function(){var t=this,e=window.location.hash;void 0!==e&&"#"===e.charAt(0)&&(e=e.substring(1),(e=decodeURIComponent(e)).split("&").forEach(function(e){var n=e.split("="),i=n[0],o=n[1];switch(i){case"l":case"language":t.widgetInstance.options.language=o,t.widgetInstance.options.force=!0;break;case"t":case"theme":t.widgetInstance.options.theme=o,t.widgetInstance.options.force=!0;break;case"m":case"mode":t.widgetInstance.options.mode=o,t.widgetInstance.options.force=!0;break;case"s":case"status":t.widgetInstance.options.status=o,t.widgetInstance.options.force=!0}}))},t.prototype.getCurrentLayout=function(){var t=this,e=i.getLayouts().filter(function(e){return e.code===t.widgetInstance.options.language},this);return e.length>0?e[0]:s},t}(),c=n(1);c("link[rel=stylesheet]").each(function(t,e){var n=c(e),o=n.attr("data-class");if(void 0!==o){var s=n.attr("data-name");void 0===s&&(s=o),i.registerTheme(s,o)}}),i.hasThemes()||i.registerTheme("",""),$.widget("fritteli.uhr",{options:{width:"100%",status:"on",language:"de_CH",theme:i.getFirstTheme().styleClass,force:!1,controls:!0,cookiePath:void 0,autoresize:!0,mode:"normal"},start:function(){this.__fritteli_uhr_instance.start()},stop:function(){this.__fritteli_uhr_instance.stop()},toggle:function(){this.__fritteli_uhr_instance.toggle()},language:function(t){this.__fritteli_uhr_instance.setLanguage(t)},theme:function(t){this.__fritteli_uhr_instance.setTheme(t)},time:function(t){this.__fritteli_uhr_instance.setTime(t)},mode:function(t){this.__fritteli_uhr_instance.setMode(t)},width:function(t){this.__fritteli_uhr_instance.setWidth(t)},_create:function(){this.__fritteli_uhr_instance=new u(this)},_destroy:function(){this.__fritteli_uhr_instance.destroy()},__fritteli_uhr_instance:null}),$.fritteli.uhr.register=i.registerLayout}});
|
|
//# sourceMappingURL=uhr.js.map
|