bookmark-stack

web extension to save pages in a stack for reading them later  https://addons.mozilla.org/firefox/addon/bookmark-stack/
git clone https://git.ce9e.org/bookmark-stack.git

commit
7aa5f1eb3c07ce79158f9ff45ed879d759311d24
parent
99f0480406ce38796aa9600919dffe50bef91939
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2018-12-06 10:37
show message on empty stack

Diffstat

M stack.js 46 +++++++++++++++++++++++++---------------------

1 files changed, 25 insertions, 21 deletions


diff --git a/stack.js b/stack.js

@@ -1,31 +1,35 @@
    1     1 'use struct';
    2     2 
    3     3 var render = function(element, items) {
    4    -1 	element.innerHTML = '';
    5    -1 	items.forEach(function(item) {
    6    -1 		var icon = document.createElement('img');
    7    -1 		icon.className = 'icon';
   -1     4 	if (items.length === 0) {
   -1     5 		element.outerHTML = '<p>No links stored yet.</p>'
   -1     6 	} else {
   -1     7 		element.innerHTML = '';
   -1     8 		items.forEach(function(item) {
   -1     9 			var icon = document.createElement('img');
   -1    10 			icon.className = 'icon';
    8    11 
    9    -1 		if (chrome && typeof browser === 'undefined') {
   10    -1 			icon.src = 'chrome://favicon/' + item.url;
   11    -1 		} else {
   12    -1 			var rootUrl = item.url.split('/').slice(0, 3).join('/');
   13    -1 			icon.src = rootUrl + '/favicon.ico';
   14    -1 		}
   -1    12 			if (chrome && typeof browser === 'undefined') {
   -1    13 				icon.src = 'chrome://favicon/' + item.url;
   -1    14 			} else {
   -1    15 				var rootUrl = item.url.split('/').slice(0, 3).join('/');
   -1    16 				icon.src = rootUrl + '/favicon.ico';
   -1    17 			}
   15    18 
   16    -1 		var a = document.createElement('a');
   17    -1 		a.id = item.id;
   18    -1 		a.href = item.url;
   19    -1 		a.title = item.url;
   20    -1 		a.textContent = item.title || item.url;
   21    -1 		a.prepend(icon);
   -1    19 			var a = document.createElement('a');
   -1    20 			a.id = item.id;
   -1    21 			a.href = item.url;
   -1    22 			a.title = item.url;
   -1    23 			a.textContent = item.title || item.url;
   -1    24 			a.prepend(icon);
   22    25 
   23    -1 		var li = document.createElement('li');
   24    -1 		li.appendChild(a);
   -1    26 			var li = document.createElement('li');
   -1    27 			li.appendChild(a);
   25    28 
   26    -1 		// reverse
   27    -1 		element.prepend(li);
   28    -1 	});
   -1    29 			// reverse
   -1    30 			element.prepend(li);
   -1    31 		});
   -1    32 	}
   29    33 };
   30    34 
   31    35 getBookmarks(function(bookmarks) {