mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-12-20 12:32:26 -05:00
8f2a027812
* initial msa work * rm debug code * Update package.json * lint, seperate constants, create missing msa cache * support multiple profiles * lint * use shared constants * fix path issues * fix token variable * fix caching msa profile data * switch clientId to one from microsoft * store caches in .minecraft, fallback to dev code auth when user+pass fails * update electron demo, fix error handling, add docs * fix caching dir * fix lint * move to class scope, token fixes * retry on fail, terminology fixes * fix promise bug * cleanup
49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
'use strict'
|
|
|
|
const { ipcRenderer } = require('electron')
|
|
|
|
function setContent (content) {
|
|
const contentItem = document.getElementById('content')
|
|
|
|
contentItem.innerHTML = content
|
|
}
|
|
|
|
document.getElementById('connect').addEventListener('click', () => {
|
|
setContent('connecting...')
|
|
const authType = document.getElementById('type')
|
|
|
|
const data = {
|
|
host: document.getElementById('host').value,
|
|
port: parseInt(document.getElementById('port').value),
|
|
username: document.getElementById('username').value,
|
|
password: document.getElementById('password').value === '' ? undefined : document.getElementById('password').value
|
|
}
|
|
if (authType.value === 'Microsoft') {
|
|
data.auth = 'microsoft'
|
|
delete data.password
|
|
}
|
|
ipcRenderer.send('connect', data)
|
|
})
|
|
|
|
function chat () {
|
|
ipcRenderer.send('chat', document.getElementById('chat').value)
|
|
document.getElementById('chat').value = ''
|
|
}
|
|
document.getElementById('chat').addEventListener('keyup', function onEvent (e) {
|
|
if (e.keyCode === 13) {
|
|
chat()
|
|
}
|
|
})
|
|
|
|
document.getElementById('send').addEventListener('click', () => {
|
|
chat()
|
|
})
|
|
|
|
window.onAuthTypeChange = function () {
|
|
const authType = document.getElementById('type')
|
|
console.log('set auth type to', authType)
|
|
}
|
|
|
|
ipcRenderer.on('content', (event, content) => {
|
|
setContent(content)
|
|
})
|