From cd832156a02ec6fdb3b9e34f687ef0f20c564c8b Mon Sep 17 00:00:00 2001 From: zuzanna-maria Date: Tue, 12 Nov 2024 10:25:06 +0100 Subject: [PATCH] Refactoring download function --- www/common/make-backup.js | 16 ++++++++++------ www/form/main.js | 3 --- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/www/common/make-backup.js b/www/common/make-backup.js index fe9ac110f..41894479e 100644 --- a/www/common/make-backup.js +++ b/www/common/make-backup.js @@ -240,20 +240,24 @@ define([ if (ctx.stop) { return; } if (!res.data) { return void error('EEMPTY'); } var data = JSON.parse(val) - var _answers = data["answers"] + if (data.form) { + var _answers = data["answers"] _answers['href'] = parsed.hash _answers['password'] = fData.password _answers['drive'] = true - var answers + var answers; ctx.sframeChan.query("Q_FORM_FETCH_ANSWERS", _answers, function (err, obj) { answers = obj && obj.results; console.log("ANSWERS", answers) }); - // var opts = { - // binary: true, - // }; - // zip.file(fileName, answers, opts); + var opts = { + binary: true, + }; + var fileName = getUnique(sanitize(rawName + ' (answers)'), '.json', existingNames); + existingNames.push(fileName.toLowerCase()); + var content = new Blob([answers], { type : "application/json" }); + zip.file(fileName, content, opts); } var fileName = getUnique(sanitize(rawName), res.ext, existingNames); diff --git a/www/form/main.js b/www/form/main.js index 6d8a02bf7..5efc81aab 100644 --- a/www/form/main.js +++ b/www/form/main.js @@ -129,9 +129,6 @@ define([ return false; } }; - var beep = function () { - - } var deleteLines = false; // "false" to support old forms sframeChan.on('Q_FORM_FETCH_ANSWERS', function (data, _cb) {