gallium-workshop/public/index.js

80 lines
2.3 KiB
JavaScript
Raw Normal View History

2023-09-02 20:50:42 -07:00
let code = document.getElementById('code')
let raw = []
let els = []
const SOURCES = [
2023-10-12 19:18:30 -07:00
'./assets/sources/index.css',
'./assets/sources/index.html',
'./assets/sources/index.js',
'./assets/sources/x-proto-dns.sh',
2023-09-02 20:50:42 -07:00
]
hljs.configure({
2023-10-12 19:18:30 -07:00
languages: ['javascript', 'css', 'html', 'bash'],
2023-09-02 20:50:42 -07:00
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'
2023-10-12 19:18:30 -07:00
spawned.style.top = (2 * y + 500) + 'px'
2023-09-02 20:50:42 -07:00
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) {
2023-10-12 19:18:30 -07:00
let res1 = await fetch(source)
let text1 = await res1.text()
let formatted = text1.replace(/\n/g, '')
2023-09-02 20:50:42 -07:00
raw.push(formatted);
}
}
init().then(spawn)
2023-10-12 19:18:30 -07:00
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'
}