Files
zoff/js/yt-min.js
2014-12-30 06:24:08 +01:00

1 line
49 KiB
JavaScript

function admin(){adminTogg=!adminTogg;if(adminTogg)$("#playlist").height($("#playlist").height()-210);if(!adminTogg)setTimeout(function(){$("#playlist").height($("#playlist").height()+210)},501);$("#adminPanel").toggleClass("hiddenAdmin")}function submitAdmin(e){voting=e.vote.value,addsongs=e.addsongs.value,longsongs=e.longsongs.value,frontpage=e.frontpage.value,allvideos=e.allvideos.value,removeplay=e.removeplay.value,adminpass=e.pass.value;confRes=$.ajax({type:"POST",url:"php/change.php",async:false,data:"conf=start&vote="+voting+"&addsongs="+addsongs+"&longsongs="+longsongs+"&frontpage="+frontpage+"&allvideos="+allvideos+"&removeplay="+removeplay+"&pass="+adminpass,success:function(){console.log("configurations response: "+response)}}).responseText;pass_corr=confRes;if(pass_corr=="correct"){$("#adminPanel").addClass("success")}else{$("#adminPanel").addClass("fadeerror");alert("Wrong password :(")}console.log(pass_corr);updateList();setTimeout(function(){$("#adminPanel").removeClass("success");$("#adminPanel").removeClass("fadeerror")},1500)}function search(e){$("#results").html("");if(e!=""){var t=encodeURIComponent(e);var n="http://gdata.youtube.com/feeds/api/videos?q="+t+"&format=5&orderby=relevance&max-results=25&v=2&alt=jsonc";$.ajax({type:"GET",url:n,dataType:"jsonp",success:function(e){if(e.data.items){var t="";$.each(e.data.items,function(e,n){if(n.duration>720&&longS==0){return}if(n["category"]=="Music"||music==1){var r=encodeURIComponent(n.title).replace(/'/g,"\\'");var i=n.viewCount;var s="http://i.ytimg.com/vi/"+n.id+"/default.jpg";var o=Math.floor(n.duration/60)+":"+(n.duration-Math.floor(n.duration/60)*60);var u=" <div id='result' class='result' onclick=\"submitAndClose('"+n.id+"','"+r+"');\"> <img src='"+s+"' class='thumb'> <div id='title'>"+n.title+" <div class='result_info'>"+i+" views • "+o+"</div> <input id='add' title='Add several songs' type='button' class='button' value='+' onclick=\"submit('"+n.id+"','"+r+"');\"> </div> </div>";t+=u}});console.log(t);$("<div style='display:none;'>"+t+"</div>").appendTo("#results").slideDown("slow")}else{$("#video").html("<div id='no'>No Video</div>")}}})}}function submitAndClose(e,t){submit(e,t);$("#results").html("");console.log("sub&closed")}function submit(e,t){console.log($.ajax({type:"GET",url:"php/change.php",async:false,data:"v="+e+"&n="+t+"&pass="+adminpass,success:function(){console.log("added "+e);document.getElementById("search").value="";$("#search").addClass("success")},error:function(){console.log("error in adding");document.getElementById("search").value="";$("#search").addClass("error")}}).responseText);$("#search").focus();setTimeout(function(){$("#search").removeClass("success");$("#search").removeClass("error")},1500);updateList();event.stopPropagation()}function initYoutubeControls(e){if(e!=undefined){ytplayer=e;durationFixer=setInterval(durationSetter,1e3)}else{tag=document.createElement("script");tag.src="https://www.youtube.com/iframe_api";firstScriptTag=document.getElementsByTagName("script")[0];firstScriptTag.parentNode.insertBefore(tag,firstScriptTag)}elems=Array("volume","duration","fullscreen");var t=document.getElementById("controls");var n=document.createElement("div");n.id="playpause";n.className="play";t.appendChild(n);for(x=0;x<elems.length;x++){var n=document.createElement("div");n.id=elems[x];t.appendChild(n)}initControls();fitToScreen();$(window).resize(function(){fitToScreen()})}function initControls(){document.getElementById("playpause").addEventListener("click",playPause);document.getElementById("fullscreen").addEventListener("click",function(){document.getElementById("player").webkitRequestFullscreen()});var e=document.getElementsByClassName("qChange")}function fitToScreen(){document.getElementById("controls").style.top=document.getElementById("player").offsetTop+$("#player").height()+"px";document.getElementById("controls").style.left=document.getElementById("player").offsetLeft+"px"}function initSlider(){$("#volume").slider({min:0,max:100,value:ytplayer.getVolume(),range:"min",animate:true,slide:function(e,t){setVolume(t.value)}})}function settings(){$("#qS").toggleClass("hide")}function changeQuality(){wantedQ=this.getAttribute("name");if(ytplayer.getPlaybackQuality!=wantedQ){ytplayer.setPlaybackQuality(wantedQ)}}function setVolume(e){ytplayer.setVolume(e)}function playPause(){console.log("playPause");state=ytplayer.getPlayerState();console.log("state: "+state);button=document.getElementById("playpause");if(state==1){ytplayer.pauseVideo()}else if(state==2){ytplayer.playVideo()}}function durationSetter(){duration=ytplayer.getDuration();dMinutes=Math.floor(duration/60);dSeconds=duration-dMinutes*60;currDurr=ytplayer.getCurrentTime();minutes=Math.floor(currDurr/60);seconds=currDurr-minutes*60;document.getElementById("duration").innerHTML=pad(minutes)+":"+pad(seconds)+" <span id='dash'>/</span> "+pad(dMinutes)+":"+pad(dSeconds)}function pad(e){return e<10?"0"+Math.floor(e):Math.floor(e)}function volumeOptions(){console.log("volumeOptions");button=document.getElementById("volume");if(ytplayer.isMuted()){ytplayer.unMute();button.innerHTML="Mute"}else{ytplayer.mute();button.innerHTML="Unmute"}}function logQ(){console.log(ytplayer.getPlaybackQuality())}function updateList(){console.log("updating list");list=$.ajax({type:"GET",url:"php/change.php",async:false}).responseText;list=$.parseJSON(list);conf=list["conf"];if(conf.hasOwnProperty("addsongs")&&conf["addsongs"]=="true")adminadd=1;else adminadd=0;if(conf.hasOwnProperty("allvideos")&&conf["allvideos"]=="true")music=1;else music=0;if(conf.hasOwnProperty("longsongs")&&conf["longsongs"]=="true")longS=1;else longS=0;if(conf.hasOwnProperty("vote")&&conf["vote"]=="true")adminvote=1;else adminvote=0;if(conf.hasOwnProperty("adminpass")&&conf["adminpass"]!="")hasadmin=1;else hasadmin=0;setTimeout(function(){$("#wrapper").empty();$.each(list["songs"],function(e,t){var n=t["title"].replace(/\\\'/g,"'").replace(/&quot;/g,"'").replace(/&/g,"&");var r=t["id"];var i="http://i.ytimg.com/vi/"+r+"/mqdefault.jpg";var s="";if(e%2==0)s=" oddlist";var o="";if(pass_corr=="correct")o="<input id='del' title='Remove' type='button' class='button' value='X' onclick=\"vote('"+r+"','del')\">";var u="<div id='result' class='result lresult"+s+"'>"+"<img src='"+i+"' class='thumb lthumb'>"+"<div class='ltitle'>"+n+"</div>"+"<div class='votes'>"+t["votes"]+"<a onclick=\"vote('"+r+"','pos');\" id='plus'>+</a>"+"<a onclick=\"vote('"+r+"','neg');\" id='minus'>-</a>"+o+"</div>"+"</div>";$("#wrapper").append(u)});if($("#playlist").height()!=$("#player").height()){if(!window.mobilecheck()){$("#playlist").css({height:$("#player").height()-$("#adminPanel").outerHeight(true)+30});$("#playlist").css({overflow:"hidden"});if(scroller==false){myScroll=new IScroll("#playlist",{mouseWheel:true,scrollbars:false,scrollY:true,interactiveScrollbars:false});scroller=true}else{myScroll.refresh()}}}if(window.mobilecheck()){document.getElementById("player").style.display="none";ytplayer.pauseVideo()}else{myScroll.refresh()}if(!adminTogg){names=["vote","addsongs","longsongs","frontpage","allvideos","removeplay"];for(var e=0;e<names.length;e++){document.getElementsByName(names[e])[0].checked=conf[names[e]]==="true";document.getElementsByName(names[e])[1].checked=conf[names[e]]==="false"}if(hasadmin)$("#setpass").text("Channel has admin");else $("#setpass").text("Channel has no admin")}},2500)}function vote(e,t){console.log(adminpass);console.log($.ajax({type:"GET",url:"php/change.php",async:false,data:"vote="+t+"&id="+e+"&pass="+adminpass,success:function(){console.log("voted "+t+" on "+e);if(t=="pos"){$("#playlist").addClass("success")}else{$("#playlist").addClass("fadeerror")}updateList()}}).responseText);setTimeout(function(){$("#playlist").removeClass("success");$("#playlist").removeClass("fadeerror")},1500)}function skip(){console.log($.ajax({type:"GET",url:"php/change.php",async:false,data:"skip",success:function(){console.log("voted to skip song");$("#buttons").addClass("success");updateList()}}).responseText);setTimeout(function(){$("#playlist").removeClass("success")},1500)}function show(){if(showToggle){showToggle=false;$("#toptitle").empty();$("#chan").addClass("bigChan");$("#chan").html("zoff.no/"+chan)}else{showToggle=true;$("#toptitle").html("Zöff");$("#chan").removeClass("bigChan");$("#chan").html(chan)}}function ks(){list=$.ajax({type:"GET",url:"php/change.php",async:false}).responseText;list=$.parseJSON(list);myScroll.destroy();myScroll=null;$("#playlist").css({height:$("#player").height()});$("#playlist").css({overflow:"hidden"});myScroll=new IScroll("#playlist",{mouseWheel:true,scrollbars:false,scrollY:true,interactiveScrollbars:false});scroller=true}function onYouTubeIframeAPIReady(){ytplayer=new YT.Player("player",{height:window.height*.75,width:window.width*.6,videoId:response,playerVars:{rel:"0",wmode:"transparent",controls:"0",iv_load_policy:"3",theme:"light",rel:"0",color:"white"},events:{onReady:onPlayerReady,onStateChange:onPlayerStateChange,onError:errorHandler,onPlaybackQualityChange:logQ}})}function onPlayerStateChange(e){console.log("new state: "+e.data);console.log("beginning: "+beginning);if(e.data==0&&checkEnd()||e.data==1&&checkEnd()){console.log("nummer 1");startNextSong();ytplayer.pauseVideo();wasPaused=false}else if(e.data==1&&wasPaused&&!beginning){console.log("unpaused");beginning=false;wasPaused=false;syncInterval=setInterval(getTime,5e3);getTime()}else if(e.data==2){clearInterval(syncInterval);interval=true;wasPaused=true;beginning=false}if(e.data==1||e.data==2){activeButton=document.getElementById("playpause").className;console.log(activeButton);if(e.data==2&&activeButton=="pause"||e.data==1&&activeButton=="play"){$("#playpause").toggleClass("play");$("#playpause").toggleClass("pause")}}if(e.data==0){quickFixCountdown=setTimeout(function(){console.log("trying quickfix");if(ytplayer.getPlayerState()==0&&wasPaused){console.log("quickfixPlay");startNextSong();wasPaused=false}},5e3)}}function checkEnd(){console.log("sjekker om brukeren spolte");$.ajax({type:"get",url:"php/timedifference.php",data:"abcde",async:false,success:function(e){timeDifference=$.parseJSON(e)}});if(parseInt(timeDifference[0])>ytplayer.getDuration()){return true}return false}function startNextSong(){if(checkEnd()&&!changed){setTimeout(function(){response=$.ajax({type:"POST",url:"php/change.php",async:false,data:"thisUrl="+response+"&act=save",success:function(){console.log("saved song-switch - "+response)}}).responseText;console.log("next video: "+response);getTitle(response);if(!window.mobilecheck()){ytplayer.loadVideoById(response)}beginning=true;setBGimage(response)},2500);updateList();changed=true;setTimeout(function(){changed=false;syncInterval=setInterval(getTime,5e3);interval=true;console.log("starter intervallen. Interval: "+interval)},2500)}}function getTime(){console.log("utenfor if test"+wasPaused);if(ytplayer.getCurrentTime()>2&&ytplayer.getPlayerState()==1)wasPaused=false;if(!wasPaused){console.log("sjekker om brukeren spolte");$.ajax({type:"get",url:"php/timedifference.php",data:"abcde",async:false,success:function(e){timeDifference=$.parseJSON(e)}});console.log("current song: "+response);console.log("song in database: "+timeDifference[1]);if(parseInt(timeDifference[2])+1>ytplayer.getCurrentTime()+parseInt(timeDifference[3])&&ytplayer.getPlayerState()==0){return true}else if(ytplayer.getCurrentTime()+parseInt(timeDifference[3])>parseInt(timeDifference[2])+5||ytplayer.getCurrentTime()+parseInt(timeDifference[3])<parseInt(timeDifference[2])-5&&ytplayer.getPlayerState()!=0&&ytplayer.getPlayerState()!=3){if(parseInt(timeDifference[0])>ytplayer.getDuration()){console.log("burde ikke søke, men hoppe til neste sang")}ytplayer.seekTo(timeDifference[0]);ytplayer.pauseVideo();if(!window.mobilecheck()){ytplayer.playVideo()}getTitle();return false}if(response!=timeDifference[1]){clearInterval(syncInterval);console.log("forskjellige videoer!!");ytplayer.pauseVideo();if(!window.mobilecheck()){ytplayer.loadVideoById(timeDifference[1])}setBGimage(timeDifference[1]);setTimeout(function(){diffVideo=true;beginning=true;$.ajax({type:"POST",url:"php/change.php",async:false,data:"thisUrl=123abcprompeprompe&act=save",success:function(e){response=timeDifference[1];getTitle()}});syncInterval=setInterval(getTime,5e3)},2500)}}}function getTitle(){$.ajax({type:"GET",url:"php/timedifference.php",async:false,success:function(e){viewers=$.parseJSON(e);var t=viewers[5].length>1?"viewers":"viewer";var n=viewers[4].replace(/\\\'/g,"'").replace(/&quot;/g,"'").replace(/&/g,"&");document.title=n+" • Zöff";document.getElementsByName("v")[0].placeholder=n+" • "+viewers[5].length+" "+t}})}function errorHandler(e){setTimeout(function(){response=$.ajax({type:"POST",url:"php/change.php",async:false,data:"thisUrl="+response+"&act=empty",success:function(){console.log("error! deleted video")}}).responseText;if(!window.mobilecheck()){ytplayer.loadVideoById(response)}setBGimage(response)},2500)}function onPlayerReady(e){getTime();if(!window.mobilecheck()){ytplayer.playVideo()}initYoutubeControls(ytplayer);getTitle();setBGimage(response);initSlider()}function setBGimage(e){console.log("change background");if(window.mozInnerScreenX==null&&!window.mobilecheck()){$("#bgimage").css("background-image","url(http://img.youtube.com/vi/"+e+"/0.jpg)")}else if(window.mobilecheck()){$("#mobile-banner").css("background-image","url(http://img.youtube.com/vi/"+e+"/hqdefault.jpg)");$("#mobile-banner").css("width",$(window).width());console.log("on mobile")}}var adminTogg=false;var pass_corr="";var old_input="";var timer=0;$(document).ready(function(){$("#search").focus();$("#base").bind("keyup keypress",function(e){var t=e.keyCode||e.which;if(t==13){e.preventDefault();return false}});$(".search_input").focus();$(".search_input").keyup(function(e){var t=$(this).val();if(t.length<3){$("#results").html("")}if(e.keyCode==13){search(t)}else if(e.keyCode==27){$("#results").html("")}else{timer=100}});setInterval(function(){timer--;if(timer==0){search($(".search_input").val())}},1)});var list;var toSend="";var sendURL;var myScroll;var scroller=false;var showToggle=true;var chan=$("#chan").html();var hasadmin=0;(function(e,t,n){function s(e,n){this.wrapper=typeof e=="string"?t.querySelector(e):e;this.scroller=this.wrapper.children[0];this.scrollerStyle=this.scroller.style;this.options={resizeScrollbars:true,mouseWheelSpeed:20,snapThreshold:.334,startX:0,startY:0,scrollY:true,directionLockThreshold:5,momentum:true,bounce:true,bounceTime:600,bounceEasing:"",preventDefault:true,preventDefaultException:{tagName:/^(INPUT|TEXTAREA|BUTTON|SELECT)$/},HWCompositing:true,useTransition:true,useTransform:true};for(var r in n){this.options[r]=n[r]}this.translateZ=this.options.HWCompositing&&i.hasPerspective?" translateZ(0)":"";this.options.useTransition=i.hasTransition&&this.options.useTransition;this.options.useTransform=i.hasTransform&&this.options.useTransform;this.options.eventPassthrough=this.options.eventPassthrough===true?"vertical":this.options.eventPassthrough;this.options.preventDefault=!this.options.eventPassthrough&&this.options.preventDefault;this.options.scrollY=this.options.eventPassthrough=="vertical"?false:this.options.scrollY;this.options.scrollX=this.options.eventPassthrough=="horizontal"?false:this.options.scrollX;this.options.freeScroll=this.options.freeScroll&&!this.options.eventPassthrough;this.options.directionLockThreshold=this.options.eventPassthrough?0:this.options.directionLockThreshold;this.options.bounceEasing=typeof this.options.bounceEasing=="string"?i.ease[this.options.bounceEasing]||i.ease.circular:this.options.bounceEasing;this.options.resizePolling=this.options.resizePolling===undefined?60:this.options.resizePolling;if(this.options.tap===true){this.options.tap="tap"}if(this.options.shrinkScrollbars=="scale"){this.options.useTransition=false}this.options.invertWheelDirection=this.options.invertWheelDirection?-1:1;this.x=0;this.y=0;this.directionX=0;this.directionY=0;this._events={};this._init();this.refresh();this.scrollTo(this.options.startX,this.options.startY);this.enable()}function o(e,n,r){var i=t.createElement("div"),s=t.createElement("div");if(r===true){i.style.cssText="position:absolute;z-index:9999";s.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:absolute;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);border-radius:3px"}s.className="iScrollIndicator";if(e=="h"){if(r===true){i.style.cssText+=";height:7px;left:2px;right:2px;bottom:0";s.style.height="100%"}i.className="iScrollHorizontalScrollbar"}else{if(r===true){i.style.cssText+=";width:7px;bottom:2px;top:2px;right:1px";s.style.width="100%"}i.className="iScrollVerticalScrollbar"}i.style.cssText+=";overflow:hidden";if(!n){i.style.pointerEvents="none"}i.appendChild(s);return i}function u(n,r){this.wrapper=typeof r.el=="string"?t.querySelector(r.el):r.el;this.wrapperStyle=this.wrapper.style;this.indicator=this.wrapper.children[0];this.indicatorStyle=this.indicator.style;this.scroller=n;this.options={listenX:true,listenY:true,interactive:false,resize:true,defaultScrollbars:false,shrink:false,fade:false,speedRatioX:0,speedRatioY:0};for(var s in r){this.options[s]=r[s]}this.sizeRatioX=1;this.sizeRatioY=1;this.maxPosX=0;this.maxPosY=0;if(this.options.interactive){if(!this.options.disableTouch){i.addEvent(this.indicator,"touchstart",this);i.addEvent(e,"touchend",this)}if(!this.options.disablePointer){i.addEvent(this.indicator,i.prefixPointerEvent("pointerdown"),this);i.addEvent(e,i.prefixPointerEvent("pointerup"),this)}if(!this.options.disableMouse){i.addEvent(this.indicator,"mousedown",this);i.addEvent(e,"mouseup",this)}}if(this.options.fade){this.wrapperStyle[i.style.transform]=this.scroller.translateZ;this.wrapperStyle[i.style.transitionDuration]=i.isBadAndroid?"0.001s":"0ms";this.wrapperStyle.opacity="0"}}var r=e.requestAnimationFrame||e.webkitRequestAnimationFrame||e.mozRequestAnimationFrame||e.oRequestAnimationFrame||e.msRequestAnimationFrame||function(t){e.setTimeout(t,1e3/60)};var i=function(){function o(e){if(s===false)return false;if(s==="")return e;return s+e.charAt(0).toUpperCase()+e.substr(1)}var r={};var i=t.createElement("div").style;var s=function(){var e=["t","webkitT","MozT","msT","OT"],t,n=0,r=e.length;for(;n<r;n++){t=e[n]+"ransform";if(t in i)return e[n].substr(0,e[n].length-1)}return false}();r.getTime=Date.now||function(){return(new Date).getTime()};r.extend=function(e,t){for(var n in t){e[n]=t[n]}};r.addEvent=function(e,t,n,r){e.addEventListener(t,n,!!r)};r.removeEvent=function(e,t,n,r){e.removeEventListener(t,n,!!r)};r.prefixPointerEvent=function(t){return e.MSPointerEvent?"MSPointer"+t.charAt(9).toUpperCase()+t.substr(10):t};r.momentum=function(e,t,r,i,s,o){var u=e-t,a=n.abs(u)/r,f,l;o=o===undefined?6e-4:o;f=e+a*a/(2*o)*(u<0?-1:1);l=a/o;if(f<i){f=s?i-s/2.5*(a/8):i;u=n.abs(f-e);l=u/a}else if(f>0){f=s?s/2.5*(a/8):0;u=n.abs(e)+f;l=u/a}return{destination:n.round(f),duration:l}};var u=o("transform");r.extend(r,{hasTransform:u!==false,hasPerspective:o("perspective")in i,hasTouch:"ontouchstart"in e,hasPointer:e.PointerEvent||e.MSPointerEvent,hasTransition:o("transition")in i});r.isBadAndroid=/Android /.test(e.navigator.appVersion)&&!/Chrome\/\d/.test(e.navigator.appVersion);r.extend(r.style={},{transform:u,transitionTimingFunction:o("transitionTimingFunction"),transitionDuration:o("transitionDuration"),transitionDelay:o("transitionDelay"),transformOrigin:o("transformOrigin")});r.hasClass=function(e,t){var n=new RegExp("(^|\\s)"+t+"(\\s|$)");return n.test(e.className)};r.addClass=function(e,t){if(r.hasClass(e,t)){return}var n=e.className.split(" ");n.push(t);e.className=n.join(" ")};r.removeClass=function(e,t){if(!r.hasClass(e,t)){return}var n=new RegExp("(^|\\s)"+t+"(\\s|$)","g");e.className=e.className.replace(n," ")};r.offset=function(e){var t=-e.offsetLeft,n=-e.offsetTop;while(e=e.offsetParent){t-=e.offsetLeft;n-=e.offsetTop}return{left:t,top:n}};r.preventDefaultException=function(e,t){for(var n in t){if(t[n].test(e[n])){return true}}return false};r.extend(r.eventType={},{touchstart:1,touchmove:1,touchend:1,mousedown:2,mousemove:2,mouseup:2,pointerdown:3,pointermove:3,pointerup:3,MSPointerDown:3,MSPointerMove:3,MSPointerUp:3});r.extend(r.ease={},{quadratic:{style:"cubic-bezier(0.25, 0.46, 0.45, 0.94)",fn:function(e){return e*(2-e)}},circular:{style:"cubic-bezier(0.1, 0.57, 0.1, 1)",fn:function(e){return n.sqrt(1- --e*e)}},back:{style:"cubic-bezier(0.175, 0.885, 0.32, 1.275)",fn:function(e){var t=4;return(e=e-1)*e*((t+1)*e+t)+1}},bounce:{style:"",fn:function(e){if((e/=1)<1/2.75){return 7.5625*e*e}else if(e<2/2.75){return 7.5625*(e-=1.5/2.75)*e+.75}else if(e<2.5/2.75){return 7.5625*(e-=2.25/2.75)*e+.9375}else{return 7.5625*(e-=2.625/2.75)*e+.984375}}},elastic:{style:"",fn:function(e){var t=.22,r=.4;if(e===0){return 0}if(e==1){return 1}return r*n.pow(2,-10*e)*n.sin((e-t/4)*2*n.PI/t)+1}}});r.tap=function(e,n){var r=t.createEvent("Event");r.initEvent(n,true,true);r.pageX=e.pageX;r.pageY=e.pageY;e.target.dispatchEvent(r)};r.click=function(e){var n=e.target,r;if(!/(SELECT|INPUT|TEXTAREA)/i.test(n.tagName)){r=t.createEvent("MouseEvents");r.initMouseEvent("click",true,true,e.view,1,n.screenX,n.screenY,n.clientX,n.clientY,e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,0,null);r._constructed=true;n.dispatchEvent(r)}};return r}();s.prototype={version:"5.1.2",_init:function(){this._initEvents();if(this.options.scrollbars||this.options.indicators){this._initIndicators()}if(this.options.mouseWheel){this._initWheel()}if(this.options.snap){this._initSnap()}if(this.options.keyBindings){this._initKeys()}},destroy:function(){this._initEvents(true);this._execEvent("destroy")},_transitionEnd:function(e){if(e.target!=this.scroller||!this.isInTransition){return}this._transitionTime();if(!this.resetPosition(this.options.bounceTime)){this.isInTransition=false;this._execEvent("scrollEnd")}},_start:function(e){if(i.eventType[e.type]!=1){if(e.button!==0){return}}if(!this.enabled||this.initiated&&i.eventType[e.type]!==this.initiated){return}if(this.options.preventDefault&&!i.isBadAndroid&&!i.preventDefaultException(e.target,this.options.preventDefaultException)){e.preventDefault()}var t=e.touches?e.touches[0]:e,r;this.initiated=i.eventType[e.type];this.moved=false;this.distX=0;this.distY=0;this.directionX=0;this.directionY=0;this.directionLocked=0;this._transitionTime();this.startTime=i.getTime();if(this.options.useTransition&&this.isInTransition){this.isInTransition=false;r=this.getComputedPosition();this._translate(n.round(r.x),n.round(r.y));this._execEvent("scrollEnd")}else if(!this.options.useTransition&&this.isAnimating){this.isAnimating=false;this._execEvent("scrollEnd")}this.startX=this.x;this.startY=this.y;this.absStartX=this.x;this.absStartY=this.y;this.pointX=t.pageX;this.pointY=t.pageY;this._execEvent("beforeScrollStart")},_move:function(e){if(!this.enabled||i.eventType[e.type]!==this.initiated){return}if(this.options.preventDefault){e.preventDefault()}var t=e.touches?e.touches[0]:e,r=t.pageX-this.pointX,s=t.pageY-this.pointY,o=i.getTime(),u,a,f,l;this.pointX=t.pageX;this.pointY=t.pageY;this.distX+=r;this.distY+=s;f=n.abs(this.distX);l=n.abs(this.distY);if(o-this.endTime>300&&f<10&&l<10){return}if(!this.directionLocked&&!this.options.freeScroll){if(f>l+this.options.directionLockThreshold){this.directionLocked="h"}else if(l>=f+this.options.directionLockThreshold){this.directionLocked="v"}else{this.directionLocked="n"}}if(this.directionLocked=="h"){if(this.options.eventPassthrough=="vertical"){e.preventDefault()}else if(this.options.eventPassthrough=="horizontal"){this.initiated=false;return}s=0}else if(this.directionLocked=="v"){if(this.options.eventPassthrough=="horizontal"){e.preventDefault()}else if(this.options.eventPassthrough=="vertical"){this.initiated=false;return}r=0}r=this.hasHorizontalScroll?r:0;s=this.hasVerticalScroll?s:0;u=this.x+r;a=this.y+s;if(u>0||u<this.maxScrollX){u=this.options.bounce?this.x+r/3:u>0?0:this.maxScrollX}if(a>0||a<this.maxScrollY){a=this.options.bounce?this.y+s/3:a>0?0:this.maxScrollY}this.directionX=r>0?-1:r<0?1:0;this.directionY=s>0?-1:s<0?1:0;if(!this.moved){this._execEvent("scrollStart")}this.moved=true;this._translate(u,a);if(o-this.startTime>300){this.startTime=o;this.startX=this.x;this.startY=this.y}},_end:function(e){if(!this.enabled||i.eventType[e.type]!==this.initiated){return}if(this.options.preventDefault&&!i.preventDefaultException(e.target,this.options.preventDefaultException)){e.preventDefault()}var t=e.changedTouches?e.changedTouches[0]:e,r,s,o=i.getTime()-this.startTime,u=n.round(this.x),a=n.round(this.y),f=n.abs(u-this.startX),l=n.abs(a-this.startY),c=0,h="";this.isInTransition=0;this.initiated=0;this.endTime=i.getTime();if(this.resetPosition(this.options.bounceTime)){return}this.scrollTo(u,a);if(!this.moved){if(this.options.tap){i.tap(e,this.options.tap)}if(this.options.click){i.click(e)}this._execEvent("scrollCancel");return}if(this._events.flick&&o<200&&f<100&&l<100){this._execEvent("flick");return}if(this.options.momentum&&o<300){r=this.hasHorizontalScroll?i.momentum(this.x,this.startX,o,this.maxScrollX,this.options.bounce?this.wrapperWidth:0,this.options.deceleration):{destination:u,duration:0};s=this.hasVerticalScroll?i.momentum(this.y,this.startY,o,this.maxScrollY,this.options.bounce?this.wrapperHeight:0,this.options.deceleration):{destination:a,duration:0};u=r.destination;a=s.destination;c=n.max(r.duration,s.duration);this.isInTransition=1}if(this.options.snap){var p=this._nearestSnap(u,a);this.currentPage=p;c=this.options.snapSpeed||n.max(n.max(n.min(n.abs(u-p.x),1e3),n.min(n.abs(a-p.y),1e3)),300);u=p.x;a=p.y;this.directionX=0;this.directionY=0;h=this.options.bounceEasing}if(u!=this.x||a!=this.y){if(u>0||u<this.maxScrollX||a>0||a<this.maxScrollY){h=i.ease.quadratic}this.scrollTo(u,a,c,h);return}this._execEvent("scrollEnd")},_resize:function(){var e=this;clearTimeout(this.resizeTimeout);this.resizeTimeout=setTimeout(function(){e.refresh()},this.options.resizePolling)},resetPosition:function(e){var t=this.x,n=this.y;e=e||0;if(!this.hasHorizontalScroll||this.x>0){t=0}else if(this.x<this.maxScrollX){t=this.maxScrollX}if(!this.hasVerticalScroll||this.y>0){n=0}else if(this.y<this.maxScrollY){n=this.maxScrollY}if(t==this.x&&n==this.y){return false}this.scrollTo(t,n,e,this.options.bounceEasing);return true},disable:function(){this.enabled=false},enable:function(){this.enabled=true},refresh:function(){var e=this.wrapper.offsetHeight;this.wrapperWidth=this.wrapper.clientWidth;this.wrapperHeight=this.wrapper.clientHeight;this.scrollerWidth=this.scroller.offsetWidth;this.scrollerHeight=this.scroller.offsetHeight;this.maxScrollX=this.wrapperWidth-this.scrollerWidth;this.maxScrollY=this.wrapperHeight-this.scrollerHeight;this.hasHorizontalScroll=this.options.scrollX&&this.maxScrollX<0;this.hasVerticalScroll=this.options.scrollY&&this.maxScrollY<0;if(!this.hasHorizontalScroll){this.maxScrollX=0;this.scrollerWidth=this.wrapperWidth}if(!this.hasVerticalScroll){this.maxScrollY=0;this.scrollerHeight=this.wrapperHeight}this.endTime=0;this.directionX=0;this.directionY=0;this.wrapperOffset=i.offset(this.wrapper);this._execEvent("refresh");this.resetPosition()},on:function(e,t){if(!this._events[e]){this._events[e]=[]}this._events[e].push(t)},off:function(e,t){if(!this._events[e]){return}var n=this._events[e].indexOf(t);if(n>-1){this._events[e].splice(n,1)}},_execEvent:function(e){if(!this._events[e]){return}var t=0,n=this._events[e].length;if(!n){return}for(;t<n;t++){this._events[e][t].apply(this,[].slice.call(arguments,1))}},scrollBy:function(e,t,n,r){e=this.x+e;t=this.y+t;n=n||0;this.scrollTo(e,t,n,r)},scrollTo:function(e,t,n,r){r=r||i.ease.circular;this.isInTransition=this.options.useTransition&&n>0;if(!n||this.options.useTransition&&r.style){this._transitionTimingFunction(r.style);this._transitionTime(n);this._translate(e,t)}else{this._animate(e,t,n,r.fn)}},scrollToElement:function(e,t,r,s,o){e=e.nodeType?e:this.scroller.querySelector(e);if(!e){return}var u=i.offset(e);u.left-=this.wrapperOffset.left;u.top-=this.wrapperOffset.top;if(r===true){r=n.round(e.offsetWidth/2-this.wrapper.offsetWidth/2)}if(s===true){s=n.round(e.offsetHeight/2-this.wrapper.offsetHeight/2)}u.left-=r||0;u.top-=s||0;u.left=u.left>0?0:u.left<this.maxScrollX?this.maxScrollX:u.left;u.top=u.top>0?0:u.top<this.maxScrollY?this.maxScrollY:u.top;t=t===undefined||t===null||t==="auto"?n.max(n.abs(this.x-u.left),n.abs(this.y-u.top)):t;this.scrollTo(u.left,u.top,t,o)},_transitionTime:function(e){e=e||0;this.scrollerStyle[i.style.transitionDuration]=e+"ms";if(!e&&i.isBadAndroid){this.scrollerStyle[i.style.transitionDuration]="0.001s"}if(this.indicators){for(var t=this.indicators.length;t--;){this.indicators[t].transitionTime(e)}}},_transitionTimingFunction:function(e){this.scrollerStyle[i.style.transitionTimingFunction]=e;if(this.indicators){for(var t=this.indicators.length;t--;){this.indicators[t].transitionTimingFunction(e)}}},_translate:function(e,t){if(this.options.useTransform){this.scrollerStyle[i.style.transform]="translate("+e+"px,"+t+"px)"+this.translateZ}else{e=n.round(e);t=n.round(t);this.scrollerStyle.left=e+"px";this.scrollerStyle.top=t+"px"}this.x=e;this.y=t;if(this.indicators){for(var r=this.indicators.length;r--;){this.indicators[r].updatePosition()}}},_initEvents:function(t){var n=t?i.removeEvent:i.addEvent,r=this.options.bindToWrapper?this.wrapper:e;n(e,"orientationchange",this);n(e,"resize",this);if(this.options.click){n(this.wrapper,"click",this,true)}if(!this.options.disableMouse){n(this.wrapper,"mousedown",this);n(r,"mousemove",this);n(r,"mousecancel",this);n(r,"mouseup",this)}if(i.hasPointer&&!this.options.disablePointer){n(this.wrapper,i.prefixPointerEvent("pointerdown"),this);n(r,i.prefixPointerEvent("pointermove"),this);n(r,i.prefixPointerEvent("pointercancel"),this);n(r,i.prefixPointerEvent("pointerup"),this)}if(i.hasTouch&&!this.options.disableTouch){n(this.wrapper,"touchstart",this);n(r,"touchmove",this);n(r,"touchcancel",this);n(r,"touchend",this)}n(this.scroller,"transitionend",this);n(this.scroller,"webkitTransitionEnd",this);n(this.scroller,"oTransitionEnd",this);n(this.scroller,"MSTransitionEnd",this)},getComputedPosition:function(){var t=e.getComputedStyle(this.scroller,null),n,r;if(this.options.useTransform){t=t[i.style.transform].split(")")[0].split(", ");n=+(t[12]||t[4]);r=+(t[13]||t[5])}else{n=+t.left.replace(/[^-\d.]/g,"");r=+t.top.replace(/[^-\d.]/g,"")}return{x:n,y:r}},_initIndicators:function(){function a(e){for(var t=i.indicators.length;t--;){e.call(i.indicators[t])}}var e=this.options.interactiveScrollbars,t=typeof this.options.scrollbars!="string",n=[],r;var i=this;this.indicators=[];if(this.options.scrollbars){if(this.options.scrollY){r={el:o("v",e,this.options.scrollbars),interactive:e,defaultScrollbars:true,customStyle:t,resize:this.options.resizeScrollbars,shrink:this.options.shrinkScrollbars,fade:this.options.fadeScrollbars,listenX:false};this.wrapper.appendChild(r.el);n.push(r)}if(this.options.scrollX){r={el:o("h",e,this.options.scrollbars),interactive:e,defaultScrollbars:true,customStyle:t,resize:this.options.resizeScrollbars,shrink:this.options.shrinkScrollbars,fade:this.options.fadeScrollbars,listenY:false};this.wrapper.appendChild(r.el);n.push(r)}}if(this.options.indicators){n=n.concat(this.options.indicators)}for(var s=n.length;s--;){this.indicators.push(new u(this,n[s]))}if(this.options.fadeScrollbars){this.on("scrollEnd",function(){a(function(){this.fade()})});this.on("scrollCancel",function(){a(function(){this.fade()})});this.on("scrollStart",function(){a(function(){this.fade(1)})});this.on("beforeScrollStart",function(){a(function(){this.fade(1,true)})})}this.on("refresh",function(){a(function(){this.refresh()})});this.on("destroy",function(){a(function(){this.destroy()});delete this.indicators})},_initWheel:function(){i.addEvent(this.wrapper,"wheel",this);i.addEvent(this.wrapper,"mousewheel",this);i.addEvent(this.wrapper,"DOMMouseScroll",this);this.on("destroy",function(){i.removeEvent(this.wrapper,"wheel",this);i.removeEvent(this.wrapper,"mousewheel",this);i.removeEvent(this.wrapper,"DOMMouseScroll",this)})},_wheel:function(e){if(!this.enabled){return}e.preventDefault();e.stopPropagation();var t,r,i,s,o=this;if(this.wheelTimeout===undefined){o._execEvent("scrollStart")}clearTimeout(this.wheelTimeout);this.wheelTimeout=setTimeout(function(){o._execEvent("scrollEnd");o.wheelTimeout=undefined},400);if("deltaX"in e){t=-e.deltaX;r=-e.deltaY}else if("wheelDeltaX"in e){t=e.wheelDeltaX/120*this.options.mouseWheelSpeed;r=e.wheelDeltaY/120*this.options.mouseWheelSpeed}else if("wheelDelta"in e){t=r=e.wheelDelta/120*this.options.mouseWheelSpeed}else if("detail"in e){t=r=-e.detail/3*this.options.mouseWheelSpeed}else{return}t*=this.options.invertWheelDirection;r*=this.options.invertWheelDirection;if(!this.hasVerticalScroll){t=r;r=0}if(this.options.snap){i=this.currentPage.pageX;s=this.currentPage.pageY;if(t>0){i--}else if(t<0){i++}if(r>0){s--}else if(r<0){s++}this.goToPage(i,s);return}i=this.x+n.round(this.hasHorizontalScroll?t:0);s=this.y+n.round(this.hasVerticalScroll?r:0);if(i>0){i=0}else if(i<this.maxScrollX){i=this.maxScrollX}if(s>0){s=0}else if(s<this.maxScrollY){s=this.maxScrollY}this.scrollTo(i,s,0)},_initSnap:function(){this.currentPage={};if(typeof this.options.snap=="string"){this.options.snap=this.scroller.querySelectorAll(this.options.snap)}this.on("refresh",function(){var e=0,t,r=0,i,s,o,u=0,a,f=this.options.snapStepX||this.wrapperWidth,l=this.options.snapStepY||this.wrapperHeight,c;this.pages=[];if(!this.wrapperWidth||!this.wrapperHeight||!this.scrollerWidth||!this.scrollerHeight){return}if(this.options.snap===true){s=n.round(f/2);o=n.round(l/2);while(u>-this.scrollerWidth){this.pages[e]=[];t=0;a=0;while(a>-this.scrollerHeight){this.pages[e][t]={x:n.max(u,this.maxScrollX),y:n.max(a,this.maxScrollY),width:f,height:l,cx:u-s,cy:a-o};a-=l;t++}u-=f;e++}}else{c=this.options.snap;t=c.length;i=-1;for(;e<t;e++){if(e===0||c[e].offsetLeft<=c[e-1].offsetLeft){r=0;i++}if(!this.pages[r]){this.pages[r]=[]}u=n.max(-c[e].offsetLeft,this.maxScrollX);a=n.max(-c[e].offsetTop,this.maxScrollY);s=u-n.round(c[e].offsetWidth/2);o=a-n.round(c[e].offsetHeight/2);this.pages[r][i]={x:u,y:a,width:c[e].offsetWidth,height:c[e].offsetHeight,cx:s,cy:o};if(u>this.maxScrollX){r++}}}this.goToPage(this.currentPage.pageX||0,this.currentPage.pageY||0,0);if(this.options.snapThreshold%1===0){this.snapThresholdX=this.options.snapThreshold;this.snapThresholdY=this.options.snapThreshold}else{this.snapThresholdX=n.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width*this.options.snapThreshold);this.snapThresholdY=n.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height*this.options.snapThreshold)}});this.on("flick",function(){var e=this.options.snapSpeed||n.max(n.max(n.min(n.abs(this.x-this.startX),1e3),n.min(n.abs(this.y-this.startY),1e3)),300);this.goToPage(this.currentPage.pageX+this.directionX,this.currentPage.pageY+this.directionY,e)})},_nearestSnap:function(e,t){if(!this.pages.length){return{x:0,y:0,pageX:0,pageY:0}}var r=0,i=this.pages.length,s=0;if(n.abs(e-this.absStartX)<this.snapThresholdX&&n.abs(t-this.absStartY)<this.snapThresholdY){return this.currentPage}if(e>0){e=0}else if(e<this.maxScrollX){e=this.maxScrollX}if(t>0){t=0}else if(t<this.maxScrollY){t=this.maxScrollY}for(;r<i;r++){if(e>=this.pages[r][0].cx){e=this.pages[r][0].x;break}}i=this.pages[r].length;for(;s<i;s++){if(t>=this.pages[0][s].cy){t=this.pages[0][s].y;break}}if(r==this.currentPage.pageX){r+=this.directionX;if(r<0){r=0}else if(r>=this.pages.length){r=this.pages.length-1}e=this.pages[r][0].x}if(s==this.currentPage.pageY){s+=this.directionY;if(s<0){s=0}else if(s>=this.pages[0].length){s=this.pages[0].length-1}t=this.pages[0][s].y}return{x:e,y:t,pageX:r,pageY:s}},goToPage:function(e,t,r,i){i=i||this.options.bounceEasing;if(e>=this.pages.length){e=this.pages.length-1}else if(e<0){e=0}if(t>=this.pages[e].length){t=this.pages[e].length-1}else if(t<0){t=0}var s=this.pages[e][t].x,o=this.pages[e][t].y;r=r===undefined?this.options.snapSpeed||n.max(n.max(n.min(n.abs(s-this.x),1e3),n.min(n.abs(o-this.y),1e3)),300):r;this.currentPage={x:s,y:o,pageX:e,pageY:t};this.scrollTo(s,o,r,i)},next:function(e,t){var n=this.currentPage.pageX,r=this.currentPage.pageY;n++;if(n>=this.pages.length&&this.hasVerticalScroll){n=0;r++}this.goToPage(n,r,e,t)},prev:function(e,t){var n=this.currentPage.pageX,r=this.currentPage.pageY;n--;if(n<0&&this.hasVerticalScroll){n=0;r--}this.goToPage(n,r,e,t)},_initKeys:function(t){var n={pageUp:33,pageDown:34,end:35,home:36,left:37,up:38,right:39,down:40};var r;if(typeof this.options.keyBindings=="object"){for(r in this.options.keyBindings){if(typeof this.options.keyBindings[r]=="string"){this.options.keyBindings[r]=this.options.keyBindings[r].toUpperCase().charCodeAt(0)}}}else{this.options.keyBindings={}}for(r in n){this.options.keyBindings[r]=this.options.keyBindings[r]||n[r]}i.addEvent(e,"keydown",this);this.on("destroy",function(){i.removeEvent(e,"keydown",this)})},_key:function(e){if(!this.enabled){return}var t=this.options.snap,r=t?this.currentPage.pageX:this.x,s=t?this.currentPage.pageY:this.y,o=i.getTime(),u=this.keyTime||0,a=.25,f;if(this.options.useTransition&&this.isInTransition){f=this.getComputedPosition();this._translate(n.round(f.x),n.round(f.y));this.isInTransition=false}this.keyAcceleration=o-u<200?n.min(this.keyAcceleration+a,50):0;switch(e.keyCode){case this.options.keyBindings.pageUp:if(this.hasHorizontalScroll&&!this.hasVerticalScroll){r+=t?1:this.wrapperWidth}else{s+=t?1:this.wrapperHeight}break;case this.options.keyBindings.pageDown:if(this.hasHorizontalScroll&&!this.hasVerticalScroll){r-=t?1:this.wrapperWidth}else{s-=t?1:this.wrapperHeight}break;case this.options.keyBindings.end:r=t?this.pages.length-1:this.maxScrollX;s=t?this.pages[0].length-1:this.maxScrollY;break;case this.options.keyBindings.home:r=0;s=0;break;case this.options.keyBindings.left:r+=t?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.up:s+=t?1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.right:r-=t?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.down:s-=t?1:5+this.keyAcceleration>>0;break;default:return}if(t){this.goToPage(r,s);return}if(r>0){r=0;this.keyAcceleration=0}else if(r<this.maxScrollX){r=this.maxScrollX;this.keyAcceleration=0}if(s>0){s=0;this.keyAcceleration=0}else if(s<this.maxScrollY){s=this.maxScrollY;this.keyAcceleration=0}this.scrollTo(r,s,0);this.keyTime=o},_animate:function(e,t,n,s){function c(){var h=i.getTime(),p,d,v;if(h>=l){o.isAnimating=false;o._translate(e,t);if(!o.resetPosition(o.options.bounceTime)){o._execEvent("scrollEnd")}return}h=(h-f)/n;v=s(h);p=(e-u)*v+u;d=(t-a)*v+a;o._translate(p,d);if(o.isAnimating){r(c)}}var o=this,u=this.x,a=this.y,f=i.getTime(),l=f+n;this.isAnimating=true;c()},handleEvent:function(e){switch(e.type){case"touchstart":case"pointerdown":case"MSPointerDown":case"mousedown":this._start(e);break;case"touchmove":case"pointermove":case"MSPointerMove":case"mousemove":this._move(e);break;case"touchend":case"pointerup":case"MSPointerUp":case"mouseup":case"touchcancel":case"pointercancel":case"MSPointerCancel":case"mousecancel":this._end(e);break;case"orientationchange":case"resize":this._resize();break;case"transitionend":case"webkitTransitionEnd":case"oTransitionEnd":case"MSTransitionEnd":this._transitionEnd(e);break;case"wheel":case"DOMMouseScroll":case"mousewheel":this._wheel(e);break;case"keydown":this._key(e);break;case"click":if(!e._constructed){e.preventDefault();e.stopPropagation()}break}}};u.prototype={handleEvent:function(e){switch(e.type){case"touchstart":case"pointerdown":case"MSPointerDown":case"mousedown":this._start(e);break;case"touchmove":case"pointermove":case"MSPointerMove":case"mousemove":this._move(e);break;case"touchend":case"pointerup":case"MSPointerUp":case"mouseup":case"touchcancel":case"pointercancel":case"MSPointerCancel":case"mousecancel":this._end(e);break}},destroy:function(){if(this.options.interactive){i.removeEvent(this.indicator,"touchstart",this);i.removeEvent(this.indicator,i.prefixPointerEvent("pointerdown"),this);i.removeEvent(this.indicator,"mousedown",this);i.removeEvent(e,"touchmove",this);i.removeEvent(e,i.prefixPointerEvent("pointermove"),this);i.removeEvent(e,"mousemove",this);i.removeEvent(e,"touchend",this);i.removeEvent(e,i.prefixPointerEvent("pointerup"),this);i.removeEvent(e,"mouseup",this)}if(this.options.defaultScrollbars){this.wrapper.parentNode.removeChild(this.wrapper)}},_start:function(t){var n=t.touches?t.touches[0]:t;t.preventDefault();t.stopPropagation();this.transitionTime();this.initiated=true;this.moved=false;this.lastPointX=n.pageX;this.lastPointY=n.pageY;this.startTime=i.getTime();if(!this.options.disableTouch){i.addEvent(e,"touchmove",this)}if(!this.options.disablePointer){i.addEvent(e,i.prefixPointerEvent("pointermove"),this)}if(!this.options.disableMouse){i.addEvent(e,"mousemove",this)}this.scroller._execEvent("beforeScrollStart")},_move:function(e){var t=e.touches?e.touches[0]:e,n,r,s,o,u=i.getTime();if(!this.moved){this.scroller._execEvent("scrollStart")}this.moved=true;n=t.pageX-this.lastPointX;this.lastPointX=t.pageX;r=t.pageY-this.lastPointY;this.lastPointY=t.pageY;s=this.x+n;o=this.y+r;this._pos(s,o);e.preventDefault();e.stopPropagation()},_end:function(t){if(!this.initiated){return}this.initiated=false;t.preventDefault();t.stopPropagation();i.removeEvent(e,"touchmove",this);i.removeEvent(e,i.prefixPointerEvent("pointermove"),this);i.removeEvent(e,"mousemove",this);if(this.scroller.options.snap){var r=this.scroller._nearestSnap(this.scroller.x,this.scroller.y);var s=this.options.snapSpeed||n.max(n.max(n.min(n.abs(this.scroller.x-r.x),1e3),n.min(n.abs(this.scroller.y-r.y),1e3)),300);if(this.scroller.x!=r.x||this.scroller.y!=r.y){this.scroller.directionX=0;this.scroller.directionY=0;this.scroller.currentPage=r;this.scroller.scrollTo(r.x,r.y,s,this.scroller.options.bounceEasing)}}if(this.moved){this.scroller._execEvent("scrollEnd")}},transitionTime:function(e){e=e||0;this.indicatorStyle[i.style.transitionDuration]=e+"ms";if(!e&&i.isBadAndroid){this.indicatorStyle[i.style.transitionDuration]="0.001s"}},transitionTimingFunction:function(e){this.indicatorStyle[i.style.transitionTimingFunction]=e},refresh:function(){this.transitionTime();if(this.options.listenX&&!this.options.listenY){this.indicatorStyle.display=this.scroller.hasHorizontalScroll?"block":"none"}else if(this.options.listenY&&!this.options.listenX){this.indicatorStyle.display=this.scroller.hasVerticalScroll?"block":"none"}else{this.indicatorStyle.display=this.scroller.hasHorizontalScroll||this.scroller.hasVerticalScroll?"block":"none"}if(this.scroller.hasHorizontalScroll&&this.scroller.hasVerticalScroll){i.addClass(this.wrapper,"iScrollBothScrollbars");i.removeClass(this.wrapper,"iScrollLoneScrollbar");if(this.options.defaultScrollbars&&this.options.customStyle){if(this.options.listenX){this.wrapper.style.right="8px"}else{this.wrapper.style.bottom="8px"}}}else{i.removeClass(this.wrapper,"iScrollBothScrollbars");i.addClass(this.wrapper,"iScrollLoneScrollbar");if(this.options.defaultScrollbars&&this.options.customStyle){if(this.options.listenX){this.wrapper.style.right="2px"}else{this.wrapper.style.bottom="2px"}}}var e=this.wrapper.offsetHeight;if(this.options.listenX){this.wrapperWidth=this.wrapper.clientWidth;if(this.options.resize){this.indicatorWidth=n.max(n.round(this.wrapperWidth*this.wrapperWidth/(this.scroller.scrollerWidth||this.wrapperWidth||1)),8);this.indicatorStyle.width=this.indicatorWidth+"px"}else{this.indicatorWidth=this.indicator.clientWidth}this.maxPosX=this.wrapperWidth-this.indicatorWidth;if(this.options.shrink=="clip"){this.minBoundaryX=-this.indicatorWidth+8;this.maxBoundaryX=this.wrapperWidth-8}else{this.minBoundaryX=0;this.maxBoundaryX=this.maxPosX}this.sizeRatioX=this.options.speedRatioX||this.scroller.maxScrollX&&this.maxPosX/this.scroller.maxScrollX}if(this.options.listenY){this.wrapperHeight=this.wrapper.clientHeight;if(this.options.resize){this.indicatorHeight=n.max(n.round(this.wrapperHeight*this.wrapperHeight/(this.scroller.scrollerHeight||this.wrapperHeight||1)),8);this.indicatorStyle.height=this.indicatorHeight+"px"}else{this.indicatorHeight=this.indicator.clientHeight}this.maxPosY=this.wrapperHeight-this.indicatorHeight;if(this.options.shrink=="clip"){this.minBoundaryY=-this.indicatorHeight+8;this.maxBoundaryY=this.wrapperHeight-8}else{this.minBoundaryY=0;this.maxBoundaryY=this.maxPosY}this.maxPosY=this.wrapperHeight-this.indicatorHeight;this.sizeRatioY=this.options.speedRatioY||this.scroller.maxScrollY&&this.maxPosY/this.scroller.maxScrollY}this.updatePosition()},updatePosition:function(){var e=this.options.listenX&&n.round(this.sizeRatioX*this.scroller.x)||0,t=this.options.listenY&&n.round(this.sizeRatioY*this.scroller.y)||0;if(!this.options.ignoreBoundaries){if(e<this.minBoundaryX){if(this.options.shrink=="scale"){this.width=n.max(this.indicatorWidth+e,8);this.indicatorStyle.width=this.width+"px"}e=this.minBoundaryX}else if(e>this.maxBoundaryX){if(this.options.shrink=="scale"){this.width=n.max(this.indicatorWidth-(e-this.maxPosX),8);this.indicatorStyle.width=this.width+"px";e=this.maxPosX+this.indicatorWidth-this.width}else{e=this.maxBoundaryX}}else if(this.options.shrink=="scale"&&this.width!=this.indicatorWidth){this.width=this.indicatorWidth;this.indicatorStyle.width=this.width+"px"}if(t<this.minBoundaryY){if(this.options.shrink=="scale"){this.height=n.max(this.indicatorHeight+t*3,8);this.indicatorStyle.height=this.height+"px"}t=this.minBoundaryY}else if(t>this.maxBoundaryY){if(this.options.shrink=="scale"){this.height=n.max(this.indicatorHeight-(t-this.maxPosY)*3,8);this.indicatorStyle.height=this.height+"px";t=this.maxPosY+this.indicatorHeight-this.height}else{t=this.maxBoundaryY}}else if(this.options.shrink=="scale"&&this.height!=this.indicatorHeight){this.height=this.indicatorHeight;this.indicatorStyle.height=this.height+"px"}}this.x=e;this.y=t;if(this.scroller.options.useTransform){this.indicatorStyle[i.style.transform]="translate("+e+"px,"+t+"px)"+this.scroller.translateZ}else{this.indicatorStyle.left=e+"px";this.indicatorStyle.top=t+"px"}},_pos:function(e,t){if(e<0){e=0}else if(e>this.maxPosX){e=this.maxPosX}if(t<0){t=0}else if(t>this.maxPosY){t=this.maxPosY}e=this.options.listenX?n.round(e/this.sizeRatioX):this.scroller.x;t=this.options.listenY?n.round(t/this.sizeRatioY):this.scroller.y;this.scroller.scrollTo(e,t)},fade:function(e,t){if(t&&!this.visible){return}clearTimeout(this.fadeTimeout);this.fadeTimeout=null;var n=e?250:500,r=e?0:300;e=e?"1":"0";this.wrapperStyle[i.style.transitionDuration]=n+"ms";this.fadeTimeout=setTimeout(function(e){this.wrapperStyle.opacity=e;this.visible=+e}.bind(this,e),r)}};s.utils=i;if(typeof module!="undefined"&&module.exports){module.exports=s}else{e.IScroll=s}})(window,document,Math);var timeDifference;var wasPaused;var beginning;var diffVideo;var serverTime;var url;var response;var url;var tag;var firstScriptTag;var ytplayer;var syncInterval;var title;var interval;var viewers;var video_id;var changed=false;var conf=[];var adminvote=0;var adminadd=0;var adminskip=0;var music=0;var longS=0;var frontpage=1;var adminpass="";$(document).ready(function(){window.mobilecheck=function(){var e=false;(function(t){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4)))e=true})(navigator.userAgent||navigator.vendor||window.opera);return e};updateList();timeDifference;wasPaused=false;beginning=true;diffVideo=false;interval=false;response=$.ajax({type:"GET",url:"php/change.php",async:false}).responseText;response=$.parseJSON(response);console.log(response["nowPlaying"].length);conf=response["conf"];console.log(conf);try{for(first in response["nowPlaying"])break;console.log(first);response=first}catch(e){response="1"}$.ajax({type:"get",url:"php/timedifference.php",data:"abcde",async:false,success:function(e){timeDifference=$.parseJSON(e)}});console.log("timediff:"+timeDifference[0]);tag=document.createElement("script");tag.src="https://www.youtube.com/iframe_api";firstScriptTag=document.getElementsByTagName("script")[0];firstScriptTag.parentNode.insertBefore(tag,firstScriptTag);if(!window.mobilecheck()){syncInterval=setInterval(getTime,5e4);listInterval=setInterval(updateList,5e4);document.getElementById("search").blur()}else{syncInterval=setInterval(getTime,5e3);listInterval=setInterval(updateList,1e4)}})