Author:
Hash:
Timestamp:
+21 -17 +/-1 browse
Kevin Schoon [me@kevinschoon.com]
d8eb192e2b1df0e91a93dbc3b71826d2061e6bad
Sun, 07 Dec 2025 14:00:50 +0000 (15 hours ago)
| 1 | diff --git a/static/verifier.js b/static/verifier.js |
| 2 | index 3994637..0e2429d 100644 |
| 3 | --- a/static/verifier.js |
| 4 | +++ b/static/verifier.js |
| 5 | @@ -7,11 +7,11 @@ const Kind = { |
| 6 | function newRecorder() { |
| 7 | const Recorder = { |
| 8 | state: [], |
| 9 | - ok(kind) { |
| 10 | - this.state.push([kind]) |
| 11 | + ok(kind, object) { |
| 12 | + this.state.push({ "kind": kind, "object": object, "error": null }) |
| 13 | }, |
| 14 | - error(kind, message, object) { |
| 15 | - this.state.push([kind, message, object]) |
| 16 | + error(kind, object, message) { |
| 17 | + this.state.push({ "kind": kind, "object": object, "error": message }) |
| 18 | } |
| 19 | }; |
| 20 | return Recorder |
| 21 | @@ -40,28 +40,28 @@ function validateLink(object, recorder, constraints = []) { |
| 22 | let constraint = constraints[i]; |
| 23 | if (constraint.kind == Kind.HREF) { |
| 24 | if (!('href' in object)) { |
| 25 | - recorder.error(Kind.HREF, "href not in link", object) |
| 26 | + recorder.error(Kind.HREF, object, "href not in link",) |
| 27 | continue; |
| 28 | } |
| 29 | - recorder.ok(Kind.HREF); |
| 30 | + recorder.ok(Kind.HREF, object); |
| 31 | if ('check' in constraint) { |
| 32 | constraint.check(object["properties"], recorder); |
| 33 | }; |
| 34 | } else if (constraint.kind == Kind.PROPERTIES) { |
| 35 | if (!('properties' in object)) { |
| 36 | - recorder.error(Kind.PROPERTIES, "properties not present in link", object); |
| 37 | + recorder.error(Kind.PROPERTIES, object, "properties not present in link"); |
| 38 | continue; |
| 39 | }; |
| 40 | - recorder.ok(Kind.PROPERTIES); |
| 41 | + recorder.ok(Kind.PROPERTIES, object); |
| 42 | if ('check' in constraint) { |
| 43 | constraint.check(object["properties"], recorder); |
| 44 | }; |
| 45 | } else if (constraint.kind == Kind.TITLES) { |
| 46 | if (!('titles' in object)) { |
| 47 | - recorder.error(Kind.TITLES, "titles not present in object", object); |
| 48 | + recorder.error(Kind.TITLES, object, "titles not present in object"); |
| 49 | continue; |
| 50 | }; |
| 51 | - recorder.ok(Kind.TITLES); |
| 52 | + recorder.ok(Kind.TITLES, object); |
| 53 | if ('check' in constraint) { |
| 54 | constraint.check(object["titles"], recorder); |
| 55 | }; |
| 56 | @@ -132,15 +132,19 @@ const _repository = { |
| 57 | }; |
| 58 | |
| 59 | function makeTable(data) { |
| 60 | - let innerHTML = "<table id=\"test-results\"><tr><th>Test</th><th>State</th><th>Message</th><th>Object</th><tr>"; |
| 61 | + let innerHTML = "<table id=\"test-results\"><tr><th>Link</th><th>State</th><th>Message</th><th>Object</th><tr>"; |
| 62 | for (let i = 0; i < data.length; i++) { |
| 63 | - let kind = data[i][0]; |
| 64 | - if (data[i][1]) { |
| 65 | - let message = data[i][1]; |
| 66 | - let object = data[i][2]; |
| 67 | - innerHTML += "<tr class=\"negative\">" + "<td>" + kind + "</td>" + "<td>Fail</td><td>" + message + "</td><td><code>" + JSON.stringify(object) + "</code></td></tr>"; |
| 68 | + let result = data[i]; |
| 69 | + if (result.error) { |
| 70 | + let relationship = result.object["rel"]; |
| 71 | + innerHTML += "<tr class=\"negative\">" + "<td>" + relationship + "</td>" + |
| 72 | + "<td>Fail</td><td>" + result.message + "</td><td><code>" + |
| 73 | + JSON.stringify(result.object) + "</code></td></tr>"; |
| 74 | } else { |
| 75 | - innerHTML += "<tr class=\"positive\"><td>" + kind + "</td>" + "<td>Pass</td><td></td><td></td></tr>"; |
| 76 | + let relationship = result.object["rel"]; |
| 77 | + innerHTML += "<tr class=\"positive\"><td>" + relationship + "</td>" + |
| 78 | + "<td>Pass</td><td></td><td>" + JSON.stringify(result.object) + |
| 79 | + "</td></tr>"; |
| 80 | } |
| 81 | } |
| 82 | innerHTML += "</table>"; |