-
Notifications
You must be signed in to change notification settings - Fork 126
Expand file tree
/
Copy pathlambda.html
More file actions
134 lines (110 loc) · 3.68 KB
/
lambda.html
File metadata and controls
134 lines (110 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<meta http-equiv='X-UA-Compatible' content='ie=edge'>
<title>JSLT demo playground</title>
<style>
.button {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
}
body {
font-family: 'Arial', 'Helvetica', sans-serif;
font-size: 14px;
margin-left: 36pt;
margin-right: 36pt;
margin-top: 48pt;
}
</style>
</head>
<body>
<script type='application/javascript'>
//<![CDATA[
function send() {
window.resultEditorView.docView.dom.innerText = '... wait ...';
const http = new XMLHttpRequest();
const url = 'jslt';
http.open('POST', url, true);
http.setRequestHeader('Content-type', 'application/json');
http.onreadystatechange = function () {
if (http.readyState === 4 && http.status === 200) {
window.resultEditorView.docView.dom.innerText = http.responseText;
}
}
const json = window.jsonEditorView.state.sliceDoc();
const jslt = window.jstlEditorView.state.sliceDoc();
const data = {json, jslt};
http.send(JSON.stringify(data));
}
//]]>
</script>
<h1>JSLT demo playground</h1>
<p>
Here you can play with <a href='https://github.com/schibsted/jslt'>JSLT</a> transforms.
Please <a href='https://github.com/schibsted/jslt/issues'>report any issues</a>.
</p>
<h2>Input</h2>
<div id='jsonEditor'></div>
<h2>JSLT</h2>
<div id='jsltEditor'></div>
<p><input id='submit' type='submit' value='Run!' class='button' onclick='send ()'></p>
<h2>Result</h2>
<div id='resultEditor'></div>
<script type="importmap">
{
"imports": {
"@codemirror/": "https://deno.land/x/codemirror_esm@v6.0.1/esm/"
}
}
</script>
<script async="" type='module'>
//<![CDATA[
import {
basicSetup,
EditorView,
} from '@codemirror/codemirror/dist/index.js';
import { javascript } from '@codemirror/lang-javascript/dist/index.js';
import { json } from '@codemirror/lang-json/dist/index.js';
import { oneDark } from '@codemirror/theme-one-dark/dist/index.js';
window.jsonEditor = document.getElementById('jsonEditor');
window.jstlEditor = document.getElementById('jsltEditor');
window.resultEditor = document.getElementById('resultEditor');
window.jsonEditorView = new EditorView({
doc: JSON.stringify({
schema: 'http://schemas.schibsted.io/thing/pulse-simple.json#1.json',
id: 'w23q7ca1-8729-24923-922b-1c0517ddffjf1',
published: '2017-05-04T09:13:29+02:00',
type: 'View',
environmentId: 'urn:schibsted.com:environment:uuid',
url: 'http://www.aftenposten.no/'
}, undefined, ' '),
extensions: [basicSetup, json(), oneDark],
parent: window.jsonEditor,
});
window.jstlEditorView = new EditorView({
doc: `let idparts = split (.id, "-")
let xxx = [for ($idparts) "x" * size (.)]
{
"id" : join ($xxx, "-"),
"type" : "Anonymized-View",
* : .
}`,
extensions: [basicSetup, javascript(), oneDark],
parent: window.jstlEditor,
});
window.resultEditorView = new EditorView({
doc: 'Transform result will appear here',
extensions: [basicSetup, json(), oneDark],
parent: window.resultEditor,
});
//]]>
</script>
</body>
</html>