javascript-console-share/src/main/amp/web/fme/components/jsconsole/javascript-console.js
/**
         * Fired when the user clicks on the execute button. Reads the script
         * from the input textarea and calls the execute webscript in the
         * repository to run the script.
         *
         * @method onExecuteClick
         */
Fired when the user clicks on the execute button. Reads the script
from the input textarea and calls the execute webscript in the
repository to run the script.


Fired when the user clicks on the execute button . Reads the script from the input textarea and calls the execute webscript in the repository to run the script .
function ACJC_onExecuteClick(e, p_obj)
      {
        this.widgets.codeMirrorScript.save();
        this.widgets.codeMirrorTemplate.save();
        var scriptCode = "";
        if (this.widgets.codeMirrorScript.somethingSelected()) {
            scriptCode = this.widgets.codeMirrorScript.getSelection();
        }
        else {
            scriptCode = this.widgets.scriptInput.value;
        }
        templateCode = this.widgets.templateInput.value;
        var input = {
           "script" : scriptCode,
           "template" : templateCode,
           "spaceNodeRef" : this.widgets.nodeField.value,
           "transaction" : this.widgets.config.transaction.value ? this.widgets.config.transaction.value : "readwrite",
           "runas" : this.widgets.config.runas.value ? this.widgets.config.runas.value : "admin",
           "urlargs" : this.widgets.config.urlargs.value ? this.widgets.config.urlargs.value : "",
           "documentNodeRef" : this.options.documentNodeRef
        };
        this.widgets.scriptOutput.disabled = true;
        this.widgets.executeButton.disabled = true;
        this.showLoadingAjaxSpinner(true);
        this.executeStartTime = new Date();
        input.resultChannel = String(this.executeStartTime.getTime());
        Alfresco.util.Ajax.request(
         {
            url: Alfresco.constants.PROXY_URI + "de/fme/jsconsole/execute",
            method: Alfresco.util.Ajax.POST,
            dataObj: input,
            requestContentType: Alfresco.util.Ajax.JSON,
            successCallback:
            {
               fn: function(res) {
                 this.fetchResult();
                 this.fetchResultTimer.cancel();
                 this.fetchResultTimer = null;
                 this.showLoadingAjaxSpinner(false);
                 this.printExecutionStats(res.json);
                 this.printDumpInfos(res.json.dumpOutput);
                 this.clearOutput();
                 this.appendLineArrayToOutput(res.json.printOutput);
                 this.widgets.templateOutputHtml.innerHTML = res.json.renderedTemplate;
                 this.widgets.templateOutputText.innerHTML = $html(res.json.renderedTemplate);
                 this.widgets.codeMirrorJSON.setValue(formatter.formatJson(res.json.renderedTemplate,"  "));
                 this.widgets.codeMirrorJSON.focus();
                 if (res.json.spaceNodeRef) {
                     this.widgets.nodeField.value = res.json.spaceNodeRef;
                     this.widgets.pathField.innerHTML = res.json.spacePath;
                 }
                 this.widgets.scriptOutput.disabled = false;
                 this.widgets.templateOutputHtml.disabled = false;
                 this.widgets.templateOutputText.disabled = false;
                 this.widgets.executeButton.disabled = false;
                 this.showResultTable(res.json.result);
                 Dom.removeClass(this.widgets.scriptOutput, 'jserror');
                 Dom.addClass(this.widgets.scriptOutput, 'jsgreen');
                 this.runLikeCrazy();
               },
               scope: this
            },
            failureCallback:
            {
               fn: function(res) {
                   if (res.serverResponse.status !== 408) {
                     this.fetchResult();
                     this.fetchResultTimer.cancel();
                     this.fetchResultTimer = null;
                     this.showLoadingAjaxSpinner(false);
                     this.printExecutionStats();
                     var result = YAHOO.lang.JSON.parse(res.serverResponse.responseText);
                     this.markJSError(result);
                     this.markFreemarkerError(result);
                     this.clearOutput();
                     this.setOutputText(result.status.code + " " +
                     result.status.name + "\nStacktrace-Details:\n"+result.callstack+"\n\n"+
                     result.status.description + "\n" + result.message);
                     this.widgets.scriptOutput.disabled = false;
                     this.widgets.executeButton.disabled = false;
                     Dom.removeClass(this.widgets.scriptOutput, 'jsgreen');
                     Dom.addClass(this.widgets.scriptOutput, 'jserror');
                     this.widgets.outputTabs.selectTab(0); 
                     this.runLikeCrazy();
                   }
               },
               scope: this
            }
         });
        Dom.removeClass(this.widgets.scriptOutput, 'jserror');
        Dom.removeClass(this.widgets.scriptOutput, 'jsgreen');
        this.fetchResultTimer = YAHOO.lang.later(1000, this, this.fetchResult, null, false);
      }
function ACJC_onExecuteClick ( e , p_obj ) { this . widgets . codeMirrorScript . save ( ) ; this . widgets . codeMirrorTemplate . save ( ) ; var scriptCode = "" ; if ( this . widgets . codeMirrorScript . somethingSelected ( ) ) { scriptCode = this . widgets . codeMirrorScript . getSelection ( ) ; } else { scriptCode = this . widgets . scriptInput . value ; } templateCode = this . widgets . templateInput . value ; var input = { "script" : scriptCode , "template" : templateCode , "spaceNodeRef" : this . widgets . nodeField . value , "transaction" : this . widgets . config . transaction . value ? this . widgets . config . transaction . value : "readwrite" , "runas" : this . widgets . config . runas . value ? this . widgets . config . runas . value : "admin" , "urlargs" : this . widgets . config . urlargs . value ? this . widgets . config . urlargs . value : "" , "documentNodeRef" : this . options . documentNodeRef } ; this . widgets . scriptOutput . disabled = true ; this . widgets . executeButton . disabled = true ; this . showLoadingAjaxSpinner ( true ) ; this . executeStartTime = new Date ( ) ; input . resultChannel = String ( this . executeStartTime . getTime ( ) ) ; Alfresco . util . Ajax . request ( { url : Alfresco . constants . PROXY_URI + "de/fme/jsconsole/execute" , method : Alfresco . util . Ajax . POST , dataObj : input , requestContentType : Alfresco . util . Ajax . JSON , successCallback : { fn : function ( res ) { this . fetchResult ( ) ; this . fetchResultTimer . cancel ( ) ; this . fetchResultTimer = null ; this . showLoadingAjaxSpinner ( false ) ; this . printExecutionStats ( res . json ) ; this . printDumpInfos ( res . json . dumpOutput ) ; this . clearOutput ( ) ; this . appendLineArrayToOutput ( res . json . printOutput ) ; this . widgets . templateOutputHtml . innerHTML = res . json . renderedTemplate ; this . widgets . templateOutputText . innerHTML = $html ( res . json . renderedTemplate ) ; this . widgets . codeMirrorJSON . setValue ( formatter . formatJson ( res . json . renderedTemplate , "  " ) ) ; this . widgets . codeMirrorJSON . focus ( ) ; if ( res . json . spaceNodeRef ) { this . widgets . nodeField . value = res . json . spaceNodeRef ; this . widgets . pathField . innerHTML = res . json . spacePath ; } this . widgets . scriptOutput . disabled = false ; this . widgets . templateOutputHtml . disabled = false ; this . widgets . templateOutputText . disabled = false ; this . widgets . executeButton . disabled = false ; this . showResultTable ( res . json . result ) ; Dom . removeClass ( this . widgets . scriptOutput , 'jserror' ) ; Dom . addClass ( this . widgets . scriptOutput , 'jsgreen' ) ; this . runLikeCrazy ( ) ; } , scope : this } , failureCallback : { fn : function ( res ) { if ( res . serverResponse . status !== 408 ) { this . fetchResult ( ) ; this . fetchResultTimer . cancel ( ) ; this . fetchResultTimer = null ; this . showLoadingAjaxSpinner ( false ) ; this . printExecutionStats ( ) ; var result = YAHOO . lang . JSON . parse ( res . serverResponse . responseText ) ; this . markJSError ( result ) ; this . markFreemarkerError ( result ) ; this . clearOutput ( ) ; this . setOutputText ( result . status . code + " " + result . status . name + "\nStacktrace-Details:\n" + result . callstack + "\n\n" + result . status . description + "\n" + result . message ) ; this . widgets . scriptOutput . disabled = false ; this . widgets . executeButton . disabled = false ; Dom . removeClass ( this . widgets . scriptOutput , 'jsgreen' ) ; Dom . addClass ( this . widgets . scriptOutput , 'jserror' ) ; this . widgets . outputTabs . selectTab ( 0 ) ; this . runLikeCrazy ( ) ; } } , scope : this } } ) ; Dom . removeClass ( this . widgets . scriptOutput , 'jserror' ) ; Dom . removeClass ( this . widgets . scriptOutput , 'jsgreen' ) ; this . fetchResultTimer = YAHOO . lang . later ( 1000 , this , this . fetchResult , null , false ) ; }
Fired when the user clicks on the execute button.
Fired when the user clicks on the execute button .
// Save any changes done in CodeMirror editor before submitting
 // If something is selected, only get the selected part of the script
 // Build JSON Object to send to the server
 // Disable the result textarea
 // show console tab
 // remove any marking
 // fetch result updates to the print output after a second
