From a03db79f5cc25872183ae7818fb5242b3b6e98ab Mon Sep 17 00:00:00 2001 From: Konstantin Kaluzhnikov Date: Fri, 28 Sep 2018 11:55:39 +0400 Subject: [PATCH 01/44] Fix total time in DoctrinePannel --- src/RunTracy/Helpers/DoctrinePanel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/RunTracy/Helpers/DoctrinePanel.php b/src/RunTracy/Helpers/DoctrinePanel.php index afbc98a..79090ee 100644 --- a/src/RunTracy/Helpers/DoctrinePanel.php +++ b/src/RunTracy/Helpers/DoctrinePanel.php @@ -91,7 +91,7 @@ protected function parse($logs) if (!isset($log['executionMS'])) { continue; } - $time = $log['executionMS']; + $time += $log['executionMS']; $row = $baseRow; $return .= sprintf( $row, From ba51ced709eb80278f2195cea1ce0555a46e15b2 Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Fri, 12 Oct 2018 14:49:36 +0200 Subject: [PATCH 02/44] Use declared settings; fix disable panels Fixes https://github.com/runcmf/runtracy/issues/12 --- src/RunTracy/Middlewares/TracyMiddleware.php | 32 ++++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/RunTracy/Middlewares/TracyMiddleware.php b/src/RunTracy/Middlewares/TracyMiddleware.php index d508d49..4b9bca9 100644 --- a/src/RunTracy/Middlewares/TracyMiddleware.php +++ b/src/RunTracy/Middlewares/TracyMiddleware.php @@ -64,9 +64,9 @@ public function __invoke(Request $request, Response $response, callable $next) $cookies = array_fill_keys($cookies, 1); $cfg = array_merge($def, $cookies); } else { - $cfg = []; + $cfg = $this->defcfg; } - if (isset($cfg['showEloquentORMPanel'])) { + if (isset($cfg['showEloquentORMPanel']) && $cfg['showEloquentORMPanel']) { if (class_exists('\Illuminate\Database\Capsule\Manager')) { Debugger::getBar()->addPanel(new \RunTracy\Helpers\EloquentORMPanel( \Illuminate\Database\Capsule\Manager::getQueryLog() @@ -76,70 +76,70 @@ public function __invoke(Request $request, Response $response, callable $next) unset($this->defcfg['showEloquentORMPanel']); } } - if (isset($cfg['showTwigPanel'])) { + if (isset($cfg['showTwigPanel']) && $cfg['showTwigPanel']) { Debugger::getBar()->addPanel(new \RunTracy\Helpers\TwigPanel( $this->container->get('twig_profile') )); } - if (isset($cfg['showPhpInfoPanel'])) { + if (isset($cfg['showPhpInfoPanel']) && $cfg['showPhpInfoPanel']) { Debugger::getBar()->addPanel(new \RunTracy\Helpers\PhpInfoPanel()); } - if (isset($cfg['showSlimEnvironmentPanel'])) { + if (isset($cfg['showSlimEnvironmentPanel']) && $cfg['showSlimEnvironmentPanel']) { Debugger::getBar()->addPanel(new \RunTracy\Helpers\SlimEnvironmentPanel( \Tracy\Dumper::toHtml($this->container->get('environment')), $this->versions )); } - if (isset($cfg['showSlimContainer'])) { + if (isset($cfg['showSlimContainer']) && $cfg['showSlimContainer']) { Debugger::getBar()->addPanel(new \RunTracy\Helpers\SlimContainerPanel( \Tracy\Dumper::toHtml($this->container), $this->versions )); } - if (isset($cfg['showSlimRouterPanel'])) { + if (isset($cfg['showSlimRouterPanel']) && $cfg['showSlimRouterPanel']) { Debugger::getBar()->addPanel(new \RunTracy\Helpers\SlimRouterPanel( \Tracy\Dumper::toHtml($this->container->get('router')), $this->versions )); } - if (isset($cfg['showSlimRequestPanel'])) { + if (isset($cfg['showSlimRequestPanel']) && $cfg['showSlimRequestPanel']) { Debugger::getBar()->addPanel(new \RunTracy\Helpers\SlimRequestPanel( \Tracy\Dumper::toHtml($this->container->get('request')), $this->versions )); } - if (isset($cfg['showSlimResponsePanel'])) { + if (isset($cfg['showSlimResponsePanel']) && $cfg['showSlimResponsePanel']) { Debugger::getBar()->addPanel(new \RunTracy\Helpers\SlimResponsePanel( \Tracy\Dumper::toHtml($this->container->get('response')), $this->versions )); } - if (isset($cfg['showVendorVersionsPanel'])) { + if (isset($cfg['showVendorVersionsPanel']) && $cfg['showVendorVersionsPanel']) { Debugger::getBar()->addPanel(new \RunTracy\Helpers\VendorVersionsPanel()); } - if (isset($cfg['showXDebugHelper'])) { + if (isset($cfg['showXDebugHelper']) && $cfg['showXDebugHelper']) { Debugger::getBar()->addPanel(new \RunTracy\Helpers\XDebugHelper( $this->defcfg['configs']['XDebugHelperIDEKey'] )); } - if (isset($cfg['showIncludedFiles'])) { + if (isset($cfg['showIncludedFiles']) && $cfg['showIncludedFiles']) { Debugger::getBar()->addPanel(new \RunTracy\Helpers\IncludedFiles()); } // check if enabled or blink if active critical value - if (isset($cfg['showConsolePanel']) || $this->defcfg['configs']['ConsoleNoLogin']) { + if ((isset($cfg['showConsolePanel']) && $cfg['showConsolePanel']) || isset($cfg['configs']['ConsoleNoLogin']) && $cfg['configs']['ConsoleNoLogin']) { Debugger::getBar()->addPanel(new \RunTracy\Helpers\ConsolePanel( $this->defcfg['configs'] )); } - if (isset($cfg['showProfilerPanel'])) { + if (isset($cfg['showProfilerPanel']) && $cfg['showProfilerPanel']) { Debugger::getBar()->addPanel(new \RunTracy\Helpers\ProfilerPanel( $this->defcfg['configs']['ProfilerPanel'] )); } - if (isset($cfg['showIdiormPanel'])) { + if (isset($cfg['showIdiormPanel']) && $cfg['showIdiormPanel']) { Debugger::getBar()->addPanel(new \RunTracy\Helpers\IdiormPanel()); } - if (isset($cfg['showDoctrinePanel'])) { + if (isset($cfg['showDoctrinePanel']) && $cfg['showDoctrinePanel']) { if (class_exists('\Doctrine\DBAL\Connection') && $this->container->has('doctrineConfig')) { Debugger::getBar()->addPanel( new \RunTracy\Helpers\DoctrinePanel( From 268b9c3d984882c7ae2f00110a6a59170886b0cf Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Fri, 12 Oct 2018 14:51:39 +0200 Subject: [PATCH 03/44] Test on php 7.2, drop hhvm --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c47fba2..c52ab65 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,12 @@ php: - 5.6 - 7.0 - 7.1 - - hhvm + - 7.2 + - nightly + +matrix: + allow_failures: + - php: nightly before_script: - composer install --no-suggest ; From d6282bf009df81ded8767104fd4295cf5eb1c66d Mon Sep 17 00:00:00 2001 From: Konstantin Kaluzhnikov Date: Wed, 31 Oct 2018 16:02:25 +0400 Subject: [PATCH 04/44] Update .travis.yml --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c47fba2..38b52b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,11 @@ php: - 5.6 - 7.0 - 7.1 - - hhvm + - 7.2 + - nightly +matrix: + allow_failures: + - php: nightly before_script: - composer install --no-suggest ; From 28e0dfb2173da02b2aee50447df84408fef96399 Mon Sep 17 00:00:00 2001 From: Konstantin Kaluzhnikov Date: Wed, 31 Oct 2018 16:06:48 +0400 Subject: [PATCH 05/44] Update .travis.yml --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 38b52b3..34f63c2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,10 +7,6 @@ php: - 7.0 - 7.1 - 7.2 - - nightly -matrix: - allow_failures: - - php: nightly before_script: - composer install --no-suggest ; From a5df4acbfca8ba29f11151bd784dbaed2c344e47 Mon Sep 17 00:00:00 2001 From: Konstantin Kaluzhnikov Date: Wed, 31 Oct 2018 16:51:30 +0400 Subject: [PATCH 06/44] Update .travis.yml --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 34f63c2..38b52b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,10 @@ php: - 7.0 - 7.1 - 7.2 + - nightly +matrix: + allow_failures: + - php: nightly before_script: - composer install --no-suggest ; From 98b20b7a6647caf540ab136a3fa0eac45dc1288a Mon Sep 17 00:00:00 2001 From: Konstantin Kaluzhnikov Date: Wed, 31 Oct 2018 17:09:22 +0400 Subject: [PATCH 07/44] Update VendorVersionsPanel.phtml --- src/RunTracy/Templates/VendorVersionsPanel.phtml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/RunTracy/Templates/VendorVersionsPanel.phtml b/src/RunTracy/Templates/VendorVersionsPanel.phtml index f51efda..c5a6223 100644 --- a/src/RunTracy/Templates/VendorVersionsPanel.phtml +++ b/src/RunTracy/Templates/VendorVersionsPanel.phtml @@ -2,8 +2,13 @@ use Tracy\Helpers; -function h($str) { +if (!function_exists('h')) { + /** + * Convenience method for htmlspecialchars. + */ + function h($str) { return htmlspecialchars($str, ENT_QUOTES | ENT_HTML5, 'UTF-8'); + } } /** From 094826dcdec6fd7bf320456299e0699926bae1d4 Mon Sep 17 00:00:00 2001 From: Konstantin Kaluzhnikov Date: Thu, 8 Nov 2018 09:16:18 +0400 Subject: [PATCH 08/44] Update PhpInfoPanel.php --- src/RunTracy/Helpers/PhpInfoPanel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/RunTracy/Helpers/PhpInfoPanel.php b/src/RunTracy/Helpers/PhpInfoPanel.php index c43c0f7..3611b6e 100644 --- a/src/RunTracy/Helpers/PhpInfoPanel.php +++ b/src/RunTracy/Helpers/PhpInfoPanel.php @@ -26,8 +26,8 @@ class PhpInfoPanel implements IBarPanel public function getTab() { $this->icon = ''. ' Date: Thu, 8 Nov 2018 09:23:27 +0400 Subject: [PATCH 11/44] fix --- src/RunTracy/Helpers/ConsolePanel.php | 2 +- src/RunTracy/Helpers/EloquentORMPanel.php | 4 ++-- src/RunTracy/Helpers/IncludedFiles.php | 4 ++-- src/RunTracy/Helpers/SlimResponsePanel.php | 4 ++-- src/RunTracy/Helpers/SlimRouterPanel.php | 4 ++-- src/RunTracy/Helpers/VendorVersionsPanel.php | 2 +- src/RunTracy/Templates/VendorVersionsPanel.phtml | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/RunTracy/Helpers/ConsolePanel.php b/src/RunTracy/Helpers/ConsolePanel.php index 83a6653..62743da 100644 --- a/src/RunTracy/Helpers/ConsolePanel.php +++ b/src/RunTracy/Helpers/ConsolePanel.php @@ -65,7 +65,7 @@ function blinker() { $this->icon = ' '. + $this->icon = ''. 'icon = ''. diff --git a/src/RunTracy/Helpers/SlimRouterPanel.php b/src/RunTracy/Helpers/SlimRouterPanel.php index d8c362d..e6087e5 100644 --- a/src/RunTracy/Helpers/SlimRouterPanel.php +++ b/src/RunTracy/Helpers/SlimRouterPanel.php @@ -34,8 +34,8 @@ public function __construct($data = null, array $ver = []) public function getTab() { - $this->icon = ' - +

- + Vendor Versions

From 7596fc86f2190b8c8f8ab0ad2aab4481403cd07d Mon Sep 17 00:00:00 2001 From: Konstantin Kaluzhnikov Date: Fri, 28 Dec 2018 12:38:44 +0400 Subject: [PATCH 12/44] add encoding console output --- Example/Settings.php | 1 + README.md | 1 + src/RunTracy/Controllers/RunTracyConsole.php | 6 ++++++ tests/Settings.php | 1 + 4 files changed, 9 insertions(+) diff --git a/Example/Settings.php b/Example/Settings.php index f5b35b6..bdb6696 100644 --- a/Example/Settings.php +++ b/Example/Settings.php @@ -127,6 +127,7 @@ 'ConsoleTerminalJs' => '/assets/js/jquery.terminal.min.js', // terminal.css full URI 'ConsoleTerminalCss' => '/assets/css/jquery.terminal.min.css', + 'ConsoleFromEncoding' => 'CP866', // or false 'ProfilerPanel' => [ // Memory usage 'primaryValue' set as Profiler::enable() or Profiler::enable(1) // 'primaryValue' => 'effective', // or 'absolute' diff --git a/README.md b/README.md index 6b7446d..7c96f30 100644 --- a/README.md +++ b/README.md @@ -183,6 +183,7 @@ return [ 'ConsoleTerminalJs' => '/assets/js/jquery.terminal.min.js', // terminal.css full URI 'ConsoleTerminalCss' => '/assets/css/jquery.terminal.min.css', + 'ConsoleFromEncoding' => 'CP866', // or false 'ProfilerPanel' => [ // Memory usage 'primaryValue' set as Profiler::enable() or Profiler::enable(1) // 'primaryValue' => 'effective', // or 'absolute' diff --git a/src/RunTracy/Controllers/RunTracyConsole.php b/src/RunTracy/Controllers/RunTracyConsole.php index 821a87a..2b1945f 100644 --- a/src/RunTracy/Controllers/RunTracyConsole.php +++ b/src/RunTracy/Controllers/RunTracyConsole.php @@ -44,6 +44,12 @@ public function index(Request $request, Response $response) $this->passwordHashAlgorithm = $cfg['ConsoleHashAlgorithm'] ?: ''; $this->homeDirectory = $cfg['ConsoleHomeDirectory'] ?: ''; + $ConsoleResponce = $this->execute(); + + if($cfg['ConsoleFromEncoding']){ + $ConsoleResponce['result']['output'] = mb_convert_encoding($ConsoleResponce['result']['output'], "UTF-8", $cfg['ConsoleFromEncoding']); + } + return $response->withJson($this->execute()); } } diff --git a/tests/Settings.php b/tests/Settings.php index 932325a..4dabf47 100644 --- a/tests/Settings.php +++ b/tests/Settings.php @@ -122,6 +122,7 @@ 'ConsoleTerminalJs' => '/assets/js/jquery.terminal.min.js', // terminal.css full URI 'ConsoleTerminalCss' => '/assets/css/jquery.terminal.min.css', + 'ConsoleFromEncoding' => 'CP866', // or false 'ProfilerPanel' => [ // Memory usage 'primaryValue' set as Profiler::enable() or Profiler::enable(1) // 'primaryValue' => 'effective', // or 'absolute' From 25cf352cb4875865ce684956cae932a3e28b4ca5 Mon Sep 17 00:00:00 2001 From: Konstantin Kaluzhnikov Date: Fri, 28 Dec 2018 12:45:47 +0400 Subject: [PATCH 13/44] fix RunTracyConsole --- src/RunTracy/Controllers/RunTracyConsole.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/RunTracy/Controllers/RunTracyConsole.php b/src/RunTracy/Controllers/RunTracyConsole.php index 2b1945f..8a72757 100644 --- a/src/RunTracy/Controllers/RunTracyConsole.php +++ b/src/RunTracy/Controllers/RunTracyConsole.php @@ -50,6 +50,6 @@ public function index(Request $request, Response $response) $ConsoleResponce['result']['output'] = mb_convert_encoding($ConsoleResponce['result']['output'], "UTF-8", $cfg['ConsoleFromEncoding']); } - return $response->withJson($this->execute()); + return $response->withJson($ConsoleResponce, null, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK); } } From aa2dbd2b9c49dc045de0c730f3764ec612a2b70a Mon Sep 17 00:00:00 2001 From: Konstantin Kaluzhnikov Date: Thu, 3 Jan 2019 11:58:20 +0400 Subject: [PATCH 14/44] fix terminal --- src/RunTracy/Templates/ConsolePanel.phtml | 2 +- web/css/jquery.terminal.css | 704 +- web/css/jquery.terminal.min.css | 9 +- web/js/jquery.terminal.js | 8648 +++++++++++++++++++++ web/js/jquery.terminal.min.js | 15 +- web/js/unix_formatting.js | 615 ++ 6 files changed, 9874 insertions(+), 119 deletions(-) create mode 100644 web/js/jquery.terminal.js create mode 100644 web/js/unix_formatting.js diff --git a/src/RunTracy/Templates/ConsolePanel.phtml b/src/RunTracy/Templates/ConsolePanel.phtml index 7939454..4e34d91 100644 --- a/src/RunTracy/Templates/ConsolePanel.phtml +++ b/src/RunTracy/Templates/ConsolePanel.phtml @@ -124,7 +124,7 @@ ""); return; } - var command_parsed = $.terminal.splitCommand(command), method = null, parameters = []; + var command_parsed = $.terminal.split_command(command), method = null, parameters = []; if (command_parsed.name.toLowerCase() === 'cd') { method = 'cd'; parameters = [command_parsed.args.length ? command_parsed.args[0] : '']; diff --git a/web/css/jquery.terminal.css b/web/css/jquery.terminal.css index 75aa68a..02fdcc8 100644 --- a/web/css/jquery.terminal.css +++ b/web/css/jquery.terminal.css @@ -4,15 +4,15 @@ * __ / // // // // // _ // _// // / / // _ // _// // // \/ // _ \/ / * / / // // // // // ___// / / // / / // ___// / / / / // // /\ // // / /__ * \___//____ \\___//____//_/ _\_ / /_//____//_/ /_/ /_//_//_/ /_/ \__\_\___/ - * \/ /____/ version 0.11.23 + * \/ /____/ version 2.0.2 * http://terminal.jcubic.pl * * This file is part of jQuery Terminal. * - * Copyright (c) 2011-2016 Jakub Jankiewicz + * Copyright (c) 2011-2018 Jakub Jankiewicz * Released under the MIT license * - * Date: Sun, 11 Dec 2016 13:17:01 +0000 + * Date: Sat, 22 Dec 2018 15:04:14 +0000 */ .terminal .terminal-output .format, .cmd .format, .cmd .prompt, .cmd .prompt div, .terminal .terminal-output div div{ @@ -36,153 +36,209 @@ position: absolute; left: -16px; top: 0; - width: 10px; + width: 16px; height: 16px; /* this seems to work after all on Android */ /*left: -99999px; clip: rect(1px,1px,1px,1px); /* on desktop textarea appear when paste */ - /* + /* opacity is needed for Edge and IE opacity: 0.01; filter: alpha(opacity = 0.01); - filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0.01); - */ - background: transparent; + filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0.01);*/ + background-color: transparent; border: none; color: transparent; outline: none; padding: 0; resize: none; - z-index: 0; + z-index: 1000; overflow: hidden; -} -.terminal .error { - color: #f00; + white-space: pre; + text-indent: -9999em; /* better cursor hiding for Safari and IE */ + top: calc(var(--cursor-line, 0) * 1em); +} +.cmd .noselect, .cmd [role="presentation"]:not(.cursor-line) > span:last-child, +.cmd .cursor-line > span:last-child > span:last-child { + -webkit-touch-callout: none; /* iOS Safari */ + -webkit-user-select: none; /* Safari */ + -khtml-user-select: none; /* Konqueror HTML */ + -moz-user-select: none; /* Firefox */ + -ms-user-select: none; /* Internet Explorer/Edge */ + user-select: none; /* Non-prefixed version, currently supported by Chrome and Opera */ +} +.terminal img, .terminal audio, .terminal object, .terminal canvas { + cursor: default; } .terminal { - padding: 10px; position: relative; /*overflow: hidden;*/ - overflow: auto; + overflow-y: auto; + /* overflow-x: hidden; */ +} +terminal.temp { + visibility: hidden; +} +.terminal { + contain: content; +} +body.terminal { + min-height: 100vh; + height: 100%; +} +html { + height: 100%; +} +body.terminal, body.full-screen-terminal { + margin: 0; + height: 100%; +} +body.full-screen-terminal .terminal { + height: 100%; +} +.terminal > div:not(.font) { + min-height: 100%; +} +.terminal > .resizer, .terminal > .font .resizer { + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + overflow: hidden; + pointer-events: none; + z-index: -1; + height: 100%; + border: none; + padding: 0; + width: 100% } .cmd { padding: 0; - height: 1.3em; position: relative; - /*margin-top: 3px; */ + float: left; } -.terminal .inverted, .cmd .inverted, .cmd .cursor.blink { +.terminal a[tabindex="1000"], +.terminal a[tabindex="1000"]:active, +.terminal a[tabindex="1000"]:focus { + outline: none; +} +.terminal .inverted, .cmd .inverted { background-color: #aaa; color: #000; } -.cmd .cursor.blink { - -webkit-animation: terminal-blink 1s infinite steps(1, start); - -moz-animation: terminal-blink 1s infinite steps(1, start); - -ms-animation: terminal-blink 1s infinite steps(1, start); - animation: terminal-blink 1s infinite steps(1, start); +.cmd .cursor { + display: inline-block; + position: relative; + height: 14px; + min-width: 1ch; + /* box-sizing: border-box; */ +} +.cmd .cursor span span { + border-bottom: 3px solid transparent; + margin-bottom: -3px; + background-clip: content-box; + border-left: 1px solid transparent; + position: absolute; + top: 0; + /* margin-left: -1px; */ + background-color: inherit; + color: inherit; + bottom: 0; + left: -1px; } -@-webkit-keyframes terminal-blink { - 0%, 100% { - background-color: #000; - color: #aaa; - } - 50% { - background-color: #bbb; - color: #000; - } +.cmd .cursor-line > span:empty { + /* display: none; */ } - -@-ms-keyframes terminal-blink { - 0%, 100% { - background-color: #000; - color: #aaa; - } - 50% { - background-color: #bbb; - color: #000; - } +.cmd .cursor-line > span:empty + .cursor + span { + /*margin-left: -1px;*/ } - -@-moz-keyframes terminal-blink { - 0%, 100% { - background-color: #000; - color: #aaa; - } - 50% { - background-color: #bbb; - color: #000; - } +.cmd .cursor-line > span:not(.cursor):not(:empty) { + /* margin-left: -1px; */ } -@keyframes terminal-blink { - 0%, 100% { - background-color: #000; - color: #aaa; - } - 50% { - background-color: #bbb; /* not #aaa because it's seems there is Google Chrome bug */ - color: #000; - } +.cmd .cursor-line > span { + display: inline-block; + float: left; } - -.terminal .terminal-output div div, .cmd .prompt { +.cmd .cursor.blink span span { + -webkit-animation: terminal-blink 1s infinite linear; + -moz-animation: terminal-blink 1s infinite linear; + -ms-animation: terminal-blink 1s infinite linear; + animation: terminal-blink 1s infinite linear; +} +.bar.terminal .inverted, .bar.cmd .inverted { + border-left-color: #aaa; +} +.terminal .terminal .terminal-output > div > div, .cmd .prompt { display: block; - line-height: 14px; + line-height: 15px; height: auto; } -.cmd .prompt { +.terminal .terminal-output > div:not(.raw) div { + white-space: nowrap; +} +.cmd .prompt > span { float: left; } -.terminal, .cmd { +.terminal, +.terminal-output > :not(.raw) span:not(.token), +.terminal-output > :not(.raw) a, +.terminal-output > :not(.raw) div, +.cmd, +.cmd span, +.cmd div { font-family: monospace; /*font-family: FreeMono, monospace; this don't work on Android */ color: #aaa; background-color: #000; font-size: 12px; - line-height: 14px; + line-height: 15px; +} +.terminal, .cmd { + box-sizing: border-box; + cursor: text; +} +.cmd .cursor span:not(.token) { + color: inherit; + background-color: inherit; } -.terminal-output > div { - /*padding-top: 3px;*/ - min-height: 14px; +.cmd .cursor * { + background-color: transparent; } -.terminal-output > div > div * { - word-wrap: break-word; /* when echo html */ +.cmd div { + clear: both; +} +.cmd .prompt + div { + clear: right; +} +.terminal-output > div > div, .cmd div { + min-height: 15px; +} +terminal .terminal-output > div { + margin-top: -1px; +} +.terminal-output > div.raw > div * { + overflow-wrap: break-word; + word-wrap: break-word; +} +.terminal .font { + position: absolute; + float: left; + font-size: inherit; + line-height: inherit; + top: -100%; + left: 0; + margin-bottom: 1px; } .terminal .terminal-output div span { display: inline-block; } -.cmd span { +.cmd > span:not(.prompt) { float: left; - /*display: inline-block; */ -} -/* fix double style of selecting text in terminal */ -.terminal-output span, .terminal-output a, .cmd div, .cmd span, .terminal td, -.terminal pre, .terminal h1, .terminal h2, .terminal h3, .terminal h4, -.terminal h5, .terminal h6 { - -webkit-touch-callout: initial; - -webkit-user-select: initial; - -khtml-user-select: initial; - -moz-user-select: initial; - -ms-user-select: initial; - user-select: initial; -} -.terminal, .terminal-output, .terminal-output div { - -webkit-touch-callout: none; - -webkit-user-select: none; - -khtml-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} -/* firefox hack */ -@-moz-document url-prefix() { - .terminal, .terminal-output, .terminal-output div { - -webkit-touch-callout: initial; - -webkit-user-select: initial; - -khtml-user-select: initial; - -moz-user-select: initial; - -ms-user-select: initial; - user-select: initial; - } +} +.cmd .prompt span.line { + display: block; + float: none; } .terminal table { border-collapse: collapse; @@ -190,6 +246,233 @@ .terminal td { border: 1px solid #aaa; } +.cmd span[data-text] span { + background-color: inherit; + color: inherit; +} +.cmd [role="presentation"] { + overflow: hidden; + padding-bottom: 3px; + margin-bottom: -3px; +} +/* + * this is set so animation can select original color as backgound for cursor + * so span can have --color for selection + */ +.cmd { + --original-color: var(--color, #aaa); +} +@-webkit-keyframes terminal-blink { + 0%, 50% { + background-color: #bbb; + background-color: var(--original-color, #bbb); + color: #000; + color: var(--background, #000); + } + 50.1%, 100% { + background-color: inherit; + color: inherit; + } +} +@-ms-keyframes terminal-blink { + 0%, 50% { + background-color: #bbb; + background-color: var(--original-color, #bbb); + color: #000; + color: var(--background, #000); + } + 50.1%, 100% { + background-color: inherit; + color: inherit; + } +} +@-moz-keyframes terminal-blink { + 0%, 50% { + background-color: #aaa; + background-color: var(--original-color, #aaa); + color: #000; + color: var(--background, #000); + } + 50.1%, 100% { + background-color: inherit; + color: inherit; + } +} +@keyframes terminal-blink { + 0%, 50% { + background-color: #aaa; + background-color: var(--original-color, #aaa); + color: #000; + color: var(--background, #000); + } + 50.1%, 100% { + background-color: inherit; + color: inherit; + } +} +@-webkit-keyframes terminal-bar { + 0%, 50% { + border-left-color: #aaa; + border-left-color: var(--color, #aaa); + } + 50.1%, 100% { + border-left-color: #000; + border-left-color: var(--background, #000); + } +} +@-ms-keyframes terminal-bar { + 0%, 50% { + border-left-color: #aaa; + border-left-color: var(--color, #aaa); + } + 50.1%, 100% { + border-left-color: #000; + border-left-color: var(--background, #000); + } +} +@-moz-keyframes terminal-bar { + 0%, 50% { + border-left-color: #aaa; + border-left-color: var(--color, #aaa); + } + 50.1%, 100% { + border-left-color: #000; + border-left-color: var(--background, #000); + } +} +@keyframes terminal-bar { + 0%, 50% { + border-left-color: #aaa; + border-left-color: var(--color, #aaa); + } + 50.1%, 100% { + border-left-color: #000; + border-left-color: var(--background, #000); + } +} +@-webkit-keyframes terminal-underline { + 0%, 50% { + border-left: none; + border-bottom-color: #aaa; + border-bottom-color: var(--color, #aaa); + } + 50.1%, 100% { + border-left: none; + border-bottom-color: #000; + border-bottom-color: var(--background, #000); + } +} +@-ms-keyframes terminal-underline { + 0%, 50% { + border-left: none; + border-bottom-color: #aaa; + border-bottom-color: var(--color, #aaa); + } + 50.1%, 100% { + border-left: none; + border-bottom-color: #000; + border-bottom-color: var(--background, #000); + } +} +@-moz-keyframes terminal-underline { + 0%, 50% { + border-left: none; + border-bottom-color: #aaa; + border-bottom-color: var(--color, #aaa); + } + 50.1%, 100% { + border-left: none; + border-bottom-color: #000; + border-bottom-color: var(--background, #000); + } +} +@keyframes terminal-underline { + 0%, 50% { + border-bottom-color: #aaa; + border-bottom-color: var(--color, #aaa); + } + 50.1%, 100% { + border-bottom-color: #000; + border-bottom-color: var(--background, #000); + } +} +.underline-animation .cursor.blink span span { + /* margin-top: 2px; */ + border-left: none; + /* margin-left: 0; */ + margin-right: -1px; + -webkit-animation-name: terminal-underline; + -moz-animation-name: terminal-underline; + -ms-animation-name: terminal-underline; + animation-name: terminal-underline; + right: 1px; +} +.bar-animation .cursor.blink span span { + -webkit-animation-name: terminal-bar; + -moz-animation-name: terminal-bar; + -ms-animation-name: terminal-bar; + animation-name: terminal-bar; +} +/* + Internet Explorer & Edge *, Safari ≤ 6 + source: https://w3reign.com/internet-explorer-edge-css-hacks/ +*/ + + +@supports (-ms-ime-align:auto) { + .cmd .clipboard { + margin-left: -9999px; + } + @keyframes terminal-blink { + 0%, 50% { + background-color: var(--original-color, #aaa); + color: var(--background, #000); + } + 50.1%, 100% { + background-color: var(--background, #000); + color: var(--original-color, #aaa); + } + } + @keyframes terminal-bar { + 0%, 50% { + border-left-color: var(--color, #aaa); + } + 50.1%, 100% { + border-left-color: var(--background, #000); + } + } + @keyframes terminal-underline { + 0%, 50% { + border-bottom-color: var(--color, #aaa); + line-height: 12px; + line-height: calc(var(--size, 1) * 12px); + } + 50.1%, 100% { + border-bottom-color: var(--background, #000); + line-height: 12px; + line-height: calc(var(--size, 1) * 12px); + } + } +} +/* IE hack Edge one don't work in IE11 */ +@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) { + .cmd .clipboard { + margin-left: -9999px; + } + .underline-animation .cursor.blink span span { + margin-top: 1px; + } + @-ms-keyframes terminal-blink { + 0%, 50% { + background-color: #aaa; + color: #000; + } + 50.1%, 100% { + background-color: #000; + color: #aaa; + } + } +} .terminal h1::-moz-selection, .terminal h2::-moz-selection, .terminal h3::-moz-selection, @@ -201,8 +484,12 @@ .terminal .terminal-output div div::-moz-selection, .terminal .terminal-output div span::-moz-selection, .terminal .terminal-output div div a::-moz-selection, +.terminal .terminal-output .raw div::-moz-selection, .cmd div::-moz-selection, .cmd > span::-moz-selection, +.cmd > span span::-moz-selection, +.cmd > div::-moz-selection, +.cmd > div span::-moz-selection, .cmd .prompt span::-moz-selection { background-color: #aaa; color: #000; @@ -226,14 +513,25 @@ .terminal .terminal-output div div::selection, .terminal .terminal-output div div a::selection, .terminal .terminal-output div span::selection, +.terminal .terminal-output .raw div::selection, .cmd div::selection, .cmd > span::selection, +.cmd > span span::selection, +.cmd > div::selection, +.cmd > div span::selection, .cmd .prompt span::selection { - background-color: #aaa; + /* + * use rgba to fix transparent selection in chrome + * http://stackoverflow.com/questions/7224445/css3-selection-behaves-differently-in-ff-chrome + */ + background-color: rgba(170, 170, 170, 0.99); color: #000; } -.terminal .terminal-output div.error, .terminal .terminal-output div.error div { + +.terminal .terminal-output > :not(.raw) .error, +.terminal .terminal-output > :not(.raw) .error * { color: red; + color: var(--error-color, red); } .tilda { position: fixed; @@ -242,12 +540,202 @@ width: 100%; z-index: 1100; } +.ui-dialog-content .terminal { + width: 100%; + height: 100%; + box-sizing: border-box; +} +.ui-dialog .ui-dialog-content.dterm { + padding: 0; +} .clear { clear: both; } -.terminal a { +.terminal .terminal-output > :not(.raw) > div { + padding-bottom: 1px; +} +.terminal .terminal-output > :not(.raw) a[href] { color: #0F60FF; + color: var(--link-color, #0F60FF); + cursor: pointer; } -.terminal a:hover { - color: red; +.terminal .terminal-output > :not(.raw) a[href]:hover { + background-color: #0F60FF; + background-color: var(--link-color, #0F60FF); + color: var(--background, #000); + text-decoration: none; +} +.terminal .terminal-fill { + position: absolute; + left: 0; + top: -100%; + width: 100%; + height: 100%; + margin: 1px 0 0; + border: none; + opacity: 0.01; + pointer-events: none; + box-sizing: border-box; +} +.terminal, .terminal .terminal-fill { + padding: 10px; +} +/* padding added as margin to .cmd to fix FireFox bug see: https://stackoverflow.com/q/29986977/387194 */ +.terminal { + padding-bottom: 0; +} +.terminal .cmd { + margin-bottom: 10px; +} +@supports (--css: variables) { + .terminal, + .terminal-output > :not(.raw) span:not(.token), + .terminal-output > :not(.raw) a, + .terminal-output > :not(.raw) div, + .cmd, + .cmd span, + .cmd div { + color: var(--color, #aaa); + background-color: var(--background, #000); + } + .terminal span[style*="--length"] { + /* + * default value for char-width taken from Google Chrome for default font + * to silence warning in webpack #371 + */ + width: calc(var(--length, 1) * var(--char-width, 7.23438) * 1px); + display: inline-block; + } + .terminal, + .terminal-output > :not(.raw) span:not(.token), + .terminal-output > :not(.raw) a, + .terminal-output > :not(.raw) div, + .cmd, + .cmd span, + .cmd div { + font-size: calc(var(--size, 1) * 12px); + line-height: calc(var(--size, 1) * 12px + 3px); + } + .cmd .clipboard { + top: calc(var(--size, 1) * 14 * var(--cursor-line, 0) * 1px); + } + .terminal .terminal-output > div > div, .cmd div{ + min-height: calc(var(--size, 1) * 15px); + } + .terminal .inverted, .cmd .inverted { + background-color: var(--color, #aaa); + color: var(--background, #000); + } + .cmd div { + min-height: calc(var(--size, 1) * 14px); + } + .cmd .cursor.blink { + color: var(--color, #aaa); + background-color: var(--background, #000); + } + .cmd .cursor.blink span span { + -webkit-animation: var(--animation, terminal-blink) 1s infinite linear; + -moz-animation: var(--animation, terminal-blink) 1s infinite linear; + -ms-animation: var(--animation, terminal-blink) 1s infinite linear; + animation: var(--animation, terminal-blink) 1s infinite linear; + } + .cmd .cursor { + height: calc(var(--size, 1) * 14px); + min-width: calc(var(--char-width, 7.23438) * 1px); + } + .terminal h1::-moz-selection, + .terminal h2::-moz-selection, + .terminal h3::-moz-selection, + .terminal h4::-moz-selection, + .terminal h5::-moz-selection, + .terminal h6::-moz-selection, + .terminal pre::-moz-selection, + .terminal td::-moz-selection, + .terminal .terminal-output div div::-moz-selection, + .terminal .terminal-output div span::-moz-selection, + .terminal .terminal-output div div a::-moz-selection, + .cmd div::-moz-selection, + .cmd > span::-moz-selection, + .cmd > span span::-moz-selection, + .cmd > div::-moz-selection, + .cmd > div span::-moz-selection, + .cmd .prompt span::-moz-selection { + background-color: var(--color, #aaa); + color: var(--background, #000); + } + .terminal h1::selection, + .terminal h2::selection, + .terminal h3::selection, + .terminal h4::selection, + .terminal h5::selection, + .terminal h6::selection, + .terminal pre::selection, + .terminal td::selection, + .terminal .terminal-output div div::selection, + .terminal .terminal-output div div a::selection, + .terminal .terminal-output div span::selection, + .cmd div::selection, + .cmd > span::selection, + .cmd > span span::selection, + .cmd > div::selection, + .cmd > div span::selection, + .cmd .prompt span::selection { + background-color: var(--color, rgba(170, 170, 170, 0.99)); + color: var(--background, #000) !important; + } +} +/* + * overwrite css variables that don't work with selection in Edge + */ +@supports (-ms-ime-align:auto) { + .terminal h1::selection, + .terminal h2::selection, + .terminal h3::selection, + .terminal h4::selection, + .terminal h5::selection, + .terminal h6::selection, + .terminal pre::selection, + .terminal td::selection, + .terminal .terminal-output div div::selection, + .terminal .terminal-output div div a::selection, + .terminal .terminal-output div span::selection, + .cmd div::selection, + .cmd > span::selection, + .cmd > span span::selection, + .cmd > div::selection, + .cmd > div span::selection, + .cmd .prompt span::selection { + background-color: rgba(170, 170, 170, 0.99); + color: #000; + } } +/* PrismJS style overwrites */ +.terminal .token.operator, +.terminal .token.entity, +.terminal .token.variable, +.terminal .token.url, +.terminal .token.string, +.terminal .style .token.string, +.terminal .token.token, +.cmd .token.operator, +.cmd .token.entity, +.cmd .token.variable, +.cmd .token.url, +.cmd .token.string, +.cmd .style .token.string, +.cmd .token.token { + background-color: inherit; +} +/* FireFox hack +@supports (-moz-animation: foo) { + .terminal, + .terminal .terminal-output > :not(.raw) span, + .terminal .terminal-output > :not(.raw) a, + .terminal .terminal-output > :not(.raw) div, + .cmd, + .cmd span, + .cmd div { + line-height: calc(var(--size, 1) * 13px); + } +} +*/ diff --git a/web/css/jquery.terminal.min.css b/web/css/jquery.terminal.min.css index a5b6875..af48e62 100644 --- a/web/css/jquery.terminal.min.css +++ b/web/css/jquery.terminal.min.css @@ -4,13 +4,14 @@ * __ / // // // // // _ // _// // / / // _ // _// // // \/ // _ \/ / * / / // // // // // ___// / / // / / // ___// / / / / // // /\ // // / /__ * \___//____ \\___//____//_/ _\_ / /_//____//_/ /_/ /_//_//_/ /_/ \__\_\___/ - * \/ /____/ version 0.11.23 + * \/ /____/ version 2.0.2 * http://terminal.jcubic.pl * * This file is part of jQuery Terminal. * - * Copyright (c) 2011-2016 Jakub Jankiewicz + * Copyright (c) 2011-2018 Jakub Jankiewicz * Released under the MIT license * - * Date: Sun, 11 Dec 2016 13:17:01 +0000 - */.terminal .terminal-output .format,.cmd .format,.cmd .prompt,.cmd .prompt div,.terminal .terminal-output div div{display:inline-block}.terminal h1,.terminal h2,.terminal h3,.terminal h4,.terminal h5,.terminal h6,.terminal pre,.cmd{margin:0}.terminal h1,.terminal h2,.terminal h3,.terminal h4,.terminal h5,.terminal h6{line-height:1.2em}.cmd .clipboard{position:absolute;left:-16px;top:0;width:10px;height:16px;background:transparent;border:0;color:transparent;outline:0;padding:0;resize:none;z-index:0;overflow:hidden}.terminal .error{color:red}.terminal{padding:10px;position:relative;overflow:auto}.cmd{padding:0;height:1.3em;position:relative}.terminal .inverted,.cmd .inverted,.cmd .cursor.blink{background-color:#aaa;color:#000}.cmd .cursor.blink{-webkit-animation:terminal-blink 1s infinite steps(1,start);-moz-animation:terminal-blink 1s infinite steps(1,start);-ms-animation:terminal-blink 1s infinite steps(1,start);animation:terminal-blink 1s infinite steps(1,start)}@-webkit-keyframes terminal-blink{0%,100%{background-color:#000;color:#aaa}50%{background-color:#bbb;color:#000}}@-ms-keyframes terminal-blink{0%,100%{background-color:#000;color:#aaa}50%{background-color:#bbb;color:#000}}@-moz-keyframes terminal-blink{0%,100%{background-color:#000;color:#aaa}50%{background-color:#bbb;color:#000}}@keyframes terminal-blink{0%,100%{background-color:#000;color:#aaa}50%{background-color:#bbb;color:#000}}.terminal .terminal-output div div,.cmd .prompt{display:block;line-height:14px;height:auto}.cmd .prompt{float:left}.terminal,.cmd{font-family:monospace;color:#aaa;background-color:#000;font-size:12px;line-height:14px}.terminal-output>div{min-height:14px}.terminal-output>div>div *{word-wrap:break-word}.terminal .terminal-output div span{display:inline-block}.cmd span{float:left}.terminal-output span,.terminal-output a,.cmd div,.cmd span,.terminal td,.terminal pre,.terminal h1,.terminal h2,.terminal h3,.terminal h4,.terminal h5,.terminal h6{-webkit-touch-callout:initial;-webkit-user-select:initial;-khtml-user-select:initial;-moz-user-select:initial;-ms-user-select:initial;user-select:initial}.terminal,.terminal-output,.terminal-output div{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}@-moz-document url-prefix(){.terminal,.terminal-output,.terminal-output div{-webkit-touch-callout:initial;-webkit-user-select:initial;-khtml-user-select:initial;-moz-user-select:initial;-ms-user-select:initial;user-select:initial}}.terminal table{border-collapse:collapse}.terminal td{border:1px solid #aaa}.terminal h1::-moz-selection,.terminal h2::-moz-selection,.terminal h3::-moz-selection,.terminal h4::-moz-selection,.terminal h5::-moz-selection,.terminal h6::-moz-selection,.terminal pre::-moz-selection,.terminal td::-moz-selection,.terminal .terminal-output div div::-moz-selection,.terminal .terminal-output div span::-moz-selection,.terminal .terminal-output div div a::-moz-selection,.cmd div::-moz-selection,.cmd>span::-moz-selection,.cmd .prompt span::-moz-selection{background-color:#aaa;color:#000}.terminal h1::selection,.terminal h2::selection,.terminal h3::selection,.terminal h4::selection,.terminal h5::selection,.terminal h6::selection,.terminal pre::selection,.terminal td::selection,.terminal .terminal-output div div::selection,.terminal .terminal-output div div a::selection,.terminal .terminal-output div span::selection,.cmd div::selection,.cmd>span::selection,.cmd .prompt span::selection{background-color:#aaa;color:#000}.terminal .terminal-output div.error,.terminal .terminal-output div.error div{color:red}.tilda{position:fixed;top:0;left:0;width:100%;z-index:1100}.clear{clear:both}.terminal a{color:#0f60ff}.terminal a:hover{color:red} \ No newline at end of file + * Date: Sat, 22 Dec 2018 15:04:14 +0000 + */.cmd .format,.cmd .prompt,.cmd .prompt div,.terminal .terminal-output .format,.terminal .terminal-output div div{display:inline-block}.cmd,.terminal h1,.terminal h2,.terminal h3,.terminal h4,.terminal h5,.terminal h6,.terminal pre{margin:0}.terminal h1,.terminal h2,.terminal h3,.terminal h4,.terminal h5,.terminal h6{line-height:1.2em}.cmd .clipboard{background-color:transparent;border:none;color:transparent;height:16px;left:-16px;outline:none;overflow:hidden;padding:0;position:absolute;resize:none;text-indent:-9999em;top:0;top:calc(var(--cursor-line, 0) * 1em);white-space:pre;width:16px;z-index:1000}.cmd .cursor-line>span:last-child>span:last-child,.cmd .noselect,.cmd [role=presentation]:not(.cursor-line)>span:last-child{-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;-webkit-touch-callout:none;-webkit-user-select:none;user-select:none}.terminal audio,.terminal canvas,.terminal img,.terminal object{cursor:default}.terminal{overflow-y:auto;position:relative}terminal.temp{visibility:hidden}.terminal{contain:content}body.terminal{height:100%;min-height:100vh}html{height:100%}body.full-screen-terminal,body.terminal{height:100%;margin:0}body.full-screen-terminal .terminal{height:100%}.terminal>div:not(.font){min-height:100%}.terminal>.font .resizer,.terminal>.resizer{border:none;bottom:0;height:100%;left:0;overflow:hidden;padding:0;pointer-events:none;position:absolute;right:0;top:0;width:100%;z-index:-1}.cmd{float:left;padding:0;position:relative}.terminal a[tabindex="1000"],.terminal a[tabindex="1000"]:active,.terminal a[tabindex="1000"]:focus{outline:none}.cmd .inverted,.terminal .inverted{background-color:#aaa;color:#000}.cmd .cursor{display:inline-block;height:14px;min-width:1ch;position:relative}.cmd .cursor span span{background-clip:content-box;background-color:inherit;border-bottom:3px solid transparent;border-left:1px solid transparent;bottom:0;color:inherit;left:-1px;margin-bottom:-3px;position:absolute;top:0}.cmd .cursor-line>span{display:inline-block;float:left}.cmd .cursor.blink span span{-moz-animation:terminal-blink 1s infinite linear;-ms-animation:terminal-blink 1s infinite linear;-webkit-animation:terminal-blink 1s linear infinite;animation:terminal-blink 1s linear infinite}.bar.cmd .inverted,.bar.terminal .inverted{border-left-color:#aaa}.cmd .prompt,.terminal .terminal .terminal-output>div>div{display:block;height:auto;line-height:15px}.terminal .terminal-output>div:not(.raw) div{white-space:nowrap}.cmd .prompt>span{float:left}.cmd,.cmd div,.cmd span,.terminal,.terminal-output>:not(.raw) a,.terminal-output>:not(.raw) div,.terminal-output>:not(.raw) span:not(.token){background-color:#000;color:#aaa;font-family:monospace;font-size:12px;line-height:15px}.cmd,.terminal{box-sizing:border-box;cursor:text}.cmd .cursor span:not(.token){background-color:inherit;color:inherit}.cmd .cursor *{background-color:transparent}.cmd div{clear:both}.cmd .prompt+div{clear:right}.cmd div,.terminal-output>div>div{min-height:15px}terminal .terminal-output>div{margin-top:-1px}.terminal-output>div.raw>div *{overflow-wrap:break-word;word-wrap:break-word}.terminal .font{float:left;font-size:inherit;left:0;line-height:inherit;margin-bottom:1px;position:absolute;top:-100%}.terminal .terminal-output div span{display:inline-block}.cmd>span:not(.prompt){float:left}.cmd .prompt span.line{display:block;float:none}.terminal table{border-collapse:collapse}.terminal td{border:1px solid #aaa}.cmd span[data-text] span{background-color:inherit;color:inherit}.cmd [role=presentation]{margin-bottom:-3px;overflow:hidden;padding-bottom:3px}.cmd{--original-color:var(--color,#aaa)}@-webkit-keyframes terminal-blink{0%,50%{background-color:#bbb;background-color:var(--original-color,#bbb);color:#000;color:var(--background,#000)}50.1%,to{background-color:inherit;color:inherit}}@-ms-keyframes terminal-blink{0%,50%{background-color:#bbb;background-color:var(--original-color,#bbb);color:#000;color:var(--background,#000)}50.1%,to{background-color:inherit;color:inherit}}@-moz-keyframes terminal-blink{0%,50%{background-color:#aaa;background-color:var(--original-color,#aaa);color:#000;color:var(--background,#000)}50.1%,to{background-color:inherit;color:inherit}}@keyframes terminal-blink{0%,50%{background-color:#aaa;background-color:var(--original-color,#aaa);color:#000;color:var(--background,#000)}50.1%,to{background-color:inherit;color:inherit}}@-webkit-keyframes terminal-bar{0%,50%{border-left-color:#aaa;border-left-color:var(--color,#aaa)}50.1%,to{border-left-color:#000;border-left-color:var(--background,#000)}}@-ms-keyframes terminal-bar{0%,50%{border-left-color:#aaa;border-left-color:var(--color,#aaa)}50.1%,to{border-left-color:#000;border-left-color:var(--background,#000)}}@-moz-keyframes terminal-bar{0%,50%{border-left-color:#aaa;border-left-color:var(--color,#aaa)}50.1%,to{border-left-color:#000;border-left-color:var(--background,#000)}}@keyframes terminal-bar{0%,50%{border-left-color:#aaa;border-left-color:var(--color,#aaa)}50.1%,to{border-left-color:#000;border-left-color:var(--background,#000)}}@-webkit-keyframes terminal-underline{0%,50%{border-bottom-color:#aaa;border-bottom-color:var(--color,#aaa);border-left:none}50.1%,to{border-bottom-color:#000;border-bottom-color:var(--background,#000);border-left:none}}@-ms-keyframes terminal-underline{0%,50%{border-bottom-color:#aaa;border-bottom-color:var(--color,#aaa);border-left:none}50.1%,to{border-bottom-color:#000;border-bottom-color:var(--background,#000);border-left:none}}@-moz-keyframes terminal-underline{0%,50%{border-bottom-color:#aaa;border-bottom-color:var(--color,#aaa);border-left:none}50.1%,to{border-bottom-color:#000;border-bottom-color:var(--background,#000);border-left:none}}@keyframes terminal-underline{0%,50%{border-bottom-color:#aaa;border-bottom-color:var(--color,#aaa)}50.1%,to{border-bottom-color:#000;border-bottom-color:var(--background,#000)}}.underline-animation .cursor.blink span span{-moz-animation-name:terminal-underline;-ms-animation-name:terminal-underline;-webkit-animation-name:terminal-underline;animation-name:terminal-underline;border-left:none;margin-right:-1px;right:1px}.bar-animation .cursor.blink span span{-moz-animation-name:terminal-bar;-ms-animation-name:terminal-bar;-webkit-animation-name:terminal-bar;animation-name:terminal-bar}@supports (-ms-ime-align:auto){.cmd .clipboard{margin-left:-9999px}@keyframes terminal-blink{0%,50%{background-color:var(--original-color,#aaa);color:var(--background,#000)}50.1%,to{background-color:var(--background,#000);color:var(--original-color,#aaa)}}@keyframes terminal-bar{0%,50%{border-left-color:var(--color,#aaa)}50.1%,to{border-left-color:var(--background,#000)}}@keyframes terminal-underline{0%,50%{border-bottom-color:var(--color,#aaa);line-height:12px;line-height:calc(var(--size, 1) * 12px)}50.1%,to{border-bottom-color:var(--background,#000);line-height:12px;line-height:calc(var(--size, 1) * 12px)}}}@media (-ms-high-contrast:active),(-ms-high-contrast:none){.cmd .clipboard{margin-left:-9999px}.underline-animation .cursor.blink span span{margin-top:1px}@-ms-keyframes terminal-blink{0%,50%{background-color:#aaa;color:#000}50.1%,to{background-color:#000;color:#aaa}}}.cmd .prompt span::-moz-selection,.cmd>div::-moz-selection,.cmd>div span::-moz-selection,.cmd>span::-moz-selection,.cmd>span span::-moz-selection,.cmd div::-moz-selection,.terminal .terminal-output .raw div::-moz-selection,.terminal .terminal-output div div::-moz-selection,.terminal .terminal-output div div a::-moz-selection,.terminal .terminal-output div span::-moz-selection,.terminal h1::-moz-selection,.terminal h2::-moz-selection,.terminal h3::-moz-selection,.terminal h4::-moz-selection,.terminal h5::-moz-selection,.terminal h6::-moz-selection,.terminal pre::-moz-selection,.terminal td::-moz-selection{background-color:#aaa;color:#000}.cmd .prompt span::selection,.cmd>div::selection,.cmd>div span::selection,.cmd>span::selection,.cmd>span span::selection,.cmd div::selection,.terminal .terminal-output .raw div::selection,.terminal .terminal-output div div::selection,.terminal .terminal-output div div a::selection,.terminal .terminal-output div span::selection,.terminal h1::selection,.terminal h2::selection,.terminal h3::selection,.terminal h4::selection,.terminal h5::selection,.terminal h6::selection,.terminal pre::selection,.terminal td::selection{background-color:hsla(0,0%,66.7%,.99);color:#000}.terminal .terminal-output>:not(.raw) .error,.terminal .terminal-output>:not(.raw) .error *{color:red;color:var(--error-color,red)}.tilda{left:0;position:fixed;top:0;width:100%;z-index:1100}.ui-dialog-content .terminal{box-sizing:border-box;height:100%;width:100%}.ui-dialog .ui-dialog-content.dterm{padding:0}.clear{clear:both}.terminal .terminal-output>:not(.raw)>div{padding-bottom:1px}.terminal .terminal-output>:not(.raw) a[href]{color:#0f60ff;color:var(--link-color,#0f60ff);cursor:pointer}.terminal .terminal-output>:not(.raw) a[href]:hover{background-color:#0f60ff;background-color:var(--link-color,#0f60ff);color:var(--background,#000);text-decoration:none}.terminal .terminal-fill{border:none;box-sizing:border-box;height:100%;left:0;margin:1px 0 0;opacity:.01;pointer-events:none;position:absolute;top:-100%;width:100%}.terminal,.terminal .terminal-fill{padding:10px}.terminal{padding-bottom:0}.terminal .cmd{margin-bottom:10px}@supports (--css:variables){.cmd,.cmd div,.cmd span,.terminal,.terminal-output>:not(.raw) a,.terminal-output>:not(.raw) div,.terminal-output>:not(.raw) span:not(.token){background-color:var(--background,#000);color:var(--color,#aaa)}.terminal span[style*="--length"]{display:inline-block;width:calc(var(--length, 1) * var(--char-width, 7.23438) * 1px)}.cmd,.cmd div,.cmd span,.terminal,.terminal-output>:not(.raw) a,.terminal-output>:not(.raw) div,.terminal-output>:not(.raw) span:not(.token){font-size:calc(var(--size, 1) * 12px);line-height:calc(var(--size, 1) * 12px + 3px)}.cmd .clipboard{top:calc(var(--size, 1) * 14 * var(--cursor-line, 0) * 1px)}.cmd div,.terminal .terminal-output>div>div{min-height:calc(var(--size, 1) * 15px)}.cmd .inverted,.terminal .inverted{background-color:var(--color,#aaa);color:var(--background,#000)}.cmd div{min-height:calc(var(--size, 1) * 14px)}.cmd .cursor.blink{background-color:var(--background,#000);color:var(--color,#aaa)}.cmd .cursor.blink span span{-moz-animation:var(--animation,terminal-blink) 1s infinite linear;-ms-animation:var(--animation,terminal-blink) 1s infinite linear;-webkit-animation:var(--animation,terminal-blink) 1s infinite linear;animation:var(--animation,terminal-blink) 1s infinite linear}.cmd .cursor{height:calc(var(--size, 1) * 14px);min-width:calc(var(--char-width, 7.23438) * 1px)}.cmd .prompt span::-moz-selection,.cmd>div::-moz-selection,.cmd>div span::-moz-selection,.cmd>span::-moz-selection,.cmd>span span::-moz-selection,.cmd div::-moz-selection,.terminal .terminal-output div div::-moz-selection,.terminal .terminal-output div div a::-moz-selection,.terminal .terminal-output div span::-moz-selection,.terminal h1::-moz-selection,.terminal h2::-moz-selection,.terminal h3::-moz-selection,.terminal h4::-moz-selection,.terminal h5::-moz-selection,.terminal h6::-moz-selection,.terminal pre::-moz-selection,.terminal td::-moz-selection{background-color:var(--color,#aaa);color:var(--background,#000)}.cmd .prompt span::selection,.cmd>div::selection,.cmd>div span::selection,.cmd>span::selection,.cmd>span span::selection,.cmd div::selection,.terminal .terminal-output div div::selection,.terminal .terminal-output div div a::selection,.terminal .terminal-output div span::selection,.terminal h1::selection,.terminal h2::selection,.terminal h3::selection,.terminal h4::selection,.terminal h5::selection,.terminal h6::selection,.terminal pre::selection,.terminal td::selection{background-color:var(--color,hsla(0,0%,66.7%,.99));color:var(--background,#000)!important}}@supports (-ms-ime-align:auto){.cmd .prompt span::selection,.cmd>div::selection,.cmd>div span::selection,.cmd>span::selection,.cmd>span span::selection,.cmd div::selection,.terminal .terminal-output div div::selection,.terminal .terminal-output div div a::selection,.terminal .terminal-output div span::selection,.terminal h1::selection,.terminal h2::selection,.terminal h3::selection,.terminal h4::selection,.terminal h5::selection,.terminal h6::selection,.terminal pre::selection,.terminal td::selection{background-color:hsla(0,0%,66.7%,.99);color:#000}}.cmd .style .token.string,.cmd .token.entity,.cmd .token.operator,.cmd .token.string,.cmd .token.token,.cmd .token.url,.cmd .token.variable,.terminal .style .token.string,.terminal .token.entity,.terminal .token.operator,.terminal .token.string,.terminal .token.token,.terminal .token.url,.terminal .token.variable{background-color:inherit} +/*# sourceMappingURL=jquery.terminal.min.css.map */ \ No newline at end of file diff --git a/web/js/jquery.terminal.js b/web/js/jquery.terminal.js new file mode 100644 index 0000000..623068a --- /dev/null +++ b/web/js/jquery.terminal.js @@ -0,0 +1,8648 @@ +/**@license + * __ _____ ________ __ + * / // _ /__ __ _____ ___ __ _/__ ___/__ ___ ______ __ __ __ ___ / / + * __ / // // // // // _ // _// // / / // _ // _// // // \/ // _ \/ / + * / / // // // // // ___// / / // / / // ___// / / / / // // /\ // // / /__ + * \___//____ \\___//____//_/ _\_ / /_//____//_/ /_/ /_//_//_/ /_/ \__\_\___/ + * \/ /____/ version 2.0.2 + * + * This file is part of jQuery Terminal. http://terminal.jcubic.pl + * + * Copyright (c) 2010-2018 Jakub Jankiewicz + * Released under the MIT license + * + * Contains: + * + * Storage plugin Distributed under the MIT License + * modified to work from Data URIs that block storage and cookies in Chrome + * Copyright (c) 2010 Dave Schindler + * + * jQuery Timers licenced with the WTFPL + * + * + * Cross-Browser Split 1.1.1 + * Copyright 2007-2012 Steven Levithan + * Available under the MIT License + * + * jQuery Caret + * Copyright (c) 2009, Gideon Sireling + * 3 clause BSD License + * + * sprintf.js + * Copyright (c) 2007-2013 Alexandru Marasteanu + * licensed under 3 clause BSD license + * + * emoji regex v7.0.1 by Mathias Bynens + * MIT license + * + * Date: Sat, 22 Dec 2018 15:04:13 +0000 + */ + +/* TODO: + * + * Debug interpreters names in LocalStorage + * + * TEST: login + promises/exec + * json-rpc/object + promises + * + * NOTE: json-rpc don't need promises and delegate resume/pause because only + * exec can call it and exec call interpreter that work with resume/pause + */ +/* global location, jQuery, setTimeout, window, global, localStorage, sprintf, + setImmediate, IntersectionObserver, MutationObserver, ResizeObserver, + module, require, define, setInterval, clearInterval */ +/* eslint-disable */ +/* istanbul ignore next */ +(function(ctx) { + var sprintf = function() { + if (!sprintf.cache.hasOwnProperty(arguments[0])) { + sprintf.cache[arguments[0]] = sprintf.parse(arguments[0]); + } + return sprintf.format.call(null, sprintf.cache[arguments[0]], arguments); + }; + sprintf.format = function(parse_tree, argv) { + var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length; + for (i = 0; i < tree_length; i++) { + node_type = get_type(parse_tree[i]); + if (node_type === 'string') { + output.push(parse_tree[i]); + } + else if (node_type === 'array') { + match = parse_tree[i]; // convenience purposes only + if (match[2]) { // keyword argument + arg = argv[cursor]; + for (k = 0; k < match[2].length; k++) { + if (!arg.hasOwnProperty(match[2][k])) { + throw(sprintf('[sprintf] property "%s" does not exist', match[2][k])); + } + arg = arg[match[2][k]]; + } + } + else if (match[1]) { // positional argument (explicit) + arg = argv[match[1]]; + } + else { // positional argument (implicit) + arg = argv[cursor++]; + } + + if (/[^s]/.test(match[8]) && (get_type(arg) !== 'number')) { + throw(sprintf('[sprintf] expecting number but found %s', get_type(arg))); + } + switch (match[8]) { + case 'b': arg = arg.toString(2); break; + case 'c': arg = String.fromCharCode(arg); break; + case 'd': arg = parseInt(arg, 10); break; + case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break; + case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break; + case 'o': arg = arg.toString(8); break; + case 's': arg = ((arg = String(arg)) && match[7] ? arg.slice(0, match[7]) : arg); break; + case 'u': arg = arg >>> 0; break; + case 'x': arg = arg.toString(16); break; + case 'X': arg = arg.toString(16).toUpperCase(); break; + } + arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? ' +' + arg : arg); + pad_character = match[4] ? match[4] === '0' ? '0' : match[4].charAt(1) : ' '; + pad_length = match[6] - String(arg).length; + pad = match[6] ? str_repeat(pad_character, pad_length) : ''; + output.push(match[5] ? arg + pad : pad + arg); + } + } + return output.join(''); + }; + + sprintf.cache = {}; + + sprintf.parse = function(fmt) { + var _fmt = fmt, match = [], parse_tree = [], arg_names = 0; + while (_fmt) { + if ((match = /^[^\x25]+/.exec(_fmt)) !== null) { + parse_tree.push(match[0]); + } + else if ((match = /^\x25{2}/.exec(_fmt)) !== null) { + parse_tree.push('%'); + } + else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) { + if (match[2]) { + arg_names |= 1; + var field_list = [], replacement_field = match[2], field_match = []; + if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { + field_list.push(field_match[1]); + while ((replacement_field = replacement_field.slice(field_match[0].length)) !== '') { + if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { + field_list.push(field_match[1]); + } + else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) { + field_list.push(field_match[1]); + } + else { + throw('[sprintf] huh?'); + } + } + } + else { + throw('[sprintf] huh?'); + } + match[2] = field_list; + } + else { + arg_names |= 2; + } + if (arg_names === 3) { + throw('[sprintf] mixing positional and named placeholders is not (yet) supported'); + } + parse_tree.push(match); + } + else { + throw('[sprintf] huh?'); + } + _fmt = _fmt.slice(match[0].length); + } + return parse_tree; + }; + + var vsprintf = function(fmt, argv, _argv) { + _argv = argv.slice(0); + _argv.splice(0, 0, fmt); + return sprintf.apply(null, _argv); + }; + + /** + * helpers + */ + function get_type(variable) { + return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase(); + } + + function str_repeat(input, multiplier) { + for (var output = []; multiplier > 0; output[--multiplier] = input) {/* do nothing */} + return output.join(''); + } + + /** + * export to either browser or node.js + */ + ctx.sprintf = sprintf; + ctx.vsprintf = vsprintf; +})(typeof global !== "undefined" ? global : window); +/* eslint-enable */ +// UMD taken from https://github.com/umdjs/umd +(function(factory, undefined) { + var root = typeof window !== 'undefined' ? window : global; + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + // istanbul ignore next + define(['jquery', 'wcwidth'], factory); + } else if (typeof module === 'object' && module.exports) { + // Node/CommonJS + module.exports = function(root, jQuery, wcwidth) { + if (jQuery === undefined) { + // require('jQuery') returns a factory that requires window to + // build a jQuery instance, we normalize how we use modules + // that require this pattern but the window provided is a noop + // if it's defined (how jquery works) + if (window !== undefined) { + jQuery = require('jquery'); + } else { + jQuery = require('jquery')(root); + } + } + if (wcwidth === undefined) { + wcwidth = require('wcwidth'); + } + factory(jQuery, wcwidth); + return jQuery; + }; + } else { + // Browser + // istanbul ignore next + factory(root.jQuery, root.wcwidth); + } +})(function($, wcwidth, undefined) { + 'use strict'; + // ----------------------------------------------------------------------- + // :: debug functions + // ----------------------------------------------------------------------- + /* eslint-disable */ + function debug(str) { + if (false) { + console.log(str); + //$.terminal.active().echo(str); + } + } + /* eslint-enable */ + // ----------------------------------------------------------------------- + // :: Replacemenet for jQuery 2 deferred objects + // ----------------------------------------------------------------------- + function DelayQueue() { + var callbacks = $.Callbacks(); + var resolved = false; + this.resolve = function() { + callbacks.fire(); + resolved = true; + }; + this.add = function(fn) { + if (resolved) { + fn(); + } else { + callbacks.add(fn); + } + }; + } + // ----------------------------------------------------------------------- + // :: map object to object + // ----------------------------------------------------------------------- + $.omap = function(o, fn) { + var result = {}; + $.each(o, function(k, v) { + result[k] = fn.call(o, k, v); + }); + return result; + }; + $.fn.text_length = function() { + return this.map(function() { + return $(this).text().length; + }).get().reduce(function(a, b) { + return a + b; + }, 0); + }; + // ----------------------------------------------------------------------- + // :: Deep clone of objects and arrays + // ----------------------------------------------------------------------- + var Clone = { + clone_object: function(object) { + var tmp = {}; + if (typeof object === 'object') { + if ($.isArray(object)) { + return this.clone_array(object); + } else if (object === null) { + return object; + } else { + for (var key in object) { + if ($.isArray(object[key])) { + tmp[key] = this.clone_array(object[key]); + } else if (typeof object[key] === 'object') { + tmp[key] = this.clone_object(object[key]); + } else { + tmp[key] = object[key]; + } + } + } + } + return tmp; + }, + clone_array: function(array) { + if (!is_function(Array.prototype.map)) { + throw new Error("Your browser don't support ES5 array map " + + 'use es5-shim'); + } + return array.slice(0).map(function(item) { + if (typeof item === 'object') { + return this.clone_object(item); + } else { + return item; + } + }.bind(this)); + } + }; + var clone = function(object) { + return Clone.clone_object(object); + }; + + /* eslint-disable */ + // ----------------------------------------------------------------------- + // :: Storage plugin + // ----------------------------------------------------------------------- + var localStorage; + /* istanbul ignore next */ + (function() { + var hasLS = function() { + try { + var testKey = 'test', storage = window.localStorage; + storage.setItem(testKey, '1'); + storage.removeItem(testKey); + return true; + } catch (error) { + return false; + } + }; + var hasCookies = function() { + try { + document.cookie.split(';'); + return true; + } catch (e) { + return false; + } + }; + // Private data + var isLS = hasLS(); + // Private functions + function wls(n, v) { + var c; + if (typeof n === 'string' && typeof v === 'string') { + localStorage[n] = v; + return true; + } else if (typeof n === 'object' && typeof v === 'undefined') { + for (c in n) { + if (n.hasOwnProperty(c)) { + localStorage[c] = n[c]; + } + } + return true; + } + return false; + } + function wc(n, v) { + var dt, e, c; + dt = new Date(); + dt.setTime(dt.getTime() + 31536000000); + e = '; expires=' + dt.toGMTString(); + if (typeof n === 'string' && typeof v === 'string') { + document.cookie = n + '=' + v + e + '; path=/'; + return true; + } else if (typeof n === 'object' && typeof v === 'undefined') { + for (c in n) { + if (n.hasOwnProperty(c)) { + document.cookie = c + '=' + n[c] + e + '; path=/'; + } + } + return true; + } + return false; + } + function rls(n) { + return localStorage[n]; + } + function rc(n) { + var nn, ca, i, c; + nn = n + '='; + ca = document.cookie.split(';'); + for (i = 0; i < ca.length; i++) { + c = ca[i]; + while (c.charAt(0) === ' ') { + c = c.slice(1, c.length); + } + if (c.indexOf(nn) === 0) { + return c.slice(nn.length, c.length); + } + } + return null; + } + function dls(n) { + return delete localStorage[n]; + } + function dc(n) { + return wc(n, '', -1); + } + /** + * Public API + * $.Storage.set("name", "value") + * $.Storage.set({"name1":"value1", "name2":"value2", etc}) + * $.Storage.get("name") + * $.Storage.remove("name") + */ + if (!hasCookies() && !isLS) { + localStorage = {}; + $.extend({ + Storage: { + set: wls, + get: rls, + remove: dls + } + }); + } else { + if (isLS) { + localStorage = window.localStorage; + } + $.extend({ + Storage: { + set: isLS ? wls : wc, + get: isLS ? rls : rc, + remove: isLS ? dls : dc + } + }); + } + })(); + // ----------------------------------------------------------------------- + // :: jQuery Timers + // ----------------------------------------------------------------------- + var jQuery = $; + /* istanbul ignore next */ + (function($) { + jQuery.fn.extend({ + everyTime: function(interval, label, fn, times, belay) { + return this.each(function() { + jQuery.timer.add(this, interval, label, fn, times, belay); + }); + }, + oneTime: function(interval, label, fn) { + return this.each(function() { + jQuery.timer.add(this, interval, label, fn, 1); + }); + }, + stopTime: function(label, fn) { + return this.each(function() { + jQuery.timer.remove(this, label, fn); + }); + } + }); + + jQuery.extend({ + timer: { + guid: 1, + global: {}, + regex: /^([0-9]+)\s*(.*s)?$/, + powers: { + // Yeah this is major overkill... + 'ms': 1, + 'cs': 10, + 'ds': 100, + 's': 1000, + 'das': 10000, + 'hs': 100000, + 'ks': 1000000 + }, + timeParse: function(value) { + if (value === undefined || value === null) { + return null; + } + var result = this.regex.exec(jQuery.trim(value.toString())); + if (result[2]) { + var num = parseInt(result[1], 10); + var mult = this.powers[result[2]] || 1; + return num * mult; + } else { + return value; + } + }, + add: function(element, interval, label, fn, times, belay) { + var counter = 0; + + if (jQuery.isFunction(label)) { + if (!times) { + times = fn; + } + fn = label; + label = interval; + } + + interval = jQuery.timer.timeParse(interval); + + if (typeof interval !== 'number' || + isNaN(interval) || + interval <= 0) { + return; + } + if (times && times.constructor !== Number) { + belay = !!times; + times = 0; + } + + times = times || 0; + belay = belay || false; + + if (!element.$timers) { + element.$timers = {}; + } + if (!element.$timers[label]) { + element.$timers[label] = {}; + } + fn.$timerID = fn.$timerID || this.guid++; + + var handler = function() { + if (belay && handler.inProgress) { + return; + } + handler.inProgress = true; + if ((++counter > times && times !== 0) || + fn.call(element, counter) === false) { + jQuery.timer.remove(element, label, fn); + } + handler.inProgress = false; + }; + + handler.$timerID = fn.$timerID; + + if (!element.$timers[label][fn.$timerID]) { + element.$timers[label][fn.$timerID] = window.setInterval(handler, interval); + } + + if (!this.global[label]) { + this.global[label] = []; + } + this.global[label].push(element); + + }, + remove: function(element, label, fn) { + var timers = element.$timers, ret; + + if (timers) { + + if (!label) { + for (var lab in timers) { + if (timers.hasOwnProperty(lab)) { + this.remove(element, lab, fn); + } + } + } else if (timers[label]) { + if (fn) { + if (fn.$timerID) { + window.clearInterval(timers[label][fn.$timerID]); + delete timers[label][fn.$timerID]; + } + } else { + for (var _fn in timers[label]) { + if (timers[label].hasOwnProperty(_fn)) { + window.clearInterval(timers[label][_fn]); + delete timers[label][_fn]; + } + } + } + + for (ret in timers[label]) { + if (timers[label].hasOwnProperty(ret)) { + break; + } + } + if (!ret) { + ret = null; + delete timers[label]; + } + } + + for (ret in timers) { + if (timers.hasOwnProperty(ret)) { + break; + } + } + if (!ret) { + element.$timers = null; + } + } + } + } + }); + if (/(msie) ([\w.]+)/.exec(navigator.userAgent.toLowerCase())) { + $(window).one('unload', function() { + var global = jQuery.timer.global; + for (var label in global) { + if (global.hasOwnProperty(label)) { + var els = global[label], i = els.length; + while (--i) { + jQuery.timer.remove(els[i], label); + } + } + } + }); + } + })(jQuery); + // ----------------------------------------------------------------------- + // :: CROSS BROWSER SPLIT + // ----------------------------------------------------------------------- + /* istanbul ignore next */ + (function(undef) { + + // prevent double include + + if (!String.prototype.split.toString().match(/\[native/)) { + return; + } + + var nativeSplit = String.prototype.split, + compliantExecNpcg = /()??/.exec("")[1] === undef, // NPCG: nonparticipating capturing group + self; + + self = function(str, separator, limit) { + // If `separator` is not a regex, use `nativeSplit` + if (Object.prototype.toString.call(separator) !== "[object RegExp]") { + return nativeSplit.call(str, separator, limit); + } + var output = [], + flags = (separator.ignoreCase ? "i" : "") + + (separator.multiline ? "m" : "") + + (separator.extended ? "x" : "") + // Proposed for ES6 + (separator.sticky ? "y" : ""), // Firefox 3+ + lastLastIndex = 0, + // Make `global` and avoid `lastIndex` issues by working with a copy + separator2, match, lastIndex, lastLength; + separator = new RegExp(separator.source, flags + "g"); + str += ""; // Type-convert + if (!compliantExecNpcg) { + // Doesn't need flags gy, but they don't hurt + separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags); + } + /* Values for `limit`, per the spec: + * If undefined: 4294967295 // Math.pow(2, 32) - 1 + * If 0, Infinity, or NaN: 0 + * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296; + * If negative number: 4294967296 - Math.floor(Math.abs(limit)) + * If other: Type-convert, then use the above rules + */ + // ? Math.pow(2, 32) - 1 : ToUint32(limit) + limit = limit === undef ? -1 >>> 0 : limit >>> 0; + while (match = separator.exec(str)) { + // `separator.lastIndex` is not reliable cross-browser + lastIndex = match.index + match[0].length; + if (lastIndex > lastLastIndex) { + output.push(str.slice(lastLastIndex, match.index)); + // Fix browsers whose `exec` methods don't consistently return `undefined` for + // nonparticipating capturing groups + if (!compliantExecNpcg && match.length > 1) { + match[0].replace(separator2, function() { + for (var i = 1; i < arguments.length - 2; i++) { + if (arguments[i] === undef) { + match[i] = undef; + } + } + }); + } + if (match.length > 1 && match.index < str.length) { + Array.prototype.push.apply(output, match.slice(1)); + } + lastLength = match[0].length; + lastLastIndex = lastIndex; + if (output.length >= limit) { + break; + } + } + if (separator.lastIndex === match.index) { + separator.lastIndex++; // Avoid an infinite loop + } + } + if (lastLastIndex === str.length) { + if (lastLength || !separator.test("")) { + output.push(""); + } + } else { + output.push(str.slice(lastLastIndex)); + } + return output.length > limit ? output.slice(0, limit) : output; + }; + + // For convenience + String.prototype.split = function(separator, limit) { + return self(this, separator, limit); + }; + + return self; + + })(); + // ----------------------------------------------------------------------- + // :: jQuery Caret + // ----------------------------------------------------------------------- + /* istanbul ignore next */ + $.fn.caret = function(pos) { + var target = this[0]; + var isContentEditable = target.contentEditable === 'true'; + //get + if (arguments.length === 0) { + //HTML5 + if (window.getSelection) { + //contenteditable + if (isContentEditable) { + target.focus(); + var range1 = window.getSelection().getRangeAt(0), + range2 = range1.cloneRange(); + range2.selectNodeContents(target); + range2.setEnd(range1.endContainer, range1.endOffset); + return range2.toString().length; + } + //textarea + return target.selectionStart; + } + //IE<9 + if (document.selection) { + target.focus(); + //contenteditable + if (isContentEditable) { + var range1 = document.selection.createRange(), + range2 = document.body.createTextRange(); + range2.moveToElementText(target); + range2.setEndPoint('EndToEnd', range1); + return range2.text.length; + } + //textarea + var pos = 0, + range = target.createTextRange(), + range2 = document.selection.createRange().duplicate(), + bookmark = range2.getBookmark(); + range.moveToBookmark(bookmark); + while (range.moveStart('character', -1) !== 0) pos++; + return pos; + } + //not supported + return 0; + } + //set + if (pos === -1) + pos = this[isContentEditable? 'text' : 'val']().length; + //HTML5 + if (window.getSelection) { + //contenteditable + if (isContentEditable) { + target.focus(); + window.getSelection().collapse(target.firstChild, pos); + } + //textarea + else + target.setSelectionRange(pos, pos); + } + //IE<9 + else if (document.body.createTextRange) { + var range = document.body.createTextRange(); + range.moveToElementText(target); + range.moveStart('character', pos); + range.collapse(true); + range.select(); + } + if (!isContentEditable && !this.is(':focus')) { + target.focus(); + } + return pos; + }; + /* eslint-enable */ + // ----------------------------------------------------------------------- + // :: Cross-browser resize element plugin using sentinel iframe or + // :: resizeObserver + // ----------------------------------------------------------------------- + $.fn.resizer = function(callback) { + var trigger = arguments.length === 0; + var unbind = arguments[0] === "unbind"; + if (!trigger && !unbind && !is_function(callback)) { + throw new Error('Invalid argument, it need to a function or string ' + + '"unbind" or no arguments.'); + } + if (unbind) { + callback = is_function(arguments[1]) ? arguments[1] : null; + } + return this.each(function() { + var $this = $(this); + var iframe; + var callbacks; + function resize_handler() { + callbacks.fire(); + } + if (trigger || unbind) { + callbacks = $this.data('callbacks'); + if (trigger) { + callbacks && callbacks.fire(); + } else { + if (callback && callbacks) { + callbacks.remove(callback); + if (!callbacks.has()) { + callbacks = null; + } + } else { + callbacks = null; + } + if (!callbacks) { + $this.removeData('callbacks'); + if (window.ResizeObserver) { + var observer = $this.data('observer'); + if (observer) { + observer.unobserve(this); + $this.removeData('observer'); + } + } else { + iframe = $this.find('> iframe'); + if (iframe.length) { + // just in case of memory leaks in IE + $(iframe[0].contentWindow).off('resize').remove(); + iframe.remove(); + } else if ($this.is('body')) { + $(window).off('resize.resizer'); + } + } + } + } + } else if ($this.data('callbacks')) { + $(this).data('callbacks').add(callback); + } else { + callbacks = $.Callbacks(); + callbacks.add(callback); + $this.data('callbacks', callbacks); + var resizer; + var first = true; + if (window.ResizeObserver) { + resizer = new ResizeObserver(function() { + if (!first) { + resize_handler(); + } + first = false; + }); + resizer.observe(this); + $this.data('observer', resizer); + } else if ($this.is('body')) { + $(window).on('resize.resizer', resize_handler); + } else { + iframe = $('