From 4e8335bfdddc5368a10bed37eaa68cf921f3730e Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 24 Jan 2018 11:01:15 +0100 Subject: [PATCH 1/4] fix support for custom button classes --- www/common/common-interface.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/www/common/common-interface.js b/www/common/common-interface.js index c256d2656..bd062a1bc 100644 --- a/www/common/common-interface.js +++ b/www/common/common-interface.js @@ -111,12 +111,14 @@ define([ return input; }; - dialog.okButton = function (content) { - return h('button.ok.primary', { tabindex: '2', }, content || Messages.okButton); + dialog.okButton = function (content, classString) { + var sel = typeof(classString) === 'string'? 'button.ok.' + classString:'button.ok.primary' + return h(sel, { tabindex: '2', }, content || Messages.okButton); }; - dialog.cancelButton = function (content) { - return h('button.cancel', { tabindex: '1'}, content || Messages.cancelButton); + dialog.cancelButton = function (content, classString) { + var sel = typeof(classString) === 'string'? 'button.' + classString:'button.cancel' + return h(sel, { tabindex: '1'}, content || Messages.cancelButton); }; dialog.message = function (text) { @@ -464,8 +466,8 @@ define([ message = dialog.message(msg); } - var ok = dialog.okButton(opt.ok); - var cancel = dialog.cancelButton(opt.cancel); + var ok = dialog.okButton(opt.ok, opt.okClass); + var cancel = dialog.cancelButton(opt.cancel, opt.cancelClass); var frame = dialog.frame([ message, From a5b7b0191fe98ca4ff7a8e5caf59a6a42cdc201e Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 24 Jan 2018 11:31:34 +0100 Subject: [PATCH 2/4] correct validation for 'channelName' --- storage/file.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/file.js b/storage/file.js index 329d7f74f..33df00692 100644 --- a/storage/file.js +++ b/storage/file.js @@ -9,7 +9,7 @@ const Pull = require('pull-stream'); const isValidChannelId = function (id) { return typeof(id) === 'string' && - [32, 48].indexOf(id.length) > -1 && + id.length >= 32 && id.length < 50 && /^[a-zA-Z0-9=+-]*$/.test(id); }; @@ -470,4 +470,4 @@ module.exports.create = function ( setInterval(function () { flushUnusedChannels(env, function () { }); }, 5000); -}; \ No newline at end of file +}; From 80cd3e208a991376cedbb52cd66fbf7edafe8eed Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 24 Jan 2018 11:35:05 +0100 Subject: [PATCH 3/4] lint compliance --- www/common/common-interface.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/common/common-interface.js b/www/common/common-interface.js index bd062a1bc..f35b361ba 100644 --- a/www/common/common-interface.js +++ b/www/common/common-interface.js @@ -112,12 +112,12 @@ define([ }; dialog.okButton = function (content, classString) { - var sel = typeof(classString) === 'string'? 'button.ok.' + classString:'button.ok.primary' + var sel = typeof(classString) === 'string'? 'button.ok.' + classString:'button.ok.primary'; return h(sel, { tabindex: '2', }, content || Messages.okButton); }; dialog.cancelButton = function (content, classString) { - var sel = typeof(classString) === 'string'? 'button.' + classString:'button.cancel' + var sel = typeof(classString) === 'string'? 'button.' + classString:'button.cancel'; return h(sel, { tabindex: '1'}, content || Messages.cancelButton); }; From 2b8414ca78e6548f5db0464176a8f4116f845bf3 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 24 Jan 2018 16:16:46 +0100 Subject: [PATCH 4/4] provide hints for running CryptPad --- www/common/boot2.js | 9 +++++++++ www/common/sframe-boot2.js | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/www/common/boot2.js b/www/common/boot2.js index 11dfa1649..a9d0606db 100644 --- a/www/common/boot2.js +++ b/www/common/boot2.js @@ -37,6 +37,15 @@ define([ window.alert("CryptPad needs localStorage to work, try a different browser"); }; + window.onerror = function (e) { + if (/requirejs\.org/.test(e)) { + console.log(); + console.error("Require.js threw a Script Error. This probably means you're missing a dependency for CryptPad.\nIt is recommended that the admin of this server runs `bower install && bower update` to get the latest code, then modify their cache version.\nBest of luck,\nThe CryptPad Developers"); + return void console.log(); + } + throw e; + }; + try { var test_key = 'localStorage_test'; var testval = Math.random().toString(); diff --git a/www/common/sframe-boot2.js b/www/common/sframe-boot2.js index fe614ba33..0d0eaa90c 100644 --- a/www/common/sframe-boot2.js +++ b/www/common/sframe-boot2.js @@ -36,5 +36,14 @@ define([ // This test is completed in common-interface.js Test(function (t) { Test.__ASYNC_BLOCKER__ = t; }); + window.onerror = function (e) { + if (/requirejs\.org/.test(e)) { + console.log(); + console.error("Require.js threw a Script Error. This probably means you're missing a dependency for CryptPad.\nIt is recommended that the admin of this server runs `bower install && bower update` to get the latest code, then modify their cache version.\nBest of luck,\nThe CryptPad Developers"); + return void console.log(); + } + throw e; + }; + require([document.querySelector('script[data-bootload]').getAttribute('data-bootload')]); });