@muze-nl/simplystore 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/www/index.html~ DELETED
@@ -1,136 +0,0 @@
1
- <!doctype html>
2
- <meta charset="utf-8">
3
- <style>
4
- #databrowser {
5
- border: 0;
6
- margin: 0;
7
- padding: 0;
8
- width: 50%;
9
- height: 80vh;
10
- }
11
- form.Query {
12
- width: 49%;
13
- float: left;
14
- height: 80vh;
15
- }
16
- form.Query .QueryFoot {
17
- position: absolute;
18
- margin-top: 0.5em;
19
- }
20
- .CodeMirror {
21
- height: 100% !important;
22
- }
23
- .dataBrowser {
24
- height: 80vh;
25
- }
26
- </style>
27
- <h1>JSONTag browser</h1>
28
- <form data-simply-command="query" class="Query">
29
- <textarea name="query" id="codeEditor" class="CodeMirror"></textarea>
30
- <div class="QueryFoot">
31
- <button type="submit">Run Query</button>
32
- </div>
33
- </form>
34
- <div class="dataBrowser">
35
- <textarea id="databrowser" class="CodeMirror" data-simply-field="data"></textarea>
36
- </div>
37
-
38
- <script src="/codemirror/lib/codemirror.js"></script>
39
- <link rel="stylesheet" href="/codemirror/lib/codemirror.css">
40
- <script src="/codemirror/mode/javascript/javascript.js"></script>
41
- <link rel="stylesheet" href="/codemirror/theme/material-ocean.css">
42
- <script src="https://unpkg.com/@muze-nl/jsontag@0.7.0/dist/browser.js"></script>
43
- <script src="https://cdn.simplyedit.io/1/simply-edit.js"></script>
44
- <script src="https://unpkg.com/simplyview@2.0.2/dist/simply.everything.js"></script>
45
- <script>
46
- var codeEditor = CodeMirror.fromTextArea(document.getElementById('codeEditor'), {
47
- lineNumbers: true,
48
- styleActiveLine: true,
49
- matchBrackets: true,
50
- theme: 'material-ocean'
51
- })
52
- codeEditor.focus()
53
- var browser = CodeMirror.fromTextArea(document.getElementById('databrowser'), {
54
- theme: 'material-ocean',
55
- readOnly: true
56
- })
57
- </script>
58
- <script>
59
- const databrowser = simply.app({
60
- routes: {
61
- '/:*': (params) => {
62
- api.get(window.location.pathname).then(data => {
63
- databrowser.view.data = JSONTag.stringify(data, null, 4)
64
- browser.setValue(databrowser.view.data)
65
- })
66
- .catch(err => {
67
- databrowser.view.data = JSONTag.stringify(err, null, 4)
68
- browser.setValue(databrowser.view.data)
69
- })
70
- }
71
- },
72
- commands: {
73
- query: async function(form, values) {
74
- api.post(window.location.pathname, values.query).then(data => {
75
- databrowser.view.data = JSONTag.stringify(data, null, 4)
76
- browser.setValue(databrowser.view.data)
77
- })
78
- .catch(err => {
79
- databrowser.view.data = JSONTag.stringify(err, null, 4)
80
- browser.setValue(databrowser.view.data)
81
- })
82
- }
83
- }
84
- })
85
-
86
- const apiBase = window.location.protocol+'//'+window.location.host;
87
- const api = {
88
- get: function(path, params) {
89
- let url = apiBase+path;
90
- if (!params && window.location.search) {
91
- url += window.location.search
92
- }
93
- if (params) {
94
- var args = Object.keys(params).map(param => encodeURIComponent(param)+'='+encodeURIComponent(params[param])).join('&')
95
- url += '?' + args
96
- }
97
- return fetch(url, {
98
- headers: {
99
- 'Accept': 'application/jsontag'
100
- }
101
- })
102
- .then(response => {
103
- let jsontag = response.text().then(JSONTag.parse)
104
- if (response.ok) {
105
- return jsontag
106
- }
107
- return jsontag.then(Promise.reject.bind(Promise))
108
- })
109
- },
110
- post: function(path, query, params) {
111
- let url = apiBase+path;
112
- if (!params && window.location.search) {
113
- url += window.location.search
114
- }
115
- if (params) {
116
- var args = Object.keys(params).map(param => encodeURIComponent(param)+'='+encodeURIComponent(params[param])).join('&')
117
- url += '?' + args
118
- }
119
-
120
- return fetch(url, {
121
- method: 'POST',
122
- headers: {
123
- 'Accept': 'application/jsontag'
124
- },
125
- body: query
126
- })
127
- .then(response => {
128
- let jsontag = response.text().then(JSONTag.parse)
129
- if (response.ok) {
130
- return jsontag
131
- }
132
- return jsontag.then(Promise.reject.bind(Promise))
133
- })
134
- }
135
- }
136
- </script>
package/www/test.html DELETED
@@ -1,30 +0,0 @@
1
- <doctype html>
2
- <script src="https://unpkg.com/@discoveryjs/json-ext@0.5.7/dist/json-ext.js"></script>
3
- <script
4
- src="https://cdn.jsdelivr.net/gh/poef/jsontag@main/dist/browser.js"></script>
5
- <body>
6
- test
7
- <script>
8
- JSON = JSONTag
9
- var url = "//localhost:3000/curriculum.jsontag";
10
- async function loadData() {
11
- const response = await fetch(url)
12
- const reader = response.body.getReader()
13
-
14
- return jsonExt.parseChunked(async function*() {
15
- while (true) {
16
- const {done, value} = await reader.read()
17
- if (done) {
18
- break
19
- }
20
- yield value
21
- }
22
- })
23
- }
24
-
25
- var all;
26
- loadData().then(data => {
27
- all = data;
28
- console.log('done');
29
- })
30
- </script>