Skip to content

Commit cb670b5

Browse files
committed
First shot at a 'community tickets' feed fetched from JIRA.
1 parent 830f229 commit cb670b5

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

contribute/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ Typically the scaladoc tool provides a low entry point for new committers, so it
4444

4545
On the Scala bug tracker you will find many bugs that are [marked as good starting points to contributing ("community" bugs)](https://issues.scala-lang.org/secure/IssueNavigator.jspa?requestId=12111) or [that are not currently assigned](https://issues.scala-lang.org/secure/IssueNavigator.jspa?requestId=12112) and that you could pick up. Once you decided on a ticket to look at, see the next step on how to proceed further.
4646

47+
<div id="communitytickets"></div>
48+
4749
<br/>
4850

4951
### I have this idea that I'd like to add to Scala, how do I start?

resources/js/main.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,73 @@ $(document).ready(function(){
208208
});
209209

210210
});
211+
212+
/**************************
213+
* Community tickets feed *
214+
**************************/
215+
216+
$(document).ready(function(){
217+
var $communityTicketsDiv = $('#communitytickets');
218+
219+
// Stop early if the element does not exist
220+
if ($communityTicketsDiv.length == 0)
221+
return;
222+
223+
function escapeHTML(text) {
224+
return text
225+
.replace(/&/g, "&amp;")
226+
.replace(/</g, "&lt;")
227+
.replace(/>/g, "&gt;")
228+
.replace(/"/g, "&quot;")
229+
.replace(/'/g, "&#039;");
230+
}
231+
232+
function doPopulateTicketsPane(data) {
233+
var headerContent =
234+
'<ul>'+
235+
'<li>Start at: '+data.startAt+'</li>'+
236+
'<li>Max results: '+data.maxResults+'</li>'+
237+
'<li>Total: '+data.total+'</li>'+
238+
'</ul>';
239+
$("#communitytickets").append(headerContent);
240+
241+
var issues = data.issues;
242+
for (i = 0; i < issues.length; i++) {
243+
var issue = issues[i];
244+
var fields = issue.fields;
245+
var thisContent =
246+
'<hr /><div class="tickets-item">' +
247+
'<div class="tickets-title"><a href="https://issues.scala-lang.org/browse/'+issue.key+'">'+escapeHTML(fields.summary)+'</a></div>' +
248+
'<div class="tickets-issuetype"><img src="'+fields.issuetype.iconUrl+'" /> '+escapeHTML(fields.issuetype.name)+'</div>' +
249+
'<div class="tickets-priority"><img src="'+fields.priority.iconUrl+'" /> '+escapeHTML(fields.priority.name)+'</div>' +
250+
'<div class="tickets-components">'+fields.components.map(function (component) {
251+
return '<a href="https://issues.scala-lang.org/browse/SI/component/'+component.id+'">'+escapeHTML(component.name)+'</a>';
252+
}).join(', ')+'</div>'+
253+
'<div class="tickets-description">'+escapeHTML(fields.description)+'</div>'+
254+
//'<div class="tickets-data"><pre>'+JSON.stringify(issue, undefined, 2)+'</pre></div>' +
255+
'</div>';
256+
$("#communitytickets").append(thisContent);
257+
}
258+
};
259+
260+
function onAjaxSuccess(response, textStatus, jqXHR) {
261+
doPopulateTicketsPane(response);
262+
}
263+
264+
function onAjaxError(jqXHR, textStatus, errorThrown) {
265+
// log the error to the console
266+
console.error(
267+
"Could not load community tickets from JIRA: " + textStatus, errorThrown);
268+
}
269+
270+
$.ajax({
271+
url: "https://issues.scala-lang.org/rest/api/2/search?jql=project+in+%28SI,SUGGEST%29+AND+status+%3D+Open+AND+labels+%3D+community+ORDER+BY+component",
272+
type: "GET",
273+
dataType: "jsonp",
274+
jsonp: 'jsonp-callback',
275+
crossDomain: true,
276+
success: onAjaxSuccess,
277+
error: onAjaxError
278+
});
279+
280+
});

0 commit comments

Comments
 (0)