Skip to content

Commit

Permalink
Fix initial value sending + add better comments
Browse files Browse the repository at this point in the history
No comment.
  • Loading branch information
pixer415 authored Feb 4, 2024
1 parent ac15271 commit 1e50bb9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
pport = e.ports[0];
}
}

// send updated value to extension
function update() {
if (pport) {
pport.postMessage(box.value);
Expand Down Expand Up @@ -101,10 +103,9 @@
const paramValue = `${decodeURIComponent(urlParams.get('value'))}`;
if (pattrn === null || pattrn.test(paramValue)) {
box.value = paramValue;
update();
}
}

// listeners
box.addEventListener("keypress", event => {
if (pattrn !== null && !pattrn.test(event.key)) {
Expand All @@ -125,7 +126,10 @@
box.addEventListener("blur", (e) => {
e.target.style.boxShadow = "";
});

// send initial value to extension
while (pport === null) {
}
update();
}
</script>
Expand Down

0 comments on commit 1e50bb9

Please sign in to comment.