B2G/gecko/browser/devtools/scratchpad/scratchpad.js
/**
   * The Scratchpad window load event handler. This method
   * initializes the Scratchpad window and source editor.
   *
   * @param nsIDOMEvent aEvent
   */
The Scratchpad window load event handler. This method
initializes the Scratchpad window and source editor.


The Scratchpad window load event handler . This method initializes the Scratchpad window and source editor .
function SP_onLoad(aEvent)
  {
    if (aEvent.target != document) {
      return;
    }
    let chrome = Services.prefs.getBoolPref(DEVTOOLS_CHROME_ENABLED);
    if (chrome) {
      let environmentMenu = document.getElementById("sp-environment-menu");
      let errorConsoleCommand = document.getElementById("sp-cmd-errorConsole");
      let chromeContextCommand = document.getElementById("sp-cmd-browserContext");
      environmentMenu.removeAttribute("hidden");
      chromeContextCommand.removeAttribute("disabled");
      errorConsoleCommand.removeAttribute("disabled");
    }
    let state = null;
    let initialText = this.strings.formatStringFromName(
      "scratchpadIntro1",
      [LayoutHelpers.prettyKey(document.getElementById("sp-key-run")),
       LayoutHelpers.prettyKey(document.getElementById("sp-key-inspect")),
       LayoutHelpers.prettyKey(document.getElementById("sp-key-display"))],
      3);
    if ("arguments" in window &&
         window.arguments[0] instanceof Ci.nsIDialogParamBlock) {
      state = JSON.parse(window.arguments[0].GetString(0));
      this.setState(state);
      initialText = state.text;
    }
    this.editor = new SourceEditor();
    let config = {
      mode: SourceEditor.MODES.JAVASCRIPT,
      showLineNumbers: true,
      initialText: initialText,
      contextMenu: "scratchpad-text-popup",
    };
    let editorPlaceholder = document.getElementById("scratchpad-editor");
    this.editor.init(editorPlaceholder, config,
                     this._onEditorLoad.bind(this, state));
  }
function SP_onLoad ( aEvent ) { if ( aEvent . target != document ) { return ; } let chrome = Services . prefs . getBoolPref ( DEVTOOLS_CHROME_ENABLED ) ; if ( chrome ) { let environmentMenu = document . getElementById ( "sp-environment-menu" ) ; let errorConsoleCommand = document . getElementById ( "sp-cmd-errorConsole" ) ; let chromeContextCommand = document . getElementById ( "sp-cmd-browserContext" ) ; environmentMenu . removeAttribute ( "hidden" ) ; chromeContextCommand . removeAttribute ( "disabled" ) ; errorConsoleCommand . removeAttribute ( "disabled" ) ; } let state = null ; let initialText = this . strings . formatStringFromName ( "scratchpadIntro1" , [ LayoutHelpers . prettyKey ( document . getElementById ( "sp-key-run" ) ) , LayoutHelpers . prettyKey ( document . getElementById ( "sp-key-inspect" ) ) , LayoutHelpers . prettyKey ( document . getElementById ( "sp-key-display" ) ) ] , 3 ) ; if ( "arguments" in window && window . arguments [ 0 ] instanceof Ci . nsIDialogParamBlock ) { state = JSON . parse ( window . arguments [ 0 ] . GetString ( 0 ) ) ; this . setState ( state ) ; initialText = state . text ; } this . editor = new SourceEditor ( ) ; let config = { mode : SourceEditor . MODES . JAVASCRIPT , showLineNumbers : true , initialText : initialText , contextMenu : "scratchpad-text-popup" , } ; let editorPlaceholder = document . getElementById ( "scratchpad-editor" ) ; this . editor . init ( editorPlaceholder , config , this . _onEditorLoad . bind ( this , state ) ) ; }
The Scratchpad window load event handler.
The Scratchpad window load event handler .