Created
July 15, 2018 12:04
-
-
Save nikolayemrikh/dcdbc61c29f4fc7deff16479a16327b7 to your computer and use it in GitHub Desktop.
Connect console with propmt in editor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>console.js</title> | |
| <link href="//htmlacademy.github.io/console.js/latest/css/style.css" rel="stylesheet"> | |
| <link href="//htmlacademy.github.io/console.js/latest/css/prism.css" rel="stylesheet"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> | |
| <style> | |
| html, | |
| body { | |
| margin: 0; | |
| padding: 0; | |
| height: 100%; | |
| -webkit-tap-highlight-color: rgba(0, 0, 0, 0); | |
| -webkit-tap-highlight-color: transparent; | |
| } | |
| .global-container { | |
| display: flex; | |
| margin: 0; | |
| padding: 0; | |
| width: 100%; | |
| height: 99%; | |
| flex-direction: column; | |
| } | |
| .global-container__prompt-container { | |
| flex: 1 0 auto; | |
| } | |
| </style> | |
| </head> | |
| <body ontouchstart=""><!-- Чтобы :active на кнопку отправки работал на мобильных устройствах --> | |
| <div class="global-container"> | |
| <div class="console-container"></div> | |
| <div class="prompt-container global-container__prompt-container"></div> | |
| </div> | |
| <script src="//htmlacademy.github.io/console.js/latest/js/index-prompt.js"></script> | |
| <script src="//htmlacademy.github.io/console.js/latest/js/index.js"></script> | |
| <script> | |
| const consoleContainerEl = document.querySelector(`.console-container`); | |
| window.jsConsole = new Console(consoleContainerEl, { | |
| array: { | |
| countEntriesWithoutKeys: true | |
| }, | |
| common: { | |
| excludeProperties: [`__proto__`], | |
| expandDepth: 1, | |
| maxFieldsInHead: 5, | |
| minFieldsToExpand: 5, // значение как в object.maxFieldsInHead | |
| maxFieldsToExpand: 15 | |
| } | |
| }); | |
| window.jsConsole.extend(window.console); | |
| window.addEventListener(`error`, (evt) => { | |
| window.jsConsole.error(evt.error); | |
| }); | |
| const promptContainer = document.querySelector(`.prompt-container`); | |
| const prompt = new Prompt(promptContainer, `jsConsole`); | |
| window.jsConsole.onAny = (appendedElHeight) => { | |
| const promptOffsetBottom = promptContainer.offsetTop + prompt.viewHeight; | |
| if (promptOffsetBottom < document.body.clientHeight) { | |
| window.scroll(0, document.body.scrollTop + appendedElHeight); | |
| } else { | |
| window.scroll(0, promptOffsetBottom); | |
| } | |
| }; | |
| </script> | |
| </body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment