From 2f0d0187a130be0a1a224b9f148a024956e9866d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?=
${errorMsg}
at ${file}:${line}:${col}`, 10000, true)
+ return false
+ }
qs('#screen').appendChild(screen.canvas)
screen.load(labels, theme) // load labels and theme
@@ -23,7 +29,7 @@ window.termInit = function (labels, theme) {
fitScreenIfNeeded()
window.addEventListener('resize', fitScreenIfNeeded)
- window.toggleFitScreen = function () {
+ let toggleFitScreen = function () {
fitScreen = !fitScreen
const resizeButtonIcon = qs('#resize-button-icon')
if (fitScreen) {
@@ -35,6 +41,11 @@ window.termInit = function (labels, theme) {
}
fitScreenIfNeeded()
}
+
+ qs('#term-fit-screen').addEventListener('click', function () {
+ toggleFitScreen()
+ return false
+ })
}
window.initSoftKeyboard(screen, input)
diff --git a/js/term_upload.js b/js/term_upload.js
index 0c188f2..c010c55 100644
--- a/js/term_upload.js
+++ b/js/term_upload.js
@@ -12,25 +12,25 @@ window.TermUpl = function (conn, input) {
// sending a super-ling string through the socket is not a good idea
const MAX_LINE_LEN = 128
- function fuOpen () {
- fuStatus('Ready...')
- Modal.show('#fu_modal', onClose)
+ function openUploadDialog () {
+ updateStatus('Ready...')
+ Modal.show('#fu_modal', onDialogClose)
$('#fu_form').toggleClass('busy', false)
input.blockKeys(true)
}
- function onClose () {
+ function onDialogClose () {
console.log('Upload modal closed.')
clearTimeout(fuTout)
line_i = 0
input.blockKeys(false)
}
- function fuStatus (msg) {
+ function updateStatus (msg) {
qs('#fu_prog').textContent = msg
}
- function fuSend () {
+ function startUpload () {
let v = qs('#fu_text').value
if (!v.length) {
fuClose()
@@ -55,11 +55,11 @@ window.TermUpl = function (conn, input) {
}[qs('#fu_crlf').value]
$('#fu_form').toggleClass('busy', true)
- fuStatus('Starting...')
- fuSendLine()
+ updateStatus('Starting...')
+ uploadLine()
}
- function fuSendLine () {
+ function uploadLine () {
if (!$('#fu_modal').hasClass('visible')) {
// Modal is closed, cancel
return
@@ -67,7 +67,7 @@ window.TermUpl = function (conn, input) {
if (!conn.canSend()) {
// postpone
- fuTout = setTimeout(fuSendLine, 1)
+ fuTout = setTimeout(uploadLine, 1)
return
}
@@ -85,16 +85,16 @@ window.TermUpl = function (conn, input) {
}
if (!input.sendString(chunk)) {
- fuStatus('FAILED!')
+ updateStatus('FAILED!')
return
}
let all = lines.length
- fuStatus(line_i + ' / ' + all + ' (' + (Math.round((line_i / all) * 1000) / 10) + '%)')
+ updateStatus(line_i + ' / ' + all + ' (' + (Math.round((line_i / all) * 1000) / 10) + '%)')
if (lines.length > line_i || inline_pos > 0) {
- fuTout = setTimeout(fuSendLine, send_delay_ms)
+ fuTout = setTimeout(uploadLine, send_delay_ms)
} else {
closeWhenReady()
}
@@ -103,10 +103,10 @@ window.TermUpl = function (conn, input) {
function closeWhenReady () {
if (!conn.canSend()) {
// stuck in XOFF still, wait to process...
- fuStatus('Waiting for Tx buffer...')
+ updateStatus('Waiting for Tx buffer...')
setTimeout(closeWhenReady, 100)
} else {
- fuStatus('Done.')
+ updateStatus('Done.')
// delay to show it
setTimeout(function () {
fuClose()
@@ -138,9 +138,21 @@ window.TermUpl = function (conn, input) {
console.log('Loading file...')
reader.readAsText(file)
}, false)
- },
- close: fuClose,
- start: fuSend,
- open: fuOpen
+
+ qs('#term-fu-open').addEventListener('click', function () {
+ openUploadDialog()
+ return false
+ })
+
+ qs('#term-fu-start').addEventListener('click', function () {
+ startUpload()
+ return false
+ })
+
+ qs('#term-fu-close').addEventListener('click', function () {
+ fuClose()
+ return false
+ })
+ }
}
}
diff --git a/pages/term.php b/pages/term.php
index 85de910..16130c8 100644
--- a/pages/term.php
+++ b/pages/term.php
@@ -33,8 +33,8 @@