-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
215 lines (181 loc) · 7.35 KB
/
index.html
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<!doctype html>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Primary Meta Tags -->
<meta name="description" content="a framework for clustering research notes">
<meta name="title" content="Xzerpt">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://xzerpt.com">
<meta property="og:title" content="Xzerpt">
<meta property="og:description" content="a framework for clustering research notes">
<meta property="og:image" content="https://xzerpt.com/exampleImages/xzerpt.png">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://xzerpt.com">
<meta property="twitter:title" content="Xzerpt">
<meta property="twitter:description" content="a framework for clustering research notes">
<meta property="twitter:image" content="https://xzerpt.com/exampleImages/xzerpt.png">
<head>
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<title>Xzerpt</title>
<style>
*{
font-family: "Trebuchet MS";
}
input[type=button], input[type=submit], input[type=reset] {
background-color: #4CAF50;
border: none;
color: white;
padding: 16px 32px;
text-decoration: none;
margin: 4px 2px;
cursor: pointer;
}
button[type=button] {
background-color: #3a42b1;
border: none;
color: white;
padding: 16px 32px;
text-decoration: none;
margin: 4px 2px;
cursor: pointer;
}
button[id=csv_button] {
background-color: #6b0f86;
border: none;
color: white;
padding: 16px 32px;
text-decoration: none;
margin: 4px 2px;
cursor: pointer;
}
</style>
</head>
<html>
<body>
<h1 style = "text-align: left;">Xzerpt: a framework for clustering research notes</h1>
<h3>Find out more on <a href="https://github.com/BrianInGermany/Xzerpt">Github</a></h3>
<form action="" id="form" method="POST">
<p><b>Type</b></p>
<input type="radio" id="paraphrase" name="info_type" value="paraphrase">
<label for="paraphrase">paraphrase</label><br>
<input type="radio" id="quote" name="info_type" value="quote">
<label for="css">quote</label><br>
<input type="radio" id="own_opinion" name="info_type" value="own opinion">
<label for="javascript">own opinion</label>
<br/>
<label for="source"><b>Source</b></label><br/>
<input type="text" id="source" name="source">
<br/>
<label for="page"><b>Page</b></label><br/>
<input type="text" id="page" name="page">
<br/>
<label for="topic"><b>Topic</b></label><br>
<textarea class="input" id="topic" name="topic" rows="2" cols="80">
</textarea>
<br/>
<label for="summary"><b>Statement</b></label><br>
<textarea class="input" id="summary" name="summary" rows="10" cols="80">
</textarea>
<br/>
<input type="submit" value="Cache Card"><div id="card_count"></div>
</form>
<button type="button" onclick="create_dl_csv()">Download CSV and Clear Cache</button>
<br/>
<button type="button" id="csv_button" onclick="window.location.href = 'csv_input.html';">Create Cards from CSV</button>
<p>By <a href="https://thejunkyard.cc">Brian Junker-Latocha</a>.</p>
<a href="https://www.buymeacoffee.com/RulTsMIXi"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=☕&slug=RulTsMIXi&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000&coffee_colour=ffffff"></a>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
var form = document.getElementById('form');
function create_dl_csv(){
const form_dict_list = JSON.parse(localStorage.getItem('form_list'))
var rows = new Array()
let csvContent = "data:text/csv;charset=utf-8,";
for (formular of form_dict_list){
// console.log("this is type of formular")
// console.log(typeof formular)
// var formular_row = new Array()
var fields = new Array();
for (let i = 0; i < 5; i++){
fields.push("");}
console.log("This is formular");
console.log(formular);
for (field of formular){
// console.log("this is type of field");
// console.log(typeof field);
if (field["name"] == "info_type"){
fields[0] = field["value"];
}
else if (field["name"] == "source"){
fields[1] = field["value"];
}
else if (field["name"] == "page"){
fields[2] = field["value"];
}
else if (field["name"] == "topic"){
fields[3] = field["value"];
if (fields[3].includes("\r\n")){
console.log("Found r and n in topic");
fields[3] = fields[3].replace(/\r\n/g, " ")
}
}
else if (field["name"] == "summary"){
fields[4] = field["value"];
if (fields[4].includes("\r\n")){
console.log("Found r and n in statement");
fields[4] = fields[4].replace(/\r\n/g, " ")
}
}
}
// formular_row.push(fields)
// console.log(fields);
// rows.push(fields)
row_string = fields.join("|");
csvContent += row_string + "\r\n";
}
// console.log("Here is ROWS")
// console.log(rows)
// rows = JSON.parse(rows);
// rows.forEach(function(rowArray) {
// let row = rowArray.join("§");
// csvContent += row + "\r\n";
// });
var encodedUri = encodeURI(csvContent);
window.open(encodedUri);
localStorage.clear();
document.getElementById("card_count").innerHTML = "0 Cards in Cache"
}
function appendToStorage(name, data){
var old_list;
if (localStorage.getItem(name) === null){
old_list = new Array();
}
else {old_list = JSON.parse(localStorage.getItem(name));}
old_list.push(data);
localStorage.setItem(name, JSON.stringify(old_list));
}
function logSubmit(event) {
appendToStorage('form_list', $("form").serializeArray());
if (localStorage.getItem("card_count") === null){
localStorage.setItem("card_count", 0)
}
card_count = parseInt(localStorage.getItem("card_count")) + 1
localStorage.setItem("card_count", card_count)
document.getElementById("card_count").innerHTML = card_count + " Cards in Cache";
event.preventDefault();
console.log(`Form Submitted! Time stamp: ${event.timeStamp}`);
document.getElementById('form').reset();
console.log($('form').serializeArray());
console.log(localStorage.getItem('form_list'));
}
// const log = document.getElementById('log');
form.addEventListener('submit', logSubmit);
</script>
</html>