Merge branch 'staging' of github.com:xwiki-labs/cryptpad into staging

pull/1/head
yflory 7 years ago
commit 1091e0b375

@ -296,7 +296,7 @@ noscript {
left: 0; left: 0;
bottom: 0; bottom: 0;
right: 0; right: 0;
z-index: 2; z-index: 2; // noscriptContainer
#noscript { #noscript {
width: 1000px; width: 1000px;
display: flex; display: flex;
@ -341,7 +341,7 @@ noscript {
left: 0; left: 0;
right: 0; right: 0;
margin: auto; margin: auto;
z-index: 1; z-index: 1; // #main, #main_other
font-size: medium; font-size: medium;
@ -607,7 +607,7 @@ noscript {
background: blue; background: blue;
position: absolute; position: absolute;
left: 0; left: 0;
z-index:1; z-index:1; // .usage
&.normal { &.normal {
background: @toolbar-green; background: @toolbar-green;
} }
@ -622,7 +622,7 @@ noscript {
position: relative; position: relative;
color: black; color: black;
text-shadow: 1px 0 2px white, 0 1px 2px white, -1px 0 2px white, 0 -1px 2px white; text-shadow: 1px 0 2px white, 0 1px 2px white, -1px 0 2px white, 0 -1px 2px white;
z-index: 2; z-index: 2; // .usageText
font-size: @main-font-size; font-size: @main-font-size;
font-weight: bold; font-weight: bold;
} }
@ -644,7 +644,7 @@ noscript {
bottom: 10vh; bottom: 10vh;
opacity: 0.9; opacity: 0.9;
box-sizing: border-box; box-sizing: border-box;
z-index: 10000; z-index: 10000; // #uploadStatusContainer
display: none; display: none;
#uploadStatus { #uploadStatus {
width: 80vw; width: 80vw;
@ -674,7 +674,7 @@ noscript {
left: @upload_pad_v; left: @upload_pad_v;
top: @upload_pad_h; bottom: @upload_pad_h; top: @upload_pad_h; bottom: @upload_pad_h;
background-color: rgba(0,0,255,0.3); background-color: rgba(0,0,255,0.3);
z-index: -1; z-index: -1; // .progressContainer
} }
.upCancel { text-align: center; } .upCancel { text-align: center; }
.fa.cancel { .fa.cancel {

@ -259,7 +259,7 @@ body .cryptpad-toolbar {
font: @toolbar-button-font; font: @toolbar-button-font;
width: 100%; width: 100%;
z-index: 9001; z-index: 10000; // body, .cryptpad-toolbar
.cp-dropdown-container { .cp-dropdown-container {
//height: 100%; //height: 100%;
@ -792,7 +792,7 @@ body .cryptpad-toolbar {
cursor: pointer; cursor: pointer;
} }
.cryptpad-user-dropdown { .cryptpad-user-dropdown {
z-index: 10000; z-index: 10000; // .cryptpad-user-dropdown
//margin-left: 20px; //margin-left: 20px;
height: 64px; height: 64px;
width: 64px; width: 64px;
@ -915,7 +915,7 @@ body .cryptpad-toolbar {
background: @dropdown-bg; background: @dropdown-bg;
display: flex; display: flex;
flex-flow: column; flex-flow: column;
z-index:10000; z-index:10000; // .drawer-content
color: black; color: black;
.fa { .fa {
font-size: 17px; font-size: 17px;

@ -64,7 +64,7 @@
bottom: 0; bottom: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
z-index: 99999; // alertify container z-index: 100000; // alertify container
&.forefront { &.forefront {
z-index: @max-z-index; // alertify max forefront z-index: @max-z-index; // alertify max forefront
} }

@ -28,7 +28,7 @@
background-color: @colortheme_dropdown-bg; background-color: @colortheme_dropdown-bg;
min-width: 250px; min-width: 250px;
box-shadow: 0px 1px 5px 0px rgba(0, 0, 0, 0.2); box-shadow: 0px 1px 5px 0px rgba(0, 0, 0, 0.2);
z-index: 1000; z-index: 1000; //Z dropdown content
max-height: 300px; max-height: 300px;
overflow-y: auto; overflow-y: auto;
font: @dropdown_font; font: @dropdown_font;

@ -10,7 +10,7 @@
bottom: 10vh; bottom: 10vh;
opacity: 0.9; opacity: 0.9;
box-sizing: border-box; box-sizing: border-box;
z-index: 1000000; z-index: 1000000; //Z file upload table container
display: none; display: none;
#cp-fileupload-table { #cp-fileupload-table {
width: 80vw; width: 80vw;
@ -40,7 +40,7 @@
left: @upload_pad_v; left: @upload_pad_v;
top: @upload_pad_h; bottom: @upload_pad_h; top: @upload_pad_h; bottom: @upload_pad_h;
background-color: rgba(0,0,255,0.3); background-color: rgba(0,0,255,0.3);
z-index: -1; z-index: -1; //Z file upload progress container
} }
.cp-fileupload-table-cancel { text-align: center; } .cp-fileupload-table-cancel { text-align: center; }
.fa.cancel { .fa.cancel {

@ -117,7 +117,7 @@
.infopages_topbar () { .infopages_topbar () {
.cp-topbar { .cp-topbar {
background: #fff; background: #fff;
z-index: 9001; z-index: 10000; //Z infopage toolbar
position: fixed; position: fixed;
top: 0; top: 0;
display: flex; display: flex;

@ -20,7 +20,7 @@
.cp-modal-container { .cp-modal-container {
display: none; display: none;
z-index: 100000; z-index: 100000; //Z modal container
position: absolute; position: absolute;
top: 0; top: 0;
bottom: 0; bottom: 0;

@ -274,7 +274,7 @@
font: @toolbar_button-font; font: @toolbar_button-font;
width: 100%; width: 100%;
z-index: 9001; z-index: 10000; // cp-toolbar
.cp-dropdown-container { .cp-dropdown-container {
//height: 100%; //height: 100%;
@ -597,7 +597,7 @@
vertical-align: top; vertical-align: top;
} }
.cp-toolbar-user-dropdown { .cp-toolbar-user-dropdown {
z-index: 10000; z-index: 10000; //Z cp-toolbar-user-dropdown
//margin-left: 20px; //margin-left: 20px;
height: 64px; height: 64px;
width: 64px; width: 64px;
@ -737,7 +737,7 @@
background: @colortheme_dropdown-bg; background: @colortheme_dropdown-bg;
display: flex; display: flex;
flex-flow: column; flex-flow: column;
z-index:10000; z-index:10000; //Z cp-toolbar-drawer-content
color: black; color: black;
.fa { .fa {
font-size: 17px; font-size: 17px;

@ -1,9 +1,14 @@
/*
WARNING: THIS FILE DOES NOTHING
It exists only as a proposal of what CSS you should use in loading.js
The CSS inside of loading.js is precompiled in order to save 200ish milliseconds to the loading screen.
*/
@import (once) "./include/colortheme.less"; @import (once) "./include/colortheme.less";
@import (once) "./include/browser.less"; @import (once) "./include/browser.less";
#cp-loading { #cp-loading {
position: fixed; position: fixed;
z-index: 9999999; z-index: 10000000; // #loading
top: 0px; top: 0px;
bottom: 0px; bottom: 0px;
left: 0px; left: 0px;
@ -35,7 +40,7 @@
} }
#cp-loading-tip { #cp-loading-tip {
position: fixed; position: fixed;
z-index: 99999; z-index: 100000; // loading tip
top: 80%; top: 80%;
left: 0; left: 0;
right: 0; right: 0;

@ -177,7 +177,7 @@ define(function () {
out.fileShare = "Copier le lien"; out.fileShare = "Copier le lien";
out.getEmbedCode = "Obtenir le code d'intégration"; out.getEmbedCode = "Obtenir le code d'intégration";
out.viewEmbedTitle = "Intégrer le pad dans une page web"; out.viewEmbedTitle = "Intégrer le pad dans une page web";
out.viewEmbedTag = "Pour intégrer ce pad, veuillez inclure l'iframe suivant dans votre page là om vous souhaitez l'afficher. Vous pouvez changer sa taille en utilisant du code CSS ou des attributs HTML."; out.viewEmbedTag = "Pour intégrer ce pad, veuillez inclure l'iframe suivant dans votre page là où vous souhaitez l'afficher. Vous pouvez changer sa taille en utilisant du code CSS ou des attributs HTML.";
out.fileEmbedTitle = "Intégrer le fichier dans une page web"; out.fileEmbedTitle = "Intégrer le fichier dans une page web";
out.fileEmbedScript = "Pour intégrer un fichier, veuillez inclure le script suivant une fois dans votre page afin de pouvoir charger le Media Tag :"; out.fileEmbedScript = "Pour intégrer un fichier, veuillez inclure le script suivant une fois dans votre page afin de pouvoir charger le Media Tag :";
out.fileEmbedTag = "Ensuite vous pouvez placer ce Media Tag où vous souhaitez dans votre page pour l'intégrer :"; out.fileEmbedTag = "Ensuite vous pouvez placer ce Media Tag où vous souhaitez dans votre page pour l'intégrer :";

@ -2,7 +2,7 @@
<html class="cp-app-noscroll"> <html class="cp-app-noscroll">
<head> <head>
<meta content="text/html; charset=utf-8" http-equiv="content-type"/> <meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<script async data-bootload="/code/inner.js" data-main="/common/sframe-boot.js?ver=1.3" src="/bower_components/requirejs/require.js?ver=2.3.5"></script> <script async data-bootload="/code/inner.js" data-main="/common/sframe-boot.js?ver=1.4" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
<style> <style>
.loading-hidden { display: none; } .loading-hidden { display: none; }
#editor1 { display: none; } #editor1 { display: none; }

@ -25,7 +25,7 @@ define([
var cacheGet = function (k, cb) { var cacheGet = function (k, cb) {
if (window.cryptpadCache) { return void window.cryptpadCache.get(k, cb); } if (window.cryptpadCache) { return void window.cryptpadCache.get(k, cb); }
setTimeout(function () { cb(localStorage['LESS_CACHE|' + key + '|' + k]); }) setTimeout(function () { cb(localStorage['LESS_CACHE|' + key + '|' + k]); });
}; };
var cachePut = function (k, v, cb) { var cachePut = function (k, v, cb) {
if (window.cryptpadCache) { return void window.cryptpadCache.put(k, v, cb); } if (window.cryptpadCache) { return void window.cryptpadCache.put(k, v, cb); }

@ -20,9 +20,10 @@ define([
'/common/pinpad.js', '/common/pinpad.js',
'/customize/application_config.js', '/customize/application_config.js',
'/common/media-tag.js', '/common/media-tag.js',
'/bower_components/nthen/index.js',
], function ($, Config, Messages, Store, Util, Hash, UI, History, UserList, Title, Metadata, ], function ($, Config, Messages, Store, Util, Hash, UI, History, UserList, Title, Metadata,
Messaging, CodeMirror, Files, FileCrypto, Realtime, Clipboard, Messaging, CodeMirror, Files, FileCrypto, Realtime, Clipboard,
Pinpad, AppConfig, MediaTag) { Pinpad, AppConfig, MediaTag, Nthen) {
// Configure MediaTags to use our local viewer // Configure MediaTags to use our local viewer
if (MediaTag && MediaTag.PdfPlugin) { if (MediaTag && MediaTag.PdfPlugin) {
@ -2071,23 +2072,8 @@ define([
return function (f) { return function (f) {
if (initialized) { if (initialized) {
return void window.setTimeout(function () { return void setTimeout(function () { f(void 0, env); });
f(void 0, env);
});
}
var block = 0;
var cb = function () {
block--;
if (!block) {
initialized = true;
updateLocalVersion();
common.addTooltips();
f(void 0, env);
if (typeof(window.onhashchange) === 'function') { window.onhashchange(); }
} }
};
if (sessionStorage[newPadNameKey]) { if (sessionStorage[newPadNameKey]) {
common.initialName = sessionStorage[newPadNameKey]; common.initialName = sessionStorage[newPadNameKey];
@ -2097,7 +2083,6 @@ define([
common.initialPath = sessionStorage[newPadPathKey]; common.initialPath = sessionStorage[newPadPathKey];
delete sessionStorage[newPadPathKey]; delete sessionStorage[newPadPathKey];
} }
common.onFriendRequest = function (confirmText, cb) { common.onFriendRequest = function (confirmText, cb) {
common.confirm(confirmText, cb, null, true); common.confirm(confirmText, cb, null, true);
}; };
@ -2105,20 +2090,9 @@ define([
common.log(data.logText); common.log(data.logText);
}; };
Store.ready(function (err, storeObj) { var proxy;
store = common.store = env.store = storeObj; var network;
common.addDirectMessageHandler(common); var provideFeedback = function () {
var proxy = getProxy();
var network = getNetwork();
network.on('disconnect', function () {
Realtime.setConnectionState(false);
});
network.on('reconnect', function () {
Realtime.setConnectionState(true);
});
if (Object.keys(proxy).length === 1) { if (Object.keys(proxy).length === 1) {
feedback("FIRST_APP_USE", true); feedback("FIRST_APP_USE", true);
} }
@ -2141,8 +2115,25 @@ define([
} }
common.reportScreenDimensions(); common.reportScreenDimensions();
common.reportLanguage(); common.reportLanguage();
};
$(function() { Nthen(function (waitFor) {
Store.ready(waitFor(function (err, storeObj) {
store = common.store = env.store = storeObj;
common.addDirectMessageHandler(common);
proxy = getProxy();
network = getNetwork();
network.on('disconnect', function () {
Realtime.setConnectionState(false);
});
network.on('reconnect', function () {
Realtime.setConnectionState(true);
});
provideFeedback();
}), common);
}).nThen(function (waitFor) {
$(waitFor());
}).nThen(function (waitFor) {
// Race condition : if document.body is undefined when alertify.js is loaded, Alertify // Race condition : if document.body is undefined when alertify.js is loaded, Alertify
// won't work. We have to reset it now to make sure it uses a correct "body" // won't work. We have to reset it now to make sure it uses a correct "body"
UI.Alertify.reset(); UI.Alertify.reset();
@ -2164,19 +2155,16 @@ define([
document.location.reload(); document.location.reload();
return; return;
} }
if (parsedNew) { if (parsedNew) { oldHref = newHref; }
oldHref = newHref;
}
}; };
if (PINNING_ENABLED && isLoggedIn()) { if (PINNING_ENABLED && isLoggedIn()) {
console.log("logged in. pads will be pinned"); console.log("logged in. pads will be pinned");
block++; var w0 = waitFor();
Pinpad.create(network, proxy, function (e, call) { Pinpad.create(network, proxy, function (e, call) {
if (e) { if (e) {
console.error(e); console.error(e);
return cb(); return w0();
} }
console.log('RPC handshake complete'); console.log('RPC handshake complete');
@ -2187,7 +2175,7 @@ define([
common.account.limit = limit; common.account.limit = limit;
localStorage.plan = common.account.plan = plan; localStorage.plan = common.account.plan = plan;
common.account.note = note; common.account.note = note;
cb(); w0();
}); });
common.arePinsSynced(function (err, yes) { common.arePinsSynced(function (err, yes) {
@ -2208,43 +2196,42 @@ define([
console.log('pinning disabled'); console.log('pinning disabled');
} }
block++; var w1 = waitFor();
require([ require([
'/common/rpc.js', '/common/rpc.js',
], function (Rpc) { ], function (Rpc) {
Rpc.createAnonymous(network, function (e, call) { Rpc.createAnonymous(network, function (e, call) {
if (e) { if (e) {
console.error(e); console.error(e);
return void cb(); return void w1();
} }
anon_rpc = common.anon_rpc = env.anon_rpc = call; anon_rpc = common.anon_rpc = env.anon_rpc = call;
cb(); w1();
}); });
}); });
// Everything's ready, continue... // Everything's ready, continue...
if($('#pad-iframe').length) { if($('#pad-iframe').length) {
block++; var w2 = waitFor();
var $iframe = $('#pad-iframe'); var $iframe = $('#pad-iframe');
var iframe = $iframe[0]; var iframe = $iframe[0];
var iframeDoc = iframe.contentDocument || iframe.contentWindow.document; var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
if (iframeDoc.readyState === 'complete') { if (iframeDoc.readyState === 'complete') {
cb(); return void w2();
return;
} }
$iframe.load(cb); $iframe.load(w2); //cb);
return;
} }
}).nThen(function () {
block++; updateLocalVersion();
cb(); common.addTooltips();
f(void 0, env);
if (typeof(window.onhashchange) === 'function') { window.onhashchange(); }
}); });
}, common);
}; };
}()); }());
// MAGIC that happens implicitly
$(function () { $(function () {
Messages._applyTranslation(); Messages._applyTranslation();
}); });

@ -1,11 +1,73 @@
define([ define([], function () {
'less!/bower_components/components-font-awesome/css/font-awesome.min.css', var loadingStyle = (function(){/*
'less!/customize/src/less2/loading.less' #cp-loading {
], function () { position: fixed;
z-index: 10000000;
top: 0px;
bottom: 0px;
left: 0px;
right: 0px;
background: #222;
color: #fafafa;
text-align: center;
font-size: 1.5em;
}
#cp-loading .cp-loading-container {
margin-top: 50vh;
transform: translateY(-50%);
}
#cp-loading .cp-loading-cryptofist {
margin-left: auto;
margin-right: auto;
height: 300px;
margin-bottom: 2em;
}
@media screen and (max-height: 450px) {
#cp-loading .cp-loading-cryptofist {
display: none;
}
}
#cp-loading .cp-loading-spinner-container {
position: relative;
height: 100px;
}
#cp-loading .cp-loading-spinner-container > div {
height: 100px;
}
#cp-loading-tip {
position: fixed;
z-index: 100000;
top: 80%;
left: 0;
right: 0;
text-align: center;
transition: opacity 750ms;
transition-delay: 3000ms;
}
@media screen and (max-height: 600px) {
#cp-loading-tip {
display: none;
}
}
#cp-loading-tip span {
background: #222;
color: #fafafa;
text-align: center;
font-size: 1.5em;
opacity: 0.7;
font-family: 'Open Sans', 'Helvetica Neue', sans-serif;
padding: 15px;
max-width: 60%;
display: inline-block;
}
*/}).toString().slice(14, -3);
var urlArgs = window.location.href.replace(/^.*\?([^\?]*)$/, function (all, x) { return x; }); var urlArgs = window.location.href.replace(/^.*\?([^\?]*)$/, function (all, x) { return x; });
var elem = document.createElement('div'); var elem = document.createElement('div');
elem.setAttribute('id', 'cp-loading'); elem.setAttribute('id', 'cp-loading');
elem.innerHTML = [ elem.innerHTML = [
'<style>',
loadingStyle,
'</style>',
'<div class="cp-loading-container">', '<div class="cp-loading-container">',
'<img class="cp-loading-cryptofist" src="/customize/cryptpad-new-logo-colors-logoonly.png?' + urlArgs + '">', '<img class="cp-loading-cryptofist" src="/customize/cryptpad-new-logo-colors-logoonly.png?' + urlArgs + '">',
'<div class="cp-loading-spinner-container">', '<div class="cp-loading-spinner-container">',

@ -2,36 +2,10 @@
// Note that this file is meant to be executed only inside of a sandbox iframe. // Note that this file is meant to be executed only inside of a sandbox iframe.
// //
// IF YOU EDIT THIS FILE, bump the version (replace 1.3 in the following command with the next version.) // IF YOU EDIT THIS FILE, bump the version (replace 1.3 in the following command with the next version.)
// grep -nr '/common/sframe-boot.js?ver=' | sed 's/:.*$//' | while read x; do \ // grep -nr '/common/sframe-boot.js?ver=' | sed 's/:.*$//' | grep -v 'sframe-boot.js' | while read x; do \
// sed -i -e 's@/common/sframe-boot.js?ver=[^"]*@/common/sframe-boot.js?ver=1.3@' $x; done // sed -i -e 's@/common/sframe-boot.js?ver=[^"]*@/common/sframe-boot.js?ver=1.3@' $x; done
;(function () { ;(function () {
var afterLoaded = function (req) { 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 || {}; req.cfg = req.cfg || {};
if (req.pfx) { if (req.pfx) {
req.cfg.onNodeCreated = function (node /*, config, module, path*/) { req.cfg.onNodeCreated = function (node /*, config, module, path*/) {
@ -54,17 +28,34 @@ var afterLoaded = function (req) {
clearInterval(intr); clearInterval(intr);
txid = {}; txid = {};
window.removeEventListener('message', onReply); 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 () { }); require(['/common/sframe-boot2.js'], function () { });
}; };
window.addEventListener('message', onReply); window.addEventListener('message', onReply);
}; };
var intr = setInterval(function () { var load0 = function () {
try { try {
var req = JSON.parse(decodeURIComponent(window.location.hash.substring(1))); var req = JSON.parse(decodeURIComponent(window.location.hash.substring(1)));
clearInterval(intr);
afterLoaded(req); afterLoaded(req);
} catch (e) { console.error(e); } } catch (e) {
}, 100); console.error(e);
setTimeout(load0, 100);
}
};
load0();
}()); }());

@ -20,5 +20,7 @@ define(['/common/requireconfig.js'], function (RequireConfig) {
window.__defineGetter__('localStorage', function () { return mkFakeStore(); }); window.__defineGetter__('localStorage', function () { return mkFakeStore(); });
window.__defineGetter__('sessionStorage', function () { return mkFakeStore(); }); window.__defineGetter__('sessionStorage', function () { return mkFakeStore(); });
window.CRYPTPAD_INSIDE = true;
require([document.querySelector('script[data-bootload]').getAttribute('data-bootload')]); require([document.querySelector('script[data-bootload]').getAttribute('data-bootload')]);
}); });

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

@ -34,12 +34,34 @@ define([
Crypto = _Crypto; Crypto = _Crypto;
Cryptget = _Cryptget; Cryptget = _Cryptget;
FilePicker = _FilePicker; FilePicker = _FilePicker;
if (localStorage.CRYPTPAD_URLARGS !== ApiConfig.requireConf.urlArgs) {
console.log("New version, flushing cache");
Object.keys(localStorage).forEach(function (k) {
if (k.indexOf('CRYPTPAD_CACHE|') !== 0) { return; }
delete localStorage[k];
});
localStorage.CRYPTPAD_URLARGS = ApiConfig.requireConf.urlArgs;
}
var cache = {};
Object.keys(localStorage).forEach(function (k) {
if (k.indexOf('CRYPTPAD_CACHE|') !== 0) { return; }
cache[k.slice(('CRYPTPAD_CACHE|').length)] = localStorage[k];
});
SFrameChannel.create($('#sbox-iframe')[0].contentWindow, waitFor(function (sfc) { SFrameChannel.create($('#sbox-iframe')[0].contentWindow, waitFor(function (sfc) {
sframeChan = sfc; sframeChan = sfc;
})); }), false, { cache: cache });
Cryptpad.ready(waitFor()); Cryptpad.ready(waitFor());
})); }));
}).nThen(function (waitFor) { }).nThen(function (waitFor) {
sframeChan.on('EV_CACHE_PUT', function (x) {
Object.keys(x).forEach(function (k) {
localStorage['CRYPTPAD_CACHE|' + k] = x[k];
});
});
secret = Cryptpad.getSecrets(); secret = Cryptpad.getSecrets();
if (!secret.channel) { if (!secret.channel) {
// New pad: create a new random channel id // New pad: create a new random channel id

@ -271,6 +271,19 @@ define([
}).nThen(function () { }).nThen(function () {
ctx.metadataMgr = MetadataMgr.create(ctx.sframeChan); ctx.metadataMgr = MetadataMgr.create(ctx.sframeChan);
ctx.sframeChan.whenReg('EV_CACHE_PUT', function () {
if (Object.keys(window.cryptpadCache.updated).length) {
ctx.sframeChan.event('EV_CACHE_PUT', window.cryptpadCache.updated);
}
window.cryptpadCache._put = window.cryptpadCache.put;
window.cryptpadCache.put = function (k, v, cb) {
window.cryptpadCache._put(k, v, cb);
var x = {};
x[k] = v;
ctx.sframeChan.event('EV_CACHE_PUT', x);
};
});
UI.addTooltips(); UI.addTooltips();
ctx.sframeChan.on('EV_RT_CONNECT', function () { CommonRealtime.setConnectionState(true); }); ctx.sframeChan.on('EV_RT_CONNECT', function () { CommonRealtime.setConnectionState(true); });

@ -127,4 +127,7 @@ define({
// Present mode URL // Present mode URL
'Q_PRESENT_URL_GET_VALUE': true, 'Q_PRESENT_URL_GET_VALUE': true,
'EV_PRESENT_URL_SET_VALUE': true, 'EV_PRESENT_URL_SET_VALUE': true,
// Put one or more entries to the cache which will go in localStorage.
'EV_CACHE_PUT': true,
}); });

File diff suppressed because one or more lines are too long

@ -2,7 +2,7 @@
<html class="cp-app-noscroll"> <html class="cp-app-noscroll">
<head> <head>
<meta content="text/html; charset=utf-8" http-equiv="content-type"/> <meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<script async data-bootload="/file/inner.js" data-main="/common/sframe-boot.js?ver=1.3" src="/bower_components/requirejs/require.js?ver=2.3.5"></script> <script async data-bootload="/file/inner.js" data-main="/common/sframe-boot.js?ver=1.4" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
<style> <style>
.loading-hidden { display: none; } .loading-hidden { display: none; }
#editor1 { display: none; } #editor1 { display: none; }

@ -2,7 +2,7 @@
<html style="height: 100%; background: transparent;"> <html style="height: 100%; background: transparent;">
<head> <head>
<meta content="text/html; charset=utf-8" http-equiv="content-type"/> <meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<script async data-bootload="/filepicker/inner.js" data-main="/common/sframe-boot.js?ver=1.3" src="/bower_components/requirejs/require.js?ver=2.3.5"></script> <script async data-bootload="/filepicker/inner.js" data-main="/common/sframe-boot.js?ver=1.4" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
<style> <style>
.loading-hidden { display: none; } .loading-hidden { display: none; }
body #cp-loading { body #cp-loading {

@ -2,7 +2,7 @@
<html class="cp-app-noscroll"> <html class="cp-app-noscroll">
<head> <head>
<meta content="text/html; charset=utf-8" http-equiv="content-type"/> <meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<script async data-bootload="/pad/inner.js" data-main="/common/sframe-boot.js?ver=1.3" src="/bower_components/requirejs/require.js?ver=2.3.5"></script> <script async data-bootload="/pad/inner.js" data-main="/common/sframe-boot.js?ver=1.4" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
</head> </head>
<body class="cp-app-pad"> <body class="cp-app-pad">
<textarea style="display:none" id="editor1" name="editor1"></textarea> <textarea style="display:none" id="editor1" name="editor1"></textarea>

@ -2,7 +2,7 @@
<html class="cp-app-noscroll cp-app-print"> <html class="cp-app-noscroll cp-app-print">
<head> <head>
<meta content="text/html; charset=utf-8" http-equiv="content-type"/> <meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<script async data-bootload="/slide/inner.js" data-main="/common/sframe-boot.js?ver=1.3" src="/bower_components/requirejs/require.js?ver=2.3.5"></script> <script async data-bootload="/slide/inner.js" data-main="/common/sframe-boot.js?ver=1.4" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
<style> <style>
.loading-hidden { display: none; } .loading-hidden { display: none; }
#editor1 { display: none; } #editor1 { display: none; }

Loading…
Cancel
Save