2018-11-02 10:48:20 -04:00
( function ( ) { var matches = function ( elm , selector ) { var matches = ( elm . document || elm . ownerDocument ) . querySelectorAll ( selector ) , i = matches . length ; while ( -- i >= 0 && matches . item ( i ) !== elm ) ; return i > - 1 } ; var AnimeClient = { noop : function ( ) { } , $ : function ( selector , context ) { context = context === undefined ? null : context ; if ( typeof selector !== "string" ) return selector ; context = context !== null && context . nodeType === 1 ? context : document ; var elements = [ ] ; if ( selector . match ( /^#([\w]+$)/ ) ) elements . push ( document . getElementById ( selector . split ( "#" ) [ 1 ] ) ) ;
2019-07-12 23:12:05 -04:00
else elements = [ ] . slice . apply ( context . querySelectorAll ( selector ) ) ; return elements } , hasElement : function ( selector ) { return AnimeClient . $ ( selector ) . length > 0 } , scrollToTop : function ( ) { var el = AnimeClient . $ ( "header" ) [ 0 ] ; el . scrollIntoView ( true ) } , hide : function ( sel ) { sel . setAttribute ( "hidden" , "hidden" ) } , show : function ( sel ) { sel . removeAttribute ( "hidden" ) } , showMessage : function ( type , message ) { var template = "<div class='message " + type + "'>\n\t\t\t\t<span class='icon'></span>\n\t\t\t\t" + message + "\n\t\t\t\t<span class='close'></span>\n\t\t\t</div>" ;
var sel = AnimeClient . $ ( ".message" ) ; if ( sel [ 0 ] !== undefined ) sel [ 0 ] . remove ( ) ; AnimeClient . $ ( "header" ) [ 0 ] . insertAdjacentHTML ( "beforeend" , template ) } , closestParent : function ( current , parentSelector ) { if ( Element . prototype . closest !== undefined ) return current . closest ( parentSelector ) ; while ( current !== document . documentElement ) { if ( matches ( current , parentSelector ) ) return current ; current = current . parentElement } return null } , url : function ( path ) { var uri = "//" + document . location . host ; uri += path . charAt ( 0 ) === "/" ? path : "/" + path ; return uri } ,
throttle : function ( interval , fn , scope ) { var wait = false ; return function ( args ) { var $jscomp$restParams = [ ] ; for ( var $jscomp$restIndex = 0 ; $jscomp$restIndex < arguments . length ; ++ $jscomp$restIndex ) $jscomp$restParams [ $jscomp$restIndex - 0 ] = arguments [ $jscomp$restIndex ] ; { var args$0 = $jscomp$restParams ; var context = scope || this ; if ( ! wait ) { fn . apply ( context , args$0 ) ; wait = true ; setTimeout ( function ( ) { wait = false } , interval ) } } } } } ; function addEvent ( sel , event , listener ) { if ( ! event . match ( /^([\w\-]+)$/ ) ) event . split ( " " ) . forEach ( function ( evt ) { addEvent ( sel ,
evt , listener ) } ) ; sel . addEventListener ( event , listener , false ) } function delegateEvent ( sel , target , event , listener ) { addEvent ( sel , event , function ( e ) { AnimeClient . $ ( target , sel ) . forEach ( function ( element ) { if ( e . target == element ) { listener . call ( element , e ) ; e . stopPropagation ( ) } } ) } ) } AnimeClient . on = function ( sel , event , target , listener ) { if ( listener === undefined ) { listener = target ; AnimeClient . $ ( sel ) . forEach ( function ( el ) { addEvent ( el , event , listener ) } ) } else AnimeClient . $ ( sel ) . forEach ( function ( el ) { delegateEvent ( el , target , event ,
listener ) } ) } ; function ajaxSerialize ( data ) { var pairs = [ ] ; Object . keys ( data ) . forEach ( function ( name ) { var value = data [ name ] . toString ( ) ; name = encodeURIComponent ( name ) ; value = encodeURIComponent ( value ) ; pairs . push ( name + "=" + value ) } ) ; return pairs . join ( "&" ) } AnimeClient . ajax = function ( url , config ) { var defaultConfig = { data : { } , type : "GET" , dataType : "" , success : AnimeClient . noop , mimeType : "application/x-www-form-urlencoded" , error : AnimeClient . noop } ; config = Object . assign ( { } , defaultConfig , config ) ; var request = new XMLHttpRequest ;
var method = String ( config . type ) . toUpperCase ( ) ; if ( method === "GET" ) url += url . match ( /\?/ ) ? ajaxSerialize ( config . data ) : "?" + ajaxSerialize ( config . data ) ; request . open ( method , url ) ; request . onreadystatechange = function ( ) { if ( request . readyState === 4 ) { var responseText = "" ; if ( request . responseType === "json" ) responseText = JSON . parse ( request . responseText ) ; else responseText = request . responseText ; if ( request . status > 299 ) config . error . call ( null , request . status , responseText , request . response ) ; else config . success . call ( null , responseText ,
request . status ) } } ; if ( config . dataType === "json" ) { config . data = JSON . stringify ( config . data ) ; config . mimeType = "application/json" } else config . data = ajaxSerialize ( config . data ) ; request . setRequestHeader ( "Content-Type" , config . mimeType ) ; switch ( method ) { case "GET" : request . send ( null ) ; break ; default : request . send ( config . data ) ; break } } ; AnimeClient . get = function ( url , data , callback ) { callback = callback === undefined ? null : callback ; if ( callback === null ) { callback = data ; data = { } } return AnimeClient . ajax ( url , { data : data , success : callback } ) } ;
AnimeClient . on ( "header" , "click" , ".message" , function ( e ) { AnimeClient . hide ( e . target ) } ) ; AnimeClient . on ( "form.js-delete" , "submit" , function ( event ) { var proceed = confirm ( "Are you ABSOLUTELY SURE you want to delete this item?" ) ; if ( proceed === false ) { event . preventDefault ( ) ; event . stopPropagation ( ) } } ) ; AnimeClient . on ( ".js-clear-cache" , "click" , function ( ) { AnimeClient . get ( "/cache_purge" , function ( ) { AnimeClient . showMessage ( "success" , "Successfully purged api cache" ) } ) } ) ; AnimeClient . on ( ".vertical-tabs input" , "change" , function ( event ) { var el =
event . currentTarget . parentElement ; var rect = el . getBoundingClientRect ( ) ; var top = rect . top + window . pageYOffset ; window . scrollTo ( { top : top , behavior : "smooth" } ) } ) ; AnimeClient . on ( ".media-filter" , "input" , function ( event ) { var rawFilter = event . target . value ; var filter = new RegExp ( rawFilter , "i" ) ; if ( rawFilter !== "" ) { AnimeClient . $ ( "article.media" ) . forEach ( function ( article ) { var titleLink = AnimeClient . $ ( ".name a" , article ) [ 0 ] ; var title = String ( titleLink . textContent ) . trim ( ) ; if ( ! filter . test ( title ) ) AnimeClient . hide ( article ) ; else AnimeClient . show ( article ) } ) ;
AnimeClient . $ ( "table.media-wrap tbody tr" ) . forEach ( function ( tr ) { var titleCell = AnimeClient . $ ( "td.align-left" , tr ) [ 0 ] ; var titleLink = AnimeClient . $ ( "a" , titleCell ) [ 0 ] ; var linkTitle = String ( titleLink . textContent ) . trim ( ) ; var textTitle = String ( titleCell . textContent ) . trim ( ) ; if ( ! ( filter . test ( linkTitle ) || filter . test ( textTitle ) ) ) AnimeClient . hide ( tr ) ; else AnimeClient . show ( tr ) } ) } else { AnimeClient . $ ( "article.media" ) . forEach ( function ( article ) { return AnimeClient . show ( article ) } ) ; AnimeClient . $ ( "table.media-wrap tbody tr" ) . forEach ( function ( tr ) { return AnimeClient . show ( tr ) } ) } } ) ;
if ( "serviceWorker" in navigator ) navigator . serviceWorker . register ( "/sw.js" ) . then ( function ( reg ) { console . log ( "Service worker registered" , reg . scope ) } ) [ "catch" ] ( function ( error ) { console . error ( "Failed to register service worker" , error ) } ) } ) ( ) ;
2018-08-20 12:58:56 -04:00
//# sourceMappingURL=scripts.min.js.map