2018-10-10 12:57:11 -04:00
( function ( ) { var matches = function ( elm , selector ) { var matches = ( elm . document || elm . ownerDocument ) . querySelectorAll ( selector ) ; var 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 ] ) ) ;
else elements = [ ] . slice . apply ( context . querySelectorAll ( selector ) ) ; return elements } , hasElement : function ( selector ) { return AnimeClient . $ ( selector ) . length > 0 } , scrollToTop : function ( ) { window . scroll ( 0 , 0 ) } , hide : function ( sel ) { sel . setAttribute ( "hidden" , "hidden" ) } , show : function ( sel ) { sel . removeAttribute ( "hidden" ) } , showMessage : function ( type , message ) { var template = "\x3cdiv class\x3d'message " + type + "'\x3e\n\t\t\t\t\x3cspan class\x3d'icon'\x3e\x3c/span\x3e\n\t\t\t\t" + message + "\n\t\t\t\t\x3cspan class\x3d'close'\x3e\x3c/span\x3e\n\t\t\t\x3c/div\x3e" ;
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 + "\x3d" + value ) } ) ; return pairs . join ( "\x26" ) } 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 } ) } ;
2018-11-01 22:01:09 -04:00
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 ; var bottom = rect . bottom + window . pageYOffset ; window . scrollTo ( { bottom : bottom , behavior : "smooth" } ) } ) ; AnimeClient . on ( "main" , "change" , ".big-check" , function ( e ) { var id = e . target . id ; document . getElementById ( "mal_" + id ) . checked = true } ) ; function renderAnimeSearchResults ( data ) { var results = [ ] ; data . forEach ( function ( x ) { var item = x . attributes ; var titles = item . titles . reduce ( function ( prev , current ) { return prev + ( current +
"\x3cbr /\x3e" ) } , [ ] ) ; results . push ( '\n\t\t\t\x3carticle class\x3d"media search"\x3e\n\t\t\t\t\x3cdiv class\x3d"name"\x3e\n\t\t\t\t\t\x3cinput type\x3d"radio" class\x3d"mal-check" id\x3d"mal_' + item . slug + '" name\x3d"mal_id" value\x3d"' + x . mal _id + '" /\x3e\n\t\t\t\t\t\x3cinput type\x3d"radio" class\x3d"big-check" id\x3d"' + item . slug + '" name\x3d"id" value\x3d"' + x . id + '" /\x3e\n\t\t\t\t\t\x3clabel for\x3d"' + item . slug + '"\x3e\n\t\t\t\t\t\t\x3cpicture width\x3d"220"\x3e\n\t\t\t\t\t\t\t\x3csource srcset\x3d"/public/images/anime/' +
x . id + '.webp" type\x3d"image/webp" /\x3e\n\t\t\t\t\t\t\t\x3csource srcset\x3d"/public/images/anime/' + x . id + '.jpg" type\x3d"image/jpeg" /\x3e\n\t\t\t\t\t\t\t\x3cimg src\x3d"/public/images/anime/' + x . id + '.jpg" alt\x3d"" width\x3d"220" /\x3e\n\t\t\t\t\t\t\x3c/picture\x3e\n\t\t\t\t\t\t\n\t\t\t\t\t\t\x3cspan class\x3d"name"\x3e\n\t\t\t\t\t\t\t' + item . canonicalTitle + "\x3cbr /\x3e\n\t\t\t\t\t\t\t\x3csmall\x3e" + titles + '\x3c/small\x3e\n\t\t\t\t\t\t\x3c/span\x3e\n\t\t\t\t\t\x3c/label\x3e\n\t\t\t\t\x3c/div\x3e\n\t\t\t\t\x3cdiv class\x3d"table"\x3e\n\t\t\t\t\t\x3cdiv class\x3d"row"\x3e\n\t\t\t\t\t\t\x3cspan class\x3d"edit"\x3e\n\t\t\t\t\t\t\t\x3ca class\x3d"bracketed" href\x3d"/anime/details/' +
item . slug + '"\x3eInfo Page\x3c/a\x3e\n\t\t\t\t\t\t\x3c/span\x3e\n\t\t\t\t\t\x3c/div\x3e\n\t\t\t\t\x3c/div\x3e\n\t\t\t\x3c/article\x3e\n\t\t' ) } ) ; return results . join ( "" ) } function renderMangaSearchResults ( data ) { var results = [ ] ; data . forEach ( function ( x ) { var item = x . attributes ; var titles = item . titles . reduce ( function ( prev , current ) { return prev + ( current + "\x3cbr /\x3e" ) } , [ ] ) ; results . push ( '\n\t\t\t\x3carticle class\x3d"media search"\x3e\n\t\t\t\t\x3cdiv class\x3d"name"\x3e\n\t\t\t\t\t\x3cinput type\x3d"radio" id\x3d"mal_' +
2018-10-10 12:57:11 -04:00
item . slug + '" name\x3d"mal_id" value\x3d"' + x . mal _id + '" /\x3e\n\t\t\t\t\t\x3cinput type\x3d"radio" class\x3d"big-check" id\x3d"' + item . slug + '" name\x3d"id" value\x3d"' + x . id + '" /\x3e\n\t\t\t\t\t\x3clabel for\x3d"' + item . slug + '"\x3e\n\t\t\t\t\t\t\x3cpicture width\x3d"220"\x3e\n\t\t\t\t\t\t\t\x3csource srcset\x3d"/public/images/manga/' + x . id + '.webp" type\x3d"image/webp" /\x3e\n\t\t\t\t\t\t\t\x3csource srcset\x3d"/public/images/manga/' + x . id + '.jpg" type\x3d"image/jpeg" /\x3e\n\t\t\t\t\t\t\t\x3cimg src\x3d"/public/images/manga/' +
x . id + '.jpg" alt\x3d"" width\x3d"220" /\x3e\n\t\t\t\t\t\t\x3c/picture\x3e\n\t\t\t\t\t\t\x3cspan class\x3d"name"\x3e\n\t\t\t\t\t\t\t' + item . canonicalTitle + "\x3cbr /\x3e\n\t\t\t\t\t\t\t\x3csmall\x3e" + titles + '\x3c/small\x3e\n\t\t\t\t\t\t\x3c/span\x3e\n\t\t\t\t\t\x3c/label\x3e\n\t\t\t\t\x3c/div\x3e\n\t\t\t\t\x3cdiv class\x3d"table"\x3e\n\t\t\t\t\t\x3cdiv class\x3d"row"\x3e\n\t\t\t\t\t\t\x3cspan class\x3d"edit"\x3e\n\t\t\t\t\t\t\t\x3ca class\x3d"bracketed" href\x3d"/manga/details/' + item . slug + '"\x3eInfo Page\x3c/a\x3e\n\t\t\t\t\t\t\x3c/span\x3e\n\t\t\t\t\t\x3c/div\x3e\n\t\t\t\t\x3c/div\x3e\n\t\t\t\x3c/article\x3e\n\t\t' ) } ) ;
return results . join ( "" ) } var search = function ( query ) { AnimeClient . $ ( ".cssload-loader" ) [ 0 ] . removeAttribute ( "hidden" ) ; AnimeClient . get ( AnimeClient . url ( "/anime-collection/search" ) , { query : query } , function ( searchResults , status ) { searchResults = JSON . parse ( searchResults ) ; AnimeClient . $ ( ".cssload-loader" ) [ 0 ] . setAttribute ( "hidden" , "hidden" ) ; AnimeClient . $ ( "#series_list" ) [ 0 ] . innerHTML = renderAnimeSearchResults ( searchResults . data ) } ) } ; if ( AnimeClient . hasElement ( ".anime #search" ) ) AnimeClient . on ( "#search" , "keyup" , AnimeClient . throttle ( 250 ,
function ( e ) { var query = encodeURIComponent ( e . target . value ) ; if ( query === "" ) return ; search ( query ) } ) ) ; AnimeClient . on ( "body.anime.list" , "click" , ".plus_one" , function ( e ) { var parentSel = AnimeClient . closestParent ( e . target , "article" ) ; var watchedCount = parseInt ( AnimeClient . $ ( ".completed_number" , parentSel ) [ 0 ] . textContent , 10 ) || 0 ; var totalCount = parseInt ( AnimeClient . $ ( ".total_number" , parentSel ) [ 0 ] . textContent , 10 ) ; var title = AnimeClient . $ ( ".name a" , parentSel ) [ 0 ] . textContent ; var data = { id : parentSel . dataset . kitsuId , mal _id : parentSel . dataset . malId ,
data : { progress : watchedCount + 1 } } ; if ( isNaN ( watchedCount ) || watchedCount === 0 ) data . data . status = "current" ; if ( ! isNaN ( watchedCount ) && watchedCount + 1 === totalCount ) data . data . status = "completed" ; AnimeClient . show ( AnimeClient . $ ( "#loading-shadow" ) [ 0 ] ) ; AnimeClient . ajax ( AnimeClient . url ( "/anime/increment" ) , { data : data , dataType : "json" , type : "POST" , success : function ( res ) { var resData = JSON . parse ( res ) ; if ( resData . errors ) { AnimeClient . hide ( AnimeClient . $ ( "#loading-shadow" ) [ 0 ] ) ; AnimeClient . showMessage ( "error" , "Failed to update " +
title + ". " ) ; AnimeClient . scrollToTop ( ) ; return } if ( resData . data . attributes . status === "completed" ) AnimeClient . hide ( parentSel ) ; AnimeClient . hide ( AnimeClient . $ ( "#loading-shadow" ) [ 0 ] ) ; AnimeClient . showMessage ( "success" , "Successfully updated " + title ) ; AnimeClient . $ ( ".completed_number" , parentSel ) [ 0 ] . textContent = ++ watchedCount ; AnimeClient . scrollToTop ( ) } , error : function ( ) { AnimeClient . hide ( AnimeClient . $ ( "#loading-shadow" ) [ 0 ] ) ; AnimeClient . showMessage ( "error" , "Failed to update " + title + ". " ) ; AnimeClient . scrollToTop ( ) } } ) } ) ;
var search$1 = function ( query ) { AnimeClient . $ ( ".cssload-loader" ) [ 0 ] . removeAttribute ( "hidden" ) ; AnimeClient . get ( AnimeClient . url ( "/manga/search" ) , { query : query } , function ( searchResults , status ) { searchResults = JSON . parse ( searchResults ) ; AnimeClient . $ ( ".cssload-loader" ) [ 0 ] . setAttribute ( "hidden" , "hidden" ) ; AnimeClient . $ ( "#series_list" ) [ 0 ] . innerHTML = renderMangaSearchResults ( searchResults . data ) } ) } ; if ( AnimeClient . hasElement ( ".manga #search" ) ) AnimeClient . on ( "#search" , "keyup" , AnimeClient . throttle ( 250 , function ( e ) { var query =
encodeURIComponent ( e . target . value ) ; if ( query === "" ) return ; search$1 ( query ) } ) ) ; AnimeClient . on ( ".manga.list" , "click" , ".edit_buttons button" , function ( e ) { var thisSel = e . target ; var parentSel = AnimeClient . closestParent ( e . target , "article" ) ; var type = thisSel . classList . contains ( "plus_one_chapter" ) ? "chapter" : "volume" ; var completed = parseInt ( AnimeClient . $ ( "." + type + "s_read" , parentSel ) [ 0 ] . textContent , 10 ) || 0 ; var total = parseInt ( AnimeClient . $ ( "." + type + "_count" , parentSel ) [ 0 ] . textContent , 10 ) ; var mangaName = AnimeClient . $ ( ".name" ,
parentSel ) [ 0 ] . textContent ; if ( isNaN ( completed ) ) completed = 0 ; var data = { id : parentSel . dataset . kitsuId , mal _id : parentSel . dataset . malId , data : { progress : completed } } ; if ( isNaN ( completed ) || completed === 0 ) data . data . status = "current" ; if ( ! isNaN ( completed ) && completed + 1 === total ) data . data . status = "completed" ; data . data . progress = ++ completed ; AnimeClient . show ( AnimeClient . $ ( "#loading-shadow" ) [ 0 ] ) ; AnimeClient . ajax ( AnimeClient . url ( "/manga/increment" ) , { data : data , dataType : "json" , type : "POST" , mimeType : "application/json" , success : function ( ) { if ( data . data . status ===
"completed" ) AnimeClient . hide ( parentSel ) ; AnimeClient . hide ( AnimeClient . $ ( "#loading-shadow" ) [ 0 ] ) ; AnimeClient . $ ( "." + type + "s_read" , parentSel ) [ 0 ] . textContent = completed ; AnimeClient . showMessage ( "success" , "Successfully updated " + mangaName ) ; AnimeClient . scrollToTop ( ) } , error : function ( ) { AnimeClient . hide ( AnimeClient . $ ( "#loading-shadow" ) [ 0 ] ) ; AnimeClient . showMessage ( "error" , "Failed to update " + mangaName ) ; AnimeClient . scrollToTop ( ) } } ) } ) } ) ( ) ;
2018-08-20 12:58:56 -04:00
//# sourceMappingURL=scripts-authed.min.js.map