Merge pull request #2704 from nextcloud/2fa-fix-backup-codes-print

print the backup codes tab and not the current one
This commit is contained in:
Roeland Jago Douma 2017-02-15 20:18:48 +01:00 committed by GitHub
commit 2d8b7b875b
1 changed files with 11 additions and 9 deletions

View File

@ -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 + "<br>";
}, '');
},
_load: function () {
this._loading = true;
@ -113,10 +113,12 @@
});
},
_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('<h1>' + t('twofactor_backupcodes', 'Nextcloud backup codes') + '</h1>');
newTab.document.write(data);
newTab.print();
newTab.close();
}
});