From 6dd80c26b18ca8b0e0bfeffe622f4bdc19d24a5f Mon Sep 17 00:00:00 2001 From: Pierre Bondoerffer Date: Mon, 12 Jun 2017 12:00:39 +0200 Subject: [PATCH 01/23] Make editing more visible --- www/poll/main.js | 10 ++++++++-- www/poll/poll.css | 8 ++++++-- www/poll/poll.less | 10 +++++++++- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/www/poll/main.js b/www/poll/main.js index eb0edef26..1ff7638d5 100644 --- a/www/poll/main.js +++ b/www/poll/main.js @@ -107,12 +107,15 @@ define([ }; var unlockElements = function () { + var $input; APP.editable.row.forEach(function (id) { - $('input[type="text"][disabled="disabled"][data-rt-id="' + id + '"]').removeAttr('disabled'); + $input = $('input[type="text"][disabled="disabled"][data-rt-id="' + id + '"]').removeAttr('disabled'); + $input.parent().parent().addClass('editing'); $('span.edit[data-rt-id="' + id + '"]').css('visibility', 'hidden'); }); APP.editable.col.forEach(function (id) { - $('input[disabled="disabled"][data-rt-id^="' + id + '"]').removeAttr('disabled'); + $input = $('input[disabled="disabled"][data-rt-id^="' + id + '"]').removeAttr('disabled'); + $input.parent().addClass('editing'); $('input[type="checkbox"][data-rt-id^="' + id + '"]').addClass('enabled'); $('.lock[data-rt-id="' + id + '"]').addClass('fa-unlock').removeClass('fa-lock').attr('title', Messages.poll_unlocked); }); @@ -296,6 +299,7 @@ define([ $('.lock[data-rt-id!="' + APP.userid + '"]').addClass('fa-lock').removeClass('fa-unlock').attr('title', Messages.poll_locked); var $cells = APP.$table.find('thead td:not(.uncommitted), tbody td'); $cells.find('[type="text"][data-rt-id!="' + APP.userid + '"]').attr('disabled', true); + $cells.removeClass('editing'); $('.edit[data-rt-id!="' + APP.userid + '"]').css('visibility', 'visible'); APP.editable.col = [APP.userid]; APP.editable.row = []; @@ -352,6 +356,8 @@ define([ e.stopPropagation(); if (!APP.ready) { return; } + if (e.which !== 1) { return; } + var target = e && e.target; if (!target) { return void debug("NO TARGET"); } diff --git a/www/poll/poll.css b/www/poll/poll.css index 3e534d5e2..a019dabe3 100644 --- a/www/poll/poll.css +++ b/www/poll/poll.css @@ -170,6 +170,10 @@ div.realtime table { border-collapse: collapse; width: calc(100% - 1px); } +form.realtime table .editing, +div.realtime table .editing { + background-color: #88b8cc; +} form.realtime table tr td:first-child, div.realtime table tr td:first-child { position: absolute; @@ -298,8 +302,8 @@ div.realtime table thead td input[type="text"][disabled] { color: #000; border: 1px solid transparent; } -form.realtime table tbody .text-cell, -div.realtime table tbody .text-cell { +form.realtime table tbody td:not(.editing) .text-cell, +div.realtime table tbody td:not(.editing) .text-cell { background: #aaa; } form.realtime table tbody .text-cell input[type="text"], diff --git a/www/poll/poll.less b/www/poll/poll.less index 699e96e03..d1979a958 100644 --- a/www/poll/poll.less +++ b/www/poll/poll.less @@ -4,6 +4,7 @@ @poll-th-bg: #aaa; @poll-th-user-bg: #999; @poll-td-bg: #aaa; +@poll-editing: #88b8cc; @poll-placeholder: #666; @poll-border-color: #555; @poll-cover-color: #000; @@ -195,6 +196,9 @@ form.realtime, div.realtime { table { border-collapse: collapse; width: ~"calc(100% - 1px)"; + .editing { + background-color: @poll-editing; + } tr { td:first-child { position:absolute; @@ -327,8 +331,12 @@ form.realtime, div.realtime { } tbody { + td:not(.editing) { + .text-cell { + background: @poll-td-bg; + } + } .text-cell { - background: @poll-td-bg; //border-radius: 20px 0 0 20px; input[type="text"] { width: ~"calc(100% - 50px)"; From 6bc191725ff232e79885d85d3e5fa35161d9f956 Mon Sep 17 00:00:00 2001 From: Pierre Bondoerffer Date: Mon, 12 Jun 2017 12:37:07 +0200 Subject: [PATCH 02/23] poll: support disconnect and fix trash button --- www/poll/main.js | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/www/poll/main.js b/www/poll/main.js index 1ff7638d5..2d848f17d 100644 --- a/www/poll/main.js +++ b/www/poll/main.js @@ -46,7 +46,8 @@ define([ editable: { row: [], col: [] - } + }, + locked: false }; var sortColumns = function (order, firstcol) { @@ -293,6 +294,7 @@ define([ }; var hideInputs = function (target, isKeyup) { + if (APP.locked) { return; } if (!isKeyup && $(target).is('[type="text"]')) { return; } @@ -353,10 +355,13 @@ define([ }; var handleClick = function (e, isKeyup) { + if (APP.locked) { return; } + e.stopPropagation(); if (!APP.ready) { return; } - if (e.which !== 1) { return; } + if (!isKeyup && e.which !== 1) { return; } + var target = e && e.target; @@ -533,7 +538,10 @@ var ready = function (info, userid, readOnly) { .click(handleClick) .on('keyup', function (e) { handleClick(e, true); }); - $(window).click(hideInputs); + $(window).click(function(e) { + if (e.which !== 1) { return; } + hideInputs(); + }); proxy .on('change', ['info'], function (o, n, p) { @@ -576,14 +584,33 @@ var ready = function (info, userid, readOnly) { UserList.getLastName(APP.toolbar.$userNameButton, isNew); }; +var setEditable = function (editable) { + APP.locked = !editable; + + if (editable === false) { + // disable all the things + $('.realtime input, .realtime button').attr('disabled', APP.locked); + $('span.edit, span.remove').hide(); + $('span.lock').addClass('fa-lock').removeClass('fa-unlock') + .attr('title', Messages.poll_locked) + .css({'cursor': 'default'}); + } else { + // enable + $('span.edit, span.remove').show(); + $('span.lock').css({'cursor': ''}); + $('.realtime button').attr('disabled', APP.locked); + unlockElements(); + } +}; + var disconnect = function () { - //setEditable(false); // TODO + setEditable(false); APP.toolbar.failed(); Cryptpad.alert(Messages.common_connectionLost, undefined, true); }; var reconnect = function (info) { - //setEditable(true); // TODO + setEditable(true); APP.toolbar.reconnecting(info.myId); Cryptpad.findOKButton().click(); }; @@ -638,7 +665,7 @@ var create = function (info) { /* add a forget button */ var forgetCb = function (err) { if (err) { return; } - disconnect(); + setEditable(false); }; var $forgetPad = Cryptpad.createButton('forget', true, {}, forgetCb); $rightside.append($forgetPad); @@ -709,7 +736,7 @@ var create = function (info) { } }); - //Cryptpad.onLogout(function () { setEditable(false); }); TODO + Cryptpad.onLogout(function () { setEditable(false); }); }); Cryptpad.onError(function (info) { if (info) { From 5d565660a9c5c035269ba3b1b757455c795fb458 Mon Sep 17 00:00:00 2001 From: Pierre Bondoerffer Date: Mon, 12 Jun 2017 12:41:03 +0200 Subject: [PATCH 03/23] tiny fixes --- www/poll/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/poll/main.js b/www/poll/main.js index 2d848f17d..0ff5dc0e0 100644 --- a/www/poll/main.js +++ b/www/poll/main.js @@ -589,7 +589,7 @@ var setEditable = function (editable) { if (editable === false) { // disable all the things - $('.realtime input, .realtime button').attr('disabled', APP.locked); + $('.realtime input, .realtime button, .upper button, .realtime textarea').attr('disabled', APP.locked); $('span.edit, span.remove').hide(); $('span.lock').addClass('fa-lock').removeClass('fa-unlock') .attr('title', Messages.poll_locked) @@ -598,7 +598,7 @@ var setEditable = function (editable) { // enable $('span.edit, span.remove').show(); $('span.lock').css({'cursor': ''}); - $('.realtime button').attr('disabled', APP.locked); + $('.realtime button, .upper button, .realtime textarea').attr('disabled', APP.locked); unlockElements(); } }; From 685b352db8b614658775de363673795207a494c9 Mon Sep 17 00:00:00 2001 From: Pierre Bondoerffer Date: Mon, 12 Jun 2017 14:25:10 +0200 Subject: [PATCH 04/23] poll: Add show help button --- customize.dist/translations/messages.es.js | 3 +++ customize.dist/translations/messages.fr.js | 3 +++ customize.dist/translations/messages.js | 3 +++ www/poll/index.html | 2 +- www/poll/main.js | 19 +++++++++++++------ 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/customize.dist/translations/messages.es.js b/customize.dist/translations/messages.es.js index 57eb41f9e..ce4bcb788 100644 --- a/customize.dist/translations/messages.es.js +++ b/customize.dist/translations/messages.es.js @@ -452,6 +452,9 @@ define(function () { out.poll_locked = "Cerrado"; out.poll_unlocked = "Abierto"; + out.poll_show_help_button = "Mostrar ayuda"; + out.poll_hide_help_button = "Esconder ayuda"; + // 1.8.0 - Idopogo out.common_connectionLost = "Connexión perdida
El documento está ahora en modo solo lectura hasta que la conexión vuelva."; diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index 70d804652..0372d6081 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -202,6 +202,9 @@ define(function () { out.poll_locked = "Verrouillé"; out.poll_unlocked = "Déverrouillé"; + out.poll_show_help_button = "Afficher l'aide"; + out.poll_hide_help_button = "Cacher l'aide"; + // Canvas out.canvas_clear = "Nettoyer"; out.canvas_delete = "Supprimer la sélection"; diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index 6d4f07c02..dd14ad8da 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -204,6 +204,9 @@ define(function () { out.poll_locked = "Locked"; out.poll_unlocked = "Unlocked"; + out.poll_show_help_button = "Show help"; + out.poll_hide_help_button = "Hide help"; + // Canvas out.canvas_clear = "Clear"; out.canvas_delete = "Delete selection"; diff --git a/www/poll/index.html b/www/poll/index.html index 31226d989..22280e8a9 100644 --- a/www/poll/index.html +++ b/www/poll/index.html @@ -28,7 +28,7 @@
- +
diff --git a/www/poll/main.js b/www/poll/main.js index 0ff5dc0e0..05009b5b1 100644 --- a/www/poll/main.js +++ b/www/poll/main.js @@ -142,12 +142,10 @@ define([ var setTablePublished = function (bool) { if (bool) { if (APP.$publish) { APP.$publish.hide(); } - if (APP.$admin) { APP.$admin.show(); } $('#create-option').hide(); $('.remove[data-rt-id^="y"], .edit[data-rt-id^="y"]').hide(); } else { if (APP.$publish) { APP.$publish.show(); } - if (APP.$admin) { APP.$admin.hide(); } $('#create-option').show(); $('.remove[data-rt-id^="y"], .edit[data-rt-id^="y"]').show(); } @@ -432,6 +430,15 @@ define([ }); }; + var showHelp = function(help) { + if (typeof help === 'undefined') { help = !$('#howItWorks').is(':visible'); } + + var msg = (help ? Messages.poll_hide_help_button : Messages.poll_show_help_button); + + $('#howItWorks').toggle(help); + $('#help').text(msg).attr('title', msg); + }; + var Title; var UserList; @@ -498,9 +505,9 @@ var ready = function (info, userid, readOnly) { }); // #publish button is removed in readonly - APP.$admin = $('#admin') + APP.$help = $('#help') .click(function () { - publish(false); + showHelp(); }); // Title @@ -702,7 +709,7 @@ var create = function (info) { }; if (readOnly) { - $('#commit, #create-user, #create-option, #publish, #admin').remove(); + $('#commit, #create-user, #create-option, #publish').remove(); } var parsedHash = Cryptpad.parsePadUrl(window.location.href); @@ -732,7 +739,7 @@ var create = function (info) { if (e) { console.error(e); } }); } else if (value === "1") { - $('#howItWorks').hide(); + showHelp(false); } }); From c7023134898554b27ff78bed0541d6a25074f190 Mon Sep 17 00:00:00 2001 From: XWiki SAS Date: Mon, 12 Jun 2017 17:34:45 +0200 Subject: [PATCH 05/23] change label texte --- www/whiteboard/main.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/www/whiteboard/main.js b/www/whiteboard/main.js index dce656473..a96fdb457 100644 --- a/www/whiteboard/main.js +++ b/www/whiteboard/main.js @@ -50,7 +50,7 @@ define([ }; var $toggle = $('#toggleDraw'); - var $width = $('#width'); + var $width = $('#width'); // brush width var $widthLabel = $('label[for="width"]'); var $opacity = $('#opacity'); var $opacityLabel = $('label[for="opacity"]'); @@ -98,7 +98,9 @@ window.canvas = canvas; var val = $width.val(); canvas.freeDrawingBrush.width = Number(val); $widthLabel.text(val); + $widthLabel.text("width: " + $width.val()) createCursor(); + console.log("change size") }; updateBrushWidth(); @@ -108,8 +110,11 @@ window.canvas = canvas; var val = $opacity.val(); brush.opacity = Number(val); canvas.freeDrawingBrush.color = Colors.hex2rgba(brush.color, brush.opacity); - $opacityLabel.text(val); + $opacityLabel.text(val) + $opacityLabel.text("opacity: " + $opacity.val()); createCursor(); + console.log("change opacity") + console.log("opacity: " + $opacity.val()) }; updateBrushOpacity(); From b8e394db671e55ae11e6ada2063963b1fa1a04c4 Mon Sep 17 00:00:00 2001 From: Pierre Bondoerffer Date: Mon, 12 Jun 2017 18:01:51 +0200 Subject: [PATCH 06/23] poll: Implement multiple choices --- www/poll/main.js | 20 ++++++++++----- www/poll/poll.css | 61 +++++++++++++++++++++++++++++++--------------- www/poll/poll.less | 34 +++++++++++++++++++++----- www/poll/render.js | 24 +++++++++++------- 4 files changed, 99 insertions(+), 40 deletions(-) diff --git a/www/poll/main.js b/www/poll/main.js index 05009b5b1..a805b4c02 100644 --- a/www/poll/main.js +++ b/www/poll/main.js @@ -98,7 +98,7 @@ define([ // Enable the checkboxes for the user's column (committed or not) $('input[disabled="disabled"][data-rt-id^="' + id + '"]').removeAttr('disabled'); - $('input[type="checkbox"][data-rt-id^="' + id + '"]').addClass('enabled'); + $('input[type="number"][data-rt-id^="' + id + '"]').addClass('enabled'); $('.lock[data-rt-id="' + id + '"]').addClass('fa-unlock').removeClass('fa-lock').attr('title', Messages.poll_unlocked); if (isOwnColumnCommitted()) { return; } @@ -117,7 +117,7 @@ define([ APP.editable.col.forEach(function (id) { $input = $('input[disabled="disabled"][data-rt-id^="' + id + '"]').removeAttr('disabled'); $input.parent().addClass('editing'); - $('input[type="checkbox"][data-rt-id^="' + id + '"]').addClass('enabled'); + $('input[type="number"][data-rt-id^="' + id + '"]').addClass('enabled'); $('.lock[data-rt-id="' + id + '"]').addClass('fa-unlock').removeClass('fa-lock').attr('title', Messages.poll_unlocked); }); }; @@ -276,10 +276,10 @@ define([ Render.setValue(object, id, input.value); change(null, null, null, 50); break; - case 'checkbox': - debug("checkbox[tr-id='%s'] %s", id, input.checked); + case 'number': + debug("checkbox[tr-id='%s'] %s", id, input.value); if (APP.editable.col.indexOf(x) >= 0 || x === APP.userid) { - Render.setValue(object, id, input.checked); + Render.setValue(object, id, parseInt(input.value)); change(); } else { debug('checkbox locked'); @@ -378,10 +378,18 @@ define([ hideInputs(target, isKeyup); break; } + if ($(target).is('input[type="number"]')) { break; } + handleInput(target); break; + case 'LABEL': + var input = $('input[type="number"][id=' + $(target).attr('for') + ']'); + var value = parseInt(input.val()); + input.val((value + 1) % 4); + + handleInput(input[0]); + break; case 'SPAN': - //case 'LABEL': if (shouldLock) { break; } diff --git a/www/poll/poll.css b/www/poll/poll.css index a019dabe3..979f7f2b8 100644 --- a/www/poll/poll.css +++ b/www/poll/poll.css @@ -229,40 +229,63 @@ div.realtime table tr td.checkbox-cell div.checkbox-contain label { height: 100%; width: 100%; } -form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable), -div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) { +form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"]:not(.editable), +div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"]:not(.editable) { display: none; } -form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover, -div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover { +form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"]:not(.editable) ~ .cover, +div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"]:not(.editable) ~ .cover { font-weight: bold; - background-color: #FA5858; color: #000; display: block; } -form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover:after, -div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover:after { +form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"]:not(.editable) ~ .cover:after, +div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"]:not(.editable) ~ .cover:after { height: 100%; } -form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover:after, -div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover:after { +form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"]:not(.editable) ~ .cover.yes, +div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"]:not(.editable) ~ .cover.yes { + background-color: #46E981; +} +form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"]:not(.editable) ~ .cover.uncommitted, +div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"]:not(.editable) ~ .cover.uncommitted { + background: #ddd; +} +form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"]:not(.editable) ~ .cover.mine, +div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"]:not(.editable) ~ .cover.mine { + display: none; +} +form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="0"] ~ .cover, +div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="0"] ~ .cover { + background-color: #FA5858; +} +form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="0"] ~ .cover:after, +div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="0"] ~ .cover:after { content: "✖"; } -form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover.yes, -div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover.yes { +form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="1"] ~ .cover, +div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="1"] ~ .cover { background-color: #46E981; } -form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover.yes:after, -div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover.yes:after { +form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="1"] ~ .cover:after, +div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="1"] ~ .cover:after { content: "✔"; } -form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover.uncommitted, -div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover.uncommitted { - background: #ddd; +form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="2"] ~ .cover, +div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="2"] ~ .cover { + background-color: #ff5; } -form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover.mine, -div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover.mine { - display: none; +form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="2"] ~ .cover:after, +div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="2"] ~ .cover:after { + content: "~"; +} +form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="3"] ~ .cover, +div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="3"] ~ .cover { + background-color: #ccc; +} +form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="3"] ~ .cover:after, +div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="number"][value="3"] ~ .cover:after { + content: "?"; } form.realtime table input[type="text"], div.realtime table input[type="text"] { diff --git a/www/poll/poll.less b/www/poll/poll.less index d1979a958..95b5cfa52 100644 --- a/www/poll/poll.less +++ b/www/poll/poll.less @@ -9,6 +9,8 @@ @poll-border-color: #555; @poll-cover-color: #000; @poll-fg: #000; +@poll-option-yellow: #ff5; +@poll-option-gray: #ccc; html, body { width: 100%; @@ -251,7 +253,7 @@ form.realtime, div.realtime { } input { - &[type="checkbox"] { + &[type="number"] { &:not(.editable) { display: none; @@ -259,26 +261,21 @@ form.realtime, div.realtime { display: block; font-weight: bold; - background-color: @cp-red; color: @poll-cover-color; &:after { height: 100%; } - &:after { content: "✖"; } - display: block; &.yes { background-color: @cp-green; - &:after { content: "✔"; } } &.uncommitted { background: #ddd; } - &.mine { display: none; } @@ -286,6 +283,31 @@ form.realtime, div.realtime { } } } + + input[type="number"][value="0"] { + ~ .cover { + background-color: @cp-red; + &:after { content: "✖"; } + } + } + input[type="number"][value="1"] { + ~ .cover { + background-color: @cp-green; + &:after { content: "✔"; } + } + } + input[type="number"][value="2"] { + ~ .cover { + background-color: @poll-option-yellow; + &:after { content: "~"; } + } + } + input[type="number"][value="3"] { + ~ .cover { + background-color: @poll-option-gray; + &:after { content: "?"; } + } + } } } } diff --git a/www/poll/render.js b/www/poll/render.js index 8399d5b71..08b91962a 100644 --- a/www/poll/render.js +++ b/www/poll/render.js @@ -70,7 +70,12 @@ var Renderer = function (Cryptpad) { }; var getCellValue = Render.getCellValue = function (obj, cellId) { - return Cryptpad.find(obj, ['table', 'cells'].concat([cellId])); + var value = Cryptpad.find(obj, ['table', 'cells'].concat([cellId])); + if (typeof value === 'boolean') { + return (value === true ? '1' : '0'); + } else { + return value; + } }; var setRowValue = Render.setRowValue = function (obj, rowId, value) { @@ -234,16 +239,20 @@ var Renderer = function (Cryptpad) { disabled: 'disabled' }].concat(cols.map(function (col) { var id = [col, rows[i-1]].join('_'); - var val = cells[id] || false; + var val = cells[id]; var result = { 'data-rt-id': id, - type: 'checkbox', + type: 'number', autocomplete: 'nope', + value: '3', }; if (readOnly) { result.disabled = "disabled"; } - if (val) { result.checked = true; } + if (typeof val !== 'undefined') { + if (typeof val === 'boolean') { val = (val ? '1' : '0'); } + result.value = val; + } return result; })); }); @@ -297,9 +306,6 @@ var Renderer = function (Cryptpad) { attrs.id = cell['data-rt-id']; var labelClass = 'cover'; - if (cell.checked) { - labelClass += ' yes'; - } // TODO implement Yes/No/Maybe/Undecided return ['TD', {class:"checkbox-cell"}, [ @@ -326,7 +332,7 @@ var Renderer = function (Cryptpad) { ]]; } - if (cell && cell.type === 'checkbox') { + if (cell && cell.type === 'number') { return makeCheckbox(cell); } return ['TD', cell, []]; @@ -399,7 +405,7 @@ var Renderer = function (Cryptpad) { preDiffApply: function (info) { if (!diffIsInput(info)) { return; } switch (getInputType(info)) { - case 'checkbox': + case 'number': //console.log('checkbox'); //console.log("[preDiffApply]", info); break; From 49370764c17f881362c0346c5d65333524816204 Mon Sep 17 00:00:00 2001 From: XWiki SAS Date: Mon, 12 Jun 2017 18:14:33 +0200 Subject: [PATCH 07/23] change whiteboard translation --- customize.dist/translations/messages.js | 3 +++ www/whiteboard/main.js | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index fa08fb1c7..cc279516c 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -211,6 +211,9 @@ define(function () { out.canvas_enable = "Enable draw"; out.canvas_width = "Width"; out.canvas_opacity = "Opacity"; + out.canvas_opacityLabel = "opacity: {0}"; + out.canvas_widthLabel = "Width: {0}"; + // File manager diff --git a/www/whiteboard/main.js b/www/whiteboard/main.js index a96fdb457..a19b5ba63 100644 --- a/www/whiteboard/main.js +++ b/www/whiteboard/main.js @@ -97,7 +97,8 @@ window.canvas = canvas; var updateBrushWidth = function () { var val = $width.val(); canvas.freeDrawingBrush.width = Number(val); - $widthLabel.text(val); + $widthLabel.text(val) + $widthLabel.text(Cryptpad.Messages._getKey("canvas_widthLabel", [val])) $widthLabel.text("width: " + $width.val()) createCursor(); console.log("change size") @@ -111,7 +112,7 @@ window.canvas = canvas; brush.opacity = Number(val); canvas.freeDrawingBrush.color = Colors.hex2rgba(brush.color, brush.opacity); $opacityLabel.text(val) - $opacityLabel.text("opacity: " + $opacity.val()); + $opacityLabel.text(Cryptpad.Messages._getKey("canvas_opacityLabel", [val])); createCursor(); console.log("change opacity") console.log("opacity: " + $opacity.val()) From 0118fdbd0036c7a7c4dfc3e17e653d91580f2629 Mon Sep 17 00:00:00 2001 From: Pierre Bondoerffer Date: Mon, 12 Jun 2017 18:16:11 +0200 Subject: [PATCH 08/23] use a local variable --- www/poll/main.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/www/poll/main.js b/www/poll/main.js index a805b4c02..400811537 100644 --- a/www/poll/main.js +++ b/www/poll/main.js @@ -108,14 +108,13 @@ define([ }; var unlockElements = function () { - var $input; APP.editable.row.forEach(function (id) { - $input = $('input[type="text"][disabled="disabled"][data-rt-id="' + id + '"]').removeAttr('disabled'); + var $input = $('input[type="text"][disabled="disabled"][data-rt-id="' + id + '"]').removeAttr('disabled'); $input.parent().parent().addClass('editing'); $('span.edit[data-rt-id="' + id + '"]').css('visibility', 'hidden'); }); APP.editable.col.forEach(function (id) { - $input = $('input[disabled="disabled"][data-rt-id^="' + id + '"]').removeAttr('disabled'); + var $input = $('input[disabled="disabled"][data-rt-id^="' + id + '"]').removeAttr('disabled'); $input.parent().addClass('editing'); $('input[type="number"][data-rt-id^="' + id + '"]').addClass('enabled'); $('.lock[data-rt-id="' + id + '"]').addClass('fa-unlock').removeClass('fa-lock').attr('title', Messages.poll_unlocked); From cd1c95792997e1ff13af090a5944f64c643cf8e5 Mon Sep 17 00:00:00 2001 From: Pierre Bondoerffer Date: Mon, 12 Jun 2017 18:23:17 +0200 Subject: [PATCH 09/23] NaN safety --- www/poll/main.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/www/poll/main.js b/www/poll/main.js index 400811537..35bc4ffb2 100644 --- a/www/poll/main.js +++ b/www/poll/main.js @@ -278,7 +278,14 @@ define([ case 'number': debug("checkbox[tr-id='%s'] %s", id, input.value); if (APP.editable.col.indexOf(x) >= 0 || x === APP.userid) { - Render.setValue(object, id, parseInt(input.value)); + var value = parseInt(input.value); + + if (isNaN(value)) { + console.error("Got NaN?!"); + break; + } + + Render.setValue(object, id, value); change(); } else { debug('checkbox locked'); @@ -359,7 +366,6 @@ define([ if (!APP.ready) { return; } if (!isKeyup && e.which !== 1) { return; } - var target = e && e.target; if (!target) { return void debug("NO TARGET"); } @@ -384,6 +390,7 @@ define([ case 'LABEL': var input = $('input[type="number"][id=' + $(target).attr('for') + ']'); var value = parseInt(input.val()); + input.val((value + 1) % 4); handleInput(input[0]); From 56f2c46c755b649d55bbd473f4f0086f29176fe7 Mon Sep 17 00:00:00 2001 From: Pierre Bondoerffer Date: Mon, 12 Jun 2017 18:25:06 +0200 Subject: [PATCH 10/23] document a line --- www/poll/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/poll/main.js b/www/poll/main.js index 35bc4ffb2..59d1fb2e4 100644 --- a/www/poll/main.js +++ b/www/poll/main.js @@ -364,7 +364,7 @@ define([ e.stopPropagation(); if (!APP.ready) { return; } - if (!isKeyup && e.which !== 1) { return; } + if (!isKeyup && e.which !== 1) { return; } // only allow left clicks var target = e && e.target; From 848010842f7a034fa1d0fba07d78c96841471ae5 Mon Sep 17 00:00:00 2001 From: Pierre Bondoerffer Date: Mon, 12 Jun 2017 18:26:27 +0200 Subject: [PATCH 11/23] dont sanity check silently --- www/poll/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/poll/main.js b/www/poll/main.js index 59d1fb2e4..99419eb22 100644 --- a/www/poll/main.js +++ b/www/poll/main.js @@ -383,7 +383,7 @@ define([ hideInputs(target, isKeyup); break; } - if ($(target).is('input[type="number"]')) { break; } + if ($(target).is('input[type="number"]')) { console.error("number input focused?"); break; } handleInput(target); break; From b2eef94232a53f9f74114ccdbc12615bfb09345e Mon Sep 17 00:00:00 2001 From: Pierre Bondoerffer Date: Mon, 12 Jun 2017 18:35:13 +0200 Subject: [PATCH 12/23] use numbers, not strings --- www/poll/render.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/poll/render.js b/www/poll/render.js index 08b91962a..f84fdc964 100644 --- a/www/poll/render.js +++ b/www/poll/render.js @@ -72,7 +72,7 @@ var Renderer = function (Cryptpad) { var getCellValue = Render.getCellValue = function (obj, cellId) { var value = Cryptpad.find(obj, ['table', 'cells'].concat([cellId])); if (typeof value === 'boolean') { - return (value === true ? '1' : '0'); + return (value === true ? 1 : 0); } else { return value; } From 2b5339193c5f801f01c8977984d664d812e222a2 Mon Sep 17 00:00:00 2001 From: Pierre Bondoerffer Date: Mon, 12 Jun 2017 18:45:04 +0200 Subject: [PATCH 13/23] bring admin back --- www/poll/index.html | 1 + www/poll/main.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/www/poll/index.html b/www/poll/index.html index 22280e8a9..091086f5c 100644 --- a/www/poll/index.html +++ b/www/poll/index.html @@ -28,6 +28,7 @@
+
diff --git a/www/poll/main.js b/www/poll/main.js index 99419eb22..8043da3fc 100644 --- a/www/poll/main.js +++ b/www/poll/main.js @@ -141,10 +141,12 @@ define([ var setTablePublished = function (bool) { if (bool) { if (APP.$publish) { APP.$publish.hide(); } + if (APP.$admin) { APP.$admin.show(); } $('#create-option').hide(); $('.remove[data-rt-id^="y"], .edit[data-rt-id^="y"]').hide(); } else { if (APP.$publish) { APP.$publish.show(); } + if (APP.$admin) { APP.$admin.hide(); } $('#create-option').show(); $('.remove[data-rt-id^="y"], .edit[data-rt-id^="y"]').show(); } @@ -518,7 +520,11 @@ var ready = function (info, userid, readOnly) { publish(true); }); - // #publish button is removed in readonly + APP.$admin = $('#admin') + .click(function () { + publish(false); + }); + APP.$help = $('#help') .click(function () { showHelp(); @@ -723,7 +729,7 @@ var create = function (info) { }; if (readOnly) { - $('#commit, #create-user, #create-option, #publish').remove(); + $('#commit, #create-user, #create-option, #publish, #admin').remove(); } var parsedHash = Cryptpad.parsePadUrl(window.location.href); From d344f0377853cb64c2503cb2768527c887c5a8d5 Mon Sep 17 00:00:00 2001 From: Pierre Bondoerffer Date: Mon, 12 Jun 2017 18:57:07 +0200 Subject: [PATCH 14/23] proper button text --- www/poll/main.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/poll/main.js b/www/poll/main.js index 8043da3fc..4878b60a6 100644 --- a/www/poll/main.js +++ b/www/poll/main.js @@ -758,7 +758,8 @@ var create = function (info) { Cryptpad.setAttribute(HIDE_INTRODUCTION_TEXT, "1", function (e) { if (e) { console.error(e); } }); - } else if (value === "1") { + showHelp(true); + } else { showHelp(false); } }); From 100cc1792a2511d4ee3ce9dfa083de1e109f6ebe Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 13 Jun 2017 11:47:22 +0200 Subject: [PATCH 15/23] non-existent files have size 0 --- rpc.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/rpc.js b/rpc.js index 6e555ae4a..25b1ae550 100644 --- a/rpc.js +++ b/rpc.js @@ -336,8 +336,13 @@ var getMultipleFileSize = function (Env, channels, cb) { channels.forEach(function (channel) { getFileSize(Env, channel, function (e, size) { if (e) { - WARN('getFileSize', e); - counts[channel] = -1; + // most likely error here is that a file no longer exists + // but a user still has it in their drive, and wants to know + // its size. We should find a way to inform them of this in + // the future. For now we can just tell them it has no size. + + //WARN('getFileSize', e); + counts[channel] = 0; return done(); } counts[channel] = size; From 3337e2133a9ecc15d07164db568be1bae29fd973 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 13 Jun 2017 11:57:21 +0200 Subject: [PATCH 16/23] more thorough tests for localStorage presence --- www/common/boot2.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/www/common/boot2.js b/www/common/boot2.js index 64d4bd71d..f197b792a 100644 --- a/www/common/boot2.js +++ b/www/common/boot2.js @@ -20,16 +20,24 @@ define([], function () { }; } - if (!localStorage || typeof(localStorage.getItem) !== 'function') { - require('jquery', function ($) { + var failStore = function () { + require(['jquery'], function ($) { $.ajax({ type: 'HEAD', url: '/common/feedback.html?NO_LOCALSTORAGE=' + (+new Date()), }); }); window.alert("CryptPad needs localStorage to work, try a different browser"); - return; - } + }; + + try { + var test_key = 'localStorage_test'; + var testval = Math.random().toString(); + localStorage.setItem(test_key, testval); + if (localStorage.getItem(test_key) !== test_key) { + return failStore(); + } + } catch (e) { console.error(e); return failStore(); } require([document.querySelector('script[data-bootload]').getAttribute('data-bootload')]); }); From 7ad89bd9af1e4a54fda5b570d45bef79ff1c97bd Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 13 Jun 2017 12:02:36 +0200 Subject: [PATCH 17/23] don't interrupt boot because of localStorage failure --- www/common/boot2.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/common/boot2.js b/www/common/boot2.js index f197b792a..84b42a32a 100644 --- a/www/common/boot2.js +++ b/www/common/boot2.js @@ -35,9 +35,9 @@ define([], function () { var testval = Math.random().toString(); localStorage.setItem(test_key, testval); if (localStorage.getItem(test_key) !== test_key) { - return failStore(); + failStore(); } - } catch (e) { console.error(e); return failStore(); } + } catch (e) { console.error(e); failStore(); } require([document.querySelector('script[data-bootload]').getAttribute('data-bootload')]); }); From 1b574da053c524b52bdc4437da4e8927a185db49 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 13 Jun 2017 12:24:32 +0200 Subject: [PATCH 18/23] fix typo --- www/common/boot2.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/common/boot2.js b/www/common/boot2.js index 84b42a32a..40f9639e8 100644 --- a/www/common/boot2.js +++ b/www/common/boot2.js @@ -21,6 +21,7 @@ define([], function () { } var failStore = function () { + console.error(new Error('wut')); require(['jquery'], function ($) { $.ajax({ type: 'HEAD', @@ -34,7 +35,7 @@ define([], function () { var test_key = 'localStorage_test'; var testval = Math.random().toString(); localStorage.setItem(test_key, testval); - if (localStorage.getItem(test_key) !== test_key) { + if (localStorage.getItem(test_key) !== testval) { failStore(); } } catch (e) { console.error(e); failStore(); } From 40cf7ea107344672b3c73b3bda94d1e3d70aa7f8 Mon Sep 17 00:00:00 2001 From: XWiki SAS Date: Tue, 13 Jun 2017 14:11:22 +0200 Subject: [PATCH 19/23] change whiteboard --- www/whiteboard/main.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/www/whiteboard/main.js b/www/whiteboard/main.js index a19b5ba63..4005929cc 100644 --- a/www/whiteboard/main.js +++ b/www/whiteboard/main.js @@ -99,9 +99,7 @@ window.canvas = canvas; canvas.freeDrawingBrush.width = Number(val); $widthLabel.text(val) $widthLabel.text(Cryptpad.Messages._getKey("canvas_widthLabel", [val])) - $widthLabel.text("width: " + $width.val()) createCursor(); - console.log("change size") }; updateBrushWidth(); @@ -114,8 +112,6 @@ window.canvas = canvas; $opacityLabel.text(val) $opacityLabel.text(Cryptpad.Messages._getKey("canvas_opacityLabel", [val])); createCursor(); - console.log("change opacity") - console.log("opacity: " + $opacity.val()) }; updateBrushOpacity(); From 74c9b663ddf9826b4ebd4f3e94014c236790d998 Mon Sep 17 00:00:00 2001 From: XWiki SAS Date: Tue, 13 Jun 2017 14:14:36 +0200 Subject: [PATCH 20/23] changing whiteboard --- www/whiteboard/main.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/www/whiteboard/main.js b/www/whiteboard/main.js index 4005929cc..40e76f9fd 100644 --- a/www/whiteboard/main.js +++ b/www/whiteboard/main.js @@ -50,7 +50,7 @@ define([ }; var $toggle = $('#toggleDraw'); - var $width = $('#width'); // brush width + var $width = $('#width'); var $widthLabel = $('label[for="width"]'); var $opacity = $('#opacity'); var $opacityLabel = $('label[for="opacity"]'); @@ -97,8 +97,7 @@ window.canvas = canvas; var updateBrushWidth = function () { var val = $width.val(); canvas.freeDrawingBrush.width = Number(val); - $widthLabel.text(val) - $widthLabel.text(Cryptpad.Messages._getKey("canvas_widthLabel", [val])) + $widthLabel.text(Cryptpad.Messages._getKey("canvas_widthLabel", [val])); createCursor(); }; updateBrushWidth(); @@ -109,7 +108,6 @@ window.canvas = canvas; var val = $opacity.val(); brush.opacity = Number(val); canvas.freeDrawingBrush.color = Colors.hex2rgba(brush.color, brush.opacity); - $opacityLabel.text(val) $opacityLabel.text(Cryptpad.Messages._getKey("canvas_opacityLabel", [val])); createCursor(); }; From 0004be521cf8d4edd1f5125bbc2582254c7b42d3 Mon Sep 17 00:00:00 2001 From: XWiki SAS Date: Tue, 13 Jun 2017 14:21:22 +0200 Subject: [PATCH 21/23] change translation --- customize.dist/translations/messages.fr.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index 64b40f553..f4e504fb3 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -209,6 +209,8 @@ define(function () { out.canvas_enable = "Activer le dessin"; out.canvas_width = "Épaisseur"; out.canvas_opacity = "Opacité"; + out.canvas_opacityLabel = "opacité: {0}"; + out.canvas_widthLabel = "taille: {0}"; // File manager From fc9ecb0f7c0f94dbc0fe2b38c6de5bbae47af102 Mon Sep 17 00:00:00 2001 From: XWiki SAS Date: Tue, 13 Jun 2017 15:20:16 +0200 Subject: [PATCH 22/23] change minimum opacity --- www/whiteboard/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/whiteboard/index.html b/www/whiteboard/index.html index d9496c344..7311e5973 100644 --- a/www/whiteboard/index.html +++ b/www/whiteboard/index.html @@ -25,7 +25,7 @@ - +
 
From 17e4e9be27bbdadafa2d8bbd4f7aa558f41cedd4 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 13 Jun 2017 16:12:13 +0200 Subject: [PATCH 23/23] download anything that isn't an image in media-tag --- www/common/media-tag.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/media-tag.js b/www/common/media-tag.js index d5d1143e9..a5958372e 100644 --- a/www/common/media-tag.js +++ b/www/common/media-tag.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.MediaTag=t():e.MediaTag=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=86)}([function(e,t,n){"use strict";var r={IMAGE:"image",AUDIO:"audio",VIDEO:"video",PDF:"pdf",DASH:"dash",DOWNLOAD:"download",CRYPTO:"crypto",CLEAR_KEY:"clear-key",MEDIA_OBJECT:"media-object"};e.exports=r},function(e,t,n){"use strict";var r={MATCHER:"matcher",RENDERER:"renderer",FILTER:"filter",SANITIZER:"sanitizer"};e.exports=r},function(e,t,n){"use strict";function r(e){if(e instanceof Array){var t=[];return e.forEach(function(e){e.mediaObject?t.push(e.mediaObject):t.push(r.start(e))}),t}var n=e;return r.start(n)}var o=n(25),i=n(24),u=n(44),a=n(45),c=n(23),s=n(22);r.createMediaObject=function(e){var t=new s(e),n=c.parse(t);return t.setProperties(n),t},r.start=function(e){var t=r.createMediaObject(e);return r.processingEngine.start(t)},r.pluginStore=r.pluginStore||new u,r.uriStore=r.uriStore||new a("../plugins"),r.processingEngine=r.processingEngine||new o(r.pluginStore),r.matchingEngine=r.matchingEngine||new i(r.pluginStore,r.uriStore),r.loadingEngine=null,e.exports=r},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var u=function(){function e(e,t){for(var n=0;n=0&&f.mediaTypes.splice(t,1)},f.removeAllAllowedMediaTypes=function(e){e.forEach(function(e){f.removeAllowedMediaType(e)})},f.isAllowedMediaType=function(e){return f.mediaTypes.some(function(t){return t===e})},e.exports=f},,function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var n=0;n MediaTag cannot find a plugin able to renderer your content

","Download");r.processingEngine.setDefaultPlugin(b),r.CryptoFilter=f;var v=["image/png","image/jpeg","image/jpg","image/gif","audio/mp3","audio/ogg","audio/wav","audio/webm","video/mp4","video/ogg","video/webm","application/pdf","application/dash+xml","download"];r.CryptoFilter.setAllowedMediaTypes(v);var g=n(21),d=(n(13),n(0),new g);r.processingEngine.configure(d),e.exports=r},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var u=n(1),a=n(5),c=n(6),s=function(e){function t(e){return r(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,u.SANITIZER,a.EVERY))}return i(t,e),t}(c);e.exports=s},,,function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){var n=t.type.split("/"),r=t.type,o=n[0],i=n[1];s.isAllowedMediaType(r)?(e.setAttribute("data-type",t.type),e.type=o,e.extension=i,e.mime=r):console.log("Not allowed metadata, allowed ones are : ",s.getAllowedMediaTypes()),e.name=t.name,e.setAttribute("data-attr-type",t.type)}function i(e){var t=e.getAttribute("src"),n=e.getAttribute("data-crypto-key"),r=p.getKeyFromStr(n),i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType="arraybuffer";var u=function(e){var t=new Event("decryptionError");t.message="string"==typeof e?e:e.message,window.document.dispatchEvent(t)};i.onload=function(){if(/^4/.test(""+this.status))return u("XHR_ERROR",""+this.status);var t=i.response;if(t){var n=new Uint8Array(t);p.decrypt(n,r,function(t,n){if(t)return u(t);var r=n.content,i=y.getBlobUrl(r,e.getMimeType()),a=new Event("decryption");a.blob=new Blob([r],{type:e.getMimeType()}),a.metadata=n.metadata,e.setAttribute("src",i),e.removeAttribute("data-crypto-key"),o(e,n.metadata),a.callback=function(){c.processingEngine.return(e)},window.document.dispatchEvent(a)})}},i.send(null)}var u=function(){function e(e,t){for(var n=0;n1;){if(f){if("number"!=typeof e[t])throw new Error("E_UNSAFE_TYPE");if(e[t]>255)throw new Error("E_OUT_OF_BOUNDS")}if(255!==e[t])return void e[t]++;if(e[t]=0,0===t)throw new Error("E_NONCE_TOO_LARGE")}}},{key:"encodePrefix",value:function(e){return[65280,255].map(function(t,n){return(e&t)>>8*(1-n)})}},{key:"decodePrefix",value:function(e){return e[0]<<8|e[1]}},{key:"joinChunks",value:function(t){return new Uint8Array(t.reduce(function(t,n){return e.slice(t).concat(e.slice(n))},[]))}},{key:"slice",value:function(e){return Array.prototype.slice.call(e)}},{key:"getRandomKeyStr",value:function(){var t=e.Nacl,n=t.randomBytes(18);return t.util.encodeBase64(n)}},{key:"getKeyFromStr",value:function(t){return e.Nacl.util.decodeBase64(t)}},{key:"encrypt",value:function(t,n){var r=t,o=e.Nacl.randomBytes(24),i=e.Nacl.secretbox(r,o,n);if(i)return new Uint8Array(e.slice(o).concat(e.slice(i)));throw new Error}},{key:"decrypt",value:function(t,n,r){var o=e.Nacl,i=function(e){var n=new Event("decryptionProgress");n.percent=e/t.length*100,window.document.dispatchEvent(n)},u=e.createNonce(),a=0,c=t.subarray(0,2),s=e.decodePrefix(c),f={metadata:void 0},p=new Uint8Array(t.subarray(2,2+s)),y=o.secretbox.open(p,u,n);e.increment(u);try{f.metadata=JSON.parse(o.util.encodeUTF8(y))}catch(e){return r("E_METADATA_DECRYPTION")}if(!f.metadata)return r("NO_METADATA");var h=function(r){var c=a*l+2+s,f=c+l;a++;var p=new Uint8Array(t.subarray(c,f)),y=o.secretbox.open(p,u,n);if(e.increment(u),!y)return void r("DECRYPTION_FAILURE");i(Math.min(f,t.length)),r(void 0,y)},b=[];!function n(){h(function(o,i){return o?setTimeout(function(){r(o)}):i?a*l1?t[0]:window.location.protocol}},{key:"hostname",value:function(e){var t=e.getAttribute("src").split("://");return t.length>1?t[1].split("/")[0]:window.location.hostname}},{key:"source",value:function(e){return e.getAttribute("src")}},{key:"schemes",value:function(e){return/\w+:/.exec(e.getAttribute("src"))}},{key:"parse",value:function(t){return{protocol:e.protocol(t),hostname:e.hostname(t),src:e.source(t),type:e.type(t),extension:e.extension(t),mime:e.mime(t)}}}]),e}();e.exports=i},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var n=0;n=e.STACK_LIMIT)throw console.error(this.snapshots[n]),new Error("Plugin stack size exceed");if(this.snapshots[n].length>=e.SNAPSHOT_LIMIT)throw console.error(this.snapshots[n]),new Error("Plugin snapshots size exceed");var r=0;if(this.stacks[n].forEach(function(e){e.type===a.RENDERER&&r++}),r>1)throw console.error(this.snapshots[n]),new Error("More of one renderer in the stack");if(0===this.stacks[n].length&&!this.stats[n][a.RENDERER]){if(!this.defaultPlugin)throw new Error("No default plugin assignated");this.stacks[n].unshift(this.defaultPlugin)}}},{key:"return",value:function(e){var t=e.getId(),n=this.unstack(e);this.stats[t]||(this.stats[t]={}),this.stats[t][n.type]?this.stats[t][n.type]+=1:this.stats[t][n.type]=1,0===this.stacks[t].length&&n.type===a.RENDERER?this.run(e):n.type!==a.SANITIZER&&this.fill(e),this.snapshot(e),this.check(e),this.run(e)}},{key:"process",value:function(e){var t=e.getId(),n=this.stacks[t].length,r=this.stacks[t][n-1];if(!r)throw console.log(this.stacks),new Error("Impossible to run a undefined plugin");r.process(e)}},{key:"isStacked",value:function(e,t){var n=e.getId();return!(!this.stacks[n]||!this.stacks[n].includes(t))}},{key:"setDefaultPlugin",value:function(e){this.defaultPlugin=e}}]),e}();f.STACK_LIMIT=100,f.SNAPSHOT_LIMIT=100,e.exports=f},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var u=function(){function e(e,t){for(var n=0;n=0&&f.mediaTypes.splice(t,1)},f.removeAllAllowedMediaTypes=function(e){e.forEach(function(e){f.removeAllowedMediaType(e)})},f.isAllowedMediaType=function(e){return f.mediaTypes.some(function(t){return t===e})},e.exports=f},,function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var n=0;n MediaTag cannot find a plugin able to renderer your content

","Download");r.processingEngine.setDefaultPlugin(b),r.CryptoFilter=f;var g=["image/png","image/jpeg","image/jpg","image/gif","audio/mp3","audio/ogg","audio/wav","audio/webm","video/mp4","video/ogg","video/webm","application/pdf","application/dash+xml","download"];r.CryptoFilter.setAllowedMediaTypes(g);var v=n(21),d=(n(13),n(0),new v);r.processingEngine.configure(d),e.exports=r},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var u=n(1),a=n(5),c=n(6),s=function(e){function t(e){return r(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,u.SANITIZER,a.EVERY))}return i(t,e),t}(c);e.exports=s},,,function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){var n=t.type.split("/"),r=t.type,o=n[0],i=n[1];console.log(s.getAllowedMediaTypes()),s.isAllowedMediaType(r)?(e.setAttribute("data-type",t.type),e.type=o,e.extension=i,e.mime=r):console.log("Not allowed metadata, allowed ones are : ",s.getAllowedMediaTypes()),e.name=t.name,e.setAttribute("data-attr-type",t.type)}function i(e){var t=e.getAttribute("src"),n=e.getAttribute("data-crypto-key"),r=p.getKeyFromStr(n),i=new XMLHttpRequest;i.open("GET",t,!0),i.responseType="arraybuffer";var u=function(e){var t=new Event("decryptionError");t.message="string"==typeof e?e:e.message,window.document.dispatchEvent(t)};i.onload=function(){if(/^4/.test(""+this.status))return u("XHR_ERROR",""+this.status);var t=i.response;if(t){var n=new Uint8Array(t);p.decrypt(n,r,function(t,n){if(t)return u(t);var r=n.content,i=y.getBlobUrl(r,e.getMimeType()),a=new Event("decryption");a.blob=new Blob([r],{type:e.getMimeType()}),a.metadata=n.metadata,console.log(n.metadata),e.setAttribute("src",i),e.removeAttribute("data-crypto-key"),["image/png","image/jpeg","image/jpg","image/gif"].indexOf(n.metadata.type)===-1&&(n.metadata.type="download"),o(e,n.metadata),a.callback=function(){c.processingEngine.return(e)},window.document.dispatchEvent(a)})}},i.send(null)}var u=function(){function e(e,t){for(var n=0;n1;){if(f){if("number"!=typeof e[t])throw new Error("E_UNSAFE_TYPE");if(e[t]>255)throw new Error("E_OUT_OF_BOUNDS")}if(255!==e[t])return void e[t]++;if(e[t]=0,0===t)throw new Error("E_NONCE_TOO_LARGE")}}},{key:"encodePrefix",value:function(e){return[65280,255].map(function(t,n){return(e&t)>>8*(1-n)})}},{key:"decodePrefix",value:function(e){return e[0]<<8|e[1]}},{key:"joinChunks",value:function(t){return new Uint8Array(t.reduce(function(t,n){return e.slice(t).concat(e.slice(n))},[]))}},{key:"slice",value:function(e){return Array.prototype.slice.call(e)}},{key:"getRandomKeyStr",value:function(){var t=e.Nacl,n=t.randomBytes(18);return t.util.encodeBase64(n)}},{key:"getKeyFromStr",value:function(t){return e.Nacl.util.decodeBase64(t)}},{key:"encrypt",value:function(t,n){var r=t,o=e.Nacl.randomBytes(24),i=e.Nacl.secretbox(r,o,n);if(i)return new Uint8Array(e.slice(o).concat(e.slice(i)));throw new Error}},{key:"decrypt",value:function(t,n,r){var o=e.Nacl,i=function(e){var n=new Event("decryptionProgress");n.percent=e/t.length*100,window.document.dispatchEvent(n)},u=e.createNonce(),a=0,c=t.subarray(0,2),s=e.decodePrefix(c),f={metadata:void 0},p=new Uint8Array(t.subarray(2,2+s)),y=o.secretbox.open(p,u,n);e.increment(u);try{f.metadata=JSON.parse(o.util.encodeUTF8(y))}catch(e){return r("E_METADATA_DECRYPTION")}if(!f.metadata)return r("NO_METADATA");var h=function(r){var c=a*l+2+s,f=c+l;a++;var p=new Uint8Array(t.subarray(c,f)),y=o.secretbox.open(p,u,n);if(e.increment(u),!y)return void r("DECRYPTION_FAILURE");i(Math.min(f,t.length)),r(void 0,y)},b=[];!function n(){h(function(o,i){return o?setTimeout(function(){r(o)}):i?a*l1?t[0]:window.location.protocol}},{key:"hostname",value:function(e){var t=e.getAttribute("src").split("://");return t.length>1?t[1].split("/")[0]:window.location.hostname}},{key:"source",value:function(e){return e.getAttribute("src")}},{key:"schemes",value:function(e){return/\w+:/.exec(e.getAttribute("src"))}},{key:"parse",value:function(t){return{protocol:e.protocol(t),hostname:e.hostname(t),src:e.source(t),type:e.type(t),extension:e.extension(t),mime:e.mime(t)}}}]),e}();e.exports=i},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var n=0;n=e.STACK_LIMIT)throw console.error(this.snapshots[n]),new Error("Plugin stack size exceed");if(this.snapshots[n].length>=e.SNAPSHOT_LIMIT)throw console.error(this.snapshots[n]),new Error("Plugin snapshots size exceed");var r=0;if(this.stacks[n].forEach(function(e){e.type===a.RENDERER&&r++}),r>1)throw console.error(this.snapshots[n]),new Error("More of one renderer in the stack");if(0===this.stacks[n].length&&!this.stats[n][a.RENDERER]){if(!this.defaultPlugin)throw new Error("No default plugin assignated");this.stacks[n].unshift(this.defaultPlugin)}}},{key:"return",value:function(e){var t=e.getId(),n=this.unstack(e);this.stats[t]||(this.stats[t]={}),this.stats[t][n.type]?this.stats[t][n.type]+=1:this.stats[t][n.type]=1,0===this.stacks[t].length&&n.type===a.RENDERER?this.run(e):n.type!==a.SANITIZER&&this.fill(e),this.snapshot(e),this.check(e),this.run(e)}},{key:"process",value:function(e){var t=e.getId(),n=this.stacks[t].length,r=this.stacks[t][n-1];if(!r)throw console.log(this.stacks),new Error("Impossible to run a undefined plugin");r.process(e)}},{key:"isStacked",value:function(e,t){var n=e.getId();return!(!this.stacks[n]||!this.stacks[n].includes(t))}},{key:"setDefaultPlugin",value:function(e){this.defaultPlugin=e}}]),e}();f.STACK_LIMIT=100,f.SNAPSHOT_LIMIT=100,e.exports=f},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var u=function(){function e(e,t){for(var n=0;n