82 lines
2.7 KiB
HTML
82 lines
2.7 KiB
HTML
|
<!DOCTYPE html>
|
||
|
<html lang="fr">
|
||
|
<head>
|
||
|
<meta charset="UTF-8">
|
||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
<link rel="icon" href="//api.gzod01.fr/pictures/gzod01.ico">
|
||
|
<link rel="stylesheet" href="//api.gzod01.fr/css/style.css">
|
||
|
<script src="//api.gzod01.fr/scripts/main.js"></script>
|
||
|
<title>sitemap.html</title>
|
||
|
</head>
|
||
|
<body>
|
||
|
<div id="header"></div>
|
||
|
<div class=content>
|
||
|
<h1>Plan Des Sites: </h1>
|
||
|
<ul id="sitemap"></ul>
|
||
|
<script>
|
||
|
|
||
|
function sleep(s) {
|
||
|
let ms = s*1000
|
||
|
return new Promise(resolve => setTimeout(resolve, ms));
|
||
|
}
|
||
|
async function fetchsitemap(){
|
||
|
const xhr = new XMLHttpRequest();
|
||
|
xhr.onreadystatechange = () => {
|
||
|
if (xhr.readyState === XMLHttpRequest.DONE) {
|
||
|
console.log(typeof xhr.responseText);
|
||
|
console.log(xhr.responseText);
|
||
|
}
|
||
|
};
|
||
|
xhr.open('GET', 'http://gzod01.fr/sitemap.json', true);
|
||
|
xhr.setRequestHeader('Accept', 'application/json');
|
||
|
xhr.send(null);
|
||
|
await sleep(2)
|
||
|
const res = JSON.parse(xhr.responseText);
|
||
|
return res
|
||
|
}
|
||
|
function createlinode(url, value, key, strtype, rootofnode){
|
||
|
if(key.startswith(strtype)){
|
||
|
let linknode = document.createelement('li')
|
||
|
linknode.innerhtml='<a href="'+url+value+'">'+key.substring(strtype.length)+'</a>'
|
||
|
rootofnode.appendchild(linknode)
|
||
|
}
|
||
|
}
|
||
|
function preparesitemap(data,rootnode,callurl="",name){
|
||
|
console.log(data, rootnode, callurl, name)
|
||
|
let url = callurl+data['-url-']
|
||
|
rootnode.innerHTML='<a href="'+url+'">'+name+'</a>'
|
||
|
let ulement = document.createElement('ul')
|
||
|
rootnode.appendChild('ul')
|
||
|
Object.entries(data).forEach((quer)=>{
|
||
|
let [rkey, rvalue] = quer
|
||
|
if(rkey.startsWith('dir-')){
|
||
|
let jsonv = JSON.parse(rvalue)
|
||
|
let newrootnode = document.createElement('li')
|
||
|
rootnode.appendChild(newrootnode)
|
||
|
preparesitemap(jsonv,newrootnode, url, rkey.substring('dir-'.length))
|
||
|
}
|
||
|
createlinode(url,rvalue,rkey,"page-",ulement)
|
||
|
createlinode(url,rvalue,rkey,"file-",ulement)
|
||
|
})
|
||
|
}
|
||
|
async function mainsitemap(){
|
||
|
let res = fetchsitemap()
|
||
|
await Object.entries(res).forEach((entry)=>{
|
||
|
console.log('helloworld')
|
||
|
let [rootkey, rootvalue] = entry
|
||
|
if(rootkey.startsWith('site-')){
|
||
|
let valuejsoned = JSON.parse(rootvalue)
|
||
|
let rootofallnode = document.getElementById('sitemap')
|
||
|
let rootofthenode = document.createElement('li')
|
||
|
rootofallnode.appendChild(rootofthenode)
|
||
|
preparesitemap(valuejsoned, rootofthenode, "", rootkey.substring('site-'.length))
|
||
|
}
|
||
|
})}
|
||
|
mainsitemap()
|
||
|
</script>
|
||
|
</div>
|
||
|
<div id="footer"></div>
|
||
|
</body>
|
||
|
</html>
|