Skip to content

Commit

Permalink
Disable form while sending
Browse files Browse the repository at this point in the history
  • Loading branch information
naokikimura committed Jan 5, 2020
1 parent 2d51bf6 commit 22a4100
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions _locales/ja/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
"content": "$1"
}
}
},
"m4": {
"message": "おくれませんでした。"
}
}
8 changes: 8 additions & 0 deletions popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,19 @@ window.addEventListener('DOMContentLoaded', (event) => {
const parent = document.getElementById('recipients');
for (child of parent.querySelectorAll('.recipient'))
parent.removeChild(child);

for (const node of event.target.querySelectorAll('input,select,textarea,button')) {
node.disabled = false;
}
});

document.getElementById('card').addEventListener('submit', (event) => {
event.preventDefault();
const form = event.target;
const data = new FormData(form);
for (const node of form.querySelectorAll('input,select,textarea,button')) {
node.disabled = true;
}
const progress = document.getElementById('progress');
const statusText = document.getElementById('status_text');
(async () => {
Expand All @@ -147,6 +154,7 @@ window.addEventListener('DOMContentLoaded', (event) => {
window.alert(chrome.i18n.getMessage('m1'));
form.reset();
})().catch(error => {
window.alert(chrome.i18n.getMessage('m4'));
console.error(error);
});
});
Expand Down

0 comments on commit 22a4100

Please sign in to comment.