X-Git-Url: https://git.mdrn.pl/ReadingsJQM.git/blobdiff_plain/b2dcc4cec0edb145ed13c26537c94b593691954f..c956fba7332f45e9abab07b2b8ac417b0f6514c8:/js/app/reader.coffee diff --git a/js/app/reader.coffee b/js/app/reader.coffee new file mode 100644 index 0000000..d106ac1 --- /dev/null +++ b/js/app/reader.coffee @@ -0,0 +1,28 @@ + + +$.fn.extend + load_book: (slug) -> + this.each -> + $.ajax + type: 'GET', + contentType: 'html', + url: '/fixtures/katalog_lektura_lord-jim.html', + error: (e) -> + console.log "Error #{e}" + success: (page) => + $page = $(page) + $text = $page.find '#book-text' + $toc = $text.find '#toc' + + this.toc = $toc.find('a').map (_i, link) => + { + anchor: link.href, + label: $(link).text() + } + + $toc.remove() + this.text = $text + + $('[data-role=header] h1', this).text( + this.text.find('h1 .title').text() + )