diff --git a/css/option.css b/css/option.css index 64475eb..9fd6dd0 100644 --- a/css/option.css +++ b/css/option.css @@ -9,3 +9,6 @@ input { input#save { width: 250px; } +select { + width: 500px; +} diff --git a/js/myscript.coffee b/js/myscript.coffee index 70a518a..1044808 100644 --- a/js/myscript.coffee +++ b/js/myscript.coffee @@ -14,26 +14,26 @@ $ -> repo = localStorage['repo'] if localStorage['token'] token = localStorage['token'] - if localStorage['labels'] + if localStorage['labels'] isnt '' labelStr = localStorage['labels'] + if localStorage['milestone'] + milestone = localStorage['milestone'] url = tab.url title = tab.title issueTitle = "Read later #{title}" body = "[#{title}](#{url})" + query = { + 'title': issueTitle + 'body': body + 'assignee': user + } if labelStr labels = "#{labelStr}".split ',' - query = JSON.stringify({ - 'title': issueTitle - 'body': body - 'assignee': user - 'labels': labels - }) - else - query = JSON.stringify({ - 'title': issueTitle - 'body': body - 'assignee': user - }) + query.labels = labels + $('.message').text typeof(milestone) + ' : ' + milestone + if milestone isnt '0' + query.milestone = milestone + query = JSON.stringify query url = "https://api.github.com/repos/#{user}/#{repo}/issues?access_token=#{token}" $.ajax 'async': false diff --git a/js/myscript.js b/js/myscript.js index 83c46da..e97a6a4 100644 --- a/js/myscript.js +++ b/js/myscript.js @@ -10,7 +10,7 @@ $(function() { return $(document).on('click', '#issue-button', function() { return ws.getCurrent(function(window) { return tbs.getSelected(window.id, function(tab) { - var body, issueTitle, labelStr, labels, query, repo, title, token, url, user; + var body, issueTitle, labelStr, labels, milestone, query, repo, title, token, url, user; user = ''; repo = ''; token = ''; @@ -23,28 +23,30 @@ $(function() { if (localStorage['token']) { token = localStorage['token']; } - if (localStorage['labels']) { + if (localStorage['labels'] !== '') { labelStr = localStorage['labels']; } + if (localStorage['milestone']) { + milestone = localStorage['milestone']; + } url = tab.url; title = tab.title; issueTitle = "Read later " + title; body = "[" + title + "](" + url + ")"; + query = { + 'title': issueTitle, + 'body': body, + 'assignee': user + }; if (labelStr) { labels = ("" + labelStr).split(','); - query = JSON.stringify({ - 'title': issueTitle, - 'body': body, - 'assignee': user, - 'labels': labels - }); - } else { - query = JSON.stringify({ - 'title': issueTitle, - 'body': body, - 'assignee': user - }); + query.labels = labels; + } + $('.message').text(typeof milestone + ' : ' + milestone); + if (milestone !== '0') { + query.milestone = milestone; } + query = JSON.stringify(query); url = "https://api.github.com/repos/" + user + "/" + repo + "/issues?access_token=" + token; return $.ajax({ 'async': false, diff --git a/js/option.coffee b/js/option.coffee index 30f24a2..56d62c4 100644 --- a/js/option.coffee +++ b/js/option.coffee @@ -1,4 +1,38 @@ $ -> + # Set Milestones + setMilestone = -> + user = localStorage['user'] + repo = localStorage['repo'] + token = localStorage['token'] + milestone = localStorage['milestone'] + if user == null || user == 'Enter the GitHub user name' + user = null + if repo == null || repo == 'Enter the GitHub repositori name' + repo = null + if user && repo + query = JSON.stringify({ + 'state': 'all' + 'sort': 'due_on' + 'direction': 'asc' + }) + url = "https://api.github.com/repos/#{user}/#{repo}/milestones?access_token=#{token}" + $.ajax + 'async': false + 'url': url + 'type': 'get' + 'data': query + 'dataType': 'json' + 'success': (res) -> + $('#milestone option').remove() + $('#milestone').append $('