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:
Caleb James DeLisle
2017-09-14 10:23:05 +02:00
parent 710418f42f
commit 8a32b72ffc
7 changed files with 127 additions and 37 deletions

View File

@@ -8,7 +8,7 @@ define([
return Math.random().toString(16).replace('0.', '') + Math.random().toString(16).replace('0.', '');
};
var create = function (ow, cb, isSandbox) {
var create = function (ow, cb, isSandbox, sendData) {
var otherWindow;
var evReady = Util.mkEvent(true);
var handlers = {};
@@ -47,7 +47,6 @@ define([
// Fire an event. channel.event('EV_SOMETHING', { args: "whatever" });
var event = chan.event = function (e, content) {
if (!otherWindow) { throw new Error('not yet initialized'); }
if (!SFrameProtocol[e]) {
throw new Error('please only fire events that are defined in sframe-protocol.js');
}
@@ -63,7 +62,6 @@ define([
// If the type is a query, your handler will be invoked with a reply function that takes
// one argument (the content to reply with).
chan.on = function (queryType, handler, quiet) {
if (!otherWindow && !quiet) { throw new Error('not yet initialized'); }
if (!SFrameProtocol[queryType]) {
throw new Error('please only register handlers which are defined in sframe-protocol.js');
}
@@ -85,7 +83,6 @@ define([
// when that handler is first registered.
// channel.whenReg('Q_SOMETHING', function () { ...query Q_SOMETHING?... });
chan.whenReg = function (queryType, cb, always) {
if (!otherWindow) { throw new Error('not yet initialized'); }
if (!SFrameProtocol[queryType]) {
throw new Error('please only register handlers which are defined in sframe-protocol.js');
}
@@ -109,7 +106,8 @@ define([
delete callWhenRegistered[content];
}
insideHandlers.push(content);
}, true);
});
chan.whenReg('EV_REGISTER_HANDLER', evReady.fire);
// Make sure both iframes are ready
chan.onReady = function (h) {
@@ -131,8 +129,9 @@ define([
//console.log(msg);
} else if (!otherWindow) {
otherWindow = ow;
evReady.fire();
ow.postMessage(JSON.stringify({ txid: data.txid }), '*');
sendData = sendData || {};
sendData.txid = data.txid;
ow.postMessage(JSON.stringify(sendData), '*');
cb(chan);
} else if (typeof(data.q) === 'string' && handlers[data.q]) {
handlers[data.q].forEach(function (f) {