Skip to content

Commit

Permalink
cleanups and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
abhijithvijayan committed Jan 11, 2019
1 parent 652c7a6 commit 270b87d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 33 deletions.
12 changes: 1 addition & 11 deletions CODE_OF_CONDUCT.md
Expand Up @@ -63,14 +63,4 @@ Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
members of the project's leadership.
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Expand Up @@ -8,7 +8,7 @@
- `npm install` to install dependencies.
- `npm run dev` to to watch file changes in developement
- (Reload Extension Manually in the browser)
- Load extension via as unpacked from `extension/` directory.
- Load extension as unpacked from `extension/` directory.
- Generate an API Key from <a href="https://kutt.it">`https://kutt.it/`</a> (Settings page)
- Paste and Save the `Key` in extension's `options page`.

Expand All @@ -21,9 +21,9 @@ Download latest `Pre-Release`
alt="Direct download"
height="50">](https://github.com/abhijithvijayan/kuttUrl-browser-extension/releases)

## ToDO
## ToDo

- [ ] Switch to Promise return Method
- [x] Switch to Promise return Method
- [ ] Fix UI issues in Firefox
- [ ] Using Node-Kutt package(feature request)

Expand Down
11 changes: 5 additions & 6 deletions src/scripts/background.js
Expand Up @@ -6,7 +6,7 @@ async function getShortURL(API_key, URLtoShorten, password) {
let shortLink;
const api_url = 'https://kutt.it/api/url/submit';
try {
const rawData = await axios({
const json = await axios({
method: "POST",
url: api_url,
headers: {
Expand All @@ -17,12 +17,11 @@ async function getShortURL(API_key, URLtoShorten, password) {
password: password
}
});
shortLink = rawData.data.shortUrl;

shortLink = json.data.shortUrl;
// returns the promise
return shortLink;
} catch (error) {
// https://gist.github.com/fgilio/230ccd514e9381fafa51608fcf137253
}
catch (error) {
if (error.response) {
console.log(error.response.data);
console.log(error.response.status);
Expand All @@ -40,7 +39,7 @@ async function getShortURL(API_key, URLtoShorten, password) {

// Calling function
browser.runtime.onMessage.addListener(async (request, sender, response) => {
if(request.msg == "start") {
if (request.msg == "start") {
// consume the promise
return getShortURL(request.API_key, request.pageUrl, request.password)
.then(shortLink => {
Expand Down
15 changes: 7 additions & 8 deletions src/scripts/options.js
Expand Up @@ -21,13 +21,12 @@ let saveData = () => {
let API_KEY = document.getElementById('api__key--value').value;
let password = document.getElementById('password--value').value;

if(!password) {
// console.log("No password Set");
}
// if(!password) {
// console.log("No password Set");
// }

// store value locally
browser.storage.local.set({key: API_KEY, pwd: password}).then(() => {
// console.log('API Key set to ' + API_KEY);
});
browser.storage.local.set({key: API_KEY, pwd: password}).then(() => {});

// Saved Alert
let element = document.querySelector('.saved__alert');
Expand All @@ -46,13 +45,13 @@ document.getElementById('button__submit').addEventListener('click', () => {

// on enter key press
document.addEventListener('keypress', (e) => {
if(e.keyCode === 13) {
if (e.keyCode === 13) {
saveData();
}
});


// Show Password Function
// Show Password
document.getElementById('password__view--checkbox').addEventListener('click', () => {
let element = document.getElementById('password--value');
if (element.type === "password") {
Expand Down
7 changes: 2 additions & 5 deletions src/scripts/popup.js
Expand Up @@ -26,8 +26,6 @@ document.addEventListener('DOMContentLoaded', () => {
// store the shortened link
shortUrl = response;

document.getElementById('url__content-inner').textContent = "Error!!";

// invalid response
if (shortUrl === null) {
document.getElementById('url__content-inner').textContent = "Invalid Response!";
Expand All @@ -50,10 +48,10 @@ document.addEventListener('DOMContentLoaded', () => {
}
else if (API_key === '' || API_key === undefined) {
// no api key set
document.getElementById('url__content-inner').textContent = 'Set API Key in Settings!';
document.getElementById('url__content-inner').textContent = 'Set API Key in Options!';
}
else {
document.getElementById('url__content-inner').textContent = 'Error!!!';
document.getElementById('url__content-inner').textContent = 'Unknown Error!!!';
}

});
Expand Down Expand Up @@ -92,7 +90,6 @@ document.addEventListener('DOMContentLoaded', () => {

// 4. QR Code
document.getElementById('button__qrcode').addEventListener('click', () => {
// document.getElementById('button__qrcode').style = "display: none;";
toggleDisplay('.qrcode__content--holder');
});

Expand Down

0 comments on commit 270b87d

Please sign in to comment.