summaryrefslogtreecommitdiffstats
path: root/src/navtree.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/navtree.js')
-rw-r--r--src/navtree.js26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/navtree.js b/src/navtree.js
index 4fb2c87..5549d7f 100644
--- a/src/navtree.js
+++ b/src/navtree.js
@@ -22,9 +22,15 @@ function stripPath2(uri)
function localStorageSupported()
{
- return 'localStorage' in window && window['localStorage'] !== null;
+ try {
+ return 'localStorage' in window && window['localStorage'] !== null && window.localStorage.getItem;
+ }
+ catch(e) {
+ return false;
+ }
}
+
function storeLink(link)
{
if (!$("#nav-sync").hasClass('sync') && localStorageSupported()) {
@@ -411,16 +417,26 @@ function navTo(o,root,hash,relpath)
}
}
+function showSyncOff(n,relpath)
+{
+ n.html('<img src="'+relpath+'sync_off.png" title="'+SYNCOFFMSG+'"/>');
+}
+
+function showSyncOn(n,relpath)
+{
+ n.html('<img src="'+relpath+'sync_on.png"/ title="'+SYNCONMSG+'">');
+}
+
function toggleSyncButton(relpath)
{
var navSync = $('#nav-sync');
if (navSync.hasClass('sync')) {
navSync.removeClass('sync');
- navSync.html('<img src="'+relpath+'sync_off.png"/>');
+ showSyncOff(navSync,relpath);
storeLink(stripPath2($(location).attr('pathname'))+$(location).attr('hash'));
} else {
navSync.addClass('sync');
- navSync.html('<img src="'+relpath+'sync_on.png"/>');
+ showSyncOn(navSync,relpath);
deleteLink();
}
}
@@ -448,10 +464,10 @@ function initNavTree(toroot,relpath)
if (localStorageSupported()) {
var navSync = $('#nav-sync');
if (cachedLink()) {
- navSync.html('<img src="'+relpath+'sync_off.png"/>');
+ showSyncOff(navSync,relpath);
navSync.removeClass('sync');
} else {
- navSync.html('<img src="'+relpath+'sync_on.png"/>');
+ showSyncOn(navSync,relpath);
}
navSync.click(function(){ toggleSyncButton(relpath); });
}