-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.html
More file actions
137 lines (98 loc) · 4.23 KB
/
create.html
File metadata and controls
137 lines (98 loc) · 4.23 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<title>Create Set</title>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<link rel="stylesheet" href="style.css">
</head>
<body> <!-- hello evin--> <!-- hewwo -->
<h2>Create a Set File</h2>
<h3>Set Name:</h3>
<input id="setname" value="MyBearzletSet">
<h4>Privacy:</h4>
<input type="radio" id="public" name="privacy" value="public" checked>
<label for="public">Public</label><br>
<input type="radio" id="private" name="privacy" value="private">
<label for="private">Private</label><br>
<h3>Contents (Rows with semicolons or empty boxes be ignored):</h3>
<button id="add">Add Row</button>
<br><br>
<div id="content">
<div id="row_1">
<input id="word1" class="word" placeholder="Word 1"> <input id="def1" class="def" placeholder="Definition 1">
<br><br>
<input id="word2" class="word" placeholder="Word 2"> <input id="def2" class="def" placeholder="Definition 2">
<br><br>
<input id="word3" class="word" placeholder="Word 3"> <input id="def3" class="def" placeholder="Definition 3">
<br><br>
</div>
</div>
<br><br>
<button id="submit">Submit</button>
<script>
let rowcount = 3;
let submit = async function () {
/*
set name
private (true/false)
word; definition
word; definition
*/
let w = document.getElementsByClassName("word");
let d = document.getElementsByClassName("def");
console.log(w, d);
let c = document.getElementById("setname").value + `\n`;
//Figure out if the set is private
if(document.getElementById("public").checked == true){
c += "false" + `\r\n`;
}
else{
c += "true" + `\r\n`;
}
for(let i=1;i<w.length+1;i++){
console.log(document.getElementById(`word${i}`).value , " & " , document.getElementById(`def${i}`).value);
if(document.getElementById(`word${i}`).value == "" || document.getElementById(`def${i}`).value == ""){
console.log("empty");
}
else if(document.getElementById(`word${i}`).value.includes(";") || document.getElementById(`def${i}`).value.includes(";") || document.getElementById(`word${i}`).value.includes("\n") || document.getElementById(`def${i}`).value.includes("\n")){
console.log("special characters");
}
else{
c += document.getElementById(`word${i}`).value + "; " + document.getElementById(`def${i}`).value + `\n\r`;
}
}
TXTgenerate(c, document.getElementById("setname").value);
};
//I am citing my own code
//https://raw.githubusercontent.com/evinjaff/FESOV-randomizer/master/config-min.js
function TXTgenerate(contents, title) {
if(title == "" || title == null || title == undefined){
title = "mySet";
}
var e,
a =
((e = document.createElement("a")),
document.body.appendChild(e),
(e.style = "display: none"),
function (a, t) {
var n = a,
r = new Blob([n], { type: "octet/stream" }),
d = window.URL.createObjectURL(r);
(e.href = d), (e.download = t), e.click(), window.URL.revokeObjectURL(d);
});
console.log(contents);
(fileName = `${title}.txt`), a(contents, fileName);
}
let add = function () {
rowcount++;
let d = document.createElement("div");
d.innerHTML = `<input id="word${rowcount}" class="word" placeholder="Word ${rowcount}"></input> <input id="def${rowcount}" class="def" placeholder="Definition ${rowcount}"></input><br><br>`;
document.getElementById("content").appendChild(d);
}
document.getElementById("submit").addEventListener("click", async function () { submit() }, false);
document.getElementById("add").addEventListener("click", add, false);
</script>
</body>
</html>