Skip to content

Commit

Permalink
put default value to metaArr
Browse files Browse the repository at this point in the history
maybe the programmer used the same names of the framework, so he would't need to put a metaArr, and that will make app not worrking &  this is a problem so i fixed it now.
  • Loading branch information
HamzaElkotp committed Sep 22, 2022
1 parent 35cfc66 commit 76bf247
Show file tree
Hide file tree
Showing 3 changed files with 20,012 additions and 20 deletions.
1 change: 0 additions & 1 deletion main.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,3 @@ body{




14 changes: 8 additions & 6 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
function jsonRead(jsonpages, metatagArr){
function jsonRead(jsonpages, metatagArr = ["SPAname", "SPAurl", "SPAtitle"]){

let xhr = fetch(jsonpages);
xhr.then((res)=>{
return res.json()
Expand All @@ -19,11 +20,14 @@ function jsonRead(jsonpages, metatagArr){
ele.addEventListener('click',()=>{

// change title, url regardless of pages or json file objects order
data.forEach((item, dataI)=>{
data.evry((item, dataI)=>{
if(data[dataI][SPAname] == ele.getAttribute("SPAname")){
document.title = data[dataI][SPAtitle];
window.history.pushState("","",data[dataI][SPAurl]);
return false;
}
console.log(1)
return true;
})

elements.forEach((eles)=>{
Expand All @@ -38,9 +42,7 @@ function jsonRead(jsonpages, metatagArr){
});
}

jsonRead("spa.json",["SPAnameR", "SPAurlR", "SPAtitleR"]);



jsonRead("spa.json",["SPAname1", "SPAurl1", "SPAtitle1"]);


// You have a problem, many requests, to window.history.pushState because looping on every element
Loading

0 comments on commit 76bf247

Please sign in to comment.