From 671c893e8aad9bd2c5634c2f5ed0f451c9a9e93b Mon Sep 17 00:00:00 2001 From: Caleb James DeLisle Date: Mon, 11 Sep 2017 17:52:34 +0200 Subject: [PATCH 1/4] Duplicating code like a moron, this should hopefully get fixed later. --- www/code/inner.js | 8 ++++++++ www/slide/inner.js | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/www/code/inner.js b/www/code/inner.js index 488a084e4..53d852ebd 100644 --- a/www/code/inner.js +++ b/www/code/inner.js @@ -571,6 +571,14 @@ define([ cpNfInner = common.startRealtime(config); metadataMgr = cpNfInner.metadataMgr; + cpNfInner.onInfiniteSpinner(function () { + setEditable(false); + Cryptpad.confirm(Messages.realtime_unrecoverableError, function (yes) { + if (!yes) { return; } + common.gotoURL(); + }); + }); + editor.on('change', onLocal); Cryptpad.onLogout(function () { setEditable(false); }); diff --git a/www/slide/inner.js b/www/slide/inner.js index a4eb9bf72..80fb3e02d 100644 --- a/www/slide/inner.js +++ b/www/slide/inner.js @@ -682,6 +682,14 @@ define([ cpNfInner = common.startRealtime(config); metadataMgr = cpNfInner.metadataMgr; + cpNfInner.onInfiniteSpinner(function () { + setEditable(false); + Cryptpad.confirm(Messages.realtime_unrecoverableError, function (yes) { + if (!yes) { return; } + common.gotoURL(); + }); + }); + editor.on('change', onLocal); Cryptpad.onLogout(function () { setEditable(false); }); From a0b3201df3ca165105263b83494431ba5b7ef392 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 12 Sep 2017 10:49:48 +0200 Subject: [PATCH 2/4] fix focus on alerts, prompts, and confirms. call back from alerts --- 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 b93e57de3..467cad4ab 100644 --- a/www/common/common-interface.js +++ b/www/common/common-interface.js @@ -36,8 +36,9 @@ define([ return $('button.ok').last(); }; - var listenForKeys = UI.listenForKeys = function (yes, no) { + var listenForKeys = UI.listenForKeys = function (yes, no, el) { var handler = function (e) { + e.stopPropagation(); switch (e.which) { case 27: // cancel if (typeof(no) === 'function') { no(e); } @@ -48,7 +49,7 @@ define([ } }; - $(window).keyup(handler); + $(el || window).keydown(handler); return handler; }; @@ -114,7 +115,9 @@ define([ }; dialog.frame = function (content) { - return h('div.alertify', [ + return h('div.alertify', { + tabindex: 1, + }, [ h('div.dialog', [ h('div', content), ]) @@ -229,6 +232,7 @@ define([ var close = Util.once(function () { $(frame).fadeOut(150, function () { $(this).remove(); }); stopListening(listener); + cb(); }); listener = listenForKeys(close, close); var $ok = $(ok).click(close); @@ -237,7 +241,6 @@ define([ setTimeout(function () { $ok.focus(); UI.notify(); - if (!document.hasFocus()) { window.focus(); } }); }; @@ -283,7 +286,6 @@ define([ setTimeout(function () { input.select().focus(); UI.notify(); - if (!document.hasFocus()) { window.focus(); } }); }; @@ -330,10 +332,10 @@ define([ document.body.appendChild(frame); setTimeout(function () { UI.notify(); + $(frame).find('.ok').focus(); if (typeof(opt.done) === 'function') { opt.done($ok.closest('.dialog')); } - if (!document.hasFocus()) { window.focus(); } }); }; From 499b5ea2ba23a0ba8b1405cd74a83f66eb44d5b4 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 12 Sep 2017 10:50:59 +0200 Subject: [PATCH 3/4] warn that a password is too short before doing anything else --- www/register/main.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/www/register/main.js b/www/register/main.js index d302a0634..e8fdb8d22 100644 --- a/www/register/main.js +++ b/www/register/main.js @@ -115,6 +115,15 @@ define([ var doesAccept = $checkAcceptTerms[0].checked; /* basic validation */ + if (!Cred.isLongEnoughPassword(passwd)) { + var warning = Messages._getKey('register_passwordTooShort', [ + Cred.MINIMUM_PASSWORD_LENGTH + ]); + return void Cryptpad.alert(warning, function () { + registering = false; + }); + } + if (passwd !== confirmPassword) { // do their passwords match? return void Cryptpad.alert(Messages.register_passwordsDontMatch); } From da0e31fa5431269a49821dd761eaf98a2a6b36d9 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 12 Sep 2017 11:20:50 +0200 Subject: [PATCH 4/4] guard against possible type errors --- www/common/userObject.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/www/common/userObject.js b/www/common/userObject.js index 504addb15..dc3b9652f 100644 --- a/www/common/userObject.js +++ b/www/common/userObject.js @@ -657,7 +657,9 @@ define([ var fData = files[FILES_DATA]; getFiles([FILES_DATA]).forEach(function (id) { if (filesList.indexOf(id) === -1) { - removePadAttribute(fData[id].href); + if (fData[id] && fData[id].href) { + removePadAttribute(fData[id].href); + } spliceFileData(id); } });