Skip to content

Commit

Permalink
Added ext-searchbox (Ctrl+F) search/replace functionality and -worker…
Browse files Browse the repository at this point in the history
…s (live syntax checkers) to the ace editor - a standalone hack.

if you don't need worker(s), modify line homieiot#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
  • Loading branch information
lorol committed May 4, 2020
1 parent 9020775 commit 7dbe115
Show file tree
Hide file tree
Showing 9 changed files with 781 additions and 753 deletions.
1,057 changes: 528 additions & 529 deletions examples/SmartSwitch/SmartSwitch.ino

Large diffs are not rendered by default.

Binary file modified examples/SmartSwitch/data/acefull.js.gz
Binary file not shown.
Binary file added examples/SmartSwitch/data/worker-css.js.gz
Binary file not shown.
Binary file added examples/SmartSwitch/data/worker-html.js.gz
Binary file not shown.
Binary file added examples/SmartSwitch/data/worker-javascript.js.gz
Binary file not shown.
19 changes: 17 additions & 2 deletions extras/update_ace.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,27 @@ REM fetcher --url=resource_url --out=output_directory
call fetcher --url="https://github.com/ajaxorg/ace-builds/blob/master/src-min-noconflict/ace.js" --out=tmp1
call fetcher --url="https://github.com/ajaxorg/ace-builds/blob/master/src-min-noconflict/mode-html.js" --out=tmp1
call fetcher --url="https://github.com/ajaxorg/ace-builds/blob/master/src-min-noconflict/theme-monokai.js" --out=tmp1
call fetcher --url="https://github.com/ajaxorg/ace-builds/blob/master/src-min-noconflict/ext-searchbox.js" --out=tmp1

REM if you don't need worker(s), modify line#446 of edit.htm .setUseWorker(!0) to (!1) (true to false)
REM and do not take and include them below
call fetcher --url="https://github.com/ajaxorg/ace-builds/blob/master/src-min-noconflict/worker-html.js" --out=tmp1
call fetcher --url="https://github.com/ajaxorg/ace-builds/blob/master/src-min-noconflict/worker-css.js" --out=tmp1
call fetcher --url="https://github.com/ajaxorg/ace-builds/blob/master/src-min-noconflict/worker-javascript.js" --out=tmp1

cd tmp1
type ace.js mode-html.js theme-monokai.js > acefull.js
type ace.js mode-html.js theme-monokai.js ext-searchbox.js > acefull.js
"C:\Program Files\7-Zip\7z.exe" a -tgzip -mx9 acefull.js.gz acefull.js
REM
"C:\Program Files\7-Zip\7z.exe" a -tgzip -mx9 worker-html.js.gz worker-html.js
"C:\Program Files\7-Zip\7z.exe" a -tgzip -mx9 worker-javascript.js.gz worker-javascript.js
"C:\Program Files\7-Zip\7z.exe" a -tgzip -mx9 worker-css.js.gz worker-css.js

REM update:
pause
copy acefull.js.gz ..\..\examples\SmartSwitch\data\acefull.js.gz
REM
copy worker-html.js.gz ..\..\examples\SmartSwitch\data\worker-html.js.gz
copy worker-javascript.js.gz ..\..\examples\SmartSwitch\data\worker-javascript.js.gz
copy worker-css.js.gz ..\..\examples\SmartSwitch\data\worker-css.js.gz
del *.js *.gz

6 changes: 6 additions & 0 deletions src/WebAuthentication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ bool checkBasicAuthentication(const char * hash, const char * username, const ch
size_t toencodeLen = strlen(username)+strlen(password)+1;
size_t encodedLen = base64_encode_expected_len(toencodeLen);
if(strlen(hash) != encodedLen)
// Fix from https://github.com/me-no-dev/ESPAsyncWebServer/issues/667
#ifdef ARDUINO_ARCH_ESP32
if(strlen(hash) != encodedLen)
#else
if (strlen(hash) != encodedLen - 1)
#endif
return false;

char *toencode = new char[toencodeLen+1];
Expand Down
10 changes: 8 additions & 2 deletions src/edit.htm
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,9 @@
edit: e
}, s)
}
"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"));
"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"));
var l = ace.edit(e);
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({
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({
name: "saveCommand",
bindKey: {
win: "Ctrl-S",
Expand Down Expand Up @@ -485,6 +485,12 @@
e[n] = a
}), createEditor("editor", e.file, e.lang, e.theme)),
n = createTree("tree", t);

window.define = ace.define;
window.require = ace.require;
ace.config.set('basePath', '/');
ace.config.set("workerPath", '/');

createFileUploader("uploader", n, t), "undefined" == typeof e.file && (e.file = "/index.htm"), t.loadUrl(e.file)
}
"undefined" == typeof XMLHttpRequest && (XMLHttpRequest = function() {
Expand Down
442 changes: 222 additions & 220 deletions src/edit.htm.gz.h

Large diffs are not rendered by default.

0 comments on commit 7dbe115

Please sign in to comment.