var Shoutbox={s:{idle:"idle",fetching:"fetching",sending:"sending",remove:"remove"},lastPost:"",last:0,state:"idle",mod:0,rank:0,init:function(e,t,s){Shoutbox.last=e,Shoutbox.rank=s,Shoutbox.mod=t,Shoutbox.timeout1=setTimeout(Shoutbox.updatePosts,5e3),Shoutbox.timeout2=setTimeout(Shoutbox.updateUser,6e4),$("#shoutbox").on("submit","form",Shoutbox.send),$("#shoutbox").on("keydown","#sbMsg",Shoutbox.checkEnter),$("#shoutbox #smileys img").bind("click",Shoutbox.addSmiley),t&&(Shoutbox.makeDraggable(),$("#sbPosts").on("click","dt a[data-delete]",function(e){e.preventDefault(),Shoutbox.deletePost($(this).data("delete"))}),$("#sbPosts").on("click","dt a[data-mute]",function(e){e.preventDefault(),Shoutbox.mute($(this).data("mute"))}))},makeDraggable:function(){$(document).ready(function(){$("#sbUser li").draggable({containment:"#sbUser",helper:"clone",snap:"#sbMute",revert:!1,zIndex:1e3}),$("#sbMute").droppable({accept:"#sbUser li",drop:function(e,t){Shoutbox.mute($("a:first-child",t.draggable).text())}})})},updatePosts:function(){Shoutbox.state==Shoutbox.s.idle?(Shoutbox.state=Shoutbox.s.fetching,$("#sbState").html("Lade Posts..."),Shoutbox.ajax=$.ajax({url:"ajax/sb-posts.php",data:{last:Shoutbox.last},type:"post",dataType:"json",success:function(e){Shoutbox.last=void 0===e.last||0==e.last?Shoutbox.last:parseInt(e.last),Shoutbox.addPosts(e.posts),Shoutbox.state=Shoutbox.s.idle,$("#sbState").empty(),Shoutbox.timeout1=setTimeout(function(){Shoutbox.updatePosts()},5e3)}})):Shoutbox.timeout1=setTimeout(function(){Shoutbox.updatePosts()},1e3)},addPosts:function(e){$.each(e,function(e,t){var s=t.text.replace(/(http(s)?\:\/\/([0-9a-zA-Z\.\/\?\&\#\-\_\!\+\~\,\;\:\|\=\%]+))/,"$3","g");s=Shoutbox.parseSmileys(s),1==Shoutbox.mod?$("#sbPosts").prepend(Tools.mkStr('
$1 
$4
',[t.user,t.rank,t.time,s,t.id])):$("#sbPosts").prepend(Tools.mkStr('
$1 
$4
',[t.user,t.rank,t.time,s]))})},send:function(){if(Shoutbox.state==Shoutbox.s.idle||Shoutbox.state==Shoutbox.s.fetching){var e=$.trim($("#sbMsg").val());0!=e.length&&(Shoutbox.state==Shoutbox.s.fetching&&Shoutbox.ajax.abort(),Shoutbox.state=Shoutbox.s.sending,2<=e.length?(e=encodeURIComponent(e),$("#sbState").html("Sende Post..."),e!=Shoutbox.lastPost?(Shoutbox.lastPost=e,Shoutbox.ajax=$.ajax({url:"ajax/sb-send.php",data:{last:Shoutbox.last,text:e},type:"POST",dataType:"JSON",success:function(e){Shoutbox.last=void 0===e.last||0==e.last?Shoutbox.last:parseInt(e.last),Shoutbox.state=Shoutbox.s.idle,e.success?($("#sbMsg").val(""),$("#sbState").html("Gespeichert."),Shoutbox.addPosts(e.posts)):($("#sbState").html(Tools.mkStr('$1',[e.msg])),Shoutbox.lastPost=null)}})):($("#sbMsg").val(""),$("#sbState").html("Doppelpost"),Shoutbox.state=Shoutbox.s.idle)):($("#sbState").html("Dein Text sollte mindestens 2 Zeichen haben."),Shoutbox.state=Shoutbox.s.idle))}else Shoutbox.state==Shoutbox.s.sending&&$("#sbState").html("Es wird bereits ein Post gesendet!");return clearTimeout(Shoutbox.timeout1),Shoutbox.timeout1=setTimeout(Shoutbox.updatePosts,5e3),!1},updateUser:function(){Shoutbox.state==Shoutbox.s.idle?($("#sbState").html("Update Online Users..."),Shoutbox.state=Shoutbox.s.fetching,$.ajax({url:"ajax/sb-user.php",type:"post",dataType:"json",success:function(e){$("section#shoutbox div#sbUser > ul").html(""),e.success?($.each(e.user,function(e,t){var s="";1==Shoutbox.mod&&t.muted&&(s=' style="opacity: .6;" title="Muted bis: '+t.muted+'"'),$("section#shoutbox div#sbUser > ul").append(Tools.mkStr('
  • $1
  • ',[t.user,t.rank,s]))}),$("#sbState").empty(),$("div#sbUser > div:first-child > em").html(e.user.length||0),Shoutbox.mod&&Shoutbox.makeDraggable()):$("#sbMsg").html(e.msg)}}),Shoutbox.state=Shoutbox.s.idle,Shoutbox.timeout2=setTimeout(function(){Shoutbox.updateUser()},6e4)):Shoutbox.timeout2=setTimeout(function(){Shoutbox.updateUser()},5e3)},deletePost:function(t){$.ajax({url:"ajax/sb-delete.php",type:"POST",data:{id:t},success:function(e){e.success?($("#sbState").html("Post gelöscht."),$('[data-id="'+t+'"]').hide(200)):$("#sbState").html("Fehler beim Löschen")}})},mute:function(t){var e,s=1/0;switch(Shoutbox.rank){case 0:case 1:return;case 2:case 3:s=12}e=s!=1/0?" (Maximum: "+s+"h)":" (-1: Für immer)";var a=prompt("Für wie viele Stunden willst du den User "+t+" muten? 0: Entmuten"+e,"1");null!==a&&(a=parseInt(a),isNaN(a)||s")}),s},addSmiley:function(){var e=$(this).attr("title");elem=document.getElementById("sbMsg"),elem.focus(),document.selection?document.selection.createRange().text=" "+e+" ":window.getSelection?elem.value=elem.value.slice(0,elem.selectionStart)+" "+e+" "+elem.value.slice(elem.selectionEnd,elem.textLength):elem.value+=" "+e+" "}},home={modules:{},init:function(){$(document).ready(function(){home.reload(),setInterval(home.reload,6e4)})},reload:function(){$("#home_loader").show(),$.ajax({url:"ajax/reload-modules.php",type:"POST",dataType:"json",data:home.modules,success:home.gen})},add:function(e){this.modules[e]=!0},gen:function(e){function t(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0}null!=e&&(void 0!==e.defect&&($(".home #defect > div ul").html(""),t(e.defect)?$(".home #defect > div").html("Keine Defektmeldungen verfügbar"):($(".home #defect > div").html(""),$.each(e.defect,function(e,t){$(".home #defect > div ul").prepend(Tools.mkStr('
  •  $7 (S$2E$3)($8)
  • ',[t.seriesUrl,t.season,t.epi,t.epiUrl,t.lang,t.hoster,t.series,t.class]))}))),void 0!==e.descriptions&&($(".home #new_descriptions > div").empty(),0==e.descriptions.series?$(".home #new_descriptions > div").append("Keine neuen Serienbeschreibungen verfügbar"):$(".home #new_descriptions > div").append(Tools.mkStr('$1 neue Serienbeschreibung$2',[e.descriptions.series,1 div").append("Keine neuen Episodenbeschreibungen verfügbar"):$(".home #new_descriptions > div").append(Tools.mkStr('$1 neue Episodenbeschreibung$2',[e.descriptions.episodes,1 div").html("Keine neuen Cover verfügbar"):($(".home #covers > div").html("
      "),$.each(e.cover,function(e,t){$(".home #covers > div ul").prepend(Tools.mkStr('
    • Serie: $2$3
      Cover nicht verfügbar
      durch $4
      Akzeptieren · Ablehnen
    • ',[t.surl,t.series,t.file?" (Cover vorhanden!)":"",t.user,t.sid,t.rand]))}))),void 0!==e.prop_series&&(t(e.prop_series)?$(".home #proposals > div").html("Keine neuen Serienvorschläge verfügbar"):($(".home #proposals > div").html("
        "),$.each(e.prop_series,function(e,t){$(".home #proposals > div ul").prepend(Tools.mkStr('
      • $3 (durch $2) 
      • ',[t.url,t.user,t.name,t.id]))})))),$("#home_loader").hide()}},series={drag:{containment:"section.serie div.infos",snap:"#rubbish",revert:"invalid"},init:function(e,t,s){$(document).ready(function(){$(".serie #sp_right img").on("error",function(){$(this).attr("src","/public/images/default-cover.jpg")}),0<$("select.series-language option").length&&(1==$("select.series-language option").length&&$("select.series-language").addClass("disabled"),$("select.series-language").niceSelect(),$("div.series-language > ul li").bind("click",function(){if(!$(this).hasClass("selected")){var e=window.location.pathname.match(/^(\/serie)(\/[0-9A-Za-z\-]+)(\/[0-9]+)?(\/[0-9]+-[0-9a-zA-Z\-]+)?(\/[a-z]{2,3})?(\/.*)?$/);e[0]=null,e[5]="/"+$(this).data("value"),/watch\:|delete\:|undefect\:/i.test(e[6])&&(e[6]=null),window.location.pathname=e.join("")}})),0<$("#seasons").length&&$("#seasons").sly({horizontal:!0,itemNav:"centered",mouseDragging:!0,touchDragging:!0,dynamicHandle:!0,dragHandle:!0,clickBar:!0,speed:250,startAt:$("#seasons").find("li.s"+e).index(),scrollBar:$("#seasons").parent().find(".scrollbar"),scrollBy:1}),0<$("#episodes").length&&($("#episodes").sly({horizontal:!0,itemNav:"centered",mouseDragging:!0,touchDragging:!0,dynamicHandle:!0,dragHandle:!0,clickBar:!0,speed:250,startAt:$("#episodes").find("li.e"+t).index(),scrollBar:$("#episodes").parent().find(".scrollbar"),scrollBy:1}),$("#episodes > ul li").on("mouseenter",function(){$(".slider .epiInfo").hide();var e=parseInt($(this).find("a").html());if(0'+e.link+"").appendTo("section.serie .hoster-player"),window.open(e.link,"_blank");break;case"1":$("section.serie .hoster-player").html('')}else $("section.serie .hoster-player .loading").hide(),$("section.serie .hoster-player h2").html("Ein unbekannter Fehler ist aufgetreten.
        Versuche es später erneut.")},error:function(){$("section.serie .hoster-player .loading").hide(),$("section.serie .hoster-player").css("cursor","default").unbind("click"),$("section.serie .hoster-player h2").html("Ein unbekannter Fehler ist aufgetreten.
        Versuche es später erneut.")}})}$(this).find("h2").removeClass("bounce").html("Dein Stream wird vorbereitet…"),$(this).find(".play").hide(),$(this).find(".loading").show(),0 div > p > span:not(.no-entry)").draggable(series.drag),$("#rubbish").droppable({accept:"div.infos > div > p > span",drop:function(e,t){$.ajax({url:"ajax/delete-role.php",type:"POST",dataType:"JSON",data:{id:t.draggable.data("id"),t:t.draggable.data("t"),sid:$(this).data("sid")},success:function(e){e.success?(t.draggable.hide(200),t.draggable.remove()):alert(e.hasOwnProperty("error")?e.error:"Aktion nicht erfolgreich")}})}}),$("#hidden_series").on("click",function(){$(this).attr("disabled",!0);var t=this;$.ajax({url:"ajax/hide-series.php",data:{hidden:$(t).prop("checked"),sid:$(t).data("sid")},type:"POST",dataType:"JSON",success:function(e){$(t).attr("disabled",!1),e.success||alert(e.hasOwnProperty("error")?e.error:"Aktion nicht erfolgreich")}})}),$("#locked_series").on("click",function(){$(this).attr("disabled",!0);var t=this;$.ajax({url:"ajax/lock-series.php",data:{locked:$(t).prop("checked"),sid:$(t).data("sid")},type:"POST",dataType:"JSON",success:function(e){$(t).attr("disabled",!1),e.success||alert(e.hasOwnProperty("error")?e.error:"Aktion nicht erfolgreich")}})}),$("ul.hoster-tabs li > span.fa-minus-circle").bind("click",function(){confirm("Wirklich diesen Hoster löschen?")&&(location.href=$(this).data("action"))}),$("#genre_container").on("submit","form",series.addGenre),$("#genre_container .slink, #genre_container #addGenre").bind("click",series.genre_show)),tippy($(".serie .frame ul li.disabled, .serie table.episodes tr.disabled").get(),{content:"Keine Streams in dieser Sprache verfügbar"})})},change_title:function(e,t){var s=prompt("Serienname ändern",t);0 div:first > p > span").css("font-weight","normal"),$(t).css("font-weight","bold")):alert(e.hasOwnProperty("error")?e.error:"Aktion nicht erfolgreich")}})},show_years:function(e,t,s){$("div.infos > div:nth(1) > p > em").html("
        -
        ")},editYears:function(e,t,s){return start=parseInt($("#startyear").val()),end=parseInt($("#endyear").val()),isNaN(start)&&(start=0),isNaN(end)&&(end=0),start!=e||end!=t?start<=end||0==end?$.ajax({url:"ajax/edit-years.php",data:{start:start,end:end,sid:s},type:"POST",dataType:"JSON",success:function(e){e.success?($("div.infos > div:nth(1) > p > em").html((0!=start?start:"Unbekannt")+" - "+(0!=end?end:"Unbekannt")),$("div.infos > div:nth(1) > p > a").attr("href","javascript:series.show_years ("+start+", "+end+", "+s+");")):alert(e.hasOwnProperty("error")?e.error:"Aktion nicht erfolgreich")}}):alert("Das Startjahr muss vor dem Endjahr liegen."):$("div.infos > div:nth(1) > p > em").html((0!=e?e:"Unbekannt")+" - "+(0!=t?t:"Unbekannt")),!1},addData:function(s,a){ts={author:"Autor",director:"Regisseur",producer:"Produzent",actor:"Hauptdarsteller"},q=prompt(ts[s]+" hinzufügen. Mehrere Personen durch Kommata trennen:"),q&&(q=q.split(","),$.each(q,function(e,t){0<(t=t.trim()).length&&$.ajax({url:"ajax/add-role.php",type:"POST",data:{t:s,data:t,series:a},success:function(e){e.success?window.location.reload():alert(e.hasOwnProperty("error")?e.error:"Aktion nicht erfolgreich")}})}))}},editor={init:function(){$(document).ready(function(){$(".serie .season-editor select.language-selector").niceSelect(),$(".serie .season-editor div.language-selector > ul li").bind("click",function(){if(!$(this).hasClass("selected")){var e=$(this).data("value");void 0!==e&&($(".serie .season-editor .episode").find(".links-wrapper.active").removeClass("active"),$(".serie .season-editor .episode").find(".links-wrapper#"+e).addClass("active"),$(".serie .season-editor .episode").find("textarea.show").removeClass("show"),$(".serie .season-editor .episode").find('textarea[name^="editor[add_links]['+e+']"]').addClass("show"),$.each($(".serie .season-editor .episode"),function(){var e=$(this).find(".links-wrapper.active > span").length||0;0==e?$(this).find(".fa-backspace").removeClass("show"):$(this).find(".fa-backspace").addClass("show"),$(this).find(".top .badge.links > span").html(e)}))}}),$(".serie .season-editor .episode textarea").on("keyup input",function(){var e=$(this).prop("offsetHeight")-$(this).prop("clientHeight");$(this).css("height","auto").css("height",$(this).prop("scrollHeight")+e)}),$(".serie .season-editor .episode .fa-backspace").bind("click",function(){$(this).parent().find(".links-wrapper.active > span").click()}),$(".serie .season-editor .episode .links-wrapper span").bind("click",function(){$(this).is("[disabled]")||($(this).hasClass("active")?$(this).removeClass("active"):$(this).addClass("active"),$(this).prev('input[type="checkbox"]').click())}),$('.serie .season-editor .top > input[type="text"]').on("change",function(){$(this).parent().find('input[type="checkbox"]').attr("checked",!0),$(this).off("change")}),$(".serie .season-editor .btn.save").bind("click",function(e){e.preventDefault(),confirm("Änderungen speichern?")&&$(".serie form#editor").submit()});var e=/^#([a-z]{0,3})\:([0-9]+)/;if(e.test(window.location.hash)){var t=window.location.hash.match(e);t[1]&&($(".language-selector").find('li[data-value="'+t[1]+'"]').trigger("click"),$(".language-selector").removeClass("open")),t[2]&&($("html, body").animate({scrollTop:$(".episode#"+t[2]+" textarea.show").offset().top-75},250),$(".episode#"+t[2]+" textarea.show").focus())}})}},Tools={updateRandomFilters:function(){0==$('select[name="random[series]"]').val()?($('label[for="random[language]"]').addClass("hidden"),$('label[for="random[season]"]').addClass("hidden"),$('select[name="random[language]"]').prop("selectedIndex",0),$('input[name="random[season]"]').val("")):($('label[for="random[language]"]').removeClass("hidden"),$('label[for="random[season]"]').removeClass("hidden"))},updateSearchFilters:function(){0==$('select[name="search[series]"]').val()?($('label[for="search[season]"]').addClass("hidden"),$('input[name="search[season]"]').val("")):$('label[for="search[season]"]').removeClass("hidden")},spoiler:function(e,t,s,a){void 0===s&&(s=""),void 0===a&&(a=""),void 0===t&&(t=$()),"none"==e.css("display")?(e.show(),t.text(a)):(e.hide(),t.text(s))},mkStr:function(s,e){return $.each(e,function(e,t){s=s.split("$"+(e+1)).join(t)}),s},placeholdify:function(){function e(e,t){return document.defaultView&&document.defaultView.getComputedStyle?document.defaultView.getComputedStyle(e,null).getPropertyValue(t):e.currentStyle?e.currentStyle[t.replace(/\-(\w)/g,function(e,t){return t.toUpperCase()})]:e.style[t.replace(/\-(\w)/g,function(e,t){return t.toUpperCase()})]}if(!("placeholder"in document.createElement("input")))for(var t=document.getElementsByTagName("input"),s=t.length;s--;)if(t[s].getAttribute("placeholder")){var a=t[s],i=document.createElement("span");i.appendChild(document.createTextNode(a.getAttribute("placeholder"))),i.className="placeholder",i.onclick=function(e){return function(){e.focus()}}(a);for(var o=0,n=0,r=a,l=null;o+=r.offsetLeft,n+=r.offsetTop,null!=(l=r.offsetParent)&&"relative"!=e(l,"position")&&"absolute"!=e(l,"position")&&(r=l););i.style.position="absolute",i.style.left=o+parseInt(e(a,"border-left-width"))+parseInt(e(a,"padding-left"))+1+"px",i.style.top=n+parseInt(e(a,"border-top-width"))+parseInt(e(a,"padding-top"))+"px",i.style.fontFamily=e(a,"font-family"),i.style.fontSize=e(a,"font-size"),l.appendChild(i),t[s].onblur=function(e,t){return function(){""==e.value&&(t.style.display="block")}}(a,i),t[s].onfocus=function(e,t){return function(){t.style.display="none"}}(0,i),a.onblur()}}};$(document).ready(function(){Tools.placeholdify(),$.ajaxSetup({data:{token:$('meta[name="security_token"]').attr("content")||""}}),$(document).ajaxError(function(e,t){400==t.status&&parseInt(sessionStorage.getItem("400"))