Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
hzoo committed Mar 19, 2016
1 parent 8a64611 commit 1b53169
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
22 changes: 11 additions & 11 deletions src/auth.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* global chrome, queryString, getSyncStorage, setSyncStorage */

const client_id = "1a3ac4d44a9e65a75a77";
const client_secret = "ab3c3a116e35d9fe11d409cb8c1205e9ae5a7e91";
const githubBaseUrl = "https://github.com/login/oauth/authorize";
const githubTokenUrl = "https://github.com/login/oauth/access_token";
const redirectUri = chrome.identity.getRedirectURL('provider_cb');

console.log(redirectUri);
const redirectUri = chrome.identity.getRedirectURL("provider_cb");

const getAuthUrl = (base, callbackUrl, scope) => {
let obj = {
Expand All @@ -15,7 +15,7 @@ const getAuthUrl = (base, callbackUrl, scope) => {
};

return `${base}?${queryString.stringify(obj)}`;
}
};

function getTokenFromCode(code) {
let obj = {
Expand All @@ -25,7 +25,7 @@ function getTokenFromCode(code) {
};

return fetch(`${githubTokenUrl}?${queryString.stringify(obj)}`)
.then((res) => res.text(), (err) => {
.then((res) => res.text(), () => {
throw new Error("Failed to get access_token");
});
}
Expand Down Expand Up @@ -62,29 +62,29 @@ function getToken(url, interactive) {
resolve(access_token);
});
} else {
reject(new Error ('neither access_token nor code available'));
reject(new Error ("neither access_token nor code available"));
}
} else {
reject(new Error('Invalid redirect URI'));
reject(new Error("Invalid redirect URI"));
}
});
});
}

function getTokenFromOauth() {
getSyncStorage({ 'access_token': null })
getSyncStorage({ "access_token": null })
.then((res) => {
if (!res.access_token) {
const url = getAuthUrl(githubBaseUrl, redirectUri, 'public_repo');
const url = getAuthUrl(githubBaseUrl, redirectUri, "public_repo");
getToken(url, true)
.then((token) => {
setSyncStorage({ 'access_token': token });
setSyncStorage({ "access_token": token });
const accessTokenInput = document.getElementById("token-input");
accessTokenInput.value = token;
document.querySelector("#feedback").textContent = "Access Token Set!";
}, (message) => {
document.querySelector("#feedback").textContent = message;
})
});
} else {
document.querySelector("#feedback").textContent = "Access Token Already Set!";
}
Expand Down
10 changes: 5 additions & 5 deletions src/content.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"use strict";

/* global chrome, getSyncStorage, setStorage, getStorage */
/* global $, getSyncStorage, setStorage, getStorage, gitHubInjection */

const isPR = (path) => /^\/[^/]+\/[^/]+\/pull\/\d+/.test(path);
const isIssue = (path) => /^\/[^/]+\/[^/]+\/issues\/\d+/.test(path);
const getCurrentUser = () => $('.js-menu-target img').attr('alt').slice(1) || "";
const isPrivate = () => $('.repo-private-label').length > 0;
const getCurrentUser = () => $(".js-menu-target img").attr("alt").slice(1) || "";
const isPrivate = () => $(".repo-private-label").length > 0;

function getContributor() {
let $contributor = $(".timeline-comment-wrapper .timeline-comment-header-text strong");
Expand All @@ -24,7 +24,7 @@ function getContributorInfo() {
let contributor = getContributor();

let ret = {
contributor: getContributor(),
contributor,
currentNum,
repoPath
};
Expand Down Expand Up @@ -217,6 +217,6 @@ document.addEventListener("DOMContentLoaded", () => {
if (getContributor()) {
update(getContributorInfo());
}
};
}
});
});
12 changes: 6 additions & 6 deletions src/options.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global getSyncStorage, setSyncStorage */
/* global getSyncStorage, setSyncStorage, clearSyncStorage, getTokenFromOauth */

document.addEventListener("DOMContentLoaded", () => {
const accessTokenInput = document.getElementById("token-input");
Expand All @@ -16,15 +16,15 @@ document.addEventListener("DOMContentLoaded", () => {

oauthLink.addEventListener("click", () => {
getTokenFromOauth();
})
});

clearCacheLink.addEventListener("click", () => {
let temp = accessTokenInput.value
chrome.storage.sync.clear((res) => {
let temp = accessTokenInput.value;
clearSyncStorage()
.then(() => {
setSyncStorage({ "access_token": temp });

document.querySelector("#feedback").textContent = "Storage Cleared";
});
})
});
});

1 change: 1 addition & 0 deletions src/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function promisify(func) {

window.getSyncStorage = promisify(chrome.storage.sync.get.bind(chrome.storage.sync));
window.setSyncStorage = promisify(chrome.storage.sync.set.bind(chrome.storage.sync));
window.clearSyncStorage = promisify(chrome.storage.sync.clear.bind(chrome.storage.sync));

window.setStorage = (CONTRIBUTOR, ORG_REPO_PATH, value) => {
return window.setSyncStorage({
Expand Down

0 comments on commit 1b53169

Please sign in to comment.