use 0x01 for seps in labels string so users can use pipe if they want to

pull/111/merge
Ondřej Hruška 7 years ago
parent 4551ad6dbe
commit 0b3cfe0e74
  1. 3
      html_orig/_debug_replacements.php
  2. 2
      html_orig/js/app.js
  3. 2
      html_orig/jssrc/term.js
  4. 2
      html_orig/pages/term.php
  5. 16
      user/cgi_main.c
  6. 2
      user/screen.c

@ -6,13 +6,14 @@
* are given to JavaScript, to avoid syntax errors with %%
*/
return [
'%term_title%' => 'ESP8266 Wireless Terminal',
'%term_title%' => 'ESPTerm local debug',
'%btn1%' => '1',
'%btn2%' => '2',
'%btn3%' => '3',
'%btn4%' => '',
'%btn5%' => '5',
'%labels_seq%' => 'TESPTerm local debug1235',
'%screenData%' => '  HELLOx NRE3',//'\u000b\u0001\u001b\u0001\u0001\u0001\u0001\u0001\f\u0005\u0001\u0010\u0003HELLOx\u0002\u000b\u0001\u0001N\u0001RE\u00023\u0001', //,
/*'{

@ -1408,7 +1408,7 @@ var Screen = (function () {
}
function _load_labels(str) {
var pieces = str.split('|');
var pieces = str.split('\x01');
qs('h1').textContent = pieces[0];
qsa('#buttons button').forEach(function(x, i) {
var s = pieces[i+1].trim();

@ -216,7 +216,7 @@ var Screen = (function () {
}
function _load_labels(str) {
var pieces = str.split('|');
var pieces = str.split('\x01');
qs('h1').textContent = pieces[0];
qsa('#buttons button').forEach(function(x, i) {
var s = pieces[i+1].trim();

@ -32,7 +32,7 @@
</nav>
<!-- this avoids having to escape quotes for JSON -->
<span class="hidden" id="initial_data">T%term_title%|%btn1%|%btn2%|%btn3%|%btn4%|%btn5%</span>
<span class="hidden" id="initial_data">%labels_seq%</span>
<script>
try {

@ -22,24 +22,16 @@ httpd_cgi_state ICACHE_FLASH_ATTR tplScreen(HttpdConnData *connData, char *token
return HTTPD_CGI_DONE;
}
char buff[100];
char buff2[10];
char buff[150];
if (streq(token, "term_title")) {
httpdSend(connData, termconf_scratch.title, -1);
if (streq(token, "labels_seq")) {
screenSerializeLabelsToBuffer(buff, 150);
httpdSend(connData, buff, -1);
}
else if (streq(token, "theme")) {
sprintf(buff, "%d", termconf->theme);
httpdSend(connData, buff, -1);
}
else {
for (int i = 1; i <= 5; i++) {
sprintf(buff2, "btn%d", i);
if (streq(token, buff2)) {
httpdSend(connData, termconf_scratch.btn[i-1], -1);
}
}
}
return HTTPD_CGI_DONE;
}

@ -683,7 +683,7 @@ void ICACHE_FLASH_ATTR
screenSerializeLabelsToBuffer(char *buffer, size_t buf_len)
{
// let's just assume it's long enough - called with the huge websocket buffer
sprintf(buffer, "T%s|%s|%s|%s|%s|%s",
sprintf(buffer, "T%s\x01%s\x01%s\x01%s\x01%s\x01%s", // use 0x01 as separator
termconf_scratch.title,
termconf_scratch.btn[0],
termconf_scratch.btn[1],

Loading…
Cancel
Save