11cb0ef41Sopenharmony_ci<!DOCTYPE html>
21cb0ef41Sopenharmony_ci<html>
31cb0ef41Sopenharmony_ci<head>
41cb0ef41Sopenharmony_ci<title>WebIDL 2 Checker</title>
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ci<script src='../lib/webidl2.js'></script>
71cb0ef41Sopenharmony_ci<script>
81cb0ef41Sopenharmony_cilet parserResult = undefined;
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_cifunction formatParserOutput() {
111cb0ef41Sopenharmony_ci  const outputEl = document.getElementById('webidl-checker-output');
121cb0ef41Sopenharmony_ci  if (parserResult) {
131cb0ef41Sopenharmony_ci    const prettyPrintEl = document.getElementById('pretty-print');
141cb0ef41Sopenharmony_ci    outputEl.innerText = JSON.stringify(parserResult, null, prettyPrintEl.checked ? 2 : null);
151cb0ef41Sopenharmony_ci  } else {
161cb0ef41Sopenharmony_ci    outputEl.innerText = '';
171cb0ef41Sopenharmony_ci  }
181cb0ef41Sopenharmony_ci}
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_cifunction checkWebIDL(textToCheck) {
211cb0ef41Sopenharmony_ci  const validation = document.getElementById('webidl-checker-validation');
221cb0ef41Sopenharmony_ci  parserResult = null;
231cb0ef41Sopenharmony_ci  try {
241cb0ef41Sopenharmony_ci    parserResult = WebIDL2.parse(textToCheck);
251cb0ef41Sopenharmony_ci    validation.innerText = 'WebIDL parsed successfully!';
261cb0ef41Sopenharmony_ci  } catch (e) {
271cb0ef41Sopenharmony_ci    validation.innerText = 'Exception while parsing WebIDL. See JavaScript console for more details.\n\n' + e.toString();
281cb0ef41Sopenharmony_ci    // Pass it along to the JavaScript console.
291cb0ef41Sopenharmony_ci    throw e;
301cb0ef41Sopenharmony_ci  } finally {
311cb0ef41Sopenharmony_ci    formatParserOutput();
321cb0ef41Sopenharmony_ci  }
331cb0ef41Sopenharmony_ci}
341cb0ef41Sopenharmony_ci</script>
351cb0ef41Sopenharmony_ci<style>
361cb0ef41Sopenharmony_citextarea {
371cb0ef41Sopenharmony_ci  font-family: monospace;
381cb0ef41Sopenharmony_ci}
391cb0ef41Sopenharmony_ci</style>
401cb0ef41Sopenharmony_ci</head>
411cb0ef41Sopenharmony_ci<body>
421cb0ef41Sopenharmony_ci<h2>WebIDL Checker</h2>
431cb0ef41Sopenharmony_ci<p>This is an online checker for WebIDL built on the <a href="https://github.com/w3c/webidl2.js">webidl2.js</a> project.</p>
441cb0ef41Sopenharmony_ci<p>Enter your WebIDL to check below:</p>
451cb0ef41Sopenharmony_ci<textarea id='webidl-to-check' rows='20' cols='80'></textarea>
461cb0ef41Sopenharmony_ci<br>
471cb0ef41Sopenharmony_ci<input type='button' value='Check WebIDL' onclick='checkWebIDL(document.getElementById("webidl-to-check").value)'>
481cb0ef41Sopenharmony_ci<p>Validation results:</p>
491cb0ef41Sopenharmony_ci<textarea id='webidl-checker-validation' rows='20' cols='80'></textarea>
501cb0ef41Sopenharmony_ci<p>Parser output:</p>
511cb0ef41Sopenharmony_ci<textarea id='webidl-checker-output' rows='20' cols='80'></textarea>
521cb0ef41Sopenharmony_ci<br>
531cb0ef41Sopenharmony_ci<input type='checkbox' id='pretty-print' checked='true' onchange='formatParserOutput()'>Pretty Print
541cb0ef41Sopenharmony_ci</body>
551cb0ef41Sopenharmony_ci</html>
56