X-Git-Url: https://git.mdrn.pl/ReadingsJQM.git/blobdiff_plain/45f8b33043d9aad64b1f89906323bc477efda0f3..ec887e1b76ec0d40861e67937026cc4b1d47f112:/js/app/app.coffee diff --git a/js/app/app.coffee b/js/app/app.coffee index 2f447d5..0096302 100644 --- a/js/app/app.coffee +++ b/js/app/app.coffee @@ -15,7 +15,8 @@ Readings.init = -> if Readings.initialized? return Readings.config = new Readings.Config - wlurl: 'http://readings.local' + wlurl: 'http://dev.wolnelektury.pl' + initdburl: 'http://dev.wolnelektury.pl/media/api/mobile/initial/initial.sql' categories: 'author': 'autor', 'epoch': 'epoka', @@ -35,20 +36,21 @@ $(document).on 'pageinit', '#page-categories' , (ev) -> rcategory = /category=(\w+)/ rtag = /tag=([a-z0-9-]+)/ rtagid = /tag_id=([0-9]+)/ +rbookid = /book_id=([0-9]+)/ $(document).on 'pageinit', "#page-tags", (ev, ui) -> category = rcategory.exec($(this).attr('data-url')) + category = category[1] if category? if category? - category = category[1] - if category? - return $(this).Readings 'list', -# category: category -# url: Readings.config.get('wlurl') + "/api/#{category}" - sql: "SELECT * FROM tag WHERE category=? ORDER BY sort_key" - params: [category] - filter: (Readings.config.get('show_filter').indexOf(category) >= 0) - mapper: (rec) -> new Readings.Tag(rec, category) - dividers: (Readings.config.get('show_dividers').indexOf(category) >= 0) + $('h1',this).text Readings.config.get('categories')[category] + return $(this).Readings 'list', + category: category + #url: Readings.config.get('wlurl') + "/api/#{category}" + sql: "SELECT * FROM tag WHERE category=? ORDER BY sort_key" + params: [category] + filter: (Readings.config.get('show_filter').indexOf(category) >= 0) + mapper: (rec) -> new Readings.Tag(rec, category) + dividers: (Readings.config.get('show_dividers').indexOf(category) >= 0) alert 'no category in query string' $(document).on 'pageinit', '#page-books', (ev, ui) -> @@ -60,3 +62,10 @@ $(document).on 'pageinit', '#page-books', (ev, ui) -> fetch: (cb) -> Readings.catalogue.withBooks(tag, cb) filter: true dividers: (tag.category != 'author') + + +$(document).on 'pageinit', '#page-reader', (ev, ui) -> + book_id_m = rbookid.exec($(this).attr('data-url')) + book_id = book_id_m[1] if book_id_m? + $(this).Readings 'reader', + book_id: book_id \ No newline at end of file