This repository has been archived by the owner on Nov 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyourairbrakesubdomain.airbrakeapp.com.js
43 lines (34 loc) · 2.02 KB
/
yourairbrakesubdomain.airbrakeapp.com.js
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
// NOTE: You need dotjs installed to use this: https://github.com/defunkt/dotjs
//
// You must name this file with your airbrakeapp subdomain prepended to the filename.
// Example: So myairbrakesubdomain.airbrakeapp.com.js
var login = "<GITHUB USER NAME>";
var token = "<GITHUB TOKEN>";
var REPO_USER = "<GITHUB REPO USER>";
var REPO_NAME = "<GITHUB REPO NAME>";
var title = $("#notice_heading h2").text();
var link = document.location.href;
var button = $('<a id="lnk-github-issue" href="#" style="font-size:11px;font-weight:normal;margin-left:13px;padding-top:8px;">Create Github Issue</a>');
button.appendTo("#notice_heading h2");
$("#lnk-github-issue").live("click",function(){$("#issue-container").show(); return false;});
$("#lnk-cancel").live("click",function(){$("#issue-container").hide();return false;});
var form_container = $('<div id="issue-container" style="z-index:99999;position:absolute;margin-left:200px;height:330px;width:500px;background-color:#ffffff;border:10px solid #cccccc;padding:10px;display:none;"></div>');
form_container.appendTo("#resolved_toggle");
var f = $('<p><strong>Issue Title</strong><br /><input type="text" id="title" value="'+title+'" size="25" /></p><p><strong>Github Issue Description</strong><br /><textarea id="body" rows="5" cols="20">'+link+'</textarea></p><p><button id="create-github-issue">Send to Github Issues</button> <a id="lnk-cancel" href="#">Cancel</a></p>');
f.appendTo("#issue-container");
$("#create-github-issue").click(function() {
var data = {"token": token, "login": login, "title": $("#title").val(), "body": $("#body").val()}
// prevent accidental double submission
button.attr("disabled", "disabled")
$.ajax({
method: "POST",
data: data,
url: "https://github.com/api/v2/json/issues/open/"+REPO_USER+"/"+REPO_NAME,
success: function() {
$("#lnk-github-issue").html("Issue Created.")
$("#issue-container").hide();
var issueUrl = data['issue']['html_url']
button.after('<a href="'+issueUrl+'" target="_blank">Go to Issue</a>')
}
});
});