Skip to content

Commit 1d47224

Browse files
committed
Added ext-searchbox (Ctrl+F) search/replace functionality and -workers (live syntax checkers) to the ace editor - a standalone hack.
if you don't need worker(s), modify line me-no-dev#446 of edit.htm .setUseWorker(!0) to (!1) (true to false) repack by do.bat and modify update_ace.bat Changes of src/WebAuthentication.cpp and minor updates of my SmartSwitch example
1 parent 6aefbbb commit 1d47224

9 files changed

+781
-753
lines changed

examples/SmartSwitch/SmartSwitch.ino

+528-529
Large diffs are not rendered by default.
2.97 KB
Binary file not shown.
34.7 KB
Binary file not shown.
46.3 KB
Binary file not shown.
Binary file not shown.

extras/update_ace.bat

+17-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,27 @@ REM fetcher --url=resource_url --out=output_directory
55
call fetcher --url="https://github.com/ajaxorg/ace-builds/blob/master/src-min-noconflict/ace.js" --out=tmp1
66
call fetcher --url="https://github.com/ajaxorg/ace-builds/blob/master/src-min-noconflict/mode-html.js" --out=tmp1
77
call fetcher --url="https://github.com/ajaxorg/ace-builds/blob/master/src-min-noconflict/theme-monokai.js" --out=tmp1
8+
call fetcher --url="https://github.com/ajaxorg/ace-builds/blob/master/src-min-noconflict/ext-searchbox.js" --out=tmp1
9+
10+
REM if you don't need worker(s), modify line#446 of edit.htm .setUseWorker(!0) to (!1) (true to false)
11+
REM and do not take and include them below
12+
call fetcher --url="https://github.com/ajaxorg/ace-builds/blob/master/src-min-noconflict/worker-html.js" --out=tmp1
13+
call fetcher --url="https://github.com/ajaxorg/ace-builds/blob/master/src-min-noconflict/worker-css.js" --out=tmp1
14+
call fetcher --url="https://github.com/ajaxorg/ace-builds/blob/master/src-min-noconflict/worker-javascript.js" --out=tmp1
815

916
cd tmp1
10-
type ace.js mode-html.js theme-monokai.js > acefull.js
17+
type ace.js mode-html.js theme-monokai.js ext-searchbox.js > acefull.js
1118
"C:\Program Files\7-Zip\7z.exe" a -tgzip -mx9 acefull.js.gz acefull.js
19+
REM
20+
"C:\Program Files\7-Zip\7z.exe" a -tgzip -mx9 worker-html.js.gz worker-html.js
21+
"C:\Program Files\7-Zip\7z.exe" a -tgzip -mx9 worker-javascript.js.gz worker-javascript.js
22+
"C:\Program Files\7-Zip\7z.exe" a -tgzip -mx9 worker-css.js.gz worker-css.js
23+
1224
REM update:
1325
pause
1426
copy acefull.js.gz ..\..\examples\SmartSwitch\data\acefull.js.gz
27+
REM
28+
copy worker-html.js.gz ..\..\examples\SmartSwitch\data\worker-html.js.gz
29+
copy worker-javascript.js.gz ..\..\examples\SmartSwitch\data\worker-javascript.js.gz
30+
copy worker-css.js.gz ..\..\examples\SmartSwitch\data\worker-css.js.gz
1531
del *.js *.gz
16-

src/WebAuthentication.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ bool checkBasicAuthentication(const char * hash, const char * username, const ch
3636
size_t toencodeLen = strlen(username)+strlen(password)+1;
3737
size_t encodedLen = base64_encode_expected_len(toencodeLen);
3838
if(strlen(hash) != encodedLen)
39+
// Fix from https://github.com/me-no-dev/ESPAsyncWebServer/issues/667
40+
#ifdef ARDUINO_ARCH_ESP32
41+
if(strlen(hash) != encodedLen)
42+
#else
43+
if (strlen(hash) != encodedLen - 1)
44+
#endif
3945
return false;
4046

4147
char *toencode = new char[toencodeLen+1];

src/edit.htm

+8-2
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,9 @@
441441
edit: e
442442
}, s)
443443
}
444-
"undefined" == typeof t && (t = "/index.html"), "undefined" == typeof n && (n = o(t)), "undefined" == typeof a && (a = "monokai"), "undefined" == typeof i && (i = "text/" + n, "c_cpp" === n && (i = "text/plain"));
444+
"undefined" == typeof t && (t = "/index.htm"), "undefined" == typeof n && (n = o(t)), "undefined" == typeof a && (a = "monokai"), "undefined" == typeof i && (i = "text/" + n, "c_cpp" === n && (i = "text/plain"));
445445
var l = ace.edit(e);
446-
return "plain" !== n && l.getSession().setMode("ace/mode/" + n), l.setTheme("ace/theme/" + a), l.$blockScrolling = 1 / 0, l.getSession().setUseSoftTabs(!0), l.getSession().setTabSize(2), l.getSession().setUseWorker(!1), l.setHighlightActiveLine(!0), l.setShowPrintMargin(!1), l.commands.addCommand({
446+
return "plain" !== n && l.getSession().setMode("ace/mode/" + n), l.setTheme("ace/theme/" + a), l.$blockScrolling = 1 / 0, l.getSession().setUseSoftTabs(!0), l.getSession().setTabSize(2), l.getSession().setUseWorker(!0), l.setHighlightActiveLine(!0), l.setShowPrintMargin(!1), l.commands.addCommand({
447447
name: "saveCommand",
448448
bindKey: {
449449
win: "Ctrl-S",
@@ -485,6 +485,12 @@
485485
e[n] = a
486486
}), createEditor("editor", e.file, e.lang, e.theme)),
487487
n = createTree("tree", t);
488+
489+
window.define = ace.define;
490+
window.require = ace.require;
491+
ace.config.set('basePath', '/');
492+
ace.config.set("workerPath", '/');
493+
488494
createFileUploader("uploader", n, t), "undefined" == typeof e.file && (e.file = "/index.htm"), t.loadUrl(e.file)
489495
}
490496
"undefined" == typeof XMLHttpRequest && (XMLHttpRequest = function() {

src/edit.htm.gz.h

+222-220
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)