Skip to content

Commit 9dabacd

Browse files
committed
[analyzer] Adjust JS code of analyzer's HTML report for IE support.
Summary: Change and replace some functions which IE does not support. This patch is made as a continuation of D92928 revision. Also improve hot keys behavior. Differential Revision: https://reviews.llvm.org/D107366
1 parent 6d5e31b commit 9dabacd

File tree

1 file changed

+32
-8
lines changed

1 file changed

+32
-8
lines changed

clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp

+32-8
Original file line numberDiff line numberDiff line change
@@ -1289,15 +1289,32 @@ var findNum = function() {
12891289
return out;
12901290
};
12911291
1292+
var classListAdd = function(el, theClass) {
1293+
if(!el.className.baseVal)
1294+
el.className += " " + theClass;
1295+
else
1296+
el.className.baseVal += " " + theClass;
1297+
};
1298+
1299+
var classListRemove = function(el, theClass) {
1300+
var className = (!el.className.baseVal) ?
1301+
el.className : el.className.baseVal;
1302+
className = className.replace(" " + theClass, "");
1303+
if(!el.className.baseVal)
1304+
el.className = className;
1305+
else
1306+
el.className.baseVal = className;
1307+
};
1308+
12921309
var scrollTo = function(el) {
12931310
querySelectorAllArray(".selected").forEach(function(s) {
1294-
s.classList.remove("selected");
1311+
classListRemove(s, "selected");
12951312
});
1296-
el.classList.add("selected");
1313+
classListAdd(el, "selected");
12971314
window.scrollBy(0, el.getBoundingClientRect().top -
12981315
(window.innerHeight / 2));
12991316
highlightArrowsForSelectedEvent();
1300-
}
1317+
};
13011318
13021319
var move = function(num, up, numItems) {
13031320
if (num == 1 && up || num == numItems - 1 && !up) {
@@ -1332,9 +1349,11 @@ window.addEventListener("keydown", function (event) {
13321349
if (event.defaultPrevented) {
13331350
return;
13341351
}
1335-
if (event.key == "j") {
1352+
// key 'j'
1353+
if (event.keyCode == 74) {
13361354
navigateTo(/*up=*/false);
1337-
} else if (event.key == "k") {
1355+
// key 'k'
1356+
} else if (event.keyCode == 75) {
13381357
navigateTo(/*up=*/true);
13391358
} else {
13401359
return;
@@ -1350,8 +1369,11 @@ StringRef HTMLDiagnostics::generateArrowDrawingJavascript() {
13501369
<script type='text/javascript'>
13511370
// Return range of numbers from a range [lower, upper).
13521371
function range(lower, upper) {
1353-
const size = upper - lower;
1354-
return Array.from(new Array(size), (x, i) => i + lower);
1372+
var array = [];
1373+
for (var i = lower; i <= upper; ++i) {
1374+
array.push(i);
1375+
}
1376+
return array;
13551377
}
13561378
13571379
var getRelatedArrowIndices = function(pathId) {
@@ -1371,7 +1393,9 @@ var highlightArrowsForSelectedEvent = function() {
13711393
const arrowIndicesToHighlight = getRelatedArrowIndices(selectedNum);
13721394
arrowIndicesToHighlight.forEach((index) => {
13731395
var arrow = document.querySelector("#arrow" + index);
1374-
arrow.classList.add("selected");
1396+
if(arrow) {
1397+
classListAdd(arrow, "selected")
1398+
}
13751399
});
13761400
}
13771401

0 commit comments

Comments
 (0)