-
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.
Showing
2 changed files
with
26 additions
and
22 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,27 +1,31 @@ | ||
function jsonRead(jsonpages, metatagFunc){ | ||
function jsonRead(jsonpages, metatagArr){ | ||
let xhr = fetch(jsonpages); | ||
xhr.then((res)=>{ | ||
return res.json() | ||
}).then((data)=>{ | ||
return data | ||
}).then((data)=>{ | ||
function evenAdder(){ | ||
|
||
let SPAname = metatagArr[0]; | ||
let SPAurl = metatagArr[1]; | ||
let SPAtitle = metatagArr[2]; | ||
|
||
let elements = document.querySelectorAll('[SPAname]'); | ||
elements.forEach((ele, index)=>{ | ||
ele.addEventListener('click',()=>{ | ||
document.title = data[index].SPAtitle; | ||
window.history.pushState("","",data[index].SPAurl); | ||
document.title = data[index][SPAtitle]; | ||
window.history.pushState("","",data[index][SPAurl]); | ||
}) | ||
}) | ||
} | ||
evenAdder(metatagFunc); | ||
evenAdder(); | ||
}); | ||
} | ||
|
||
function metaTags(SPAnameKeyName, urlKeyName, titleKeyName){ | ||
let SPAname = SPAnameKeyName; | ||
let SPAurl = urlKeyName; | ||
let SPAtitle = titleKeyName; | ||
} | ||
jsonRead("spa.json",["SPAnameR", "SPAurlR", "SPAtitleR"]); | ||
|
||
|
||
|
||
|
||
|
||
jsonRead("spa.json",metaTags("SPAname", "SPAurl", "SPAtitle")); |
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