-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
21 lines (18 loc) · 896 Bytes
/
popup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const validateForm = data => (data.startTime !== "" && data.lunchStart !== "" && data.lunchEnd !== "" && data.end !== "")
document.addEventListener("DOMContentLoaded", () => {
document.querySelector("#submit-btn").addEventListener("click", () => {
let startTime = document.querySelector("#start").value
let lunchStart = document.querySelector("#lunch-start").value
let lunchEnd = document.querySelector("#lunch-end").value
let end = document.querySelector("#end").value
let data = { startTime, lunchStart, lunchEnd, end }
if (validateForm(data)) {
document.querySelector(".error").style.visibility = "hidden"
chrome.tabs.executeScript({
code: "let data = " + JSON.stringify(data)
}, function() { chrome.tabs.executeScript({file: "filler.js"}) })
} else {
document.querySelector(".error").style.visibility = "visible"
}
})
})