-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from 3296Fall2020/dl-inventory-frontend
Dl inventory frontend
- Loading branch information
Showing
17 changed files
with
654 additions
and
5 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
function login () { | ||
|
||
var accountDiv = document.createElement("div"); | ||
accountDiv.classList.add("account"); | ||
|
||
var idSpan = document.createElement('span'); | ||
idSpan.innerHTML = "ID "; | ||
accountDiv.appendChild(idSpan); | ||
var idInput = document.createElement("input"); | ||
accountDiv.appendChild(idInput); | ||
|
||
var passwordSpan = document.createElement('span'); | ||
passwordSpan.innerHTML = "Password "; | ||
accountDiv.appendChild(passwordSpan); | ||
var passwordInput = document.createElement("input"); | ||
passwordInput.setAttribute("type", "password"); | ||
accountDiv.appendChild(passwordInput); | ||
|
||
|
||
var loginButton = document.createElement("button"); | ||
loginButton.innerHTML = "login"; | ||
accountDiv.appendChild(loginButton); | ||
|
||
var msgDiv = document.createElement("div"); | ||
accountDiv.appendChild(msgDiv); | ||
|
||
loginButton.onclick = function () { | ||
alert("Do login here") | ||
}; // onclick function | ||
|
||
return accountDiv; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
function loginForm () { | ||
|
||
var accountDiv = document.createElement("div"); | ||
accountDiv.classList.add("account"); | ||
|
||
//create break line element | ||
var br = document.createElement("br"); | ||
|
||
//create a form | ||
var form = document.createElement("form"); | ||
form.setAttribute("method", "post"); | ||
form.setAttribute("action", "submit.php"); | ||
|
||
//create an input element for User ID | ||
var id = document.createElement("input"); | ||
id.setAttribute("type", "text"); | ||
id.setAttribute("name", "id"); | ||
id.setAttribute("placeholder", "User ID"); | ||
id.setAttribute("required","true"); | ||
|
||
//create an input element for Password | ||
var password = document.createElement("input"); | ||
password.setAttribute("type", "password"); | ||
password.setAttribute("name", "password"); | ||
password.setAttribute("placeholder", "Password"); | ||
password.setAttribute("required","true"); | ||
|
||
//create a submit button | ||
var loginButton = document.createElement("input"); | ||
loginButton.setAttribute("type", "submit"); | ||
loginButton.setAttribute("value", "Log in"); | ||
|
||
form.appendChild(id); | ||
form.appendChild(br.cloneNode()); | ||
form.appendChild(password); | ||
form.appendChild(br.cloneNode()); | ||
form.appendChild(loginButton); | ||
|
||
accountDiv.appendChild(form); | ||
|
||
return accountDiv; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
function logout () { | ||
var accountDiv = document.createElement("div"); | ||
accountDiv.classList.add("account"); | ||
|
||
var logoutButton = document.createElement("button"); | ||
logoutButton.innerHTML = "logout"; | ||
accountDiv.appendChild(logoutButton); | ||
|
||
logoutButton.onclick = function () { | ||
alert("Do logout here") | ||
}; // onclick function | ||
|
||
return accountDiv; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
function registerForm () { | ||
|
||
var accountDiv = document.createElement("div"); | ||
accountDiv.classList.add("account"); | ||
|
||
//create break line element | ||
var br = document.createElement("br"); | ||
|
||
//create a form | ||
var form = document.createElement("form"); | ||
form.setAttribute("method", "post"); | ||
form.setAttribute("action", "submit.php"); | ||
|
||
//create an input element for User ID | ||
var id = document.createElement("input"); | ||
id.setAttribute("type", "text"); | ||
id.setAttribute("name", "id"); | ||
id.setAttribute("placeholder", "User ID"); | ||
id.setAttribute("required","true"); | ||
id.setAttribute("maxlength","15"); | ||
|
||
//create an input element for Password | ||
var password = document.createElement("input"); | ||
password.setAttribute("type", "password"); | ||
password.setAttribute("name", "password"); | ||
password.setAttribute("placeholder", "Password"); | ||
password.setAttribute("required","true"); | ||
password.setAttribute("maxlength","15"); | ||
|
||
//create an input element for Confirm Password | ||
var confirmPassword = document.createElement("input"); | ||
confirmPassword.setAttribute("type", "password"); | ||
confirmPassword.setAttribute("name", "confirmPassword"); | ||
confirmPassword.setAttribute("placeholder", "Confirm Password"); | ||
confirmPassword.setAttribute("required","true"); | ||
confirmPassword.setAttribute("maxlength","15"); | ||
|
||
|
||
//create a submit button | ||
var registerButton = document.createElement("input"); | ||
registerButton.setAttribute("type", "submit"); | ||
registerButton.setAttribute("value", "Register"); | ||
|
||
form.appendChild(id); | ||
form.appendChild(br.cloneNode()); | ||
form.appendChild(password); | ||
form.appendChild(br.cloneNode()); | ||
form.appendChild(confirmPassword); | ||
form.appendChild(br.cloneNode()); | ||
form.appendChild(registerButton); | ||
|
||
accountDiv.appendChild(form); | ||
|
||
return accountDiv; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
function sneakerInventory() { | ||
var clickSortContainer = document.createElement("div"); | ||
clickSortContainer.classList.add("clickSort"); | ||
ajax("json/inventory.json", processSneakerInventory, clickSortContainer); | ||
|
||
function processSneakerInventory (list) { | ||
|
||
var inventoryList = []; | ||
for (var i=0; i <list.length; i++) { | ||
inventoryList[i] = {}; | ||
inventoryList[i].sneakerName = list[i].sneakerName; | ||
inventoryList[i].image = "<img src='" + list[i].image + "' style=width:5rem'>"; | ||
inventoryList[i].currentValue = list[i].currentValue; | ||
inventoryList[i].releaseDate = list[i].releaseDate; | ||
inventoryList[i].webUserId = list[i].webUserId; | ||
} | ||
|
||
var params = { | ||
list: inventoryList, | ||
sortOrderPropName: "sneakerName", | ||
sortIcon: "icon/sortUpDown16.png", | ||
title: "Sneaker Inventory" | ||
} | ||
|
||
var myClickSort = makeClickSort(params); | ||
clickSortContainer.appendChild(myClickSort); | ||
} | ||
return clickSortContainer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
function ajax(url, successCallBackFn, errorEle) { | ||
|
||
var httpReq; | ||
if (window.XMLHttpRequest) { | ||
httpReq = new XMLHttpRequest(); //For Firefox, Safari, Opera | ||
} else if (window.ActiveXObject) { | ||
httpReq = new ActiveXObject("Microsoft.XMLHTTP"); //For IE 5+ | ||
} else { | ||
alert('ajax not supported'); | ||
} | ||
|
||
console.log("ready to get content " + url); | ||
httpReq.open("GET", url); // specify which page you want to get | ||
|
||
|
||
httpReq.onreadystatechange = function () { | ||
//console.log("in ajax, ready state is " + httpReq.readyState); | ||
|
||
if (httpReq.readyState === 4) { // 4 means that the data transfer is complete | ||
console.log("in ajax, status is " + httpReq.status); | ||
|
||
if (httpReq.status === 200) { // 200 means file found (unlike 404 which means not found) | ||
console.log("in ajax, js object printed next"); | ||
|
||
var obj = JSON.parse(httpReq.responseText); | ||
console.log(obj); | ||
|
||
// Here we call back whichever function wanted us to make the AJAX call. | ||
successCallBackFn(obj); | ||
|
||
} else { // error, file not found | ||
|
||
// One input parameter to this ajax function is a DOM element designed to hold any possible error message. | ||
// Populate it with as much information as we know about the error. | ||
errorEle.innerHTML = "Error " + httpReq.status + "-" + httpReq.statusText + | ||
" while attempting to read '" + url + "'"; | ||
} | ||
} | ||
}; // end of anonymous callback function definition | ||
|
||
httpReq.send(null); // initiate ajax call | ||
console.log("call initiated"); | ||
|
||
|
||
} // end function ajax |
Oops, something went wrong.