]> source.dussan.org Git - nextcloud-server.git/commitdiff
print and close the new tab, not the current one when printing backup codes
authorChristoph Wurst <christoph@winzerhof-wurst.at>
Thu, 15 Dec 2016 17:16:41 +0000 (18:16 +0100)
committerChristoph Wurst <christoph@winzerhof-wurst.at>
Thu, 16 Feb 2017 15:14:49 +0000 (16:14 +0100)
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
apps/twofactor_backupcodes/js/settingsview.js

index 763960231201ea92b89b43cecb1e05fd7cdf82a4..633b845dc7603c68c54305e22eb5295c3b22231f 100644 (file)
                                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 + "<br>";
+                       }, '');
                },
                _load: function () {
                        this._loading = true;
                        });
                },
                _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();
                }
        });