-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
113 lines (87 loc) · 3.02 KB
/
app.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
let minutes = 0;
let seconds = 0;
// ========== Counter and DAte of Checkin =============
function CheckInCounter() {
seconds += 1;
if (seconds == 60) {
minutes += 1;
seconds = 0;
}
let timestring =
"Eingecheckt: " + pad2(minutes) + ":" + pad2(seconds) + " minutes ago";
var counter = document.getElementById("checkin-counter");
counter.innerHTML = timestring;
}
function pad2(number) {
return (number < 10 ? "0" : "") + number;
}
function setTodaysDate() {
// Construct USC Date Format for activity field
let today = new Date();
var strDate = "D M, H:M"
.replace("M", today.toLocaleString("de-de", { month: "long" }))
.replace("D", today.getDate())
.replace("H", pad2(today.getHours()))
.replace("M", pad2(today.getMinutes()));
let datetime = document.getElementById("datetime");
datetime.innerHTML = strDate;
}
// =========== Activity Changes =====================
var activity_lentpark = {
activity: "Schwimmen",
"location-tag": "Lentpark",
tag: "Schwimmen",
src: "img/activity_img/activity_img_lentpark.jpg",
};
var activity_stuntwerk = {
activity: "Bouldern",
"location-tag": "Stuntwerk",
tag: "Bouldern",
src: "img/activity_img/activity_img_bouldern.jpg",
};
var activity_justfit = {
activity: "Freies Training",
"location-tag": "Just Fit 01 Classic Köln Riehl",
tag: "Fitness",
src: "img/activity_img/activity_img_justfit.jpg",
};
function displayActivity(activity_obj) {
document.getElementById("activity").innerHTML = activity_obj["activity"];
document.getElementById("location-tag").innerHTML =
"<img src='img/tag.png' id='location-icon'>" + activity_obj["location-tag"];
document.getElementById("tag").innerHTML =
" <img src='img/label.png' id='tag-icon'>" + activity_obj["tag"];
document.getElementById("location-img").src = activity_obj["src"];
}
// ============= Profile Changes ======
function displayConfigView() {
console.log("Displaying Config View");
document.getElementById("checkin-view").style.display = "none";
document.getElementById("config-view").style.display = "block";
}
function displayCheckInView() {
console.log("Displaying CheckinView");
document.getElementById("checkin-view").style.display = "block";
document.getElementById("config-view").style.display = "none";
}
function setProfileName() {
let name = document.getElementById("name-field").value;
console.log("Updating Profile with name", name);
document.getElementById("name").innerHTML = name;
}
function updateProfilPicture() {
const profileImg = document.getElementById("profile-img").files[0];
const profileImgURL = URL.createObjectURL(profileImg);
console.log("Updating Profile picture with", profileImgURL);
document.getElementById("profil-picture").setAttribute("src", profileImgURL);
}
function updateProfile() {
setProfileName();
updateProfilPicture();
}
// Setup
console.log("UrbanSportScanner ready");
setTodaysDate();
// Set Timer to refresh checkin-counter
var cancel = setInterval(CheckInCounter, 1000);
displayActivity(activity_stuntwerk);