FP.app = {}; FP.app.init = (function($){ var Book; function init(bookURL){ var search = window.location.search.match(/book=(.*)/), bookURL = bookURL || (search ? search[1] : "moby-dick"); //-- Setup the browser prefixes FP.core.crossBrowserColumnCss(); //-- Set up our sidebar $("#main").width($(window).width()-40); Book = new FP.Book("area", bookURL + "/"); //Book = new FP.Book("area", "/the-hound-of-the-baskervilles/"); Book.listen("book:metadataReady", meta); Book.listen("book:tocReady", toc); //-- Wait for Dom ready to handle jquery $(function() { controls(); }); } function meta(){ var title = Book.getTitle(); author = Book.getCreator(), $title = $("#book-title"), $author = $("#chapter-title"); document.title = title+" – "+author; $title.html(title); $author.html(author); } function toc(){ var contents = Book.getTOC(); $toc = $("#toc"); $toc.empty(); contents.forEach(function(item){ $wrapper = $("
  • "); $item = $(""+item.label+""); //-- Handle sub items later /* if(item.subitems.length){ $subitems = $("