forked from TeamNewPipe/CrashReportToMarkdown
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
151 lines (141 loc) · 4.84 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<!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="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 onTransform() {
input = document.getElementById("input");
output = document.getElementById("output");
try {
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;
}
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";
output.value += "\n<details><summary><b>Crash log</b></summary><p>\n";
output.value += "\n```\n";
report.exceptions.forEach(function(exception, index) {
output.value += exception;
if (index !== report.exceptions.length - 1) output.value += "\n-------------------\n\n";
});
output.value += "\n```\n";
output.value += "</p></details>\n";
output.value += "<hr>\n";
onResize(output);
}
function onCopy() {
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) {
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");
}
</script>
</body>
</html>