Add a dev mode to facilitate debugging

pull/1/head
yflory 6 years ago
parent 07cd0b21b6
commit 4abed38bb1

@ -49,6 +49,11 @@ define([
var CHECKPOINT_INTERVAL = 50; var CHECKPOINT_INTERVAL = 50;
var debug = function (x) {
if (!window.CP_DEV_MODE) { return; }
console.log(x);
};
var stringify = function (obj) { var stringify = function (obj) {
return JSONSortify(obj); return JSONSortify(obj);
}; };
@ -203,7 +208,7 @@ define([
cpIndex: 0 cpIndex: 0
}; };
var getContent = APP.getContent = function () { var getContent = function () {
try { try {
return window.frames[0].editor.asc_nativeGetFile(); return window.frames[0].editor.asc_nativeGetFile();
} catch (e) { } catch (e) {
@ -560,10 +565,12 @@ define([
APP.chan = chan; APP.chan = chan;
var send = ooChannel.send = function (obj) { var send = ooChannel.send = function (obj) {
debug(obj);
chan.event('CMD', obj); chan.event('CMD', obj);
}; };
chan.on('CMD', function (obj) { chan.on('CMD', function (obj) {
debug(obj);
switch (obj.type) { switch (obj.type) {
case "auth": case "auth":
handleAuth(obj, send); handleAuth(obj, send);

@ -302,6 +302,7 @@ define([
password: password, password: password,
channel: secret.channel, channel: secret.channel,
enableSF: localStorage.CryptPad_SF === "1", // TODO to remove when enabled by default enableSF: localStorage.CryptPad_SF === "1", // TODO to remove when enabled by default
devMode: localStorage.CryptPad_dev === "1",
}; };
if (window.CryptPad_newSharedFolder) { if (window.CryptPad_newSharedFolder) {
additionalPriv.newSharedFolder = window.CryptPad_newSharedFolder; additionalPriv.newSharedFolder = window.CryptPad_newSharedFolder;

@ -587,6 +587,10 @@ define([
console.error("Can't check permissions for the app"); console.error("Can't check permissions for the app");
} }
try {
window.CP_DEV_MODE = ctx.metadataMgr.getPrivateData().devMode;
} catch (e) {}
ctx.sframeChan.on('EV_LOADING_ERROR', function (err) { ctx.sframeChan.on('EV_LOADING_ERROR', function (err) {
if (err === 'DELETED') { if (err === 'DELETED') {
var msg = Messages.deletedError + '<br>' + Messages.errorRedirectToHome; var msg = Messages.deletedError + '<br>' + Messages.errorRedirectToHome;

Loading…
Cancel
Save