// 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