X-Git-Url: https://git.mdrn.pl/ReadingsJQM.git/blobdiff_plain/1be34458067b077d6403eb0bec498759be8fd4ca..refs/heads/readings:/js/app/app.js diff --git a/js/app/app.js b/js/app/app.js index b95b86e..bd5087d 100644 --- a/js/app/app.js +++ b/js/app/app.js @@ -1,5 +1,5 @@ (function() { - var rcategory, rtag, rtagid; + var rbookid, rcategory, rtag, rtagid; window.Readings = {}; @@ -45,22 +45,24 @@ rtagid = /tag_id=([0-9]+)/; + rbookid = /book_id=([0-9]+)/; + $(document).on('pageinit', "#page-tags", function(ev, ui) { var category; category = rcategory.exec($(this).attr('data-url')); + if (category != null) category = category[1]; if (category != null) { - category = category[1]; - if (category != null) { - return $(this).Readings('list', { - sql: "SELECT * FROM tag WHERE category=? ORDER BY sort_key", - params: [category], - filter: Readings.config.get('show_filter').indexOf(category) >= 0, - mapper: function(rec) { - return 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, + sql: "SELECT * FROM tag WHERE category=? ORDER BY sort_key", + params: [category], + filter: Readings.config.get('show_filter').indexOf(category) >= 0, + mapper: function(rec) { + return new Readings.Tag(rec, category); + }, + dividers: Readings.config.get('show_dividers').indexOf(category) >= 0 + }); } return alert('no category in query string'); }); @@ -81,4 +83,13 @@ }); }); + $(document).on('pageinit', '#page-reader', function(ev, ui) { + var book_id, book_id_m; + book_id_m = rbookid.exec($(this).attr('data-url')); + if (book_id_m != null) book_id = book_id_m[1]; + return $(this).Readings('reader', { + book_id: book_id + }); + }); + }).call(this);