From 944e3daa7931e749b0d1f47a50658abbabcd079f Mon Sep 17 00:00:00 2001 From: chromoxdor <33860956+chromoxdor@users.noreply.github.com> Date: Sun, 27 Jul 2025 21:24:21 +0200 Subject: [PATCH] minor corrections help text --- static/cm-plugins.js | 2 +- static/cm-plugins.min.js | 2 +- static/espeasy.js | 5 +++-- static/espeasy.min.js | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/static/cm-plugins.js b/static/cm-plugins.js index 57ac4c9a8..c4983d8c3 100644 --- a/static/cm-plugins.js +++ b/static/cm-plugins.js @@ -979,7 +979,7 @@ var isSame; }); } - CodeMirror.commands.find = function (cm) { doSearch; }; + CodeMirror.commands.find = function (cm) { clearSearch(cm); doSearch(cm); }; CodeMirror.commands.findPersistent = function (cm) { clearSearch(cm); doSearch(cm, false, true); }; CodeMirror.commands.findPersistentNext = function (cm) { doSearch(cm, false, true, true); }; CodeMirror.commands.findPersistentPrev = function (cm) { doSearch(cm, true, true, true); }; diff --git a/static/cm-plugins.min.js b/static/cm-plugins.min.js index 5fba4dbaf..c2cda8ee0 100644 --- a/static/cm-plugins.min.js +++ b/static/cm-plugins.min.js @@ -1 +1 @@ -var isSame;!function(t){"object"==typeof exports&&"object"==typeof module?t(require("codemirror")):"function"==typeof define&&define.amd?define(["codemirror"],mod):t(CodeMirror)}((function(t){"use strict";var e=/[\w?.,%]+/;t.registerHelper("hint","anyword",(function(n,i){for(var o=i&&i.word||e,r=i&&i.range||500,s=i&&i.extraWords||EXTRAWORDS,a=n.getCursor(),c=n.getLine(a.line),l=a.ch,h=l;h&&o.test(c.charAt(h-1));)--h;var u=h!=l&&c.slice(h,l);u&&(u=u.toLowerCase()),isSame=s.some((t=>t.toLowerCase()===u));for(var f=i&&i.list||[],d={},p=new RegExp(o.source,"gi"),m=-1;m<=1;m+=2)for(var g=a.line,v=Math.min(Math.max(g+m*r,n.firstLine()),n.lastLine())+m;g!=v;g+=m){var y,C=n.getLine(g),x=(C=(C=C.replace(/\/{2}.*/g,"")).replace(/(=|-|\+|\*|<|>)\d+/g,"")).match(/\w+(?:,(\S+)){2}/);for(x&&(C=C.replace(x[1]," "+x[1])),C.includes("#")&&(p=new RegExp(/[\w?#.,%]+/,"gi"));y=p.exec(C);)g==a.line&&y[0].toLowerCase()===u||u&&0!=y[0].toLowerCase().lastIndexOf(u,0)||Object.prototype.hasOwnProperty.call(d,y[0])||(d[y[0]]=!0,f.push(y[0]))}f.sort(),f.reverse();let b=new Map(f.map((t=>[t.toLowerCase(),t])));(f=[...b.values()]).sort();var w=s.filter((t=>t.toLowerCase().startsWith(u||"")));w.sort(),f=f.concat(w);let N=new Map(f.map((t=>[t.toLowerCase(),t])));return(f=[...N.values()]).sort((function(t,e){return t.toLowerCase().localeCompare(e.toLowerCase())})),{list:f,from:t.Pos(a.line,h),to:t.Pos(a.line,l)}}))})),function(t){"object"==typeof exports&&"object"==typeof module?t(require("codemirror")):"function"==typeof define&&define.amd?define(["codemirror"],mod):t(CodeMirror)}((function(t){"use strict";function e(e,n){if(this.cm=e,this.options=n,this.widget=null,this.debounce=0,this.tick=0,this.startPos=this.cm.getCursor("start"),this.startLen=this.cm.getLine(this.startPos.line).length-this.cm.getSelection().length,this.options.updateOnCursorActivity){var i=this;e.on("cursorActivity",this.activityFunc=function(){i.cursorActivity()})}t.signal(this,"startCompletion",this)}t.showHint=function(t,e,n){if(!e)return t.showHint(n);n&&n.async&&(e.async=!0);var i={hint:e};if(n)for(var o in n)i[o]=n[o];return t.showHint(i)},t.defineExtension("showHint",(function(n){n=function(t,e,n){var i=t.options.hintOptions,o={};for(var r in c)o[r]=c[r];if(i)for(var r in i)void 0!==i[r]&&(o[r]=i[r]);if(n)for(var r in n)void 0!==n[r]&&(o[r]=n[r]);o.hint.resolve&&(o.hint=o.hint.resolve(t,e));return o}(this,this.getCursor("start"),n);var i=this.listSelections();if(!(i.length>1)){if(this.somethingSelected()){if(!n.hint.supportsSelection)return;for(var o=0;ol.clientHeight+1;if(setTimeout((function(){H=s.getScrollInfo()})),L.bottom-E>0){var k=L.bottom-L.top;if(v.top-(v.bottom-L.top)-k>0)l.style.top=(C=v.top-k-w)+"px",x=!1;else if(k>E){l.style.height=E-5+"px",l.style.top=(C=v.bottom-L.top-w)+"px";var A=s.getCursor();n.from.ch!=A.ch&&(v=s.cursorCoords(A),l.style.left=(y=v.left-b)+"px",L=l.getBoundingClientRect())}}var P,F=L.right-M;if(T&&(F+=s.display.nativeBarWidth),F>0&&(L.right-L.left>M&&(l.style.width=M-5+"px",F-=L.right-L.left-M),l.style.left=(y=v.left-F-b)+"px"),T)for(var q=l.firstChild;q;q=q.nextSibling)q.style.paddingRight=s.display.nativeBarWidth+"px";(s.addKeyMap(this.keyMap=function(t,e){var n={Up:function(){e.moveFocus(-1)},Down:function(){e.moveFocus(1)},PageUp:function(){e.moveFocus(1-e.menuSize(),!0)},PageDown:function(){e.moveFocus(e.menuSize()-1,!0)},Home:function(){e.setFocus(0)},End:function(){e.setFocus(e.length-1)},Enter:e.pick,Tab:e.pick,Esc:e.close},i=/Mac/.test(navigator.platform);isSame&&(n.Space=e.pick,n[","]=e.pick),i&&(n["Ctrl-P"]=function(){e.moveFocus(-1)},n["Ctrl-N"]=function(){e.moveFocus(1)});var o=t.options.customKeys,r=o?{}:n;function s(t,i){var o;o="string"!=typeof i?function(t){return i(t,e)}:n.hasOwnProperty(i)?n[i]:i,r[t]=o}if(o)for(var a in o)o.hasOwnProperty(a)&&s(a,o[a]);var c=t.options.extraKeys;if(c)for(var a in c)c.hasOwnProperty(a)&&s(a,c[a]);return r}(e,{moveFocus:function(t,e){i.changeActive(i.selectedHint+t,e)},setFocus:function(t){i.changeActive(t)},menuSize:function(){return i.screenAmount()},length:u.length,close:function(){e.close()},pick:function(){i.pick()},data:n})),e.options.closeOnUnfocus)&&(s.on("blur",this.onBlur=function(){P=setTimeout((function(){e.close()}),100)}),s.on("focus",this.onFocus=function(){clearTimeout(P)}));s.on("scroll",this.onScroll=function(){var t=s.getScrollInfo(),n=s.getWrapperElement().getBoundingClientRect();H||(H=s.getScrollInfo());var i=C+H.top-t.top,o=i-(c.pageYOffset||(a.documentElement||a.body).scrollTop);if(x||(o+=l.offsetHeight),o<=n.top||o>=n.bottom)return e.close();l.style.top=i+"px",l.style.left=y+H.left-t.left+"px"}),t.on(l,"dblclick",(function(t){var e=r(l,t.target||t.srcElement);e&&null!=e.hintId&&(i.changeActive(e.hintId),i.pick())})),t.on(l,"click",(function(t){var n=r(l,t.target||t.srcElement);n&&null!=n.hintId&&(i.changeActive(n.hintId),e.options.completeOnSingleClick&&i.pick())})),t.on(l,"mousedown",(function(){setTimeout((function(){s.focus()}),20)}));var R=this.getSelectedHintRange();return 0===R.from&&0===R.to||this.scrollToActive(),t.signal(n,"select",u[this.selectedHint],l.childNodes[this.selectedHint]),!0}function a(t,e,n,i){if(t.async)t(e,i,n);else{var o=t(e,n);o&&o.then?o.then(i):i(o)}}e.prototype={close:function(){this.active()&&(this.cm.state.completionActive=null,this.tick=null,this.options.updateOnCursorActivity&&this.cm.off("cursorActivity",this.activityFunc),this.widget&&this.data&&t.signal(this.data,"close"),this.widget&&this.widget.close(),t.signal(this.cm,"endCompletion",this.cm))},active:function(){return this.cm.state.completionActive==this},pick:function(e,n){var i=e.list[n],r=this;this.cm.operation((function(){i.hint?i.hint(r.cm,e,i):r.cm.replaceRange(o(i),i.from||e.from,i.to||e.to,"complete"),t.signal(e,"pick",i),r.cm.scrollIntoView()})),this.options.closeOnPick&&this.close()},cursorActivity:function(){this.debounce&&(i(this.debounce),this.debounce=0);var t=this.startPos;this.data&&(t=this.data.from);var e=this.cm.getCursor(),o=this.cm.getLine(e.line);if(e.line!=this.startPos.line||o.length-e.ch!=this.startLen-this.startPos.ch||e.ch0?" ".repeat(o):""),isSame&&"Space"===nameKey?"If"===this.data.list[0]?this.data.list[0]=this.data.list[0]+" ":"Do"!=this.data.list[0]&&(this.data.list[0]=this.data.list[0]+" ",isSame=!1,t=0):isSame&&"Enter"===nameKey?("If"===this.data.list[0]?(this.data.list[0]=this.data.list[0]+" \n"+e+"Endif",t=1):"On"===this.data.list[0]?(this.data.list[0]=this.data.list[0]+" Do\n\nEndon",t=2):"Do"===this.data.list[0]?(this.data.list[0]=this.data.list[0]+"\n\nEndon",t=2.2):(this.data.list[0]=this.data.list[0]+"\n"+n,t=0),isSame=!1):isSame&&","===nameKey&&(this.data.list[0]=this.data.list[0]+",",t=0,isSame=!1),"LogEntry"===this.data.list[this.selectedHint]&&(this.data.list[this.selectedHint]=this.data.list[this.selectedHint]+",''",t=3),this.completion.pick(this.data,this.selectedHint);var r=rEdit.getCursor().line,s=rEdit.getCursor().ch;if(1===t)rEdit.setCursor({line:r-1});else if(2===t)for(rEdit.setCursor({line:r-1}),rEdit.execCommand("insertSoftTab"),rEdit.setCursor({line:r-2,ch:i+1});rEdit.getCursor().ch>3;)rEdit.execCommand("indentLess");else 2.2===t?(rEdit.setCursor({line:r-1}),rEdit.execCommand("insertSoftTab")):3===t&&rEdit.setCursor({line:r,ch:s-1})},changeActive:function(e,n){if(e>=this.data.list.length?e=n?this.data.list.length-1:0:e<0&&(e=n?0:this.data.list.length-1),this.selectedHint!=e){var i=this.hints.childNodes[this.selectedHint];i&&(i.className=i.className.replace(" CodeMirror-hint-active",""),i.removeAttribute("aria-selected")),(i=this.hints.childNodes[this.selectedHint=e]).className+=" CodeMirror-hint-active",i.setAttribute("aria-selected","true"),this.completion.cm.getInputField().setAttribute("aria-activedescendant",i.id),this.scrollToActive(),t.signal(this.data,"select",this.data.list[this.selectedHint],i)}},scrollToActive:function(){var t=this.getSelectedHintRange(),e=this.hints.childNodes[t.from],n=this.hints.childNodes[t.to],i=this.hints.firstChild;e.offsetTopthis.hints.scrollTop+this.hints.clientHeight&&(this.hints.scrollTop=n.offsetTop+n.offsetHeight-this.hints.clientHeight+i.offsetTop)},screenAmount:function(){return Math.floor(this.hints.clientHeight/this.hints.firstChild.offsetHeight)||1},getSelectedHintRange:function(){var t=this.completion.options.scrollMargin||0;return{from:Math.max(0,this.selectedHint-t),to:Math.min(this.data.list.length-1,this.selectedHint+t)}}},t.registerHelper("hint","auto",{resolve:function(e,n){var i,o=e.getHelpers(n,"hint");if(o.length){var r=function(t,e,n){var i=function(t,e){if(!t.somethingSelected())return e;for(var n=[],i=0;i0?e(t):o(r+1)}))}(0)};return r.async=!0,r.supportsSelection=!0,r}return(i=e.getHelper(e.getCursor(),"hintWords"))?function(e){return t.hint.fromList(e,{words:i})}:t.hint.anyword?function(e,n){return t.hint.anyword(e,n)}:function(){}}}),t.registerHelper("hint","fromList",(function(e,n){var i,o=e.getCursor(),r=e.getTokenAt(o),s=t.Pos(o.line,r.start),a=o;r.start]/,closeOnPick:!0,closeOnUnfocus:!0,updateOnCursorActivity:!0,completeOnSingleClick:!0,container:null,customKeys:null,extraKeys:null,paddingForScrollbar:!0,moveOnOverlap:!0};t.defineOption("hintOptions",null)})),function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror"),require("./searchcursor"),require("../dialog/dialog")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./searchcursor","../dialog/dialog"],t):t(CodeMirror)}((function(t){"use strict";function e(){this.posFrom=this.posTo=this.lastQuery=this.query=null,this.overlay=null}function n(t){return t.state.search||(t.state.search=new e)}function i(t){return"string"==typeof t&&t==t.toLowerCase()}function o(t,e,n){return t.getSearchCursor(e,n,{caseFold:i(e),multiline:!0})}function r(t,e,n,i,o){t.openDialog?t.openDialog(e,o,{value:i,selectValueOnOpen:!0,bottom:t.options.search.bottom}):o(prompt(n,i))}function s(t){return t.replace(/\\([nrt\\])/g,(function(t,e){return"n"==e?"\n":"r"==e?"\r":"t"==e?"\t":"\\"==e?"\\":t}))}function a(t){var e=t.match(/^\/(.*)\/([a-z]*)$/);if(e)try{t=new RegExp(e[1],-1==e[2].indexOf("i")?"":"i")}catch(t){}else t=s(t);return("string"==typeof t?""==t:t.test(""))&&(t=/x^/),t}function c(t,e,n){e.queryText=n,e.query=a(n),t.removeOverlay(e.overlay,i(e.query)),e.overlay=function(t,e){return"string"==typeof t?t=new RegExp(t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),e?"gi":"g"):t.global||(t=new RegExp(t.source,t.ignoreCase?"gi":"g")),{token:function(e){t.lastIndex=e.pos;var n=t.exec(e.string);if(n&&n.index==e.pos)return e.pos+=n[0].length||1,"searching";n?e.pos=n.index:e.skipToEnd()}}}(e.query,i(e.query)),t.addOverlay(e.overlay),t.showMatchesOnScrollbar&&(e.annotate&&(e.annotate.clear(),e.annotate=null),e.annotate=t.showMatchesOnScrollbar(e.query,i(e.query)))}function l(e,i,o,s){var a=n(e);if(a.query)return h(e,i);var l=e.getSelection()||a.lastQuery;if(l instanceof RegExp&&"x^"==l.source&&(l=null),o&&e.openDialog){var f=null,p=function(n,i){t.e_stop(i),n&&(n!=a.queryText&&(c(e,a,n),a.posFrom=a.posTo=e.getCursor()),f&&(f.style.opacity=1),h(e,i.shiftKey,(function(t,n){var i;n.line<3&&document.querySelector&&(i=e.display.wrapper.querySelector(".CodeMirror-dialog"))&&i.getBoundingClientRect().bottom-4>e.cursorCoords(n,"window").top&&((f=i).style.opacity=.4)})))};!function(t,e,n,i,o){t.openDialog(e,i,{value:n,selectValueOnOpen:!0,closeOnEnter:!1,onClose:function(){u(t)},onKeyUp:o,bottom:t.options.search.bottom})}(e,d(e),l,p,(function(i,o){var r=t.keyName(i);"Enter"!=r&&o!=a.queryText&&(c(e,a,o),e.execCommand("goLineUp"),a.posFrom=a.posTo=e.getCursor(),h(e,i.shiftKey));var s=e.getOption("extraKeys"),l=s&&s[r]||t.keyMap[e.getOption("keyMap")][r];"findNext"==l||"findPrev"==l||"findPersistentNext"==l||"findPersistentPrev"==l?(t.e_stop(i),c(e,n(e),o),e.execCommand(l)):"find"!=l&&"findPersistent"!=l||(t.e_stop(i),p(o,i))})),s&&l&&(c(e,a,l),h(e,i))}else r(e,d(e),"Search for:",l,(function(t){t&&!a.query&&e.operation((function(){c(e,a,t),a.posFrom=a.posTo=e.getCursor(),h(e,i)}))}))}function h(e,i,r){e.operation((function(){const s=n(e);let a=o(e,s.query,i?s.posFrom:s.posTo);var c,l;(a.find(i)||(a=o(e,s.query,i?t.Pos(e.lastLine()):t.Pos(e.firstLine(),0)),a.find(i)))&&(c=a.from(),l=a.to(),e.__searchNextHighlight&&e.__searchNextHighlight.clear(),e.__searchNextHighlight=e.markText(c,l,{className:"search-next-highlight"}),e.setSelection(a.from(),a.to()),e.scrollTo(null,e.charCoords(a.from(),"local").top),s.posFrom=a.from(),s.posTo=a.to(),r&&r(a.from(),a.to()))}))}function u(t){t.operation((function(){var e=n(t);e.lastQuery=e.query,e.query&&(e.query=e.queryText=null,t.removeOverlay(e.overlay),e.annotate&&(e.annotate.clear(),e.annotate=null))}))}function f(t,e){var n=t?document.createElement(t):document.createDocumentFragment();for(var i in e)n[i]=e[i];for(var o=2;oh);u++){var f=t.getLine(l++);a=null==a?f:a+"\n"+f}c*=2,e.lastIndex=n.ch;var d=e.exec(a);if(d){var p=a.slice(0,d.index).split("\n"),m=d[0].split("\n"),g=n.line+p.length-1,v=p[p.length-1].length;return{from:i(g,v),to:i(g+m.length-1,1==m.length?v+m[0].length:m[m.length-1].length),match:d}}}}function c(t,e,n){for(var i,o=0;o<=t.length;){e.lastIndex=o;var r=e.exec(t);if(!r)break;var s=r.index+r[0].length;if(s>t.length-n)break;(!i||s>i.index+i[0].length)&&(i=r),o=r.index+1}return i}function l(t,e,n){e=o(e,"g");for(var r=n.line,s=n.ch,a=t.firstLine();r>=a;r--,s=-1){var l=t.getLine(r),h=c(l,e,s<0?0:l.length-s);if(h)return{from:i(r,h.index),to:i(r,h.index+h[0].length),match:h}}}function h(t,e,n){if(!r(e))return l(t,e,n);e=o(e,"gm");for(var s,a=1,h=t.getLine(n.line).length-n.ch,u=n.line,f=t.firstLine();u>=f;){for(var d=0;d=f;d++){var p=t.getLine(u--);s=null==s?p:p+"\n"+s}a*=2;var m=c(s,e,h);if(m){var g=s.slice(0,m.index).split("\n"),v=m[0].split("\n"),y=u+g.length,C=g[g.length-1].length;return{from:i(y,C),to:i(y+v.length-1,1==v.length?C+v[0].length:v[v.length-1].length),match:m}}}}function u(t,e,n,i){if(t.length==e.length)return n;for(var o=0,r=n+Math.max(0,t.length-e.length);;){if(o==r)return o;var s=o+r>>1,a=i(t.slice(0,s)).length;if(a==n)return s;a>n?r=s:o=s+1}}function f(t,o,r,s){if(!o.length)return null;var a=s?e:n,c=a(o).split(/\r|\n\r?/);t:for(var l=r.line,h=r.ch,f=t.lastLine()+1-c.length;l<=f;l++,h=0){var d=t.getLine(l).slice(h),p=a(d);if(1==c.length){var m=p.indexOf(c[0]);if(-1==m)continue t;r=u(d,p,m,a)+h;return{from:i(l,u(d,p,m,a)+h),to:i(l,u(d,p,m+c[0].length,a)+h)}}var g=p.length-c[0].length;if(p.slice(g)==c[0]){for(var v=1;v=f;l--,h=-1){var d=t.getLine(l);h>-1&&(d=d.slice(0,h));var p=a(d);if(1==c.length){var m=p.lastIndexOf(c[0]);if(-1==m)continue t;return{from:i(l,u(d,p,m,a)),to:i(l,u(d,p,m+c[0].length,a))}}var g=c[c.length-1];if(p.slice(0,g.length)==g){var v=1;for(r=l-c.length+1;v(this.doc.getLine(n.line)||"").length&&(n.ch=0,n.line++)),0!=t.cmpPos(n,this.doc.clipPos(n))))return this.atOccurrence=!1;var o=this.matches(e,n);if(this.afterEmptyMatch=o&&0==t.cmpPos(o.from,o.to),o)return this.pos=o,this.atOccurrence=!0,this.pos.match||!0;var r=i(e?this.doc.firstLine():this.doc.lastLine()+1,0);return this.pos={from:r,to:r},this.atOccurrence=!1},from:function(){if(this.atOccurrence)return this.pos.from},to:function(){if(this.atOccurrence)return this.pos.to},replace:function(e,n){if(this.atOccurrence){var o=t.splitLines(e);this.doc.replaceRange(o,this.pos.from,this.pos.to,n),this.pos.to=i(this.pos.from.line+o.length-1,o[o.length-1].length+(1==o.length?this.pos.from.ch:0))}}},t.defineExtension("getSearchCursor",(function(t,e,n){return new p(this.doc,t,e,n)})),t.defineDocExtension("getSearchCursor",(function(t,e,n){return new p(this,t,e,n)})),t.defineExtension("selectMatches",(function(e,n){for(var i=[],o=this.getSearchCursor(e,this.getCursor("from"),n);o.findNext()&&!(t.cmpPos(o.to(),this.getCursor("to"))>0);)i.push({anchor:o.from(),head:o.to()});i.length&&this.setSelections(i,0)}))})),function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}((function(t){function e(e,n,i){var o,r=document.body;return(o=r.appendChild(document.createElement("div"))).className=i?"CodeMirror-dialog CodeMirror-dialog-bottom":"CodeMirror-dialog CodeMirror-dialog-top","string"==typeof n?o.innerHTML=n:o.appendChild(n),t.addClass(r,"dialog-opened"),o}function n(t,e){t.state.currentNotificationClose&&t.state.currentNotificationClose(),t.state.currentNotificationClose=e}t.defineExtension("openDialog",(function(i,o,r){r||(r={}),n(this,null);var s=e(0,i,r.bottom),a=!1,c=this;function l(e){if("string"==typeof e)u.value=e;else{if(a)return;a=!0,t.rmClass(s.parentNode,"dialog-opened"),s.parentNode.removeChild(s),c.focus(),r.onClose&&r.onClose(s)}}var h,u=s.getElementsByTagName("input")[0];return u?(u.focus(),r.value&&(u.value=r.value,!1!==r.selectValueOnOpen&&u.select()),r.onInput&&t.on(u,"input",(function(t){r.onInput(t,u.value,l)})),r.onKeyUp&&t.on(u,"keyup",(function(t){r.onKeyUp(t,u.value,l)})),t.on(u,"keydown",(function(e){r&&r.onKeyDown&&r.onKeyDown(e,u.value,l)||((27==e.keyCode||!1!==r.closeOnEnter&&13==e.keyCode)&&(u.blur(),t.e_stop(e),l()),13==e.keyCode&&o(u.value,e))})),!1!==r.closeOnBlur&&t.on(s,"focusout",(function(t){null!==t.relatedTarget&&l()}))):(h=s.getElementsByTagName("button")[0])&&(t.on(h,"click",(function(){l(),c.focus()})),!1!==r.closeOnBlur&&t.on(h,"blur",l),h.focus()),l})),t.defineExtension("openConfirm",(function(i,o,r){n(this,null);var s=e(0,i,r&&r.bottom),a=s.getElementsByTagName("button"),c=!1,l=this,h=1;function u(){c||(c=!0,t.rmClass(s.parentNode,"dialog-opened"),s.parentNode.removeChild(s),l.focus())}a[0].focus();for(var f=0;ft.toLowerCase()===u));for(var f=i&&i.list||[],d={},p=new RegExp(o.source,"gi"),m=-1;m<=1;m+=2)for(var g=a.line,v=Math.min(Math.max(g+m*r,n.firstLine()),n.lastLine())+m;g!=v;g+=m){var y,C=n.getLine(g),x=(C=(C=C.replace(/\/{2}.*/g,"")).replace(/(=|-|\+|\*|<|>)\d+/g,"")).match(/\w+(?:,(\S+)){2}/);for(x&&(C=C.replace(x[1]," "+x[1])),C.includes("#")&&(p=new RegExp(/[\w?#.,%]+/,"gi"));y=p.exec(C);)g==a.line&&y[0].toLowerCase()===u||u&&0!=y[0].toLowerCase().lastIndexOf(u,0)||Object.prototype.hasOwnProperty.call(d,y[0])||(d[y[0]]=!0,f.push(y[0]))}f.sort(),f.reverse();let b=new Map(f.map((t=>[t.toLowerCase(),t])));(f=[...b.values()]).sort();var w=s.filter((t=>t.toLowerCase().startsWith(u||"")));w.sort(),f=f.concat(w);let N=new Map(f.map((t=>[t.toLowerCase(),t])));return(f=[...N.values()]).sort((function(t,e){return t.toLowerCase().localeCompare(e.toLowerCase())})),{list:f,from:t.Pos(a.line,h),to:t.Pos(a.line,l)}}))})),function(t){"object"==typeof exports&&"object"==typeof module?t(require("codemirror")):"function"==typeof define&&define.amd?define(["codemirror"],mod):t(CodeMirror)}((function(t){"use strict";function e(e,n){if(this.cm=e,this.options=n,this.widget=null,this.debounce=0,this.tick=0,this.startPos=this.cm.getCursor("start"),this.startLen=this.cm.getLine(this.startPos.line).length-this.cm.getSelection().length,this.options.updateOnCursorActivity){var i=this;e.on("cursorActivity",this.activityFunc=function(){i.cursorActivity()})}t.signal(this,"startCompletion",this)}t.showHint=function(t,e,n){if(!e)return t.showHint(n);n&&n.async&&(e.async=!0);var i={hint:e};if(n)for(var o in n)i[o]=n[o];return t.showHint(i)},t.defineExtension("showHint",(function(n){n=function(t,e,n){var i=t.options.hintOptions,o={};for(var r in c)o[r]=c[r];if(i)for(var r in i)void 0!==i[r]&&(o[r]=i[r]);if(n)for(var r in n)void 0!==n[r]&&(o[r]=n[r]);o.hint.resolve&&(o.hint=o.hint.resolve(t,e));return o}(this,this.getCursor("start"),n);var i=this.listSelections();if(!(i.length>1)){if(this.somethingSelected()){if(!n.hint.supportsSelection)return;for(var o=0;ol.clientHeight+1;if(setTimeout((function(){H=s.getScrollInfo()})),L.bottom-E>0){var k=L.bottom-L.top;if(v.top-(v.bottom-L.top)-k>0)l.style.top=(C=v.top-k-w)+"px",x=!1;else if(k>E){l.style.height=E-5+"px",l.style.top=(C=v.bottom-L.top-w)+"px";var A=s.getCursor();n.from.ch!=A.ch&&(v=s.cursorCoords(A),l.style.left=(y=v.left-b)+"px",L=l.getBoundingClientRect())}}var P,F=L.right-M;if(T&&(F+=s.display.nativeBarWidth),F>0&&(L.right-L.left>M&&(l.style.width=M-5+"px",F-=L.right-L.left-M),l.style.left=(y=v.left-F-b)+"px"),T)for(var q=l.firstChild;q;q=q.nextSibling)q.style.paddingRight=s.display.nativeBarWidth+"px";(s.addKeyMap(this.keyMap=function(t,e){var n={Up:function(){e.moveFocus(-1)},Down:function(){e.moveFocus(1)},PageUp:function(){e.moveFocus(1-e.menuSize(),!0)},PageDown:function(){e.moveFocus(e.menuSize()-1,!0)},Home:function(){e.setFocus(0)},End:function(){e.setFocus(e.length-1)},Enter:e.pick,Tab:e.pick,Esc:e.close},i=/Mac/.test(navigator.platform);isSame&&(n.Space=e.pick,n[","]=e.pick),i&&(n["Ctrl-P"]=function(){e.moveFocus(-1)},n["Ctrl-N"]=function(){e.moveFocus(1)});var o=t.options.customKeys,r=o?{}:n;function s(t,i){var o;o="string"!=typeof i?function(t){return i(t,e)}:n.hasOwnProperty(i)?n[i]:i,r[t]=o}if(o)for(var a in o)o.hasOwnProperty(a)&&s(a,o[a]);var c=t.options.extraKeys;if(c)for(var a in c)c.hasOwnProperty(a)&&s(a,c[a]);return r}(e,{moveFocus:function(t,e){i.changeActive(i.selectedHint+t,e)},setFocus:function(t){i.changeActive(t)},menuSize:function(){return i.screenAmount()},length:u.length,close:function(){e.close()},pick:function(){i.pick()},data:n})),e.options.closeOnUnfocus)&&(s.on("blur",this.onBlur=function(){P=setTimeout((function(){e.close()}),100)}),s.on("focus",this.onFocus=function(){clearTimeout(P)}));s.on("scroll",this.onScroll=function(){var t=s.getScrollInfo(),n=s.getWrapperElement().getBoundingClientRect();H||(H=s.getScrollInfo());var i=C+H.top-t.top,o=i-(c.pageYOffset||(a.documentElement||a.body).scrollTop);if(x||(o+=l.offsetHeight),o<=n.top||o>=n.bottom)return e.close();l.style.top=i+"px",l.style.left=y+H.left-t.left+"px"}),t.on(l,"dblclick",(function(t){var e=r(l,t.target||t.srcElement);e&&null!=e.hintId&&(i.changeActive(e.hintId),i.pick())})),t.on(l,"click",(function(t){var n=r(l,t.target||t.srcElement);n&&null!=n.hintId&&(i.changeActive(n.hintId),e.options.completeOnSingleClick&&i.pick())})),t.on(l,"mousedown",(function(){setTimeout((function(){s.focus()}),20)}));var R=this.getSelectedHintRange();return 0===R.from&&0===R.to||this.scrollToActive(),t.signal(n,"select",u[this.selectedHint],l.childNodes[this.selectedHint]),!0}function a(t,e,n,i){if(t.async)t(e,i,n);else{var o=t(e,n);o&&o.then?o.then(i):i(o)}}e.prototype={close:function(){this.active()&&(this.cm.state.completionActive=null,this.tick=null,this.options.updateOnCursorActivity&&this.cm.off("cursorActivity",this.activityFunc),this.widget&&this.data&&t.signal(this.data,"close"),this.widget&&this.widget.close(),t.signal(this.cm,"endCompletion",this.cm))},active:function(){return this.cm.state.completionActive==this},pick:function(e,n){var i=e.list[n],r=this;this.cm.operation((function(){i.hint?i.hint(r.cm,e,i):r.cm.replaceRange(o(i),i.from||e.from,i.to||e.to,"complete"),t.signal(e,"pick",i),r.cm.scrollIntoView()})),this.options.closeOnPick&&this.close()},cursorActivity:function(){this.debounce&&(i(this.debounce),this.debounce=0);var t=this.startPos;this.data&&(t=this.data.from);var e=this.cm.getCursor(),o=this.cm.getLine(e.line);if(e.line!=this.startPos.line||o.length-e.ch!=this.startLen-this.startPos.ch||e.ch0?" ".repeat(o):""),isSame&&"Space"===nameKey?"If"===this.data.list[0]?this.data.list[0]=this.data.list[0]+" ":"Do"!=this.data.list[0]&&(this.data.list[0]=this.data.list[0]+" ",isSame=!1,t=0):isSame&&"Enter"===nameKey?("If"===this.data.list[0]?(this.data.list[0]=this.data.list[0]+" \n"+e+"Endif",t=1):"On"===this.data.list[0]?(this.data.list[0]=this.data.list[0]+" Do\n\nEndon",t=2):"Do"===this.data.list[0]?(this.data.list[0]=this.data.list[0]+"\n\nEndon",t=2.2):(this.data.list[0]=this.data.list[0]+"\n"+n,t=0),isSame=!1):isSame&&","===nameKey&&(this.data.list[0]=this.data.list[0]+",",t=0,isSame=!1),"LogEntry"===this.data.list[this.selectedHint]&&(this.data.list[this.selectedHint]=this.data.list[this.selectedHint]+",''",t=3),this.completion.pick(this.data,this.selectedHint);var r=rEdit.getCursor().line,s=rEdit.getCursor().ch;if(1===t)rEdit.setCursor({line:r-1});else if(2===t)for(rEdit.setCursor({line:r-1}),rEdit.execCommand("insertSoftTab"),rEdit.setCursor({line:r-2,ch:i+1});rEdit.getCursor().ch>3;)rEdit.execCommand("indentLess");else 2.2===t?(rEdit.setCursor({line:r-1}),rEdit.execCommand("insertSoftTab")):3===t&&rEdit.setCursor({line:r,ch:s-1})},changeActive:function(e,n){if(e>=this.data.list.length?e=n?this.data.list.length-1:0:e<0&&(e=n?0:this.data.list.length-1),this.selectedHint!=e){var i=this.hints.childNodes[this.selectedHint];i&&(i.className=i.className.replace(" CodeMirror-hint-active",""),i.removeAttribute("aria-selected")),(i=this.hints.childNodes[this.selectedHint=e]).className+=" CodeMirror-hint-active",i.setAttribute("aria-selected","true"),this.completion.cm.getInputField().setAttribute("aria-activedescendant",i.id),this.scrollToActive(),t.signal(this.data,"select",this.data.list[this.selectedHint],i)}},scrollToActive:function(){var t=this.getSelectedHintRange(),e=this.hints.childNodes[t.from],n=this.hints.childNodes[t.to],i=this.hints.firstChild;e.offsetTopthis.hints.scrollTop+this.hints.clientHeight&&(this.hints.scrollTop=n.offsetTop+n.offsetHeight-this.hints.clientHeight+i.offsetTop)},screenAmount:function(){return Math.floor(this.hints.clientHeight/this.hints.firstChild.offsetHeight)||1},getSelectedHintRange:function(){var t=this.completion.options.scrollMargin||0;return{from:Math.max(0,this.selectedHint-t),to:Math.min(this.data.list.length-1,this.selectedHint+t)}}},t.registerHelper("hint","auto",{resolve:function(e,n){var i,o=e.getHelpers(n,"hint");if(o.length){var r=function(t,e,n){var i=function(t,e){if(!t.somethingSelected())return e;for(var n=[],i=0;i0?e(t):o(r+1)}))}(0)};return r.async=!0,r.supportsSelection=!0,r}return(i=e.getHelper(e.getCursor(),"hintWords"))?function(e){return t.hint.fromList(e,{words:i})}:t.hint.anyword?function(e,n){return t.hint.anyword(e,n)}:function(){}}}),t.registerHelper("hint","fromList",(function(e,n){var i,o=e.getCursor(),r=e.getTokenAt(o),s=t.Pos(o.line,r.start),a=o;r.start]/,closeOnPick:!0,closeOnUnfocus:!0,updateOnCursorActivity:!0,completeOnSingleClick:!0,container:null,customKeys:null,extraKeys:null,paddingForScrollbar:!0,moveOnOverlap:!0};t.defineOption("hintOptions",null)})),function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror"),require("./searchcursor"),require("../dialog/dialog")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./searchcursor","../dialog/dialog"],t):t(CodeMirror)}((function(t){"use strict";function e(){this.posFrom=this.posTo=this.lastQuery=this.query=null,this.overlay=null}function n(t){return t.state.search||(t.state.search=new e)}function i(t){return"string"==typeof t&&t==t.toLowerCase()}function o(t,e,n){return t.getSearchCursor(e,n,{caseFold:i(e),multiline:!0})}function r(t,e,n,i,o){t.openDialog?t.openDialog(e,o,{value:i,selectValueOnOpen:!0,bottom:t.options.search.bottom}):o(prompt(n,i))}function s(t){return t.replace(/\\([nrt\\])/g,(function(t,e){return"n"==e?"\n":"r"==e?"\r":"t"==e?"\t":"\\"==e?"\\":t}))}function a(t){var e=t.match(/^\/(.*)\/([a-z]*)$/);if(e)try{t=new RegExp(e[1],-1==e[2].indexOf("i")?"":"i")}catch(t){}else t=s(t);return("string"==typeof t?""==t:t.test(""))&&(t=/x^/),t}function c(t,e,n){e.queryText=n,e.query=a(n),t.removeOverlay(e.overlay,i(e.query)),e.overlay=function(t,e){return"string"==typeof t?t=new RegExp(t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),e?"gi":"g"):t.global||(t=new RegExp(t.source,t.ignoreCase?"gi":"g")),{token:function(e){t.lastIndex=e.pos;var n=t.exec(e.string);if(n&&n.index==e.pos)return e.pos+=n[0].length||1,"searching";n?e.pos=n.index:e.skipToEnd()}}}(e.query,i(e.query)),t.addOverlay(e.overlay),t.showMatchesOnScrollbar&&(e.annotate&&(e.annotate.clear(),e.annotate=null),e.annotate=t.showMatchesOnScrollbar(e.query,i(e.query)))}function l(e,i,o,s){var a=n(e);if(a.query)return h(e,i);var l=e.getSelection()||a.lastQuery;if(l instanceof RegExp&&"x^"==l.source&&(l=null),o&&e.openDialog){var f=null,p=function(n,i){t.e_stop(i),n&&(n!=a.queryText&&(c(e,a,n),a.posFrom=a.posTo=e.getCursor()),f&&(f.style.opacity=1),h(e,i.shiftKey,(function(t,n){var i;n.line<3&&document.querySelector&&(i=e.display.wrapper.querySelector(".CodeMirror-dialog"))&&i.getBoundingClientRect().bottom-4>e.cursorCoords(n,"window").top&&((f=i).style.opacity=.4)})))};!function(t,e,n,i,o){t.openDialog(e,i,{value:n,selectValueOnOpen:!0,closeOnEnter:!1,onClose:function(){u(t)},onKeyUp:o,bottom:t.options.search.bottom})}(e,d(e),l,p,(function(i,o){var r=t.keyName(i);"Enter"!=r&&o!=a.queryText&&(c(e,a,o),e.execCommand("goLineUp"),a.posFrom=a.posTo=e.getCursor(),h(e,i.shiftKey));var s=e.getOption("extraKeys"),l=s&&s[r]||t.keyMap[e.getOption("keyMap")][r];"findNext"==l||"findPrev"==l||"findPersistentNext"==l||"findPersistentPrev"==l?(t.e_stop(i),c(e,n(e),o),e.execCommand(l)):"find"!=l&&"findPersistent"!=l||(t.e_stop(i),p(o,i))})),s&&l&&(c(e,a,l),h(e,i))}else r(e,d(e),"Search for:",l,(function(t){t&&!a.query&&e.operation((function(){c(e,a,t),a.posFrom=a.posTo=e.getCursor(),h(e,i)}))}))}function h(e,i,r){e.operation((function(){const s=n(e);let a=o(e,s.query,i?s.posFrom:s.posTo);var c,l;(a.find(i)||(a=o(e,s.query,i?t.Pos(e.lastLine()):t.Pos(e.firstLine(),0)),a.find(i)))&&(c=a.from(),l=a.to(),e.__searchNextHighlight&&e.__searchNextHighlight.clear(),e.__searchNextHighlight=e.markText(c,l,{className:"search-next-highlight"}),e.setSelection(a.from(),a.to()),e.scrollTo(null,e.charCoords(a.from(),"local").top),s.posFrom=a.from(),s.posTo=a.to(),r&&r(a.from(),a.to()))}))}function u(t){t.operation((function(){var e=n(t);e.lastQuery=e.query,e.query&&(e.query=e.queryText=null,t.removeOverlay(e.overlay),e.annotate&&(e.annotate.clear(),e.annotate=null))}))}function f(t,e){var n=t?document.createElement(t):document.createDocumentFragment();for(var i in e)n[i]=e[i];for(var o=2;oh);u++){var f=t.getLine(l++);a=null==a?f:a+"\n"+f}c*=2,e.lastIndex=n.ch;var d=e.exec(a);if(d){var p=a.slice(0,d.index).split("\n"),m=d[0].split("\n"),g=n.line+p.length-1,v=p[p.length-1].length;return{from:i(g,v),to:i(g+m.length-1,1==m.length?v+m[0].length:m[m.length-1].length),match:d}}}}function c(t,e,n){for(var i,o=0;o<=t.length;){e.lastIndex=o;var r=e.exec(t);if(!r)break;var s=r.index+r[0].length;if(s>t.length-n)break;(!i||s>i.index+i[0].length)&&(i=r),o=r.index+1}return i}function l(t,e,n){e=o(e,"g");for(var r=n.line,s=n.ch,a=t.firstLine();r>=a;r--,s=-1){var l=t.getLine(r),h=c(l,e,s<0?0:l.length-s);if(h)return{from:i(r,h.index),to:i(r,h.index+h[0].length),match:h}}}function h(t,e,n){if(!r(e))return l(t,e,n);e=o(e,"gm");for(var s,a=1,h=t.getLine(n.line).length-n.ch,u=n.line,f=t.firstLine();u>=f;){for(var d=0;d=f;d++){var p=t.getLine(u--);s=null==s?p:p+"\n"+s}a*=2;var m=c(s,e,h);if(m){var g=s.slice(0,m.index).split("\n"),v=m[0].split("\n"),y=u+g.length,C=g[g.length-1].length;return{from:i(y,C),to:i(y+v.length-1,1==v.length?C+v[0].length:v[v.length-1].length),match:m}}}}function u(t,e,n,i){if(t.length==e.length)return n;for(var o=0,r=n+Math.max(0,t.length-e.length);;){if(o==r)return o;var s=o+r>>1,a=i(t.slice(0,s)).length;if(a==n)return s;a>n?r=s:o=s+1}}function f(t,o,r,s){if(!o.length)return null;var a=s?e:n,c=a(o).split(/\r|\n\r?/);t:for(var l=r.line,h=r.ch,f=t.lastLine()+1-c.length;l<=f;l++,h=0){var d=t.getLine(l).slice(h),p=a(d);if(1==c.length){var m=p.indexOf(c[0]);if(-1==m)continue t;r=u(d,p,m,a)+h;return{from:i(l,u(d,p,m,a)+h),to:i(l,u(d,p,m+c[0].length,a)+h)}}var g=p.length-c[0].length;if(p.slice(g)==c[0]){for(var v=1;v=f;l--,h=-1){var d=t.getLine(l);h>-1&&(d=d.slice(0,h));var p=a(d);if(1==c.length){var m=p.lastIndexOf(c[0]);if(-1==m)continue t;return{from:i(l,u(d,p,m,a)),to:i(l,u(d,p,m+c[0].length,a))}}var g=c[c.length-1];if(p.slice(0,g.length)==g){var v=1;for(r=l-c.length+1;v(this.doc.getLine(n.line)||"").length&&(n.ch=0,n.line++)),0!=t.cmpPos(n,this.doc.clipPos(n))))return this.atOccurrence=!1;var o=this.matches(e,n);if(this.afterEmptyMatch=o&&0==t.cmpPos(o.from,o.to),o)return this.pos=o,this.atOccurrence=!0,this.pos.match||!0;var r=i(e?this.doc.firstLine():this.doc.lastLine()+1,0);return this.pos={from:r,to:r},this.atOccurrence=!1},from:function(){if(this.atOccurrence)return this.pos.from},to:function(){if(this.atOccurrence)return this.pos.to},replace:function(e,n){if(this.atOccurrence){var o=t.splitLines(e);this.doc.replaceRange(o,this.pos.from,this.pos.to,n),this.pos.to=i(this.pos.from.line+o.length-1,o[o.length-1].length+(1==o.length?this.pos.from.ch:0))}}},t.defineExtension("getSearchCursor",(function(t,e,n){return new p(this.doc,t,e,n)})),t.defineDocExtension("getSearchCursor",(function(t,e,n){return new p(this,t,e,n)})),t.defineExtension("selectMatches",(function(e,n){for(var i=[],o=this.getSearchCursor(e,this.getCursor("from"),n);o.findNext()&&!(t.cmpPos(o.to(),this.getCursor("to"))>0);)i.push({anchor:o.from(),head:o.to()});i.length&&this.setSelections(i,0)}))})),function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}((function(t){function e(e,n,i){var o,r=document.body;return(o=r.appendChild(document.createElement("div"))).className=i?"CodeMirror-dialog CodeMirror-dialog-bottom":"CodeMirror-dialog CodeMirror-dialog-top","string"==typeof n?o.innerHTML=n:o.appendChild(n),t.addClass(r,"dialog-opened"),o}function n(t,e){t.state.currentNotificationClose&&t.state.currentNotificationClose(),t.state.currentNotificationClose=e}t.defineExtension("openDialog",(function(i,o,r){r||(r={}),n(this,null);var s=e(0,i,r.bottom),a=!1,c=this;function l(e){if("string"==typeof e)u.value=e;else{if(a)return;a=!0,t.rmClass(s.parentNode,"dialog-opened"),s.parentNode.removeChild(s),c.focus(),r.onClose&&r.onClose(s)}}var h,u=s.getElementsByTagName("input")[0];return u?(u.focus(),r.value&&(u.value=r.value,!1!==r.selectValueOnOpen&&u.select()),r.onInput&&t.on(u,"input",(function(t){r.onInput(t,u.value,l)})),r.onKeyUp&&t.on(u,"keyup",(function(t){r.onKeyUp(t,u.value,l)})),t.on(u,"keydown",(function(e){r&&r.onKeyDown&&r.onKeyDown(e,u.value,l)||((27==e.keyCode||!1!==r.closeOnEnter&&13==e.keyCode)&&(u.blur(),t.e_stop(e),l()),13==e.keyCode&&o(u.value,e))})),!1!==r.closeOnBlur&&t.on(s,"focusout",(function(t){null!==t.relatedTarget&&l()}))):(h=s.getElementsByTagName("button")[0])&&(t.on(h,"click",(function(){l(),c.focus()})),!1!==r.closeOnBlur&&t.on(h,"blur",l),h.focus()),l})),t.defineExtension("openConfirm",(function(i,o,r){n(this,null);var s=e(0,i,r&&r.bottom),a=s.getElementsByTagName("button"),c=!1,l=this,h=1;function u(){c||(c=!0,t.rmClass(s.parentNode,"dialog-opened"),s.parentNode.removeChild(s),l.focus())}a[0].focus();for(var f=0;f { alert(`Available shortcuts: • Ctrl+F / Cmd+F: Open search -• Ctrl+G / Cmd+G: Find next +• Enter or + Ctrl+G / Cmd+G: Find next • Shift+Ctrl+G / Shift+Cmd+G: Find previous • Shift+Ctrl+F / Cmd+Option+F: Replace • Shift+Ctrl+R / Shift+Cmd+Option+F: Replace all -• Use /re/ syntax for regexp search`); +• Use /re/ syntax for regex search`); } } ]; diff --git a/static/espeasy.min.js b/static/espeasy.min.js index b34b46775..680d1eb2c 100644 --- a/static/espeasy.min.js +++ b/static/espeasy.min.js @@ -1 +1 @@ -var commonAtoms=["And","Or"],commonKeywords=["If","Else","Elseif","Endif"],commonCommands=["AccessInfo","Background","Build","ClearAccessBlock","ClearRTCam","Config","ControllerDisable","ControllerEnable","DateTime","Debug","Dec","DeepSleep","DisablePriorityTask","DNS","DST","EraseSDKWiFi","ExecuteRules","FactoryReset","Gateway","I2Cscanner","Inc","IP","Let","LetStr","Load","LogEntry","LogPortStatus","LoopTimerSet","LoopTimerSet_ms","LoopTimerSetAndRun","LoopTimerSetAndRun_ms","MemInfo","MemInfoDetail","Name","Password","PostToHTTP","Publish","PublishR","Reboot","Save","SendTo","SendToHTTP","SendToUDP","SendToUDPMix","Settings","Subnet","Subscribe","TaskClear","TaskClearAll","TaskDisable","TaskEnable","TaskRun","TaskValueSet","TaskValueSetAndRun","TaskValueSetDerived","TaskValueSetPresentation","TimerPause","TimerResume","TimerSet","TimerSet_ms","TimeZone","UdpPort","UdpTest","Unit","UseNTP","WdConfig","WdRead","WiFi","WiFiAllowAP","WiFiAPMode","WiFiConnect","WiFiDisconnect","WiFiKey","WiFiKey2","WiFiMode","WiFiScan","WiFiSSID","WiFiSSID2","WiFiSTAMode","Event","AsyncEvent","GPIO","GPIOToggle","LongPulse","LongPulse_mS","Monitor","Pulse","PWM","Servo","Status","Tone","RTTTL","UnMonitor","Provision","Provision,Config","Provision,Security","Provision,Notification","Provision,Provision","Provision,Rules","Provision,CustomCdnUrl","Provision,Firmware"],commonEvents=["Clock#Time","Login#Failed","MQTT#Connected","MQTT#Disconnected","MQTTimport#Connected","MQTTimport#Disconnected","Rules#Timer","System#Boot","System#BootMode","System#Sleep","System#Wake","TaskExit#","TaskInit#","ThingspeakReply","Time#Initialized","Time#Set","WiFi#APmodeDisabled","WiFi#APmodeEnabled","WiFi#ChangedAccesspoint","WiFi#ChangedWiFichannel","WiFi#Connected","WiFi#Disconnected"],commonPlugins=["ResetPulseCounter","SetPulseCounterTotal","LogPulseStatistic","analogout","MCPGPIO","MCPGPIOToggle","MCPLongPulse","MCPLongPulse_ms","MCPPulse","Status,MCP","Monitor,MCP","MonitorRange,MCP","UnMonitorRange,MCP","UnMonitor,MCP","MCPGPIORange","MCPGPIOPattern","MCPMode","MCPModeRange","ExtGpio","ExtPwm","ExtPulse","ExtLongPulse","Status,EXT,","LCDCmd","LCD","PCFGPIO","PCFGPIOToggle","PCFLongPulse","PCFLongPulse_ms","PCFPulse","Status,PCF","Monitor,PCF","MonitorRange,PCF","UnMonitorRange,PCF","UnMonitor,PCF","PCFGPIORange","PCFGPIOpattern","PCFMode","PCFmodeRange","SerialSend","SerialSendMix","Ser2NetClientSend","SerialSend_test","pcapwm","pcafrq","mode2","OLED","OLEDCMD","OLEDCMD,on","OLEDCMD,off","OLEDCMD,clear","IRSEND","IRSENDAC","OledFramedCmd","OledFramedCmd,Display","OledFramedCmd,low","OledFramedCmd,med","OledFramedCmd,high","OledFramedCmd,Frame","OledFramedCmd,linecount","OledFramedCmd,leftalign","OledFramedCmd,align","OledFramedCmd,userDef1","OledFramedCmd,userDef2","NeoPixel","NeoPixelAll","NeoPixelLine","NeoPixelHSV","NeoPixelAllHSV","NeoPixelLineHSV","NeoPixelBright","MotorShieldCmd,DCMotor","MotorShieldCmd,Stepper","MHZCalibrateZero","MHZReset","MHZABCEnable","MHZABCDisable","Sensair_SetRelay","PMSX003","PMSX003,Wake","PMSX003,Sleep","PMSX003,Reset","encwrite","Play","Vol","Eq","Mode","Repeat","tareChanA","tareChanB","7dn","7dst","7dsd","7dtext","7ddt","7dt","7dtfont","7dtbin","7don","7doff","7output","HLWCalibrate","HLWReset","csecalibrate","cseclearpulses","csereset","WemosMotorShieldCMD","LolinMotorShieldCMD","GPS","GPS,Sleep","GPS,Wake","GPS#GotFix","GPS#LostFix","GPS#Travelled","homieValueSet","SerialProxy_Write","SerialProxy_WriteMix","SerialProxy_Test","HeatPumpir","MitsubishiHP","MitsubishiHP,temperature","MitsubishiHP,power","MitsubishiHP,mode","MitsubishiHP,fan","MitsubishiHP,vane","MitsubishiHP,widevane","Culreader_Write","Touch","Touch,Rot","Touch,Flip","Touch,Enable","Touch,Disable","Touch,On","Touch,Off","Touch,Toggle","Touch,Setgrp","Touch,Incgrp","Touch,Decgrp","Touch,Incpage","Touch,Decpage","Touch,Updatebutton","WakeOnLan","DotMatrix","DotMatrix,clear","DotMatrix,update","DotMatrix,size","DotMatrix,txt","DotMatrix,settxt","DotMatrix,content","DotMatrix,alignment","DotMatrix,anim.in","DotMatrix,anim.out","DotMatrix,speed","DotMatrix,pause","DotMatrix,font","DotMatrix,layout","DotMatrix,inverted","DotMatrix,specialeffect","DotMatrix,offset","DotMatrix,brightness","DotMatrix,repeat","DotMatrix,setbar","DotMatrix,bar","Thermo","Thermo,Up","Thermo,Down","Thermo,Mode","Thermo,ModeBtn","Thermo,Setpoint","Max1704xclearalert","scdgetabc","scdgetalt","scdgettmp","scdsetcalibration","scdsetfrc","scdgetinterval","multirelay","multirelay,on","multirelay,off","multirelay,set","multirelay,get","multirelay,loop","ShiftOut","ShiftOut,Set","ShiftOut,SetNoUpdate","ShiftOut,Update","ShiftOut,SetAll","ShiftOut,SetAllNoUpdate","ShiftOut,SetAllLow","ShiftOut,SetAllHigh","ShiftOut,SetChipCount","ShiftOut,SetHexBin","cdmrst","nfx","nfx,off","nfx,on","nfx,dim","nfx,line,","nfx,hsvline,","nfx,one,","nfx,hsvone,","nfx,all,","nfx,rgb,","nfx,fade,","nfx,hsv,","nfx,colorfade,","nfx,rainbow","nfx,kitt,","nfx,comet,","nfx,theatre,","nfx,scan,","nfx,dualscan,","nfx,twinkle,","nfx,twinklefade,","nfx,sparkle,","nfx,wipe,","nfx,dualwipe","nfx,fire","nfx,fireflicker","nfx,faketv","nfx,simpleclock","nfx,stop","nfx,statusrequest","nfx,fadetime,","nfx,fadedelay,","nfx,speed,","nfx,count,","nfx,bgcolor","ShiftIn","ShiftIn,PinEvent","ShiftIn,ChipEvent","ShiftIn,SetChipCount","ShiftIn,SampleFrequency","ShiftIn,EventPerPin","scd4x","scd4x,storesettings","scd4x,facoryreset","scd4x,selftest","scd4x,setfrc,","axp","axp,ldo2","axp,ldo3","axp,ldoio","axp,gpio0","axp,gpio1","axp,gpio2","axp,gpio3","axp,gpio4","axp,dcdc2","axp,dcdc3","axp,ldo2map","axp,ldo3map","axp,ldoiomap","axp,dcdc2map","axp,dcdc3map","axp,ldo2perc","axp,ldo3perc","axp,ldoioperc","axp,dcdc2perc","axp,dcdc3perc","I2CEncoder","I2CEncoder,bright","I2CEncoder,led1","I2CEncoder,led2","I2CEncoder,gain","I2CEncoder,set","cachereader","cachereader,readpos","cachereader,sendtaskinfo","cachereader,flush","tm1621","tm1621,write,","tm1621,writerow,","tm1621,voltamp,","tm1621,energy,","tm1621,celcius,","tm1621,fahrenheit,","tm1621,humidity,","tm1621,raw,","dac","dac,1","dac,2","sht4x","sht4x,startup","ld2410","ld2410,factoryreset","ld2410,logall","digipot","digipot,reset","digipot,shutdown","digipot,","7dextra","7dbefore","7dgroup","7digit","7color","7digitcolor","7groupcolor","gp8403","gp8403,volt,","gp8403,mvolt,","gp8403,range,","gp8403,preset,","gp8403,init,","sen5x","sen5x,startclean","sen5x,techlog,","as3935","as3935,clearstats","as3935,calibrate","as3935,setgain,","as3935,setnf,","as3935,setwd,","as3925,setsrej,","lu9685","lu9685,servo,","lu9685,enable,","lu9685,disable,","lu9685,setrange,","geni2c","geni2c,cmd,","geni2c,exec,","geni2c,log,"],pluginDispKind=["tft","ili9341","ili9342","ili9481","ili9486","ili9488","epd","eink","epaper","il3897","uc8151d","ssd1680","ws2in7","ws1in54","st77xx","st7735","st7789","st7796","neomatrix","neo","pcd8544"],pluginDispCmd=["cmd,on","cmd,off","cmd,clear","cmd,backlight","cmd,bright","cmd,deepsleep","cmd,seq_start","cmd,seq_end","cmd,inv","cmd,rot",",clear",",rot",",tpm",",txt",",txp",",txz",",txc",",txs",",txtfull",",asciitable",",font",",l",",lh",",lv",",lm",",lmr",",r",",rf",",c",",cf",",rf",",t",",tf",",rr",",rrf",",px",",pxh",",pxv",",bmp",",btn",",win",",defwin",",delwin"],commonTag=["On","Do","Endon"],commonNumber=["toBin","toHex","Constrain","XOR","AND:","OR:","Ord","bitRead","bitSet","bitClear","bitWrite","urlencode"],commonMath=["Log","Ln","Abs","Exp","Sqrt","Sq","Round","Sin","Cos","Tan","aSin","aCos","aTan","Sin_d","Cos_d","Tan_d","aSin_d","aCos_d","aTan_d","map","mapc"],commonWarning=["delay","Delay","ResetFlashWriteCounter"],taskSpecifics=["settings.Enabled","settings.Interval","settings.ValueCount","settings.Controller1.Enabled","settings.Controller2.Enabled","settings.Controller3.Enabled","settings.Controller1.Idx","settings.Controller2.Idx","settings.Controller3.Idx"],AnythingElse=["%eventvalue%","%eventpar%","%eventname%","%sysname%","%bootcause%","%systime%","%systm_hm%","%systm_hm_0%","%systm_hm_sp%","%systime_am%","%systime_am_0%","%systime_am_sp%","%systm_hm_am%","%systm_hm_am_0%","%systm_hm_am_sp%","%lcltime%","%sunrise%","%s_sunrise%","%m_sunrise%","%sunset%","%s_sunset%","%m_sunset%","%lcltime_am%","%syshour%","%syshour_0%","%sysmin%","%sysmin_0%","%syssec%","%syssec_0%","%sysday%","%sysday_0%","%sysmonth%","%sysmonth_0%","%systzoffset%","%systzoffset_s%","%sysyear%","%sysyear_0%","%sysyears%","%sysweekday%","%sysweekday_s%","%unixtime%","%unixtime_lcl%","%uptime%","%uptime_ms%","%rssi%","%ip%","%unit%","%unit_0%","%ssid%","%bssid%","%wi_ch%","%iswifi%","%vcc%","%mac%","%mac_int%","%isntp%","%ismqtt%","%dns%","%dns1%","%dns2%","%flash_freq%","%flash_size%","%flash_chip_vendor%","%flash_chip_model%","%fs_free%","%fs_size%","%cpu_id%","%cpu_freq%","%cpu_model%","%cpu_rev%","%cpu_cores%","%board_name%","%inttemp%","%islimited_build%","%isvar_double%","substring","lookup","indexOf","indexOf_ci","equals","equals_ci","strtol","timeToMin","timeToSec","%ethwifimode%","%ethconnected%","%ethduplex%","%ethspeed%","%ethstate%","%ethspeedstate%","%c_w_dir%","%c_c2f%","%c_ms2Bft%","%c_dew_th%","%c_alt_pres_sea%","%c_sea_pres_alt%","%c_cm2imp%","%c_isnum%","%c_mm2imp%","%c_m2day%","%c_m2dh%","%c_m2dhm%","%c_s2dhms%","%c_ts2date%","%c_ts2wday%","%c_random%","%c_2hex%","%c_u2ip%","%c_uname%","%c_uage%","%c_ubuild%","%c_ubuildstr%","%c_uload%","%c_utype%","%c_utypestr%","%c_strf%","var","int","str","length"];for(const e of pluginDispKind)commonPlugins=commonPlugins.concat(e);for(const e of pluginDispKind)for(const t of pluginDispCmd){let n=e+t;commonPlugins=commonPlugins.concat(n)}var rEdit,EXTRAWORDS=commonAtoms.concat(commonPlugins,commonKeywords,commonCommands,commonEvents,commonTag,commonNumber,commonMath,commonWarning,taskSpecifics,AnythingElse),confirmR=!0,android=/Android/.test(navigator.userAgent);function initCM(){android&&(confirmR=!!confirm("Do you want to enable colored rules?\n(There are some issues with Android causing it to fail!)\nTestet with Chrome, Firefox and Vivaldi so far.\nPlease report any issues you may have with this feature.")),confirmR&&(CodeMirror.commands.autocomplete=function(e){e.showHint({hint:CodeMirror.hint.anyword})},(rEdit=CodeMirror.fromTextArea(document.getElementById("rules"),{tabSize:2,indentWithTabs:!1,lineNumbers:!0,autoCloseBrackets:!0,extraKeys:{"Ctrl-Space":"autocomplete",Tab:e=>{"null"===e.getMode().name?e.execCommand("insertTab"):e.somethingSelected()?e.execCommand("indentMore"):e.execCommand("insertSoftTab")},"Shift-Tab":e=>e.execCommand("indentLess")}})).on("change",(function(){rEdit.save()})),android||rEdit.on("inputRead",(function(e,t){var n=e.getCursor(),o=e.getTokenAt(n);/[\w%,.]/.test(t.text)&&"comment"!=o.type&&e.showHint({completeSingle:!1})})),CodeMirror.keyMap.default["Ctrl-F"]=function(e){openFind()},CodeMirror.keyMap.default["Cmd-F"]=function(e){openFind()})}function closeSearchDialog(){const e=document.querySelectorAll(".CodeMirror-dialog");e.length>0&&(e.forEach((e=>e.remove())),document.body.classList.remove("dialog-opened")),rEdit.execCommand("clearSearch")}function removeHighlight(){requestAnimationFrame((()=>{document.querySelectorAll(".search-next-highlight").forEach((e=>e.classList.remove("search-next-highlight")))}))}let findDialogObserver=null;function openFind(){findDialogObserver&&(findDialogObserver.disconnect(),findDialogObserver=null),findDialogObserver=new MutationObserver((()=>{document.querySelector(".CodeMirror-dialog")||(removeHighlight(),findDialogObserver.disconnect(),findDialogObserver=null)})),findDialogObserver.observe(document.body,{childList:!0,subtree:!0}),clearSearchNextHighlight(rEdit),rEdit.execCommand("findPersistent"),addFindButtons()}function clearSearchNextHighlight(e){removeHighlight(),e.__searchNextHighlight&&(e.__searchNextHighlight.clear(),e.__searchNextHighlight=null)}function addFindButtons(){document.querySelector(".CodeMirror-selected");const e=document.querySelector(".CodeMirror-dialog");if(!e||e.querySelector(".search-button-group"))return;[{title:"Find Previous",symbol:"▲",action:()=>rEdit.execCommand("findPersistentPrev")},{title:"Find Next",symbol:"▼",action:()=>rEdit.execCommand("findPersistentNext")},{title:"Replace",symbol:"Replace",action:()=>{closeSearchDialog(),rEdit.execCommand("replace"),addFindButtons()}},{title:"Close",symbol:"❌",action:closeSearchDialog},{title:"Help",symbol:"?",action:()=>{alert("Available shortcuts:\n• Ctrl+F / Cmd+F: Open search\n• Ctrl+G / Cmd+G: Find next\n• Shift+Ctrl+G / Shift+Cmd+G: Find previous\n• Shift+Ctrl+F / Cmd+Option+F: Replace\n• Shift+Ctrl+R / Shift+Cmd+Option+F: Replace all\n• Use /re/ syntax for regexp search")}}].forEach((({title:t,symbol:n,action:o})=>{const i=document.createElement("span");i.title=t,i.className="help"===t.toLowerCase()?"button help":"button",i.innerHTML=n,i.style.cssText="\n cursor: pointer;\n user-select: none;\n ",i.addEventListener("click",(e=>{e.preventDefault(),o()})),e.appendChild(i)}))}function triggerFormatting(){if(confirmR){const e=rEdit.getDoc(),t=(rEdit.getScrollInfo(),e.getCursor()),n=0===t.ch?t.line-1:t.line;rEdit.getLine(n)}let e=confirmR?rEdit.getValue():document.getElementById("rules").value;if(e=initalAutocorrection(e),e=formatLogic(e),confirmR){rEdit.setValue(e);const t=currentLine,n=0===cursor.ch&&lineText.length>0?lineText.length:cursor.ch-1;rEdit.setCursor({line:t,ch:n}),rEdit.scrollTo(scrollInfo.left,scrollInfo.top),rEdit.focus(),rEdit.save()}else document.getElementById("rules").value=e}function initalAutocorrection(e){for(const t of EXTRAWORDS)if("Do"===t){const t=/(^|\s)(do)(\s*)(\/\/.*)?$/gim;e=e.replace(t,((e,t,n,o,i)=>`${t}Do${o}${i??""}`))}else{const n=new RegExp(`^\\s*\\b${t}\\b`,"gmi");e=e.replace(n,(e=>e.replace(new RegExp(t,"i"),t)))}return e}function formatLogic(e){const t=" ",n=e.split("\n").map((e=>{const t=e.trimStart();return t.startsWith("//")?e:t})),o=[],i=[];let r=!1,s=null,a=[],c=[];function l(e){return e.trim().startsWith("//")}function d(e){return""===e.trim()}function m(e){return e.trim().toLowerCase().startsWith("on")}function u(e){return e.trim().toLowerCase().endsWith("do")}function f(e){return"endon"===e.trim().toLowerCase()}function h(e){return e.trim().toLowerCase().startsWith("if")}function p(e){return"else"===e.trim().toLowerCase()}function g(e){return e.trim().toLowerCase().startsWith("elseif")}function x(e){return"endif"===e.trim().toLowerCase()}let C=0;function S(){a.length>0&&(i.push(`• Missing ${a.length} Endif(s):`),i.push(` - Unclosed If block(s) starting at line(s): ${c.join(", ")}`)),a=[],c=[]}for(let e=0;e0){const e=extractFirstErrorLine(i);if(alert("Errors found:\n"+i.join("\n")),!isNaN(e))if(confirmR)setTimeout((()=>{jumpToLine(e)}),50);else{const t=document.getElementById("rules");setTimeout((()=>{jumpToLineInTextarea(t,e)}),50)}}return o.join("\n")}function jumpToLine(e){const t=Math.max(0,e-1);rEdit.setCursor({line:t,ch:0}),rEdit.focus(),rEdit.scrollIntoView({line:t,ch:0},100)}function extractFirstErrorLine(e){for(const t of e){let e=t.match(/• Line (\d+)/);if(e)return parseInt(e[1]);if(e=t.match(/starting at line (\d+)/),e)return parseInt(e[1]);if(e=t.match(/starting at line\(s\):\s*(\d+)/),e)return parseInt(e[1])}return null}function jumpToLineInTextarea(e,t){const n=e.value.split("\n"),o=Math.max(1,Math.min(t,n.length));let i=0;for(let e=0;e{const e=document.getElementById("rulesselect");if(e){if(confirmR){const t=document.createElement("button");t.type="button",t.id="searchBtn",t.innerHTML="🔎︎",t.style.padding="2px 5px",t.className="button help",e.appendChild(t),t.addEventListener("click",(()=>{void 0!==rEdit&&openFind()}))}const t=document.createElement("button");t.type="button",t.id="formatBtn",t.textContent="Format",t.className="button",e.appendChild(t),t.addEventListener("click",(()=>{triggerFormatting()}))}let t="";if(document.addEventListener("keydown",(function(e){const n=e.key;if(e.ctrlKey&&e.shiftKey&&"f"===n.toLowerCase())return e.preventDefault(),void triggerFormatting();(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Enter","Tab","Escape","Shift","Control","Alt","Meta"].includes(n)||1!==n.length)&&(t="")})),android){var n=!1;rEdit.on("keydown",((e,o)=>{["Enter","Backspace"," "].includes(o.key)&&(t=""),n=!0}));let e="";const i=rEdit.getInputField();function o(o,i=!1){if(!(rEdit.hasFocus()&&rEdit&&o.data&&n))return;n=!1;const r=o.data,s=rEdit.getDoc(),a=s.getCursor(),c=rEdit.getTokenAt(a);if(" "===r)return t="",void(e="");if(!(r===e&&t.length>0))if(/[\w%,.]/.test(r)&&"comment"!==c.type){const n=a.ch<=1?r.slice(-1):r;t+=n,e=t,t.startsWith(String(a.line+1))&&0===a.ch&&(t=t.slice(String(a.line).length));const o={line:a.line,ch:a.ch-t.length+1},c=()=>{s.replaceRange(t,o,a),rEdit.setCursor({line:o.line,ch:o.ch+t.length}),rEdit.showHint({completeSingle:!1})};i?c():setTimeout(c,0)}else t=""}const r=navigator.userAgent.toLowerCase(),s=/firefox/.test(r),a=/chrome/.test(r)&&!s;s?i.addEventListener("beforeinput",(e=>{e.preventDefault(),o(e,!0)})):a&&document.addEventListener("input",(e=>{o(e,!1)})),rEdit.on("endCompletion",(function(){setTimeout((()=>{!function(){const e=document.createElement("input");e.type="text",e.style.position="absolute",e.style.opacity="0",e.style.height="0",e.style.width="0",e.style.border="none",e.style.top="0",e.style.left="-9999",e.style.padding="0",e.style.zIndex="-1",e.style.fontSize="16px",document.body.appendChild(e),e.focus(),setTimeout((()=>{e.remove(),rEdit.focus()}),10)}()}),100)}))}})),function(e){"object"==typeof exports&&"object"==typeof module?e(require("codemirror")):"function"==typeof define&&define.amd?define(["codemirror"],e):e(CodeMirror)}((function(e){"use strict";e.defineMode("espeasy",(function(){var e={};function t(t,n){for(var o=0;oe.toLowerCase()));commonCommands=commonCommands.concat(n);var o=commonEvents.map((e=>e.toLowerCase()));commonEvents=commonEvents.concat(o);var i=commonPlugins.map((e=>e.toLowerCase()));commonPlugins=commonPlugins.concat(i);var r=commonAtoms.map((e=>e.toLowerCase()));commonAtoms=commonAtoms.concat(r);var s=commonKeywords.map((e=>e.toLowerCase()));commonKeywords=commonKeywords.concat(s);var a=commonTag.map((e=>e.toLowerCase()));commonTag=commonTag.concat(a);var c=commonNumber.map((e=>e.toLowerCase()));commonNumber=commonNumber.concat(c);var l=commonMath.map((e=>e.toLowerCase()));commonMath=commonMath.concat(l);var d=AnythingElse.map((e=>e.toLowerCase()));AnythingElse=AnythingElse.concat(d);var m=taskSpecifics.map((e=>e.toLowerCase()));function u(t,n){if(t.eatSpace())return null;t.sol();var o=t.next();if(/\d/.test(o)){if("0"==o)return"x"===t.next()?(t.eatWhile(/\w/),"number"):(t.eatWhile(/\d|\./),"number");if(t.eatWhile(/\d|\./),!t.match("d")&&!t.match("output")&&(t.eol()||/\D/.test(t.peek())))return"number"}if(/\w/.test(o))for(const e of EXTRAWORDS){let n=e.substring(1);(e.includes(":")||e.includes(",")||e.includes("."))&&t.match(n)}if(/\w/.test(o)&&(t.eatWhile(/[\w]/),t.match(".gpio")||t.match(".pulse")||t.match(".frq")||t.match(".pwm")))return"def";if("\\"===o)return t.next(),null;if("("===o||")"===o)return"bracket";if("{"===o||"}"===o||":"===o)return"number";if("/"==o)return/\//.test(t.peek())?(t.skipToEnd(),"comment"):"operator";if("'"==o&&(t.eatWhile(/[^']/),t.match("'")))return"attribute";if("+"===o||"="===o||"<"===o||">"===o||"-"===o||","===o||"*"===o||"!"===o)return"operator";if("%"==o){if(/\d/.test(t.next()))return"number";if(t.eatWhile(/[^\s\%]/),t.match("%"))return"hr"}if("["==o&&(t.eatWhile(/[^\s\]]/),t.eat("]")))return"hr";t.eatWhile(/\w/);var i=t.current();return/\w/.test(o)&&t.match("#")?(t.eatWhile(/[\w.#]/),"events"):"#"===o?(t.eatWhile(/\w/),"number"):e.hasOwnProperty(i)?e[i]:null}function f(e,t){return(t.tokens[0]||u)(e,t)}return taskSpecifics=taskSpecifics.concat(m),t("atom",commonAtoms),t("keyword",commonKeywords),t("builtin",commonCommands),t("events",commonEvents),t("def",commonPlugins),t("tag",commonTag),t("number",commonNumber),t("bracket",commonMath),t("warning",commonWarning),t("hr",AnythingElse),t("comment",taskSpecifics),{startState:function(){return{tokens:[]}},token:function(e,t){return f(e,t)},closeBrackets:"[]{}''\"\"``()",lineComment:"//",fold:"brace"}}))})),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],mod):e(CodeMirror)}((function(e){var t={pairs:"()[]{}''\"\"",closeBefore:")]}'\":;>",triples:"",explode:"[]{}"},n=e.Pos;function o(e,n){return"pairs"==n&&"string"==typeof e?e:"object"==typeof e&&null!=e[n]?e[n]:t[n]}e.defineOption("autoCloseBrackets",!1,(function(t,n,s){s&&s!=e.Init&&(t.removeKeyMap(i),t.state.closeBrackets=null),n&&(r(o(n,"pairs")),t.state.closeBrackets=n,t.addKeyMap(i))}));var i={Backspace:function(t){var i=a(t);if(!i||t.getOption("disableInput"))return e.Pass;for(var r=o(i,"pairs"),s=t.listSelections(),c=0;c=0;c--){var m=s[c].head;t.replaceRange("",n(m.line,m.ch-1),n(m.line,m.ch+1),"+delete")}},Enter:function(t){var n=a(t),i=n&&o(n,"explode");if(!i||t.getOption("disableInput"))return e.Pass;for(var r=t.listSelections(),s=0;s1&&h.indexOf(i)>=0&&t.getRange(n(b.line,b.ch-2),b)==i+i){if(b.ch>2&&/\bstring/.test(t.getTokenTypeAt(n(b.line,b.ch-2))))return e.Pass;S="addFour"}else if(p){var v=0==b.ch?" ":t.getRange(n(b.line,b.ch-1),b);if(e.isWordChar(P)||v==i||e.isWordChar(v))return e.Pass;S="both"}else{if(!x||!(0===P.length||/\s/.test(P)||f.indexOf(P)>-1))return e.Pass;S="both"}else S=p&&m(t,b)?"both":h.indexOf(i)>=0&&t.getRange(b,n(b.line,b.ch+3))==i+i+i?"skipThree":"skip";if(u){if(u!=S)return e.Pass}else u=S}var T=d%2?s.charAt(d-1):i,M=d%2?i:s.charAt(d+1);t.operation((function(){if("skip"==u)c(t,1);else if("skipThree"==u)c(t,3);else if("surround"==u){for(var e=t.getSelections(),n=0;n0?{line:s.head.line,ch:s.head.ch+t}:{line:s.head.line-1};n.push({anchor:a,head:a})}e.setSelections(n,i)}function l(t){var o=e.cmpPos(t.anchor,t.head)>0;return{anchor:new n(t.anchor.line,t.anchor.ch+(o?-1:1)),head:new n(t.head.line,t.head.ch+(o?1:-1))}}function d(e,t){var o=e.getRange(n(t.line,t.ch-1),n(t.line,t.ch+1));return 2==o.length?o:null}function m(e,t){var o=e.getTokenAt(n(t.line,t.ch+1));return/\bstring/.test(o.type)&&o.start==t.ch&&(0==t.ch||!/\bstring/.test(e.getTokenTypeAt(t)))}r(t.pairs+"`")})); \ No newline at end of file +var commonAtoms=["And","Or"],commonKeywords=["If","Else","Elseif","Endif"],commonCommands=["AccessInfo","Background","Build","ClearAccessBlock","ClearRTCam","Config","ControllerDisable","ControllerEnable","DateTime","Debug","Dec","DeepSleep","DisablePriorityTask","DNS","DST","EraseSDKWiFi","ExecuteRules","FactoryReset","Gateway","I2Cscanner","Inc","IP","Let","LetStr","Load","LogEntry","LogPortStatus","LoopTimerSet","LoopTimerSet_ms","LoopTimerSetAndRun","LoopTimerSetAndRun_ms","MemInfo","MemInfoDetail","Name","Password","PostToHTTP","Publish","PublishR","Reboot","Save","SendTo","SendToHTTP","SendToUDP","SendToUDPMix","Settings","Subnet","Subscribe","TaskClear","TaskClearAll","TaskDisable","TaskEnable","TaskRun","TaskValueSet","TaskValueSetAndRun","TaskValueSetDerived","TaskValueSetPresentation","TimerPause","TimerResume","TimerSet","TimerSet_ms","TimeZone","UdpPort","UdpTest","Unit","UseNTP","WdConfig","WdRead","WiFi","WiFiAllowAP","WiFiAPMode","WiFiConnect","WiFiDisconnect","WiFiKey","WiFiKey2","WiFiMode","WiFiScan","WiFiSSID","WiFiSSID2","WiFiSTAMode","Event","AsyncEvent","GPIO","GPIOToggle","LongPulse","LongPulse_mS","Monitor","Pulse","PWM","Servo","Status","Tone","RTTTL","UnMonitor","Provision","Provision,Config","Provision,Security","Provision,Notification","Provision,Provision","Provision,Rules","Provision,CustomCdnUrl","Provision,Firmware"],commonEvents=["Clock#Time","Login#Failed","MQTT#Connected","MQTT#Disconnected","MQTTimport#Connected","MQTTimport#Disconnected","Rules#Timer","System#Boot","System#BootMode","System#Sleep","System#Wake","TaskExit#","TaskInit#","ThingspeakReply","Time#Initialized","Time#Set","WiFi#APmodeDisabled","WiFi#APmodeEnabled","WiFi#ChangedAccesspoint","WiFi#ChangedWiFichannel","WiFi#Connected","WiFi#Disconnected"],commonPlugins=["ResetPulseCounter","SetPulseCounterTotal","LogPulseStatistic","analogout","MCPGPIO","MCPGPIOToggle","MCPLongPulse","MCPLongPulse_ms","MCPPulse","Status,MCP","Monitor,MCP","MonitorRange,MCP","UnMonitorRange,MCP","UnMonitor,MCP","MCPGPIORange","MCPGPIOPattern","MCPMode","MCPModeRange","ExtGpio","ExtPwm","ExtPulse","ExtLongPulse","Status,EXT,","LCDCmd","LCD","PCFGPIO","PCFGPIOToggle","PCFLongPulse","PCFLongPulse_ms","PCFPulse","Status,PCF","Monitor,PCF","MonitorRange,PCF","UnMonitorRange,PCF","UnMonitor,PCF","PCFGPIORange","PCFGPIOpattern","PCFMode","PCFmodeRange","SerialSend","SerialSendMix","Ser2NetClientSend","SerialSend_test","pcapwm","pcafrq","mode2","OLED","OLEDCMD","OLEDCMD,on","OLEDCMD,off","OLEDCMD,clear","IRSEND","IRSENDAC","OledFramedCmd","OledFramedCmd,Display","OledFramedCmd,low","OledFramedCmd,med","OledFramedCmd,high","OledFramedCmd,Frame","OledFramedCmd,linecount","OledFramedCmd,leftalign","OledFramedCmd,align","OledFramedCmd,userDef1","OledFramedCmd,userDef2","NeoPixel","NeoPixelAll","NeoPixelLine","NeoPixelHSV","NeoPixelAllHSV","NeoPixelLineHSV","NeoPixelBright","MotorShieldCmd,DCMotor","MotorShieldCmd,Stepper","MHZCalibrateZero","MHZReset","MHZABCEnable","MHZABCDisable","Sensair_SetRelay","PMSX003","PMSX003,Wake","PMSX003,Sleep","PMSX003,Reset","encwrite","Play","Vol","Eq","Mode","Repeat","tareChanA","tareChanB","7dn","7dst","7dsd","7dtext","7ddt","7dt","7dtfont","7dtbin","7don","7doff","7output","HLWCalibrate","HLWReset","csecalibrate","cseclearpulses","csereset","WemosMotorShieldCMD","LolinMotorShieldCMD","GPS","GPS,Sleep","GPS,Wake","GPS#GotFix","GPS#LostFix","GPS#Travelled","homieValueSet","SerialProxy_Write","SerialProxy_WriteMix","SerialProxy_Test","HeatPumpir","MitsubishiHP","MitsubishiHP,temperature","MitsubishiHP,power","MitsubishiHP,mode","MitsubishiHP,fan","MitsubishiHP,vane","MitsubishiHP,widevane","Culreader_Write","Touch","Touch,Rot","Touch,Flip","Touch,Enable","Touch,Disable","Touch,On","Touch,Off","Touch,Toggle","Touch,Setgrp","Touch,Incgrp","Touch,Decgrp","Touch,Incpage","Touch,Decpage","Touch,Updatebutton","WakeOnLan","DotMatrix","DotMatrix,clear","DotMatrix,update","DotMatrix,size","DotMatrix,txt","DotMatrix,settxt","DotMatrix,content","DotMatrix,alignment","DotMatrix,anim.in","DotMatrix,anim.out","DotMatrix,speed","DotMatrix,pause","DotMatrix,font","DotMatrix,layout","DotMatrix,inverted","DotMatrix,specialeffect","DotMatrix,offset","DotMatrix,brightness","DotMatrix,repeat","DotMatrix,setbar","DotMatrix,bar","Thermo","Thermo,Up","Thermo,Down","Thermo,Mode","Thermo,ModeBtn","Thermo,Setpoint","Max1704xclearalert","scdgetabc","scdgetalt","scdgettmp","scdsetcalibration","scdsetfrc","scdgetinterval","multirelay","multirelay,on","multirelay,off","multirelay,set","multirelay,get","multirelay,loop","ShiftOut","ShiftOut,Set","ShiftOut,SetNoUpdate","ShiftOut,Update","ShiftOut,SetAll","ShiftOut,SetAllNoUpdate","ShiftOut,SetAllLow","ShiftOut,SetAllHigh","ShiftOut,SetChipCount","ShiftOut,SetHexBin","cdmrst","nfx","nfx,off","nfx,on","nfx,dim","nfx,line,","nfx,hsvline,","nfx,one,","nfx,hsvone,","nfx,all,","nfx,rgb,","nfx,fade,","nfx,hsv,","nfx,colorfade,","nfx,rainbow","nfx,kitt,","nfx,comet,","nfx,theatre,","nfx,scan,","nfx,dualscan,","nfx,twinkle,","nfx,twinklefade,","nfx,sparkle,","nfx,wipe,","nfx,dualwipe","nfx,fire","nfx,fireflicker","nfx,faketv","nfx,simpleclock","nfx,stop","nfx,statusrequest","nfx,fadetime,","nfx,fadedelay,","nfx,speed,","nfx,count,","nfx,bgcolor","ShiftIn","ShiftIn,PinEvent","ShiftIn,ChipEvent","ShiftIn,SetChipCount","ShiftIn,SampleFrequency","ShiftIn,EventPerPin","scd4x","scd4x,storesettings","scd4x,facoryreset","scd4x,selftest","scd4x,setfrc,","axp","axp,ldo2","axp,ldo3","axp,ldoio","axp,gpio0","axp,gpio1","axp,gpio2","axp,gpio3","axp,gpio4","axp,dcdc2","axp,dcdc3","axp,ldo2map","axp,ldo3map","axp,ldoiomap","axp,dcdc2map","axp,dcdc3map","axp,ldo2perc","axp,ldo3perc","axp,ldoioperc","axp,dcdc2perc","axp,dcdc3perc","I2CEncoder","I2CEncoder,bright","I2CEncoder,led1","I2CEncoder,led2","I2CEncoder,gain","I2CEncoder,set","cachereader","cachereader,readpos","cachereader,sendtaskinfo","cachereader,flush","tm1621","tm1621,write,","tm1621,writerow,","tm1621,voltamp,","tm1621,energy,","tm1621,celcius,","tm1621,fahrenheit,","tm1621,humidity,","tm1621,raw,","dac","dac,1","dac,2","sht4x","sht4x,startup","ld2410","ld2410,factoryreset","ld2410,logall","digipot","digipot,reset","digipot,shutdown","digipot,","7dextra","7dbefore","7dgroup","7digit","7color","7digitcolor","7groupcolor","gp8403","gp8403,volt,","gp8403,mvolt,","gp8403,range,","gp8403,preset,","gp8403,init,","sen5x","sen5x,startclean","sen5x,techlog,","as3935","as3935,clearstats","as3935,calibrate","as3935,setgain,","as3935,setnf,","as3935,setwd,","as3925,setsrej,","lu9685","lu9685,servo,","lu9685,enable,","lu9685,disable,","lu9685,setrange,","geni2c","geni2c,cmd,","geni2c,exec,","geni2c,log,"],pluginDispKind=["tft","ili9341","ili9342","ili9481","ili9486","ili9488","epd","eink","epaper","il3897","uc8151d","ssd1680","ws2in7","ws1in54","st77xx","st7735","st7789","st7796","neomatrix","neo","pcd8544"],pluginDispCmd=["cmd,on","cmd,off","cmd,clear","cmd,backlight","cmd,bright","cmd,deepsleep","cmd,seq_start","cmd,seq_end","cmd,inv","cmd,rot",",clear",",rot",",tpm",",txt",",txp",",txz",",txc",",txs",",txtfull",",asciitable",",font",",l",",lh",",lv",",lm",",lmr",",r",",rf",",c",",cf",",rf",",t",",tf",",rr",",rrf",",px",",pxh",",pxv",",bmp",",btn",",win",",defwin",",delwin"],commonTag=["On","Do","Endon"],commonNumber=["toBin","toHex","Constrain","XOR","AND:","OR:","Ord","bitRead","bitSet","bitClear","bitWrite","urlencode"],commonMath=["Log","Ln","Abs","Exp","Sqrt","Sq","Round","Sin","Cos","Tan","aSin","aCos","aTan","Sin_d","Cos_d","Tan_d","aSin_d","aCos_d","aTan_d","map","mapc"],commonWarning=["delay","Delay","ResetFlashWriteCounter"],taskSpecifics=["settings.Enabled","settings.Interval","settings.ValueCount","settings.Controller1.Enabled","settings.Controller2.Enabled","settings.Controller3.Enabled","settings.Controller1.Idx","settings.Controller2.Idx","settings.Controller3.Idx"],AnythingElse=["%eventvalue%","%eventpar%","%eventname%","%sysname%","%bootcause%","%systime%","%systm_hm%","%systm_hm_0%","%systm_hm_sp%","%systime_am%","%systime_am_0%","%systime_am_sp%","%systm_hm_am%","%systm_hm_am_0%","%systm_hm_am_sp%","%lcltime%","%sunrise%","%s_sunrise%","%m_sunrise%","%sunset%","%s_sunset%","%m_sunset%","%lcltime_am%","%syshour%","%syshour_0%","%sysmin%","%sysmin_0%","%syssec%","%syssec_0%","%sysday%","%sysday_0%","%sysmonth%","%sysmonth_0%","%systzoffset%","%systzoffset_s%","%sysyear%","%sysyear_0%","%sysyears%","%sysweekday%","%sysweekday_s%","%unixtime%","%unixtime_lcl%","%uptime%","%uptime_ms%","%rssi%","%ip%","%unit%","%unit_0%","%ssid%","%bssid%","%wi_ch%","%iswifi%","%vcc%","%mac%","%mac_int%","%isntp%","%ismqtt%","%dns%","%dns1%","%dns2%","%flash_freq%","%flash_size%","%flash_chip_vendor%","%flash_chip_model%","%fs_free%","%fs_size%","%cpu_id%","%cpu_freq%","%cpu_model%","%cpu_rev%","%cpu_cores%","%board_name%","%inttemp%","%islimited_build%","%isvar_double%","substring","lookup","indexOf","indexOf_ci","equals","equals_ci","strtol","timeToMin","timeToSec","%ethwifimode%","%ethconnected%","%ethduplex%","%ethspeed%","%ethstate%","%ethspeedstate%","%c_w_dir%","%c_c2f%","%c_ms2Bft%","%c_dew_th%","%c_alt_pres_sea%","%c_sea_pres_alt%","%c_cm2imp%","%c_isnum%","%c_mm2imp%","%c_m2day%","%c_m2dh%","%c_m2dhm%","%c_s2dhms%","%c_ts2date%","%c_ts2wday%","%c_random%","%c_2hex%","%c_u2ip%","%c_uname%","%c_uage%","%c_ubuild%","%c_ubuildstr%","%c_uload%","%c_utype%","%c_utypestr%","%c_strf%","var","int","str","length"];for(const e of pluginDispKind)commonPlugins=commonPlugins.concat(e);for(const e of pluginDispKind)for(const t of pluginDispCmd){let n=e+t;commonPlugins=commonPlugins.concat(n)}var rEdit,EXTRAWORDS=commonAtoms.concat(commonPlugins,commonKeywords,commonCommands,commonEvents,commonTag,commonNumber,commonMath,commonWarning,taskSpecifics,AnythingElse),confirmR=!0,android=/Android/.test(navigator.userAgent);function initCM(){android&&(confirmR=!!confirm("Do you want to enable colored rules?\n(There are some issues with Android causing it to fail!)\nTestet with Chrome, Firefox and Vivaldi so far.\nPlease report any issues you may have with this feature.")),confirmR&&(CodeMirror.commands.autocomplete=function(e){e.showHint({hint:CodeMirror.hint.anyword})},(rEdit=CodeMirror.fromTextArea(document.getElementById("rules"),{tabSize:2,indentWithTabs:!1,lineNumbers:!0,autoCloseBrackets:!0,extraKeys:{"Ctrl-Space":"autocomplete",Tab:e=>{"null"===e.getMode().name?e.execCommand("insertTab"):e.somethingSelected()?e.execCommand("indentMore"):e.execCommand("insertSoftTab")},"Shift-Tab":e=>e.execCommand("indentLess")}})).on("change",(function(){rEdit.save()})),android||rEdit.on("inputRead",(function(e,t){var n=e.getCursor(),o=e.getTokenAt(n);/[\w%,.]/.test(t.text)&&"comment"!=o.type&&e.showHint({completeSingle:!1})})),CodeMirror.keyMap.default["Ctrl-F"]=function(e){openFind()},CodeMirror.keyMap.default["Cmd-F"]=function(e){openFind()})}function closeSearchDialog(){const e=document.querySelectorAll(".CodeMirror-dialog");e.length>0&&(e.forEach((e=>e.remove())),document.body.classList.remove("dialog-opened")),rEdit.execCommand("clearSearch")}function removeHighlight(){requestAnimationFrame((()=>{document.querySelectorAll(".search-next-highlight").forEach((e=>e.classList.remove("search-next-highlight")))}))}let findDialogObserver=null;function openFind(){findDialogObserver&&(findDialogObserver.disconnect(),findDialogObserver=null),findDialogObserver=new MutationObserver((()=>{document.querySelector(".CodeMirror-dialog")||(removeHighlight(),findDialogObserver.disconnect(),findDialogObserver=null)})),findDialogObserver.observe(document.body,{childList:!0,subtree:!0}),clearSearchNextHighlight(rEdit),rEdit.execCommand("findPersistent"),addFindButtons()}function clearSearchNextHighlight(e){removeHighlight(),e.__searchNextHighlight&&(e.__searchNextHighlight.clear(),e.__searchNextHighlight=null)}function addFindButtons(){document.querySelector(".CodeMirror-selected");const e=document.querySelector(".CodeMirror-dialog");if(!e||e.querySelector(".search-button-group"))return;[{title:"Find Previous",symbol:"▲",action:()=>rEdit.execCommand("findPersistentPrev")},{title:"Find Next",symbol:"▼",action:()=>rEdit.execCommand("findPersistentNext")},{title:"Replace",symbol:"Replace",action:()=>{closeSearchDialog(),rEdit.execCommand("replace"),addFindButtons()}},{title:"Close",symbol:"❌",action:closeSearchDialog},{title:"Help",symbol:"?",action:()=>{alert("Available shortcuts:\n• Ctrl+F / Cmd+F: Open search\n• Enter or\n Ctrl+G / Cmd+G: Find next\n• Shift+Ctrl+G / Shift+Cmd+G: Find previous\n• Shift+Ctrl+F / Cmd+Option+F: Replace\n• Shift+Ctrl+R / Shift+Cmd+Option+F: Replace all\n• Use /re/ syntax for regex search")}}].forEach((({title:t,symbol:n,action:o})=>{const i=document.createElement("span");i.title=t,i.className="help"===t.toLowerCase()?"button help":"button",i.innerHTML=n,i.style.cssText="\n cursor: pointer;\n user-select: none;\n ",i.addEventListener("click",(e=>{e.preventDefault(),o()})),e.appendChild(i)}))}function triggerFormatting(){if(confirmR){const e=rEdit.getDoc(),t=(rEdit.getScrollInfo(),e.getCursor()),n=0===t.ch?t.line-1:t.line;rEdit.getLine(n)}let e=confirmR?rEdit.getValue():document.getElementById("rules").value;if(e=initalAutocorrection(e),e=formatLogic(e),confirmR){rEdit.setValue(e);const t=currentLine,n=0===cursor.ch&&lineText.length>0?lineText.length:cursor.ch-1;rEdit.setCursor({line:t,ch:n}),rEdit.scrollTo(scrollInfo.left,scrollInfo.top),rEdit.focus(),rEdit.save()}else document.getElementById("rules").value=e}function initalAutocorrection(e){for(const t of EXTRAWORDS)if("Do"===t){const t=/(^|\s)(do)(\s*)(\/\/.*)?$/gim;e=e.replace(t,((e,t,n,o,i)=>`${t}Do${o}${i??""}`))}else{const n=new RegExp(`^\\s*\\b${t}\\b`,"gmi");e=e.replace(n,(e=>e.replace(new RegExp(t,"i"),t)))}return e}function formatLogic(e){const t=" ",n=e.split("\n").map((e=>{const t=e.trimStart();return t.startsWith("//")?e:t})),o=[],i=[];let r=!1,s=null,a=[],c=[];function l(e){return e.trim().startsWith("//")}function d(e){return""===e.trim()}function m(e){return e.trim().toLowerCase().startsWith("on")}function u(e){return e.trim().toLowerCase().endsWith("do")}function f(e){return"endon"===e.trim().toLowerCase()}function h(e){return e.trim().toLowerCase().startsWith("if")}function p(e){return"else"===e.trim().toLowerCase()}function g(e){return e.trim().toLowerCase().startsWith("elseif")}function x(e){return"endif"===e.trim().toLowerCase()}let C=0;function S(){a.length>0&&(i.push(`• Missing ${a.length} Endif(s):`),i.push(` - Unclosed If block(s) starting at line(s): ${c.join(", ")}`)),a=[],c=[]}for(let e=0;e0){const e=extractFirstErrorLine(i);if(alert("Errors found:\n"+i.join("\n")),!isNaN(e))if(confirmR)setTimeout((()=>{jumpToLine(e)}),50);else{const t=document.getElementById("rules");setTimeout((()=>{jumpToLineInTextarea(t,e)}),50)}}return o.join("\n")}function jumpToLine(e){const t=Math.max(0,e-1);rEdit.setCursor({line:t,ch:0}),rEdit.focus(),rEdit.scrollIntoView({line:t,ch:0},100)}function extractFirstErrorLine(e){for(const t of e){let e=t.match(/• Line (\d+)/);if(e)return parseInt(e[1]);if(e=t.match(/starting at line (\d+)/),e)return parseInt(e[1]);if(e=t.match(/starting at line\(s\):\s*(\d+)/),e)return parseInt(e[1])}return null}function jumpToLineInTextarea(e,t){const n=e.value.split("\n"),o=Math.max(1,Math.min(t,n.length));let i=0;for(let e=0;e{const e=document.getElementById("rulesselect");if(e){if(confirmR){const t=document.createElement("button");t.type="button",t.id="searchBtn",t.innerHTML="🔎︎",t.style.padding="2px 5px",t.className="button help",e.appendChild(t),t.addEventListener("click",(()=>{void 0!==rEdit&&openFind()}))}const t=document.createElement("button");t.type="button",t.id="formatBtn",t.textContent="Format",t.className="button",e.appendChild(t),t.addEventListener("click",(()=>{triggerFormatting()}))}let t="";if(document.addEventListener("keydown",(function(e){const n=e.key;if(e.ctrlKey&&e.shiftKey&&"f"===n.toLowerCase())return e.preventDefault(),void triggerFormatting();(["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Enter","Tab","Escape","Shift","Control","Alt","Meta"].includes(n)||1!==n.length)&&(t="")})),android){var n=!1;rEdit.on("keydown",((e,o)=>{["Enter","Backspace"," "].includes(o.key)&&(t=""),n=!0}));let e="";const i=rEdit.getInputField();function o(o,i=!1){if(!(rEdit.hasFocus()&&rEdit&&o.data&&n))return;n=!1;const r=o.data,s=rEdit.getDoc(),a=s.getCursor(),c=rEdit.getTokenAt(a);if(" "===r)return t="",void(e="");if(!(r===e&&t.length>0))if(/[\w%,.]/.test(r)&&"comment"!==c.type){const n=a.ch<=1?r.slice(-1):r;t+=n,e=t,t.startsWith(String(a.line+1))&&0===a.ch&&(t=t.slice(String(a.line).length));const o={line:a.line,ch:a.ch-t.length+1},c=()=>{s.replaceRange(t,o,a),rEdit.setCursor({line:o.line,ch:o.ch+t.length}),rEdit.showHint({completeSingle:!1})};i?c():setTimeout(c,0)}else t=""}const r=navigator.userAgent.toLowerCase(),s=/firefox/.test(r),a=/chrome/.test(r)&&!s;s?i.addEventListener("beforeinput",(e=>{e.preventDefault(),o(e,!0)})):a&&document.addEventListener("input",(e=>{o(e,!1)})),rEdit.on("endCompletion",(function(){setTimeout((()=>{!function(){const e=document.createElement("input");e.type="text",e.style.position="absolute",e.style.opacity="0",e.style.height="0",e.style.width="0",e.style.border="none",e.style.top="0",e.style.left="-9999",e.style.padding="0",e.style.zIndex="-1",e.style.fontSize="16px",document.body.appendChild(e),e.focus(),setTimeout((()=>{e.remove(),rEdit.focus()}),10)}()}),100)}))}})),function(e){"object"==typeof exports&&"object"==typeof module?e(require("codemirror")):"function"==typeof define&&define.amd?define(["codemirror"],e):e(CodeMirror)}((function(e){"use strict";e.defineMode("espeasy",(function(){var e={};function t(t,n){for(var o=0;oe.toLowerCase()));commonCommands=commonCommands.concat(n);var o=commonEvents.map((e=>e.toLowerCase()));commonEvents=commonEvents.concat(o);var i=commonPlugins.map((e=>e.toLowerCase()));commonPlugins=commonPlugins.concat(i);var r=commonAtoms.map((e=>e.toLowerCase()));commonAtoms=commonAtoms.concat(r);var s=commonKeywords.map((e=>e.toLowerCase()));commonKeywords=commonKeywords.concat(s);var a=commonTag.map((e=>e.toLowerCase()));commonTag=commonTag.concat(a);var c=commonNumber.map((e=>e.toLowerCase()));commonNumber=commonNumber.concat(c);var l=commonMath.map((e=>e.toLowerCase()));commonMath=commonMath.concat(l);var d=AnythingElse.map((e=>e.toLowerCase()));AnythingElse=AnythingElse.concat(d);var m=taskSpecifics.map((e=>e.toLowerCase()));function u(t,n){if(t.eatSpace())return null;t.sol();var o=t.next();if(/\d/.test(o)){if("0"==o)return"x"===t.next()?(t.eatWhile(/\w/),"number"):(t.eatWhile(/\d|\./),"number");if(t.eatWhile(/\d|\./),!t.match("d")&&!t.match("output")&&(t.eol()||/\D/.test(t.peek())))return"number"}if(/\w/.test(o))for(const e of EXTRAWORDS){let n=e.substring(1);(e.includes(":")||e.includes(",")||e.includes("."))&&t.match(n)}if(/\w/.test(o)&&(t.eatWhile(/[\w]/),t.match(".gpio")||t.match(".pulse")||t.match(".frq")||t.match(".pwm")))return"def";if("\\"===o)return t.next(),null;if("("===o||")"===o)return"bracket";if("{"===o||"}"===o||":"===o)return"number";if("/"==o)return/\//.test(t.peek())?(t.skipToEnd(),"comment"):"operator";if("'"==o&&(t.eatWhile(/[^']/),t.match("'")))return"attribute";if("+"===o||"="===o||"<"===o||">"===o||"-"===o||","===o||"*"===o||"!"===o)return"operator";if("%"==o){if(/\d/.test(t.next()))return"number";if(t.eatWhile(/[^\s\%]/),t.match("%"))return"hr"}if("["==o&&(t.eatWhile(/[^\s\]]/),t.eat("]")))return"hr";t.eatWhile(/\w/);var i=t.current();return/\w/.test(o)&&t.match("#")?(t.eatWhile(/[\w.#]/),"events"):"#"===o?(t.eatWhile(/\w/),"number"):e.hasOwnProperty(i)?e[i]:null}function f(e,t){return(t.tokens[0]||u)(e,t)}return taskSpecifics=taskSpecifics.concat(m),t("atom",commonAtoms),t("keyword",commonKeywords),t("builtin",commonCommands),t("events",commonEvents),t("def",commonPlugins),t("tag",commonTag),t("number",commonNumber),t("bracket",commonMath),t("warning",commonWarning),t("hr",AnythingElse),t("comment",taskSpecifics),{startState:function(){return{tokens:[]}},token:function(e,t){return f(e,t)},closeBrackets:"[]{}''\"\"``()",lineComment:"//",fold:"brace"}}))})),function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],mod):e(CodeMirror)}((function(e){var t={pairs:"()[]{}''\"\"",closeBefore:")]}'\":;>",triples:"",explode:"[]{}"},n=e.Pos;function o(e,n){return"pairs"==n&&"string"==typeof e?e:"object"==typeof e&&null!=e[n]?e[n]:t[n]}e.defineOption("autoCloseBrackets",!1,(function(t,n,s){s&&s!=e.Init&&(t.removeKeyMap(i),t.state.closeBrackets=null),n&&(r(o(n,"pairs")),t.state.closeBrackets=n,t.addKeyMap(i))}));var i={Backspace:function(t){var i=a(t);if(!i||t.getOption("disableInput"))return e.Pass;for(var r=o(i,"pairs"),s=t.listSelections(),c=0;c=0;c--){var m=s[c].head;t.replaceRange("",n(m.line,m.ch-1),n(m.line,m.ch+1),"+delete")}},Enter:function(t){var n=a(t),i=n&&o(n,"explode");if(!i||t.getOption("disableInput"))return e.Pass;for(var r=t.listSelections(),s=0;s1&&h.indexOf(i)>=0&&t.getRange(n(b.line,b.ch-2),b)==i+i){if(b.ch>2&&/\bstring/.test(t.getTokenTypeAt(n(b.line,b.ch-2))))return e.Pass;S="addFour"}else if(p){var v=0==b.ch?" ":t.getRange(n(b.line,b.ch-1),b);if(e.isWordChar(P)||v==i||e.isWordChar(v))return e.Pass;S="both"}else{if(!x||!(0===P.length||/\s/.test(P)||f.indexOf(P)>-1))return e.Pass;S="both"}else S=p&&m(t,b)?"both":h.indexOf(i)>=0&&t.getRange(b,n(b.line,b.ch+3))==i+i+i?"skipThree":"skip";if(u){if(u!=S)return e.Pass}else u=S}var T=d%2?s.charAt(d-1):i,M=d%2?i:s.charAt(d+1);t.operation((function(){if("skip"==u)c(t,1);else if("skipThree"==u)c(t,3);else if("surround"==u){for(var e=t.getSelections(),n=0;n0?{line:s.head.line,ch:s.head.ch+t}:{line:s.head.line-1};n.push({anchor:a,head:a})}e.setSelections(n,i)}function l(t){var o=e.cmpPos(t.anchor,t.head)>0;return{anchor:new n(t.anchor.line,t.anchor.ch+(o?-1:1)),head:new n(t.head.line,t.head.ch+(o?1:-1))}}function d(e,t){var o=e.getRange(n(t.line,t.ch-1),n(t.line,t.ch+1));return 2==o.length?o:null}function m(e,t){var o=e.getTokenAt(n(t.line,t.ch+1));return/\bstring/.test(o.type)&&o.start==t.ch&&(0==t.ch||!/\bstring/.test(e.getTokenTypeAt(t)))}r(t.pairs+"`")})); \ No newline at end of file