Skip to content

Commit

Permalink
Merge pull request QasimWani#2 from QasimWani/dev
Browse files Browse the repository at this point in the history
Merge upstream dev
  • Loading branch information
Jeremy Tsai authored Dec 2, 2020
2 parents 203b6cb + c8cf9a5 commit 52b24e8
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 18 deletions.
17 changes: 1 addition & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<a href="https://twitter.com/intent/tweet?text=LeetHub%20-%20Automatically%20sync%20your%20code%20to%20GitHub%20after%20solving%20any%20leetcode%20problems!&url=https://github.com/QasimWani/LeetHub&hashtags=javascript,github,leetcode,coding,interview,chrome"> <img src="https://img.shields.io/twitter/url/http/shields.io.svg?style=social"> </a>
</p>

## Top 10 Trending JavaScript Repositories
## Top 5 Trending JavaScript Repositories


### Available on:
Expand Down Expand Up @@ -76,21 +76,6 @@ And that's what LeetHub is supposed to do: indirectly improving your coding skil

<ol>
<li>Fork this repo</li>
<li>
Add dev credentials (note this is unstable and can be removed at any time. Create your own for stability, don't use in production!) in <a href="scripts/oauth2.js#L6">oauth2.js</a> and <a href="scripts/authorize.js#L13">authorize.js</a> to enable web auth using GitHub API.

```javascript

this.KEY = "leethub_token";
this.ACCESS_TOKEN_URL = "https://github.com/login/oauth/access_token";
this.AUTHORIZATION_URL = "https://github.com/login/oauth/authorize";
this.CLIENT_ID = "beb4f0aa19ab8faf5004";
this.CLIENT_SECRET = "843f835609c7ef02ef0f2f1645bc49514c0e65a6";
this.REDIRECT_URL = "https://github.com/"; //for example, https://github.com
this.SCOPES = ['repo'];

```
</li>
<li>Go to <a href="chrome://extensions">chrome://extensions</a> </li>
<li>Enable <a href="https://www.mstoic.com/enable-developer-mode-in-chrome/">Developer mode</a> by toggling the switch on top right corner</li>
<li>Click 'Load unpacked'</li>
Expand Down
Binary file modified assets/extension/top_trending.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions css/welcome.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ body {
margin-bottom: 0px;
}

#unlink
{
font-family: "Norwester", "Helvetica Neue", "Lucida Grande", sans-serif;
font-size: 1.1em;
font-weight: normal !important;
color: green !important;
margin-bottom: 0px;
}

p
{
color: white !important;
Expand All @@ -53,4 +62,5 @@ body {
a
{
color: white !important;
cursor: pointer;
}
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name" : "LeetHub",
"description" : "Automatically integrate your code with LeetCode and GitHub",
"homepage_url": "https://github.com/QasimWani/LeetHub",
"version" : "0.0.6",
"version" : "0.0.8",
"author" : "Qasim Wani",
"browser_action": {
"default_icon": "assets/thumbnail.png",
Expand Down Expand Up @@ -33,4 +33,4 @@
}
],
"content_security_policy": "script-src 'self' https://code.jquery.com/jquery-3.3.1.min.js https://github.com/login/oauth/authorize https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.js; object-src 'self'"
}
}
23 changes: 23 additions & 0 deletions scripts/welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ $("#hook_button").on('click', ()=>{
}
});

$("#unlink a").on('click', () => {
unlink_repo();
$("#unlink").hide();
$("#success").text("Successfully unlinked your current git repo. Please create/link a new hook.");
});

/* Detect mode type */
chrome.storage.sync.get("mode_type", data=>{
const mode = data.mode_type;
Expand Down Expand Up @@ -202,6 +208,7 @@ var link_repo = (token, name)=>{
$("#error").hide();
$("#success").html(`Successfully linked <a target="blank" href="${res['html_url']}">${name}</a> to LeetHub. Start <a href="http://leetcode.com">LeetCoding</a> now!`);
$("#success").show();
$("#unlink").show();
});
/* Set Repo Hook */
chrome.storage.sync.set({"leethub_hook": res['full_name']}, data=>{
Expand Down Expand Up @@ -229,6 +236,21 @@ var link_repo = (token, name)=>{
xhr.send();
}

var unlink_repo = () => {
/* Set mode type to hook */
chrome.storage.sync.set({ "mode_type": "hook" }, data => {
console.log(`Unlinking repo`);
});
/* Set Repo Hook to NONE */
chrome.storage.sync.set({ "leethub_hook": null }, data => {
console.log("Defaulted repo hook to NONE");
});

/* Hide accordingly */
document.getElementById("hook_mode").style.display = "inherit";
document.getElementById("commit_mode").style.display = "none";
}

/* Status codes for linking of repo */
var link_status_code = (status, name)=>{
let bool = false;
Expand Down Expand Up @@ -298,6 +320,7 @@ var status_code = (res, status, name)=>{
$("#error").hide();
$("#success").html(`Successfully created <a target="blank" href="${res['html_url']}">${name}</a>. Start <a href="http://leetcode.com">LeetCoding</a>!`);
$("#success").show();
$("#unlink").show();
/* Show new layout */
document.getElementById("hook_mode").style.display = "none";
document.getElementById("commit_mode").style.display = "inherit";
Expand Down
3 changes: 3 additions & 0 deletions welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
<br><br><br><br><br><br><br><br>
<p hidden id="error"></p>
<p hidden id="success"></p>
<p hidden id="unlink">
Linked the wrong repo? <a>Unlink</a>.
</p>
</div>

<!-- Create Hook -->
Expand Down

0 comments on commit 52b24e8

Please sign in to comment.