commit d938db0cdd75338ec65a37fe669ac2bd9157608f Author: GZod01 Date: Sat Mar 25 10:26:41 2023 +0100 ok diff --git a/api/css/style.css b/api/css/style.css new file mode 100644 index 0000000..838c462 --- /dev/null +++ b/api/css/style.css @@ -0,0 +1,207 @@ +:root{ + /*the color that will be switch */ + --main-bg-color: white; + --main-txt-color: black; + --scdr-bg-color: lightgray; + --scdr-txt-color: var(--main-txt-color); +} +@media (prefers-color-scheme:dark){ + body::after{ + content: 'dark'; + display: none; + } +} +@media (prefers-color-scheme:light){ + body::after{ + content: 'light'; + display: none; + } +} +@media screen and (max-width: 890px) { + header.nav a:not(:first-child) {display: none;} + header.nav a.icon { + float: right; + display: block; + } +} +@media screen and (max-width: 890px) { + header.nav.responsive {position: relative;} + header.nav.responsive a.icon { + position: absolute; + right: 0; + top: 0; + } + header.nav.responsive a { + float: none; + display: block; + text-align: left; + } +} +body { + min-height: 100vh; + margin: 0; + word-break: break-word; + display: flex; + flex-direction: column; + background-color: var(--main-bg-color); + color: var(--main-txt-color); +} +.content{ + position:relative; + min-height:80vh; + width:100% +} +.parent{ + position:relative; +} +.fullcentered{ + text-align:center; + margin: 0; + position: absolute; + top: 50%; + left: 50%; + -ms-transform: translate(-50%, -50%); + transform: translate(-50%, -50%); +} +.reallycentered{ + text-align:center; + margin:0; + position:fixed; + top:50%; + left:50%; + -ms-transform:translate(-50%,-50%); + transform:translate(-50%,-50%); +} +header.nav{ + margin:0; + background-color: var(--scdr-bg-color); + color: var(--scdr-txt-color); + padding-bottom: 2px; + overflow:hidden; +} +footer a{ + color: var(--scdr-txt-color); + text-decoration:none; +} +header.nav a{ + color: var(--scdr-txt-color); + text-decoration: none; + float:left; + display:block; + text-align:center; + padding:14px 16px; + font-size: 17px +} +header.nav a:hover{ + color:var(--main-bg-color); +} +header.nav a.active{ + background-color: var(--main-bg-color); + color: var(--scdr-txt-color) +} +header.nav .icon{ + display:none +} +a{ + color:var(--main-txt-color); +} +a:hover{ + background-color:var(--main-txt-color); + color:var(--main-bg-color); +} +footer{ + margin-top: auto; + border-top:solid var(--scdr-txt-color); + /*display: flex ;*/ + text-align: center; + width: 100%; + left: 0; + background-color:var(--scdr-bg-color) ; + color: var(--scdr-txt-color); +} +.footerleft{ + border-right: solid var(--scdr-txt-color); + height: 100%; + left:0; + width:50%; +} +.footerright{ + border-left: solid var(--scdr-txt-color); + height: 100%; + right:0; + width:50% +} +.themebutton{ + right:0; + top:50%; + position: fixed; + cursor: pointer; + text-align:center; + border-radius:100%; + z-index:3; + background-color: var(--scdr-bg-color); + color: var(--scdr-txt-color); +} +.themebutton:hover{ + background-color: var(--scdr-txt-color); + color:var(--scdr-bg-color); +} +button{ + border:solid var(--scdr-txt-color); + background-color: var(--scdr-bg-color); + color: var(--scdr-txt-color); +} +button:hover{ + background-color:var(--scdr-txt-color); + color:var(--scdr-bg-color); +} +select{ + border:solid var(--scdr-txt-color); + background-color: var(--scdr-bg-color); + color: var(--scdr-txt-color); +} +select:hover{ + background-color:var(--scdr-txt-color); + color:var(--scdr-bg-color); +} +form { + border: solid var(--scdr-txt-color); + background-color: var(--scdr-bg-color); + color: var(--scdr-txt-color) +} +fieldset{ + border:solid var(--main-txt-color); + background-color: var(--main-bg-color); + color: var(--main-txt-color); +} +#switchmodeicon{ + font-size:200%; +} +/*** Works on common browsers ***/ +::selection { + background-color:var(--main-txt-color); + color:var(--main-bg-color); +} + +/*** Mozilla based browsers ***/ +::-moz-selection { + background-color:var(--main-txt-color); + color:var(--main-bg-color); +} + +/***For Other Browsers ***/ +::-o-selection { + background-color:var(--main-txt-color); + color:var(--main-bg-color); +} + +::-ms-selection { + background-color:var(--main-txt-color); + color:var(--main-bg-color); +} + +/*** For Webkit ***/ +::-webkit-selection { + background-color:var(--main-txt-color); + color:var(--main-bg-color); +} diff --git a/api/index.html b/api/index.html new file mode 100644 index 0000000..ea6b444 --- /dev/null +++ b/api/index.html @@ -0,0 +1 @@ +api.gzod01.fr= scripts, css, parts of pages (like footers, headers, etc.) etc. diff --git a/api/parts/footer.html b/api/parts/footer.html new file mode 100644 index 0000000..8521f36 --- /dev/null +++ b/api/parts/footer.html @@ -0,0 +1,14 @@ + diff --git a/api/parts/header.html b/api/parts/header.html new file mode 100644 index 0000000..d993c85 --- /dev/null +++ b/api/parts/header.html @@ -0,0 +1,13 @@ +
+ + Switch the theme +
diff --git a/api/pictures/gzod01.ico b/api/pictures/gzod01.ico new file mode 100644 index 0000000..8da0a34 Binary files /dev/null and b/api/pictures/gzod01.ico differ diff --git a/api/pictures/gzod01.png b/api/pictures/gzod01.png new file mode 100644 index 0000000..30cdc71 Binary files /dev/null and b/api/pictures/gzod01.png differ diff --git a/api/pictures/pdpdevmatrix.jpg b/api/pictures/pdpdevmatrix.jpg new file mode 100644 index 0000000..624c49c Binary files /dev/null and b/api/pictures/pdpdevmatrix.jpg differ diff --git a/api/pictures/pdpdevmatrix.png b/api/pictures/pdpdevmatrix.png new file mode 100644 index 0000000..30cdc71 Binary files /dev/null and b/api/pictures/pdpdevmatrix.png differ diff --git a/api/scripts/consoleterm.min.js b/api/scripts/consoleterm.min.js new file mode 100644 index 0000000..568b357 --- /dev/null +++ b/api/scripts/consoleterm.min.js @@ -0,0 +1,86 @@ +export {*} +function showdevconsole(){ +if(document.getElementById('console')=null){document.body.innerHTML += '
+console.log= function(tolog){termshow('&infg&span color="grey"&supd&LOG: '+tolog+'&infg&/span&supd&')} +console.error= function(tolog){termshow('&infg&span color="red"&supd&ERROR: '+tolog+'&infg&/span&supd&')} +console.warn= function(tolog){termshow('&infg&span color="orange"&supd&WARN: '+tolog+'&infg&/span&supd&')} +function consoleloop(){ + let x= terminput('') + termshow('executing : '+x+' ...') + try{ + let nfunc = new Function(x) + termshow(nfunc()) + }catch(e){ + termshow('error: '+e) + } +} +document.getElementById('console').innerHTML = ` + + +
+
+
+ +
+ + + + +` +} diff --git a/api/scripts/gameStorage.js b/api/scripts/gameStorage.js new file mode 100644 index 0000000..86ab5d9 --- /dev/null +++ b/api/scripts/gameStorage.js @@ -0,0 +1,37 @@ +Object.prototype.itemSetJSON= function (name, value){ + this[name]=value +} +Object.prototype.itemGetJSON = function(name){ + return this[name] +} +function getGameStorage(){ + return JSON.parse(localStorage['games']) +} +function getGameStorageByName(name){ + return JSON.parse(localStorage['games'])[name] +} +function setGameStorage(gamedatas){ + localStorage['games'] = JSON.stringify(gamedatas) +} +function setGameStorageByName(name, namedatas){ + let cgamestorage = JSON.parse(localStorage['games']) + cgamestorage[name]=namedatas + localStorage['games'] = JSON.stringify(cgamestorage) +} +function getUSCPMStorage(){ + initstorage('uscpm') + return JSON.parse(localStorage['games'])['uscpm'] +} +function setUSCPMStorage(data){ + setGameStorageByName('uscpm', data) +} +function initstorage(name=null){ + if(localStorage['games']==undefined){ + setGameStorage({}) + } + if(name !=null){ + if(getGameStorageByName(name)==undefined){ + setGameStorageByName(name, {}) + } + } +} diff --git a/api/scripts/main.js b/api/scripts/main.js new file mode 100644 index 0000000..589e6c9 --- /dev/null +++ b/api/scripts/main.js @@ -0,0 +1,195 @@ +var getfooter = ` +
+ + +
+
+

Copyright © 2023- + | GZod01

+ +
+ +` +var getheader = ` + Accueil + Jeux + Services + Projets + Me contacter + Plan Du Site + A Propos + Mentions Légales + + + +` + + +function barresponsivefunction(){ + var x = document.getElementById("headernavbar"); + if (x.className === "nav") { + x.className += " responsive"; +   } else { + x.className = "nav"; + } +} +function getpartials(){ + // Bug with the fetch to api.gzod01.fr/parts/... TODO + // let default_header = document.createElement('header') + // let getheader = fetch('//api.gzod01.fr/parts/header.html').then(function (response) { + // // The API call was successful! + // return response.text(); + // }).then(function (html) { + // let parser = new DOMParser(); + // let doc = parser.parseFromString(html, 'text/html'); + // return doc + // }).catch(function (err) { + // console.warn('Something went wrong.', err); + // }); + // default_header.appendChild(getheader) + // let default_footer = document.createElement('footer') + // let getfooter = fetch('//api.gzod01.fr/parts/footer.html').then(function (response) { + // // The API call was successful! + // return response.text(); + // }).then(function (html) { + // let parser = new DOMParser(); + // let doc = parser.parseFromString(html, 'text/html'); + // return doc + // }).catch(function (err) { + // console.warn('Something went wrong.', err); + // }); + // default_footer.appendChild(getfooter) + let default_header = document.createElement('header') + let default_footer = document.createElement('footer') + default_header.innerHTML = getheader + default_header.className = 'nav' + default_header.id = 'headernavbar' + default_footer.innerHTML = getfooter + document.getElementById('header').replaceWith(default_header) + document.getElementById('footer').replaceWith(default_footer) +} +function mainscript(){ + getpartials() + gettheme() + cookiepopup() + checkProtocol() + document.head.innerHTML = document.head.innerHTML + '' +} +window.onload = ()=>{mainscript()} +function gettheme(){ + if(localStorage.getItem('colorscheme')==='dark'){ + var colorScheme = 'dark' + } + else if(localStorage.getItem('colorscheme')==='light'){ + var colorScheme = 'light' + } + else if(localStorage.getItem('colorscheme')==='matrix'){ + var colorScheme = 'matrix' + } + else{ + var colorScheme = getComputedStyle(document.body,':after').content + if(colorScheme==='"dark"'){colorScheme='dark'} + else if(colorScheme==='"light"'){colorScheme='light'} + else{colorScheme='light'} + } + let r = document.querySelector(':root') + if(colorScheme==='dark'){ + r.style.setProperty('--main-bg-color','midnightblue') + r.style.setProperty('--main-txt-color','white') + r.style.setProperty('--scdr-bg-color','darkslateblue') + } + else if(colorScheme==='light'){ + r.style.setProperty('--main-bg-color','white') + r.style.setProperty('--main-txt-color','black') + r.style.setProperty('--scdr-bg-color','lightgray ') + } + else if(colorScheme==='matrix'){ + r.style.setProperty('--main-bg-color','#000') + r.style.setProperty('--main-txt-color','lime') + r.style.setProperty('--scdr-bg-color','#111') + } + +} +function switchtheme(){ + let r = document.querySelector(':root') + if('white'===r.style.getPropertyValue('--main-txt-color')){ + localStorage.setItem('colorscheme','light') + gettheme() + } + else if('black'===r.style.getPropertyValue('--main-txt-color')){ + localStorage.setItem('colorscheme','dark') + gettheme() + } + else{ + localStorage.setItem('colorscheme','light') + gettheme() + } +} + +function cookiepopup(){ + if(localStorage.getItem('cookieaccepted')==null){ + let cookieparentdiv = document.createElement('div') + cookieparentdiv.style.backgroundColor= 'rgba(0,0,0,0.5)' + cookieparentdiv.style.setProperty('backdrop-filter','blur(5px)') + cookieparentdiv.style.width = '100%' + cookieparentdiv.style.height= '100%' + cookieparentdiv.style.position='fixed' + cookieparentdiv.id='cookiepopup' + let cookiediv = document.createElement('div') + cookiediv.className= 'reallycentered' + cookiediv.id = 'cookiepopup' + cookiediv.style.backgroundColor = 'var(--scdr-bg-color)' + cookiediv.style.border = 'solid 2px var(--scdr-txt-color)' + cookiediv.innerHTML= '

Ce site utilise des "Cookies" (principalement le localStorage) pour fonctionner (theme de couleurs, données des jeux, etc.).

Afin que ce site fonctionne vous devez donc accepter les cookies, si vous avez une question sur l\'utilisation des cookies vous pouvez consulter les Mentions Légales(contenant aussi la politique de confidentialité).


' + cookieparentdiv.appendChild(cookiediv) + document.body.appendChild(cookieparentdiv) + console.log('do') + } +} +class CurrentTime extends HTMLElement { + connectedCallback() { + let date = new Date() + let type = this.getAttribute('type').toLowerCase() + if(type==='year'){ + this.innerHTML=date.getFullYear() + } else if(type==='fulldate'){ + this.innerHTML=date.getDay()+'/'+date.getMonth()+'/'+date.getFullYear() + } + else if(type==='full'){this.innerHTML=date.getHours()+':'+date.getMinutes()+':'+date.getSeconds()+' '+date.getDay()+'/'+date.getMonth()+'/'+date.getFullYear()} + else{this.innerHTML = 'YOU HAVE TO SET THE TYPE ATTRIBUTE TO ONE OF THESE VALUE: YEAR : IT WILL DISPLAY THE CURRENT YEAR ; FULLDATE : IT WILL DISPLAY THE CURRENT DATE (day/month/year) ; FULL : IT WILL DISPLAY tHE FULL CURRENT DATE AND HOUR (hour:minute:seconds day/month/year) ; THERE WILL BE OTHER TYPE IN THE FUTURE'} + } +} +customElements.define("current-time", CurrentTime); +function text(url) { + return fetch(url).then(res => res.text()); +} +function checkProtocol(){ + if(localStorage['dangerous']==='OK'){ + } + else if(location.protocol==='http:'){ + let a = document.querySelector('.content').innerHTML + document.querySelector('.content').innerHTML = '
Bonjour, Une nouvelle version plus sécurisée du site est disponible (version https).
OU ' + } +} + +// BETA OF FETCH DON'T VERY WORK: +//await toawaithtml(url) return the html in the url +//so: +async function fetchhtml(url){ + let result = await text(url) + let parser = new DOMParser() + let finalresult= await parser.parseFromString(result, 'text/html') + return finalresult +} +html =(url,result)=> fetchhtml(url).then(res=>result = res) + diff --git a/api/scripts/old.main.js b/api/scripts/old.main.js new file mode 100644 index 0000000..9cc0cf7 --- /dev/null +++ b/api/scripts/old.main.js @@ -0,0 +1,56 @@ +let inactivityTime = function() { + let time; + window.onload = resetTimer; + document.onmousemove = resetTimer; + document.onkeypress = resetTimer; + function resetTimer() { + clearTimeout(time); + time = setTimeout(matrix, 2000) + } +}; +window.onload = function() { + inactivityTime(); +} + + +function matrix(){ + let canvasnodecreation = document.createElement('canvas') + document.body.innerHTML='' + document.body.appendChild(canvasnodecreation) + var canvas = document.querySelector('canvas'), + ctx = canvas.getContext('2d'); + + canvas.width = window.innerWidth; + canvas.height = window.innerHeight; + + var letters = '010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101'; + letters = letters.split(''); + + + var fontSize = 10, + columns = canvas.width / fontSize; + + + var drops = []; + for (var i = 0; i < columns; i++) { + drops[i] = 1; + } + + + function draw() { + ctx.fillStyle = 'rgba(0, 0, 0, .1)'; + ctx.fillRect(0, 0, canvas.width, canvas.height); + for (var i = 0; i < drops.length; i++) { + var text = letters[Math.floor(Math.random() * letters.length)]; + ctx.fillStyle = '#0f0'; + ctx.fillText(text, i * fontSize, drops[i] * fontSize); + drops[i]++; + if (drops[i] * fontSize > canvas.height && Math.random() > .95) { + drops[i] = 0; + } + } + } + + + setInterval(draw, 33); +} diff --git a/api/scripts/termapi.js b/api/scripts/termapi.js new file mode 100644 index 0000000..688dd10 --- /dev/null +++ b/api/scripts/termapi.js @@ -0,0 +1,200 @@ +// TERM API BY GZOD01 (FROM CYBERTERMHACK BY GZOD01) +const clog = console.log +const cwarn = console.warn +const cerror = console.error +const cclear = console.clear +console.log = function(str){if(devmodeenabled){termshowhtml('JS-LOG: '+str+' ');}clog(str)} +console.warn = function(str){if(devmodeenabled){termshowhtml('JS-WARN: '+str+' ')}cwarn(str)} +console.error = function(str){if(devmodeenabled){termshowhtml('JS-ERROR: '+str+' ')}cerror(str)} +console.clear = function(){if(devmodeenabled){let l = document.querySelectorAll('#console'); for(let i=0; i canvas.height && Math.random() > .95) { + drops[i] = 0; + } + } + } + + + setInterval(draw, 33); +} +// END OF MATRIX CODE + +// function like the time.sleep in python +function sleep(s) { + let ms = s*1000 + return new Promise(resolve => setTimeout(resolve, ms)); +} +// function like random.choice() in python +function randchoice(list){ + console.log(list[randint(0,list.length-1)]) + return list[randint(0,list.length-1)] +} + +// TODO : var historic = [] + +// lastx = the last input do (the input you get when you press up arrow) to replace with an historic +var lastx = "" + +// the function to execute when up arrow pressed +function historic(){ + // TODO : terminpt.value=historic[historic.lengh-1-index] + document.getElementById('terminpt').value = lastx // to replace with an historic (line above) , set the input value (content) to the last input executed +} +// when a key is down +onkeydown = function(e){ + // if the key is the tab key (keyCode 9) + if(e.keyCode==9){ + // execute the autocomplete function + autocomplete() + } +} +// when a key is up +onkeyup = function(e){ + // if the key is enter key (keyCode 13) + if(e.keyCode==13){ + // set the inputcomplete variable to true to inform the terminput function that the user press enter + inputcomplete = true + } + // if the input is up arrow key (keyCode 38) + else if(e.keyCode == 38){ + // execute the historic function + historic() + } +} +// function like the print() function in python, add the text to the #termcontent div +function termshowhtml(str){ + let tc = document.getElementById('termcontent') + let nchild = document.createElement('div') + nchild.innerHTML = str + tc.appendChild(nchild) + document.getElementById('termcontent').scrollTo(0,document.getElementById('termcontent').scrollHeight) +} +function termshow(str){ + str = str.replace('<','<') + str= str.replace('>','>') + str= str.replace('&infg&','<') + str = str.replace('&supd&','>') + termshowhtml(str.replace('\n','
')) +} +// the input() function of python, check if the input is complete (see the inputcomplete variable and the onkeyup (e.keyCode == 13) execution +function terminput(str){ + let tiname = document.getElementById('inptname') + tiname.innerHTML = str + let inpt = document.getElementById('terminpt') + if(inputcomplete){ + console.log(inpt.value) + inputcomplete=false + let resultat = inpt.value + inpt.value = '' + return resultat + } + else{ + //return 'ERR' if the input isn't complete + return 'ERR' + } +} +// replace this list with the list of your commands +var list_of_command = ['ls','ssh','pbk','exit','theme','matrix','hack','attack','save','import','help','exit'] +// autocomplete when tab press show all the command starting with the value in your input +function autocomplete(){ + let inptval = document.getElementById('terminpt').value + termshow('List of available commands starting with " '+inptval+' " :') + for(let i = 0; i + + + + + + + + + ${titleofdoc} + + + +
+ ${docstr} +
+ + + + ` + return toreturn +} +function transform() {document.querySelector(':root').innerHTML = transformpage(document.getElementById('content'),document.title)} +window.onload = () =>{transform()}