-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
521b362
commit a6180c9
Showing
7 changed files
with
239 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" class="notranslate" translate="no"> | ||
<head> | ||
<link rel="stylesheet" href="../../../styles/fonts.css" /> | ||
<link rel="stylesheet" href="../../../styles/main.css" /> | ||
<link rel="stylesheet" href="../../../styles/folders.css" /> | ||
<title>Custom Set | Vocabulary Testing Program 6</title> | ||
<link rel="icon" type="image/png" href="../../../logos/logo-square.png"/> | ||
<meta property="og:image" content="../../../logos/logo-banner.png" /> | ||
<meta property="og:image:width" content="1980" /> | ||
<meta property="og:image:height" content="1741" /> | ||
<meta http-equiv="content-type" content="text/html; charset=utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta property="description" content="Study Custom Set on Vocabulary Testing Program 6." /> | ||
</head> | ||
<body> | ||
<div id="header"></div> | ||
<div id="content"> | ||
<div id="settings-bar" hidden> | ||
<!-- <span id="before-slider">Classic</span> | ||
<label class="switch" id="switch-slider"> | ||
<input type="checkbox" id="gamemode-checkbox"> | ||
<span class="slider"></span> | ||
</label> | ||
<span id="after-slider" class="not-selected">Match</span> --> | ||
<select id="gamemode-selector"></select> | ||
<button class="start-button" id="start-button" role="button">Start!</button> | ||
<span id="high-score"> | ||
<img class="high-score-image" /> | ||
<span id="high-score-text"></span> | ||
</span> | ||
<p id="help-tip"></p> | ||
</div> | ||
<div class="flex-container" id="units-flex"></div> | ||
<div id="custom-upload-box"> | ||
<div id="file-input"> | ||
<input type="file" id="input-upload" name="input-upload" accept=".txt, .csv" multiple="multiple"> | ||
<label for="input-upload" id="upload-button">Choose files</label> | ||
<p id="file-upload-text"><i>No files selected</i></p> | ||
</div> | ||
<button class="start-button" id="upload-go-button" role="button" disabled="true">Go!</button> | ||
</div> | ||
<div id="margin"></div> | ||
</div> | ||
<div id="footer"></div> | ||
<script> | ||
const OPTIONS = {lang: "cs", id: "csupload", name: "Custom Set Upload", all: false}; | ||
</script> | ||
<script src="../../../scripts/lightdark.js"></script> | ||
<script src="../../../scripts/header.js"></script> | ||
<script src="../../../scripts/cookies.js"></script> | ||
<script src="../../../scripts/footer.js"></script> | ||
<script src="../../../scripts/misc.js"></script> | ||
<script src="../../../scripts/folders-setup.js"></script> | ||
<script src="../../../scripts/folders-misc.js"></script> | ||
<script src="../../../scripts/folders-classic.js"></script> | ||
<script src="../../../scripts/folders-match.js"></script> | ||
<script src="../../../scripts/folders-start.js"></script> | ||
<script src="../../../scripts/folders-custom.js"></script> | ||
<script async data-id="101454906" src="//static.getclicky.com/js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const upload = document.getElementById("input-upload"); | ||
const file_text = document.getElementById("file-upload-text"); | ||
const upload_go = document.getElementById("upload-go-button"); | ||
|
||
let terms = []; | ||
|
||
function read_vtp6_format(text) { | ||
let lines = text.split("\n"); | ||
lines.forEach(line => { | ||
let spl = line.split("\t"); | ||
if (spl.length == 2) { | ||
terms.push(spl); | ||
} else { | ||
console.error("Invalid line: " + line); | ||
} | ||
}); | ||
} | ||
|
||
upload.addEventListener("input", () => { | ||
let n = upload.files.length | ||
if (n == 0) { | ||
file_text.innerHTML = `<i>No files selected</i>`; | ||
upload_go.disabled = true; | ||
} else if (n == 1) { | ||
file_text.innerHTML = `<i>1 file selected</i>`; | ||
upload_go.disabled = false; | ||
} else { | ||
file_text.innerHTML = `<i>${n} files selected</i>`; | ||
upload_go.disabled = false; | ||
} | ||
}); | ||
|
||
upload_go.addEventListener("click", () => { | ||
files = [...upload.files]; | ||
files.forEach(file => { | ||
if (file) { | ||
let reader = new FileReader(); | ||
reader.addEventListener("load", () => { | ||
read_vtp6_format(reader.result) | ||
}, false); | ||
reader.readAsText(file); | ||
} | ||
}); | ||
document.getElementById("custom-upload-box").hidden = true; | ||
document.getElementById("settings-bar").hidden = false; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,37 @@ | ||
let units = TERMS_LIST.split("\n\n"); | ||
if (OPTIONS["lang"] !== "cs") { | ||
let units = TERMS_LIST.split("\n\n"); | ||
|
||
const uflex = document.getElementById("units-flex"); | ||
const uflex = document.getElementById("units-flex"); | ||
|
||
let total = 0; | ||
let total = 0; | ||
|
||
units = units.map((unit, uindex) => { | ||
let [unit_header, ...urest] = unit.split("\n"); | ||
if (!assert(unit_header.startsWith("# "), | ||
"Header " + uindex + " not in proper format.")) return; | ||
unit_name = unit_header.slice(2); | ||
unit_varname = unit_name.toLowerCase().replaceAll(" ", ""); | ||
let unit_terms = urest.map((uline, ulindex) => { | ||
let uret = uline.split("\t"); | ||
if (assert(uret.length === 2, | ||
"Line not in proper format in " + | ||
unit_name + " (line " + ulindex + ").") | ||
) return uret; | ||
}).filter(l => l !== undefined); | ||
let uflexbox = document.createElement("div"); | ||
uflexbox.classList.add("units-flexbox"); | ||
uflexbox.setAttribute("name", unit_varname); | ||
uflexbox.innerHTML = ` | ||
<input type="checkbox" class="folders-checkbox" /> | ||
<span class="checkbox-label">${unit_name} <i>(${unit_terms.length})</i></span>`; | ||
uflex.appendChild(uflexbox); | ||
total += unit_terms.length; | ||
return [[unit_name, unit_varname], unit_terms]; | ||
}); | ||
units = units.map((unit, uindex) => { | ||
let [unit_header, ...urest] = unit.split("\n"); | ||
if (!assert(unit_header.startsWith("# "), | ||
"Header " + uindex + " not in proper format.")) return; | ||
unit_name = unit_header.slice(2); | ||
unit_varname = unit_name.toLowerCase().replaceAll(" ", ""); | ||
let unit_terms = urest.map((uline, ulindex) => { | ||
let uret = uline.split("\t"); | ||
if (assert(uret.length === 2, | ||
"Line not in proper format in " + | ||
unit_name + " (line " + ulindex + ").") | ||
) return uret; | ||
}).filter(l => l !== undefined); | ||
let uflexbox = document.createElement("div"); | ||
uflexbox.classList.add("units-flexbox"); | ||
uflexbox.setAttribute("name", unit_varname); | ||
uflexbox.innerHTML = ` | ||
<input type="checkbox" class="folders-checkbox" /> | ||
<span class="checkbox-label">${unit_name} <i>(${unit_terms.length})</i></span>`; | ||
uflex.appendChild(uflexbox); | ||
total += unit_terms.length; | ||
return [[unit_name, unit_varname], unit_terms]; | ||
}); | ||
|
||
assert(is_unique(units.map(l => l[0][1])), "Headers are not unique."); | ||
assert(is_unique(units.map(l => l[0][1])), "Headers are not unique."); | ||
|
||
assert(units.length == NUM_UNITS, "Expected " + NUM_UNITS + " units, got " + units.length + "."); | ||
assert(units.length == NUM_UNITS, "Expected " + NUM_UNITS + " units, got " + units.length + "."); | ||
|
||
document.getElementById("insert-length-here").innerHTML = "(" + total + " terms)"; | ||
document.getElementById("insert-length-here").innerHTML = "(" + total + " terms)"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters