Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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...
commit f2b74af064a7eebacd4502bbc6653911bb994350 1 parent f677d13
@toolness toolness authored
View
1  config.json
@@ -34,6 +34,7 @@
, "src/settings.local.js"
, "src/utils.js"
, "src/uproot.js"
+ , "src/bug-report.js"
, "src/tag-colors.js"
, "src/event-emitter.js"
, "src/focused-overlay.js"
View
20 src/bug-report.js
@@ -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);
View
8 src/input.js
@@ -385,6 +385,14 @@
}
},
{
+ key: 'B',
+ cmd: 'bug-report',
+ alwaysInToolbar: true,
+ execute: function() {
+ jQuery.openBugReportDialog(self);
+ }
+ },
+ {
key: 'P',
cmd: 'uproot',
alwaysInToolbar: true,
View
2  src/settings.js
@@ -24,7 +24,9 @@
preferencesURL: "preferences.html",
easyRemixDialogURL: "easy-remix-dialog/index.html",
uprootDialogURL: "uproot-dialog.html",
+ bugReportDialogURL: "bug-report-dialog.html",
hackpubURL: "http://hackpub.hackasaurus.org/",
+ bugReportHackpubURL: "http://hackpub.hackasaurus.org/buckets/webxray-bugs/",
hackpubInjectionURL: "published-hack/injector.js",
pluginURLs: []
};
View
205 static-files/bug-report-dialog.html
@@ -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>
View
15 static-files/strings.json
@@ -52,6 +52,15 @@
"success": "Here is the URL for your remix that anyone can view.",
"html-source": "Here's the HTML source code of your remix."
},
+ "bug-report-dialog": {
+ "header": "Report A Bug",
+ "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.",
+ "to-internet": "Publish To Internet",
+ "to-internet-desc": "Instantly publish your bug to a URL that anyone can view.",
+ "publishing": "Publishing...",
+ "error": "Sorry, an error occurred. Please try again later.",
+ "success": "Here is the URL for your bug that anyone can view."
+ },
"style-info": {
"tap-space-html": "Tap <div class=\"webxray-kbd\">space bar</div> to edit this style.",
"style-change": "style change"
@@ -75,7 +84,8 @@
"redo": "Redo",
"dom-ascend": "Ascend to parent element",
"dom-descend": "Descend to child element",
- "uproot": "Publish your remix"
+ "uproot": "Publish your remix",
+ "bug-report": "Report a bug"
},
"short-command-descriptions": {
"help": "help",
@@ -87,6 +97,7 @@
"redo": "redo",
"dom-ascend": "ascend",
"dom-descend": "descend",
- "uproot": "publish"
+ "uproot": "publish",
+ "bug-report": "report bug"
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.