Skip to content

Commit

Permalink
Make it possible to press enter on input fields. Bump version to 0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
dibollinger committed Apr 19, 2021
1 parent 95bfb61 commit 4e19344
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "__MSG_extensionName__",
"author": "Dino Bollinger",
"homepage_url": "https://github.com/dibollinger/CookieBlock",
"version": "0.1",
"version": "0.2",
"incognito": "spanning",
"default_locale": "en",

Expand Down
20 changes: 20 additions & 0 deletions src/options/cookieblock_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,23 @@ document.querySelector("#advert_excepts_submit").addEventListener("click", (e) =
e.preventDefault();
handleExceptionSubmit("#advert_excepts_input", "cblk_exadvert", "advertising_exceptions");
});


/**
* Helper function for setting up enter events on the text input fields.
* @param {String} inputFieldID Identity of the input field.
* @param {String} buttonID Identity of the button to click.
*/
const addEnterListener = function(inputFieldID, buttonID) {
document.getElementById(inputFieldID).addEventListener("keydown", function(event) {
if (!event.repeat && event.key === "Enter") {
event.preventDefault();
document.getElementById(buttonID).click();
}
});
}

addEnterListener("website_excepts_input", "website_excepts_submit");
addEnterListener("func_excepts_input", "func_excepts_submit");
addEnterListener("analytics_excepts_input", "analytics_excepts_submit");
addEnterListener("advert_excepts_input", "advert_excepts_submit");

0 comments on commit 4e19344

Please sign in to comment.