Merge branch 'canvas' of github.com:espterm/espterm-front-end into canvas

cpsdqs/unified-input
Ondřej Hruška 7 years ago
commit 23fe523412
  1. 9
      .eslintignore
  2. 2
      jssrc/term_input.js
  3. 4
      jssrc/term_screen.js
  4. 38
      jssrc/utils.js
  5. 7
      jssrc/wifi.js

@ -0,0 +1,9 @@
# possibly minified output
js
out
# libraries
jssrc/lib
# php generated file
jssrc/lang.js

@ -252,7 +252,7 @@ window.Input = (function () {
// Mouse events // Mouse events
onMouseMove: function (x, y) { onMouseMove: function (x, y) {
if (!opts.mt_move) return if (!opts.mt_move) return
const b = mb1 ? 1 : mb2 ? 2 : mb3 ? 3 : 0; const b = mb1 ? 1 : mb2 ? 2 : mb3 ? 3 : 0
const m = packModifiersForMouse() const m = packModifiersForMouse()
Conn.send('m' + encode2B(y) + encode2B(x) + encode2B(b) + encode2B(m)) Conn.send('m' + encode2B(y) + encode2B(x) + encode2B(b) + encode2B(m))
}, },

@ -47,9 +47,7 @@ const themes = [
// should not be used to look up 0-15 (will return transparent) // should not be used to look up 0-15 (will return transparent)
const colorTable256 = new Array(16).fill('rgba(0, 0, 0, 0)') const colorTable256 = new Array(16).fill('rgba(0, 0, 0, 0)')
{
// fill color table // fill color table
// colors 16-231 are a 6x6x6 color cube // colors 16-231 are a 6x6x6 color cube
for (let red = 0; red < 6; red++) { for (let red = 0; red < 6; red++) {
for (let green = 0; green < 6; green++) { for (let green = 0; green < 6; green++) {
@ -61,13 +59,11 @@ const colorTable256 = new Array(16).fill('rgba(0, 0, 0, 0)')
} }
} }
} }
// colors 232-255 are a grayscale ramp, sans black and white // colors 232-255 are a grayscale ramp, sans black and white
for (let gray = 0; gray < 24; gray++) { for (let gray = 0; gray < 24; gray++) {
let value = gray * 10 + 8 let value = gray * 10 + 8
colorTable256.push(`rgb(${value}, ${value}, ${value})`) colorTable256.push(`rgb(${value}, ${value}, ${value})`)
} }
}
class TermScreen { class TermScreen {
constructor () { constructor () {

@ -48,7 +48,7 @@ function extend (defaults, options) {
/** Escape string for use as literal in RegExp */ /** Escape string for use as literal in RegExp */
function rgxe (str) { function rgxe (str) {
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&') return str.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&')
} }
/** Format number to N decimal places, output as string */ /** Format number to N decimal places, output as string */
@ -72,42 +72,6 @@ Math.log10 = Math.log10 || function (x) {
return Math.log(x) / Math.LN10 return Math.log(x) / Math.LN10
} }
/**
* Perform a substitution in the given string.
*
* Arguments - array or list of replacements.
* Arguments numeric keys will replace {0}, {1} etc.
* Named keys also work, ie. {foo: "bar"} -> replaces {foo} with bar.
*
* Braces are added to keys if missing.
*
* @returns {String} result
*/
String.prototype.format = function () {
let out = this
let repl = arguments
if (arguments.length == 1 && (Array.isArray(arguments[0]) || typeof arguments[0] == 'object')) {
repl = arguments[0]
}
for (let ph in repl) {
if (repl.hasOwnProperty(ph)) {
const ph_orig = ph
if (!ph.match(/^\{.*\}$/)) {
ph = '{' + ph + '}'
}
// replace all occurrences
const pattern = new RegExp(rgxe(ph), 'g')
out = out.replace(pattern, repl[ph_orig])
}
}
return out
}
/** HTML escape */ /** HTML escape */
function e (str) { function e (str) {
return $.htmlEscape(str) return $.htmlEscape(str)

@ -82,10 +82,11 @@
} }
let inner = mk('div') let inner = mk('div')
let escapedSSID = $.htmlEscape(ap.essid)
$(inner).addClass('inner') $(inner).addClass('inner')
.htmlAppend('<div class="rssi">{0}</div>'.format(ap.rssi_perc)) .htmlAppend(`<div class="rssi">${ap.rssi_perc}</div>`)
.htmlAppend('<div class="essid" title="{0}">{0}</div>'.format($.htmlEscape(ap.essid))) .htmlAppend(`<div class="essid" title="${escapedSSID}">${escapedSSID}</div>`)
.htmlAppend('<div class="auth">{0}</div>'.format(authStr[ap.enc])) .htmlAppend(`<div class="auth">${authStr[ap.enc]}</div>`)
$item.on('click', function () { $item.on('click', function () {
let $th = $(this) let $th = $(this)

Loading…
Cancel
Save