in frontend/src/index.js [102:173]
date: dateStr(evt.value.x),
};
render("history_point", ctx, "history_details");
};
}
});
}
async function showDirectory(dir, revision, files) {
const context = {
navbar: buildNavbar(dir, revision),
files: files.map((file) => {
file.route = buildRoute({
path: file.path,
view: file.type,
});
// Calc decimal range to make a nice coloration
file.coveragePercent = Math.floor(file.coveragePercent);
file.range = parseInt(file.coveragePercent / 10) * 10;
return file;
}),
revision: revision || REV_LATEST,
file_name() {
// Build filename relative to current dir
if (dir) {
// Remove extra / only when present
const offset = dir[dir.length - 1] === "/" ? 0 : 1;
return this.path.substring(dir.length + offset);
}
return this.path;
},
};
render("file_browser", context, "output");
}
async function showFile(source, file, revision, selectedLine) {
selectedLine = selectedLine !== undefined ? parseInt(selectedLine) : -1;
let language;
if (file.path.endsWith("cpp") || file.path.endsWith("h")) {
language = "cpp";
} else if (file.path.endsWith("c")) {
language = "c";
} else if (
file.path.endsWith("js") ||
file.path.endsWith("jsm") ||
file.path.endsWith("mjs") ||
file.path.endsWith("jsx")
) {
language = "javascript";
} else if (file.path.endsWith("css")) {
language = "css";
} else if (file.path.endsWith("py")) {
language = "python";
} else if (file.path.endsWith("java")) {
language = "java";
}
const context = {
navbar: buildNavbar(file.path, revision),
language,
lines: source.map((line, nb) => {
const coverage = file.coverage[nb];
let cssClass = "";
let hits = null;
if (coverage !== undefined && coverage >= 0) {
cssClass = coverage > 0 ? "covered" : "uncovered";
// Build a nicer coverage string for counts
if (coverage >= 1000000) {