-
Notifications
You must be signed in to change notification settings - Fork 0
/
PTRetriever.html
69 lines (59 loc) · 1.87 KB
/
PTRetriever.html
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Access the Pivotal Tracker API via CORS</title>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js'
type='text/javascript'></script>
</head>
<body>
<form>
<p>
<label for='token'>User API Token:</label>
<input type='text' id='token' />
</p><p>
<label for='project_id'>ID Number of Pivotal Tracker Project:</label>
<input type='text' id='project_id' />
</p>
</form>
<a href='#' id='doit_link'>Fetch Story Names from Project</a>
<div style='margin:40px'>
<p id='result_title'></p>
<ul id='result_area'>
</ul>
</div>
<script type="text/javascript">
var projectId;
function executeTrackerApiFetch() {
// get parameters
var token = $('#token').val();
projectId = $('#project_id').val();
// compose request URL
var url = 'https://www.pivotaltracker.com/services/v5';
url += '/projects/' + projectId;
url += '/stories?filter=state:delivered,finished,rejected,started';
url += ',unstarted,unscheduled';
url += '&limit=20';
// do API request to get story names
$.ajax({
url: url,
beforeSend: function(xhr) {
xhr.setRequestHeader('X-TrackerToken', token);
}
}).done(displayTrackerApiResponse);
}
function displayTrackerApiResponse(stories) {
$('#result_title').html('Unaccepted stories from Project #' + projectId + ' (up to the first 20)');
var html = '';
for (var i=0; i < stories.length;i++) {
html += '<li>' + stories[i].name + '</li>';
}
$('#result_area').html(html);
}
$(function() {
$('#doit_link').click(executeTrackerApiFetch);
});
</script>
</body>
</html>
If you are going to load this example HTML i