Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 86 additions & 7 deletions persona.js
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -60,20 +110,30 @@ 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) {
o.innerHTML = obpr;
}
}

/*
* 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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -125,7 +200,11 @@ function printDiv() {
return false;
}

/*
* Function: reloadtext
* Description: Reloads the page.
* Params: None
*/
function reloadtext() {
location.reload();
}

}