@ -1,6 +1,12 @@
// Move advanced search to side-menu
$ ( 'a[href*="advanced"]' ) . parent ( ) . insertAfter ( '#nav_new' ) ;
$ ( 'body' ) . addClass ( 'blur' ) ;
$ ( 'body.stat' ) . addClass ( 'stats' ) ;
$ ( 'body.config' ) . addClass ( 'admin' ) ;
$ ( 'body.uiconfig' ) . addClass ( 'admin' ) ;
$ ( 'body.advsearch' ) . addClass ( 'advanced_search' ) ;
$ ( 'body.newuser' ) . addClass ( 'admin' ) ;
$ ( 'body.mailset' ) . addClass ( 'admin' ) ;
// Back button
curHref = window . location . href . split ( '/' ) ;
@ -34,99 +40,7 @@ $( 'a.navbar-brand' ).clone().appendTo( '.home-btn' ).empty().removeClass('navba
// Wrap book description in div container
if ( $ ( 'body.book' ) . length > 0 ) {
/ * d e s c r i p t i o n = $ ( ' h 3 : c o n t a i n s ( " D e s c r i p t i o n : " ) ' ) . n e x t U n t i l ( ' . m o r e s t u f f ' ) . s l i c e ( 0 , - 1 ) ;
bookInfo = $ ( '.author' ) . nextUntil ( 'h3:contains("Description:")' ) ;
$ ( 'h3:contains("Description:")' ) . hide ( ) ;
$ ( description ) . detach ( ) ;
$ ( bookInfo ) . wrapAll ( '<div class="bookinfo"></div>' ) ;
$ ( 'h3:contains("Description:")' ) . after ( '<div class="description"></div>' ) ;
$ ( '.languages' ) . appendTo ( '.bookinfo' ) ;
$ ( '.hr' ) . detach ( ) ;
if ( $ ( '.identifiers ' ) . length > 0 ) {
console . log ( ".identifiers length " + $ ( '.identifiers ' ) . length ) ;
$ ( '.identifiers' ) . before ( '<div class="hr"></div>' ) ;
} else {
if ( $ ( '.bookinfo > p:first-child' ) . length > 0 ) {
console . log ( ".bookinfo > p:first-child length " + $ ( '.bookinfo > p' ) . length ) ;
$ ( '.bookinfo > p:first-child' ) . first ( ) . after ( '<div class="hr"></div>' ) ;
} else {
if ( $ ( '.bookinfo a[href*="/series/"]' ) . length > 0 ) {
console . log ( 'series text found; placing hr below series' ) ;
$ ( '.bookinfo a[href*="/series/"]' ) . parent ( ) . after ( '<div class="hr"></div>' ) ;
} else {
console . log ( "prepending hr div to top of .bookinfo" ) ;
$ ( '.bookinfo' ) . prepend ( '<div class="hr"></div>' ) ;
}
}
}
$ ( '.rating' ) . insertBefore ( '.hr' ) ;
$ ( 'div.description' ) . hide ( ) ;
$ ( '#remove-from-shelves' ) . insertAfter ( '.hr' ) ;
/ * i f b o o k d e s c r i p t i o n i s n o t i n h t m l f o r m a t , R e m o v e e x t r a l i n e b r e a k s
Remove blank lines / unnecessary spaces , split by line break to array
Push array into . description div . If there is still a wall of text ,
find sentences and split wall into groups of three sentence paragraphs .
If the book format is in html format , Keep html , but strip away inline
styles and empty elements * /
/ *
// If text is sitting in div as text node
if ( description [ 0 ] === undefined ) {
textValue = $ ( '.book-meta' )
. contents ( )
. filter ( function ( ) {
return this . nodeType == Node . TEXT _NODE ;
} ) . text ( ) ;
description = $ . makeArray (
textValue . replace ( /(?:(?:\r\n|\r|\n)\s*){2}/gm , "" )
) ;
$ ( '.book-meta' ) . contents ( ) . filter ( function ( ) {
return this . nodeType === 3 ;
} ) . remove ( ) ;
}
if ( description [ 1 ] === undefined ) {
newdesc = description . toString ( )
. replace ( /^(?=\n)$|^\s*|\s*$|\n\n+/gm , "" ) . split ( /\n/ ) ;
$ . each ( newdesc , function ( i , val ) {
$ ( 'div.description' ) . append ( '<p>' + newdesc [ i ] + '</p>' ) ;
} ) ;
$ ( '.description' ) . fadeIn ( 100 ) ;
//If still a wall of text create 3 sentence paragraphs.
if ( $ ( '.description p' ) . length === 1 ) {
if ( description . context != undefined ) {
newdesc = description . text ( )
. replace ( /^(?=\n)$|^\s*|\s*$|\n\n+/gm , "" ) . split ( /\n/ ) ;
}
else {
newdesc = description . toString ( ) ;
}
doc = nlp ( newdesc . toString ( ) ) ;
sentences = doc . map ( ( m ) => m . out ( 'text' ) ) ;
$ ( '.description p' ) . remove ( ) ;
let size = 3 ; let sentenceChunks = [ ] ;
for ( var i = 0 ; i < sentences . length ; i += size ) {
sentenceChunks . push ( sentences . slice ( i , i + size ) ) ;
}
let output = '' ;
$ . each ( sentenceChunks , function ( i , val ) {
let preOutput = '' ;
$ . each ( val , function ( i , val ) {
preOutput += val ;
} ) ;
output += '<p>' + preOutput + '</p>' ;
} ) ;
$ ( 'div.description' ) . append ( output ) ;
}
} else {
$ . each ( description , function ( i , val ) {
$ ( description [ i ] . outerHTML ) . appendTo ( '.description' ) ;
$ ( 'div.description :empty' ) . remove ( ) ;
$ ( 'div.description ' ) . attr ( 'style' , '' ) ;
} ) ;
$ ( 'div.description' ) . fadeIn ( 100 ) ;
} * /
description = $ ( '.comments' ) ;
bookInfo = $ ( '.author' ) . nextUntil ( 'h3:contains("Description")' ) ;
$ ( 'h3:contains("Description")' ) . detach ( ) ;
@ -240,7 +154,6 @@ return $(this).text().replace(/^\s+|^\t+|\t+|\s+$/g, "");
$ ( '.book-meta h2:first' ) . clone ( )
. prependTo ( '.book-meta > .btn-toolbar:first' ) ;
// If only one download type exists still put the items into a drop-drown list.
downloads = $ ( 'a[id^=btnGroupDrop]' ) . get ( ) ;
if ( $ ( downloads ) . length === 1 ) {
@ -385,18 +298,6 @@ $(document).mouseup(function (e) {
// Split path name to array and remove blanks
url = window . location . pathname
. split ( "/" ) . filter ( function ( v ) { return v !== '' } ) ;
// Add classes to some body elements that don't have it
if ( jQuery . inArray ( 'epub' , url ) != - 1 ) {
$ ( 'body' ) . addClass ( url [ 3 ] ) ;
} else {
$ ( 'body' ) . addClass ( url [ 1 ] ) ;
}
if ( $ ( 'body.shelf' ) . length > 0 ) {
$ ( 'a[href*= "' + url [ 1 ] + "/" + url [ 2 ] + '"]' )
. parent ( )
. addClass ( 'active' ) ;
}
// Move create shelf
$ ( '#nav_createshelf' ) . prependTo ( '.your-shelves' ) ;
@ -434,13 +335,7 @@ $( 'input#query' ).focusout(function() {
$ ( 'form[role="search"]' ) . removeClass ( 'search-focus' ) ;
} , 100 ) ;
} ) ;
// Add class to random book discover
// ToDo: done
$ ( 'h2:contains("Discover (Random Books")' )
. parent ( )
. addClass ( 'random-books' ) ;
// Check if dropdown goes out of viewport and add class
$ ( document ) . on ( 'click' , '.dropdown-toggle' , function ( ) {
@ -454,7 +349,7 @@ $(document).on('click','.dropdown-toggle',function() {
// Fade out content on page unload
// delegate all clicks on "a" tag (links)
$ ( document ) . on ( "click" , "a:not(.btn-toolbar a, a[href*='shelf/remove'], .identifiers a, .bookinfo , .btn-group > a, #add-to-shelves a, #book-list a, .stat.blur.stats a )" , function ( ) {
/ * $ ( d o c u m e n t ) . o n ( " c l i c k " , " a : n o t ( . b t n - t o o l b a r a , a [ h r e f * = ' s h e l f / r e m o v e ' ] , . i d e n t i f i e r s a , . b o o k i n f o , . b t n - g r o u p > a , # a d d - t o - s h e l v e s a , # b o o k - l i s t a , . s t a t . b l u r a ) " , f u n c t i o n ( ) {
// get the href attribute
var newUrl = $ ( this ) . attr ( "href" ) ;
@ -466,7 +361,7 @@ $(document).on("click", "a:not(.btn-toolbar a, a[href*='shelf/remove'], .identif
return ;
}
// now, fadeout the html (whole page)
now , fadeout the html ( whole page )
$ ( '.blur-wrapper' ) . fadeOut ( 250 ) ;
$ ( ".row-fluid .col-sm-10" ) . fadeOut ( 500 , function ( ) {
// when the animation is complete, set the new location
@ -475,7 +370,7 @@ $(document).on("click", "a:not(.btn-toolbar a, a[href*='shelf/remove'], .identif
// prevent the default browser behavior.
return false ;
} ) ;
} ) ; * /
// Collapse long text into read-more
$ ( 'div.comments' ) . readmore ( {
@ -507,7 +402,7 @@ backurl = '../../book/' + url[2]
$ ( 'body.epub #title-controls' )
. append ( '<div class="epub-back"><input action="action" onclick="location.href=backurl; return false;" type="button" value="Back" /></div>' )
$ ( 'body.stat s .col-sm-10 p:first' ) . insertAfter ( '#libs' ) ;
$ ( 'body.stat .col-sm-10 p:first' ) . insertAfter ( '#libs' ) ;
// Check if link is external and force _blank attribute
$ ( function ( ) { // document ready
@ -593,7 +488,7 @@ $( '.plexBack > a' ).attr({
$ ( '#top_tasks' ) . attr ( {
'data-toggle' : 'tooltip' ,
'title' : 'Tasks' ,
'title' : $ ( '#top_tasks' ) . text ( ) , //'Tasks',
'data-placement' : 'bottom' ,
'data-viewport' : '#main-nav' } )
. addClass ( 'tasks-btn-tooltip' ) ;
@ -614,18 +509,20 @@ $( '.profileDrop' ).attr({
$ ( '#btn-upload' ) . attr ( {
'data-toggle' : 'tooltip' ,
'title' : 'Upload' ,
'title' : $ ( '#btn-upload' ) . text ( ) , // 'Upload',
'data-placement' : 'bottom' ,
'data-viewport' : '#main-nav' } )
. addClass ( 'upload-btn-tooltip' ) ;
$ ( '#add-to-shelf' ) . attr ( {
'data-toggle-two' : 'tooltip' ,
'title' : ' Add to Shelf' ,
'title' : $ ( ' #add-to-shelf' ) . text ( ) , // ' Add to Shelf',
'data-placement' : 'bottom' ,
'data-viewport' : '.btn-toolbar' } )
. addClass ( 'addtoshelf-btn-tooltip' ) ;
var teetet = $ ( '#add-to-shelf' ) . text ( )
$ ( '#have_read_cb' ) . attr ( {
'data-toggle' : 'tooltip' ,
'title' : 'Mark As Read' ,
@ -642,7 +539,7 @@ $( '#have_read_cb:checked' ).attr({
$ ( 'button#delete' ) . attr ( {
'data-toggle-two' : 'tooltip' ,
'title' : 'Delete' ,
'title' : $ ( 'button#delete' ) . text ( ) , //'Delete',
'data-placement' : 'bottom' ,
'data-viewport' : '.btn-toolbar' } )
. addClass ( 'delete-book-btn-tooltip' ) ;
@ -657,11 +554,13 @@ $( '#have_read_cb' ).click(function() {
$ ( '.btn-group[aria-label="Edit/Delete book"] a' ) . attr ( {
'data-toggle' : 'tooltip' ,
'title' : 'Edit' ,
'title' : $ ( '#edit_book' ) . text ( ) , // 'Edit',
'data-placement' : 'bottom' ,
'data-viewport' : '.btn-toolbar' } )
. addClass ( 'edit-btn-tooltip' ) ;
var teetet = $ ( '#edit_book' ) . text ( )
$ ( '#sendbtn' ) . attr ( {
'data-toggle' : 'tooltip' ,
'title' : 'Send to Kindle' ,
@ -742,10 +641,10 @@ if ( $( window ).width() <= 768 ) {
}
// LayerCake plug
if ( $ ( ' .stat.blur.stats p') . length > 0 ) {
$ ( ' .stat.blur.stats p') . append ( " and <a href='https://github.com/leram84/layer.Cake/tree/master/caliBlur' target='_blank'>layer.Cake</a>" ) ;
str = $ ( ' .stat.blur.stats p') . html ( ) . replace ( "</a>." , "</a>" ) ;
$ ( ' .stat.blur.stats p') . html ( str ) ;
if ( $ ( ' body.stat p') . length > 0 ) {
$ ( ' body.stat p') . append ( " and <a href='https://github.com/leram84/layer.Cake/tree/master/caliBlur' target='_blank'>layer.Cake</a>" ) ;
str = $ ( ' body.stat p') . html ( ) . replace ( "</a>." , "</a>" ) ;
$ ( ' body.stat p') . html ( str ) ;
}
// Collect delete buttons in editbook to single dropdown
$ ( '.editbook .text-center.more-stuff' ) . prepend ( '<button id="deleteButton" type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-remove"></span>Delete Format<span class="caret"></span></button><ul class="dropdown-menu delete-dropdown"></ul>' ) ;