/***
* Copyright 2012, Digital Fusion
* Licensed under the MIT license.
* http://teamdf.com/jquery-plugins/license/
*
* @author Sam Sehnert
* @desc A small plugin that checks whether elements are within
* the user visible viewport of a web browser.
* can accounts for vertical position, horizontal, or both
*/
!function(t){var i=t(window);t.fn.visible=function(t,e,o){if(!(this.length<1)){var r=this.length>1?this.eq(0):this,n=r.get(0),f=i.width(),h=i.height(),o=o?o:"both",l=e===!0?n.offsetWidth*n.offsetHeight:!0;if("function"==typeof n.getBoundingClientRect){var g=n.getBoundingClientRect(),u=g.top>=0&&g.top0&&g.bottom<=h,c=g.left>=0&&g.left0&&g.right<=f,v=t?u||s:u&&s,b=t?c||a:c&&a;if("both"===o)return l&&v&&b;if("vertical"===o)return l&&v;if("horizontal"===o)return l&&b}else{var d=i.scrollTop(),p=d+h,w=i.scrollLeft(),m=w+f,y=r.offset(),z=y.top,B=z+r.height(),C=y.left,R=C+r.width(),j=t===!0?B:z,q=t===!0?z:B,H=t===!0?R:C,L=t===!0?C:R;if("both"===o)return!!l&&p>=q&&j>=d&&m>=L&&H>=w;if("vertical"===o)return!!l&&p>=q&&j>=d;if("horizontal"===o)return!!l&&m>=L&&H>=w}}}}(jQuery);
// Move advanced search to side-menu
$( 'a[href*="advanced"]' ).parent().insertAfter( '#nav_new' );
$( 'body' ).addClass('blur');
// 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 = $( 'h3:contains("Description:")' ).nextUntil( '.morestuff' ).slice(0,-1);
bookInfo = $( '.author' ).nextUntil( 'h3:contains("Description:")');
$( 'h3:contains("Description:")' ).hide();
$( description ).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' );
$( 'div.description' ).hide();
$( '#remove-from-shelves' ).insertAfter( '.hr' );
/* 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 ( 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( '
' + newdesc[i] + '
' );
});
$( '.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' + preOutput + '
';
});
$( '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();
$( '.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( '