Merge branch 'canvas-babel' into canvas

cpsdqs/unified-input
Ondřej Hruška 7 years ago
commit c07a6162f2
  1. 18
      .babelrc
  2. 28
      build.sh
  3. 4
      jssrc/appcommon.js
  4. 3
      jssrc/lib/keymaster.js
  5. 14
      jssrc/term_screen.js
  6. 2
      jssrc/utils.js
  7. 2
      jssrc/wifi.js
  8. 3
      package.json
  9. 2
      pages/_head.php
  10. 884
      yarn.lock

@ -0,0 +1,18 @@
{
"presets": [
["env", {
"targets": {
"browsers": [
"last 2 versions",
"> 4%",
"ie 11",
"safari 8",
"android 4.4"
]
}
}],
["minify", {
"mergeVars": false
}]
]
}

@ -1,21 +1,19 @@
#!/bin/bash #!/bin/bash
echo 'Packing JS...' echo 'Packing JS...'
npm run babel -- -o js/app.js --source-maps jssrc/lib \
echo ';' > ';' jssrc/lib/chibi.js \
cat jssrc/lib/chibi.js ';' \ jssrc/lib/keymaster.js \
jssrc/lib/keymaster.js ';' \ jssrc/lib/polyfills.js \
jssrc/lib/polyfills.js ';' \ jssrc/utils.js \
jssrc/utils.js ';' \ jssrc/modal.js \
jssrc/modal.js ';' \ jssrc/notif.js \
jssrc/notif.js ';' \ jssrc/appcommon.js \
jssrc/appcommon.js ';' \ jssrc/lang.js \
jssrc/lang.js ';' \ jssrc/wifi.js \
jssrc/wifi.js ';' \ jssrc/term_* \
jssrc/term_* ';' \ jssrc/term.js \
jssrc/term.js ';' \ jssrc/soft_keyboard.js
jssrc/soft_keyboard.js | npm run --silent minify > js/app.js
rm ';'
echo 'Building CSS...' echo 'Building CSS...'

@ -58,8 +58,8 @@ $.ready(function () {
val -= step val -= step
} }
if (typeof min != 'undefined') val = Math.max(val, +min) if (undef(min)) val = Math.max(val, +min)
if (typeof max != 'undefined') val = Math.min(val, +max) if (undef(max)) val = Math.min(val, +max)
$this.val(val) $this.val(val)
if ('createEvent' in document) { if ('createEvent' in document) {

@ -307,4 +307,5 @@
if(typeof module !== 'undefined') module.exports = assignKey; if(typeof module !== 'undefined') module.exports = assignKey;
})(this); })(window);

@ -69,7 +69,7 @@ for (let gray = 0; gray < 24; gray++) {
class TermScreen { class TermScreen {
constructor () { constructor () {
this.canvas = document.createElement('canvas') this.canvas = mk('canvas')
this.ctx = this.canvas.getContext('2d') this.ctx = this.canvas.getContext('2d')
if ('AudioContext' in window || 'webkitAudioContext' in window) { if ('AudioContext' in window || 'webkitAudioContext' in window) {
@ -587,7 +587,7 @@ class TermScreen {
let selectedText = this.getSelectedText() let selectedText = this.getSelectedText()
// don't copy anything if nothing is selected // don't copy anything if nothing is selected
if (!selectedText) return if (!selectedText) return
let textarea = document.createElement('textarea') let textarea = mk('textarea')
document.body.appendChild(textarea) document.body.appendChild(textarea)
textarea.value = selectedText textarea.value = selectedText
textarea.select() textarea.select()
@ -717,10 +717,10 @@ class TermScreen {
const FONT_MASK = 0b101 const FONT_MASK = 0b101
// Map of (attrs & FONT_MASK) -> Array of cell indices // Map of (attrs & FONT_MASK) -> Array of cell indices
const fontGroups = new Map() let fontGroups = new Map()
// Map of (cell index) -> boolean, whether or not a cell has updated // Map of (cell index) -> boolean, whether or not a cell has updated
const updateMap = new Map() let updateMap = new Map()
for (let cell = 0; cell < screenLength; cell++) { for (let cell = 0; cell < screenLength; cell++) {
let x = cell % width let x = cell % width
@ -994,9 +994,7 @@ class TermScreen {
this.screenAttrs = new Array(screenLength).fill(' ') this.screenAttrs = new Array(screenLength).fill(' ')
} }
let strArray = typeof Array.from !== 'undefined' let strArray = !undef(Array.from) ? Array.from(str) : str.split('')
? Array.from(str)
: str.split('')
const MASK_LINE_ATTR = 0xC8 const MASK_LINE_ATTR = 0xC8
const MASK_BLINK = 1 << 4 const MASK_BLINK = 1 << 4
@ -1084,7 +1082,7 @@ class TermScreen {
let label = pieces[i + 1].trim() let label = pieces[i + 1].trim()
// if empty string, use the "dim" effect and put nbsp instead to // if empty string, use the "dim" effect and put nbsp instead to
// stretch the button vertically // stretch the button vertically
button.innerHTML = label ? e(label) : '&nbsp;' button.innerHTML = label ? esc(label) : '&nbsp;'
button.style.opacity = label ? 1 : 0.2 button.style.opacity = label ? 1 : 0.2
}) })
} }

@ -73,7 +73,7 @@ Math.log10 = Math.log10 || function (x) {
} }
/** HTML escape */ /** HTML escape */
function e (str) { function esc (str) {
return $.htmlEscape(str) return $.htmlEscape(str)
} }

@ -15,7 +15,7 @@
$('#sta-nw').toggleClass('hidden', name.length === 0) $('#sta-nw').toggleClass('hidden', name.length === 0)
$('#sta-nw-nil').toggleClass('hidden', name.length > 0) $('#sta-nw-nil').toggleClass('hidden', name.length > 0)
$('#sta-nw .essid').html(e(name)) $('#sta-nw .essid').html(esc(name))
const nopw = undef(password) || password.length === 0 const nopw = undef(password) || password.length === 0
$('#sta-nw .passwd').toggleClass('hidden', nopw) $('#sta-nw .passwd').toggleClass('hidden', nopw)
$('#sta-nw .nopasswd').toggleClass('hidden', !nopw) $('#sta-nw .nopasswd').toggleClass('hidden', !nopw)

@ -4,11 +4,14 @@
"description": "ESPTerm web interface", "description": "ESPTerm web interface",
"license": "MPL-2.0", "license": "MPL-2.0",
"devDependencies": { "devDependencies": {
"babel-cli": "^6.26.0",
"babel-minify": "^0.2.0", "babel-minify": "^0.2.0",
"babel-preset-env": "^1.6.0",
"node-sass": "^4.5.3", "node-sass": "^4.5.3",
"standard": "^10.0.3" "standard": "^10.0.3"
}, },
"scripts": { "scripts": {
"babel": "babel $@",
"minify": "babel-minify $@", "minify": "babel-minify $@",
"sass": "node-sass $@" "sass": "node-sass $@"
} }

@ -11,7 +11,7 @@
var _root = <?= JS_WEB_ROOT ?>; var _root = <?= JS_WEB_ROOT ?>;
var _demo = <?= (int)ESP_DEMO ?>; var _demo = <?= (int)ESP_DEMO ?>;
<?php if($_GET['page']=='term'): ?>var _demo_screen = <?= ESP_DEMO ? DEMO_SCREEN : 0 ?>;<?php endif; ?> <?php if($_GET['page']=='term'): ?>var _demo_screen = <?= ESP_DEMO ? DEMO_SCREEN : 0 ?>;<?php endif; ?>
<?php if($_GET['page']=='cfg_wifi'): ?>var _demo_aps = <?= ESP_DEMO ? json_encode(DEMO_APS) : '' ?>;<?php endif; ?> <?php if($_GET['page']=='cfg_wifi'): ?>var _demo_aps = <?= ESP_DEMO ? json_encode(DEMO_APS) : '""' ?>;<?php endif; ?>
</script> </script>
</head> </head>
<body class="<?= $_GET['BODYCLASS'] ?>"> <body class="<?= $_GET['BODYCLASS'] ?>">

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save