1. implement cryptpadCache which has put() and get() functions that can be used like a localStorage that auto-flushes when a new version is released
2. change loading.js to use packaged css in order to get the loading screen up as quick as possible. 3. change LessLoader to cache less in cryptpadCache
This commit is contained in:
@@ -6,32 +6,6 @@
|
||||
// sed -i -e 's@/common/sframe-boot.js?ver=[^"]*@/common/sframe-boot.js?ver=1.3@' $x; done
|
||||
;(function () {
|
||||
var afterLoaded = function (req) {
|
||||
var localStorage = {};
|
||||
if (req.cfg && req.cfg.urlArgs) {
|
||||
try {
|
||||
localStorage = window.localStorage;
|
||||
if (localStorage['CRYPTPAD_VERSION'] !== req.cfg.urlArgs) {
|
||||
// new version, flush
|
||||
Object.keys(localStorage).forEach(function (k) {
|
||||
if (!k.indexOf('CRYPTPAD_CACHE_')) { delete localStorage[k]; }
|
||||
});
|
||||
localStorage['CRYPTPAD_VERSION'] = req.cfg.urlArgs;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
localStorage = {};
|
||||
}
|
||||
}
|
||||
window.cryptpadCache = Object.freeze({
|
||||
put: function (k, v, cb) {
|
||||
cb = cb || function () { };
|
||||
setTimeout(function () { localStorage['CRYPTPAD_CACHE_' + k] = v; cb(); });
|
||||
},
|
||||
get: function (k, cb) {
|
||||
if (!cb) { throw new Error(); }
|
||||
setTimeout(function () { cb(localStorage['CRYPTPAD_CACHE_' + k]); });
|
||||
}
|
||||
});
|
||||
req.cfg = req.cfg || {};
|
||||
if (req.pfx) {
|
||||
req.cfg.onNodeCreated = function (node /*, config, module, path*/) {
|
||||
@@ -54,6 +28,20 @@ var afterLoaded = function (req) {
|
||||
clearInterval(intr);
|
||||
txid = {};
|
||||
window.removeEventListener('message', onReply);
|
||||
data.cache = data.cache || {};
|
||||
var updated = {};
|
||||
window.cryptpadCache = {
|
||||
get: function (k, cb) {
|
||||
setTimeout(function () { cb(data.cache[k]); });
|
||||
},
|
||||
put: function (k, v, cb) {
|
||||
cb = cb || function () { };
|
||||
updated[k] = v;
|
||||
setTimeout(function () { data.cache[k] = v; cb(); });
|
||||
},
|
||||
updated: updated,
|
||||
cache: data.cache
|
||||
};
|
||||
require(['/common/sframe-boot2.js'], function () { });
|
||||
};
|
||||
window.addEventListener('message', onReply);
|
||||
|
||||
Reference in New Issue
Block a user