Skip to content
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ Search capabilities include populating screen with substring matches. To introdu
- Jacob Peach (Frontend)
- Alperen Yazmaci (API)

test


4 changes: 2 additions & 2 deletions contacts.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
</head>
<body>
<header id="nav-header" class="text-black nav py-5 bg-accent">
<a class="text-black" href="http://oceanic-connections.xyz/contacts.php" aira-label="button"><div id="home-button" class= "header-link button" type="button">Home</div></a>
<a class="text-black" href="http://oceanic-connections.xyz/about.php" aira-label="button"><div id="about-link" class="header-link button" type="button">About</div></a>
<a class="text-black" href="http://159.203.115.181/contacts.php" aira-label="button"><div id="home-button" class= "header-link button" type="button">Home</div></a>
<a class="text-black" href="http://159.203.115.181/about.php" aira-label="button"><div id="about-link" class="header-link button" type="button">About</div></a>
<a class="text-black logout" href="javascript:doLogout()" aira-label="button"> <div id="about-us-button" class="header-link button" type="button">Logout</div></a>
</header>
<!-- Image Background -->
Expand Down
90 changes: 72 additions & 18 deletions js/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//const urlBase = 'http://159.203.115.181/LAMPAPI';
const urlBase = 'http://oceanic-connections.xyz/LAMPAPI';
const urlBase = 'http://159.203.115.181/LAMPAPI';

const extension = 'php';

Expand Down Expand Up @@ -237,6 +236,7 @@ function doLogin(){
window.location.href = "contacts.php";
}
};
console.log(jsonPayload);
xhr.send(jsonPayload);
}
catch(err)
Expand Down Expand Up @@ -918,32 +918,87 @@ function searchContact(first, last, contactId, favorite, pagination){
xhr.open("POST", url, true);

xhr.setRequestHeader("Content-type", "application/json; charset=UTF-8");
if(confirm("Are you sure you want to delete this contact?") == true) {
try{
xhr.onreadystatechange = function() {
if(this.readyState == 4 && this.status == 200){
//document.getElementById("contact-result").innerHTML ="Contacts have been recieved";
if(xhr.responseText!="No Records Found"){
console.log(xhr.responseText);
let jsonObject = JSON.parse( xhr.responseText );
globalJsonObject = jsonObject;
loadContacts(jsonObject);
console.log("GlobalPageCounter "+firstContactPageFlag);
}
else{
if(pagination === 1){
firstContactPageFlag -=1;
return;
}
else{
globalJsonObject = null;
noContactsFound();
}
}
}
};
xhr.send(jsonPayload);

}
catch(err){
document.getElementById("contact-result").innerHTML = err.message;
console.log(err.message);
}
}
}
}
}

function deleteContact(num){
if(confirm("Are you sure you want to delete this contact?") == true) {
if(contactInEdit === 0){
console.log(num);

let url = urlBase + "/DeleteContact." + extension;

//globalJsonObject.splice(num-1,1);
console.log(globalJsonObject);

let deletedContactID = globalJsonObject.contacts[num-1].ID;
let convertToString = "" + deletedContactID;

let tmp = {contactID:deletedContactID};

let jsonPayload = JSON.stringify(tmp);

console.log(convertToString);

let xhr = new XMLHttpRequest();

xhr.open("POST", url, true);
xhr.setRequestHeader("Content-type", "application/json; charset=UTF-8");
console.log(jsonPayload);
try{
xhr.onreadystatechange = function() {
if(this.readyState == 4 && this.status == 200){
//document.getElementById("contact-result").innerHTML ="Contacts have been recieved";
if(xhr.responseText!="No Records Found"){
console.log(xhr.responseText);
let jsonObject = JSON.parse( xhr.responseText );
globalJsonObject = jsonObject;
loadContacts(jsonObject);
console.log("GlobalPageCounter "+firstContactPageFlag);
}
else{
if(pagination === 1){
firstContactPageFlag -=1;
return;
let jsonObject = JSON.parse(xhr.responseText);
console.log(jsonObject.deleted);
console.log(jsonObject.error);
if(jsonObject.deleted === "Yes"){
document.getElementById("contact-result").innerHTML = "Contact has been deleted";
if(document.getElementById("search-bar").value == ""){
firstPage(null,null);
}
else{
globalJsonObject = null;
noContactsFound();
searchContact(null,null,null,null,null);
}
}
else{
document.getElementById("contact-result").innerHTML = "Contact was not deleted";
}
}
};
xhr.send(jsonPayload);

}
catch(err){
document.getElementById("contact-result").innerHTML = err.message;
Expand Down Expand Up @@ -1006,7 +1061,6 @@ function deleteContact(num){
}
}
}

function updateContact(num){
let edit = 1;

Expand Down
2 changes: 1 addition & 1 deletion login.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<body>
<!-- Header --->
<header id="nav-header" class="text-black nav py-5 bg-accent">
<a class="text-black" href="http://oceanic-connections.xyz/about.php"><div id="about-link" class="header-link button" type="button">About</div></a>
<a class="text-black" href="http://159.203.115.181/about.php"><div id="about-link" class="header-link button" type="button">About</div></a>
</header>


Expand Down