-
Notifications
You must be signed in to change notification settings - Fork 0
/
a.js
50 lines (47 loc) · 1.64 KB
/
a.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const url = 'https://script.google.com/macros/s/AKfycbyrmIgCfnUT4fdyIIgr0dVEQYvEfluFu38NIV7ureMS0nDr6y_v/exec'
var array = []
var displayElement = document.getElementById('display')
var comment = ''
var count = 0
let Move = setInterval(() => {
fetch(url)
.then(response => response.json())
.then(data => {
const object = data
for (var i = 0; i < object.length; i++) {
array[i] = []
array[i][0] = object[i].date
array[i][1] = object[i].start
array[i][2] = object[i].end
array[i][3] = object[i].restaurant
}
})
if (count < array.length) {
comment = '<p>' + array[count][0] + ' ' + array[count][1] + '限から' + array[count][2] + 'まで ' + array[count][3] + '</p>'
displayElement.insertAdjacentHTML('beforeend', comment)
count++
}
}, 1000)
$("#button").click(function () {
var dateElement = document.getElementById("date")
var startElement = document.getElementById("start")
var endElement = document.getElementById("end")
var restaurantElement = document.getElementById("restaurant")
var data = {
date: dateElement.value,
start: startElement.value,
end: endElement.value,
restaurant: restaurantElement.value,
}
console.log(data)
fetch(url, {
method: "POST",
body: JSON.stringify(data),
mode: "no-cors",
headers: {
"Content-Type": "application/json"
}
})
.then(response => console.log("Success:", response))
.catch(error => console.error("Error:", error))
})