mirror of
https://github.com/lax1dude/crashreport-viewer.git
synced 2024-12-22 05:54:11 -08:00
added a checkbox to set an offset to the first line
This commit is contained in:
parent
54cb377112
commit
9e81319cdb
|
@ -43,6 +43,7 @@ body {
|
||||||
font-family: 'Ubuntu', sans-serif;
|
font-family: 'Ubuntu', sans-serif;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
padding: 4px 8px;
|
padding: 4px 8px;
|
||||||
|
height: 34px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.toggleShow {
|
.toggleShow {
|
||||||
|
@ -115,6 +116,28 @@ body {
|
||||||
padding: 4px 0px;
|
padding: 4px 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#firstLineSpan {
|
||||||
|
float: right;
|
||||||
|
font-size: 22px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
#enableFirstLine {
|
||||||
|
width: 21px;
|
||||||
|
height: 21px;
|
||||||
|
margin: 0px;
|
||||||
|
vertical-align: middle;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#firstLineValue {
|
||||||
|
font-family: 'Source Code Pro', monospace;
|
||||||
|
font-size: 16px;
|
||||||
|
width: 80px;
|
||||||
|
height: 30px;
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.darkModeScrollbar::-webkit-scrollbar, .darkModeScrollbar::-webkit-scrollbar-track {
|
.darkModeScrollbar::-webkit-scrollbar, .darkModeScrollbar::-webkit-scrollbar-track {
|
||||||
background-color: black;
|
background-color: black;
|
||||||
width: 15px;
|
width: 15px;
|
||||||
|
|
|
@ -209,6 +209,13 @@ function printVersionWarning(vers) {
|
||||||
|
|
||||||
function updateSource(srcMap) {
|
function updateSource(srcMap) {
|
||||||
clearDecodedView();
|
clearDecodedView();
|
||||||
|
|
||||||
|
var firstLine = 0;
|
||||||
|
var j = parseInt(appElements.firstLineValue.value);
|
||||||
|
if(!isNaN(j) && j > 1 && appElements.enableFirstLine.checked) {
|
||||||
|
firstLine = j - 1;
|
||||||
|
}
|
||||||
|
|
||||||
var sourceValue = appElements.inputTextArea.value;
|
var sourceValue = appElements.inputTextArea.value;
|
||||||
var lines = sourceValue.split(/\r?\n/g);
|
var lines = sourceValue.split(/\r?\n/g);
|
||||||
var vers = extractVersionFromFile(lines);
|
var vers = extractVersionFromFile(lines);
|
||||||
|
@ -239,7 +246,9 @@ function updateSource(srcMap) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!isNaN(lineNo) && !isNaN(colNo)) {
|
if(!isNaN(lineNo) && !isNaN(colNo)) {
|
||||||
var original = formatLine(srcMap.originalPositionFor({ line: lineNo, column: colNo }));
|
var newLineNumber = lineNo - firstLine;
|
||||||
|
if(newLineNumber > 0) {
|
||||||
|
var original = formatLine(srcMap.originalPositionFor({ line: newLineNumber, column: colNo }));
|
||||||
if(original !== null) {
|
if(original !== null) {
|
||||||
if(firstToken.endsWith("line")) {
|
if(firstToken.endsWith("line")) {
|
||||||
appElements.outputContent.appendChild(document.createTextNode(lines[i] + " "));
|
appElements.outputContent.appendChild(document.createTextNode(lines[i] + " "));
|
||||||
|
@ -263,6 +272,7 @@ function updateSource(srcMap) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
appElements.outputContent.appendChild(document.createTextNode(lines[i] + "\n"));
|
appElements.outputContent.appendChild(document.createTextNode(lines[i] + "\n"));
|
||||||
}
|
}
|
||||||
|
@ -420,6 +430,56 @@ function showFileChooser() {
|
||||||
fileChooserElement.click();
|
fileChooserElement.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function changeFirstLineShading(en) {
|
||||||
|
if(en) {
|
||||||
|
appElements.firstLineText.style.color = "white";
|
||||||
|
appElements.firstLineValue.disabled = false;
|
||||||
|
}else {
|
||||||
|
appElements.firstLineText.style.color = "#999999";
|
||||||
|
appElements.firstLineValue.disabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var changeFirstLineTimout = -1;
|
||||||
|
|
||||||
|
function handleChangeFirstLineEnabled() {
|
||||||
|
changeFirstLineTimout = -1;
|
||||||
|
var cookie = {};
|
||||||
|
cookie.enableFirstLine = appElements.enableFirstLine.checked;
|
||||||
|
var i = parseInt(appElements.firstLineValue.value);
|
||||||
|
var is_nan = isNaN(i);
|
||||||
|
if(!is_nan || cookie.enableFirstLine) {
|
||||||
|
if(is_nan || i < 1) {
|
||||||
|
i = 1;
|
||||||
|
}
|
||||||
|
cookie.firstLineValue = i;
|
||||||
|
window.localStorage.setItem("crashReportViewer_conf", JSON.stringify(cookie));
|
||||||
|
}
|
||||||
|
changeFirstLineShading(cookie.enableFirstLine);
|
||||||
|
if(!isShowingOriginal) {
|
||||||
|
updateDecodedPane();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeFirstLineEnabled() {
|
||||||
|
if(changeFirstLineTimout != -1) {
|
||||||
|
clearTimeout(changeFirstLineTimout);
|
||||||
|
}
|
||||||
|
changeFirstLineTimout = setTimeout(handleChangeFirstLineEnabled, 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeFirstLineEnabledImmediate() {
|
||||||
|
if(changeFirstLineTimout != -1) {
|
||||||
|
clearTimeout(changeFirstLineTimout);
|
||||||
|
}
|
||||||
|
var i = parseInt(appElements.firstLineValue.value);
|
||||||
|
var is_nan = isNaN(i);
|
||||||
|
if(is_nan || i < 1) {
|
||||||
|
appElements.firstLineValue.value = "1";
|
||||||
|
}
|
||||||
|
handleChangeFirstLineEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
window.addEventListener("load", () => {
|
window.addEventListener("load", () => {
|
||||||
|
|
||||||
appElements = {
|
appElements = {
|
||||||
|
@ -430,7 +490,10 @@ window.addEventListener("load", () => {
|
||||||
outputTextArea: document.getElementById("outputTextArea"),
|
outputTextArea: document.getElementById("outputTextArea"),
|
||||||
outputContent: document.getElementById("outputContent"),
|
outputContent: document.getElementById("outputContent"),
|
||||||
fetchingMessage: document.getElementById("fetchingMessage"),
|
fetchingMessage: document.getElementById("fetchingMessage"),
|
||||||
loadingDots: document.getElementById("loadingDots")
|
loadingDots: document.getElementById("loadingDots"),
|
||||||
|
enableFirstLine: document.getElementById("enableFirstLine"),
|
||||||
|
firstLineText: document.getElementById("firstLineText"),
|
||||||
|
firstLineValue: document.getElementById("firstLineValue")
|
||||||
};
|
};
|
||||||
|
|
||||||
dotsInterval = setInterval(updateDots, 300);
|
dotsInterval = setInterval(updateDots, 300);
|
||||||
|
@ -452,6 +515,27 @@ window.addEventListener("load", () => {
|
||||||
|
|
||||||
appElements.sourceMaps.addEventListener("change", comboBoxChangeHandler);
|
appElements.sourceMaps.addEventListener("change", comboBoxChangeHandler);
|
||||||
|
|
||||||
|
appElements.enableFirstLine.addEventListener("change", changeFirstLineEnabledImmediate);
|
||||||
|
appElements.firstLineValue.addEventListener("propertychange", changeFirstLineEnabled);
|
||||||
|
appElements.firstLineValue.addEventListener("change", changeFirstLineEnabled);
|
||||||
|
appElements.firstLineValue.addEventListener("click", changeFirstLineEnabled);
|
||||||
|
appElements.firstLineValue.addEventListener("keyup", changeFirstLineEnabled);
|
||||||
|
appElements.firstLineValue.addEventListener("input", changeFirstLineEnabled);
|
||||||
|
appElements.firstLineValue.addEventListener("paste", changeFirstLineEnabled);
|
||||||
|
|
||||||
|
var cookie = window.localStorage.getItem("crashReportViewer_conf");
|
||||||
|
if(cookie) {
|
||||||
|
try {
|
||||||
|
cookie = JSON.parse(cookie);
|
||||||
|
if(cookie && typeof cookie.firstLineValue === "number") {
|
||||||
|
appElements.enableFirstLine.checked = !!cookie.enableFirstLine;
|
||||||
|
appElements.firstLineValue.value = "" + cookie.firstLineValue;
|
||||||
|
changeFirstLineShading(!!cookie.enableFirstLine);
|
||||||
|
}
|
||||||
|
}catch(e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fetch("sourceMaps.json")
|
fetch("sourceMaps.json")
|
||||||
.then((r) => r.json())
|
.then((r) => r.json())
|
||||||
.then(sourceMapListLoaded)
|
.then(sourceMapListLoaded)
|
||||||
|
|
|
@ -28,6 +28,9 @@
|
||||||
<span id="fetchingMessage">Fetching source maps, please wait<span id="loadingDots"></span></span>
|
<span id="fetchingMessage">Fetching source maps, please wait<span id="loadingDots"></span></span>
|
||||||
<span id="showOriginal" class="toggleShow toggleSelected" style="display:none;">Show Original</span>
|
<span id="showOriginal" class="toggleShow toggleSelected" style="display:none;">Show Original</span>
|
||||||
<span id="showDecoded" class="toggleShow toggleShowDisabled" style="display:none;">Show Decoded</span>
|
<span id="showDecoded" class="toggleShow toggleShowDisabled" style="display:none;">Show Decoded</span>
|
||||||
|
<span id="firstLineSpan">
|
||||||
|
<input type="checkbox" id="enableFirstLine" /> <span style="color:#999999;" id="firstLineText">First line:</span> <input type="text" pattern="[0-9]+" id="firstLineValue" disabled />
|
||||||
|
</span>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="containerBody">
|
<div class="containerBody">
|
||||||
|
|
Loading…
Reference in New Issue
Block a user