From 3858aa976a41e31892d31a107b1c6f20b9671960 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 16 Jan 2018 16:52:06 +0100 Subject: [PATCH 1/4] better warning in case of errors in /file/ --- customize.dist/translations/messages.js | 1 + www/file/inner.js | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index 1c1a43bff..abece3af6 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -581,6 +581,7 @@ define(function () { out.upload_mustLogin = "You must be logged in to upload files"; out.download_button = "Decrypt & Download"; out.download_mt_button = "Download"; + out.download_resourceNotAvailable = "The requested resource was not available..."; out.todo_title = "CryptTodo"; out.todo_newTodoNamePlaceholder = "Describe your task..."; diff --git a/www/file/inner.js b/www/file/inner.js index 30e742528..2dbe765ce 100644 --- a/www/file/inner.js +++ b/www/file/inner.js @@ -91,7 +91,12 @@ define([ var key = Nacl.util.decodeBase64(cryptKey); FileCrypto.fetchDecryptedMetadata(src, key, function (e, metadata) { - if (e) { return void console.error(e); } + if (e) { + if (e === 'XHR_ERROR') { + return void UI.errorLoadingScreen(Messages.download_resourceNotAvailable); + } + return void console.error(e); + } var title = document.title = metadata.name; Title.updateTitle(title || Title.defaultTitle); toolbar.addElement(['pageTitle'], {pageTitle: title}); @@ -238,10 +243,9 @@ define([ } // we're in upload mode - if (!common.isLoggedIn()) { + UI.removeLoadingScreen(); return UI.alert(Messages.upload_mustLogin, function () { - UI.errorLoadingScreen(Messages.upload_mustLogin); common.setLoginRedirect(function () { common.gotoURL('/login/'); }); From 1dd07ea48ab3824b882353e031fbe0eed9610a3a Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 16 Jan 2018 18:03:55 +0100 Subject: [PATCH 2/4] polyfill MAX_SAFE_INTEGER everywhere --- www/common/boot2.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/www/common/boot2.js b/www/common/boot2.js index ec3b3d7db..11dfa1649 100644 --- a/www/common/boot2.js +++ b/www/common/boot2.js @@ -21,6 +21,11 @@ define([ }; } + // RPC breaks if you don't support Number.MAX_SAFE_INTEGER + if (Number && !Number.MAX_SAFE_INTEGER) { + Number.MAX_SAFE_INTEGER = 9007199254740991; + } + var failStore = function () { console.error(new Error('wut')); require(['jquery'], function ($) { From 50e3e3ce919a3f38aa273ef8f2c5df2666fe93ac Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 16 Jan 2018 18:12:33 +0100 Subject: [PATCH 3/4] polyfill Symbol for IE --- www/common/boot2.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/www/common/boot2.js b/www/common/boot2.js index 11dfa1649..6d81e249c 100644 --- a/www/common/boot2.js +++ b/www/common/boot2.js @@ -26,6 +26,14 @@ define([ Number.MAX_SAFE_INTEGER = 9007199254740991; } + if (typeof(window.Symbol) !== 'function') { + var idCounter = 0; + var Symbol = window.Symbol = function Symbol(key) { + return '__' + key + '_' + Math.floor(Math.random() * 1e9) + '_' + (++idCounter) + '__'; + }; + Symbol.iterator = Symbol('Symbol.iterator'); + } + var failStore = function () { console.error(new Error('wut')); require(['jquery'], function ($) { From a91a047d73956d657142fe069c103bdf0a8bf123 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 16 Jan 2018 18:15:08 +0100 Subject: [PATCH 4/4] more polyfill for IE --- www/common/sframe-boot2.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/www/common/sframe-boot2.js b/www/common/sframe-boot2.js index fe614ba33..697f22a91 100644 --- a/www/common/sframe-boot2.js +++ b/www/common/sframe-boot2.js @@ -18,6 +18,14 @@ define([ Number.MAX_SAFE_INTEGER = 9007199254740991; } + if (typeof(window.Symbol) !== 'function') { + var idCounter = 0; + var Symbol = window.Symbol = function Symbol(key) { + return '__' + key + '_' + Math.floor(Math.random() * 1e9) + '_' + (++idCounter) + '__'; + }; + Symbol.iterator = Symbol('Symbol.iterator'); + } + var mkFakeStore = function () { var fakeStorage = { getItem: function (k) { return fakeStorage[k]; },