From e111015afab4e21fb6a722746e9ad9ed86ad0c10 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Thu, 15 Dec 2016 18:16:41 +0100 Subject: [PATCH 1/2] print and close the new tab, not the current one when printing backup codes Signed-off-by: Christoph Wurst --- apps/twofactor_backupcodes/js/settingsview.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/apps/twofactor_backupcodes/js/settingsview.js b/apps/twofactor_backupcodes/js/settingsview.js index 7639602312..633b845dc7 100644 --- a/apps/twofactor_backupcodes/js/settingsview.js +++ b/apps/twofactor_backupcodes/js/settingsview.js @@ -59,16 +59,16 @@ total: this._total, used: this._used, codes: this._codes, - download: this._getDownloadDataHref() + download: this._getDownloadData() })); }, - _getDownloadDataHref: function () { + _getDownloadData: function () { if (!this._codes) { return ''; } - return 'data:text/plain,' + encodeURIComponent(_.reduce(this._codes, function (prev, code) { - return prev + code + "\r\n"; - }, '')); + return _.reduce(this._codes, function (prev, code) { + return prev + code + "
"; + }, ''); }, _load: function () { this._loading = true; @@ -113,10 +113,11 @@ }); }, _onPrintBackupCodes: function () { - var url = this._getDownloadDataHref(); - window.open(url, t('twofactor_backupcodes', 'Nextcloud backup codes')); - window.print(); - window.close(); + var data = this._getDownloadData(); + var newTab = window.open('', t('twofactor_backupcodes', 'Nextcloud backup codes')); + newTab.document.write(data); + newTab.print(); + newTab.close(); } }); From 3295fe2eb74695d4549da8d27d9427c20302487e Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Tue, 20 Dec 2016 14:52:24 +0100 Subject: [PATCH 2/2] add title to backup codes print page Signed-off-by: Christoph Wurst --- apps/twofactor_backupcodes/js/settingsview.js | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/twofactor_backupcodes/js/settingsview.js b/apps/twofactor_backupcodes/js/settingsview.js index 633b845dc7..753644fb21 100644 --- a/apps/twofactor_backupcodes/js/settingsview.js +++ b/apps/twofactor_backupcodes/js/settingsview.js @@ -115,6 +115,7 @@ _onPrintBackupCodes: function () { var data = this._getDownloadData(); var newTab = window.open('', t('twofactor_backupcodes', 'Nextcloud backup codes')); + newTab.document.write('

' + t('twofactor_backupcodes', 'Nextcloud backup codes') + '

'); newTab.document.write(data); newTab.print(); newTab.close();