-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
24 lines (21 loc) · 672 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { transform } from "./transform.js";
function output(value){
let outputEl = document.getElementById("output");
outputEl.textContent = value;
}
/** @type {HTMLFormElement} */
let formEl = document.getElementById("form");
formEl.onsubmit = function(ev){
ev.preventDefault();
/** @type {HTMLTextAreaElement} */
let textArea = formEl["data"];
let yapiSchema = textArea.value;
try {
output(transform(JSON.parse(yapiSchema)));
navigator.clipboard.writeText(window['output'].innerText);
window['tips'].innerText = "copied ✔";
}catch(e){
output('');
window['tips'].innerText = e.message;
}
};