From e2b162bf6d8f11c7c06c52546f71943b4744c614 Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 17 Aug 2016 15:29:04 +0200 Subject: [PATCH] snapshot some dead code --- www/poll/main.js | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/www/poll/main.js b/www/poll/main.js index e2a41ee65..b39de2f1d 100644 --- a/www/poll/main.js +++ b/www/poll/main.js @@ -9,10 +9,12 @@ define([ '/common/cryptpad-common.js', '/common/visible.js', '/common/notify.js', + '/bower_components/file-saver/FileSaver.min.js', '/bower_components/jquery/dist/jquery.min.js', '/customize/pad.js' ], function (Config, Messages, Table, Wizard, TextPatcher, Listmap, Crypto, Cryptpad, Visible, Notify) { var $ = window.jQuery; + var saveAs = window.saveAs; Cryptpad.styleAlerts(); console.log("Initializing your realtime session..."); @@ -288,6 +290,7 @@ define([ var ready = function (info) { console.log("Your realtime object is ready"); + module.ready = true; var proxy = module.rt.proxy; @@ -321,6 +324,8 @@ define([ } }); + // HERE TODO make this idempotent so you can call it again + // cols proxy.table.colsOrder.forEach(function (uid) { var val = proxy.table.cols[uid]; @@ -581,12 +586,63 @@ define([ Wizard.hasBeenDisplayed = true; })); + /* Import/Export buttons */ + /* + $toolbar.append(Button({ + id: 'import', + 'class': 'import button action', + title: 'IMPORT', // TODO translate + }).text('IMPORT') // TODO translate + .click(function () { + var proxy = module.rt.proxy; + + console.log("pew pew"); + if (!module.ready) { return; } + + console.log("bang bang"); + Cryptpad.importContent('text/plain', function (content, file) { + var parsed; + try { + parsed = JSON.parse(content); + } catch (err) { + Cryptpad.alert("Could not parse imported content"); + return; + } + console.log(content); + //module.rt.update(parsed); + })(); + })); + + $toolbar.append(Button({ + id: 'export', + 'class': 'export button action', + title: 'EXPORT', // TODO translate + }).text("EXPORT") // TODO translate + .click(function () { + if (!module.ready) { return; } + var proxy = module.rt.proxy; + + var title = suggestName(); + + var text = JSON.stringify(proxy, null, 2); + + Cryptpad.prompt(Messages.exportPrompt, title + '.json', function (filename) { + if (filename === null) { return; } + var blob = new Blob([text], { + type: 'application/json', + }); + saveAs(blob, filename); + }); + }));*/ + + setEditable(true); if (First) { // assume the first user to the poll wants to be the administrator... // TODO prompt them with questions to set up their poll... } + /* TODO even if the user isn't the first, check their storage to see if they've visited before and if they 'own' a column in the table.