/* This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)
* Copyright (C) 2018-2019 hexeth
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
// 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('/');
prevHref = document.referrer.split('/');
$( '.navbar-form.navbar-left' )
.before( '
' );
if ( history.length === 1 ||
curHref[0] +
curHref[1] +
curHref[2] !=
prevHref[0] +
prevHref[1] +
prevHref[2] ||
$( 'body.root' )>length > 0 ) {
$( '.plexBack' ).addClass( 'noBack' );
}
//Weird missing a after pressing back from edit.
setTimeout(function() {
if ( $( '.plexBack a').length < 1 ) {
$( '.plexBack' ).append('');
}
},10);
// Home button
$( '.plexBack' ).before( '' );
$( 'a.navbar-brand' ).clone().appendTo( '.home-btn' ).empty().removeClass('navbar-brand');
/////////////////////////////////
// Start of Book Details Work //
///////////////////////////////
// Wrap book description in div container
if ( $( 'body.book' ).length > 0 ) {
description = $( '.comments' );
bookInfo = $( '.author' ).nextUntil( 'h3:contains("Description")');
$( 'h3:contains("Description")' ).detach();
$( '.comments' ).detach();
$( bookInfo ).wrapAll( '' );
// $( 'h3:contains("Description:")' ).after( '' );
$( '.languages' ).appendTo( '.bookinfo' );
$('.hr').detach();
if ( $( '.identifiers ').length > 0 ) {
console.log(".identifiers length " + $( '.identifiers ').length );
$( '.identifiers' ).before( '' );
} else {
if ( $( '.bookinfo > p:first-child' ).length > 0 ) {
console.log(".bookinfo > p:first-child length " + $( '.bookinfo > p' ).length );
$( '.bookinfo > p:first-child' ).first().after( '' );
} else{
if ( $( '.bookinfo a[href*="/series/"]' ).length > 0 ) {
console.log( 'series text found; placing hr below series' );
$( '.bookinfo a[href*="/series/"]' ).parent().after( '' );
} else {
console.log("prepending hr div to top of .bookinfo");
$( '.bookinfo' ).prepend( '' );
}
}
}
$( '.rating' ).insertBefore( '.hr' );
$( '#remove-from-shelves' ).insertAfter( '.hr' );
$( description ).appendTo('.bookinfo')
/* if book description is not in html format, Remove extra line breaks
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 ( $('.comments:has(p)' ).length === 0 ) {
newdesc = description.text()
.replace(/^(?=\n)$|^\s*|\s*$|\n\n+/gm,"").split(/\n/);
$('.comments' ).empty();
$.each(newdesc, function(i, val) {
$( 'div.comments' ).append( '
' + newdesc[i] + '
' );
});
$( '.comments' ).fadeIn(100);
} //If still a wall of text create 3 sentence paragraphs.
if( $( '.comments p' ).length === 1 ) {
if ( description.context != undefined ) {
newdesc = description.text()
.replace(/^(?=\n)$|^\s*|\s*$|\n\n+/gm,"").split(/\n/);
}
else {
newdesc = description.text();
}
doc = nlp ( newdesc.toString() );
sentences = doc.map((m)=> m.out( 'text' ));
sentences[0] = sentences[0].replace(",","");
$( '.comments p' ).remove();
let size = 3; let sentenceChunks = [];
for (var i=0; i' + preOutput + '';
});
$( 'div.comments' ).append( output );
}
else {
$.each(description, function(i, val) {
// $( description[i].outerHTML ).appendTo( '.comments' );
$( 'div.comments :empty' ).remove();
$( 'div.comments ').attr( 'style', '' );
});
$( 'div.comments' ).fadeIn( 100 );
}
// Sexy blurred backgrounds
cover = $( '.cover img' ).attr( 'src' );
$( '#loader + .container-fluid' )
.prepend( '' );
// Fix-up book detail headings
publisher = $( '.publishers p span' ).text().split( ':' );
$( '.publishers p span' ).remove();
$.each(publisher, function(i, val) {
$( '.publishers' ).append( '' + publisher[i] + '' );
});
$( '.publishers span:nth-child(3)' ).text(function() {
return $(this).text().replace(/^\s+|^\t+|\t+|\s+$/g, "");
});
published = $( '.publishing-date p' )
.text().split(': ');
$( '.publishing-date p' ).remove();
$.each(published, function(i, val) {
$( '.publishing-date' ).append( '' + published[i] + '' );
});
languages = $( '.languages p span' ).text().split( ': ' );
$( '.languages p span' ).remove();
$.each(languages, function(i, val) {
$( '.languages' ).append( '' + languages[i] + '' );
});
$( '.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 ) {
$( '