mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-25 04:24:45 -04:00
Clean store module. Publish test build commands.
This commit is contained in:
parent
e99bd06370
commit
c20da80bda
2 changed files with 42 additions and 11 deletions
35
mkrfile.js
35
mkrfile.js
|
@ -128,4 +128,39 @@ module.exports = function (suite) {
|
||||||
.jszip({dir: build, level: 9})
|
.jszip({dir: build, level: 9})
|
||||||
.write(target, true);
|
.write(target, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
suite.target('build-test', [], 'build a test suite').task(function () {
|
||||||
|
|
||||||
|
$(src + '/_h5ai/client/css/styles.less')
|
||||||
|
.less()
|
||||||
|
.autoprefixer()
|
||||||
|
.write(build + '/test/h5ai-styles.css', true);
|
||||||
|
|
||||||
|
$(src + '/_h5ai/client/js/scripts.js')
|
||||||
|
.includeit()
|
||||||
|
.write(build + '/test/h5ai-scripts.js', true);
|
||||||
|
|
||||||
|
$(root + '/test/styles.less')
|
||||||
|
.less()
|
||||||
|
.autoprefixer()
|
||||||
|
.write(build + '/test/styles.css', true);
|
||||||
|
|
||||||
|
$(root + '/test/scripts.js')
|
||||||
|
.includeit()
|
||||||
|
.write(build + '/test/scripts.js', true);
|
||||||
|
|
||||||
|
$(root + '/test/tests.js')
|
||||||
|
.includeit()
|
||||||
|
.write(build + '/test/tests.js', true);
|
||||||
|
|
||||||
|
$(root + '/test/index.html.jade')
|
||||||
|
.jade()
|
||||||
|
.write(build + '/test/index.html', true);
|
||||||
|
|
||||||
|
$.report({
|
||||||
|
type: 'info',
|
||||||
|
message: 'browse to file://' + build + '/test/index.html'
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,31 +1,27 @@
|
||||||
modulejs.define('core/store', ['modernizr'], function (modernizr) {
|
modulejs.define('core/store', ['modernizr'], function (modernizr) {
|
||||||
|
|
||||||
var store = modernizr.localstorage ? window.localStorage : null;
|
var store = modernizr.localstorage ? window.localStorage : {};
|
||||||
var key = '_h5ai';
|
var storekey = '_h5ai';
|
||||||
|
|
||||||
|
|
||||||
function load() {
|
function load() {
|
||||||
|
|
||||||
if (store) {
|
try {
|
||||||
try {
|
return JSON.parse(store[storekey]);
|
||||||
return JSON.parse(store[key]);
|
} catch (e) {}
|
||||||
} catch (e) {}
|
|
||||||
}
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
function save(obj) {
|
function save(obj) {
|
||||||
|
|
||||||
if (store) {
|
store[storekey] = JSON.stringify(obj);
|
||||||
store[key] = JSON.stringify(obj);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function put(key, value) {
|
function put(key, value) {
|
||||||
|
|
||||||
var obj = load();
|
var obj = load();
|
||||||
obj[key] = value;
|
obj[key] = value;
|
||||||
return save(obj);
|
save(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
function get(key) {
|
function get(key) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue