Commit c7c65071 authored by 0xJMR's avatar 0xJMR
Browse files

Added functionality to change mode.

parent 0d025439
Pipeline #62363 passed with stages
in 2 minutes and 3 seconds
......@@ -180,11 +180,52 @@
<script>
var radios = document.querySelectorAll("input[name='View']");
var card = document.querySelector(".card");
var front = document.querySelectorAll(".card-face-front tr");
var back = document.querySelectorAll(".card-face-back tr");
function clickButton(index) {
radios[index].click();
}
function selectRange(start, end) {
for(var i = start - 1; i < (end || start); i++) {
front[i].classList.add("marked");
back[i].classList.add("marked");
}
}
function scroll(index, start) {
start = start - 1;
window.scrollTo(0, index === 0 ? front[start].offsetTop : back[start].offsetTop);
}
function onChange(event) {
card.classList.toggle("flipped");
}
function onHashChange() {
window.setTimeout(function() {
var hash = window.location.hash;
var parts = hash.substring(1).split(':');
var index = parts[0];
var start = parts[1];
var end = parts[2];
if(index) {
clickButton(index);
if(start) {
scroll(index, start);
selectRange(start, end);
}
}
}, 0);
}
radios.forEach(function(element) { element.addEventListener("change", onChange) });
onHashChange();
window.addEventListener("hashchange", onHashChange);
</script>
</html>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment