mirror of
https://github.com/TeamNewPipe/CrashReportToMarkdown
synced 2025-01-22 04:13:43 +00:00
191 lines
6.1 KiB
HTML
191 lines
6.1 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Error Report to Markdown reporter</title>
|
|
<style>
|
|
html, body {
|
|
font-family: Roboto, Arial, sans-serif;
|
|
margin: 0;
|
|
padding: 15px;
|
|
background: #f3eff2;
|
|
color: #070000;
|
|
}
|
|
button {
|
|
display: inline-block;
|
|
background: #4d4d4d;
|
|
color: #fff;
|
|
border: 0;
|
|
border-radius: 4px;
|
|
padding: 10px 15px;
|
|
margin: 0 10px 15px 0;
|
|
}
|
|
button:hover,
|
|
button:focus,
|
|
button:active {
|
|
background: #3d3d3d;
|
|
}
|
|
div + button {
|
|
margin-top: 15px;
|
|
}
|
|
div {
|
|
display: flex;
|
|
}
|
|
textarea {
|
|
max-width: 100%;
|
|
border: 0;
|
|
background: white;
|
|
padding: 10px;
|
|
overflow: auto;
|
|
color: #898989;
|
|
font-size: 1.2em;
|
|
}
|
|
textarea.placeholder {
|
|
height: 1.2em;
|
|
}
|
|
textarea::placeholder {
|
|
font-size: 1em;
|
|
line-height: 1em;
|
|
color: #898989;
|
|
}
|
|
#clipboard-message {
|
|
display: block;
|
|
position: fixed;
|
|
text-align: center;
|
|
padding: 30px;
|
|
width: 50%;
|
|
bottom: 30px;
|
|
left: calc(25% - 30px);
|
|
border-radius: 5px;
|
|
background: #4d4d4d;
|
|
color: white;
|
|
opacity: 0;
|
|
transition: opacity 1s ease-in-out;
|
|
}
|
|
#clipboard-message.visible {
|
|
opacity: 1;
|
|
}
|
|
a button {
|
|
text-decoration: none;
|
|
color: #fff;
|
|
display: inline-block;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>The incredible NPE to Markdown converter</h1>
|
|
<h3>Paste the JSON bugreport here</h3>
|
|
<div><textarea rows="1" cols="150" id="input" class="placeholder" placeholder="Paste the JSON bugreport here" onchange="onResize(this)" onkeyup="onResize(this)"></textarea></div>
|
|
<button onclick="onPaste()">paste</button>
|
|
<button onClick="onTransform()">transform</button>
|
|
<div><textarea rows="1" cols="150" id="output" class="placeholder" placeholder="Click transform and your human readable bugreport will appear here. "></textarea></div>
|
|
<h3>Paste it into your Github issue</h3>
|
|
<button onClick="onCopy()">copy to clipboard</button>
|
|
<a href="https://github.com/TeamNewPipe/NewPipe/issues/new"><button>new issue</button></a>
|
|
<span id="clipboard-message">Copied to clipboard!</span>
|
|
|
|
<script>
|
|
|
|
function onPaste() {
|
|
let input = document.getElementById("input");
|
|
input.focus();
|
|
input.select();
|
|
document.execCommand("paste");
|
|
onResize(input);
|
|
}
|
|
|
|
function onTransform() {
|
|
let input = document.getElementById("input");
|
|
let output = document.getElementById("output");
|
|
|
|
try {
|
|
var report = JSON.parse(input.value);
|
|
} catch (e) {
|
|
var msg = "Cannot convert bug report to Markdown:\n\n";
|
|
if (e instanceof SyntaxError) {
|
|
alert(msg + "Failed to parse JSON due to syntax error:\n" + e.message);
|
|
} else {
|
|
alert(msg + "Unknown error occurred:\n" + e.name + ": " + e.message)
|
|
}
|
|
return;
|
|
}
|
|
|
|
generateOutput(report);
|
|
}
|
|
|
|
function generateOutput(report) {
|
|
output.value = "";
|
|
|
|
output.value += "## Exception";
|
|
output.value += "\n* __User Action:__ " + report.user_action;
|
|
output.value += "\n* __Request:__ " + report.request;
|
|
output.value += "\n* __Content Language:__ " + report.content_language;
|
|
output.value += "\n* __Service:__ " + report.service;
|
|
output.value += "\n* __Version:__ " + report.version;
|
|
output.value += "\n* __OS:__ " + report.os;
|
|
|
|
output.value += "\n" + report.user_comment + "\n";
|
|
|
|
if (report.exceptions.length > 1) {
|
|
output.value += "\n<details><summary><b>Exceptions (" + (report.exceptions.length + 1) + ")</b></summary><p>\n";
|
|
}
|
|
|
|
report.exceptions.forEach(function(exception, index) {
|
|
output.value += "\n<details><summary><b>Crash log" + (index + 1) + "</b></summary>\n";
|
|
output.value += "\n```\n";
|
|
output.value += exception.stacktrace;
|
|
output.value += "\n```\n";
|
|
if (exception.document && exception.document !== "") {
|
|
output.value += "\n```HTML\n";
|
|
output.value += exception.document;
|
|
output.value += "\n```\n";
|
|
}
|
|
output.value += "</details>\n";
|
|
});
|
|
|
|
if (report.exceptions.length > 1) {
|
|
output.value += "</p></details>\n";
|
|
}
|
|
|
|
output.value += "<hr>\n";
|
|
onResize(output);
|
|
}
|
|
|
|
function onCopy() {
|
|
let output = document.getElementById("output");
|
|
if (output.value === "") return;
|
|
output.select();
|
|
document.execCommand("copy");
|
|
output.blur();
|
|
var clipboardMsg = document.getElementById("clipboard-message");
|
|
clipboardMsg.classList.add("visible");
|
|
setTimeout(function () {
|
|
clipboardMsg.classList.remove("visible");
|
|
}, 4000);
|
|
}
|
|
|
|
function onResize(el) {
|
|
let lines = el.value.split('\n');
|
|
el.rows = lines.length < 20 ? "" + lines.length + "" : '20';
|
|
if (lines.length === 1) el.classList.add("placeholder");
|
|
else el.classList.remove("placeholder");
|
|
}
|
|
|
|
// everything which needs to be done once the DOM is loaded.
|
|
(function() {
|
|
// load crash report from URL if data is given
|
|
let url = new URL(window.location.href);
|
|
if (url.searchParams.has("data")) {
|
|
// data is base64 encoded for simple privacy reasons and URL-encoded
|
|
let data = decodeURIComponent(url.searchParams.get("data"));
|
|
//data = atob(data);
|
|
data = JSON.parse(data);
|
|
generateOutput(data);
|
|
}
|
|
})();
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|