From 38226b7c0bf80bbe053fd13160d6a12584d99a78 Mon Sep 17 00:00:00 2001 From: ewertmOSU Date: Wed, 16 Aug 2023 20:52:49 -0700 Subject: [PATCH] Added function headers to persona.js --- persona.js | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 86 insertions(+), 7 deletions(-) diff --git a/persona.js b/persona.js index 9838a6f..e4b2e9c 100755 --- a/persona.js +++ b/persona.js @@ -1,50 +1,100 @@ +/* + * Filename: persona.js + * Functions: dropdown, changeColor, yearinput, empinput, placeinput, paraone, + * backparaoneip, Noune, objpro, possadj, posspro, Reflexive, + * printDiv, reloadtext + * Description: Manage dropdown selections, input values, text color changes, + * printing specific sections of the page,and page reloading. + */ + +/* + * Function: dropdown + * Description: Handles the dropdown selection event and displays the corresponding section. + * Params: None + */ function dropdown(){ console.log("in function"); var e = document.getElementById("persona-name-dropdown"); - var myVal = e.options[e.selectedIndex].value; + var myVal = e.options[e.selectedIndex].value; // Get the selected value from the dropdown console.log(myVal); const personaSections = document.getElementsByClassName('persona-section'); for (const section of personaSections) { - section.style.display = 'none'; + section.style.display = 'none'; // Hide all persona sections by default } - document.getElementById(myVal).syle.display = 'block'; + document.getElementById(myVal).syle.display = 'block'; // Display the selected persona section } +/* +* Function: changeColor +* Description: Changes the text color of an element. +* Params: section - ID of the element to change color for +*/ function changeColor(section) { var elem = document.getElementById(section); elem.style.color = "#1E57C8"; } +/* +* Function: yearinput +* Description: Handles year input and displays it on the page. +* Params: None +*/ function yearinput() { var yearvalue = document.getElementById("year").value; document.getElementById("yearoutput").innerHTML = yearvalue; - changeColor("year"); + changeColor("year"); } +/* +* Function: empinput +* Description: Handles employee input and displays it on the page. +* Params: None +*/ function empinput() { var empvalue = document.getElementById("emp").value; document.getElementById("empoutput").innerHTML = empvalue; changeColor("emp"); } +/* +* Function: placeinput +* Description: Handles place input and displays it on the page. +* Params: None +*/ function placeinput() { var placevalue = document.getElementById("place").value; document.getElementById("placeoutput").innerHTML = placevalue; changeColor("place"); } +/* +* Function: paraone +* Description: Handles paragraph input and displays it on the page. +* Params: None +*/ function paraone() { var para = document.getElementById("Para1").value; document.getElementById("para1output").innerHTML = para; changeColor("Para1"); } + +/* +* Function: backparaoneip +* Description: Handles input for a background paragraph and displays it on the page. +* Params: None +*/ function backparaoneip() { var back1 = document.getElementById("backparaone").value; document.getElementById("backparaoneop").innerHTML = back1; changeColor("backparaone"); } +/* +* Function: Noune +* Description: Handles input for a noun and displays it on the page. +* Params: None +*/ function Noune() { var str = document.getElementById("Nouneip").value; var noun = str.toLowerCase(); @@ -60,13 +110,18 @@ function Noune() { } } +/* +* Function: objpro +* Description: Handles input for an object pronoun and displays it on the page. +* Params: None +*/ function objpro() { changeColor("Objpro"); var str1 = document.getElementById("Objpro").value; var obpr = str1.toLowerCase(); if (obpr == "") { //alert("Oops! did you forget to enter an Object Pronouns?"); - return false; + return false; // If the input is empty, return false to prevent further processing } const obproutputs = document.getElementsByClassName('obproutput'); for (const o of obproutputs) { @@ -74,6 +129,11 @@ function objpro() { } } +/* +* Function: possadj +* Description: Handles input for a possessive adjective and displays it on the page. +* Params: None +*/ function possadj() { changeColor("Pos.adj"); var str2 = document.getElementById("Pos.adj").value; @@ -88,6 +148,11 @@ function possadj() { } } +/* +* Function: posspro +* Description: Handles input for a possessive pronoun and displays it on the page. +* Params: None +*/ function posspro() { changeColor("Pos.pro"); var popro = document.getElementById("Pos.pro").value; @@ -99,6 +164,11 @@ function posspro() { document.getElementById("Reflexive1").innerHTML = popro; } +/* +* Function: Reflexive +* Description: Handles input for a reflexive pronoun and displays it on the page. +* Params: None +*/ function Reflexive() { changeColor("ref"); var str3 = document.getElementById("ref").value; @@ -113,6 +183,11 @@ function Reflexive() { } } +/* +* Function: printDiv +* Description: Prints a specific section of the page. +* Params: None +*/ function printDiv() { var printbody = document.getElementById("printbody"); var printbodyClone = printbody.cloneNode(true); @@ -125,7 +200,11 @@ function printDiv() { return false; } +/* +* Function: reloadtext +* Description: Reloads the page. +* Params: None +*/ function reloadtext() { location.reload(); -} - +} \ No newline at end of file