diff options
Diffstat (limited to 'app/Resources/static/themes/_global/js')
-rw-r--r-- | app/Resources/static/themes/_global/js/bookmarklet.js | 2 | ||||
-rw-r--r-- | app/Resources/static/themes/_global/js/restoreScroll.js | 25 |
2 files changed, 27 insertions, 0 deletions
diff --git a/app/Resources/static/themes/_global/js/bookmarklet.js b/app/Resources/static/themes/_global/js/bookmarklet.js new file mode 100644 index 00000000..2afdfc3c --- /dev/null +++ b/app/Resources/static/themes/_global/js/bookmarklet.js | |||
@@ -0,0 +1,2 @@ | |||
1 | |||
2 | top["bookmarklet-url@wallabag.org"]=""+"<!DOCTYPE html>"+"<html>"+"<head>"+"<title>bag it!</title>"+'<link rel="icon" href="tpl/img/favicon.ico" />'+"</head>"+"<body>"+"<script>"+"window.onload=function(){"+"window.setTimeout(function(){"+"history.back();"+"},250);"+"};"+"</scr"+"ipt>"+"</body>"+"</html>" | ||
diff --git a/app/Resources/static/themes/_global/js/restoreScroll.js b/app/Resources/static/themes/_global/js/restoreScroll.js new file mode 100644 index 00000000..e63d06c6 --- /dev/null +++ b/app/Resources/static/themes/_global/js/restoreScroll.js | |||
@@ -0,0 +1,25 @@ | |||
1 | function supportsLocalStorage() { | ||
2 | try { | ||
3 | return 'localStorage' in window && window['localStorage'] !== null; | ||
4 | } catch (e) { | ||
5 | return false; | ||
6 | } | ||
7 | } | ||
8 | |||
9 | function savePercent(id, percent) { | ||
10 | if (!supportsLocalStorage()) { return false; } | ||
11 | localStorage["wallabag.article." + id + ".percent"] = percent; | ||
12 | return true; | ||
13 | } | ||
14 | |||
15 | function retrievePercent(id) { | ||
16 | if (!supportsLocalStorage()) { return false; } | ||
17 | |||
18 | var bheight = $(document).height(); | ||
19 | var percent = localStorage["wallabag.article." + id + ".percent"]; | ||
20 | var scroll = bheight * percent; | ||
21 | |||
22 | $('html,body').animate({scrollTop: scroll}, 'fast'); | ||
23 | |||
24 | return true; | ||
25 | } | ||