|
@ -15,8 +15,46 @@ const socket = io(window.location.origin, { |
|
|
socket.on('connect', () => { |
|
|
socket.on('connect', () => { |
|
|
const term = new Terminal(); |
|
|
const term = new Terminal(); |
|
|
term.open(document.getElementById('terminal')); |
|
|
term.open(document.getElementById('terminal')); |
|
|
term.setOption('fontSize', 14); |
|
|
const defaultOptions = { fontSize: 14 }; |
|
|
|
|
|
let options: any; |
|
|
|
|
|
try { |
|
|
|
|
|
if (localStorage.options === undefined) { |
|
|
|
|
|
options = defaultOptions; |
|
|
|
|
|
} else { |
|
|
|
|
|
options = JSON.parse(localStorage.options); |
|
|
|
|
|
} |
|
|
|
|
|
} catch { |
|
|
|
|
|
options = defaultOptions; |
|
|
|
|
|
} |
|
|
|
|
|
Object.keys(options).forEach(key => { |
|
|
|
|
|
const value = options[key]; |
|
|
|
|
|
term.setOption(key, value); |
|
|
|
|
|
}); |
|
|
|
|
|
const code = JSON.stringify(options, null, 2); |
|
|
|
|
|
const editor = document.querySelector('#options .editor'); |
|
|
|
|
|
editor.value = code; |
|
|
|
|
|
editor.addEventListener('keyup', e => { |
|
|
|
|
|
try { |
|
|
|
|
|
const updated = JSON.parse(editor.value); |
|
|
|
|
|
const updatedCode = JSON.stringify(updated, null, 2); |
|
|
|
|
|
editor.value = updatedCode; |
|
|
|
|
|
editor.classList.remove('error'); |
|
|
|
|
|
localStorage.options = updatedCode; |
|
|
|
|
|
Object.keys(updated).forEach(key => { |
|
|
|
|
|
const value = updated[key]; |
|
|
|
|
|
term.setOption(key, value); |
|
|
|
|
|
}); |
|
|
|
|
|
resize(); |
|
|
|
|
|
} catch { |
|
|
|
|
|
// skip
|
|
|
|
|
|
editor.classList.add('error'); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
document.getElementById('overlay').style.display = 'none'; |
|
|
document.getElementById('overlay').style.display = 'none'; |
|
|
|
|
|
document.querySelector('#options .toggler').addEventListener('click', e => { |
|
|
|
|
|
document.getElementById('options').classList.toggle('opened'); |
|
|
|
|
|
e.preventDefault(); |
|
|
|
|
|
}); |
|
|
window.addEventListener('beforeunload', handler, false); |
|
|
window.addEventListener('beforeunload', handler, false); |
|
|
/* |
|
|
/* |
|
|
term.scrollPort_.screen_.setAttribute('contenteditable', 'false'); |
|
|
term.scrollPort_.screen_.setAttribute('contenteditable', 'false'); |
|
|