-
-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathapp.min.js
1 lines (1 loc) · 70 KB
/
app.min.js
1
function supportsLocalStorage(){try{return"localStorage"in window&&null!==window.localStorage}catch(e){return!1}}function save(e){if(!supportsLocalStorage())return!1;localStorage.time=e,setTimeout((function(){localStorage.shows=$(".container__list-of-shows").html()}),500)}function load(){localStorage.time&&(totalTimeWastedInMinutes=parseFloat(localStorage.time),convertMinutes(parseFloat(localStorage.time))),localStorage.shows&&$(".container__list-of-shows").html(localStorage.shows),$(".container__list-of-shows li").length>=1&&$(".result-container").is(".visuallyhidden")&&($(".result-container").removeClass("visuallyhidden"),$(".result-container").parent().removeClass("hiding"))}function reset(){localStorage.removeItem("time"),localStorage.removeItem("shows"),document.location.reload(!0)}navigator.userAgent.indexOf("Windows NT 6.1")>0&&$("body").addClass("windows"),setTimeout((function(){load()}),400),console.log("Yo!\nThis app was created by Alex Cican: http://alexcican.com\nQuestions? [email protected]"),function(e){void 0===e.fn.each2&&e.extend(e.fn,{each2:function(t){for(var s=e([0]),i=-1,n=this.length;++i<n&&(s.context=s[0]=this[i])&&!1!==t.call(s[0],i,s););return this}})}(jQuery),function(e,t){"use strict";if(window.Select2===t){var s,i,n,o,a,r,l,c={x:0,y:0},h={TAB:9,ENTER:13,ESC:27,SPACE:32,LEFT:37,UP:38,RIGHT:39,DOWN:40,SHIFT:16,CTRL:17,ALT:18,PAGE_UP:33,PAGE_DOWN:34,HOME:36,END:35,BACKSPACE:8,DELETE:46,isArrow:function(e){switch(e=e.which?e.which:e){case h.LEFT:case h.RIGHT:case h.UP:case h.DOWN:return!0}return!1},isControl:function(e){switch(e.which){case h.SHIFT:case h.CTRL:case h.ALT:return!0}return!!e.metaKey},isFunctionKey:function(e){return(e=e.which?e.which:e)>=112&&e<=123}},d={"Ⓐ":"A","A":"A","À":"A","Á":"A","Â":"A","Ầ":"A","Ấ":"A","Ẫ":"A","Ẩ":"A","Ã":"A","Ā":"A","Ă":"A","Ằ":"A","Ắ":"A","Ẵ":"A","Ẳ":"A","Ȧ":"A","Ǡ":"A","Ä":"A","Ǟ":"A","Ả":"A","Å":"A","Ǻ":"A","Ǎ":"A","Ȁ":"A","Ȃ":"A","Ạ":"A","Ậ":"A","Ặ":"A","Ḁ":"A","Ą":"A","Ⱥ":"A","Ɐ":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ǣ":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ⓑ":"B","B":"B","Ḃ":"B","Ḅ":"B","Ḇ":"B","Ƀ":"B","Ƃ":"B","Ɓ":"B","Ⓒ":"C","C":"C","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","Ç":"C","Ḉ":"C","Ƈ":"C","Ȼ":"C","Ꜿ":"C","Ⓓ":"D","D":"D","Ḋ":"D","Ď":"D","Ḍ":"D","Ḑ":"D","Ḓ":"D","Ḏ":"D","Đ":"D","Ƌ":"D","Ɗ":"D","Ɖ":"D","Ꝺ":"D","DZ":"DZ","DŽ":"DZ","Dz":"Dz","Dž":"Dz","Ⓔ":"E","E":"E","È":"E","É":"E","Ê":"E","Ề":"E","Ế":"E","Ễ":"E","Ể":"E","Ẽ":"E","Ē":"E","Ḕ":"E","Ḗ":"E","Ĕ":"E","Ė":"E","Ë":"E","Ẻ":"E","Ě":"E","Ȅ":"E","Ȇ":"E","Ẹ":"E","Ệ":"E","Ȩ":"E","Ḝ":"E","Ę":"E","Ḙ":"E","Ḛ":"E","Ɛ":"E","Ǝ":"E","Ⓕ":"F","F":"F","Ḟ":"F","Ƒ":"F","Ꝼ":"F","Ⓖ":"G","G":"G","Ǵ":"G","Ĝ":"G","Ḡ":"G","Ğ":"G","Ġ":"G","Ǧ":"G","Ģ":"G","Ǥ":"G","Ɠ":"G","Ꞡ":"G","Ᵹ":"G","Ꝿ":"G","Ⓗ":"H","H":"H","Ĥ":"H","Ḣ":"H","Ḧ":"H","Ȟ":"H","Ḥ":"H","Ḩ":"H","Ḫ":"H","Ħ":"H","Ⱨ":"H","Ⱶ":"H","Ɥ":"H","Ⓘ":"I","I":"I","Ì":"I","Í":"I","Î":"I","Ĩ":"I","Ī":"I","Ĭ":"I","İ":"I","Ï":"I","Ḯ":"I","Ỉ":"I","Ǐ":"I","Ȉ":"I","Ȋ":"I","Ị":"I","Į":"I","Ḭ":"I","Ɨ":"I","Ⓙ":"J","J":"J","Ĵ":"J","Ɉ":"J","Ⓚ":"K","K":"K","Ḱ":"K","Ǩ":"K","Ḳ":"K","Ķ":"K","Ḵ":"K","Ƙ":"K","Ⱪ":"K","Ꝁ":"K","Ꝃ":"K","Ꝅ":"K","Ꞣ":"K","Ⓛ":"L","L":"L","Ŀ":"L","Ĺ":"L","Ľ":"L","Ḷ":"L","Ḹ":"L","Ļ":"L","Ḽ":"L","Ḻ":"L","Ł":"L","Ƚ":"L","Ɫ":"L","Ⱡ":"L","Ꝉ":"L","Ꝇ":"L","Ꞁ":"L","LJ":"LJ","Lj":"Lj","Ⓜ":"M","M":"M","Ḿ":"M","Ṁ":"M","Ṃ":"M","Ɱ":"M","Ɯ":"M","Ⓝ":"N","N":"N","Ǹ":"N","Ń":"N","Ñ":"N","Ṅ":"N","Ň":"N","Ṇ":"N","Ņ":"N","Ṋ":"N","Ṉ":"N","Ƞ":"N","Ɲ":"N","Ꞑ":"N","Ꞥ":"N","NJ":"NJ","Nj":"Nj","Ⓞ":"O","O":"O","Ò":"O","Ó":"O","Ô":"O","Ồ":"O","Ố":"O","Ỗ":"O","Ổ":"O","Õ":"O","Ṍ":"O","Ȭ":"O","Ṏ":"O","Ō":"O","Ṑ":"O","Ṓ":"O","Ŏ":"O","Ȯ":"O","Ȱ":"O","Ö":"O","Ȫ":"O","Ỏ":"O","Ő":"O","Ǒ":"O","Ȍ":"O","Ȏ":"O","Ơ":"O","Ờ":"O","Ớ":"O","Ỡ":"O","Ở":"O","Ợ":"O","Ọ":"O","Ộ":"O","Ǫ":"O","Ǭ":"O","Ø":"O","Ǿ":"O","Ɔ":"O","Ɵ":"O","Ꝋ":"O","Ꝍ":"O","Ƣ":"OI","Ꝏ":"OO","Ȣ":"OU","Ⓟ":"P","P":"P","Ṕ":"P","Ṗ":"P","Ƥ":"P","Ᵽ":"P","Ꝑ":"P","Ꝓ":"P","Ꝕ":"P","Ⓠ":"Q","Q":"Q","Ꝗ":"Q","Ꝙ":"Q","Ɋ":"Q","Ⓡ":"R","R":"R","Ŕ":"R","Ṙ":"R","Ř":"R","Ȑ":"R","Ȓ":"R","Ṛ":"R","Ṝ":"R","Ŗ":"R","Ṟ":"R","Ɍ":"R","Ɽ":"R","Ꝛ":"R","Ꞧ":"R","Ꞃ":"R","Ⓢ":"S","S":"S","ẞ":"S","Ś":"S","Ṥ":"S","Ŝ":"S","Ṡ":"S","Š":"S","Ṧ":"S","Ṣ":"S","Ṩ":"S","Ș":"S","Ş":"S","Ȿ":"S","Ꞩ":"S","Ꞅ":"S","Ⓣ":"T","T":"T","Ṫ":"T","Ť":"T","Ṭ":"T","Ț":"T","Ţ":"T","Ṱ":"T","Ṯ":"T","Ŧ":"T","Ƭ":"T","Ʈ":"T","Ⱦ":"T","Ꞇ":"T","Ꜩ":"TZ","Ⓤ":"U","U":"U","Ù":"U","Ú":"U","Û":"U","Ũ":"U","Ṹ":"U","Ū":"U","Ṻ":"U","Ŭ":"U","Ü":"U","Ǜ":"U","Ǘ":"U","Ǖ":"U","Ǚ":"U","Ủ":"U","Ů":"U","Ű":"U","Ǔ":"U","Ȕ":"U","Ȗ":"U","Ư":"U","Ừ":"U","Ứ":"U","Ữ":"U","Ử":"U","Ự":"U","Ụ":"U","Ṳ":"U","Ų":"U","Ṷ":"U","Ṵ":"U","Ʉ":"U","Ⓥ":"V","V":"V","Ṽ":"V","Ṿ":"V","Ʋ":"V","Ꝟ":"V","Ʌ":"V","Ꝡ":"VY","Ⓦ":"W","W":"W","Ẁ":"W","Ẃ":"W","Ŵ":"W","Ẇ":"W","Ẅ":"W","Ẉ":"W","Ⱳ":"W","Ⓧ":"X","X":"X","Ẋ":"X","Ẍ":"X","Ⓨ":"Y","Y":"Y","Ỳ":"Y","Ý":"Y","Ŷ":"Y","Ỹ":"Y","Ȳ":"Y","Ẏ":"Y","Ÿ":"Y","Ỷ":"Y","Ỵ":"Y","Ƴ":"Y","Ɏ":"Y","Ỿ":"Y","Ⓩ":"Z","Z":"Z","Ź":"Z","Ẑ":"Z","Ż":"Z","Ž":"Z","Ẓ":"Z","Ẕ":"Z","Ƶ":"Z","Ȥ":"Z","Ɀ":"Z","Ⱬ":"Z","Ꝣ":"Z","ⓐ":"a","a":"a","ẚ":"a","à":"a","á":"a","â":"a","ầ":"a","ấ":"a","ẫ":"a","ẩ":"a","ã":"a","ā":"a","ă":"a","ằ":"a","ắ":"a","ẵ":"a","ẳ":"a","ȧ":"a","ǡ":"a","ä":"a","ǟ":"a","ả":"a","å":"a","ǻ":"a","ǎ":"a","ȁ":"a","ȃ":"a","ạ":"a","ậ":"a","ặ":"a","ḁ":"a","ą":"a","ⱥ":"a","ɐ":"a","ꜳ":"aa","æ":"ae","ǽ":"ae","ǣ":"ae","ꜵ":"ao","ꜷ":"au","ꜹ":"av","ꜻ":"av","ꜽ":"ay","ⓑ":"b","b":"b","ḃ":"b","ḅ":"b","ḇ":"b","ƀ":"b","ƃ":"b","ɓ":"b","ⓒ":"c","c":"c","ć":"c","ĉ":"c","ċ":"c","č":"c","ç":"c","ḉ":"c","ƈ":"c","ȼ":"c","ꜿ":"c","ↄ":"c","ⓓ":"d","d":"d","ḋ":"d","ď":"d","ḍ":"d","ḑ":"d","ḓ":"d","ḏ":"d","đ":"d","ƌ":"d","ɖ":"d","ɗ":"d","ꝺ":"d","dz":"dz","dž":"dz","ⓔ":"e","e":"e","è":"e","é":"e","ê":"e","ề":"e","ế":"e","ễ":"e","ể":"e","ẽ":"e","ē":"e","ḕ":"e","ḗ":"e","ĕ":"e","ė":"e","ë":"e","ẻ":"e","ě":"e","ȅ":"e","ȇ":"e","ẹ":"e","ệ":"e","ȩ":"e","ḝ":"e","ę":"e","ḙ":"e","ḛ":"e","ɇ":"e","ɛ":"e","ǝ":"e","ⓕ":"f","f":"f","ḟ":"f","ƒ":"f","ꝼ":"f","ⓖ":"g","g":"g","ǵ":"g","ĝ":"g","ḡ":"g","ğ":"g","ġ":"g","ǧ":"g","ģ":"g","ǥ":"g","ɠ":"g","ꞡ":"g","ᵹ":"g","ꝿ":"g","ⓗ":"h","h":"h","ĥ":"h","ḣ":"h","ḧ":"h","ȟ":"h","ḥ":"h","ḩ":"h","ḫ":"h","ẖ":"h","ħ":"h","ⱨ":"h","ⱶ":"h","ɥ":"h","ƕ":"hv","ⓘ":"i","i":"i","ì":"i","í":"i","î":"i","ĩ":"i","ī":"i","ĭ":"i","ï":"i","ḯ":"i","ỉ":"i","ǐ":"i","ȉ":"i","ȋ":"i","ị":"i","į":"i","ḭ":"i","ɨ":"i","ı":"i","ⓙ":"j","j":"j","ĵ":"j","ǰ":"j","ɉ":"j","ⓚ":"k","k":"k","ḱ":"k","ǩ":"k","ḳ":"k","ķ":"k","ḵ":"k","ƙ":"k","ⱪ":"k","ꝁ":"k","ꝃ":"k","ꝅ":"k","ꞣ":"k","ⓛ":"l","l":"l","ŀ":"l","ĺ":"l","ľ":"l","ḷ":"l","ḹ":"l","ļ":"l","ḽ":"l","ḻ":"l","ſ":"l","ł":"l","ƚ":"l","ɫ":"l","ⱡ":"l","ꝉ":"l","ꞁ":"l","ꝇ":"l","lj":"lj","ⓜ":"m","m":"m","ḿ":"m","ṁ":"m","ṃ":"m","ɱ":"m","ɯ":"m","ⓝ":"n","n":"n","ǹ":"n","ń":"n","ñ":"n","ṅ":"n","ň":"n","ṇ":"n","ņ":"n","ṋ":"n","ṉ":"n","ƞ":"n","ɲ":"n","ʼn":"n","ꞑ":"n","ꞥ":"n","nj":"nj","ⓞ":"o","o":"o","ò":"o","ó":"o","ô":"o","ồ":"o","ố":"o","ỗ":"o","ổ":"o","õ":"o","ṍ":"o","ȭ":"o","ṏ":"o","ō":"o","ṑ":"o","ṓ":"o","ŏ":"o","ȯ":"o","ȱ":"o","ö":"o","ȫ":"o","ỏ":"o","ő":"o","ǒ":"o","ȍ":"o","ȏ":"o","ơ":"o","ờ":"o","ớ":"o","ỡ":"o","ở":"o","ợ":"o","ọ":"o","ộ":"o","ǫ":"o","ǭ":"o","ø":"o","ǿ":"o","ɔ":"o","ꝋ":"o","ꝍ":"o","ɵ":"o","ƣ":"oi","ȣ":"ou","ꝏ":"oo","ⓟ":"p","p":"p","ṕ":"p","ṗ":"p","ƥ":"p","ᵽ":"p","ꝑ":"p","ꝓ":"p","ꝕ":"p","ⓠ":"q","q":"q","ɋ":"q","ꝗ":"q","ꝙ":"q","ⓡ":"r","r":"r","ŕ":"r","ṙ":"r","ř":"r","ȑ":"r","ȓ":"r","ṛ":"r","ṝ":"r","ŗ":"r","ṟ":"r","ɍ":"r","ɽ":"r","ꝛ":"r","ꞧ":"r","ꞃ":"r","ⓢ":"s","s":"s","ß":"s","ś":"s","ṥ":"s","ŝ":"s","ṡ":"s","š":"s","ṧ":"s","ṣ":"s","ṩ":"s","ș":"s","ş":"s","ȿ":"s","ꞩ":"s","ꞅ":"s","ẛ":"s","ⓣ":"t","t":"t","ṫ":"t","ẗ":"t","ť":"t","ṭ":"t","ț":"t","ţ":"t","ṱ":"t","ṯ":"t","ŧ":"t","ƭ":"t","ʈ":"t","ⱦ":"t","ꞇ":"t","ꜩ":"tz","ⓤ":"u","u":"u","ù":"u","ú":"u","û":"u","ũ":"u","ṹ":"u","ū":"u","ṻ":"u","ŭ":"u","ü":"u","ǜ":"u","ǘ":"u","ǖ":"u","ǚ":"u","ủ":"u","ů":"u","ű":"u","ǔ":"u","ȕ":"u","ȗ":"u","ư":"u","ừ":"u","ứ":"u","ữ":"u","ử":"u","ự":"u","ụ":"u","ṳ":"u","ų":"u","ṷ":"u","ṵ":"u","ʉ":"u","ⓥ":"v","v":"v","ṽ":"v","ṿ":"v","ʋ":"v","ꝟ":"v","ʌ":"v","ꝡ":"vy","ⓦ":"w","w":"w","ẁ":"w","ẃ":"w","ŵ":"w","ẇ":"w","ẅ":"w","ẘ":"w","ẉ":"w","ⱳ":"w","ⓧ":"x","x":"x","ẋ":"x","ẍ":"x","ⓨ":"y","y":"y","ỳ":"y","ý":"y","ŷ":"y","ỹ":"y","ȳ":"y","ẏ":"y","ÿ":"y","ỷ":"y","ẙ":"y","ỵ":"y","ƴ":"y","ɏ":"y","ỿ":"y","ⓩ":"z","z":"z","ź":"z","ẑ":"z","ż":"z","ž":"z","ẓ":"z","ẕ":"z","ƶ":"z","ȥ":"z","ɀ":"z","ⱬ":"z","ꝣ":"z"};a=e(document),l=1,o=function(){return l++},a.on("mousemove",(function(e){c.x=e.pageX,c.y=e.pageY})),s=O(Object,{bind:function(e){var t=this;return function(){e.apply(t,arguments)}},init:function(s){var i,n,a,l,h,d=".select2-results";this.opts=s=this.prepareOpts(s),this.id=s.id,s.element.data("select2")!==t&&null!==s.element.data("select2")&&s.element.data("select2").destroy(),this.container=this.createContainer(),this.containerId="s2id_"+(s.element.attr("id")||"autogen"+o()),this.containerSelector="#"+this.containerId.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g,"\\$1"),this.container.attr("id",this.containerId),this.body=(a=function(){return s.element.closest("body")},h=!1,function(){return!1===h&&(l=a(),h=!0),l}),b(this.container,this.opts.element,this.opts.adaptContainerCssClass),this.container.attr("style",s.element.attr("style")),this.container.css(E(s.containerCss)),this.container.addClass(E(s.containerCssClass)),this.elementTabIndex=this.opts.element.attr("tabindex"),this.opts.element.data("select2",this).attr("tabindex","-1").before(this.container).on("click.select2",w),this.container.data("select2",this),this.dropdown=this.container.find(".select2-drop"),b(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass),this.dropdown.addClass(E(s.dropdownCssClass)),this.dropdown.data("select2",this),this.dropdown.on("click",w),this.results=i=this.container.find(d),this.search=n=this.container.find("input.select2-input"),this.queryCount=0,this.resultsPage=0,this.context=null,this.initContainer(),this.container.on("click",w),this.results.on("mousemove",(function(s){var i=c;i!==t&&i.x===s.pageX&&i.y===s.pageY||e(s.target).trigger("mousemove-filtered",s)})),this.dropdown.on("mousemove-filtered touchstart touchmove touchend",d,this.bind(this.highlightUnderEvent)),function(e,t){var s=v(e,(function(e){t.trigger("scroll-debounced",e)}));t.on("scroll",(function(e){p(e.target,t.get())>=0&&s(e)}))}(80,this.results),this.dropdown.on("scroll-debounced",d,this.bind(this.loadMoreIfNeeded)),e(this.container).on("change",".select2-input",(function(e){e.stopPropagation()})),e(this.dropdown).on("change",".select2-input",(function(e){e.stopPropagation()})),e.fn.mousewheel&&i.mousewheel((function(e,t,s,n){var o=i.scrollTop();n>0&&o-n<=0?(i.scrollTop(0),w(e)):n<0&&i.get(0).scrollHeight-i.scrollTop()+n<=i.height()&&(i.scrollTop(i.get(0).scrollHeight-i.height()),w(e))})),g(n),n.on("keyup-change input paste",this.bind(this.updateResults)),n.on("focus",(function(){n.addClass("select2-focused")})),n.on("blur",(function(){n.removeClass("select2-focused")})),this.dropdown.on("mouseup",d,this.bind((function(t){e(t.target).closest(".select2-result-selectable").length>0&&(this.highlightUnderEvent(t),this.selectHighlighted(t))}))),this.dropdown.on("click mouseup mousedown",(function(e){e.stopPropagation()})),e.isFunction(this.opts.initSelection)&&(this.initSelection(),this.monitorSource()),null!==s.maximumInputLength&&this.search.attr("maxlength",s.maximumInputLength);var u=s.element.prop("disabled");u===t&&(u=!1),this.enable(!u);var f=s.element.prop("readonly");f===t&&(f=!1),this.readonly(f),r=r||function(){var t=e("<div class='select2-measure-scrollbar'></div>");t.appendTo("body");var s={width:t.width()-t[0].clientWidth,height:t.height()-t[0].clientHeight};return t.remove(),s}(),this.autofocus=s.element.prop("autofocus"),s.element.prop("autofocus",!1),this.autofocus&&this.focus(),this.nextSearchTerm=t},destroy:function(){var e=this.opts.element,s=e.data("select2");this.close(),this.propertyObserver&&(delete this.propertyObserver,this.propertyObserver=null),s!==t&&(s.container.remove(),s.dropdown.remove(),e.removeClass("select2-offscreen").removeData("select2").off(".select2").prop("autofocus",this.autofocus||!1),this.elementTabIndex?e.attr({tabindex:this.elementTabIndex}):e.removeAttr("tabindex"),e.show())},optionToData:function(e){return e.is("option")?{id:e.prop("value"),text:e.text(),element:e.get(),css:e.attr("class"),disabled:e.prop("disabled"),locked:f(e.attr("locked"),"locked")||f(e.data("locked"),!0)}:e.is("optgroup")?{text:e.attr("label"),children:[],element:e.get(),css:e.attr("class")}:void 0},prepareOpts:function(s){var i,n,a,r,l=this;if("select"===(i=s.element).get(0).tagName.toLowerCase()&&(this.select=n=s.element),n&&e.each(["id","multiple","ajax","query","createSearchChoice","initSelection","data","tags"],(function(){if(this in s)throw new Error("Option '"+this+"' is not allowed for Select2 when attached to a <select> element.")})),"function"!=typeof(s=e.extend({},{populateResults:function(i,n,a){var r,c=this.opts.id;r=function(i,n,h){var d,u,p,f,m,g,v,w,b,C;for(d=0,u=(i=s.sortResults(i,n,a)).length;d<u;d+=1)f=!(m=!0===(p=i[d]).disabled)&&c(p)!==t,g=p.children&&p.children.length>0,(v=e("<li></li>")).addClass("select2-results-dept-"+h),v.addClass("select2-result"),v.addClass(f?"select2-result-selectable":"select2-result-unselectable"),m&&v.addClass("select2-disabled"),g&&v.addClass("select2-result-with-children"),v.addClass(l.opts.formatResultCssClass(p)),v.attr("role","presentation"),(w=e(document.createElement("div"))).addClass("select2-result-label"),w.attr("id","select2-result-label-"+o()),w.attr("role","option"),(C=s.formatResult(p,w,a,l.opts.escapeMarkup))!==t&&w.html(C),v.append(w),g&&((b=e("<ul></ul>")).addClass("select2-result-sub"),r(p.children,b,h+1),v.append(b)),v.data("select2-data",p),n.append(v)},r(n,i,0)}},e.fn.select2.defaults,s)).id&&(a=s.id,s.id=function(e){return e[a]}),e.isArray(s.element.data("select2Tags"))){if("tags"in s)throw"tags specified as both an attribute 'data-select2-tags' and in options of Select2 "+s.element.attr("id");s.tags=s.element.data("select2Tags")}if(n?(s.query=this.bind((function(e){var s,n,o,a={results:[],more:!1},r=e.term;o=function(t,s){var i;t.is("option")?e.matcher(r,t.text(),t)&&s.push(l.optionToData(t)):t.is("optgroup")&&(i=l.optionToData(t),t.children().each2((function(e,t){o(t,i.children)})),i.children.length>0&&s.push(i))},s=i.children(),this.getPlaceholder()!==t&&s.length>0&&(n=this.getPlaceholderOption())&&(s=s.not(n)),s.each2((function(e,t){o(t,a.results)})),e.callback(a)})),s.id=function(e){return e.id}):"query"in s||("ajax"in s?((r=s.element.data("ajax-url"))&&r.length>0&&(s.ajax.url=r),s.query=S.call(s.element,s.ajax)):"data"in s?s.query=T(s.data):"tags"in s&&(s.query=x(s.tags),s.createSearchChoice===t&&(s.createSearchChoice=function(t){return{id:e.trim(t),text:e.trim(t)}}),s.initSelection===t&&(s.initSelection=function(t,i){var n=[];e(m(t.val(),s.separator)).each((function(){var t={id:this,text:this},i=s.tags;e.isFunction(i)&&(i=i()),e(i).each((function(){if(f(this.id,t.id))return t=this,!1})),n.push(t)})),i(n)}))),"function"!=typeof s.query)throw"query function not defined for Select2 "+s.element.attr("id");return s},monitorSource:function(){var e,s,i=this.opts.element;i.on("change.select2",this.bind((function(e){!0!==this.opts.element.data("select2-change-triggered")&&this.initSelection()}))),e=this.bind((function(){var e=i.prop("disabled");e===t&&(e=!1),this.enable(!e);var s=i.prop("readonly");s===t&&(s=!1),this.readonly(s),b(this.container,this.opts.element,this.opts.adaptContainerCssClass),this.container.addClass(E(this.opts.containerCssClass)),b(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass),this.dropdown.addClass(E(this.opts.dropdownCssClass))})),i.on("propertychange.select2",e),this.mutationCallback===t&&(this.mutationCallback=function(t){t.forEach(e)}),(s=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver)!==t&&(this.propertyObserver&&(delete this.propertyObserver,this.propertyObserver=null),this.propertyObserver=new s(this.mutationCallback),this.propertyObserver.observe(i.get(0),{attributes:!0,subtree:!1}))},triggerSelect:function(t){var s=e.Event("select2-selecting",{val:this.id(t),object:t});return this.opts.element.trigger(s),!s.isDefaultPrevented()},triggerChange:function(t){t=t||{},t=e.extend({},t,{type:"change",val:this.val()}),this.opts.element.data("select2-change-triggered",!0),this.opts.element.trigger(t),this.opts.element.data("select2-change-triggered",!1),this.opts.element.click(),this.opts.blurOnChange&&this.opts.element.blur()},isInterfaceEnabled:function(){return!0===this.enabledInterface},enableInterface:function(){var e=this._enabled&&!this._readonly,t=!e;return e!==this.enabledInterface&&(this.container.toggleClass("select2-container-disabled",t),this.close(),this.enabledInterface=e,!0)},enable:function(e){e===t&&(e=!0),this._enabled!==e&&(this._enabled=e,this.opts.element.prop("disabled",!e),this.enableInterface())},disable:function(){this.enable(!1)},readonly:function(e){return e===t&&(e=!1),this._readonly!==e&&(this._readonly=e,this.opts.element.prop("readonly",e),this.enableInterface(),!0)},opened:function(){return this.container.hasClass("select2-dropdown-open")},positionDropdown:function(){var t,s,i,n,o,a=this.dropdown,l=this.container.offset(),c=this.container.outerHeight(!1),h=this.container.outerWidth(!1),d=a.outerHeight(!1),u=e(window),p=u.width(),f=u.height(),m=u.scrollLeft()+p,g=u.scrollTop()+f,v=l.top+c,w=l.left,b=v+d<=g,C=l.top-d>=this.body().scrollTop(),y=a.outerWidth(!1),S=w+y<=m;a.hasClass("select2-drop-above")?(s=!0,!C&&b&&(i=!0,s=!1)):(s=!1,!b&&C&&(i=!0,s=!0)),i&&(a.hide(),l=this.container.offset(),c=this.container.outerHeight(!1),h=this.container.outerWidth(!1),d=a.outerHeight(!1),m=u.scrollLeft()+p,g=u.scrollTop()+f,v=l.top+c,S=(w=l.left)+(y=a.outerWidth(!1))<=m,a.show()),this.opts.dropdownAutoWidth?(o=e(".select2-results",a)[0],a.addClass("select2-drop-auto-width"),a.css("width",""),(y=a.outerWidth(!1)+(o.scrollHeight===o.clientHeight?0:r.width))>h?h=y:y=h,S=w+y<=m):this.container.removeClass("select2-drop-auto-width"),"static"!==this.body().css("position")&&(v-=(t=this.body().offset()).top,w-=t.left),S||(w-=w+y-m),n={left:w,width:h},s?(n.top=l.top-d,n.bottom="auto",this.container.addClass("select2-drop-above"),a.addClass("select2-drop-above")):(n.top=v,n.bottom="auto",this.container.removeClass("select2-drop-above"),a.removeClass("select2-drop-above")),n=e.extend(n,E(this.opts.dropdownCss)),a.css(n)},shouldOpen:function(){var t;return!this.opened()&&(!1!==this._enabled&&!0!==this._readonly&&(t=e.Event("select2-opening"),this.opts.element.trigger(t),!t.isDefaultPrevented()))},clearDropdownAlignmentPreference:function(){this.container.removeClass("select2-drop-above"),this.dropdown.removeClass("select2-drop-above")},open:function(){return!!this.shouldOpen()&&(this.opening(),!0)},opening:function(){var t,s=this.containerId,i="scroll."+s,n="resize."+s,o="orientationchange."+s;this.container.addClass("select2-dropdown-open").addClass("select2-container-active"),this.clearDropdownAlignmentPreference(),this.dropdown[0]!==this.body().children().last()[0]&&this.dropdown.detach().appendTo(this.body()),0==(t=e("#select2-drop-mask")).length&&((t=e(document.createElement("div"))).attr("id","select2-drop-mask").attr("class","select2-drop-mask"),t.hide(),t.appendTo(this.body()),t.on("mousedown touchstart click",(function(t){var s,i=e("#select2-drop");i.length>0&&((s=i.data("select2")).opts.selectOnBlur&&s.selectHighlighted({noFocus:!0}),s.close({focus:!0}),t.preventDefault(),t.stopPropagation())}))),this.dropdown.prev()[0]!==t[0]&&this.dropdown.before(t),e("#select2-drop").removeAttr("id"),this.dropdown.attr("id","select2-drop"),t.show(),this.positionDropdown(),this.dropdown.show(),this.positionDropdown(),this.dropdown.addClass("select2-drop-active");var a=this;this.container.parents().add(window).each((function(){e(this).on(n+" "+i+" "+o,(function(e){a.positionDropdown()}))}))},close:function(){if(this.opened()){var t=this.containerId,s="scroll."+t,i="resize."+t,n="orientationchange."+t;this.container.parents().add(window).each((function(){e(this).off(s).off(i).off(n)})),this.clearDropdownAlignmentPreference(),e("#select2-drop-mask").hide(),this.dropdown.removeAttr("id"),this.dropdown.hide(),this.container.removeClass("select2-dropdown-open").removeClass("select2-container-active"),this.results.empty(),this.clearSearch(),this.search.removeClass("select2-active"),this.opts.element.trigger(e.Event("select2-close"))}},externalSearch:function(e){this.open(),this.search.val(e),this.updateResults(!1)},clearSearch:function(){},getMaximumSelectionSize:function(){return E(this.opts.maximumSelectionSize)},ensureHighlightVisible:function(){var t,s,i,n,o,a,r,l=this.results;(s=this.highlight())<0||(0!=s?(t=this.findHighlightableChoices().find(".select2-result-label"),n=(i=e(t[s])).offset().top+i.outerHeight(!0),s===t.length-1&&(r=l.find("li.select2-more-results")).length>0&&(n=r.offset().top+r.outerHeight(!0)),n>(o=l.offset().top+l.outerHeight(!0))&&l.scrollTop(l.scrollTop()+(n-o)),(a=i.offset().top-l.offset().top)<0&&"none"!=i.css("display")&&l.scrollTop(l.scrollTop()+a)):l.scrollTop(0))},findHighlightableChoices:function(){return this.results.find(".select2-result-selectable:not(.select2-disabled, .select2-selected)")},moveHighlight:function(t){for(var s=this.findHighlightableChoices(),i=this.highlight();i>-1&&i<s.length;){var n=e(s[i+=t]);if(n.hasClass("select2-result-selectable")&&!n.hasClass("select2-disabled")&&!n.hasClass("select2-selected")){this.highlight(i);break}}},highlight:function(t){var s,i,n=this.findHighlightableChoices();if(0===arguments.length)return p(n.filter(".select2-highlighted")[0],n.get());t>=n.length&&(t=n.length-1),t<0&&(t=0),this.removeHighlight(),(s=e(n[t])).addClass("select2-highlighted"),this.search.attr("aria-activedescendant",s.find(".select2-result-label").attr("id")),this.ensureHighlightVisible(),(i=s.data("select2-data"))&&this.opts.element.trigger({type:"select2-highlight",val:this.id(i),choice:i})},removeHighlight:function(){this.results.find(".select2-highlighted").removeClass("select2-highlighted")},countSelectableResults:function(){return this.findHighlightableChoices().length},highlightUnderEvent:function(t){var s=e(t.target).closest(".select2-result-selectable");if(s.length>0&&!s.is(".select2-highlighted")){var i=this.findHighlightableChoices();this.highlight(i.index(s))}else 0==s.length&&this.removeHighlight()},loadMoreIfNeeded:function(){var e=this.results,t=e.find("li.select2-more-results"),s=this.resultsPage+1,i=this,n=this.search.val(),o=this.context;0!==t.length&&t.offset().top-e.offset().top-e.height()<=this.opts.loadMorePadding&&(t.addClass("select2-active"),this.opts.query({element:this.opts.element,term:n,page:s,context:o,matcher:this.opts.matcher,callback:this.bind((function(a){i.opened()&&(i.opts.populateResults.call(this,e,a.results,{term:n,page:s,context:o}),i.postprocessResults(a,!1,!1),!0===a.more?(t.detach().appendTo(e).text(i.opts.formatLoadMore(s+1)),window.setTimeout((function(){i.loadMoreIfNeeded()}),10)):t.remove(),i.positionDropdown(),i.resultsPage=s,i.context=a.context,this.opts.element.trigger({type:"select2-loaded",items:a}))}))}))},tokenize:function(){},updateResults:function(s){var i,n,o,a=this.search,r=this.results,l=this.opts,c=this,h=a.val(),d=e.data(this.container,"select2-last-term");if((!0===s||!d||!f(h,d))&&(e.data(this.container,"select2-last-term",h),!0===s||!1!==this.showSearchInput&&this.opened())){o=++this.queryCount;var u=this.getMaximumSelectionSize();if(u>=1&&(i=this.data(),e.isArray(i)&&i.length>=u&&_(l.formatSelectionTooBig,"formatSelectionTooBig")))m("<li class='select2-selection-limit'>"+l.formatSelectionTooBig(u)+"</li>");else{if(a.val().length<l.minimumInputLength)return _(l.formatInputTooShort,"formatInputTooShort")?m("<li class='select2-no-results'>"+l.formatInputTooShort(a.val(),l.minimumInputLength)+"</li>"):m(""),void(s&&this.showSearch&&this.showSearch(!0));l.formatSearching&&0===this.findHighlightableChoices().length&&m("<li class='select2-searching'>"+l.formatSearching()+"</li>"),a.addClass("select2-active"),this.removeHighlight(),(n=this.tokenize())!=t&&null!=n&&a.val(n),this.resultsPage=1,l.query({element:l.element,term:a.val(),page:this.resultsPage,context:null,matcher:l.matcher,callback:this.bind((function(i){var n;o==this.queryCount&&(this.opened()?(this.context=i.context===t?null:i.context,this.opts.createSearchChoice&&""!==a.val()&&(n=this.opts.createSearchChoice.call(c,a.val(),i.results))!==t&&null!==n&&c.id(n)!==t&&null!==c.id(n)&&0===e(i.results).filter((function(){return f(c.id(this),c.id(n))})).length&&i.results.unshift(n),0===i.results.length&&_(l.formatNoMatches,"formatNoMatches")?m("<li class='select2-no-results'>"+l.formatNoMatches(a.val())+"</li>"):(r.empty(),c.opts.populateResults.call(this,r,i.results,{term:a.val(),page:this.resultsPage,context:null}),!0===i.more&&_(l.formatLoadMore,"formatLoadMore")&&(r.append("<li class='select2-more-results'>"+c.opts.escapeMarkup(l.formatLoadMore(this.resultsPage))+"</li>"),window.setTimeout((function(){c.loadMoreIfNeeded()}),10)),this.postprocessResults(i,s),p(),this.opts.element.trigger({type:"select2-loaded",items:i}))):this.search.removeClass("select2-active"))}))})}}function p(){a.removeClass("select2-active"),c.positionDropdown()}function m(e){r.html(e),p()}},cancel:function(){this.close()},blur:function(){this.opts.selectOnBlur&&this.selectHighlighted({noFocus:!0}),this.close(),this.container.removeClass("select2-container-active"),this.search[0]===document.activeElement&&this.search.blur(),this.clearSearch(),this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus")},focusSearch:function(){var e;(e=this.search)[0]!==document.activeElement&&window.setTimeout((function(){var t,s=e[0],i=e.val().length;e.focus(),e.is(":visible")&&s===document.activeElement&&(s.setSelectionRange?s.setSelectionRange(i,i):s.createTextRange&&((t=s.createTextRange()).collapse(!1),t.select()))}),0)},selectHighlighted:function(e){var t=this.highlight(),s=this.results.find(".select2-highlighted").closest(".select2-result").data("select2-data");s?(this.highlight(t),this.onSelect(s,e)):e&&e.noFocus&&this.close()},getPlaceholder:function(){var e;return this.opts.element.attr("placeholder")||this.opts.element.attr("data-placeholder")||this.opts.element.data("placeholder")||this.opts.placeholder||((e=this.getPlaceholderOption())!==t?e.text():t)},getPlaceholderOption:function(){if(this.select){var e=this.select.children("option").first();if(this.opts.placeholderOption!==t)return"first"===this.opts.placeholderOption&&e||"function"==typeof this.opts.placeholderOption&&this.opts.placeholderOption(this.select);if(""===e.text()&&""===e.val())return e}},initContainerWidth:function(){var s=function(){var s,i,n,o,a;if("off"===this.opts.width)return null;if("element"===this.opts.width)return 0===this.opts.element.outerWidth(!1)?"auto":this.opts.element.outerWidth(!1)+"px";if("copy"===this.opts.width||"resolve"===this.opts.width){if((s=this.opts.element.attr("style"))!==t)for(o=0,a=(i=s.split(";")).length;o<a;o+=1)if(null!==(n=i[o].replace(/\s/g,"").match(/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i))&&n.length>=1)return n[1];return"resolve"===this.opts.width?(s=this.opts.element.css("width")).indexOf("%")>0?s:0===this.opts.element.outerWidth(!1)?"auto":this.opts.element.outerWidth(!1)+"px":null}return e.isFunction(this.opts.width)?this.opts.width():this.opts.width}.call(this);null!==s&&this.container.css("width",s)}}),i=O(s,{createContainer:function(){return e(document.createElement("div")).attr({class:"select2-container"}).html(["<a href='javascript:void(0)' onclick='return false;' class='select2-choice' tabindex='-1'>"," <span class='select2-chosen'> </span><abbr class='select2-search-choice-close'></abbr>"," <span class='select2-arrow' role='presentation'><b role='presentation'></b></span>","</a>","<input class='select2-focusser select2-offscreen' type='text' aria-haspopup='true' role='button' />","<div class='select2-drop select2-display-none'>"," <div class='select2-search'>"," <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input' role='combobox' aria-expanded='true'"," aria-autocomplete='list' title='Search field' />"," </div>"," <ul class='select2-results' role='listbox'>"," </ul>","</div>"].join(""))},enableInterface:function(){this.parent.enableInterface.apply(this,arguments)&&this.focusser.prop("disabled",!this.isInterfaceEnabled())},opening:function(){var s,i,n;this.opts.minimumResultsForSearch>=0&&this.showSearch(!0),this.parent.opening.apply(this,arguments),!1!==this.showSearchInput&&this.search.val(this.focusser.val()),this.search.focus(),(s=this.search.get(0)).createTextRange?((i=s.createTextRange()).collapse(!1),i.select()):s.setSelectionRange&&(n=this.search.val().length,s.setSelectionRange(n,n)),""===this.search.val()&&this.nextSearchTerm!=t&&(this.search.val(this.nextSearchTerm),this.search.select()),this.focusser.prop("disabled",!0).val(""),this.updateResults(!0),this.opts.element.trigger(e.Event("select2-open"))},close:function(e){this.opened()&&(this.parent.close.apply(this,arguments),e=e||{focus:!0},this.focusser.removeAttr("disabled"),e.focus&&this.focusser.focus())},focus:function(){this.opened()?this.close():(this.focusser.removeAttr("disabled"),this.focusser.focus())},isFocused:function(){return this.container.hasClass("select2-container-active")},cancel:function(){this.parent.cancel.apply(this,arguments),this.focusser.removeAttr("disabled"),this.focusser.focus()},destroy:function(){e("label[for='"+this.focusser.attr("id")+"']").attr("for",this.opts.element.attr("id")),this.parent.destroy.apply(this,arguments)},initContainer:function(){var t,s,i=this.container,n=this.dropdown,a=o();this.opts.minimumResultsForSearch<0?this.showSearch(!1):this.showSearch(!0),this.selection=t=i.find(".select2-choice"),this.focusser=i.find(".select2-focusser"),t.find(".select2-chosen").attr("id","select2-chosen-"+a),this.focusser.attr("aria-labelledby","select2-chosen-"+a),this.results.attr("id","select2-results-"+a),this.search.attr("aria-owns","select2-results-"+a),this.focusser.attr("id","s2id_autogen"+a),s=e("label[for='"+this.opts.element.attr("id")+"']").attr("for",this.focusser.attr("id"));var r=this.opts.element.attr("title");this.opts.element.attr("title",r||s.text()),this.focusser.attr("tabindex",this.elementTabIndex),this.search.on("keydown",this.bind((function(e){if(this.isInterfaceEnabled())if(e.which!==h.PAGE_UP&&e.which!==h.PAGE_DOWN)switch(e.which){case h.UP:case h.DOWN:return this.moveHighlight(e.which===h.UP?-1:1),void w(e);case h.ENTER:return this.selectHighlighted(),void w(e);case h.TAB:return void this.selectHighlighted({noFocus:!0});case h.ESC:return this.cancel(e),void w(e)}else w(e)}))),this.search.on("blur",this.bind((function(e){document.activeElement===this.body().get(0)&&window.setTimeout(this.bind((function(){this.opened()&&this.search.focus()})),0)}))),this.focusser.on("keydown",this.bind((function(e){if(this.isInterfaceEnabled()&&e.which!==h.TAB&&!h.isControl(e)&&!h.isFunctionKey(e)&&e.which!==h.ESC){if(!1!==this.opts.openOnEnter||e.which!==h.ENTER){if(e.which==h.DOWN||e.which==h.UP||e.which==h.ENTER&&this.opts.openOnEnter){if(e.altKey||e.ctrlKey||e.shiftKey||e.metaKey)return;return this.open(),void w(e)}return e.which==h.DELETE||e.which==h.BACKSPACE?(this.opts.allowClear&&this.clear(),void w(e)):void 0}w(e)}}))),g(this.focusser),this.focusser.on("keyup-change input",this.bind((function(e){if(this.opts.minimumResultsForSearch>=0){if(e.stopPropagation(),this.opened())return;this.open()}}))),t.on("mousedown","abbr",this.bind((function(e){var t;this.isInterfaceEnabled()&&(this.clear(),(t=e).preventDefault(),t.stopImmediatePropagation(),this.close(),this.selection.focus())}))),t.on("mousedown",this.bind((function(t){this.container.hasClass("select2-container-active")||this.opts.element.trigger(e.Event("select2-focus")),this.opened()?this.close():this.isInterfaceEnabled()&&this.open(),w(t)}))),n.on("mousedown",this.bind((function(){this.search.focus()}))),t.on("focus",this.bind((function(e){w(e)}))),this.focusser.on("focus",this.bind((function(){this.container.hasClass("select2-container-active")||this.opts.element.trigger(e.Event("select2-focus")),this.container.addClass("select2-container-active")}))).on("blur",this.bind((function(){this.opened()||(this.container.removeClass("select2-container-active"),this.opts.element.trigger(e.Event("select2-blur")))}))),this.search.on("focus",this.bind((function(){this.container.hasClass("select2-container-active")||this.opts.element.trigger(e.Event("select2-focus")),this.container.addClass("select2-container-active")}))),this.initContainerWidth(),this.opts.element.addClass("select2-offscreen"),this.setPlaceholder()},clear:function(t){var s=this.selection.data("select2-data");if(s){var i=e.Event("select2-clearing");if(this.opts.element.trigger(i),i.isDefaultPrevented())return;var n=this.getPlaceholderOption();this.opts.element.val(n?n.val():""),this.selection.find(".select2-chosen").empty(),this.selection.removeData("select2-data"),this.setPlaceholder(),!1!==t&&(this.opts.element.trigger({type:"select2-removed",val:this.id(s),choice:s}),this.triggerChange({removed:s}))}},initSelection:function(){if(this.isPlaceholderOptionSelected())this.updateSelection(null),this.close(),this.setPlaceholder();else{var e=this;this.opts.initSelection.call(null,this.opts.element,(function(s){s!==t&&null!==s&&(e.updateSelection(s),e.close(),e.setPlaceholder())}))}},isPlaceholderOptionSelected:function(){var e;return!!this.getPlaceholder()&&((e=this.getPlaceholderOption())!==t&&e.prop("selected")||""===this.opts.element.val()||this.opts.element.val()===t||null===this.opts.element.val())},prepareOpts:function(){var t=this.parent.prepareOpts.apply(this,arguments),s=this;return"select"===t.element.get(0).tagName.toLowerCase()?t.initSelection=function(e,t){var i=e.find("option").filter((function(){return this.selected}));t(s.optionToData(i))}:"data"in t&&(t.initSelection=t.initSelection||function(s,i){var n=s.val(),o=null;t.query({matcher:function(e,s,i){var a=f(n,t.id(i));return a&&(o=i),a},callback:e.isFunction(i)?function(){i(o)}:e.noop})}),t},getPlaceholder:function(){return this.select&&this.getPlaceholderOption()===t?t:this.parent.getPlaceholder.apply(this,arguments)},setPlaceholder:function(){var e=this.getPlaceholder();if(this.isPlaceholderOptionSelected()&&e!==t){if(this.select&&this.getPlaceholderOption()===t)return;this.selection.find(".select2-chosen").html(this.opts.escapeMarkup(e)),this.selection.addClass("select2-default"),this.container.removeClass("select2-allowclear")}},postprocessResults:function(e,t,s){var i=0,n=this;if(this.findHighlightableChoices().each2((function(e,t){if(f(n.id(t.data("select2-data")),n.opts.element.val()))return i=e,!1})),!1!==s&&(!0===t&&i>=0?this.highlight(i):this.highlight(0)),!0===t){var o=this.opts.minimumResultsForSearch;o>=0&&this.showSearch(k(e.results)>=o)}},showSearch:function(t){this.showSearchInput!==t&&(this.showSearchInput=t,this.dropdown.find(".select2-search").toggleClass("select2-search-hidden",!t),this.dropdown.find(".select2-search").toggleClass("select2-offscreen",!t),e(this.dropdown,this.container).toggleClass("select2-with-searchbox",t))},onSelect:function(e,t){if(this.triggerSelect(e)){var s=this.opts.element.val(),i=this.data();this.opts.element.val(this.id(e)),this.updateSelection(e),this.opts.element.trigger({type:"select2-selected",val:this.id(e),choice:e}),this.nextSearchTerm=this.opts.nextSearchTerm(e,this.search.val()),this.close(),t&&t.noFocus||this.focusser.focus(),f(s,this.id(e))||this.triggerChange({added:e,removed:i})}},updateSelection:function(e){var s,i,n=this.selection.find(".select2-chosen");this.selection.data("select2-data",e),n.empty(),null!==e&&(s=this.opts.formatSelection(e,n,this.opts.escapeMarkup)),s!==t&&n.append(s),(i=this.opts.formatSelectionCssClass(e,n))!==t&&n.addClass(i),this.selection.removeClass("select2-default"),this.opts.allowClear&&this.getPlaceholder()!==t&&this.container.addClass("select2-allowclear")},val:function(){var e,s=!1,i=null,n=this,o=this.data();if(0===arguments.length)return this.opts.element.val();if(e=arguments[0],arguments.length>1&&(s=arguments[1]),this.select)this.select.val(e).find("option").filter((function(){return this.selected})).each2((function(e,t){return i=n.optionToData(t),!1})),this.updateSelection(i),this.setPlaceholder(),s&&this.triggerChange({added:i,removed:o});else{if(!e&&0!==e)return void this.clear(s);if(this.opts.initSelection===t)throw new Error("cannot call val() if initSelection() is not defined");this.opts.element.val(e),this.opts.initSelection(this.opts.element,(function(e){n.opts.element.val(e?n.id(e):""),n.updateSelection(e),n.setPlaceholder(),s&&n.triggerChange({added:e,removed:o})}))}},clearSearch:function(){this.search.val(""),this.focusser.val("")},data:function(e){var s,i=!1;if(0===arguments.length)return(s=this.selection.data("select2-data"))==t&&(s=null),s;arguments.length>1&&(i=arguments[1]),e?(s=this.data(),this.opts.element.val(e?this.id(e):""),this.updateSelection(e),i&&this.triggerChange({added:e,removed:s})):this.clear(i)}}),n=O(s,{createContainer:function(){return e(document.createElement("div")).attr({class:"select2-container select2-container-multi"}).html(["<ul class='select2-choices'>"," <li class='select2-search-field'>"," <input type='text' autocomplete='off' autocorrect='off' placeholder='Type-in a TV show' title='Name of a TV show' autocapitalize='off' spellcheck='false' class='select2-input' required autofocus='true'>"," </li>","</ul>","<div class='select2-drop select2-drop-multi select2-display-none'>"," <ul class='select2-results'>"," </ul>","</div>"].join(""))},prepareOpts:function(){var t=this.parent.prepareOpts.apply(this,arguments),s=this;return"select"===t.element.get(0).tagName.toLowerCase()?t.initSelection=function(e,t){var i=[];e.find("option").filter((function(){return this.selected})).each2((function(e,t){i.push(s.optionToData(t))})),t(i)}:"data"in t&&(t.initSelection=t.initSelection||function(s,i){var n=m(s.val(),t.separator),o=[];t.query({matcher:function(s,i,a){var r=e.grep(n,(function(e){return f(e,t.id(a))})).length;return r&&o.push(a),r},callback:e.isFunction(i)?function(){for(var e=[],s=0;s<n.length;s++)for(var a=n[s],r=0;r<o.length;r++){var l=o[r];if(f(a,t.id(l))){e.push(l),o.splice(r,1);break}}i(e)}:e.noop})}),t},selectChoice:function(e){var t=this.container.find(".select2-search-choice-focus");t.length&&e&&e[0]==t[0]||(t.length&&this.opts.element.trigger("choice-deselected",t),t.removeClass("select2-search-choice-focus"),e&&e.length&&(this.close(),e.addClass("select2-search-choice-focus"),this.opts.element.trigger("choice-selected",e)))},destroy:function(){e("label[for='"+this.search.attr("id")+"']").attr("for",this.opts.element.attr("id")),this.parent.destroy.apply(this,arguments)},initContainer:function(){var t,s=".select2-choices";this.searchContainer=this.container.find(".select2-search-field"),this.selection=t=this.container.find(s);var i=this;this.selection.on("click",".select2-search-choice:not(.select2-locked)",(function(t){i.search[0].focus(),i.selectChoice(e(this))})),this.search.attr("id","s2id_autogen"+o()),e("label[for='"+this.opts.element.attr("id")+"']").attr("for",this.search.attr("id")),this.search.on("input paste",this.bind((function(){this.isInterfaceEnabled()&&(this.opened()||this.open())}))),this.search.attr("tabindex",this.elementTabIndex),this.keydowns=0,this.search.on("keydown",this.bind((function(s){if(this.isInterfaceEnabled()){++this.keydowns;var i=t.find(".select2-search-choice-focus"),n=i.prev(".select2-search-choice:not(.select2-locked)"),o=i.next(".select2-search-choice:not(.select2-locked)"),a=function(t){var s=0,i=0;if("selectionStart"in(t=e(t)[0]))s=t.selectionStart,i=t.selectionEnd-s;else if("selection"in document){t.focus();var n=document.selection.createRange();i=document.selection.createRange().text.length,n.moveStart("character",-t.value.length),s=n.text.length-i}return{offset:s,length:i}}(this.search);if(i.length&&(s.which==h.LEFT||s.which==h.RIGHT||s.which==h.BACKSPACE||s.which==h.DELETE||s.which==h.ENTER)){var r=i;return s.which==h.LEFT&&n.length?r=n:s.which==h.RIGHT?r=o.length?o:null:s.which===h.BACKSPACE?(this.unselect(i.first()),r=n.length?n:o):s.which==h.DELETE?(this.unselect(i.first()),r=o.length?o:null):s.which==h.ENTER&&(r=null),this.selectChoice(r),w(s),void(r&&r.length||this.open())}if((s.which===h.BACKSPACE&&1==this.keydowns||s.which==h.LEFT)&&0==a.offset&&!a.length)return this.selectChoice(t.find(".select2-search-choice:not(.select2-locked)").last()),void w(s);if(this.selectChoice(null),this.opened())switch(s.which){case h.UP:case h.DOWN:return this.moveHighlight(s.which===h.UP?-1:1),void w(s);case h.ENTER:return this.selectHighlighted(),void w(s);case h.TAB:return this.selectHighlighted({noFocus:!0}),void this.close();case h.ESC:return this.cancel(s),void w(s)}if(s.which!==h.TAB&&!h.isControl(s)&&!h.isFunctionKey(s)&&s.which!==h.BACKSPACE&&s.which!==h.ESC){if(s.which===h.ENTER){if(!1===this.opts.openOnEnter)return;if(s.altKey||s.ctrlKey||s.shiftKey||s.metaKey)return}this.open(),s.which!==h.PAGE_UP&&s.which!==h.PAGE_DOWN||w(s),s.which===h.ENTER&&w(s)}}}))),this.search.on("keyup",this.bind((function(e){this.keydowns=0,this.resizeSearch()}))),this.search.on("blur",this.bind((function(t){this.container.removeClass("select2-container-active"),this.search.removeClass("select2-focused"),this.selectChoice(null),t.stopImmediatePropagation(),this.opts.element.trigger(e.Event("select2-blur"))}))),this.container.on("click",s,this.bind((function(t){this.isInterfaceEnabled()&&(e(t.target).closest(".select2-search-choice").length>0||(this.selectChoice(null),this.clearPlaceholder(),this.container.hasClass("select2-container-active")||this.opts.element.trigger(e.Event("select2-focus")),this.open(),this.focusSearch(),t.preventDefault()))}))),this.container.on("focus",s,this.bind((function(){this.isInterfaceEnabled()&&(this.container.hasClass("select2-container-active")||this.opts.element.trigger(e.Event("select2-focus")),this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"),this.clearPlaceholder())}))),this.initContainerWidth(),this.opts.element.addClass("select2-offscreen"),this.clearSearch()},enableInterface:function(){this.parent.enableInterface.apply(this,arguments)&&this.search.prop("disabled",!this.isInterfaceEnabled())},initSelection:function(){if(""===this.opts.element.val()&&""===this.opts.element.text()&&(this.updateSelection([]),this.close(),this.clearSearch()),this.select||""!==this.opts.element.val()){var e=this;this.opts.initSelection.call(null,this.opts.element,(function(s){s!==t&&null!==s&&(e.updateSelection(s),e.close(),e.clearSearch())}))}},clearSearch:function(){var e=this.getPlaceholder();this.getMaxSearchWidth();e!==t&&0===this.getVal().length&&!1===this.search.hasClass("select2-focused")?this.search.val(e).addClass("select2-default"):this.search.focus()},clearPlaceholder:function(){this.search.hasClass("select2-default")&&this.search.val("").removeClass("select2-default")},opening:function(){this.clearPlaceholder(),this.resizeSearch(),this.parent.opening.apply(this,arguments),this.focusSearch(),this.updateResults(!0),this.search.focus(),this.opts.element.trigger(e.Event("select2-open"))},close:function(){this.search.hasClass("select2-focused")&&(this.container.hasClass("select2-container-active")||this.search.select()),this.opened()&&this.parent.close.apply(this,arguments)},focus:function(){this.close(),this.search.focus()},isFocused:function(){return this.search.hasClass("select2-focused")},updateSelection:function(t){var s=[],i=[],n=this;e(t).each((function(){p(n.id(this),s)<0&&(s.push(n.id(this)),i.push(this))})),t=i,this.selection.find(".select2-search-choice").remove(),e(t).each((function(){n.addSelectedChoice(this)})),n.postprocessResults()},tokenize:function(){var e=this.search.val();null!=(e=this.opts.tokenizer.call(this,e,this.data(),this.bind(this.onSelect),this.opts))&&e!=t&&(this.search.val(e),e.length>0&&this.open())},onSelect:function(e,t){this.triggerSelect(e)&&(this.addSelectedChoice(e),this.opts.element.trigger({type:"selected",val:this.id(e),choice:e}),!this.select&&this.opts.closeOnSelect||this.postprocessResults(e,!1,!0===this.opts.closeOnSelect),this.opts.closeOnSelect?this.close():this.countSelectableResults()>0?(this.resizeSearch(),this.getMaximumSelectionSize()>0&&this.val().length>=this.getMaximumSelectionSize()&&this.updateResults(!0),this.positionDropdown()):this.close(),this.triggerChange({added:e}),t&&t.noFocus||this.focusSearch())},cancel:function(){this.close(),this.focusSearch()},addSelectedChoice:function(s){var i,n,o=!s.locked,a=e("<li class='select2-search-choice visuallyhidden'> <div></div> <a href='#' onclick='return false;' class='select2-search-choice-close' tabindex='-1'></a></li>"),r=e("<li class='select2-search-choice select2-locked'><div></div></li>"),l=o?a:r,c=this.id(s),h=this.getVal();(i=this.opts.formatSelection(s,l.find("div"),this.opts.escapeMarkup))!=t&&l.find("div").replaceWith("<div>"+i+"</div>"),(n=this.opts.formatSelectionCssClass(s,l.find("div")))!=t&&l.addClass(n),o&&l.find(".select2-search-choice-close").on("mousedown",w).on("click dblclick",this.bind((function(t){this.isInterfaceEnabled()&&(e(t.target).closest(".select2-search-choice").fadeOut("fast",this.bind((function(){this.unselect(e(t.target)),this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus"),this.close(),this.focusSearch()}))).dequeue(),w(t))}))).on("focus",this.bind((function(){this.isInterfaceEnabled()&&(this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"))}))),l.data("select2-data",s),l.insertBefore(this.searchContainer),h.push(c),this.setVal(h)},unselect:function(t){var s,i,n=this.getVal();if(0===(t=t.closest(".select2-search-choice")).length)throw"Invalid argument: "+t+". Must be .select2-search-choice";if(s=t.data("select2-data")){for(;(i=p(this.id(s),n))>=0;)n.splice(i,1),this.setVal(n),this.select&&this.postprocessResults();var o=e.Event("select2-removing");o.val=this.id(s),o.choice=s,this.opts.element.trigger(o),o.isDefaultPrevented()||(t.remove(),this.opts.element.trigger({type:"select2-removed",val:this.id(s),choice:s}),this.triggerChange({removed:s}))}},postprocessResults:function(e,t,s){var i=this.getVal(),n=this.results.find(".select2-result"),o=this.results.find(".select2-result-with-children"),a=this;n.each2((function(e,t){p(a.id(t.data("select2-data")),i)>=0&&(t.addClass("select2-selected"),t.find(".select2-result-selectable").addClass("select2-selected"))})),o.each2((function(e,t){t.is(".select2-result-selectable")||0!==t.find(".select2-result-selectable:not(.select2-selected)").length||t.addClass("select2-selected")})),-1==this.highlight()&&!1!==s&&a.highlight(0),!this.opts.createSearchChoice&&!n.filter(".select2-result:not(.select2-selected)").length>0&&(!e||e&&!e.more&&0===this.results.find(".select2-no-results").length)&&_(a.opts.formatNoMatches,"formatNoMatches")&&this.results.append("<li class='select2-no-results'>"+a.opts.formatNoMatches(a.search.val())+"</li>")},getMaxSearchWidth:function(){},resizeSearch:function(){},getVal:function(){var e;return this.select?null===(e=this.select.val())?[]:e:m(e=this.opts.element.val(),this.opts.separator)},setVal:function(t){var s;this.select?this.select.val(t):(s=[],e(t).each((function(){p(this,s)<0&&s.push(this)})),this.opts.element.val(0===s.length?"":s.join(this.opts.separator)))},buildChangeDetails:function(e,t){t=t.slice(0),e=e.slice(0);for(var s=0;s<t.length;s++)for(var i=0;i<e.length;i++)f(this.opts.id(t[s]),this.opts.id(e[i]))&&(t.splice(s,1),s>0&&s--,e.splice(i,1),i--);return{added:t,removed:e}},val:function(s,i){var n,o=this;if(0===arguments.length)return this.getVal();if((n=this.data()).length||(n=[]),!s&&0!==s)return this.opts.element.val(""),this.updateSelection([]),this.clearSearch(),void(i&&this.triggerChange({added:this.data(),removed:n}));if(this.setVal(s),this.select)this.opts.initSelection(this.select,this.bind(this.updateSelection)),i&&this.triggerChange(this.buildChangeDetails(n,this.data()));else{if(this.opts.initSelection===t)throw new Error("val() cannot be called if initSelection() is not defined");this.opts.initSelection(this.opts.element,(function(t){var s=e.map(t,o.id);o.setVal(s),o.updateSelection(t),o.clearSearch(),i&&o.triggerChange(o.buildChangeDetails(n,o.data()))}))}this.clearSearch()},onSortStart:function(){if(this.select)throw new Error("Sorting of elements is not supported when attached to <select>. Attach to <input type='hidden'/> instead.");this.search.width(0),this.searchContainer.hide()},onSortEnd:function(){var t=[],s=this;this.searchContainer.show(),this.searchContainer.appendTo(this.searchContainer.parent()),this.resizeSearch(),this.selection.find(".select2-search-choice").each((function(){t.push(s.opts.id(e(this).data("select2-data")))})),this.setVal(t),this.triggerChange()},data:function(t,s){var i,n,o=this;if(0===arguments.length)return this.selection.find(".select2-search-choice").map((function(){return e(this).data("select2-data")})).get();n=this.data(),t||(t=[]),i=e.map(t,(function(e){return o.opts.id(e)})),this.setVal(i),this.updateSelection(t),this.clearSearch(),s&&this.triggerChange(this.buildChangeDetails(n,this.data()))}}),e.fn.select2=function(){var s,o,a,r,l,c=Array.prototype.slice.call(arguments,0),h=["val","destroy","opened","open","close","focus","isFocused","container","dropdown","onSortStart","onSortEnd","enable","disable","readonly","positionDropdown","data","search"],d=["opened","isFocused","container","dropdown"],u=["val","data"],f={search:"externalSearch"};return this.each((function(){if(0===c.length||"object"==typeof c[0])(s=0===c.length?{}:e.extend({},c[0])).element=e(this),"select"===s.element.get(0).tagName.toLowerCase()?l=s.element.prop("multiple"):(l=s.multiple||!1,"tags"in s&&(s.multiple=l=!0)),(o=l?new n:new i).init(s);else{if("string"!=typeof c[0])throw"Invalid arguments to select2 plugin: "+c;if(p(c[0],h)<0)throw"Unknown method: "+c[0];if(r=t,(o=e(this).data("select2"))===t)return;if("container"===(a=c[0])?r=o.container:"dropdown"===a?r=o.dropdown:(f[a]&&(a=f[a]),r=o[a].apply(o,c.slice(1))),p(c[0],d)>=0||p(c[0],u)&&1==c.length)return!1}})),r===t?this:r},e.fn.select2.defaults={width:"copy",loadMorePadding:0,closeOnSelect:!0,openOnEnter:!0,containerCss:{},dropdownCss:{},containerCssClass:"",dropdownCssClass:"",formatResult:function(e,t,s,i){var n=[];return C(e.text,s.term,n,i),n.join("")},formatSelection:function(e,s,i){return e?i(e.text):t},sortResults:function(e,t,s){return e},formatResultCssClass:function(e){return e.css},formatSelectionCssClass:function(e,s){return t},formatNoMatches:function(){return"No matches found"},formatInputTooShort:function(e,t){var s=t-e.length;return"Please enter "+s+" more character"+(1==s?"":"s")},formatInputTooLong:function(e,t){var s=e.length-t;return"Please delete "+s+" character"+(1==s?"":"s")},formatSelectionTooBig:function(e){return"You can only select "+e+" item"+(1==e?"":"s")},formatLoadMore:function(e){return"Loading more results..."},formatSearching:function(){return"Searching..."},minimumResultsForSearch:0,minimumInputLength:0,maximumInputLength:null,maximumSelectionSize:0,id:function(e){return e.id},matcher:function(e,t){return u(""+t).toUpperCase().indexOf(u(""+e).toUpperCase())>=0},separator:",",tokenSeparators:[],tokenizer:function(e,s,i,n){var o,a,r,l,c,h=e,d=!1;if(!n.createSearchChoice||!n.tokenSeparators||n.tokenSeparators.length<1)return t;for(;;){for(a=-1,r=0,l=n.tokenSeparators.length;r<l&&(c=n.tokenSeparators[r],!((a=e.indexOf(c))>=0));r++);if(a<0)break;if(o=e.substring(0,a),e=e.substring(a+c.length),o.length>0&&(o=n.createSearchChoice.call(this,o,s))!==t&&null!==o&&n.id(o)!==t&&null!==n.id(o)){for(d=!1,r=0,l=s.length;r<l;r++)if(f(n.id(o),n.id(s[r]))){d=!0;break}d||i(o)}}return h!==e?e:void 0},escapeMarkup:y,blurOnChange:!1,selectOnBlur:!1,adaptContainerCssClass:function(e){return e},adaptDropdownCssClass:function(e){return null},nextSearchTerm:function(e,s){return t}},e.fn.select2.ajaxDefaults={transport:e.ajax,params:{type:"GET",cache:!1,dataType:"json"}},window.Select2={query:{ajax:S,local:T,tags:x},util:{debounce:v,markMatch:C,escapeMarkup:y,stripDiacritics:u},class:{abstract:s,single:i,multi:n}}}function u(e){var t,s,i,n;if(!e||e.length<1)return e;for(t="",s=0,i=e.length;s<i;s++)n=e.charAt(s),t+=d[n]||n;return t}function p(e,t){for(var s=0,i=t.length;s<i;s+=1)if(f(e,t[s]))return s;return-1}function f(e,s){return e===s||e!==t&&s!==t&&(null!==e&&null!==s&&(e.constructor===String?e+""==s+"":s.constructor===String&&s+""==e+""))}function m(t,s){var i,n,o;if(null===t||t.length<1)return[];for(n=0,o=(i=t.split(s)).length;n<o;n+=1)i[n]=e.trim(i[n]);return i}function g(s){var i="keyup-change-value";s.on("keydown",(function(){e.data(s,i)===t&&e.data(s,i,s.val())})),s.on("keyup",(function(){var n=e.data(s,i);n!==t&&s.val()!==n&&(e.removeData(s,i),s.trigger("keyup-change"))}))}function v(e,s,i){var n;return i=i||t,function(){var t=arguments;window.clearTimeout(n),n=window.setTimeout((function(){s.apply(i,t)}),e)}}function w(e){e.preventDefault(),e.stopPropagation()}function b(t,s,i){var n,o,a=[];(n=t.attr("class"))&&e((n=""+n).split(" ")).each2((function(){0===this.indexOf("select2-")&&a.push(this)})),(n=s.attr("class"))&&e((n=""+n).split(" ")).each2((function(){0!==this.indexOf("select2-")&&(o=i(this))&&a.push(o)})),t.attr("class",a.join(" "))}function C(e,t,s,i){var n=u(e.toUpperCase()).indexOf(u(t.toUpperCase())),o=t.length;n<0?s.push(i(e)):(s.push(i(e.substring(0,n))),s.push("<span class='select2-match'>"),s.push(i(e.substring(n,n+o))),s.push("</span>"),s.push(i(e.substring(n+o,e.length))))}function y(e){var t={"\\":"\","&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return String(e).replace(/[&<>"'\/\\]/g,(function(e){return t[e]}))}function S(s){var i,n=null,o=s.quietMillis||100,a=s.url,r=this;return function(l){window.clearTimeout(i),i=window.setTimeout((function(){var i=s.data,o=a,c=s.transport||e.fn.select2.ajaxDefaults.transport,h={type:s.type||"GET",cache:s.cache||!1,jsonpCallback:s.jsonpCallback||t,dataType:s.dataType||"json"},d=e.extend({},e.fn.select2.ajaxDefaults.params,h);i=i?i.call(r,l.term,l.page,l.context):null,o="function"==typeof o?o.call(r,l.term,l.page,l.context):o,n&&n.abort(),s.params&&(e.isFunction(s.params)?e.extend(d,s.params.call(r)):e.extend(d,s.params)),e.extend(d,{url:o,dataType:s.dataType,data:i,success:function(e){var t=s.results(e,l.page);l.callback(t)}}),n=c.call(r,d)}),o)}}function T(t){var s,i,n=t,o=function(e){return""+e.text};e.isArray(n)&&(n={results:i=n}),!1===e.isFunction(n)&&(i=n,n=function(){return i});var a=n();return a.text&&(o=a.text,e.isFunction(o)||(s=a.text,o=function(e){return e[s]})),function(t){var s,i=t.term,a={results:[]};""!==i?(s=function(n,a){var r,l;if((n=n[0]).children){for(l in r={},n)n.hasOwnProperty(l)&&(r[l]=n[l]);r.children=[],e(n.children).each2((function(e,t){s(t,r.children)})),(r.children.length||t.matcher(i,o(r),n))&&a.push(r)}else t.matcher(i,o(n),n)&&a.push(n)},e(n().results).each2((function(e,t){s(t,a.results)})),t.callback(a)):t.callback(n())}}function x(s){var i=e.isFunction(s);return function(n){var o=n.term,a={results:[]};e(i?s():s).each((function(){var e=this.text!==t,s=e?this.text:this;(""===o||n.matcher(o,s))&&a.results.push(e?this:{id:this,text:this})})),n.callback(a)}}function _(t,s){if(e.isFunction(t))return!0;if(!t)return!1;throw new Error(s+" must be a function or a falsy value")}function E(t){return e.isFunction(t)?t():t}function k(t){var s=0;return e.each(t,(function(e,t){t.children?s+=k(t.children):s++})),s}function O(t,s){var i=function(){};return(i.prototype=new t).constructor=i,i.prototype.parent=t.prototype,i.prototype=e.extend(i.prototype,s),i}}(jQuery),$("body").keydown((function(e){27===e.keyCode&&($("body").hasClass("noScroll")?hideModalWindow():showModalWindow())})),$(window).keydown((function(e){if(13==e.keyCode&&($(".seasons").is(":focus")||$(".submit").is(":focus"))&&($(".select2-input").val().length<=0||0!==$(".select2-input").val().length)&&!hasSelectedShow)return e.preventDefault(),!1})),$("input, .seasons").focus((function(){var e=$(this);e.select(),window.setTimeout((function(){e.select()}),1),e.mouseup((function t(){return e.off("mouseup",t),!1}))})),$(".seasons").focus((function(){$(".seasons-description").removeClass("visuallyhidden")})).blur((function(){$(".seasons-description").addClass("visuallyhidden")})),$(".seasons").keydown((function(e){var t=e.keyCode;if(t>57&&t<96||t>105)return!1})),$(".seasons").change((function(){var e=parseInt($(this).val(),10),t=$(this).attr("max");e>t&&$(this).val(t),e<1&&$(this).val(1)}));var nrEpisodes=0,nrSeasons=0,runtime=0,delay=function(){var e=0;return function(t,s){clearTimeout(e),e=setTimeout(t,s)}}(),API_KEY="d56e51fb77b081a9cb5192eaaa7823ad";function makeAjaxCall(e,t,s){return $.ajax({type:e,url:t,dataType:"jsonp",json:"callbackname",crossDomain:!0,success:s,error:function(e){console.log("An error occurred.")}})}$(".tvshow").select2({placeholder:"Type in a TV show",multiple:!0,maximumSelectionSize:1,minimumInputLength:2,maximumInputLength:20,query:function(e){delay((function(){var t={results:[]},s=$(".select2-input").val();makeAjaxCall("GET","https://api.themoviedb.org/3/search/tv?api_key="+API_KEY+"&query="+s,(function(s){$.each(s,(function(s,i){$.each(i,(function(s,i){s<2&&makeAjaxCall("GET","https://api.themoviedb.org/3/tv/"+i.id+"?api_key="+API_KEY,(function(s){var n=null!=s.number_of_seasons?s.number_of_seasons:1;(t.results.push({id:s.id,text:s.original_name,runtime:s.episode_run_time[0],poster:s.poster_path,bg:s.backdrop_path,seasons:n,episodes:s.number_of_episodes}),null==s.episode_run_time[0])&&makeAjaxCall("GET","https://api.themoviedb.org/3/tv/"+i.id+"/season/1?api_key="+API_KEY,(function(e){for(var i=0,n=0,o=0,a=0;a<e.episodes.length;a++){var r=e.episodes[a];r.hasOwnProperty("runtime")&&(i+=r.runtime,n++)}o=n>0?i/n:0,o=Math.floor(o);for(var l=0;l<t.results.length;l++)if(t.results[l].id===s.id){t.results[l].runtime=o;break}}));e.callback(t)}))}))}))}))}),1e3)}});var selectedTVshow,hasSelectedShow=!1,totalSeasons=0,episodes=0;runtime=0;$(".tvshow").change((function(){if(selectedTVshow=jQuery.parseJSON(JSON.stringify($(".tvshow").select2("data"))),console.log(selectedTVshow),$(".show-to-add").remove(),!(selectedTVshow[0].seasons>=0&&selectedTVshow[0].runtime>=0)){var e=$(".select2-results");return e.parent().css("display","block"),$("<li />").addClass("select2-no-results").html("This show has an error. Please select a different one.").appendTo(e),hasSelectedShow=!1,$(".select2-search-choice.visuallyhidden").remove(),!1}if(void 0!==selectedTVshow[0]){var t=$(".bg").css("background-image"),s="url(https://image.tmdb.org/t/p/original/"+selectedTVshow[0].bg+")";if(s!=t){var i=new Image;i.src="https://image.tmdb.org/t/p/original/"+selectedTVshow[0].bg,setTimeout((function(){$(".bg").css("background-image",s),i=null}),1400)}$(".seasons").attr("max",selectedTVshow[0].seasons),totalSeasons=selectedTVshow[0].seasons,episodes=selectedTVshow[0].episodes,runtime=selectedTVshow[0].runtime;var n=null;n=null==selectedTVshow[0].poster?"../images/126.42.jpg":"https://image.tmdb.org/t/p/w342"+selectedTVshow[0].poster,$(".container__list-of-shows").prepend('<li class="show-to-add visuallyhidden"><a href="#" class="btn icon-close js-remove-item" title="Remove this TV show"></a><img src="'+n+'" alt="'+selectedTVshow[0].text+'" /><div class="container__list-of-shows__info"><span class="container__list-of-shows__info__title" title="TV show title">'+selectedTVshow[0].text+'</span><span class="container__list-of-shows__info__seasons" title="Nr. of seasons"></span><span class="container__list-of-shows__info__wasted-time visuallyhidden"></span></div></li>'),$("input").val(selectedTVshow[0].text)}else $(".bg").addClass("hide"),setTimeout((function(){$(".bg").attr("src","")}),1e3);$(".select2-search-choice.visuallyhidden").remove(),setTimeout((function(){$(".seasons").focus().val(selectedTVshow[0].seasons),showSubmitButton()}),100),hasSelectedShow=!0}));var flagScrollHidden=!1;function addNoScroll(){$("body").hasClass("noScroll")||($("body").addClass("noScroll"),flagScrollHidden=!0);var e=$(".container__list-of-shows").children().size();e>=1&&e<4?($(".container__list-of-shows > li:nth-child(1)").addClass("blur-and-reduce-opacity"),$(".container__list-of-shows > li:nth-child(2)").addClass("blur-and-reduce-opacity")):e>=4&&e<5?($(".container__list-of-shows > li:nth-child(1)").addClass("blur-and-reduce-opacity"),$(".container__list-of-shows > li:nth-child(2)").addClass("blur-and-reduce-opacity"),$(".container__list-of-shows > li:nth-child(3)").addClass("blur-and-reduce-opacity")):e>=5&&($(".container__list-of-shows > li:nth-child(2)").addClass("blur-and-reduce-opacity"),$(".container__list-of-shows > li:nth-child(3)").addClass("blur-and-reduce-opacity"))}function removeNoScroll(){$("body").hasClass("noScroll")&&$("body").removeClass("noScroll"),$(".container__list-of-shows").children().removeClass("blur-and-reduce-opacity")}$(".tvshow").on("select2-close",(function(e){$("input").blur(),flagScrollHidden=!1,removeNoScroll()})),$(".tvshow").on("select2-loaded",(function(){0==flagScrollHidden&&addNoScroll()}));var timeWastedInMinutes=0,totalTimeWastedInMinutes=0,episodesPerSeason=0,seasons=0,width=window.innerWidth>0?window.innerWidth:screen.width,height=window.innerHeight>0?window.innerHeight:screen.height;function showTemporaryTimerOfPreviousShow(e,t){var s=convertMinutes(e,!0);t?$(".container__top__previous-show-time").html("- "+s):$(".container__top__previous-show-time").html("+ "+s),$(".container__top__previous-show-time").removeClass("visuallyhidden").addClass("show"),setTimeout((function(){$(".container__top__previous-show-time").removeClass("show").addClass("hiding"),setTimeout((function(){$(".container__top__previous-show-time").removeClass("hiding").addClass("visuallyhidden")}),400)}),3e3)}function convertMinutes(e,t){var s=Math.floor(e/1440),i=Math.floor((e-1440*s)/60),n=Math.floor(e-1440*s-60*i);if(s=formatNumber(s,2),i=formatNumber(i,2),n=formatNumber(n,2),t)return s+" : "+i+" : "+n;updateClock(s,i,n)}function formatNumber(e,t){for(var s=e+"";s.length<t;)s="0"+s;return s}function updateClock(e,t,s){var i=$(".container__top__hours-wasted"),n=i.find(".hours-wasted__days"),o=i.find(".hours-wasted__hours"),a=i.find(".hours-wasted__minutes"),r=new countUp("days",0,e,0,2),l=new countUp("hours",0,t,0,4),c=new countUp("minutes",0,s,0,6);r.reset(),l.reset(),c.reset(),r.start(),l.start(),c.start(),"01"==e?n.find(".description").text("day"):n.find(".description").text("days"),"01"==t?o.find(".description").text("hour"):o.find(".description").text("hours"),"01"==s?a.find(".description").text("minute"):a.find(".description").text("minutes"),e<1?$(".sharing-link").attr("href","https://twitter.com/share?text=I’ve wasted "+t+" hours and "+s+" minutes of my life watching TV shows. Calculate your time:&url=tiii.me"):1==e?$(".sharing-link").attr("href","https://twitter.com/share?text=I’ve wasted "+e+" day, "+t+" hours, and "+s+" minutes of my life watching TV shows. Calculate your time:&url=tiii.me"):t<1?$(".sharing-link").attr("href","https://twitter.com/share?text=I’ve wasted "+e+" days and "+s+" minutes of my life watching TV shows. Calculate your time:&url=tiii.me"):1==t?$(".sharing-link").attr("href","https://twitter.com/share?text=I’ve wasted "+e+" days, "+t+" hour, and "+s+" minutes of my life watching TV shows. Calculate your time:&url=tiii.me"):s<1?$(".sharing-link").attr("href","https://twitter.com/share?text=I’ve wasted "+e+" days and "+t+" hours of my life watching TV shows. Calculate your time:&url=tiii.me"):1==s?$(".sharing-link").attr("href","https://twitter.com/share?text=I’ve wasted "+e+" days, "+t+" hours, and "+s+" minute of my life watching TV shows. Calculate your time:&url=tiii.me"):t<1&&s<1?$(".sharing-link").attr("href","https://twitter.com/share?text=I’ve wasted "+e+" days of my life watching TV shows. Calculate your time:&url=tiii.me"):$(".sharing-link").attr("href","https://twitter.com/share?text=I’ve wasted "+e+" days, "+t+" hours, and "+s+" minutes of my life watching TV shows. Calculate your time:&url=tiii.me")}function showSubmitButton(){var e=$(".submit");e.hasClass("show")||(e.removeClass("visuallyhidden").addClass("showing"),setTimeout((function(){e.removeClass("showing").addClass("show")}),100))}function showModalWindow(){$(".about__content").removeClass("hide").addClass("show"),$(".js-hide-modal").removeClass("visuallyhidden"),$(".about__content a").attr("tabindex",""),$(".about__content a.about__icon").attr("tabindex","0"),$("body").addClass("noScroll")}function hideModalWindow(){$(".about__content").removeClass("show").addClass("hiding"),setTimeout((function(){$(".about__content").addClass("hide").removeClass("hiding show"),$(".js-hide-modal").addClass("visuallyhidden")}),150),$("body").removeClass("noScroll"),$(".about__content a").attr("tabindex","-1")}function countUp(e,t,s,i,n,o){this.options=o||{useEasing:!0,useGrouping:!0,separator:",",decimal:"."};for(var a=0,r=["webkit","moz","ms"],l=0;l<r.length&&!window.requestAnimationFrame;++l)window.requestAnimationFrame=window[r[l]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[r[l]+"CancelAnimationFrame"]||window[r[l]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(e){var t=(new Date).getTime(),s=Math.max(0,16-(t-a)),i=window.setTimeout((function(){e(t+s)}),s);return a=t+s,i}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(e){clearTimeout(e)});var c=this;this.d="string"==typeof e?document.getElementById(e):e,this.startVal=Number(t),this.endVal=Number(s),this.countDown=this.startVal>this.endVal,this.startTime=null,this.timestamp=null,this.remaining=null,this.frameVal=this.startVal,this.rAF=null,this.decimals=Math.max(0,i||0),this.dec=Math.pow(10,this.decimals),this.duration=1e3*n||2e3,this.easeOutExpo=function(e,t,s,i){return 1024*s*(1-Math.pow(2,-10*e/i))/1023+t},this.count=function(e){null===c.startTime&&(c.startTime=e),c.timestamp=e;var t=e-c.startTime;if(c.remaining=c.duration-t,c.options.useEasing)if(c.countDown){var s=c.easeOutExpo(t,0,c.startVal-c.endVal,c.duration);c.frameVal=c.startVal-s}else c.frameVal=c.easeOutExpo(t,c.startVal,c.endVal-c.startVal,c.duration);else if(c.countDown){s=(c.startVal-c.endVal)*(t/c.duration);c.frameVal=c.startVal-s}else c.frameVal=c.startVal+(c.endVal-c.startVal)*(t/c.duration);c.frameVal=Math.round(c.frameVal*c.dec)/c.dec,c.frameVal=c.countDown?c.frameVal<c.endVal?c.endVal:c.frameVal:c.frameVal>c.endVal?c.endVal:c.frameVal,c.d.innerHTML=c.formatNumber(c.frameVal.toFixed(c.decimals)),t<c.duration?c.rAF=requestAnimationFrame(c.count):null!=c.callback&&c.callback()},this.start=function(e){return c.callback=e,isNaN(c.endVal)||isNaN(c.startVal)?(console.log("countUp error: startVal or endVal is not a number"),c.d.innerHTML="--"):c.rAF=requestAnimationFrame(c.count),!1},this.stop=function(){cancelAnimationFrame(c.rAF)},this.reset=function(){c.startTime=null,cancelAnimationFrame(c.rAF),c.d.innerHTML=c.formatNumber(c.startVal.toFixed(c.decimals))},this.resume=function(){c.startTime=null,c.duration=c.remaining,c.startVal=c.frameVal,requestAnimationFrame(c.count)},this.formatNumber=function(e){var t,s,i,n;if(s=(t=(e+="").split("."))[0],i=t.length>1?c.options.decimal+t[1]:"",n=/(\d+)(\d{3})/,c.options.useGrouping)for(;n.test(s);)s=s.replace(n,"$1"+c.options.separator+"$2");return s+i},c.d.innerHTML=c.formatNumber(c.startVal.toFixed(c.decimals))}$(".submit").on("click touchstart",(function(){return seasons=$(".seasons").val(),episodesPerSeason=episodes/totalSeasons,$(".show-to-add").find(".container__list-of-shows__info__seasons").html(seasons),$(".show-to-add").removeClass("visuallyhidden").addClass("showing"),setTimeout((function(){$(".show-to-add").removeClass("showing").addClass("show")}),100),setTimeout((function(){$(".show-to-add").removeClass()}),500),timeWastedInMinutes=runtime*(episodesPerSeason*seasons),$(".show-to-add").find(".container__list-of-shows__info__wasted-time").html(timeWastedInMinutes),convertMinutes(totalTimeWastedInMinutes+=timeWastedInMinutes),save(totalTimeWastedInMinutes),$("input").val(""),$(this).removeClass("show").addClass("hiding"),setTimeout((function(){$(".submit").removeClass("hiding").addClass("visuallyhidden")}),100),$(".select2-input").focus(),$(".result-container").is(".visuallyhidden")?($(".result-container").removeClass("visuallyhidden"),$(".result-container").parent().removeClass("hiding")):showTemporaryTimerOfPreviousShow(timeWastedInMinutes),!1})),$(".seasons").on("keyup change",(function(){0!==$(".select2-input").val().length&&hasSelectedShow&&0!==$(this).val().length&&showSubmitButton()})),$(".js-show-modal").on("click touchstart",(function(){return showModalWindow(),!1})),$(".about__content__inner").on("click touchstart",(function(e){e.stopPropagation()})),$(".about__content").on("click touchstart",(function(e){return hideModalWindow(),!1})),$(".reset-local-storage").on("click touchstart",(function(){return reset(),!1})),$(".container__list-of-shows").on("click touchstart",".js-remove-item",(function(){return $(this).parent().removeClass().addClass("remove-tv-show"),setTimeout((function(){$(".remove-tv-show").remove()}),200),timeWastedInMinutes=$(this).siblings(".container__list-of-shows__info").children(".container__list-of-shows__info__wasted-time.visuallyhidden").text(),(totalTimeWastedInMinutes-=timeWastedInMinutes)<=0&&(totalTimeWastedInMinutes=0),convertMinutes(totalTimeWastedInMinutes),save(totalTimeWastedInMinutes),1===$(".container__list-of-shows li").length&&($(".result-container").parent().addClass("hiding"),setTimeout((function(){$(".result-container").addClass("visuallyhidden")}),150)),showTemporaryTimerOfPreviousShow(timeWastedInMinutes,!0),!1}));