From c1ab07f3421328894bb2fe33df5817514e05a16d Mon Sep 17 00:00:00 2001 From: Tyler Perkins Date: Fri, 25 Nov 2022 23:29:34 -0500 Subject: [PATCH] Add json prettieir --- src/common/common.css | 26 +++++++++++++++++++++++++ src/utilities/base64.css | 13 ------------- src/utilities/index.css | 2 -- src/utilities/index.php | 14 ++++++++++++-- src/utilities/json.css | 41 ++++++++++++++++++++++++++++++++++++++++ src/utilities/json.js | 28 +++++++++++++++++++++++++++ src/utilities/json.php | 30 +++++++++++++++++++++++++++++ 7 files changed, 137 insertions(+), 17 deletions(-) create mode 100644 src/utilities/json.css create mode 100644 src/utilities/json.js create mode 100644 src/utilities/json.php diff --git a/src/common/common.css b/src/common/common.css index 5de3fcb..3934b93 100644 --- a/src/common/common.css +++ b/src/common/common.css @@ -37,6 +37,32 @@ button:hover { } +.common-title { + width: 100vw; + height: 20vh; + + display: grid; + align-content: center; + justify-content: center; + justify-items: center; + align-items: center; + + margin-top: 25px; +} + +textarea { + max-height: 20em; + + vertical-align: center; + background: rgba(11,11,12,1); + border-color: white; + border-style: dashed; + color: white; + max-width: 100%; + + margin: 0px; +} + html { scroll-behavior: smooth; } diff --git a/src/utilities/base64.css b/src/utilities/base64.css index 0dd26bf..375bdd4 100644 --- a/src/utilities/base64.css +++ b/src/utilities/base64.css @@ -23,19 +23,6 @@ padding: 10px; } -textarea { - max-height: 20em; - - vertical-align: center; - background: rgba(11,11,12,1); - border-color: white; - border-style: dashed; - color: white; - max-width: 100%; - - margin: 0px; -} - #output { margin-top: -17vh; } diff --git a/src/utilities/index.css b/src/utilities/index.css index 667d6d2..2caafd8 100644 --- a/src/utilities/index.css +++ b/src/utilities/index.css @@ -40,8 +40,6 @@ } .fill-div:hover { - #background: rgba(44,44,48,0.5); - #background: rgba(22,22,24,1); background: rgba(0,0,0,1); text-decoration: underline 0.1em rgba(255,255,255,1); diff --git a/src/utilities/index.php b/src/utilities/index.php index a6fef4b..d40335e 100644 --- a/src/utilities/index.php +++ b/src/utilities/index.php @@ -15,7 +15,7 @@
-
+

Dipole Calculator

Utility to help you tune a dipole given a target frequency

@@ -25,7 +25,7 @@
- diff --git a/src/utilities/json.css b/src/utilities/json.css new file mode 100644 index 0000000..205982e --- /dev/null +++ b/src/utilities/json.css @@ -0,0 +1,41 @@ +.json-title{ + width: 100vw; + height: 20vh; + + display: grid; + align-content: center; + justify-content: center; + justify-items: center; + align-items: center; + + margin-top: 25px; +} + +.json-body { + width: 90vw; + min-height: 80vh; + background: rgba(11,11,12,0.3); + margin: 0px 5vw ; + + display: grid; + grid-template-columns: 1fr; + grid-template-rows: 1fr 1fr 1fr; + padding: 10px; + +} + +.json-buttons { + display: inline; + text-align: center; + margin-top: 15px; +} + +#output { + margin-top: -17vh; + max-height: 45em; +} + + +body { + overflow-x: hidden; +} diff --git a/src/utilities/json.js b/src/utilities/json.js new file mode 100644 index 0000000..00821c2 --- /dev/null +++ b/src/utilities/json.js @@ -0,0 +1,28 @@ +$(function(ready){ + $('#input').change(function() { + let input = $('#input').val(); + localStorage.setItem('json', input); + }); + $('#pretty').click(function() { + let input = $('#input').val(); + let encoded = ""; + try { + let parsed = JSON.parse(input); + encoded = JSON.stringify(parsed, null, 4); + } catch(error) { + console.log(error); + encoded = error; + } + + $('#output').val(encoded); + }); +}) + +$(document).ready(function() { + let last_input = localStorage.getItem('json'); + if(last_input != null) { + $('#input').val(last_input); + } + $('#input').change(); +}); + diff --git a/src/utilities/json.php b/src/utilities/json.php new file mode 100644 index 0000000..876012a --- /dev/null +++ b/src/utilities/json.php @@ -0,0 +1,30 @@ + + + + + Tyler Perkins - JSON + + + + + + +
+

Json Beautifier

+ +
+ +
+ +
+ +
+ +
+ + + + + + +