From: John-Anthony Elenis Date: Wed, 21 Aug 2019 17:33:16 +0000 (-0400) Subject: added color to debug console X-Git-Tag: v1.0~64 X-Git-Url: http://git.osdn.net/view?p=alterlinux%2Flightdm-webkit2-theme-alter.git;a=commitdiff_plain;h=afc9162221f5e5b7fdd594c1e105b915e657622f added color to debug console --- diff --git a/index.html b/index.html index 2e7ad04..dc5fc40 100644 --- a/index.html +++ b/index.html @@ -50,13 +50,19 @@ position: absolute; top: 4px; } - #console textarea { + div#console .terminal { overflow-y: scroll; background-color: rgba(0,0,0,0.8); - font-size: 16pt; + font-size: 14pt; color: white; height: 30vh; width: 85vw; + resize: both; + } + div#console .terminal text { + display: block; + padding: 0; + margin: 0; } @@ -69,7 +75,7 @@ - +
@@ -81,11 +87,10 @@
- +
- -
+
diff --git a/js/theme.js b/js/theme.js index c758cc4..dd0cb2c 100644 --- a/js/theme.js +++ b/js/theme.js @@ -53,21 +53,35 @@ window.onerror = function() { var $log; var $autoscroll; $(document).ready(()=> { - $log = $("#console textarea"); + $log = $("#console .terminal"); $autoscroll = $("#console input"); }); var log = { + _parse(str, color) { + if (typeof str == "object") str = JSON.stringify(str,null, 2); + str = "[" + moment().format("hh:mm:ss") + "]: " + str; + str = "" + str + ""; + return $log.html() + str; + }, + normal (str) { + $log.html(this._parse(str,"white")); + if ($autoscroll.prop('checked')) + $log[0].scrollTop = $log[0].scrollHeight; + }, error (str) { - if (typeof str == "object") str = JSON.stringify(str,null, 2); - $log.val($log.val() + str + "\n"); + $log.html(this._parse(str,"red")); if ($autoscroll.prop('checked')) - $log[0].scrollTop = $log[0].scrollHeight; + $log[0].scrollTop = $log[0].scrollHeight; }, - warn () { - + warn (str) { + $log.html(this._parse(str,"yellow")); + if ($autoscroll.prop('checked')) + $log[0].scrollTop = $log[0].scrollHeight; }, - debug () { - + debug (str) { + $log.html(this._parse(str,"lightblue")); + if ($autoscroll.prop('checked')) + $log[0].scrollTop = $log[0].scrollHeight; } }