From 5159803fc5263007572a6972ab9d42429a178e58 Mon Sep 17 00:00:00 2001 From: "Eugeniy E. Mikhailov" Date: Wed, 12 Feb 2020 16:34:10 -0500 Subject: javascript for hiding controls --- GradeBook.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'GradeBook.js') diff --git a/GradeBook.js b/GradeBook.js index 18652c8..4878060 100644 --- a/GradeBook.js +++ b/GradeBook.js @@ -1,10 +1,10 @@ -function toggleHTMLClassVisibility(className) { +function toggleHTMLClassVisibility(className, defaultVisibleStyle) { var x = document.getElementsByClassName(className); var i; - var display_style = "block"; // default + var display_style = defaultVisibleStyle; // default for (i = 0; i < x.length; i++) { if (x[i].style.display === "none") { - display_style = "block"; + display_style = defaultVisibleStyle; } else { display_style = "none"; } @@ -16,7 +16,7 @@ function toggleHTMLClassVisibility(className) { function setHTMLClassVisibility(className, display_style) { // use "block" or "none" for display_style if (display_style === "") { - display_style = "block"; // default + display_style = ""; // default } var x = document.getElementsByClassName(className); var i; @@ -28,11 +28,15 @@ function setHTMLClassVisibility(className, display_style) { function toggleHistogramMarker() { - toggleHTMLClassVisibility("histogram_marker"); + toggleHTMLClassVisibility("histogram_marker", "block"); }; function toggleGradingScheme() { - toggleHTMLClassVisibility("grading_scheme"); + toggleHTMLClassVisibility("grading_scheme", "block"); +}; + +function toggleControls() { + toggleHTMLClassVisibility("controls", ""); }; // getCookie is copied from https://www.w3schools.com/js/js_cookies.asp @@ -60,6 +64,7 @@ function readAndSetVisibility(className) { function onPageLoad() { readAndSetVisibility("histogram_marker"); readAndSetVisibility("grading_scheme"); + readAndSetVisibility("controls"); return ""; } -- cgit v1.2.3