some cleaning and made all pages work

box-drawing
Ondřej Hruška 7 years ago
parent d63271714c
commit da12d4e7ee
  1. 23
      js/appcommon.js
  2. 8
      js/demo.js
  3. 10
      js/index.js
  4. 13
      js/utils.js
  5. 5
      pages/_cfg_menu.php

@ -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')

@ -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')) {

@ -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

@ -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')

@ -13,8 +13,3 @@
}
?>
</nav>
<script>
function menuOpen() { $('#menu').toggleClass('expanded') }
$('#brand').on('click', menuOpen).on('keypress', cr(menuOpen));
</script>

Loading…
Cancel
Save