Skip to content

Commit a900f7d

Browse files
committed
version 0.1.0
1 parent 360b7ae commit a900f7d

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@
44
## 設定方法
55
* <chrome://extensions/> を開く
66
* 「パッケージ化されていない拡張機能を読み込みます」のボタンを押す
7-
* 解凍したフォルダを読み込んで完了
7+
* 解凍したフォルダを読み込んで完了
8+
9+
# Source code
10+
<https://github.com/tomotomo/backlog-template>

options.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<meta http-equiv="X-UA-Compatible" content="ie=edge">
77
<title>Option settings</title>
8+
<style media="screen">
9+
#message {
10+
display: none;
11+
padding: 4px;
12+
}
13+
#message.success {
14+
color: #4F8A10;
15+
background-color: #DFF2BF;
16+
}
17+
</style>
818
<script src="jquery-3.1.0.min.js"></script>
919
<script src="options.js"></script>
1020
</head>
@@ -18,5 +28,6 @@
1828
<dd><input type="text" name="issueIdOrKey" id="issueIdOrKey"></dd>
1929
</dl>
2030
<p><input type="button" value="Save" id="save"></p>
31+
<p id="message" class="success"></p>
2132
</body>
2233
</html>

options.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ $(function () {
77
$('#issueIdOrKey').val(data.issueIdOrKey);
88
});
99

10-
var key = 'backlog-template';
1110
var vals = {};
1211
$('#save').on('click', function () {
1312
vals = {
1413
spaceKey: $('#spaceKey').val(),
1514
apiKey: $('#apiKey').val(),
1615
issueIdOrKey: $('#issueIdOrKey').val()
1716
};
18-
console.log(vals);
17+
1918
chrome.storage.sync.set(vals, function () {
20-
console.log('Options are saved', vals);
19+
console.log('Options saved', vals);
20+
$('#message').text('Options saved!!').show();
2121
});
2222
});
2323

run.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
$(function () {
22
chrome.storage.sync.get(['spaceKey', 'apiKey', 'issueIdOrKey'], function (data) {
3-
console.log(data);
3+
run(data);
44
});
5-
// TODO localStorageの設定データが全部取得できたら実行する。
6-
run();
75
});
86

9-
function run() {
7+
function run(data) {
108

119
var Backlog = {
12-
endpoint: 'https://*.backlog.jp/api/v2',
13-
api_key: 'YOUR_API_KEY',
10+
endpoint: 'https://' + data.spaceKey + '.backlog.jp/api/v2',
11+
api_key: data.apiKey,
1412

1513
callApi: function (api) {
1614
var url = this.endpoint + api + '?apiKey=' + this.api_key;
@@ -28,14 +26,13 @@ function run() {
2826
}
2927
};
3028

31-
3229
var $title = $('input[name="issue.summary"]');
3330
var $desc = $('textarea[name="issue.description"]');
34-
Backlog.getIssue('ISSUE_ID').done(function (data) {
31+
Backlog.getIssue(data.issueIdOrKey).done(function (response) {
3532
$title.val('3ヶ月後に見ても分かるタイトルを書きましょう');
36-
$desc.val(data.description);
33+
$desc.val(response.description);
3734
}).fail(function (XMLHttpRequest, textStatus) {
38-
console.error('Error Backlog.call function:' + textStatus);
35+
console.error('Error: ' + textStatus);
3936
});
4037

4138
}

0 commit comments

Comments
 (0)