final-fixes #32

Merged
rodude123 merged 2 commits from final-fixes into master 2023-03-05 20:00:52 +00:00
17 changed files with 20 additions and 22 deletions
+4 -3
View File
@@ -53,8 +53,6 @@ $app->get("/timelineData/{timeline}", function (Request $request, Response $resp
return $response; return $response;
} }
// something went wrong // something went wrong
$response->getBody()->write(json_encode(array("errorMessage" => "Error, timeline data not found"))); $response->getBody()->write(json_encode(array("errorMessage" => "Error, timeline data not found")));
return $response->withStatus(404); return $response->withStatus(404);
@@ -73,7 +71,6 @@ $app->patch("/timelineData/{timeline}/{id}", function (Request $request, Respons
return $response->withStatus(400); return $response->withStatus(400);
} }
if (!$timelineData->updateEduData($data["dateFrom"], $data["dateTo"], $data["grade"], $data["course"], $args["id"])) if (!$timelineData->updateEduData($data["dateFrom"], $data["dateTo"], $data["grade"], $data["course"], $args["id"]))
{ {
// uh oh something went wrong // uh oh something went wrong
@@ -81,6 +78,7 @@ $app->patch("/timelineData/{timeline}/{id}", function (Request $request, Respons
return $response->withStatus(500); return $response->withStatus(500);
} }
$response->withStatus(201);
return $response; return $response;
} }
@@ -100,6 +98,7 @@ $app->patch("/timelineData/{timeline}/{id}", function (Request $request, Respons
return $response->withStatus(500); return $response->withStatus(500);
} }
$response->withStatus(201);
return $response; return $response;
} }
@@ -160,6 +159,7 @@ $app->post("/timelineData/{timeline}", function (Request $request, Response $res
} }
$response->getBody()->write(json_encode(array("ID" => $insertedID))); $response->getBody()->write(json_encode(array("ID" => $insertedID)));
$response->withStatus(201);
return $response; return $response;
} }
@@ -186,6 +186,7 @@ $app->post("/timelineData/{timeline}", function (Request $request, Response $res
} }
$response->getBody()->write(json_encode(array("ID" => $insertedID))); $response->getBody()->write(json_encode(array("ID" => $insertedID)));
$response->withStatus(201);
return $response; return $response;
} }
+1 -1
View File
@@ -79,7 +79,7 @@ class middleware
$app->add(new JwtAuthentication([ $app->add(new JwtAuthentication([
"rules" => [ "rules" => [
new RequestPathRule([ new RequestPathRule([
"path" => ["/api/projectData", "/api/timeline/[a-z]*", "/api/logout"], "path" => ["/api/projectData", "/api/timelineData/[a-z]*", "/api/projectImage/[0-9]*", "/api/logout"],
"ignore" => ["/api/contact", "/api/user/login", "/api/user/changePassword"] "ignore" => ["/api/contact", "/api/user/login", "/api/user/changePassword"]
]), ]),
new RequestMethodRule([ new RequestMethodRule([
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1
View File
@@ -0,0 +1 @@
function showErrorMessage(e){document.querySelector("#loginError").classList.remove("hidden"),document.querySelector("#loginError div").innerText=e}document.addEventListener("DOMContentLoaded",(e=>{fetch("/api/user/isLoggedIn").then((e=>{e.ok&&(window.location.href="./editor.html")}))})),document.querySelector("#login form").addEventListener("submit",(e=>{e.preventDefault();let r=new FormData;if(e.target.username.value.length>0&&e.target.password.value.length>0)return r.append("username",e.target.username.value),r.append("password",e.target.password.value),void fetch("/api/user/login",{method:"POST",body:r}).then((e=>{e.ok?window.location.href="./editor.html":400!==e.status?(document.querySelector("#loginError").classList.remove("hidden"),document.querySelector("#loginError div").innerHTML="Invalid username or password"):showErrorMessage("Please type in a username and password.")}));document.querySelector("#loginError").classList.remove("hidden"),document.querySelector("#loginError div").innerHTML="Please type in a username and password"})),document.querySelector("#loginError .close").addEventListener("click",(()=>document.querySelector("#loginError").classList.toggle("hidden")));
+1 -1
View File
File diff suppressed because one or more lines are too long
-1
View File
@@ -1 +0,0 @@
let dataText=["full stack developer","web designer","student","gamer","drummer"];function main(t,n,i){n<t.length?(document.querySelector("header div h1").innerHTML=t.substring(0,n+1)+'<span aria-hidden="true">_</span>',setTimeout((function(){main(t,n+1,i)}),100)):"function"==typeof i&&setTimeout(i,700)}function StartTextAnimation(t){void 0===dataText[t]?setTimeout((function(){StartTextAnimation(0)}),1500):t<dataText[t].length&&main(dataText[t],0,(function(){setTimeout(StartTextAnimation,1500,t+1)}))}function getProjectData(){fetch("/api/projectData").then((t=>{t.json().then((n=>{t.ok&&n.forEach((t=>{if("1"===t.isMainProject)return document.getElementById("mainProj").innerHTML=`\n\t\t\t\t\t\t<h1>${t.title}</h1>\n\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t<img src="${""===t.imgLocation?"../imgs/placeholder.png":t.imgLocation}" alt="">\n\t\t\t\t\t\t\t<div class="flexRow">\n\t\t\t\t\t\t\t\t<p>${t.information}</p>\n\t\t\t\t\t\t\t\t<div class="flexCol">\n\t\t\t\t\t\t\t\t\t<a href="${"N/A"===t.projectLink?"#":t.projectLink}" class="btn btnPrimary boxShadowIn boxShadowOut" ${"N/A"===t.projectLink?'disabled="disabled"':""}>View Project</a>\n\t\t\t\t\t\t\t\t\t<a href="${"N/A"===t.gitLink?"#":t.gitLink}" class="btn btnOutline boxShadowIn boxShadowOut" ${"N/A"===t.gitLink?'disabled="disabled"':""}>Git</a>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t`,null;document.querySelector("#otherProj div").innerHTML+=`\n <div class="oProjItem">\n <img src="${""===t.imgLocation?"../imgs/placeholder.png":t.imgLocation}" alt="">\n <div class="flexCol">\n <div>\n \t<h3>${t.title}</h3>\n <p>${t.information}</p>\n </div>\n <div>\n <a href="${"N/A"===t.projectLink?"#":t.projectLink}" class="btn btnPrimary boxShadowIn boxShadowOut"${"N/A"===t.projectLink?'disabled="disabled"':""}>View Project</a>\n <a href="${"N/A"===t.githubLink?"#":t.gitubLink}" class="btn btnOutline boxShadowIn boxShadowOut">${"N/A"===t.githubLink?'disabled="disabled"':""}Git</a>\n </div>\n </div>\n </div>\n `}))}))}))}document.addEventListener("DOMContentLoaded",(()=>{StartTextAnimation(0)}));
+1 -1
View File
@@ -1 +1 @@
const scrollLimit=150;function getProjectData(){fetch("/api/projectData").then((t=>{t.json().then((n=>{t.ok&&n.forEach((t=>{if("1"===t.isMainProject)return document.querySelector("#mainProj").innerHTML=`\n\t\t\t\t\t\t<h1>${t.title}</h1>\n\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t<img src="${""===t.imgLocation?"../imgs/placeholder.png":t.imgLocation}" alt="">\n\t\t\t\t\t\t\t<div class="flexRow">\n\t\t\t\t\t\t\t\t<p>${t.information}</p>\n\t\t\t\t\t\t\t\t<div class="flexCol">\n\t\t\t\t\t\t\t\t\t<a href="${"N/A"===t.projectLink?"#":t.projectLink}" class="btn btnPrimary boxShadowIn boxShadowOut" ${"N/A"===t.projectLink?'disabled="disabled"':""}>View Project</a>\n\t\t\t\t\t\t\t\t\t<a href="${"N/A"===t.gitLink?"#":t.gitLink}" class="btn btnOutline boxShadowIn boxShadowOut" ${"N/A"===t.gitLink?'disabled="disabled"':""}>Git</a>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t`,null;document.querySelector("#otherProj").innerHTML+=`\n <div class="oProjItem">\n <img src="${""===t.imgLocation?"../imgs/placeholder.png":t.imgLocation}" alt="">\n <div class="flexCol">\n <div>\n \t<h3>${t.title}</h3>\n <p>${t.information}</p>\n </div>\n <div>\n <a href="${"N/A"===t.projectLink?"#":t.projectLink}" class="btn btnPrimary boxShadowIn boxShadowOut"${"N/A"===t.projectLink?'disabled="disabled"':""}>View Project</a>\n <a href="${"N/A"===t.githubLink?"#":t.gitubLink}" class="btn btnOutline boxShadowIn boxShadowOut">${"N/A"===t.githubLink?'disabled="disabled"':""}Git</a>\n </div>\n </div>\n </div>\n `}))}))}))}window.onscroll=()=>{document.body.scrollTop>=150||document.documentElement.scrollTop>=150?document.querySelector("nav").classList.add("scrolled"):document.querySelector("nav").classList.remove("scrolled")},document.querySelector("#goBackToTop").addEventListener("click",(()=>{window.scrollTo(0,0)})),document.addEventListener("DOMContentLoaded",(()=>{getProjectData(),document.getElementById("year").innerHTML=(new Date).getFullYear().toString()})); const scrollLimit=150;function getProjectData(){fetch("/api/projectData").then((t=>{t.json().then((n=>{t.ok&&n.forEach((t=>{if(1===t.isMainProject)return document.querySelector("#mainProj").innerHTML=`\n\t\t\t\t\t\t<h1>${t.title}</h1>\n\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t<img src="${""===t.imgLocation?"../imgs/placeholder.png":t.imgLocation}" alt="">\n\t\t\t\t\t\t\t<div class="flexRow">\n\t\t\t\t\t\t\t\t<p>${t.information}</p>\n\t\t\t\t\t\t\t\t<div class="flexCol">\n\t\t\t\t\t\t\t\t\t<a href="${"N/A"===t.projectLink?"#":t.projectLink}" class="btn btnPrimary boxShadowIn boxShadowOut" ${"N/A"===t.projectLink?'disabled="disabled"':""}>View Project</a>\n\t\t\t\t\t\t\t\t\t<a href="${"N/A"===t.gitLink?"#":t.gitLink}" class="btn btnOutline boxShadowIn boxShadowOut" ${"N/A"===t.gitLink?'disabled="disabled"':""}>Git</a>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t`,null;document.querySelector("#otherProj").innerHTML+=`\n <div class="oProjItem">\n <img src="${""===t.imgLocation?"../imgs/placeholder.png":t.imgLocation}" alt="">\n <div class="flexCol">\n <div>\n \t<h3>${t.title}</h3>\n <p>${t.information}</p>\n </div>\n <div>\n <a href="${"N/A"===t.projectLink?"#":t.projectLink}" class="btn btnPrimary boxShadowIn boxShadowOut"${"N/A"===t.projectLink?'disabled="disabled"':""}>View Project</a>\n <a href="${"N/A"===t.githubLink?"#":t.gitubLink}" class="btn btnOutline boxShadowIn boxShadowOut">${"N/A"===t.githubLink?'disabled="disabled"':""}Git</a>\n </div>\n </div>\n </div>\n `}))}))}))}window.onscroll=()=>{document.body.scrollTop>=150||document.documentElement.scrollTop>=150?document.querySelector("nav").classList.add("scrolled"):document.querySelector("nav").classList.remove("scrolled")},document.querySelector("#goBackToTop").addEventListener("click",(()=>{window.scrollTo(0,0)})),document.addEventListener("DOMContentLoaded",(()=>{getProjectData(),document.getElementById("year").innerHTML=(new Date).getFullYear().toString()}));
View File
-1
View File
@@ -1 +0,0 @@
let dataText=["full stack developer","web designer","student","gamer","drummer"];function typeWriter(t,e,n){e<t.length?(document.querySelector("header div h1").innerHTML=t.substring(0,e+1)+'<span aria-hidden="true">_</span>',setTimeout((function(){typeWriter(t,e+1,n)}),100)):"function"==typeof n&&setTimeout(n,700)}function StartTextAnimation(t){void 0===dataText[t]?setTimeout((function(){StartTextAnimation(0)}),1500):t<dataText[t].length&&typeWriter(dataText[t],0,(function(){setTimeout(StartTextAnimation,1500,t+1)}))}document.addEventListener("DOMContentLoaded",(()=>{StartTextAnimation(0)}));
-3
View File
@@ -53,8 +53,6 @@ $app->get("/timelineData/{timeline}", function (Request $request, Response $resp
return $response; return $response;
} }
// something went wrong // something went wrong
$response->getBody()->write(json_encode(array("errorMessage" => "Error, timeline data not found"))); $response->getBody()->write(json_encode(array("errorMessage" => "Error, timeline data not found")));
return $response->withStatus(404); return $response->withStatus(404);
@@ -73,7 +71,6 @@ $app->patch("/timelineData/{timeline}/{id}", function (Request $request, Respons
return $response->withStatus(400); return $response->withStatus(400);
} }
if (!$timelineData->updateEduData($data["dateFrom"], $data["dateTo"], $data["grade"], $data["course"], $args["id"])) if (!$timelineData->updateEduData($data["dateFrom"], $data["dateTo"], $data["grade"], $data["course"], $args["id"]))
{ {
// uh oh something went wrong // uh oh something went wrong
+1 -1
View File
@@ -79,7 +79,7 @@ class middleware
$app->add(new JwtAuthentication([ $app->add(new JwtAuthentication([
"rules" => [ "rules" => [
new RequestPathRule([ new RequestPathRule([
"path" => ["/api/projectData", "/api/timeline/[a-z]*", "/api/logout"], "path" => ["/api/projectData", "/api/timelineData/[a-z]*", "/api/projectImage/[0-9]*", "/api/logout"],
"ignore" => ["/api/contact", "/api/user/login", "/api/user/changePassword"] "ignore" => ["/api/contact", "/api/user/login", "/api/user/changePassword"]
]), ]),
new RequestMethodRule([ new RequestMethodRule([
+3 -1
View File
@@ -64,12 +64,14 @@ h2 {
a.btn, form input[type="submit"] { a.btn, form input[type="submit"] {
text-decoration: none; text-decoration: none;
display: inline-block; display: inline-flex;
padding: 1em 2em; padding: 1em 2em;
border-radius: 0.625em; border-radius: 0.625em;
border: 0.3215em solid var(--primaryDefault); border: 0.3215em solid var(--primaryDefault);
color: #FFFFFF; color: #FFFFFF;
text-align: center; text-align: center;
align-items: center;
max-height: 4em;
} }
form input[type="submit"] { form input[type="submit"] {
+2 -2
View File
@@ -636,7 +636,7 @@ function updateProjectItem(id, e)
if (res.ok) if (res.ok)
{ {
if (data["isMainProject"] === "true") if (updatedProjectImage["isMainProject"] === "true")
{ {
document.querySelectorAll(".isMainProject input").forEach(item => item.checked = false); document.querySelectorAll(".isMainProject input").forEach(item => item.checked = false);
document.querySelector(`#isMainProject${id}`).checked = true; document.querySelector(`#isMainProject${id}`).checked = true;
@@ -657,7 +657,7 @@ function updateProjectItem(id, e)
} }
document.querySelector(`#projError${id}`).classList.remove("hidden"); document.querySelector(`#projError${id}`).classList.remove("hidden");
document.querySelector(`#projError${id} div`).innerHTML = projectDataError.error; document.querySelector(`#projError${id} div`).innerHTML = updatedProjectImage.error;
})); }));
+2 -3
View File
@@ -105,15 +105,14 @@ function getProjectData()
if (res.ok) if (res.ok)
{ {
for (let i = 0; i < 4; i++){ for (let i = 0; i < 4; i++){
const item = json[i]; if (json[i]["isMainProject"] === 1)
if (json[i]["isMainProject"] === "1")
{ {
document.getElementById("mainProj").innerHTML = ` document.getElementById("mainProj").innerHTML = `
<h1>${json[i]["title"]}</h1> <h1>${json[i]["title"]}</h1>
<div> <div>
<img src="${(json[i]["imgLocation"] === "") ? "../imgs/placeholder.png" : json[i]["imgLocation"]}" alt=""> <img src="${(json[i]["imgLocation"] === "") ? "../imgs/placeholder.png" : json[i]["imgLocation"]}" alt="">
<div class="flexRow"> <div class="flexRow">
<p>${item["information"]}</p> <p>${json[i]["information"]}</p
<div class="flexCol"> <div class="flexCol">
<a href="${(json[i]["projectLink"] === "N/A") ? "#" : json[i]["projectLink"]}" class="btn btnPrimary boxShadowIn boxShadowOut" ${(json[i]["projectLink"] === "N/A") ? "disabled=\"disabled\"" : ""}>View Project</a> <a href="${(json[i]["projectLink"] === "N/A") ? "#" : json[i]["projectLink"]}" class="btn btnPrimary boxShadowIn boxShadowOut" ${(json[i]["projectLink"] === "N/A") ? "disabled=\"disabled\"" : ""}>View Project</a>
<a href="${(json[i]["gitLink"] === "N/A") ? "#" : json[i]["gitLink"]}" class="btn btnOutline boxShadowIn boxShadowOut" ${(json[i]["gitLink"] === "N/A") ? "disabled=\"disabled\"" : ""}>Git</a> <a href="${(json[i]["gitLink"] === "N/A") ? "#" : json[i]["gitLink"]}" class="btn btnOutline boxShadowIn boxShadowOut" ${(json[i]["gitLink"] === "N/A") ? "disabled=\"disabled\"" : ""}>Git</a>
+1 -1
View File
@@ -34,7 +34,7 @@ function getProjectData()
{ {
json.forEach(item => json.forEach(item =>
{ {
if (item["isMainProject"] === "1") if (item["isMainProject"] === 1)
{ {
document.querySelector("#mainProj").innerHTML = ` document.querySelector("#mainProj").innerHTML = `
<h1>${item["title"]}</h1> <h1>${item["title"]}</h1>