Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a very hacky bug reporting mechanism. Hacky largely because I j…
…ust copied and pasted uproot-dialog.html to bug-report-dialog.html and changed a few things. Hopefully this will be good enough for now, though.
- Loading branch information
Showing
6 changed files
with
249 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
(function(jQuery) { | ||
"use strict"; | ||
|
||
var $ = jQuery; | ||
|
||
jQuery.extend({ | ||
openBugReportDialog: function(input) { | ||
jQuery.simpleModalDialog({ | ||
input: input, | ||
url: jQuery.webxraySettings.url("bugReportDialogURL"), | ||
payload: JSON.stringify({ | ||
buildMetadata: buildMetadata, | ||
hackpubURL: jQuery.webxraySettings.url("bugReportHackpubURL"), | ||
originalURL: window.location.href, | ||
languages: jQuery.locale.languages | ||
}) | ||
}); | ||
} | ||
}); | ||
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Report A Bug</title> | ||
<link rel="stylesheet" href="dialog-common/stylesheets/base.css"> | ||
<style> | ||
textarea { | ||
font-family: Monaco, "Lucida Console", monospace; | ||
font-size: 9pt; | ||
width: 100%; | ||
height: 15em; | ||
margin-bottom: 1em; | ||
} | ||
|
||
div.big-button { | ||
display: inline-block; | ||
width: 200px; | ||
text-align: center; | ||
cursor: pointer; | ||
background-color: #f8a339; | ||
font-style: italic; | ||
color: white; | ||
border-radius: 10px; | ||
padding: 20px; | ||
} | ||
|
||
div.big-button:after { | ||
content: ' »'; | ||
} | ||
|
||
div.big-button:hover { | ||
background-color: #ffc833; | ||
} | ||
|
||
div.publish-option { | ||
padding-top: 0.5em; | ||
padding-bottom: 0.5em; | ||
} | ||
|
||
div.publish-option p { | ||
display: inline; | ||
padding: 10px; | ||
} | ||
|
||
.published-url { | ||
padding: 10px; | ||
text-align: center; | ||
} | ||
|
||
.published-url a { | ||
font-size: 24pt; | ||
text-decoration: none; | ||
color: steelblue; | ||
padding: 10px; | ||
} | ||
|
||
.published-url a:hover { | ||
background-color: #f0f0f0; | ||
} | ||
</style> | ||
<div class="container"> | ||
<div id="buttons"> | ||
<div class="close-button" id="close" | ||
data-l10n="dialog-common:close">Close</div> | ||
</div> | ||
<div id="header"><h1 class="title"><span data-l10n="dialog-common:product-name">X-Ray Goggles</span> <span class="subtitle" data-l10n="header">Report A Bug</span></h1></div> | ||
<div id="choose-publish-method"> | ||
<p data-l10n="intro">Enter a description for the bug you're experiencing below. Note that your description, as well as the current page you're using the goggles on, will be made public, as Hackasaurus is an open-source project.</p> | ||
<div class="publish-option"> | ||
<textarea id="bug-description"></textarea> | ||
<div class="big-button to-internet" data-l10n="to-internet">Publish To Internet</div> | ||
<p data-l10n="to-internet-desc">Instantly publish your bug to a URL that anyone can view.</p> | ||
</div> | ||
</div> | ||
<div id="to-internet" style="display: none;"> | ||
<p class="loading" data-l10n="publishing">Publishing...</p> | ||
<div class="failure" style="display: none;"> | ||
<p data-l10n="error">Sorry, an error occurred. Please try again later.</p> | ||
</div> | ||
<div class="finished" style="display: none;"> | ||
<p data-l10n="success">Here is the URL for your bug that anyone can view.</p> | ||
<div class="published-url"> | ||
<a target="_blank" href="http://foo/bar">http://foo/bar</a> | ||
</div> | ||
</div> | ||
</div> | ||
<div id="bug-report-template" style="display: none"> | ||
<p>This bug report was made from the Hackasaurus Web X-Ray Goggles (commit <code><a class="commit"></a></code> / built <span class="build-date"></span>) on <span class="timestamp"></span>.</p> | ||
<p>The goggles were activated on <a class="original-url"></a> from a browser with <code>User-Agent</code> string <code class="user-agent"></code>.</p> | ||
<p>The user had the following comments.</p> | ||
<pre class="description" style="white-space: pre-wrap"></pre> | ||
</div> | ||
</div> | ||
<script src="jquery.min.js"></script> | ||
<script src="yepnope.1.0.2-min.js"></script> | ||
<script src="src/localization.js"></script> | ||
<script> | ||
function DeferredTimeout(ms) { | ||
var deferred = jQuery.Deferred(); | ||
|
||
setTimeout(function() { deferred.resolve(); }, ms); | ||
return deferred; | ||
} | ||
|
||
function DeferredPublish(html, originalURL, hackpubURL) { | ||
return jQuery.ajax({ | ||
type: 'POST', | ||
url: hackpubURL + "publish", | ||
data: { | ||
'html': html, | ||
'original-url': originalURL | ||
}, | ||
crossDomain: true, | ||
dataType: 'json' | ||
}); | ||
} | ||
|
||
function makeBugReportHTML(buildMetadata, originalURL) { | ||
var BASE_GITHUB_URL = "https://github.com/hackasaurus/webxray/commit/"; | ||
var report = $("#bug-report-template"); | ||
report.find("a.commit") | ||
.attr("href", BASE_GITHUB_URL + buildMetadata.commit) | ||
.text(buildMetadata.commit.slice(0, 10)); | ||
report.find(".build-date").text(buildMetadata.date); | ||
report.find(".timestamp").text((new Date()).toString()); | ||
report.find("a.original-url") | ||
.attr("href", originalURL) | ||
.text(originalURL); | ||
report.find(".user-agent").text(navigator.userAgent); | ||
report.find(".description").text($("#bug-description").val()); | ||
return report.html(); | ||
} | ||
|
||
function setupUI(buildMetadata, originalURL, hackpubURL) { | ||
$(".to-internet.big-button").click(function() { | ||
$("#choose-publish-method").fadeOut(function() { | ||
$("#to-internet").fadeIn(function() { | ||
var html = makeBugReportHTML(buildMetadata, originalURL); | ||
var timeout = DeferredTimeout(1000); | ||
var publish = DeferredPublish(html, originalURL, hackpubURL); | ||
jQuery.when(publish, timeout).then( | ||
function onSuccess(publishArgs) { | ||
$("#to-internet .loading").fadeOut(function() { | ||
var data = publishArgs[0]; | ||
var url = data['published-url']; | ||
$(".published-url a").attr("href", url).text(url); | ||
$("#to-internet .finished").fadeIn(); | ||
}); | ||
}, | ||
function onFailure() { | ||
$("#to-internet .failure").fadeIn(); | ||
} | ||
); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
function init(buildMetadata, originalURL, hackpubURL) { | ||
var ppxURL = "http://toolness.github.com/postmessage-proxied-xhr/"; | ||
|
||
yepnope({ | ||
test: jQuery.support.cors, | ||
nope: [ppxURL + 'ppx.min.js', ppxURL + 'ppx.jquery.min.js'], | ||
complete: function() { | ||
if (!jQuery.support.cors) | ||
jQuery.proxyAjaxThroughPostMessage(hackpubURL + 'ppx-server'); | ||
setupUI(buildMetadata, originalURL, hackpubURL); | ||
} | ||
}); | ||
} | ||
|
||
function loadLocalization(languages, cb) { | ||
jQuery.localization.loadLocale({ | ||
languages: languages, | ||
path: "src/locale/", | ||
complete: function(locale) { | ||
$(document.body).localize(locale, "bug-report-dialog"); | ||
cb(); | ||
} | ||
}); | ||
} | ||
|
||
if (top === self) { | ||
// We're not in an iframe, so we're being used for development. | ||
$(window).ready(function() { | ||
var buildMetadata = { | ||
"date": "Wed Mar 21 10:28:59 2012", | ||
"commit": "f677d13c9595d62b0e68f8943c446d8e8adb692a" | ||
}; | ||
loadLocalization(["en", "es"], function() { | ||
init(buildMetadata, "http://foo.com/", | ||
"http://hackpub.hackasaurus.org/buckets/webxray-bugs/"); | ||
}); | ||
}); | ||
} else | ||
window.addEventListener("message", function(event) { | ||
$("#close").click(function() { | ||
window.parent.postMessage("close", "*"); | ||
}); | ||
var data = JSON.parse(event.data); | ||
loadLocalization(data.languages, function() { | ||
init(data.buildMetadata, data.originalURL, data.hackpubURL); | ||
}); | ||
}, false); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters