pretty much working version
[wl-mobile.git] / assets / www / js / links.js
diff --git a/assets/www/js/links.js b/assets/www/js/links.js
new file mode 100644 (file)
index 0000000..ff2bb12
--- /dev/null
@@ -0,0 +1,49 @@
+
+var Links = new function() {
+       var self = this;
+
+       self.href = function(view, par) {
+               return view+"/"+par;
+       };
+
+       self.button = function(view, par, text, offset) {
+               offset = offset || 0;
+               var html = "<div class='button button-"+view+"' onclick='History.visit(\"" + 
+                                       self.href(view, par).replace(/["']/g, "\\$&") + "\", "+offset+");'>";
+               icon = view;
+               if (icon != 'Book' && icon != 'Bookmarks' && icon != 'BookText' && 
+                       icon != 'Last' && icon != 'Tag') {
+                   icon = 'Tag';
+               }
+               html += "<img src='img/icon-" + icon + ".png' />";
+               html += "<div class='label'>" + text + "</div>";
+               html += "<div class='clr'></div>";
+               html += "</div>\n";
+               return html; 
+       };
+
+       self.bookLink = function(book) {
+               var target = 'Book';
+               var note = '';
+
+               if (book.html_file) {
+                       // this assumes that either book has a html XOR it has children
+                       target = 'BookText';
+                       note = "<div class='note'>";
+                       if (book._local)
+                               note += 'Pobrane';
+                       else {
+                               note += book.pretty_size;
+                       }
+                       note += "</div>";
+               }
+
+               return self.button(target, book.id,
+                               "<div class='sub'>" + book.authors + "</div>" +
+                               book.title + note);
+       };
+
+       self.deleteButton = function(id) {
+               return "<div class='delete' onClick='History.deleteBookmark(\""+id+"\");'>x</div>";
+       };
+}