pretty much working version
[wl-mobile.git] / assets / www / js / links.js
1
2 var Links = new function() {
3         var self = this;
4
5         self.href = function(view, par) {
6                 return view+"/"+par;
7         };
8
9         self.button = function(view, par, text, offset) {
10                 offset = offset || 0;
11                 var html = "<div class='button button-"+view+"' onclick='History.visit(\"" + 
12                                         self.href(view, par).replace(/["']/g, "\\$&") + "\", "+offset+");'>";
13                 icon = view;
14                 if (icon != 'Book' && icon != 'Bookmarks' && icon != 'BookText' && 
15                         icon != 'Last' && icon != 'Tag') {
16                     icon = 'Tag';
17                 }
18                 html += "<img src='img/icon-" + icon + ".png' />";
19                 html += "<div class='label'>" + text + "</div>";
20                 html += "<div class='clr'></div>";
21                 html += "</div>\n";
22                 return html; 
23         };
24
25         self.bookLink = function(book) {
26                 var target = 'Book';
27                 var note = '';
28
29                 if (book.html_file) {
30                         // this assumes that either book has a html XOR it has children
31                         target = 'BookText';
32                         note = "<div class='note'>";
33                         if (book._local)
34                                 note += 'Pobrane';
35                         else {
36                                 note += book.pretty_size;
37                         }
38                         note += "</div>";
39                 }
40
41                 return self.button(target, book.id,
42                                 "<div class='sub'>" + book.authors + "</div>" +
43                                 book.title + note);
44         };
45
46         self.deleteButton = function(id) {
47                 return "<div class='delete' onClick='History.deleteBookmark(\""+id+"\");'>x</div>";
48         };
49 }