-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.js
38 lines (32 loc) · 1.02 KB
/
run.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
$(function () {
chrome.storage.sync.get(['spaceKey', 'apiKey', 'issueIdOrKey'], function (data) {
run(data);
});
});
function run(data) {
var Backlog = {
endpoint: 'https://' + data.spaceKey + '.backlog.jp/api/v2',
api_key: data.apiKey,
callApi: function (api) {
var url = this.endpoint + api + '?apiKey=' + this.api_key;
return $.ajax({
url: url,
timeout: 3000,
cache: false,
dataType: 'json'
});
},
getIssue: function (issueId) {
var path = '/issues/' + issueId;
return this.callApi(path);
}
};
var $title = $('input[name="issue.summary"]');
var $desc = $('textarea[name="issue.description"]');
Backlog.getIssue(data.issueIdOrKey).done(function (response) {
$title.val('3ヶ月後に見ても分かるタイトルを書きましょう');
$desc.val(response.description);
}).fail(function (XMLHttpRequest, textStatus) {
console.error('Error: ' + textStatus);
});
}