cleanups and fixes

This commit is contained in:
abhijithvijayan
2019-01-11 20:43:45 +05:30
parent 652c7a6682
commit 270b87d29f
5 changed files with 18 additions and 33 deletions

View File

@@ -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 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 faith may face temporary or permanent repercussions as determined by other
members of the project's leadership. 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

View File

@@ -8,7 +8,7 @@
- `npm install` to install dependencies. - `npm install` to install dependencies.
- `npm run dev` to to watch file changes in developement - `npm run dev` to to watch file changes in developement
- (Reload Extension Manually in the browser) - (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) - 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`. - Paste and Save the `Key` in extension's `options page`.
@@ -21,9 +21,9 @@ Download latest `Pre-Release`
alt="Direct download" alt="Direct download"
height="50">](https://github.com/abhijithvijayan/kuttUrl-browser-extension/releases) 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 - [ ] Fix UI issues in Firefox
- [ ] Using Node-Kutt package(feature request) - [ ] Using Node-Kutt package(feature request)

View File

@@ -6,7 +6,7 @@ async function getShortURL(API_key, URLtoShorten, password) {
let shortLink; let shortLink;
const api_url = 'https://kutt.it/api/url/submit'; const api_url = 'https://kutt.it/api/url/submit';
try { try {
const rawData = await axios({ const json = await axios({
method: "POST", method: "POST",
url: api_url, url: api_url,
headers: { headers: {
@@ -17,12 +17,11 @@ async function getShortURL(API_key, URLtoShorten, password) {
password: password password: password
} }
}); });
shortLink = rawData.data.shortUrl; shortLink = json.data.shortUrl;
// returns the promise // returns the promise
return shortLink; return shortLink;
} catch (error) { }
// https://gist.github.com/fgilio/230ccd514e9381fafa51608fcf137253 catch (error) {
if (error.response) { if (error.response) {
console.log(error.response.data); console.log(error.response.data);
console.log(error.response.status); console.log(error.response.status);
@@ -40,7 +39,7 @@ async function getShortURL(API_key, URLtoShorten, password) {
// Calling function // Calling function
browser.runtime.onMessage.addListener(async (request, sender, response) => { browser.runtime.onMessage.addListener(async (request, sender, response) => {
if(request.msg == "start") { if (request.msg == "start") {
// consume the promise // consume the promise
return getShortURL(request.API_key, request.pageUrl, request.password) return getShortURL(request.API_key, request.pageUrl, request.password)
.then(shortLink => { .then(shortLink => {

View File

@@ -21,13 +21,12 @@ let saveData = () => {
let API_KEY = document.getElementById('api__key--value').value; let API_KEY = document.getElementById('api__key--value').value;
let password = document.getElementById('password--value').value; let password = document.getElementById('password--value').value;
if(!password) { // if(!password) {
// console.log("No password Set"); // console.log("No password Set");
} // }
// store value locally // store value locally
browser.storage.local.set({key: API_KEY, pwd: password}).then(() => { browser.storage.local.set({key: API_KEY, pwd: password}).then(() => {});
// console.log('API Key set to ' + API_KEY);
});
// Saved Alert // Saved Alert
let element = document.querySelector('.saved__alert'); let element = document.querySelector('.saved__alert');
@@ -46,13 +45,13 @@ document.getElementById('button__submit').addEventListener('click', () => {
// on enter key press // on enter key press
document.addEventListener('keypress', (e) => { document.addEventListener('keypress', (e) => {
if(e.keyCode === 13) { if (e.keyCode === 13) {
saveData(); saveData();
} }
}); });
// Show Password Function // Show Password
document.getElementById('password__view--checkbox').addEventListener('click', () => { document.getElementById('password__view--checkbox').addEventListener('click', () => {
let element = document.getElementById('password--value'); let element = document.getElementById('password--value');
if (element.type === "password") { if (element.type === "password") {

View File

@@ -26,8 +26,6 @@ document.addEventListener('DOMContentLoaded', () => {
// store the shortened link // store the shortened link
shortUrl = response; shortUrl = response;
document.getElementById('url__content-inner').textContent = "Error!!";
// invalid response // invalid response
if (shortUrl === null) { if (shortUrl === null) {
document.getElementById('url__content-inner').textContent = "Invalid Response!"; document.getElementById('url__content-inner').textContent = "Invalid Response!";
@@ -50,10 +48,10 @@ document.addEventListener('DOMContentLoaded', () => {
} }
else if (API_key === '' || API_key === undefined) { else if (API_key === '' || API_key === undefined) {
// no api key set // 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 { else {
document.getElementById('url__content-inner').textContent = 'Error!!!'; document.getElementById('url__content-inner').textContent = 'Unknown Error!!!';
} }
}); });
@@ -92,7 +90,6 @@ document.addEventListener('DOMContentLoaded', () => {
// 4. QR Code // 4. QR Code
document.getElementById('button__qrcode').addEventListener('click', () => { document.getElementById('button__qrcode').addEventListener('click', () => {
// document.getElementById('button__qrcode').style = "display: none;";
toggleDisplay('.qrcode__content--holder'); toggleDisplay('.qrcode__content--holder');
}); });