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 document.getElementById('books').innerHTML = html;
31 document.getElementById('first').innerHTML = (BooksModel.first + 1);
32 document.getElementById('last').innerHTML = (BooksModel.last + 1);
33 document.getElementById('count').innerHTML = BooksModel.count;
39 function bookHtml(book) {
40 var result = '<div class="book">'
43 + '<td><a href="/book/' + book.Id + '">';
44 if (0 == book.CoverId) {
45 result += '(No cover available)';
47 result += '<img class="cover-thumb" src="/download/' + book.CoverId + '"/>';
50 + '<td onclick="displayDetails(' + book.Id + ');" '
51 + ' onmouseover="ToolTip.startTooltipTimer(' + book.Id + ');">'
52 + '<p><b>' + book.Title + '</b></p>'
54 + '<i>' + book.AuthorReading + '</i>';
55 if (typeof(book.SeriesName) !== 'undefined' && book.SeriesName.length > 0) {
56 result += '<br/><i>' + book.SeriesName + ' ' + book.Volume + '</i>';