4 var BooksView = (function() {
7 // ========================
8 // Private member variables
9 var booksModel = undefined;
14 my.init = function(linkedBooksModel) {
15 booksModel = linkedBooksModel;
17 booksModel.listen(my);
20 // Called when the model changes
21 my.notify = function () {
24 var limit = BooksModel.last - BooksModel.first;
25 for (i = 0; i <= limit; ++i) {
26 var book = BooksModel.cache[i];
27 html += bookHtml(book);
30 Browser.getElementById('books').innerHTML = html;
31 Browser.getElementById('first').innerHTML = (BooksModel.first + 1);
32 Browser.getElementById('bottom_first').innerHTML = (BooksModel.first + 1);
33 Browser.getElementById('last').innerHTML = (BooksModel.last + 1);
34 Browser.getElementById('bottom_last').innerHTML = (BooksModel.last + 1);
35 Browser.getElementById('count').innerHTML = BooksModel.count;
36 Browser.getElementById('bottom_count').innerHTML = BooksModel.count;
42 function bookHtml(book) {
43 var result = '<div class="book">'
46 + '<td><a href="/book/' + book.Id + '">';
47 if (0 == book.CoverId) {
48 result += '(No cover available)';
50 result += '<img class="cover-thumb" src="/download/' + book.CoverId + '"/>';
53 + '<td onclick="displayDetails(' + book.Id + ');" '
54 + ' onmouseover="ToolTip.startTooltipTimer(' + book.Id + ');"'
55 + ' onmouseleave="ToolTip.stopTooltipTimer();">'
56 + '<p><b>' + book.Title + '</b></p>'
58 + '<i>' + book.AuthorReading + '</i>';
59 if (typeof(book.SeriesName) !== 'undefined' && book.SeriesName.length > 0) {
60 result += '<br/><i>' + book.SeriesName + ' ' + book.Volume + '</i>';