Titeiiko commited on
Commit
ab4f1d8
·
1 Parent(s): 14131be

Create index.html

Browse files
Files changed (1) hide show
  1. index.html +255 -0
index.html ADDED
@@ -0,0 +1,255 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>GJSON Playground</title>
5
+ <meta charset="utf-8"/>
6
+ <!-- <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/hack-font@3/build/web/hack.css">
7
+ -->
8
+ <style>
9
+ * {
10
+ /* box-sizing: content-box; */
11
+ box-sizing: border-box;
12
+ }
13
+ html, body {
14
+ width: 100%;
15
+ height: 100%;
16
+ margin: 0;
17
+ padding: 0;
18
+ background-color: #a7b2bb;
19
+ color: rgba(39,40,34,0.80);
20
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
21
+ font-size: 17px;
22
+ }
23
+ .contents {
24
+ width: 90%;
25
+ margin: 0 auto;
26
+ }
27
+ #path {
28
+ display: block;
29
+ width: 100%;
30
+ max-width: 1000px;
31
+ border-radius: 15px;
32
+ background-color: #272822;
33
+ border: 0;
34
+ color: #dfdfde;
35
+ line-height: 50px;
36
+ padding: 0 25px;
37
+ font-size: 15px;
38
+ font-family: Hack, monospace;
39
+ outline: none;
40
+ box-shadow: 0px 15px 15px rgba(0,0,0,0.3);
41
+ margin: 10px auto;
42
+ }
43
+ #input, #output {
44
+ display: block;
45
+ width: 100%;
46
+ max-width: 1000px;
47
+ border-radius: 15px;
48
+ background-color: #272822;
49
+ border: 0;
50
+ padding: 25px;
51
+ color: #dfdfde;
52
+ font-size: 15px;
53
+ font-family: Hack, monospace;
54
+ outline: none;
55
+ box-shadow: 0px 15px 15px rgba(0,0,0,0.3);
56
+ resize: vertical;
57
+ margin: 10px auto;
58
+ word-wrap:unset;
59
+ }
60
+
61
+ #input {
62
+ height: 300px;
63
+ }
64
+ #output {
65
+ height: 150px;
66
+ }
67
+ .top {
68
+ display: block;
69
+ margin: 40px auto 40px auto;
70
+ text-align: center;
71
+ }
72
+ .top .logo {
73
+ position: relative;
74
+ left: -2px;
75
+ display: block;
76
+ margin: 0 auto 5px auto;
77
+ }
78
+ .top .sub {
79
+ color: #272822;
80
+ font-size: 32px;
81
+ font-weight: 900;
82
+ margin: 0 auto 0 auto;
83
+ }
84
+ .bottom {
85
+ display: block;
86
+ max-width: 800px;
87
+ margin: 40px auto 40px auto;
88
+ }
89
+ .bottom pre{
90
+ background: rgba(0,0,0,0.10);
91
+ padding: 20px;
92
+ border-radius: 6px;
93
+ font-family: Hack, monospace;
94
+ font-size: 15px;
95
+ }
96
+ .bottom p{
97
+ text-align: center;
98
+ }
99
+ .bottom h2, .bottom h3{
100
+ text-align: center;
101
+ color: #272822;
102
+ }
103
+ .octocat {
104
+ margin-top: 20px;
105
+ opacity: 0.82;
106
+ }
107
+ .example {
108
+ overflow: auto;
109
+ }
110
+ a {
111
+ color: black
112
+ }
113
+ </style>
114
+ </head>
115
+ <body>
116
+ <div class="contents">
117
+ <div class="top">
118
+ <img src="logo.png" height="60" class="logo">
119
+ <div class="sub">PLAYGROUND</div>
120
+ <p>Otis an Anti-Spam AI Model</p>
121
+ </div>
122
+ <div><input type="text" value="name.last" id="path"
123
+ data-gramm_editor="false" spellcheck="false" autocomplete="off"></div>
124
+ <div>
125
+ <textarea id="output" readonly
126
+ data-gramm_editor="false" spellcheck="false" autocomplete="off"
127
+ ></textarea>
128
+ </div>
129
+
130
+ <div class="bottom">
131
+ <h3>EXAMPLES</h3>
132
+ <pre class="example">
133
+ name.last >> "Anderson"
134
+ age >> 37
135
+ children >> ["Sara","Alex","Jack"]
136
+ children.# >> 3
137
+ children.1 >> "Alex"
138
+ child*.2 >> "Jack"
139
+ c?ildren.0 >> "Sara"
140
+ fav\.movie >> "Deer Hunter"
141
+ friends.#.first >> ["Dale","Roger","Jane"]
142
+ friends.1.last >> "Craig"</pre>
143
+
144
+
145
+ <p>
146
+ Query an array for the first match by using #(...),
147
+ or find all matches with #(...)#.
148
+ Queries support the ==, !=, <, <=, >, >= comparison operators and
149
+ the simple pattern matching % operator.
150
+ </p>
151
+
152
+ <pre class="example">
153
+ friends.#(last=="Murphy").first >> "Dale"
154
+ friends.#(last=="Murphy")#.first >> ["Dale","Jane"]
155
+ friends.#(age>45)#.last >> ["Craig","Murphy"]
156
+ friends.#(first%"D*").last >> "Murphy"
157
+ friends.#(nets.#(=="fb"))#.first >> ["Dale","Roger"]</pre>
158
+
159
+ <p>
160
+
161
+ </p>
162
+
163
+ <p>
164
+ Use the selectors syntax to join multiple paths into a new JSON document.
165
+ </p>
166
+
167
+ <pre class="example">
168
+ {name.first,age,"murphys":friends.#(last="Murphy")#.first}
169
+ [name.first,age,children.0]</pre>
170
+
171
+ <p>
172
+ Use modifiers to modify the json. There are currently the following built-in modifiers:
173
+ <ul>
174
+ <li><b>@reverse</b>: Reverse an array or the members of an object.</li>
175
+ <li><b>@ugly</b>: Remove all whitespace from JSON.</li>
176
+ <li><b>@pretty</b>: Make the JSON more human readable.</li>
177
+ <li><b>@this</b>: Returns the current element. It can be used to retrieve the root element.</li>
178
+ <li><b>@valid</b>: Ensure the json document is valid.</li>
179
+ <li><b>@flatten</b>: Flattens an array.</li>
180
+ <li><b>@join</b>: Joins multiple objects into a single object.</li>
181
+ <li><b>@keys</b>: Returns an array of keys for an object.</li>
182
+ <li><b>@values</b>: Returns an array of values for an object.</li>
183
+ </ul>
184
+ </p>
185
+
186
+ <pre class="example">
187
+ children.@reverse >> ["Jack","Alex","Sara"]
188
+ [email protected] >> "Jack"
189
+ {name.first,"murphys":friends.0}.@pretty >> <i>beautiful JSON</i>
190
+ {name.first,"murphys":friends.0}.@ugly >> <i>compact JSON</i>
191
+ [@this].#(age>35).name.last >> "Anderson"</pre>
192
+
193
+ <p>
194
+ For more information, please see the <a href="https://github.com/tidwall/gjson">GJSON project</a>
195
+ and the <a href="https://github.com/tidwall/gjson/blob/master/SYNTAX.md">GJSON syntax</a>.
196
+ </p>
197
+ <p>
198
+ <br>
199
+ <br>
200
+ This page is open source at
201
+ <a href="https://github.com/tidwall/gjson-play">tidwall/gjson-play</a>.
202
+ <br>
203
+ <a href="https://github.com/tidwall/gjson"><img class="octocat"
204
+ src="octocat.png" height="40" border="0"></a>
205
+ </p>
206
+
207
+ </div>
208
+ </div>
209
+
210
+ <script>
211
+ document.addEventListener('DOMContentLoaded', () => {
212
+ var prev_path = null;
213
+
214
+ window.setInterval(function() {
215
+ var path = document.getElementById("path").value.trim();
216
+ if (path == "") {
217
+
218
+ } else if (path != prev_path) {
219
+ analyzeContent(path)
220
+ .then(function(output) {
221
+ document.getElementById("output").value = output;
222
+ prev_path = path;
223
+ })
224
+ .catch(function(error) {
225
+ console.error(error);
226
+ });
227
+ }
228
+ }, 200);
229
+ });
230
+
231
+ function analyzeContent(content) {
232
+ return new Promise(function(resolve, reject) {
233
+ const endpoint = `/${content}`;
234
+
235
+ fetch(endpoint)
236
+ .then(function(response) {
237
+ if (response.ok) {
238
+ return response.text();
239
+ } else {
240
+ throw new Error('Failed to fetch data');
241
+ }
242
+ })
243
+ .then(function(data) {
244
+ resolve(data);
245
+ })
246
+ .catch(function(error) {
247
+ reject(error);
248
+ });
249
+ });
250
+ }
251
+
252
+ </script>
253
+
254
+ </body>
255
+ </html>