web: Add query string to `Report Bug` link

* web: Add query string to the Report Bug link (closes #1753)
This commit is contained in:
JMcKiern 2020-12-14 19:25:10 +00:00 committed by GitHub
parent c4d7b24629
commit 63be0455a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 47 additions and 30 deletions

View File

@ -91,6 +91,7 @@ export class RufflePlayer extends HTMLElement {
private playButton: HTMLElement;
private unmuteOverlay: HTMLElement;
private rightClickMenu: HTMLElement;
private swfUrl?: string;
private instance: Ruffle | null;
private _trace_observer: ((message: string) => void) | null;
@ -409,6 +410,14 @@ export class RufflePlayer extends HTMLElement {
if ("url" in options) {
console.log("Loading SWF file " + options.url);
try {
this.swfUrl = new URL(
options.url,
document.location.href
).href;
} catch {
this.swfUrl = options.url;
}
const parameters = {
...sanitizeParameters(
@ -712,25 +721,6 @@ export class RufflePlayer extends HTMLElement {
}
this.panicked = true;
// Clears out any existing content (ie play button or canvas) and replaces it with the error screen
this.container.innerHTML = `
<div id="panic">
<div id="panic-title">Something went wrong :(</div>
<div id="panic-body">
<p>Ruffle has encountered a major issue whilst trying to display this Flash content.</p>
<p>This isn't supposed to happen, so we'd really appreciate if you could file a bug!</p>
</div>
<div id="panic-footer">
<ul>
<li><a href="https://github.com/ruffle-rs/ruffle/issues/new">Report Bug</a></li>
<li><a href="#" id="panic-view-details">View Error Details</a></li>
</ul>
</div>
</div>
`;
(<HTMLLinkElement>(
this.container.querySelector("#panic-view-details")
)).onclick = () => {
let errorText = "# Error Info\n";
if (error instanceof Error) {
@ -748,6 +738,7 @@ export class RufflePlayer extends HTMLElement {
errorText += "\n# Page Info\n";
errorText += `Page URL: ${document.location.href}\n`;
if (this.swfUrl) errorText += `SWF URL: ${this.swfUrl}\n`;
errorText += "\n# Browser Info\n";
errorText += `Useragent: ${window.navigator.userAgent}\n`;
@ -760,6 +751,32 @@ export class RufflePlayer extends HTMLElement {
errorText += `Built: %BUILD_DATE%\n`;
errorText += `Commit: %COMMIT_HASH%\n`;
const issueTitle = `Ruffle Error on ${document.location.href}`;
const issueLink =
"https://github.com/ruffle-rs/ruffle/issues/new?title=" +
encodeURIComponent(issueTitle) +
"&body=" +
encodeURIComponent(errorText);
// Clears out any existing content (ie play button or canvas) and replaces it with the error screen
this.container.innerHTML = `
<div id="panic">
<div id="panic-title">Something went wrong :(</div>
<div id="panic-body">
<p>Ruffle has encountered a major issue whilst trying to display this Flash content.</p>
<p>This isn't supposed to happen, so we'd really appreciate if you could file a bug!</p>
</div>
<div id="panic-footer">
<ul>
<li><a href=${issueLink}>Report Bug</a></li>
<li><a href="#" id="panic-view-details">View Error Details</a></li>
</ul>
</div>
</div>
`;
(<HTMLLinkElement>(
this.container.querySelector("#panic-view-details")
)).onclick = () => {
this.container.querySelector(
"#panic-body"
)!.innerHTML = `<textarea>${errorText}</textarea>`;