|
1 |
| -var confirm_gist = function(confirmation_message) { |
2 |
| - if (!Controller.isFeatureEnabled_("confirmGist")) { |
3 |
| - gistie(); |
4 |
| - return; |
5 |
| - } |
6 |
| - |
7 |
| - // Set optional confirmation_message |
8 |
| - confirmation_message = confirmation_message || "Yes. Paste this commit."; |
9 |
| - var deleteMessage = Controller.getConfig_("github.token") ? " " : "You might not be able to delete it after posting.<br>"; |
10 |
| - var publicMessage = Controller.isFeatureEnabled_("publicGist") ? "<b>public</b>" : "private"; |
11 |
| - // Insert the verification links into div#notification_message |
12 |
| - var notification_text = 'This will create a ' + publicMessage + ' paste of your commit to <a href="http://gist.github.com/">http://gist.github.com/</a><br>' + |
13 |
| - deleteMessage + |
14 |
| - 'Are you sure you want to continue?<br/><br/>' + |
15 |
| - '<a href="#" onClick="hideNotification();return false;" style="color: red;">No. Cancel.</a> | ' + |
16 |
| - '<a href="#" onClick="gistie();return false;" style="color: green;">' + confirmation_message + '</a>'; |
17 |
| - |
18 |
| - notify(notification_text, 0); |
19 |
| - // Hide img#spinner, since it?s visible by default |
20 |
| - $("spinner").style.display = "none"; |
21 |
| -} |
22 |
| - |
23 |
| -var gistie = function() { |
24 |
| - notify("Uploading code to Gistie..", 0); |
25 |
| - |
26 |
| - parameters = { |
27 |
| - "file_ext[gistfile1]": "patch", |
28 |
| - "file_name[gistfile1]": commit.object.subject.replace(/[^a-zA-Z0-9]/g, "-") + ".patch", |
29 |
| - "file_contents[gistfile1]": commit.object.patch(), |
30 |
| - }; |
31 |
| - |
32 |
| - // TODO: Replace true with private preference |
33 |
| - token = Controller.getConfig_("github.token"); |
34 |
| - login = Controller.getConfig_("github.user"); |
35 |
| - if (token && login) { |
36 |
| - parameters.login = login; |
37 |
| - parameters.token = token; |
38 |
| - } |
39 |
| - if (!Controller.isFeatureEnabled_("publicGist")) |
40 |
| - parameters.private = true; |
41 |
| - |
42 |
| - var params = []; |
43 |
| - for (var name in parameters) |
44 |
| - params.push(encodeURIComponent(name) + "=" + encodeURIComponent(parameters[name])); |
45 |
| - params = params.join("&"); |
46 |
| - |
47 |
| - var t = new XMLHttpRequest(); |
48 |
| - t.onreadystatechange = function() { |
49 |
| - if (t.readyState == 4 && t.status >= 200 && t.status < 300) { |
50 |
| - if (m = t.responseText.match(/<a href="\/gists\/([a-f0-9]+)\/edit">/)) |
51 |
| - notify("Code uploaded to gistie <a target='_new' href='http://gist.github.com/" + m[1] + "'>#" + m[1] + "</a>", 1); |
52 |
| - else { |
53 |
| - notify("Pasting to Gistie failed :(.", -1); |
54 |
| - Controller.log_(t.responseText); |
55 |
| - } |
56 |
| - } |
57 |
| - } |
58 |
| - |
59 |
| - t.open('POST', "https://gist.github.com/gists"); |
60 |
| - t.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); |
61 |
| - t.setRequestHeader('Accept', 'text/javascript, text/html, application/xml, text/xml, */*'); |
62 |
| - t.setRequestHeader('Content-type', 'application/x-www-form-urlencoded;charset=UTF-8'); |
63 |
| - |
64 |
| - try { |
65 |
| - t.send(params); |
66 |
| - } catch(e) { |
67 |
| - notify("Pasting to Gistie failed: " + e, -1); |
68 |
| - } |
69 |
| -} |
70 |
| - |
71 | 1 | var selectCommit = function(a) {
|
72 | 2 | Controller.selectCommit_(a);
|
73 | 3 | }
|
74 | 4 |
|
75 |
| -// Relead only refs |
76 |
| -var reload = function() { |
77 |
| - commit.reloadRefs(); |
78 |
| - showRefs(); |
79 |
| -} |
80 |
| - |
81 | 5 | var showImage = function(element, filename)
|
82 | 6 | {
|
83 | 7 | element.outerHTML = '<img src="GitX://' + commit.sha + '/' + filename + '">';
|
84 | 8 | return false;
|
85 | 9 | }
|
86 | 10 |
|
87 |
| -var enableFeature = function(feature, element) |
88 |
| -{ |
89 |
| - if(!Controller || Controller.isFeatureEnabled_(feature)) { |
90 |
| - element.style.display = ""; |
91 |
| - } else { |
92 |
| - element.style.display = "none"; |
93 |
| - } |
94 |
| -} |
95 |
| - |
96 |
| -var enableFeatures = function() |
97 |
| -{ |
98 |
| - enableFeature("gist", $("gist")) |
99 |
| -} |
100 |
| - |
101 |
| - |
102 | 11 | var showDiff = function(data){
|
103 | 12 | $("diff").innerHTML=data;
|
104 |
| - enableFeatures(); |
105 | 13 | }
|
106 | 14 |
|
0 commit comments