From 30f6ef3f85449aac097f4a13ff228ee3d6f6ffd9 Mon Sep 17 00:00:00 2001 From: ansuz Date: Fri, 12 May 2017 17:34:29 +0200 Subject: [PATCH] handle more response codes, use metadata --- www/common/common-util.js | 2 +- www/media/main.js | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/www/common/common-util.js b/www/common/common-util.js index 7f735411e..a5822c743 100644 --- a/www/common/common-util.js +++ b/www/common/common-util.js @@ -101,7 +101,7 @@ define([], function () { xhr.open("GET", src, true); xhr.responseType = "arraybuffer"; xhr.onload = function () { - if (this.status !== 200) { + if ([200, 304].indexOf(this.status) === -1) { return CB('XHR_ERROR'); } return void CB(void 0, new Uint8Array(xhr.response)); diff --git a/www/media/main.js b/www/media/main.js index 9e5276019..044fba0c0 100644 --- a/www/media/main.js +++ b/www/media/main.js @@ -20,11 +20,6 @@ define([ Cryptpad.addLoadingScreen(); var andThen = function () { - $(window.document).on('decryption', function (e) { - var decrypted = e.originalEvent; - console.log(decrypted.blob, decrypted.metadata); - }); - var $bar = $iframe.find('.toolbar-container'); var secret = Cryptpad.getSecrets(); @@ -71,11 +66,16 @@ define([ $mt.attr('data-crypto-key', 'cryptpad:'+cryptKey); $mt.attr('data-type', type); - window.onMediaMetadata = function (metadata) { + $(window.document).on('decryption', function (e) { + var decrypted = e.originalEvent; + var metadata = decrypted.metadata; + + console.log(metadata); + console.log(defaultName); if (!metadata || metadata.name !== defaultName) { return; } var title = document.title = metadata.name; updateTitle(title || defaultName); - }; + }); require(['/common/media-tag.js'], function (MediaTag) { var configTb = {