Skip to content

Commit

Permalink
show or hide pinyin or zhuyin when multiple exists
Browse files Browse the repository at this point in the history
  • Loading branch information
krmanik committed Oct 2, 2022
1 parent bc96dc0 commit 5f7bd9a
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 26 deletions.
24 changes: 18 additions & 6 deletions card templates/Card 1/back.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
document.getElementById(_id).checked = false;
document.getElementById(divId).style.display = "none";
if (_id == "text-pinyin") {
document.querySelector(".pinyin").style.display = "none";
showHide(".pinyin", false);
}
if (_id == "text-zhuyin") {
document.querySelectorAll(".zhuyin")[1].style.display = "none";
showHide(".zhuyin", false);
}
} else {
document.getElementById(_id).checked = true;
Expand All @@ -70,21 +70,33 @@
}
if (e.id == "text-pinyin") {
if (e.checked) {
document.querySelector(".pinyin").style.display = "inline";
showHide(".pinyin", true);
} else {
document.querySelector(".pinyin").style.display = "none";
showHide(".pinyin", false);
}
}

if (e.id == "text-zhuyin") {
if (e.checked) {
document.querySelectorAll(".zhuyin")[1].style.display = "inline";
showHide(".zhuyin", true);
} else {
document.querySelectorAll(".zhuyin")[1].style.display = "none";
showHide(".zhuyin", false);
}
}
}

function showHide(type, isShow) {
if (isShow) {
document.querySelectorAll(type).forEach(function (val) {
val.style.display = 'inline';
});
} else {
document.querySelectorAll(type).forEach(function (val) {
val.style.display = 'none';
});
}
}

function openSidebar(id) {
var width = id == "sidebar" ? "250px" : "160px";
document.getElementById(id).style.width = width;
Expand Down
24 changes: 18 additions & 6 deletions card templates/Card 2/back.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
document.getElementById(_id).checked = false;
document.getElementById(divId).style.display = "none";
if (_id == "text-pinyin") {
document.querySelector(".pinyin").style.display = "none";
showHide(".pinyin", false);
}
if (_id == "text-zhuyin") {
document.querySelectorAll(".zhuyin")[1].style.display = "none";
showHide(".zhuyin", false);
}
} else {
document.getElementById(_id).checked = true;
Expand All @@ -70,21 +70,33 @@
}
if (e.id == "text-pinyin") {
if (e.checked) {
document.querySelector(".pinyin").style.display = "inline";
showHide(".pinyin", true);
} else {
document.querySelector(".pinyin").style.display = "none";
showHide(".pinyin", false);
}
}

if (e.id == "text-zhuyin") {
if (e.checked) {
document.querySelectorAll(".zhuyin")[1].style.display = "inline";
showHide(".zhuyin", true);
} else {
document.querySelectorAll(".zhuyin")[1].style.display = "none";
showHide(".zhuyin", false);
}
}
}

function showHide(type, isShow) {
if (isShow) {
document.querySelectorAll(type).forEach(function (val) {
val.style.display = 'inline';
});
} else {
document.querySelectorAll(type).forEach(function (val) {
val.style.display = 'none';
});
}
}

function openSidebar(id) {
var width = id == "sidebar" ? "250px" : "160px";
document.getElementById(id).style.width = width;
Expand Down
24 changes: 18 additions & 6 deletions card templates/Card 3/back.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
document.getElementById(_id).checked = false;
document.getElementById(divId).style.display = "none";
if (_id == "text-pinyin") {
document.querySelector(".pinyin").style.display = "none";
showHide(".pinyin", false);
}
if (_id == "text-zhuyin") {
document.querySelectorAll(".zhuyin")[1].style.display = "none";
showHide(".zhuyin", false);
}
} else {
document.getElementById(_id).checked = true;
Expand All @@ -70,21 +70,33 @@
}
if (e.id == "text-pinyin") {
if (e.checked) {
document.querySelector(".pinyin").style.display = "inline";
showHide(".pinyin", true);
} else {
document.querySelector(".pinyin").style.display = "none";
showHide(".pinyin", false);
}
}

if (e.id == "text-zhuyin") {
if (e.checked) {
document.querySelectorAll(".zhuyin")[1].style.display = "inline";
showHide(".zhuyin", true);
} else {
document.querySelectorAll(".zhuyin")[1].style.display = "none";
showHide(".zhuyin", false);
}
}
}

function showHide(type, isShow) {
if (isShow) {
document.querySelectorAll(type).forEach(function (val) {
val.style.display = 'inline';
});
} else {
document.querySelectorAll(type).forEach(function (val) {
val.style.display = 'none';
});
}
}

function openSidebar(id) {
var width = id == "sidebar" ? "250px" : "160px";
document.getElementById(id).style.width = width;
Expand Down
24 changes: 18 additions & 6 deletions card templates/Card 4/back.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
document.getElementById(_id).checked = false;
document.getElementById(divId).style.display = "none";
if (_id == "text-pinyin") {
document.querySelector(".pinyin").style.display = "none";
showHide(".pinyin", false);
}
if (_id == "text-zhuyin") {
document.querySelectorAll(".zhuyin")[1].style.display = "none";
showHide(".zhuyin", false);
}
} else {
document.getElementById(_id).checked = true;
Expand All @@ -70,21 +70,33 @@
}
if (e.id == "text-pinyin") {
if (e.checked) {
document.querySelector(".pinyin").style.display = "inline";
showHide(".pinyin", true);
} else {
document.querySelector(".pinyin").style.display = "none";
showHide(".pinyin", false);
}
}

if (e.id == "text-zhuyin") {
if (e.checked) {
document.querySelectorAll(".zhuyin")[1].style.display = "inline";
showHide(".zhuyin", true);
} else {
document.querySelectorAll(".zhuyin")[1].style.display = "none";
showHide(".zhuyin", false);
}
}
}

function showHide(type, isShow) {
if (isShow) {
document.querySelectorAll(type).forEach(function (val) {
val.style.display = 'inline';
});
} else {
document.querySelectorAll(type).forEach(function (val) {
val.style.display = 'none';
});
}
}

function openSidebar(id) {
var width = id == "sidebar" ? "250px" : "160px";
document.getElementById(id).style.width = width;
Expand Down
29 changes: 27 additions & 2 deletions card templates/Card 5/front.html
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ <h3>xie hanzi</h3>
continue;
}
if (_id == "text-pinyin") {
document.querySelector(".pinyin").style.display = "none";
showHide(".pinyin", false);
}
if (_id == "text-zhuyin") {
document.querySelectorAll(".zhuyin")[1].style.display = "none";
showHide(".zhuyin", false);
}
document.getElementById(divId).style.display = "none";
} else {
Expand Down Expand Up @@ -292,8 +292,21 @@ <h3>xie hanzi</h3>

if (e.checked) {
document.getElementById(divId).style.display = "block";
if (e.id == "text-pinyin") {
showHide(".pinyin", true);
}
if (e.id == "text-zhuyin") {
showHide(".zhuyin", true);
}
} else {
document.getElementById(divId).style.display = "none";

if (e.id == "text-pinyin") {
showHide(".pinyin", false);
}
if (e.id == "text-zhuyin") {
showHide(".zhuyin", false);
}
}
}

Expand All @@ -304,6 +317,18 @@ <h3>xie hanzi</h3>
}
}

function showHide(type, isShow) {
if (isShow) {
document.querySelectorAll(type).forEach(function (val) {
val.style.display = 'inline';
});
} else {
document.querySelectorAll(type).forEach(function (val) {
val.style.display = 'none';
});
}
}

function openSidebar(id) {
var width = id == "sidebar" ? "250px" : "160px";
document.getElementById(id).style.width = width;
Expand Down

0 comments on commit 5f7bd9a

Please sign in to comment.