-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathquizletconvert.html
351 lines (305 loc) · 13.7 KB
/
quizletconvert.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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Converting Quizlet Study Sets on Lang</title>
<script src="code.js"></script>
<link rel="stylesheet" href="css/stylesheet.css">
<link rel="icon" href="assets/logos/circular lang icon.png">
<script src="javascript/loadBalancer.js"></script>
<script src="javascript/utils.js"></script>
<script src="javascript/LangError.js"></script>
<script src="javascript/signInChecker.js"></script>
<style>
#studysetinput {
left: 0;
transition: opacity 0.05s ease-in-out;
width: 20px;
background-color: var(--primary-light);
}
#submitbutton {
text-align: center;
transition: opacity 0.5s ease-in-out;
opacity: 0;
}
#overallContainer {
transition: all 0.5s ease-in;
overflow: hidden;
flex-direction: column;
display: flex;
height: 100vh;
width: 100vw;
align-items: center;
justify-content: center;
}
body {
transition: all 0.5s ease-in;
background-color: var(--primary-dark);
}
/* https://cssloaders.github.io */
.lds-ellipsis {
/* transition: opacity 0.5s ease-in-out; */
opacity: 0;
display: inline-block;
position: relative;
width: 80px;
height: 80px;
}
.lds-ellipsis div {
position: absolute;
top: 33px;
width: 13px;
height: 13px;
border-radius: 50%;
background: var(--primary-light);
animation-timing-function: cubic-bezier(0, 1, 1, 0);
}
.lds-ellipsis div:nth-child(1) {
left: 8px;
animation: lds-ellipsis1 0.6s infinite;
}
.lds-ellipsis div:nth-child(2) {
left: 8px;
animation: lds-ellipsis2 0.6s infinite;
}
.lds-ellipsis div:nth-child(3) {
left: 32px;
animation: lds-ellipsis2 0.6s infinite;
}
.lds-ellipsis div:nth-child(4) {
left: 56px;
animation: lds-ellipsis3 0.6s infinite;
}
@keyframes lds-ellipsis1 {
0% {
transform: scale(0);
}
100% {
transform: scale(1);
}
}
@keyframes lds-ellipsis3 {
0% {
transform: scale(1);
}
100% {
transform: scale(0);
}
}
@keyframes lds-ellipsis2 {
0% {
transform: translate(0, 0);
}
100% {
transform: translate(24px, 0);
}
}
</style>
</head>
<!-- <body onload="window.location.href='other/featuredown.html'"> -->
<body>
<div id="overallContainer" >
<a href="homepage.html">
<svg style="height: 5vw; width: 5vw; position: absolute; top: 20px; left: 20px; display:inline-block; fill: var(--primary-light); " enable-background="new 0 0 26.676 26.676" version="1.1" viewBox="0 0 26.676 26.676" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><path d="m26.105 21.891c-0.229 0-0.439-0.131-0.529-0.346-0.066-0.156-1.716-3.857-7.885-4.59-1.285-0.156-2.824-0.236-4.693-0.25v4.613c0 0.213-0.115 0.406-0.304 0.508-0.188 0.098-0.413 0.084-0.588-0.033l-11.852-7.978c-0.16-0.107-0.254-0.287-0.254-0.476 0-0.191 0.094-0.365 0.254-0.477l11.857-7.979c0.175-0.121 0.398-0.129 0.588-0.029 0.19 0.102 0.303 0.295 0.303 0.502v4.293c2.578 0.336 13.674 2.33 13.674 11.674 0 0.271-0.191 0.508-0.459 0.562-0.037 6e-3 -0.076 6e-3 -0.112 6e-3z"/></svg>
</a>
<div id="horizontalContainer;" class="horizontalFlex" style="width: 100vw; justify-content: center; align-items: center;">
<div id="text" class="headerText"></div>
<input id="studysetinput" type="text" style="height: 50px;"">
</div>
<div id="submitbutton" class="button" style="background-color: var(--primary-light);">
Continue
</div>
</div>
<div id="popup" class="popupContainer" style="z-index:2000;">
<div class="popup centerFlex verticalFlex">
<div style="margin: 50px;">
<img style="height:10vh;" src="assets/icons/langerror.png" alt="error">
</div>
<div style="margin-bottom: 30px;" id="popupText">Quizlet Convert had an error.</div>
<div class="button buttonHoverDark horizontalFlex centerFlex" style="width: 25%;" onclick="window.location.href='../homepage.html'">Ok</div>
</div>
</div>
<div style="position:absolute; bottom:0; right:0; margin:20px; display:flex; cursor:pointer;" id="storeLink" onclick="window.location.href='https://chromewebstore.google.com/detail/quizlet-to-langstudy/ckmfofefmcaieajjkelnakglpkkmeomd'">
<p style="color:white; font-weight:bold; margin-right:10px;">Get the Quizlet Convert Extension for Google Chrome!</p>
<img src="assets/icons/chromewebstore.svg" style="height:50px;">
</div>
<!-- <div id="header0" class="absolute" style="width: 100vw">
<div class="horizontalFlex header">
<div onclick="returnMain()" style="cursor:pointer;">
<img style="height: 10vh;" src="assets/logos/lang.png">
</div>
<div class="flexSpacer"></div>
<div style="font-family: 'Rubik Mono One', sans-serif; font-size:2vw;">Study Sheet Creator</div>
<div class="flexSpacer"></div>
<div id="homeusername">Getting your userinfo...</div>
<div>
<img class="pfp" style="height: 5vh;" src="newsettings.svg" onclick="window.location.href='settings.html'">
</div>
</div>
</div> -->
</body>
<script>
function grabQuizlet(link) {
if (window.localStorage.getItem("usertoken") == "" || window.localStorage.getItem("usertoken") == null || window.localStorage.getItem("usertoken") == "signedout"){
console.log("Attempting to show blocker.")
showBlocker("To create and upload your own Studysheets, use AI assistance, and connect to Quizlet, please create a Lang account.")
return;
}
console.log("link+ "+link)
var url = "https://backend.langstudy.tech/v2/quizlet";
var xhr = new XMLHttpRequest();
xhr.open("POST", url);
xhr.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
xhr.setRequestHeader("lye-session", window.localStorage.getItem('usertoken'));
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
console.log(xhr.status);
console.log(xhr.responseText);
var newStudysheet = xhr.responseText;
readableSS = JSON.parse(newStudysheet)
if (typeof readableSS.error !== 'undefined'){
if (readableSS.error == "unknown_quizlet_error") {
showPopup("We ran into an unexpected issue with Quizlet. Here's what Quizlet said when we tried to read your Quizlet Study Set: "+readableSS.quizlet_error+" If this converter still does not work, you can use the <a href=\"https://chromewebstore.google.com/detail/quizlet-to-langstudy/ckmfofefmcaieajjkelnakglpkkmeomd\">Chrome Extension (Only for Google Chrome Users)</a>.")
e = new LangError("Unexpected Quizlet Issue: "+readableSS.quizlet_error, "quizletconvert", "unknown", "unknown", "We ran into an unexpected issue with Quizlet. Here's what Quizlet said when we tried to read your Studysheet: "+readableSS.quizlet_error, false)
}
else {
showPopup("We couldn't get your Quizlet Study Set because it's marked as private on Quizlet. To bypass this, try our <a href=\"https://chromewebstore.google.com/detail/quizlet-to-langstudy/ckmfofefmcaieajjkelnakglpkkmeomd\">Chrome Extension</a>.")
}
}
else if (readableSS.length == 0){
showPopup("We ran into an unexpected issue with Quizlet. To convert this set, you may need to use the more reliable and faster <a href=\"https://chromewebstore.google.com/detail/quizlet-to-langstudy/ckmfofefmcaieajjkelnakglpkkmeomd\">Chrome Extension (Only for Google Chrome Users)</a>.")
e = new LangError("Unexpected Quizlet Issue: "+readableSS.quizlet_error, "quizletconvert", "unknown", "unknown", "We ran into an unexpected issue with Quizlet. Here's what Quizlet said when we tried to read your Studysheet: "+readableSS.quizlet_error, false)
}
else {
window.localStorage.setItem("fullstudysheet", newStudysheet);
window.location.href="creator.html";
}
}
};
var data = link;
console.log("sending " + data + " to " + url);
xhr.send(data);
}
function animation_part_one() {
var element = document.getElementById("text")
var cursor = document.getElementById("studysetinput")
cursor.style.position = "absolute"
var text = "Just enter your studyset link"
var i = 0;
// set tex
var interval = setInterval(function() {
// get the position of the text
var pos = element.getBoundingClientRect()
var x = pos.x
var rightEdge = x + element.offsetWidth
cursor.style.left = (rightEdge + 50) + "px"
element.innerHTML = text.substring(0, i);
i++;
if (i > text.length) {
clearInterval(interval);
setTimeout(function() {
animation_part_two()
}, 1500);
}
}, 50);
}
function animation_part_two() {
var element = document.getElementById("text")
var cursor = document.getElementById("studysetinput")
var text = "Just enter your studyset "
element.innerHTML = text + "link";
var interval = setInterval(function() {
var pos = element.getBoundingClientRect()
var x = pos.x
var rightEdge = x + element.offsetWidth
cursor.style.left = (rightEdge - 200) + "px"
text = text.substring(0, text.length - 1);
element.innerHTML = text + "link"
if (text == "") {
clearInterval(interval);
cursor.style.position = "relative"
cursor.style.left = "0"
element.innerHTML = "link:"
setTimeout(function() {
animation_part_three()
}, 500);
// setTimeout(function() {
// animation_part_three()
// }, 1000);
}
}, 50);
}
function animation_part_three() {
var element = document.getElementById("text")
var cursor = document.getElementById("studysetinput")
shouldBlinkCursor = false;
cursor.style.opacity = "1"
cursor.style.transition = "all 1s ease-in-out"
cursor.style.width = "50%"
setTimeout(function() {
var button = document.getElementById("submitbutton")
button.style.opacity = "1"
button.addEventListener("click", function() {
get_studysheet()
})
document.addEventListener("keydown", function(e) {
if (e.key == "Enter") {
get_studysheet()
}
})
}, 500);
}
var shouldBlinkCursor = true;
function blink_cursor() {
var cursor = document.getElementById("studysetinput")
var on = false;
var interval = setInterval(function() {
if (!shouldBlinkCursor) {
clearInterval(interval);
return;
}
if (on) {
cursor.style.opacity = 0;
} else {
cursor.style.opacity = 1;
}
on = !on;
}, 200);
}
blink_cursor()
setTimeout(function() {
animation_part_one()
}, 1000);
function get_studysheet() {
var container = document.getElementById("overallContainer")
// container.style.transition = "width 0.5s ease-in-out"
container.style.width = "0";
container.style.opacity = "0";
document.body.style.backgroundColor = "black"
setTimeout(function() {
container.innerHTML = ""
container.style.transition = "opacity 1s ease-in-out"
container.style.width = "100vw"
container.style.opacity = "1"
container.innerHTML = '<div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div>'
container.children[0].classList.add("fadeIn")
}, 500);
setTimeout(function() {
finished()
}, 3000);
link = document.getElementById("studysetinput").value;
console.log("link = "+link)
grabQuizlet(link)
}
function finished() {
var container = document.getElementById("overallContainer")
container.style.opacity = "0"
setTimeout(function() {
container.innerHTML = '<div class="headerText" style="font-size:30px;">Lang is retrieving your Quizlet.</div><br><div style="color:wheat; font-weight:bold; font-size:25px;">Thank you for your patience- the trip to the Quizlet servers is a long one.</div>'
container.style.opacity = "1"
}, 1000);
document.body.style.backgroundColor = "var(--primary-dark)"
}
</script>
</html>