Skip to content

Commit

Permalink
Enable download of Siegfried results
Browse files Browse the repository at this point in the history
  • Loading branch information
ross-spencer committed Jun 30, 2024
1 parent 5df8c13 commit e663d3d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
4 changes: 4 additions & 0 deletions index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ <h2 class="subtitle">An analysis tool for file-format reports for digital preser
<label class="custom-file-upload">
<input class="analysis_button" type="button" id="butDirectory" />
Siegfried: Identify directory
</label>&nbsp
<label class="custom-file-upload">
<input class="analysis_button" type="button" id="butDownload" />
Siegfried: Download results
</label>
</div>
<!-- LOADER AND READY BUTTONS -->
Expand Down
29 changes: 22 additions & 7 deletions sf/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,19 @@ function getArgs() {
return args;
}

function downloadResults() {
let res = document.getElementById("sf-results").value.trim();
var base64doc = btoa(unescape(encodeURIComponent(res))),
a = document.createElement('a'),
e = new MouseEvent('click');
a.download = 'results.yaml';
a.href = 'data:text/html;base64,' + base64doc;
a.dispatchEvent(e);
}


function toggleInit() {
let sf = true;

toggleHeight = document.getElementById("static-analysis").offsetHeight;
document.getElementById("static-analysis").style.height = 0;
document.getElementById("static-analysis").style.visibility = "hidden";
Expand All @@ -31,7 +41,7 @@ function toggleInit() {
document.getElementById("static-analysis").style.height = toggleHeight + "px";
document.getElementById("static-analysis").style.visibility = "visible";
toggleHeight = document.getElementById("use-siegfried").offsetHeight;
document.getElementById("use-siegfried").style.height="0";
document.getElementById("use-siegfried").style.height = "0";
sf = false;
return;
}
Expand All @@ -42,7 +52,7 @@ function toggleInit() {
document.getElementById("use-siegfried").style.height = toggleHeight + "px";
document.getElementById("use-siegfried").style.visibility = "visible";
toggleHeight = document.getElementById("static-analysis").offsetHeight;
document.getElementById("static-analysis").style.height="0";
document.getElementById("static-analysis").style.height = "0";
sf = true;
return;
});
Expand All @@ -61,8 +71,7 @@ window.onload = () => {
console.log("file selection error: " + err);
});
};
}
).catch((err) => {
}).catch((err) => {
console.log("file selection error: " + err);
});
});
Expand All @@ -85,9 +94,15 @@ window.onload = () => {
}).catch((err) => {
console.log("directory selection error: " + err);
});
}
).catch((err) => {
}).catch((err) => {
console.log("directory selection error: " + err);
});
});
document.getElementById('butDownload').addEventListener('click', (event) => {
try {
downloadResults()
} catch (err) {
console.log("download siegfrried error (ensure siegfried has been run): " + err)
}
});
}

0 comments on commit e663d3d

Please sign in to comment.