2 lines
No EOL
17 KiB
JavaScript
2 lines
No EOL
17 KiB
JavaScript
!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}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={code:null,hours:null,letters:[],minutes:null,permanent:[],prettyName:null,version:2},s=n(0),r=function(){function t(t,e){this.widgetId=t,this.cookiePath=e}return t.prototype.getLayout=function(){var t=this.getCookie("uhr-language");return t&&(this.removeCookie("uhr-language"),this.setLayout(t)),this.getCookie("uhr-layout")},t.prototype.setLayout=function(t){this.setCookie("uhr-layout",t)},t.prototype.getMode=function(){return this.getCookie("uhr-mode")},t.prototype.setMode=function(t){this.setCookie("uhr-mode",t)},t.prototype.getStatus=function(){return this.getCookie("uhr-status")},t.prototype.setStatus=function(t){this.setCookie("uhr-status",t)},t.prototype.getTheme=function(){return this.getCookie("uhr-theme")},t.prototype.setTheme=function(t){this.setCookie("uhr-theme",t)},t.prototype.getCookie=function(t){return s.get(t+this.widgetId)},t.prototype.setCookie=function(t,e){var n;n=this.cookiePath?{expires:365,path:this.cookiePath}:{expires:365},s.set(t+this.widgetId,e,n)},t.prototype.removeCookie=function(t){this.cookiePath?s.remove(t+this.widgetId,{path:this.cookiePath}):s.remove(t+this.widgetId)},t}(),h=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 h(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}(),u=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}(),c=function(){function t(t,e,n,i){this.uhr=t,this.$element=e,this.options=n,this.id=i,this.cookieHandler=new r(i,n.cookiePath)}return t.prototype.render=function(){this.setupHTML(),this.wireFunctionality()},t.prototype.setWidth=function(t){this.$element.css("width",t);var e=this.$element.width();this.$element.width(e),this.$element.height(e),this.$element.css("font-size",e/40+"px")},t.prototype.setupHTML=function(){var t=this;if(this.$element.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.options.width),this.options.controls){var e=$('<div class="uhr-controlpanel" id="uhr-controlpanel'+this.id+'"></div>'),n=$('<div class="content"></div>');e.append(n);var o=$('<div class="onoffswitch" id="uhr-onoffswitch'+this.id+'"></div>');o.append('<input type="checkbox" class="onoffswitch-checkbox" id="uhr-onoffswitch-checkbox'+this.id+'" checked="checked" />'),o.append('<label class="onoffswitch-label" for="uhr-onoffswitch-checkbox'+this.id+'"><div class="onoffswitch-inner"></div><div class="onoffswitch-switch"></div></label>'),n.append(o);var s=$('<div class="onoffswitch" id="uhr-modeswitch'+this.id+'"></div>');if(s.append('<input type="checkbox" class="onoffswitch-checkbox" id="uhr-modeswitch-checkbox'+this.id+'" checked="checked" />'),s.append('<label class="onoffswitch-label" for="uhr-modeswitch-checkbox'+this.id+'"><div class="modeswitch-inner"></div><div class="onoffswitch-switch"></div></label>'),n.append(s),i.hasMultipleLayouts()){var r=$('<select id="uhr-languagechooser'+this.id+'"></select>');i.getLayouts().forEach(function(t){r.append('<option value="'+t.code+'">'+t.prettyName+"</option>")}),n.append(r)}if(i.hasMultipleThemes()){var h=$('<select id="uhr-themechooser'+this.id+'"></select>');i.getThemes().forEach(function(t){h.append('<option value="'+t.styleClass+'">'+t.name+"</option>")}),n.append(h)}var a=$('<a class="uhr-closecontrolpanel" id="uhr-closecontrolpanel'+this.id+'"></a>');a.on({click:function(){return $("#uhr-controlpanel"+t.id).hide("fast")}}),n.append(a),this.$element.after(e),e.hide();var u=$('<a class="uhr-configlink" id="uhr-configlink'+this.id+'"></a>');u.on({click:function(){return t.toggleConfigScreen()}}),this.$element.after(u)}},t.prototype.wireFunctionality=function(){var t=this,e=$("#uhr-onoffswitch-checkbox"+this.id);e.on({click:function(){return t.uhr.toggle()}});var n=this.cookieHandler.getStatus();(void 0===n||this.options.force)&&(n=this.options.status),e.prop("checked","on"===n),"on"===n?this.uhr.start():this.uhr.stop();var o=$("#uhr-modeswitch-checkbox"+this.id);o.on({click:function(){"seconds"===t.options.mode?t.uhr.setMode("normal"):t.uhr.setMode("seconds")}});var s=this.cookieHandler.getMode();(void 0===s||this.options.force)&&(s=this.options.mode),o.prop("checked","seconds"!==s),"seconds"===s?this.uhr.setMode("seconds"):this.uhr.setMode("normal");var r=$("#uhr-languagechooser"+this.id);r.on({change:function(){var e=$("#uhr-languagechooser"+t.id).val();t.uhr.setLayout(e)}});var h=this.cookieHandler.getLayout();(void 0===h||this.options.force)&&(h=this.options.language);var a=i.getLayouts().some(function(t){return h===t.code});if(!a){var u=void 0;u=i.hasLayouts()?i.getFirstLayout().code:"",console.warn("Language '"+h+"' not found! Using fallback '"+u+"'."),h=u}r.val(h),this.options.language="",this.uhr.setLayout(h);var c=$("#uhr-themechooser"+this.id);c.on({change:function(){var e=$("#uhr-themechooser"+t.id).val();t.uhr.setTheme(e)}});var l=this.cookieHandler.getTheme();if((void 0===l||this.options.force)&&(l=this.options.theme),!(a=i.getThemes().some(function(t){return l===t.styleClass}))){var d=i.getFirstTheme().styleClass;console.warn("Theme '"+l+"' not found! Using fallback '"+d+"'."),l=d}c.val(l),this.options.theme="",this.uhr.setTheme(l),this.options.autoresize&&$(window).on({resize:function(){var e=t.$element.parent(),n=$(window),i=e.width(),o=e.height(),s=n.width(),r=n.height(),h=Math.min(i,o,s,r)+"px";t.setWidth(h)}})},t.prototype.toggleConfigScreen=function(){$("#uhr-controlpanel"+this.id).toggle("fast")},t}(),l=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.cookieHandler=new r(this.widgetInstance.uuid,this.widgetInstance.options.cookiePath),this.parseHash(),this.renderer=new c(this,this.widgetInstance.element,this.widgetInstance.options,this.widgetInstance.uuid),this.renderer.render(),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.cookieHandler.setStatus("on"))},t.prototype.stop=function(){this.isOn()&&(window.clearInterval(this.timer),this.timer=null,this.update(),this.cookieHandler.setStatus("off"))},t.prototype.toggle=function(){this.isOn()?this.stop():this.start()},t.prototype.setLayout=function(t){var e=this;t!==this.widgetInstance.options.language&&(this.widgetInstance.options.language=t,new u(this.getCurrentLayout(),this.widgetInstance.element.find(".letterarea")).render(function(){e.currentMinute=-1,e.update()}),this.cookieHandler.setLayout(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.cookieHandler.setTheme(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.cookieHandler.setMode(t)},t.prototype.setWidth=function(t){this.renderer.setWidth(t)},t.prototype.isOn=function(){return null!==this.timer},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.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]:o},t}(),d=n(1);d("link[rel=stylesheet]").each(function(t,e){var n=d(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.setLayout(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 l(this)},_destroy:function(){this.__fritteli_uhr_instance.destroy()},__fritteli_uhr_instance:null}),$.fritteli.uhr.register=i.registerLayout}});
|
|
//# sourceMappingURL=uhr.js.map
|