-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathidpcg_web.js
62 lines (50 loc) · 1.7 KB
/
idpcg_web.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//Author: Zi Hao (Nemo) Liu, @menoliu
//Date modified: May 26, 2022
function formReset() {
document.getElementById("idpcg_form").reset();
document.getElementById("preview").innerHTML = "#!/bin/bash<br><br>idpconfgen -h \\";
}
function resetScm() {
document.getElementById("faspr").checked=false;
document.getElementById("mcsce").checked=false;
}
function resetDsd() {
document.getElementById("dsd").checked=false;
}
function processForm(newline) {
var formData = new FormData(document.getElementById("idpcg_form"));
var contents = '';
var select = document.getElementById("subclients");
var client = select.options[select.selectedIndex].value;
for (var pair of formData.entries()){
var flag = pair[0];
var val = pair[1];
if (flag == "pos" && val != '') {
contents += newline+val+' \\';
continue;
}
if (val != ''){
if (val == "True"){
contents += newline+flag+' \\';
}
else {
contents += newline+flag+' '+val+' \\';
}
}
}
contents=contents.slice(0,-2);
return [client, contents];
}
function loadPreview() {
var nltab = "<br> ";
processed = processForm(nltab);
var header = "#!/bin/bash<br><br>idpconfgen "+processed[0]+" \\";
document.getElementById("preview").innerHTML = header+processed[1];
}
function downloadScript() {
var nltab = "\n\t";
processed = processForm(nltab)
var header = "#!/bin/bash\n\nidpconfgen "+processed[0]+" \\";
var bashFile = new File([header+processed[1]], "idpconfgenJob.sh", {type: "text/plain;charset=utf-8"});
saveAs(bashFile);
}