-
Notifications
You must be signed in to change notification settings - Fork 125
(enhancement) - re-worked the Playground page to use CodeMirror #352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
catull
wants to merge
1
commit into
schibsted:master
Choose a base branch
from
catull:feature/pimp-the-page
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,99 +1,134 @@ | ||
| <style> | ||
| .button { | ||
| background-color: #4CAF50; /* Green */ | ||
| border: none; | ||
| color: white; | ||
| padding: 15px 32px; | ||
| text-align: center; | ||
| text-decoration: none; | ||
| display: inline-block; | ||
| font-size: 16px; | ||
| } | ||
|
|
||
| pre { | ||
| background-color: #E3E3E3; | ||
| font-family: "Lucida Console", Monaco, "Courier New", monospace; | ||
| font-size: 14pt | ||
| } | ||
|
|
||
| #jslt, #input { | ||
| font-family: "Lucida Console", Monaco, "Courier New", monospace; | ||
| font-size: 14pt | ||
| } | ||
|
|
||
| body { | ||
| font-family: "Arial", "Helvetica", sans-serif; | ||
| margin-left: 36pt; | ||
| margin-right: 36pt; | ||
| margin-top: 48pt; | ||
| } | ||
| </style> | ||
| <script> | ||
| function send() { | ||
| var out = document.getElementById('result'); | ||
| out.firstChild.nodeValue = '...wait...'; | ||
|
|
||
| var input = document.getElementById('input').value | ||
| var jslt = document.getElementById('jslt').value | ||
| var data = {"json" : input, "jslt" : jslt } | ||
|
|
||
| var http = new XMLHttpRequest(); | ||
| var url = "jslt-demo"; | ||
| //var url = "http://localhost:9999/jslt"; | ||
| http.open("POST", url, true); | ||
| http.setRequestHeader("Content-type", "application/json"); | ||
|
|
||
| http.onreadystatechange = function() { | ||
| if (http.readyState == 4 && http.status == 200) { | ||
| var out = document.getElementById('result'); | ||
| out.firstChild.nodeValue = http.responseText; | ||
| <!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)); | ||
| } | ||
| } | ||
| http.send(JSON.stringify(data)); | ||
| } | ||
| </script> | ||
| //]]> | ||
| </script> | ||
|
|
||
| <title>JSLT demo playground</title> | ||
| <h1>JSLT demo playground</h1> | ||
| <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> | ||
| <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>Result</h2> | ||
| <h2>Input</h2> | ||
|
|
||
| <pre id="result"> | ||
| <div id='jsonEditor'></div> | ||
|
|
||
| Transform result will appear here | ||
| <h2>JSLT</h2> | ||
|
|
||
| </pre> | ||
| <div id='jsltEditor'></div> | ||
|
|
||
| <p><input type=submit value="Run!" class=button onclick="send()"> | ||
| <p><input id='submit' type='submit' value='Run!' class='button' onclick='send ()'></p> | ||
|
|
||
| <h2>JSLT</h2> | ||
| <h2>Result</h2> | ||
|
|
||
| <textarea id="jslt" name="jslt" cols=80 rows=20> | ||
| let idparts = split(.id, "-") | ||
| let xxx = [for ($idparts) "x" * size(.)] | ||
| <div id='resultEditor'></div> | ||
|
|
||
| { | ||
| "id" : join($xxx, "-"), | ||
| "type" : "Anonymized-View", | ||
| * : . | ||
| } | ||
| </textarea> | ||
| <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'; | ||
|
|
||
| <h2>Input</h2> | ||
| 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 (.)] | ||
|
|
||
| <textarea id="input" name="input" cols=80 rows=20> | ||
| { | ||
| "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/" | ||
| } | ||
| </textarea> | ||
| "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> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Information exposure through a stack trace Medium