Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: transpilation error for browser
- Loading branch information
Showing
7 changed files
with
154 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<html> | ||
<head> | ||
<title>Example</title> | ||
<script data-main="./es5" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" defer="" async=""></script> | ||
<link rel="stylesheet" href="./styles.css" /> | ||
</head> | ||
<body> | ||
<div id="c"> | ||
<div> | ||
<div class="i"> | ||
<label for="sch">Schematron URL</label> | ||
<input id="sch" value="https://raw.githubusercontent.com/OpenPEPPOL/peppol-bis-invoice-3/master/rules/examples/Allowance-example.xml" /> | ||
</div> | ||
<div class="i"> | ||
<label for="xml">XML URL</label> | ||
<input id="xml" value="https://raw.githubusercontent.com/OpenPEPPOL/peppol-bis-invoice-3/master/rules/sch/CEN-EN16931-UBL.sch" /> | ||
</div> | ||
<div> | ||
<button id="btn" disabled="disabled">Run validation</button> | ||
<span id="status">Loading...</span> | ||
</div> | ||
</div> | ||
<hr /> | ||
<table id="table"> | ||
<thead> | ||
<tr><th>Lvl</th><th>Assertion</th><th>Description</th></tr> | ||
</thead> | ||
<tbody id="results"></tbody> | ||
</table> | ||
</div> | ||
</body> | ||
</html> |
This file contains 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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
requirejs.config({}); | ||
|
||
function createTr(data) { | ||
var r = document.createElement("tr"); | ||
for (var i = 0; i < data.length; i++) { | ||
var e = document.createElement("td"); | ||
e.textContent = data[i] || ""; | ||
r.appendChild(e); | ||
} | ||
return r; | ||
} | ||
|
||
requirejs(['../../build/schematron-browser'], function (shematron) { | ||
/** @type {HTMLButtonElement} */ | ||
var btn = document.getElementById("btn"); | ||
/** @type {HTMLDivElement} */ | ||
var status = document.getElementById("status"); | ||
/** @type {HTMLInputElement} */ | ||
var sch = document.getElementById("sch"); | ||
/** @type {HTMLInputElement} */ | ||
var xml = document.getElementById("xml"); | ||
/** @type {HTMLTableSectionElement} */ | ||
var results = document.getElementById("results"); | ||
|
||
/** @type {import("../../esm/browser").validate} */ | ||
var validate = schematron.validate; | ||
|
||
btn.onclick = function () { | ||
btn.disabled = true; | ||
status.textContent = "Running validation..."; | ||
while (results.hasChildNodes()) { | ||
results.removeChild(results.lastChild); | ||
} | ||
|
||
/** @type {import("../../esm/browser").IValidateOptions} */ | ||
const options = { | ||
resourceDir: window.location.href | ||
}; | ||
|
||
validate(xml.value, sch.value, options).then(function (r) { | ||
r.errors.forEach(function (e) { | ||
var d = ["🔴", e.assertionId, e.description]; | ||
results.appendChild(createTr(d)); | ||
}); | ||
r.ignored.forEach(function (e) { | ||
var d = ["⚠", e.assertionId, e.errorMessage]; | ||
results.appendChild(createTr(d)); | ||
}); | ||
r.warnings.forEach(function (e) { | ||
var d = ["🔸", e.assertionId, e.description]; | ||
results.appendChild(createTr(d)); | ||
}); | ||
r.passed.forEach(function (e) { | ||
var d = ["✓", e.assertionId, e.description]; | ||
results.appendChild(createTr(d)); | ||
}); | ||
|
||
status.textContent = ""; | ||
}).catch(function (e) { | ||
console.error(e); | ||
status.textContent = e.toString(); | ||
}).then(function () { | ||
btn.disabled = false; | ||
}); | ||
}; | ||
|
||
status.textContent = ""; | ||
btn.disabled = false; | ||
}); |
This file contains 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
:root, html { | ||
margin: 0; | ||
padding: 0; | ||
background: #ccc; | ||
} | ||
|
||
body { | ||
max-width: 720px; | ||
margin: 0 auto; | ||
padding: 8px; | ||
background: #efefef; | ||
} | ||
|
||
#c { | ||
position: relative; | ||
} | ||
|
||
tr.warn { | ||
color: rgb(120, 85, 0); | ||
} | ||
tr.error { | ||
color: rgb(90, 0, 0); | ||
} | ||
tr.passed { | ||
color: rgb(0, 90, 0); | ||
} | ||
|
||
.i { | ||
position: relative; | ||
margin: 12px 0; | ||
} | ||
.i > input { | ||
display: block; | ||
width: 100%; | ||
} | ||
.i > input:focus { | ||
outline: #009 thin; | ||
border-color: #009; | ||
} | ||
.i > label { | ||
display: block; | ||
width: auto; | ||
} |