From ef8b5af25b3529199d3c6fa172ff4b9d32983f03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciar=C3=A1n=20Eaton?= <86569883+EatonCiaran@users.noreply.github.com> Date: Sat, 10 Jul 2021 14:11:13 +0100 Subject: [PATCH] Tidy up code and improve flexibility --- README.md | 31 ++- demos/index.html | 40 +--- demos/{css => }/main.css | 0 dist/jquery.console.min.css | 1 + dist/jquery.console.min.js | 18 ++ src/jquery.console.css | 25 ++- src/jquery.console.js | 400 ++++++++++++++++++++++-------------- 7 files changed, 323 insertions(+), 192 deletions(-) rename demos/{css => }/main.css (100%) create mode 100644 dist/jquery.console.min.css create mode 100644 dist/jquery.console.min.js diff --git a/README.md b/README.md index 6de3361..5891890 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,10 @@ The jQuery Console plugin allows you to easily create a non-interactive console --- +## Live Demo + +A live demo of this project can be found at https://eatonciaran.github.io/jquery-console/ + ## Usage Initialise the console by attaching it to a `div` tag. `options` is optional. @@ -27,19 +31,36 @@ myConsole.log("message"); ## Options +### defaultLevel +Integer or string. Set the default severity level of messaages. If an integer it needs to be a valid index of the levels +array and if it's a string the value needs to be found in that array. + +### fadeoutTime +Integer to set how long in milliseconds messages take to fadeout when `timeout` is being used. Default: `400`. + ### history -Integer to set how many messages to retain. Default: `10000`. +Integer to set how many messages to retain. Set to `0` to retain everything (Not recommended). Default: `10000`. + +### levels +Array of severity levels. Modifying this is only useful if the number of default severities is insufficient for your CSS needs. +Default `["emergency", "alert", "critical", "error", "warning", "notice", "info", "debug"]` ### msgDirection -String to denote whether messages are appended to the top or bottom. Default: `"down"` +String to denote whether messages are appended to the top or bottom. Default: `"down"`. * `"down"`: append to the bottom * `"up"`: append to the top ### showTimestamp -Boolean flag indicating whether the timestamp the message was logged should be shown. Default: `true` +Boolean to enable displaying of message timestamps. Default: `true`. + +### tagOddEven +Boolean to enable messages being tagged odd or even to allow alternating message styling. Default `false`. ### timeout -Integer to set how long in milliseconds until messages are deleted. Setting to `0` results in no timeout. Default: `0` +Integer to set how long in milliseconds until messages are deleted. Set to `0` for no timeout. Default: `0`. + +### timestampOnLeft +Boolean to control whether timestamp appears on the left or the right of the message. Default: `false`. --- @@ -48,7 +69,7 @@ Integer to set how long in milliseconds until messages are deleted. Setting to ` ### log Logs message to the assigned console. Takes 2 parameters: * `msg`: String representing the message to be logged. Required. -* `level`: Can either be an integer or string representing the desired visual style. Default: `6` +* `level`: Can either be an integer or string representing the desired visual style / severity. Default determined by the option `defaultLevel`. Assuming the option `levels` is default the following values are accepted: | Integer | String | | ------- | ------------- | diff --git a/demos/index.html b/demos/index.html index 836a097..fa9bc81 100644 --- a/demos/index.html +++ b/demos/index.html @@ -4,8 +4,8 @@
- - + +