Added comments
This commit is contained in:
parent
4fb608a955
commit
acb7b4135f
23
main.js
23
main.js
|
@ -11,14 +11,17 @@ clipboard.on('success', function (e) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
//Set default url
|
//Set default url as current tab
|
||||||
// chrome.tabs.query({ active: true, lastFocusedWindow: true }, tabs => {
|
chrome.tabs.query({ active: true, lastFocusedWindow: true }, tabs => {
|
||||||
// document.getElementById("target").value = tabs[0].url;
|
document.getElementById("target").value = tabs[0].url;
|
||||||
// });
|
});
|
||||||
document.getElementById("target").value = "google.com";
|
|
||||||
|
|
||||||
// Calls the api to create a new short url
|
// Create button click handler calls the api to create a new short url
|
||||||
document.getElementById("create").onclick = createUrl;
|
document.getElementById("create").onclick = createUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls the api to create a new short url and handels displaying the ui for "created" urls
|
||||||
|
*/
|
||||||
function createUrl() {
|
function createUrl() {
|
||||||
let shorturl = {
|
let shorturl = {
|
||||||
target: document.getElementById("target").value,
|
target: document.getElementById("target").value,
|
||||||
|
@ -55,9 +58,11 @@ function createUrl() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Add error dismiss event handler
|
||||||
document.getElementById("error_dismiss").onclick = () => {
|
document.getElementById("error_dismiss").onclick = () => {
|
||||||
document.getElementById("error_container").classList.add("hidden");
|
document.getElementById("error_container").classList.add("hidden");
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display alerts for errors (only handling 400 correctly r/n)
|
* Display alerts for errors (only handling 400 correctly r/n)
|
||||||
* @param {response} res The fetch response object
|
* @param {response} res The fetch response object
|
||||||
|
@ -76,8 +81,12 @@ function handleError(res) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Resets the UI
|
//Add ui reset error handler
|
||||||
document.getElementById("reset").onclick = reset;
|
document.getElementById("reset").onclick = reset;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the ui by emtying/resetting all inputs and showing the "default" home ui containers again.
|
||||||
|
*/
|
||||||
function reset() {
|
function reset() {
|
||||||
document.getElementById("shorturl").innerText = "";
|
document.getElementById("shorturl").innerText = "";
|
||||||
document.getElementById("target_container").className = "";
|
document.getElementById("target_container").className = "";
|
||||||
|
|
Loading…
Reference in New Issue