-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbetterpets.js
186 lines (161 loc) · 5.2 KB
/
betterpets.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/* SUBURB API */
(function() {
var widget, initAddressFinder = function() {
widget = new AddressFinder.Widget(
document.getElementById('suburb'),
'ADDRESSFINDER_DEMO_KEY',
'AU', {
"show_addresses": false,
"show_locations": true,
"location_params": {
"location_types": "locality"
}
}
);
widget.on('location:select', function(fullLocation, metaData) {
document.getElementById('suburb').value = metaData.full_location
document.getElementById('postcode').value = metaData.postcode;
});
};
function downloadAddressFinder() {
var script = document.createElement('script');
script.src = 'https://api.addressfinder.io/assets/v3/widget.js';
script.async = true;
script.onload = initAddressFinder;
document.body.appendChild(script);
};
document.addEventListener('DOMContentLoaded', downloadAddressFinder);
})();
/* IMAGE CHANGE DEPENDING ON USER PREFERENCE */
// objects created for each user "type" containing properties for the icon and main image pertaining to the user type
var catPerson = {
catuser: "catperson",
caticon: "images/catw.png",
catmain: "images/maincat.jpg",
}
var dogPerson = {
doguser: "dogperson",
dogicon: "images/dogw.png",
dogmain: "images/maindog.jpg",
}
var bothPerson = {
cduser: "both",
cdicon: "images/cd.png",
cdmain: "images/catdog.jpg",
}
//upon loading of the homapage, change the picture set on the home screen depending on the user type
window.onload = () => {
const user = localStorage.getItem("usertype");
var Image_Id = document.getElementById('mainimage');
if (user === catPerson.catuser) {
Image_Id.src = catPerson.catmain;
}
else if (user === dogPerson.doguser) {
Image_Id.src = dogPerson.dogmain;
}
else{
Image_Id.src = bothPerson.cdmain;
}
}
//function to assign user type and keep it in local storage
function changeusertype() {
var Image_Id = document.getElementById('mainimage');
if (Image_Id.src.match("images/maindog.jpg")) {
Image_Id.src = catPerson.catmain;
localStorage.setItem("usertype", catPerson.catuser);
}
else if (Image_Id.src.match("images/maincat.jpg")) {
Image_Id.src = bothPerson.cdmain;
localStorage.setItem("usertype", bothPerson.cduser);
}
else {
Image_Id.src = "images/maindog.jpg";
localStorage.setItem("usertype", dogPerson.doguser);
}
}
document.getElementById("icon").addEventListener("load", iconchange());
//function to change the icon on each page according to user type
function iconchange() {
var icon = document.getElementById("icon");
const user = localStorage.getItem("usertype");
if (user === "dogperson") {
icon.src = "images/dogw.png";
}
else if (user === catPerson.catuser) {
icon.src = catPerson.caticon;
}
else {
icon.src = "images/cd.png";
}
}
/* SERVICES SLIDES */
let slideIndex = 1;
showSlides(slideIndex);
function plusSlides(n) {
showSlides(slideIndex += n);
}
function currentSlide(n) {
showSlides(slideIndex = n);
}
function showSlides(n) {
let i;
let slides = document.getElementsByClassName("slides");
let dots = document.getElementsByClassName("dot");
if (n > slides.length) {slideIndex = 1}
if (n < 1) {slideIndex = slides.length}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " active";
}
/* LOG IN/SIGN UP FORM POP OUT */
function openForm() {
document.getElementById("myForm").style.display = "block";
}
function loginForm() {
document.getElementById("myLogin").style.display = "block";
document.getElementById("myForm").style.display = "none";
}
function closeForm() {
document.getElementById("myForm").style.display = "none";
}
function back(){
document.getElementById("myForm").style.display = "block";
document.getElementById("myLogin").style.display = "none";
}
function passwordpopup() {
document.getElementById("passmessage").style.display = "block";
}
function passwordhide() {
document.getElementById("passmessage").style.display = "none";
}
/* PLAY DATE OPTIONS */
function pullInfo(n) {
if (n == 1) {
document.getElementById("breedtable").style.display = "flex";
document.getElementById("agetable").style.display = "none";
document.getElementById("gendertable").style.display = "none";
}
if (n == 2) {
document.getElementById("agetable").style.display ="flex";
document.getElementById("breedtable").style.display = "none";
document.getElementById("gendertable").style.display = "none";
}
if (n == 3) {
document.getElementById("gendertable").style.display = "flex";
document.getElementById("breedtable").style.display = "none";
document.getElementById("agetable").style.display = "none";
}
}
function selectMatch(n) {
var id = n;
document.getElementById("inviteForm").style.visibility = "visible";
document.getElementById("inviteeid").setAttribute('value', id);
}
function closeMatch() {
document.getElementById("inviteForm").style.visibility = "hidden";
}