parent
dd0c3f22d3
commit
5b6fcee7f6
2 changed files with 51 additions and 2 deletions
|
@ -24,7 +24,7 @@
|
|||
<pmui-playscreen id="play-screen" style="display: none;"></pmui-playscreen>
|
||||
<pmui-keybindsscreen id="keybinds-screen" style="display: none;"></pmui-keybindsscreen>
|
||||
<pmui-optionsscreen id="options-screen" style="display: none;"></pmui-optionsscreen>
|
||||
<pmui-titlescreen id="title-screen" style="display: block;"></pmui-titlescreen>
|
||||
<pmui-titlescreen id="title-screen" style="display: none;"></pmui-titlescreen>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
49
index.js
49
index.js
|
@ -401,4 +401,53 @@ async function connect (options) {
|
|||
}, 2500)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {URLSearchParams} params
|
||||
*/
|
||||
async function fromTheOutside (params, addr) {
|
||||
const opts = {}
|
||||
const dfltConfig = await (await window.fetch('config.json')).json()
|
||||
|
||||
let server, port, proxy, proxyPort
|
||||
|
||||
if (address.includes(':')) {
|
||||
const s = address.split(':')
|
||||
server = s[0]
|
||||
port = Number(s[1]) || 25565
|
||||
} else {
|
||||
server = address
|
||||
port = Number(params.get('port')) || 25565
|
||||
}
|
||||
|
||||
const proxyAddr = params.get('proxy')
|
||||
if (proxyAddr) {
|
||||
const s = proxyAddr.split(':')
|
||||
proxy = s[0]
|
||||
proxyPort = Number(s[1] ?? 'NaN') || 22
|
||||
} else {
|
||||
proxy = dfltConfig.defaultProxy
|
||||
proxyPort = !dfltConfig.defaultProxy && !dfltConfig.defaultProxyPort ? '' : dfltConfig.defaultProxyPort ?? 443
|
||||
}
|
||||
|
||||
opts.server = `${server}:${port}`
|
||||
opts.proxy = `${proxy}:${proxyPort}`
|
||||
opts.username = params.get('username') ?? `pviewer${Math.floor(Math.random() * 1000)}`
|
||||
opts.password = params.get('password') ?? ''
|
||||
opts.botVersion = params.get('version') ?? false
|
||||
|
||||
console.log(opts)
|
||||
|
||||
showEl('loading-screen')
|
||||
removePanorama()
|
||||
connect(opts)
|
||||
}
|
||||
|
||||
const params = new URLSearchParams(window.location.search)
|
||||
let address
|
||||
if ((address = params.get('address'))) {
|
||||
fromTheOutside(params, address)
|
||||
} else {
|
||||
showEl('title-screen')
|
||||
main()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue