2020-08-02 19:39:04 -04:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
const { ipcRenderer } = require('electron')
|
|
|
|
|
|
|
|
function setContent (content) {
|
|
|
|
const contentItem = document.getElementById('content')
|
|
|
|
|
|
|
|
contentItem.innerHTML = content
|
|
|
|
}
|
|
|
|
|
|
|
|
document.getElementById('connect').addEventListener('click', () => {
|
|
|
|
setContent('connecting...')
|
2021-01-29 19:21:03 -05:00
|
|
|
const authType = document.getElementById('type')
|
|
|
|
|
2020-08-02 19:39:04 -04:00
|
|
|
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
|
|
|
|
}
|
2021-01-29 19:21:03 -05:00
|
|
|
if (authType.value === 'Microsoft') {
|
|
|
|
data.auth = 'microsoft'
|
|
|
|
delete data.password
|
|
|
|
}
|
2020-08-02 19:39:04 -04:00
|
|
|
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()
|
|
|
|
})
|
|
|
|
|
2021-01-29 19:21:03 -05:00
|
|
|
window.onAuthTypeChange = function () {
|
|
|
|
const authType = document.getElementById('type')
|
|
|
|
console.log('set auth type to', authType)
|
|
|
|
}
|
|
|
|
|
2020-08-02 19:39:04 -04:00
|
|
|
ipcRenderer.on('content', (event, content) => {
|
|
|
|
setContent(content)
|
|
|
|
})
|