Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| update_sets [01/13/2026YYY 05:14] – johnsonjohn | update_sets [01/13/2026YYY 06:01] (current) – johnsonjohn | ||
|---|---|---|---|
| Line 1917: | Line 1917: | ||
| ---- | ---- | ||
| =====JWJ Onboarding Catalog Item===== | =====JWJ Onboarding Catalog Item===== | ||
| + | JWJ0215 05/ | ||
| + | |||
| <code xml onboardingCI.xml> | <code xml onboardingCI.xml> | ||
| <?xml version=" | <?xml version=" | ||
| Line 4293: | Line 4295: | ||
| </ | </ | ||
| </ | </ | ||
| + | ---- | ||
| + | |||
| + | ===== UI Script to Enable Syntax Editor Macros ===== | ||
| + | <code xml enableUISyntaxEditor.xml> | ||
| + | < | ||
| + | <?xml version=" | ||
| + | <unload unload_date=" | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | |||
| + | //object to store macros in | ||
| + | var macrosObj={ | ||
| + | }; | ||
| + | |||
| + | var fn = function(e){ | ||
| + | var keyCode = e.keyCode || e.which; | ||
| + | |||
| + | //check if key pressed is TAB | ||
| + | if (keyCode == 9) { | ||
| + | |||
| + | //get DOM element for active pane | ||
| + | var cmEl = jQuery(document.activeElement).parents(' | ||
| + | |||
| + | //get CodeMirror object for active pane. CodeMirror is the Syntax Editor library used in the Widget Editor | ||
| + | var cmObj = cmEl.CodeMirror; | ||
| + | |||
| + | //get position of cursor and end of line | ||
| + | var tmpCursor=cmObj.getCursor(); | ||
| + | var eol=cmObj.getLine(tmpCursor.line).length; | ||
| + | |||
| + | //do nothing if cursor is not at end of line | ||
| + | //this allows users to continue using TAB key for formatting/ | ||
| + | if(tmpCursor.ch < eol){ | ||
| + | return true; | ||
| + | } | ||
| + | |||
| + | //do nothing if any text is selected | ||
| + | if(cmObj.somethingSelected()){ | ||
| + | return true; | ||
| + | } | ||
| + | |||
| + | //find the start and end position of the word preceeding the cursor | ||
| + | var wordObj = cmObj.findWordAt({ | ||
| + | line: tmpCursor.line, | ||
| + | ch: tmpCursor.ch-2 | ||
| + | }); | ||
| + | |||
| + | //get the actual word preceeding the cursor | ||
| + | var word = cmObj.getRange(wordObj.anchor, | ||
| + | |||
| + | //do nothing if a corresponding Syntax Editor Macro does not exist | ||
| + | if(typeof macrosObj[word]===' | ||
| + | return true; | ||
| + | |||
| + | //select the word preceeding the cursor | ||
| + | var sel = cmObj.setSelection(wordObj.anchor, | ||
| + | |||
| + | //replace selection with the text of the Syntax Editor Macro | ||
| + | cmObj.replaceSelection( macrosObj[word].text ); | ||
| + | } | ||
| + | }; | ||
| + | |||
| + | //add keyup event listener | ||
| + | jQuery(window).on(' | ||
| + | |||
| + | //populate macrosObj with records from the Syntax Editor Macro table | ||
| + | var requestBody = ""; | ||
| + | var client=new XMLHttpRequest(); | ||
| + | client.open(" | ||
| + | |||
| + | client.setRequestHeader(' | ||
| + | client.setRequestHeader(' | ||
| + | client.setRequestHeader(' | ||
| + | |||
| + | var rsc = function(){ | ||
| + | if(this.readyState == this.DONE) { | ||
| + | var rspObj=JSON.parse(this.response).result; | ||
| + | for(var macro in rspObj){ | ||
| + | if(!rspObj.hasOwnProperty(macro)) | ||
| + | continue; | ||
| + | |||
| + | var currentMacro=rspObj[macro]; | ||
| + | macrosObj[currentMacro.name]=currentMacro; | ||
| + | } | ||
| + | } | ||
| + | }; | ||
| + | |||
| + | client.onreadystatechange = rsc; | ||
| + | client.send(requestBody); | ||
| + | })(); | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| ---- | ---- | ||