ESPTerm web interface submodule, separated to make testing and development easier
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
espterm-front-end/jssrc/term.js

50 lines
1.4 KiB

/** Init the terminal sub-module - called from HTML */
window.termInit = function (labels, theme) {
Conn.init()
Input.init()
TermUpl.init()
const screen = new window.TermScreen()
let didNotifyAboutScreen = false
Object.defineProperty(window, 'Screen', {
get () {
if (!didNotifyAboutScreen) {
console.warn('Use local variables instead of window.Screen')
didNotifyAboutScreen = true
}
return screen
}
})
qs('#screen').appendChild(screen.canvas)
screen.load(labels, theme) // load labels and theme
{
let fitScreen = false
let fitScreenIfNeeded = function fitScreenIfNeeded () {
screen.window.fitIntoWidth = fitScreen ? window.innerWidth - 20 : 0
screen.window.fitIntoHeight = fitScreen ? window.innerHeight : 0
}
fitScreenIfNeeded()
window.addEventListener('resize', fitScreenIfNeeded)
window.toggleFitScreen = function () {
fitScreen = !fitScreen
const resizeButtonIcon = qs('#resize-button-icon')
if (fitScreen) {
resizeButtonIcon.classList.remove('icn-resize-small')
resizeButtonIcon.classList.add('icn-resize-full')
} else {
resizeButtonIcon.classList.remove('icn-resize-full')
resizeButtonIcon.classList.add('icn-resize-small')
}
fitScreenIfNeeded()
}
}
window.initSoftKeyboard(screen)
if (window.attachDebugScreen) window.attachDebugScreen(screen)
window.termScreen = screen // for debugging
}