Between the code there is questions for each fuction please help ASAP :) Get all
ID: 3577568 • Letter: B
Question
Between the code there is questions for each fuction please help ASAP :)
Get all functions to work, similar to the customer GUI code we received. Save as YourFirstNameYourLastNameMIS3023Final.html and email to Professor by 11:25 am Hover mouse over the two textareas and the Delete Email field to see what is required on each one New Employee information 10 points E-Ma nedoalhosani@gmail.com Name www Address: wee33 Salary: 2323 Add New Display All Existing Employees 5 points Display Employees Emp Bill Delete An Employee 10 pointsExplanation / Answer
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
Remove this if you use the .htaccess -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>Final MIS3023</title>
<meta name="description" content="" />
<meta name="author" content="akhilesh-bajaj" />
<meta name="viewport" content="width=device-width; initial-scale=1.0" />
<!-- Replace favicon.ico & apple-touch-icon.png in the root of your domain and delete these references -->
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<script language = "javascript"></script>
<style>
article, aside, figure, footer, header, main, nav, section {
display: block;
}
body {
font-family: Arial, Helvetica, sans-serif;
background-color: white;
margin: 0 auto;
width: 800px;
border: 3px solid blue;
}
main {
padding: 0 2em 1em;
}
h1 {
color: blue;
}
label {
float: left;
width: 11em;
text-align: right;
padding-bottom: .5em;
}
input {
margin-left: 1em;
margin-bottom: .5em;
}
textarea {
background-color: #eee;
width: 500px;
height:70px;
}
fieldset{
width:500px;
margin-top: 1em;
}
input:{
border:2px solid black;
}
</style>
</head>
<body>
<script>
"use strict";
var $ = function(id) {
return document.getElementById(id);
};
function initEmps(){
//alert("In init Emps")
//add dummy employees to array, after asking user for initial size
var text = prompt("Please enter initial size of arrsy", "");
var size=0;
if (text != null) {
size=parseInt(text);
}
var emps_array = new Array(size);
//emps_array[0]="Bill";//this line needs to be commented out
return emps_array;
}
function printEmps(emps_par){
//alert("in printEmps");
var printStr = "";
for(var i=0;i<emps_par.length;i++){
if(emps_par[i]){
printStr+="Emp "+(i+1)+" :Name:"+emps_par[i].name+",Email:"+emps_par[i].email+",Address:"+emps_par[i].address+", Salary : "+emps_par[i].salary+" ";
}
}
//set printStr = all the employees info so it prints out all employees
$("all_emp").value = printStr;
return;
}
function addEmp(emps_par){
//alert ("in add emp");
//add an employee in an empty slot, or if all slots are full, then at the end of the array
var employee={};
employee.name=$("name1").value;
employee.email=$("email").value;
employee.address=$("address").value;
employee.salary=$("salary").value;
var slotAvailable=false;
for(var i=0;i<emps_par.length;i++){
if (!(i in emps_par)) { //check the empty slot
emps_par[i]=employee;
slotAvailable=true;
break;
}
}
if(!slotAvailable){ //if slot not available push at the end of array
emps_par.push(employee);
}
printEmps(emps_par);
return emps_par;
}
function delEmp(emps_par){
//alert ("in del emp");
//ask for email then check if email found. IF found, delete and create empty slot
//if not found alert that employee was not found and clear the delete email field.
var email=$("emailToDel").value;
var isFound=false;
for(var i=0;i<emps_par.length;i++){
if(emps_par[i]){
if(email.toLowerCase()==emps_par[i].email.toLowerCase()){
emps_par.splice(i, 1);
isFound=true;
break;
}
}
}
if(!isFound){
alert("Employee not found");
$("emailToDel").value = "";
return;
}
printEmps(emps_par);
return emps_par;
}
function searchEmp(emps_par){
//alert ("in search emp");
//search the array for email, if found, print that employee's details in the emp_found text area,
//otherwise
//alert that employee was not found and clear the search field
//print out the employee if found, otherwise say not found in text area
var email=$("emailToSearch").value;
var isFound=false;
for(var i=0;i<emps_par.length;i++){
if(emps_par[i]){
if(email.toLowerCase()==emps_par[i].email.toLowerCase()){
isFound=true;
var printStr="Name : "+emps_par[i].name+", Email : "+emps_par[i].email+", Address : "+emps_par[i].address+", Salary : "+emps_par[i].salary+"";
$("emp_found").value = printStr;
break;
}
}
}
if(!isFound){
alert("Employee not found");
$("emailToSearch").value = "";
$("emp_found").value = "Employee not found";
return;
}
}
function main() {
//called when page is loaded and runs all the other functions
//alert("in main");
var emps = initEmps();
$("display_emp").addEventListener("click", function() {
printEmps(emps);
});
$("add_emp").addEventListener("click", function() {
addEmp(emps);
});
$("del_emp").addEventListener("click", function() {
delEmp(emps);
});
$("search_emp").addEventListener("click", function() {
searchEmp(emps);
});
}//main
window.onload = function() {
$("all_emp").value = "";
//clearInputTextFields();
main();
}//onload
</script>
<header>
<h5>Get all functions to work, similar to the customer GUI code we received. Save as YourFirstNameYourLastNameMIS3023Final.html and email to Professor by 11:25 am</h5>
<h6>Hover mouse over the two textareas and the Delete Email field to see what is required on each one</h6>
</header>
<fieldset>
<legend>
New Employee Information 10 points
</legend>
<label for="email">E-Mail:</label>
<input type="email" name="email" id="email" required>
<br>
<br>
<label for="name1">Name:</label>
<input type="text" name="name1" id="name1"
placeholder="Employee Name">
<br>
<br>
<label for="Address">Address:</label>
<input type="text" name="address" id="address"
placeholder="Employee Address">
<br>
<br>
<label for="salary">Salary:</label>
<input type="text" name="salary" id="salary"
placeholder="Employee Salary">
<br>
<br>
<input type="submit" id="add_emp" value="Add New" title="Add a new employee"/>
</fieldset>
<br>
<fieldset>
<legend>
Display All Existing Employees 5 points
</legend>
<input type="button" id="display_emp" value="Display Employees" title="Display All Employees in Box"/>
<textarea id="all_emp" placeholder= "Display All Employees Here" title="Displays All Employees here, one per row"> </textarea>
</fieldset>
<br>
<fieldset>
<legend>
Delete An Employee 10 points
</legend>
<label for="emailToDel">E-Mail:</label>
<input type="email" title = "If found, delete, otherwise alert not found" name="emailToDel" id="emailToDel">
<br>
<br>
<input type="button" id="del_emp" value="Delete Employee" title="Delete an employee whose Email is given"/>
</fieldset>
<fieldset>
<legend>
Search For An Existing Employee 10 points
</legend>
<input type="button" id="search_emp" value="Search By Email" title="Search by Email"/>
<label for="emailToSearch">E-Mail:</label>
<input type="email" name="emailToSearch" id="emailToSearch">
<textarea id="emp_found" placeholder= "Displays the Found Employee Here, otherwise not found message" title="Displays Found Employee here, otherwise not found message"> </textarea>
</fieldset>
<br>
<footer>
<p>
© Copyright by akhilesh-bajaj, 2016
</p>
</footer>
</body>
</html>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.