-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
41 lines (33 loc) · 1.21 KB
/
app.js
File metadata and controls
41 lines (33 loc) · 1.21 KB
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
const getVenuePoint = () => {
const urlParams = new URLSearchParams(window.location.search);
const latitude = urlParams.get("latitude");
const longitude = urlParams.get("longitude");
return [latitude || 0, longitude || 0];
};
const delay = async (time) => {
return new Promise((resolve) => setTimeout(resolve, time));
};
const getCurrentTemp = async (latitude, longitude) => {
console.time("getCurrentTemp");
// in the real world, you'd call out to a data provider to fetch the weather
// at the display venue's point. for this example, we're artificially waiting
await delay(250);
console.timeEnd("getCurrentTemp");
return "34°";
};
const initCreative = async () => {
const [latitude, longitude] = getVenuePoint();
console.log("lat/lng:", latitude, longitude);
const currentTemp = await getCurrentTemp(latitude, longitude);
console.log("currentTemp:", currentTemp);
document.getElementById("temp").innerText = currentTemp;
console.log("signaling ready!");
const ready = document.createElement("div");
ready.id = "dynamic-creative-ready";
document.body.appendChild(ready);
};
document.onreadystatechange = () => {
if (document.readyState === "interactive") {
initCreative();
}
};