diff --git a/js/appcommon.js b/js/appcommon.js index e8226d9..4eaa827 100644 --- a/js/appcommon.js +++ b/js/appcommon.js @@ -1,23 +1,18 @@ const $ = require('./lib/chibi') -const { mk, qs } = require('./utils') +const { mk, qs, cr } = require('./utils') const modal = require('./modal') const notify = require('./notif') -/** - * Filter 'spacebar' and 'return' from keypress handler, - * and when they're pressed, fire the callback. - * use $(...).on('keypress', cr(handler)) - */ -function cr (hdl) { - return function (e) { - if (e.which === 10 || e.which === 13 || e.which === 32) { - hdl() - } - } -} - /** Global generic init */ $.ready(function () { + // Opening menu on mobile / narrow screen + function menuOpen () { + $('#menu').toggleClass('expanded') + } + $('#brand') + .on('click', menuOpen) + .on('keypress', cr(menuOpen)) + // Checkbox UI (checkbox CSS and hidden input with int value) $('.Row.checkbox').forEach(function (x) { let inp = x.querySelector('input') diff --git a/js/demo.js b/js/demo.js index 69f29e5..88811ba 100644 --- a/js/demo.js +++ b/js/demo.js @@ -175,7 +175,7 @@ class ScrollingTerminal { } } } - deleteChar () { + deleteChar () { // FIXME unused? this.moveBack() this.screen.splice((this.cursor.y + 1) * this.width, 0, [' ', TERM_DEFAULT_STYLE]) this.screen.splice(this.cursor.y * this.width + this.cursor.x, 1) @@ -197,11 +197,11 @@ class ScrollingTerminal { } else if (action === 'delete') { this.deleteForward(args[0]) } else if (action === 'insert-blanks') { - this.insertBlanks(args[0]) + this.insertBlanks(args[0]) // FIXME undefined? } else if (action === 'clear') { this.clear() } else if (action === 'bell') { - this.terminal.load('B') + this.terminal.load('B') // FIXME undefined? } else if (action === 'back') { this.moveBack() } else if (action === 'new-line') { @@ -566,7 +566,7 @@ let demoshIndex = { run (...args) { let steady = args.includes('--steady') if (args.includes('block')) { - this.emit('write', `\x1b[${0 + 2 * steady} q`) + this.emit('write', `\x1b[${2 * steady} q`) } else if (args.includes('line')) { this.emit('write', `\x1b[${3 + steady} q`) } else if (args.includes('bar') || args.includes('beam')) { diff --git a/js/index.js b/js/index.js index 9747bd5..5bd9f2e 100644 --- a/js/index.js +++ b/js/index.js @@ -4,4 +4,14 @@ require('./notif') require('./appcommon') try { require('./demo') } catch (err) {} require('./wifi') + +const $ = require('./lib/chibi') +const { qs, cr } = require('./utils') +const tr = require('./lang') + +/* Export stuff to the global scope for inline scripts */ window.termInit = require('./term') +window.$ = $ +window.tr = tr +window.qs = qs +window.cr = cr diff --git a/js/utils.js b/js/utils.js index 428a6cb..8c7a3a4 100755 --- a/js/utils.js +++ b/js/utils.js @@ -13,6 +13,19 @@ exports.qsa = function qsa (s) { return document.querySelectorAll(s) } +/** + * Filter 'spacebar' and 'return' from keypress handler, + * and when they're pressed, fire the callback. + * use $(...).on('keypress', cr(handler)) + */ +exports.cr = function cr (hdl) { + return function (e) { + if (e.which === 10 || e.which === 13 || e.which === 32) { + hdl() + } + } +} + /** Convert any to bool safely */ exports.bool = function bool (x) { return (x === 1 || x === '1' || x === true || x === 'true') diff --git a/pages/_cfg_menu.php b/pages/_cfg_menu.php index db01711..bf6afb0 100644 --- a/pages/_cfg_menu.php +++ b/pages/_cfg_menu.php @@ -13,8 +13,3 @@ } ?> - -