From e77ad4e909eec45a224c2c40fcefe7e16974e87e Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 7 Nov 2016 12:26:48 +0100 Subject: [PATCH 1/2] better fixes for export --- www/code/main.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/www/code/main.js b/www/code/main.js index 4f6b087dd..4c28fe58e 100644 --- a/www/code/main.js +++ b/www/code/main.js @@ -253,19 +253,21 @@ define([ var clike = /^\s*(\/\*|\/\/)(.*)?(\*\/)*$/; if (clike.test(line)) { line.replace(clike, function (a, one, two) { - if (!two && two.replace) { return; } + if (!(two && two.replace)) { return; } text = two.replace(/\*\/\s*$/, '').trim(); }); return true; } + + // TODO make one more pass for multiline comments }); return text.trim(); }; - var suggestName = function () { + var suggestName = function (fallback) { if (document.title === defaultName) { - return getHeadingText() || ""; + return getHeadingText() || fallback || ""; } else { return document.title || getHeadingText() || defaultName; } @@ -276,7 +278,7 @@ define([ var ext = Modes.extensionOf(module.highlightMode); - var title = Cryptpad.fixFileName(suggestName()) + ext; + var title = Cryptpad.fixFileName(suggestName('cryptpad')) + (ext || '.txt'); Cryptpad.prompt(Messages.exportPrompt, title, function (filename) { if (filename === null) { return; } From d009b7400c26e65c61ce5faeb2eaa68425c4d0d6 Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 7 Nov 2016 12:29:57 +0100 Subject: [PATCH 2/2] fall back to default title if one is not suggested --- www/pad/main.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/www/pad/main.js b/www/pad/main.js index 310a3d353..de3e2bcf9 100644 --- a/www/pad/main.js +++ b/www/pad/main.js @@ -321,9 +321,9 @@ define([ })) { return text; } }; - var suggestName = function () { + var suggestName = function (fallback) { if (document.title === defaultName) { - return getHeadingText() || ""; + return getHeadingText() || fallback || ""; } else { return document.title || getHeadingText() || defaultName; } @@ -510,7 +510,7 @@ define([ var exportFile = function () { var html = getHTML(); - var suggestion = suggestName(); + var suggestion = suggestName('cryptpad-document'); Cryptpad.prompt(Messages.exportPrompt, Cryptpad.fixFileName(suggestion) + '.html', function (filename) { if (!(typeof(filename) === 'string' && filename)) { return; }