};
// Settings Manager - This is a utility for saving settings
-// First we see if localStorage is available, which isn't pt. in FF due to bug #495747
+// First we see if localStorage is available, FF bug #495747
// If not, we use FUEL in FF and fallback to Cookies for other browsers.
var Settings = (function settingsClosure() {
var isCookiesEnabled = (function() {
var isLocalStorageEnabled = (function localStorageEnabledTest() {
try {
localStorage;
- } catch(e) {
+ } catch (e) {
return false;
}
return true;
return {
set: function settingsSet(name, val) {
- if(location.protocol == 'chrome:' && !isLocalStorageEnabled) {
- Application.prefs.setValue(extPrefix + '.' + name, val);
- } else if(isLocalStorageEnabled) {
+ if (location.protocol == 'chrome:' && !isLocalStorageEnabled) {
+ Application.prefs.setValue(extPrefix + '.' + name, val);
+ } else if (isLocalStorageEnabled) {
localStorage.setItem(name, val);
- } else if(isCookiesEnabled) {
+ } else if (isCookiesEnabled) {
var cookieString = name + '=' + escape(val);
- var expire = (new Date((new Date().getTime())+1000*60*60*24*365)).toGMTString();
- cookieString += '; expires='+expire;
- document.cookie = cookieString;
- }
+ var expire = new Date();
+ expire.setTime(expire.getTime() + 1000 * 60 * 60 * 24 * 365);
+ cookieString += '; expires=' + expire.toGMTString();
+ document.cookie = cookieString;
+ }
},
get: function settingsGet(name, defaultValue) {
- if(location.protocol == 'chrome:' && !isLocalStorageEnabled) {
- return Application.prefs.getValue(extPrefix + '.' + name, defaultValue);
- } else if(isLocalStorageEnabled) {
+ if (location.protocol == 'chrome:' && !isLocalStorageEnabled) {
+ var preferenceName = extPrefix + '.' + name;
+ return Application.prefs.getValue(preferenceName, defaultValue);
+ } else if (isLocalStorageEnabled) {
return localStorage.getItem(name) || defaultValue;
- } else if(isCookiesEnabled) {
- var res = document.cookie.match ( '(^|;) ?' + name + '=([^;]*)(;|$)' );
+ } else if (isCookiesEnabled) {
+ var res = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
return res ? unescape(res[2]) : defaultValue;
}
}
setTimeout(function scrollWindow() {
window.scrollTo(0, scroll);
}, 0);
- } else
+ } else
this.page = 1;
}
},
window.addEventListener('scroll', function webViewerScroll(evt) {
updateViewarea();
- var id;
- if((id = PDFView.pages[0].content.pdf.fingerprint)) {
- Settings.set(id+'.scroll', window.pageYOffset);
- }
+ var fingerprint = PDFView.pages[0].content.pdf.fingerprint;
+ Settings.set(fingerprint + '.scroll', window.pageYOffset);
}, true);