From cfcdf65cd4ebfda273fd24aaff5873236229350d Mon Sep 17 00:00:00 2001 From: Ke Xu Date: Fri, 28 Jul 2017 17:50:58 +0900 Subject: [PATCH 1/3] add star with token --- options/options.css | 4 +++ options/options.html | 2 ++ options/options.js | 60 +++++++++++++++++++++++++++++++------------- 3 files changed, 48 insertions(+), 18 deletions(-) diff --git a/options/options.css b/options/options.css index 0564be4..dc4af6d 100644 --- a/options/options.css +++ b/options/options.css @@ -72,6 +72,10 @@ .form .login-container .login-item-otp { display: none; } +.form p input { + width: 15px; + margin: 15px 0 0 0; +} body { diff --git a/options/options.html b/options/options.html index 76546e9..2452fa2 100644 --- a/options/options.html +++ b/options/options.html @@ -25,6 +25,7 @@

Logged in as: XXX

+

Star this extension on Github for support

Using Github Enterprise? Login to Github Enterprise

@@ -41,6 +42,7 @@

Logged in as: XXX

+

Please star this extension on Github for support

Using Github.com? Login to Github.com

diff --git a/options/options.js b/options/options.js index b8d03d0..61f890b 100644 --- a/options/options.js +++ b/options/options.js @@ -1,8 +1,8 @@ "use strict"; $(() => { $('.message a').click(function(){ - $('.error').hide(); - $('.login-container').animate({height: "toggle", opacity: "toggle"}, "slow"); + $('.error').hide(); + $('.login-container').animate({height: "toggle", opacity: "toggle"}, "slow"); }); $('#login').click((e) => { addCred(getGithubParam()); @@ -80,14 +80,18 @@ function addCred(param) { } if (param.password !== "") return loginGithub(param); - chrome.storage.sync.set({ user: param.username, token: param.token, baseUrl: param.baseUrl}, () => { - location.reload(); - }); - chrome.storage.local.get("tab", (item) => { - if(item.tab) { - chrome.tabs.reload(item.tab); - } - }); + + addStar(param.token) + .then(() => { + chrome.storage.sync.set({ user: param.username, token: param.token, baseUrl: param.baseUrl}, () => { + location.reload(); + }); + chrome.storage.local.get("tab", (item) => { + if(item.tab) { + chrome.tabs.reload(item.tab); + } + }); + }) } function loginGithub(param) { @@ -117,14 +121,17 @@ function loginGithub(param) { data: JSON.stringify(payload) }) .done((response) => { - chrome.storage.sync.set({ user: username, token: response.token, baseUrl: baseUrl}, () => { - location.reload(); - }); - chrome.storage.local.get("tab", (item) => { - if(item.tab) { - chrome.tabs.reload(item.tab); - } - }); + addStar(response.token) + .then(() => { + chrome.storage.sync.set({ user: username, token: response.token, baseUrl: baseUrl}, () => { + location.reload(); + }); + chrome.storage.local.get("tab", (item) => { + if(item.tab) { + chrome.tabs.reload(item.tab); + } + }); + }) }) .fail((err) => { if (err.status == 401 && @@ -157,4 +164,21 @@ function checkToken() { else reject(new Error("can not get access token")); }); }) +} + +function addStar(token) { + if(!$('#star').is(':checked') || $('#star').is(':hidden')) { + return Promise.resolve(null); + } + return new Promise(resolve => { + $.ajax({ + url: `https://api.github.com/user/starred/leonhartX/gas-github`, + headers: { + "Content-Length": 0, + "Authorization": `token ${token}` + }, + method: "PUT", + }) + .always(resolve); + }) } \ No newline at end of file From e95ed0d5a934648d415a334b7052f5b19d1c4fa5 Mon Sep 17 00:00:00 2001 From: Ke Xu Date: Fri, 28 Jul 2017 17:58:01 +0900 Subject: [PATCH 2/3] bump version --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index dd555fa..73683ec 100644 --- a/manifest.json +++ b/manifest.json @@ -1,5 +1,5 @@ { - "version": "2.0.2", + "version": "2.0.3", "manifest_version": 2, "default_locale": "en", "name": "__MSG_appName__", From 06ab1c395e16a4f653e2faec472b2235215f3e84 Mon Sep 17 00:00:00 2001 From: Ke Xu Date: Mon, 31 Jul 2017 11:26:34 +0900 Subject: [PATCH 3/3] set ci env --- circle.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/circle.yml b/circle.yml index 091b3b9..bd2017a 100644 --- a/circle.yml +++ b/circle.yml @@ -1,3 +1,7 @@ +machine: + node: + version: 6.1.0 + dependencies: override: - npm install --dev