aboutsummaryrefslogtreecommitdiff
path: root/files/uk/інструменти/chernetka-scratchpad/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/uk/інструменти/chernetka-scratchpad/index.html')
-rw-r--r--files/uk/інструменти/chernetka-scratchpad/index.html112
1 files changed, 112 insertions, 0 deletions
diff --git a/files/uk/інструменти/chernetka-scratchpad/index.html b/files/uk/інструменти/chernetka-scratchpad/index.html
new file mode 100644
index 0000000000..e1337596c7
--- /dev/null
+++ b/files/uk/інструменти/chernetka-scratchpad/index.html
@@ -0,0 +1,112 @@
+---
+title: Чернетка - Scratchpad
+slug: Інструменти/chernetka-Scratchpad
+translation_of: Archive/Tools/Scratchpad
+---
+<p>{{ToolsSidebar}}</p>
+
+<p>Чернетка надає середовище для експериментів із JavaScript-кодом. Ви можете писати, запускати, і перевіряти результати програмного коду, що взаємодіє з веб-сторінкою.</p>
+
+<p>На відміну від <a href="/en-US/docs/Tools/Web_Console" title="en/Using the Web Console">Web Console</a>, що розроблена для одночасної інтерпретації одної стрічки коду, чернетка дозволяє редагувати більші скрипти, а потім виконувати їх різними способами, залежно від того, як ви бажаєте використовувати результат.</p>
+
+<p>{{EmbedYouTube("Pt7DZACyClM")}}</p>
+
+<h2 id="Usage">Usage</h2>
+
+<h3 id="Opening_Scratchpad_in_its_own_window">Opening Scratchpad in its own window</h3>
+
+<p>There are several different ways to open Scratchpad in its own window:</p>
+
+<ul>
+ <li>press <kbd>Shift</kbd> + <kbd>F4</kbd>, or go to the Web Developer menu (which is a submenu in the Tools menu on macOS and Linux), then select Scratchpad</li>
+ <li>click the wrench icon (<img alt="" src="https://mdn.mozillademos.org/files/12710/wrench-icon.png" style="height: 21px; width: 21px;">), which is in the main toolbar or under the Hamburger menu (<img alt="" src="https://mdn.mozillademos.org/files/12712/hamburger.png" style="height: 20px; width: 22px;">), then select "Scratchpad".</li>
+</ul>
+
+<p>This will open up Scratchpad in its own window.</p>
+
+<h3 id="Opening_Scratchpad_in_the_Toolbox">Opening Scratchpad in the Toolbox</h3>
+
+<div class="geckoVersionNote">New in Firefox 47.</div>
+
+<p>From Firefox 47, you can open Scratchpad inside the <a href="/en-US/docs/Tools/Tools_Toolbox">Toolbox</a>. First you need to check "Scratchpad" in the "Default Firefox Developer Tools" section of the <a href="/en-US/docs/Tools/Tools_Toolbox#Settings_2">Settings</a> page.</p>
+
+<p>Now Scratchpad will be available in the Toolbox, alongside other tools like the Page Inspector and the Web Console. This is especially useful in <a href="/en-US/docs/Tools/Web_Console/Split_console">split Console mode</a>: you can use Scratchpad for a persistent, multiline editor, and the Console to interact with the page.</p>
+
+<h3 id="Editing">Editing</h3>
+
+<p>The Scratchpad window looks something like this (on macOS the menu bar is at the top of the screen):</p>
+
+<p><img alt="A screenshot of the Scratchpad" src="https://mdn.mozillademos.org/files/5983/scratchpad.png"></p>
+
+<p>The File menu offers options to save and load JavaScript code snippets, so you can reuse code later if you like.</p>
+
+<h4 id="Code_completion">Code completion</h4>
+
+<p>Scratchpad integrates the <a href="http://ternjs.net/">tern code analysis engine</a>, and uses that to provide autocomplete suggestions and popups containing information on the current symbol. To list autocomplete suggestions, press <kbd>Ctrl</kbd> + <kbd>Space</kbd>.</p>
+
+<p>For example, try typing <kbd>d</kbd>, then pressing <kbd>Ctrl</kbd> + <kbd>Space</kbd>. You'll see the autocomplete box, as shown below:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/7933/scratchpad-autocomplete.png" style="display: block; margin-left: auto; margin-right: auto;">The icon next to each suggestion indicates the type, and the currently highlighted suggestion gets a popup with more information. <kbd>↑</kbd> and <kbd>↓</kbd> cycle through the suggestions and <kbd>Enter</kbd> or <kbd>Tab</kbd> select the highlighted choice.</p>
+
+<h4 id="Inline_documentation">Inline documentation</h4>
+
+<p>To show the inline documentation popup, press <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Space</kbd> when the cursor is on an identifier. For example, if you type <code>document</code>.<code>addEventListener</code>, then press <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Space</kbd>, you'll see a popup that shows a summary of the function's syntax and a short description:</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/7935/scratchpad-symbolinfo.png" style="display: block; margin-left: auto; margin-right: auto;">The "[docs]" link takes you to the MDN documentation for the symbol.</p>
+
+<h3 id="Executing">Executing</h3>
+
+<p class="note">Once you've written your code, select the code you want to run. If you don't select anything, all the code in the window will be run. Then choose the way you want the code to run using the buttons along the top, using the Execute menu, or using the context menu. The code is executed in the scope of the currently selected tab. Any variables you declare outside of a function will be added to the global object for that tab.</p>
+
+<p>There are four execution options available.<strong> </strong></p>
+
+<h4 id="Run">Run</h4>
+
+<p>When you choose the Run option, the selected code is executed. This is what you'd use to execute a function or other code that manipulates the content of your page without needing to see the result.</p>
+
+<h4 id="Inspect">Inspect</h4>
+
+<p>The Inspect option executes the code just like the Run option; however, after the code returns, an object inspector is opened to let you examine the returned value.</p>
+
+<p>For example, if you enter the code:</p>
+
+<pre class="brush:css">window
+</pre>
+
+<p>Then choose Inspect, the object inspector is shown that looks something like this:</p>
+
+<p><img alt="Inspecting an object in the Scratchpad" src="https://mdn.mozillademos.org/files/5985/scratchpad-inspect.png"></p>
+
+<h4 id="Display">Display</h4>
+
+<p>The Display option executes the selected code, then inserts the result directly into your Scratchpad editor window as a comment, so you can use it as a <a href="http://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop">REPL</a>.</p>
+
+<h4 id="Reload_And_Run">Reload And Run</h4>
+
+<p>The Reload And Run option is only available in the Execute menu. It first reloads the page, then executes the code when the page's "load" event fires. This is useful for running the code in a pristine environment.</p>
+
+<h2 id="Running_Scratchpad_in_the_browser_context">Running Scratchpad in the browser context</h2>
+
+<p>You can run Scratchpad in the context of the browser as a whole rather than a specific web page. This is useful if you are working on Firefox itself or developing add-ons. To do this check "Enable chrome and add-on debugging" in the <a href="/en-US/docs/Tools/Tools_Toolbox#Settings_2">Developer Tool Settings</a>. Once you've done this, the Environment menu has a Browser option; once that's selected, your scope is the entire browser rather than just the page content, as you will see from examining some globals:</p>
+
+<pre class="brush: js">window
+/*
+[object ChromeWindow]
+*/
+
+gBrowser
+/*
+[object XULElement]
+*/</pre>
+
+<p>The Scratchpad execution context is set to browser when a snippet file has<br>
+ <code>// -sp-context: browser</code><br>
+ on the first line.</p>
+
+<h2 id="Keyboard_shortcuts">Keyboard shortcuts</h2>
+
+<p>{{ Page ("en-US/docs/tools/Keyboard_shortcuts", "scratchpad") }}</p>
+
+<h3 id="Source_editor_shortcuts">Source editor shortcuts</h3>
+
+<p>{{ Page ("en-US/docs/tools/Keyboard_shortcuts", "source-editor") }}</p>