79 lines
2.3 KiB
JavaScript
79 lines
2.3 KiB
JavaScript
let code = document.getElementById('code')
|
|
let raw = []
|
|
let els = []
|
|
|
|
const SOURCES = [
|
|
'./assets/sources/index.css',
|
|
'./assets/sources/index.html',
|
|
'./assets/sources/index.js',
|
|
'./assets/sources/x-proto-dns.sh',
|
|
]
|
|
|
|
hljs.configure({
|
|
languages: ['javascript', 'css', 'html', 'bash'],
|
|
ignoreUnescapedHTML: true
|
|
})
|
|
|
|
let highlight = () => {
|
|
document.querySelectorAll('pre').forEach(el => {
|
|
hljs.highlightElement(el)
|
|
})
|
|
}
|
|
|
|
let spawn = () => {
|
|
els.forEach(el => {
|
|
if (Math.random() < 0.3) el.remove()
|
|
})
|
|
|
|
let spawned = document.createElement('pre')
|
|
let source = raw[Math.floor(Math.random() * raw.length)]
|
|
let start = Math.floor(Math.random() * source.length)
|
|
let length = 250
|
|
let end = start + length
|
|
let text = source.substring(start, end)
|
|
spawned.innerText = text
|
|
code.appendChild(spawned)
|
|
|
|
let x = Math.random() * (window.innerWidth - 500)
|
|
let y = Math.random() * (window.innerHeight - 400)
|
|
spawned.style.left = x + 'px'
|
|
spawned.style.top = (2 * y + 500) + 'px'
|
|
spawned.style.width = '500px'
|
|
spawned.style.height = '100px'
|
|
spawned.style.textWrap = 'wrap'
|
|
spawned.style.opacity = 0.5
|
|
spawned.style.background = 'black'
|
|
spawned.style.position = 'absolute'
|
|
spawned.style.overflow = 'hidden'
|
|
|
|
highlight()
|
|
els.push(spawned)
|
|
setTimeout(spawn, 100)
|
|
}
|
|
|
|
let init = async () => {
|
|
for (let source of SOURCES) {
|
|
let res1 = await fetch(source)
|
|
let text1 = await res1.text()
|
|
let formatted = text1.replace(/\n/g, '')
|
|
raw.push(formatted);
|
|
}
|
|
}
|
|
|
|
init().then(spawn)
|
|
|
|
let quakeInstructions = () => {
|
|
alert(
|
|
'Here are the steps to follow to join QuakeJS multiplayer (while at school):\n\n' +
|
|
'1. Check your WiFi settings and connect to the "Gas Leak" network. If you don\'t see this network, there\'s probably no game to join.\n' +
|
|
'2. The password to the "Gas Leak" network is "fish_tony" (disable any VPNs before connecting).\n' +
|
|
'3. Navigate to http://192.168.50.123 on your browser (or close this dialog).\n' +
|
|
'4. Click esc and configure settings (try SETUP > PLAYER to rename).\n' +
|
|
'5. Leave arena and click MULTIPLAYER.\n' +
|
|
'6. Click SPECIFY and type in 192.168.50.123 as the address.\n' +
|
|
'7. Leave the port unchanged and join the game.\n' +
|
|
'8. Use "t" to chat.\n\n' +
|
|
'Happy fragging!'
|
|
)
|
|
window.location.href = 'http://192.168.50.123'
|
|
}
|