Skip to content

Commit 98a088d

Browse files
author
Craig Cornelius
authored
Fix selection on left mouse to unescape HTML entities (#480)
* Fix selection on left mouse to unescape HTML entities * Replaced unescaping function
1 parent dfbc189 commit 98a088d

File tree

1 file changed

+33
-28
lines changed

1 file changed

+33
-28
lines changed

verifier/detail_template.html

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
cursor: pointer;
3434
font-size:20px;
3535
}
36-
36+
3737
.diff_area {
3838
font-size: 24px;
3939
font-color: blue;
@@ -102,7 +102,7 @@
102102
<script type="text/javascript">
103103
// Global for the test_type.
104104
const test_type = "$test_type";
105-
105+
106106
// Stores info from the json data fetched asynchronously.
107107
let test_results = {
108108
'pass': {
@@ -122,7 +122,7 @@
122122
count: 0,
123123
characterized: null,
124124
check_boxes: [],
125-
widget_label_sets: [],
125+
widget_label_sets: [],
126126
box_labels: [],
127127
selected_set: null,
128128
pagination_container: null
@@ -160,7 +160,7 @@
160160
selected_set: null,
161161
pagination_container: null
162162
}
163-
163+
164164
};
165165

166166
// Get the JSON data from the tests.
@@ -196,8 +196,8 @@
196196
p5.then((response) => response.json())
197197
.then((data) => {
198198
test_results['known_issue'].json = data}),
199-
200-
199+
200+
201201
// TODO: Make a separate promise.all for this?
202202
p_pass_char.then((response) => response.json())
203203
.then((data) => {
@@ -261,12 +261,12 @@
261261
// Update the group selected with the intersection or inclusion of label sets
262262
const class_name = widget.className;
263263
const test_data = test_results[class_name];
264-
264+
265265
// Start with all the tests, intersecting or removing data as needed.
266266
test_data.selected_set = new Set(test_data.all_labels);
267267

268268
const selected_count_items = document.getElementsByName('selectedCount');
269-
269+
270270
// Update the number of results size
271271
let newSize = test_data.selected_set == null ? 0 : test_data.selected_set.size;
272272
const output = [...selected_count_items].filter(elem => elem.className == class_name);
@@ -276,29 +276,29 @@
276276
}
277277

278278
let excluded_set = new Set(); // Remove these label after the loop.
279-
279+
280280
// For each widget, if active, update the state of the selected and exclued sets
281281
for (let index in test_data.check_boxes) {
282282
const widget = test_data.check_boxes[index];
283283
const label_set = test_data.widget_label_sets[index];
284284

285285
// This is a tristate item.
286286
const which_state = widget.value;
287-
287+
288288
// Choose the value depending on the status of the control
289289
if (which_state == check_mark) {
290290
// Update by intersection with this set.
291291
test_data.selected_set =
292292
new Set([...test_data.selected_set].filter((x) => label_set.has(x)));
293-
}
293+
}
294294
else if (which_state == cross_mark) {
295295
// Update by removing all these labels, i.e., intersect with the inverse
296296
for (let label of label_set) {
297297
excluded_set.add(label);
298298
}
299299
}
300300
}
301-
301+
302302
// Remove the excluded values from selected set.
303303
excluded_set.forEach((label) => {
304304
test_data.selected_set.delete(label);
@@ -310,7 +310,7 @@
310310
// Set the current count of items
311311
output[0].innerHTML = output[0].innerText = newSize;
312312
}
313-
313+
314314
// Get the characterized data from the correct set of items
315315
if (newSize == 0) {
316316
// Reset all widgets in this group
@@ -320,7 +320,7 @@
320320
for (let index in test_data.check_boxes) {
321321
const widget = test_data.check_boxes[index];
322322
const label_set = test_data.widget_label_sets[index];
323-
323+
324324
// Compute overlap between the selected set and this widgetss data.
325325
let intersectSet = new Set(
326326
[...label_set].filter(i => test_data.selected_set.has(i)));
@@ -364,7 +364,7 @@
364364
const diff_area_name = "diff_area_" + c_type;
365365
const onclick_call =
366366
'"captureInputDataOnClick(this);" onmouseover="hoverDiffText(this,' + diff_area_name + ');"';
367-
367+
368368
let table_opening =
369369
'<table id="table_' + c_type +
370370
'" class="class_' + c_type + '">';
@@ -482,7 +482,7 @@
482482
// -----------------------
483483
function create_tristate_area(
484484
id, data_class, characterization, count, container) {
485-
// Make a tristate control for the items in this data class
485+
// Make a tristate control for the items in this data class
486486
// Reference: https://jsfiddle.net/wf_bitplan_com/941std72/8/
487487
// Creates this widget, storing the result in the data_class
488488
// <input title="this is a tri-state button: &#x2753;,&#x2705;,&#x274C;" type="button" onclick="tristate1(this)" value="&#x2753;" />
@@ -511,7 +511,7 @@
511511
if (container) {
512512
container.appendChild(box_div);
513513
}
514-
return box;
514+
return box;
515515
}
516516

517517
function tristate1(control) {
@@ -541,7 +541,7 @@
541541
// display the current value if it's unexpected
542542
alert(control.value);
543543
}
544-
}
544+
}
545545

546546
function create_widget_area(data_class, make_widget_function) {
547547
/* Given a set of labels and named characteristics, create a set of checkboxes with
@@ -551,11 +551,11 @@
551551
const test_info = test_results[data_class];
552552

553553
const selected_count_items = document.getElementsByName('selectedCount');
554-
554+
555555
let leftover_labels = new Set();
556556
const json = test_info.json;
557557
for (const item of json) {
558-
const label = item['label'];
558+
const label = item['label'];
559559
test_info.all_labels.add(label);
560560
leftover_labels.add(label);
561561
}
@@ -566,7 +566,7 @@
566566
if (output) {
567567
output[0].innerHTML = output[0].innerText = newSize;
568568
}
569-
569+
570570
let div_name = data_class + '_characterized';
571571
let container = document.getElementById(div_name);
572572
for (const characterization in test_info.characterized) {
@@ -600,7 +600,7 @@
600600
test_info.check_boxes.push(new_widget);
601601
}
602602
}
603-
603+
604604
// Handle any non-characterized tests.
605605
if (leftover_labels.size > 0) {
606606
// Create an item for non-categorized results.
@@ -624,7 +624,7 @@
624624
div_for_checkbox.attributeStyleMap.clear();
625625
});
626626

627-
627+
628628
// reset the number of results size
629629
const selected_count_items = document.getElementsByName('selectedCount');
630630
const newSize = test_data.selected_set == null ? 0 : test_data.all_labels.size;
@@ -636,6 +636,11 @@
636636
}
637637
}
638638

639+
function unEscape(htmlStr) {
640+
var doc = new DOMParser().parseFromString(htmlStr, "text/html");
641+
return doc.documentElement.textContent;
642+
}
643+
639644
// For getting contents of output into json string for testing
640645
function captureInputDataOnClick(element) {
641646
const text = element.innerHTML;
@@ -647,7 +652,7 @@
647652
}
648653
// alert(output);
649654
// Copy to clipboard.
650-
navigator.clipboard.writeText(output);
655+
navigator.clipboard.writeText(unEscape(output));
651656
}
652657

653658
// On hover, show the difference between expected and actual result
@@ -676,14 +681,14 @@
676681
let found = false;
677682
const label_data = document.getElementById('label_data');
678683
label_data.innerHTML = "???";
679-
684+
680685
let item_index;
681686
let pagination_container;
682687
let pagination_obj;
683688

684689
for (const type of result_types) {
685690
const results = test_results[type].all_labels;
686-
691+
687692
if (results.has(label)) {
688693
// Show the result type and the data for this one,
689694
// i.e., label, expected result, result, input_data.
@@ -733,7 +738,7 @@
733738
Intended to use for differences between expected and actual result.
734739
-->
735740
<script src="../../../diff_match_patch.js"></script>
736-
741+
737742
</head>
738743
<body>
739744
<h1>Verification report: $test_type on $library_name</h1>
@@ -845,7 +850,7 @@ <h3>Find label</h3>
845850
</div> <!-- grid end -->
846851
</details>
847852
</div>
848-
</details>
853+
</details>
849854

850855
<details id="error_details">
851856
<summary>Test errors <span id='error_count'>($error_count)</span></summary>

0 commit comments

Comments
 (0)