-
Notifications
You must be signed in to change notification settings - Fork 0
/
kdoc-widget.js
1 lines (1 loc) · 3.61 KB
/
kdoc-widget.js
1
!function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},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 o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(o,r,function(e){return t[e]}.bind(null,r));return o},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=2)}([function(t,e){t.exports=""},function(t,e){},function(t,e,n){"use strict";n.r(e),n(0),n(1);var o=function(t){var e=parseInt(t.substring(0,2),10),n=11<e?"PM":"AM";return(e+11)%12+1+":"+t.substring(2)+n},r=["init","widget"];function i(t,e){if(!t)throw Error("API method required");if(t=t.toLowerCase(),-1===r.indexOf(t))throw Error("Method ".concat(t," is not supported"));switch(t){case"widget":!function(t){if(void 0===window.jQuery||parseFloat(window.jQuery.fn.jquery)<3.3){var e=document.createElement("script");e.src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js",e.readyState?e.onreadystatechange=function(){"complete"!=this.readyState&&"loaded"!=this.readyState||n()}:e.onload=n,(document.getElementsByTagName("head")[0]||document.documentElement).appendChild(e)}else t(window.jQuery);function n(){t(window.jQuery.noConflict(!0))}}(function(t){t.ajax({url:"https://kdoc-api.herokuapp.com/api/lineup",dataType:"jsonp",type:"GET"}).done(function(e){var n={},r=new Date,i=r.getMonth()+1<10?"0".concat(r.getMonth()+1):r.getMonth()+1,a=r.getDate()<=9?"0".concat(r.getDate()):r.getDate(),c=r.getHours()<=9?"0".concat(r.getHours()):r.getHours(),s=r.getMinutes()<=9?"0".concat(r.getMinutes()):r.getMinutes(),d=r.getSeconds()<=9?"0".concat(r.getSeconds()):r.getSeconds(),u="".concat(r.getFullYear()).concat(i).concat(a).concat(c).concat(s).concat(d),l=Number(u.substring(0,12)),f=e.tv.programme;f.forEach(function(t,e,o){var r=Number(t.$.start.substring(0,12)),i=Number(t.$.stop.substring(0,12));r<=l&&l<i&&(n={index:e})});var p=f[n.index],g=f[n.index+1],y=f[n.index+2],h=o(p.$.start.substring(8,12)),b=o(g.$.start.substring(8,12)),w=o(y.$.start.substring(8,12)),m="".concat(h," ").concat(p.title[0]._),v="".concat(b," ").concat(g.title[0]._),x="".concat(w," ").concat(y.title[0]._);t(".kdoc-widget").append('<div class="kdoc-list" style="display:flex; flex-direction: row;">'),t(".kdoc-list").append(t('<div class="kdoc-on-air" style="box-sizing: border-box; width: 33%;"><h2 style="font-weight: 900;">ON-AIR</p></h2><p style="padding-right:2em;">'+m+"</p></div>")).append(t('<div class="kdoc-on-air" style="box-sizing: border-box; width: 33%;"><h2 style="font-weight: 900;">UP NEXT</h2><p style="padding-right:2em;">'+v+"</p></div>")).append(t('<div class="kdoc-on-air" style="box-sizing: border-box; width: 33%;"><h2 style="font-weight: 900;">SOON</h2><p style="padding-right:2em;">'+x+"</p></div>"))}).fail(function(t){})});break;default:console.warn("No handler defined for ".concat(t))}}function a(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}!function(t){var e={someDefaultConfiguration:!1},n=t[t["kdoc-widget"]],o=n.q;if(o)for(var r=0;r<o.length;r++)"init"==o[r][0].toLowerCase()?e=a(e,o[r][1]):i(o[r][0],o[r][1]);(n=i).configurations=e}(window)}]);