Update campaign_results.min.js

pull/2990/head
BlkPh0x 2023-10-10 13:35:04 +11:00 committed by GitHub
parent 54781b920b
commit 2541c7190b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 36 additions and 38 deletions

View File

@ -198,6 +198,8 @@ function completeCampaign() {
}
})
}
// Exports campaign results as a CSV file
function exportAsCleanCSV(scope) {
var csvScope = null;
var filename = campaign.name + ' - ' + capitalize(scope) + '.csv';
@ -289,44 +291,40 @@ function exportAsCleanCSV(scope) {
// exportAsCSV('events');
// exportAsCSV('cleanresults'); // Add this line to export clean results
// Exports campaign results as a CSV file
exportAsCSV(scope) {
exportHTML = $("#exportButton").html();
var csvScope = null;
var filename = campaign.name + " - " + capitalize(scope) + ".csv";
switch (scope) {
case "results":
csvScope = campaign.results;
break;
case "events":
csvScope = campaign.timeline;
break;
}
if (!csvScope) {
return;
}
$("#exportButton").html('<i class="fa fa-spinner fa-spin"></i>');
var csvString = Papa.unparse(csvScope, { escapeFormulae: true });
var csvData = new Blob([csvString], { type: "text/csv;charset=utf-8;" });
if (navigator.msSaveBlob) {
navigator.msSaveBlob(csvData, filename);
} else {
var csvURL = window.URL.createObjectURL(csvData);
var dlLink = document.createElement("a");
dlLink.href = csvURL;
dlLink.setAttribute("download", filename);
document.body.appendChild(dlLink);
dlLink.click();
document.body.removeChild(dlLink);
}
$("#exportButton").html(exportHTML);
function exportAsCSV(scope) {
exportHTML = $("#exportButton").html()
var csvScope = null
var filename = campaign.name + ' - ' + capitalize(scope) + '.csv'
switch (scope) {
case "results":
csvScope = campaign.results
break;
case "events":
csvScope = campaign.timeline
break;
}
if (!csvScope) {
return
}
$("#exportButton").html('<i class="fa fa-spinner fa-spin"></i>')
var csvString = Papa.unparse(csvScope, {
'escapeFormulae': true
})
var csvData = new Blob([csvString], {
type: 'text/csv;charset=utf-8;'
});
if (navigator.msSaveBlob) {
navigator.msSaveBlob(csvData, filename);
} else {
var csvURL = window.URL.createObjectURL(csvData);
var dlLink = document.createElement('a');
dlLink.href = csvURL;
dlLink.setAttribute('download', filename)
document.body.appendChild(dlLink)
dlLink.click();
document.body.removeChild(dlLink)
}
$("#exportButton").html(exportHTML)
}
function replay(event_idx) {