5 lines
12 KiB
JavaScript
5 lines
12 KiB
JavaScript
/*! uhr - v9.0.0-dev.0 - 2019-05-03
|
|
* http://bärneruhr.ch/
|
|
* Copyright (c) 2019 Manuel Friedli; Licensed GPL-3.0 */
|
|
|
|
!function(u){"use strict";var i,e,n,l={id:0,languages:[],themes:[],registerLanguage:function(i,e){l.languages.some(function(t){return i===t.code&&(console.error("Error: Language code '"+i+"' cannot be registered for language '"+e.language+"' because it is already registered for language '"+t.language+"'!"),!0)})||(e.code=i,l.languages.push(e))}};u("link[rel=stylesheet]").each(function(t,i){var e=u(i),n=e.attr("data-class");if(void 0!==n){var s=e.attr("data-name");void 0===s&&(s=n),l.themes.push({styleClass:n,name:s})}}),0===l.themes.length&&l.themes.push({});var s;function y(t,i){var e=t,n=i||"";this.addStyle=function(t){""===n?n=t:n+=" "+t},this.toString=function(){return'<span class="item letter '+n+'">'+e+"</span>"}}function o(t){var i={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]},e={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]},n={3:[3],4:[2,3],5:[3],6:[3],7:[3],8:[3],9:[2,3,4]},s={3:[9],4:[8,9],5:[9],6:[9],7:[9],8:[9],9:[8,9,10]},o={3:[2,3,4],4:[1,5],5:[5],6:[4],7:[3],8:[2],9:[1,2,3,4,5]},h={3:[8,9,10],4:[7,11],5:[11],6:[10],7:[9],8:[8],9:[7,8,9,10,11]},a={3:[1,2,3,4,5],4:[4],5:[3],6:[4],7:[5],8:[1,5],9:[2,3,4]},r={3:[7,8,9,10,11],4:[10],5:[9],6:[10],7:[11],8:[7,11],9:[8,9,10]},c={3:[4],4:[3,4],5:[2,4],6:[1,4],7:[1,2,3,4,5],8:[4],9:[4]},d={3:[10],4:[9,10],5:[8,10],6:[7,10],7:[7,8,9,10,11],8:[10],9:[10]},u={3:[1,2,3,4,5],4:[1],5:[1,2,3,4],6:[5],7:[5],8:[1,5],9:[2,3,4]},l={3:[7,8,9,10,11],4:[7],5:[7,8,9,10],6:[11],7:[11],8:[7,11],9:[8,9,10]},f={3:[9,10],4:[8],5:[7],6:[7,8,9,10],7:[7,11],8:[7,11],9:[8,9,10]},p={3:[7,8,9,10,11],4:[11],5:[10],6:[9],7:[8],8:[8],9:[8]},g={3:[8,9,10],4:[7,11],5:[7,11],6:[8,9,10],7:[7,11],8:[7,11],9:[8,9,10]},m={3:[8,9,10],4:[7,11],5:[7,11],6:[8,9,10,11],7:[11],8:[10],9:[8,9]},v={0:[i,e],1:[i,s],2:[i,h],3:[i,r],4:[i,d],5:[i,l],6:[i,f],7:[i,p],8:[i,g],9:[i,m],10:[n,e],11:[n,s],12:[n,h],13:[n,r],14:[n,d],15:[n,l],16:[n,f],17:[n,p],18:[n,g],19:[n,m],20:[o,e],21:[o,s],22:[o,h],23:[o,r],24:[o,d],25:[o,l],26:[o,f],27:[o,p],28:[o,g],29:[o,m],30:[a,e],31:[a,s],32:[a,h],33:[a,r],34:[a,d],35:[a,l],36:[a,f],37:[a,p],38:[a,g],39:[a,m],40:[c,e],41:[c,s],42:[c,h],43:[c,r],44:[c,d],45:[c,l],46:[c,f],47:[c,p],48:[c,g],49:[c,m],50:[u,e],51:[u,s],52:[u,h],53:[u,r],54:[u,d],55:[u,l],56:[u,f],57:[u,p],58:[u,g],59:[u,m]};function b(e,n,t){null!=t&&Object.keys(t).forEach(function(i){t[i].forEach(function(t){e[i-1][t-1].addStyle(n)})})}function w(i,e,t){null!=t&&(Array.isArray(t)?t.forEach(function(t){b(i,e,t)}):b(i,e,t))}function k(n,s,o){null!=o&&Object.keys(o).forEach(function(t){var i=t.split(","),e=o[t];i.forEach(function(t){w(n,s+t,e)})})}this.parse=function(){var s=[];return t.letters.forEach(function(t){for(var i=[],e=0;e<t.length;e++){var n=new y(t[e]);i.push(n)}s.push(i)}),w(s,"on",t.permanent),void 0!==t.seconds&&null!==t.seconds?k(s,"second",t.seconds):k(s,"second",v),k(s,"minute",t.minutes),k(s,"hour",t.hours),s}}function h(n,s){this.render=function(t){if(void 0===n.parsed)switch(n.version){case 2:var i=new o(n).parse();Object.defineProperty(n,"parsed",{value:i,writable:!1,configurable:!1});break;default:return void console.warn("Unknown layout version: '"+n.version+"'")}var e=n.parsed;s.fadeOut("fast",function(){s.empty(),e.forEach(function(t,i,e){t.forEach(function(t){s.append(t.toString())}),i<e.length-1&&s.append("<br/>")}),"function"==typeof t&&t(),s.fadeIn("fast")})}}function f(t){this.options.mode=t,this.currentMinute=-1,n.bind(this)(),i.bind(this)("uhr-mode",t)}function p(t){var i=this.element;i.css("width",t);var e=i.width();i.width(e),i.height(e),i.css("font-size",e/40+"px")}var a,r;a=function(){var t=this.element;if(t.addClass("uhr"),t.empty(),t.append('<span class="item dot dot1"></span>'),t.append('<span class="item dot dot2"></span>'),t.append('<span class="item dot dot3"></span>'),t.append('<span class="item dot dot4"></span>'),t.append('<div class="letterarea"></div>'),t.append('<div class="reflection"></div>'),p.bind(this)(this.options.width),this.options.controls){var i=u('<div class="uhr-controlpanel" id="uhr-controlpanel'+this.id+'"></div>'),e=u('<div class="content"></div>');i.append(e);var n=u('<div class="onoffswitch" id="uhr-onoffswitch'+this.id+'"></div>');n.append('<input type="checkbox" class="onoffswitch-checkbox" id="uhr-onoffswitch-checkbox'+this.id+'" checked="checked" />'),n.append('<label class="onoffswitch-label" for="uhr-onoffswitch-checkbox'+this.id+'"><div class="onoffswitch-inner"></div><div class="onoffswitch-switch"></div></label>'),e.append(n);var s=u('<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>'),e.append(s),1<l.languages.length){var o=u('<select id="uhr-languagechooser'+this.id+'"></select>');l.languages.forEach(function(t){o.append('<option value="'+t.code+'">'+t.language+"</option>")}),e.append(o)}if(1<l.themes.length){var h=u('<select id="uhr-themechooser'+this.id+'"></select>');l.themes.forEach(function(t){h.append('<option value="'+t.styleClass+'">'+t.name+"</option>")}),e.append(h)}var a=u('<a class="uhr-closecontrolpanel" id="uhr-closecontrolpanel'+this.id+'"></a>');a.on("click",function(){u("#uhr-controlpanel"+this.id).hide("fast")}.bind(this)),e.append(a),t.after(i),i.hide();var r=u('<a class="uhr-configlink" id="uhr-configlink'+this.id+'"></a>');r.on("click",function(){(function(){u("#uhr-controlpanel"+this.id).toggle("fast")}).bind(this)()}.bind(this)),t.after(r)}},r=function(){var t=u("#uhr-onoffswitch-checkbox"+this.id);t.on("click",function(){this.toggle()}.bind(this));var i=u.cookie("uhr-status"+this.id);void 0!==i&&!this.options.force||(i=this.options.status),t.prop("checked","on"===i),"on"===i?this.start():this.stop();var e=u("#uhr-modeswitch-checkbox"+this.id);e.on("click",function(){"seconds"===this.options.mode?f.bind(this)("normal"):f.bind(this)("seconds")}.bind(this));var n=u.cookie("uhr-mode"+this.id);void 0!==n&&!this.options.force||(n=this.options.mode),e.prop("checked","seconds"!==n),"seconds"===n?f.bind(this)("seconds"):f.bind(this)("normal");var s=u("#uhr-languagechooser"+this.id);s.on("change",function(){var t=u("#uhr-languagechooser"+this.id).val();this.language(t)}.bind(this));var o=u.cookie("uhr-language"+this.id);void 0!==o&&!this.options.force||(o=this.options.language);var h,a=l.languages.some(function(t){return o===t.code});a||(h=0<l.languages.length?l.languages[0].code:"",console.warn("Language '"+o+"' not found! Using fallback '"+h+"'"),o=h);s.val(o),this.options.language="",this.language(o);var r=u("#uhr-themechooser"+this.id);r.on("change",function(){var t=u("#uhr-themechooser"+this.id).val();this.theme(t)}.bind(this));var c=u.cookie("uhr-theme"+this.id);if(void 0!==c&&!this.options.force||(c=this.options.theme),!(a=l.themes.some(function(t){return c===t.styleClass}))){var d=l.themes[0].styleClass;console.warn("Theme '"+c+"' not found! Using fallback '"+d+"'"),c=d}r.val(c),this.options.theme="",this.theme(c),this.options.autoresize&&u(window).on("resize",function(){var t=this.element.parent(),i=u(window),e=t.width(),n=t.height(),s=i.width(),o=i.height(),h=Math.min(e,n,s,o)+"px";p.bind(this)(h)}.bind(this))};var c,d,g,m,v,b,w;i=function(t,i){var e={};e=void 0!==this.options.cookiePath?{expires:365,path:this.options.cookiePath}:{expires:365},u.cookie(t+this.id,i,e)},e=function(){return null!==this.timer},n=function(){if(e.bind(this)()){var t=this.options.time;if(!s.bind(this)().hasOwnProperty("seconds")&&"seconds"!==this.options.mode){if(t.getMinutes()===this.currentMinute)return;this.currentMinute=t.getMinutes()}c.bind(this)(t)}else d.bind(this)(),this.currentMinute=-1},c=function(t){var i=m.bind(this)(t),e=v.bind(this)(t),n=w.bind(this)(t),s=b.bind(this)(t);if(d.bind(this)(),"seconds"===this.options.mode)g.bind(this)("second"+i);else{g.bind(this)("on");for(var o=1;o<=e;o++)g.bind(this)("dot"+o);g.bind(this)("minute"+s),g.bind(this)("hour"+n)}},g=function(t){this.element.find(".item."+t).addClass("active")},d=function(){this.element.find(".item").removeClass("active")},m=function(t){return"function"==typeof s.bind(this)().getSeconds?s.bind(this)().getSeconds(t):t.getSeconds()},v=function(t){return"function"==typeof s.bind(this)().getDotMinute?s.bind(this)().getDotMinute(t):t.getMinutes()%5},b=function(t){return"function"==typeof s.bind(this)().getCoarseMinute?s.bind(this)().getCoarseMinute(t):t.getMinutes()},w=function(t){if("function"==typeof s.bind(this)().getHour)return s.bind(this)().getHour(t);var i=t.getHours();return 25<=t.getMinutes()?(i+1)%24:i},s=function(){var t=l.languages.filter(function(t){return t.code===this.options.language},this);return 0<t.length?t[0]:{}},u.widget("fritteli.uhr",{options:{width:"100%",status:"on",language:"de_CH",theme:l.themes[0].styleClass,force:!1,controls:!0,cookiePath:void 0,autoresize:!0,mode:"normal"},start:function(){e.bind(this)()||(this.timer=window.setInterval(function(){this.options.time=new Date,n.bind(this)()}.bind(this),1e3),n.bind(this)(),i.bind(this)("uhr-status","on"))},stop:function(){e.bind(this)()&&(window.clearInterval(this.timer),this.timer=null,n.bind(this)(),i.bind(this)("uhr-status","off"))},toggle:function(){e.bind(this)()?this.stop():this.start()},language:function(t){t!==this.options.language&&(this.options.language=t,new h(s.bind(this)(),this.element.find(".letterarea")).render.bind(this)(function(){this.currentMinute=-1,n.bind(this)()}.bind(this)),i.bind(this)("uhr-language",t),n.bind(this)())},theme:function(t){t!==this.options.theme&&(this.element.removeClass(this.options.theme).addClass(t),u("#uhr-onoffswitch"+this.id).removeClass(this.options.theme).addClass(t),this.options.theme=t,i.bind(this)("uhr-theme",t))},time:function(t){this.currentMinute=-1,null===t?this.options.time=new Date:(null!==this.timer&&window.clearInterval(this.timer),this.options.time=t),n.bind(this)()},mode:f,width:p,_create:function(){this.id=l.id++,this.timer=null,this.currentMinute=-1;var t,i=this.options.time;void 0===this.options.time&&(this.options.time=new Date),void 0!==(t=window.location.hash)&&"string"==typeof t&&"#"===t.charAt(0)&&(t=t.substring(1),(t=decodeURIComponent(t)).split("&").forEach(function(t){var i=t.split("="),e=i[0],n=i[1];switch(e){case"l":case"language":this.options.language=n,this.options.force=!0;break;case"t":case"theme":this.options.theme=n,this.options.force=!0;break;case"m":case"mode":this.options.mode=n,this.options.force=!0;break;case"s":case"status":this.options.status=n,this.options.force=!0}}.bind(this))),a.bind(this)(),r.bind(this)(),void 0!==i&&this.time(i)},_destroy:function(){this.timer=null,u(this.element).removeAttr("style").removeAttr("class").empty(),u("#uhr-configlink"+this.id).remove(),u("#uhr-controlpanel"+this.id).remove()}}),u.fritteli.uhr.register=l.registerLanguage}(jQuery),function(t){"use strict";var i={4:[1,2]},e={3:[9,10,11]},n={4:[4,5,6,7,8]},s={1:[9,10,11]},o={2:[9,10,11]},h={2:[1,2,3,4,5,6]},a={3:[1,2,3,4,5,6]},r={version:2,language:"Bärndütsch",letters:["ESKISCHAFÜF","VIERTUBFZÄÄ","ZWÄNZGSIVOR","ABOHAUBIEGE","EISZWÖISDRÜ","VIERIFÜFIQT","SÄCHSISIBNI","ACHTINÜNIEL","ZÄNIERBEUFI","ZWÖUFINAUHR"],permanent:{1:[1,2,4,5,6,7]},minutes:{"5,6,7,8,9":[s,i],"10,11,12,13,14":[o,i],"15,16,17,18,19":[h,i],"20,21,22,23,24":[a,i],"25,26,27,28,29":[s,e,n],"30,31,32,33,34":n,"35,36,37,38,39":[s,i,n],"40,41,42,43,44":[a,e],"45,46,47,48,49":[h,e],"50,51,52,53,54":[o,e],"55,56,57,58,59":[s,e]},hours:{"0,12":{10:[1,2,3,4,5,6]},"1,13":{5:[1,2,3]},"2,14":{5:[4,5,6,7]},"3,15":{5:[9,10,11]},"4,16":{6:[1,2,3,4,5]},"5,17":{6:[6,7,8,9]},"6,18":{7:[1,2,3,4,5,6]},"7,19":{7:[7,8,9,10,11]},"8,20":{8:[1,2,3,4,5]},"9,21":{8:[6,7,8,9]},"10,22":{9:[1,2,3,4]},"11,23":{9:[8,9,10,11]}}};jQuery.fritteli.uhr.register("de_CH",r)}();
|