mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-03-20 04:20:00 +01:00
Updates storage.
This commit is contained in:
parent
e6bbb7c2cd
commit
e43d43933a
@ -1,25 +1,37 @@
|
||||
|
||||
modulejs.define('core/store', ['_'], function (_) {
|
||||
modulejs.define('core/store', ['_', 'modernizr'], function (_, modernizr) {
|
||||
|
||||
var store = window.localStorage,
|
||||
var store = modernizr.localstorage ? window.localStorage : null,
|
||||
|
||||
key = '_h5ai',
|
||||
|
||||
load = function () {
|
||||
|
||||
if (store) {
|
||||
try {
|
||||
return JSON.parse(store[key]);
|
||||
} catch (e) {}
|
||||
}
|
||||
return {};
|
||||
},
|
||||
|
||||
save = function (obj) {
|
||||
|
||||
if (store) {
|
||||
store[key] = JSON.stringify(obj);
|
||||
}
|
||||
},
|
||||
|
||||
put = function (key, value) {
|
||||
|
||||
if (store && _.isString(key)) {
|
||||
store[key] = JSON.stringify({data: value});
|
||||
}
|
||||
var obj = load();
|
||||
obj[key] = value;
|
||||
return save(obj);
|
||||
},
|
||||
|
||||
get = function (key) {
|
||||
|
||||
if (store && _.isString(key)) {
|
||||
var json = store[key],
|
||||
obj = {};
|
||||
|
||||
try { obj = JSON.parse(json); } catch (e) {}
|
||||
|
||||
return obj.data;
|
||||
}
|
||||
return load()[key];
|
||||
};
|
||||
|
||||
return {
|
||||
|
@ -34,7 +34,7 @@ modulejs.define('ext/l10n', ['_', '$', 'core/settings', 'core/langs', 'core/form
|
||||
'</span>',
|
||||
langOptionTemplate = '<li class="langOption"/>',
|
||||
|
||||
storekey = 'h5ai.language',
|
||||
storekey = 'l10n.lang',
|
||||
|
||||
loaded = {
|
||||
en: _.extend({}, defaultTranslations)
|
||||
|
@ -28,7 +28,7 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/resource',
|
||||
'</div>' +
|
||||
'</div>',
|
||||
|
||||
storekey = 'h5ai.preview-img.isFullscreen',
|
||||
storekey = 'preview-img.isFullscreen',
|
||||
|
||||
currentEntries = [],
|
||||
currentIdx = 0,
|
||||
|
@ -6,7 +6,7 @@ modulejs.define('ext/sort', ['_', '$', 'core/settings', 'core/resource', 'core/e
|
||||
order: 'na'
|
||||
}, allsettings.sort),
|
||||
|
||||
storekey = 'h5ai.sortorder',
|
||||
storekey = 'sort.order',
|
||||
|
||||
type = function (entry) {
|
||||
|
||||
|
@ -7,7 +7,7 @@ modulejs.define('view/viewmode', ['_', '$', 'core/settings', 'core/resource', 'c
|
||||
modes: modes
|
||||
}, allsettings.view),
|
||||
|
||||
storekey = 'h5ai.viewmode',
|
||||
storekey = 'viewmode',
|
||||
|
||||
template = '<li id="view-[MODE]" class="view">' +
|
||||
'<a href="#">' +
|
||||
|
18
src/_h5ai/client/js/lib/modernizr-2.6.2.js
vendored
18
src/_h5ai/client/js/lib/modernizr-2.6.2.js
vendored
@ -1,5 +1,5 @@
|
||||
/* Modernizr 2.6.2 (Custom Build) | MIT & BSD
|
||||
* Build: http://modernizr.com/download/#-opacity-rgba-canvas-history-audio-video-shiv-cssclasses-prefixes
|
||||
* Build: http://modernizr.com/download/#-opacity-rgba-canvas-history-audio-video-localstorage-shiv-cssclasses-prefixes
|
||||
*/
|
||||
;
|
||||
|
||||
@ -182,7 +182,21 @@ window.Modernizr = (function( window, document, undefined ) {
|
||||
} catch(e) { }
|
||||
|
||||
return bool;
|
||||
}; for ( var feature in tests ) {
|
||||
};
|
||||
|
||||
|
||||
tests['localstorage'] = function() {
|
||||
try {
|
||||
localStorage.setItem(mod, mod);
|
||||
localStorage.removeItem(mod);
|
||||
return true;
|
||||
} catch(e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
for ( var feature in tests ) {
|
||||
if ( hasOwnProp(tests, feature) ) {
|
||||
featureName = feature.toLowerCase();
|
||||
Modernizr[featureName] = tests[feature]();
|
||||
|
Loading…
x
Reference in New Issue
Block a user