From eaf01588e6d60f5b428957204b43b0cad8266ab9 Mon Sep 17 00:00:00 2001 From: Dave Elsensohn Date: Fri, 1 Jun 2018 17:02:13 -0700 Subject: [PATCH] Adjusted hex validation, added formatting upon form save. --- www/main.css | 2 ++ www/main.js | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/www/main.css b/www/main.css index 5018cc8..84b1fdd 100644 --- a/www/main.css +++ b/www/main.css @@ -2,6 +2,8 @@ body { font-family: sans-serif; color: white; background-color: black; + margin: 0; + padding: 0; } .page { diff --git a/www/main.js b/www/main.js index 2ae3cd7..8b18306 100644 --- a/www/main.js +++ b/www/main.js @@ -69,8 +69,8 @@ function validateEndpoint(endpoint) { * @return {boolean} */ function isHex(hex) { - const a = parseInt(hex, 16); - return (a.toString(16) === hex); + const re = /[0-9A-Fa-f]{6}/g; + return re.test(hex); } /** @@ -215,13 +215,13 @@ function handleAddRule(evt) { ruleDiv.classList.add('rule'); let fieldTotal = '
'; - fieldTotal += ''; + fieldTotal += ''; fieldTotal += ''; fieldTotal += '
'; let fieldHex = '
'; fieldHex += ''; - fieldHex += ''; + fieldHex += ''; fieldHex += '
'; // let remove = 'X'; @@ -271,6 +271,7 @@ function storeRules(evt) { // Sort the rules in order and store rulesArr.sort(compareValues('num')); localStorage.setItem('rules', JSON.stringify(rulesArr)); + formatMetric(metric.innerText); ruleForm.classList.remove('active'); }