This repository has been archived by the owner on Dec 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
324 lines (206 loc) · 8.33 KB
/
main.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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
var isUWPorWeb = false;
window.onload = function() {
if (isUWPorWeb) {
var greet = document.querySelector('#greeting');
greet.innerText =
'This is UWP app. You can use Windows class. It is ' + new Date();
document.querySelector('#scenarioView').style.display = 'block';
} else {
document.querySelector('#greeting').innerText =
'This is Web browser It is ' + new Date();
}
};
(function() {
"use strict";
if (typeof Windows !== 'undefined' &&
typeof Windows.UI !== 'undefined' &&
typeof Windows.ApplicationModel !== 'undefined') {
isUWPorWeb = true;
} else {
isUWPorWeb = false;
}
var app = WinJS.Application;
//SPLIT VIEW
var mySplitView = window.mySplitView = {
splitView: null,
trailClicked: WinJS.UI.eventHandler(function(ev) {
var trailId = ev.currentTarget.dataset.trailId;
updateUI(allTrails[trailId]);
}),
homeClicked: WinJS.UI.eventHandler(function(ev) {
//add remove tags
document.getElementById("app").classList.add("show-home");
document.getElementById("app").classList.remove("show-trail");
}),
};
//END SPLIT VIEW
function updateUI(trail) {
//add remove tags
document.getElementById("app").classList.add("show-trail");
document.getElementById("app").classList.remove("show-home");
//update title
var titleElt = document.body.querySelector(".trail-title");
titleElt.textContent = trail.title;
//update location
var locationElt = document.body.querySelector(".trail-location");
locationElt.textContent = trail.location;
//update description
var descriptionElt = document.body.querySelector(".trail-description");
descriptionElt.textContent = trail.description;
//update Flipview
var flipViewElt = document.body.querySelector(".flipView");
//---------------------------------------JS #1-2: Work Here--------------------------------------------
________________________________
________________________________
//---------------------------------------End JS #1-2----------------------------------------------------
//update Rating
var ratingElt = document.body.querySelector(".rating");
ratingElt.winControl.averageRating = trail.averageRating;
ratingElt.winControl.userRating = 0;
}
var trailNameToID = {
"Snoqualmie Falls Trail": 0,
"Foster Island Trail": 1,
"Alki Trail": 2
}
var allTrails = [{
title: "Snoqualmie Falls Trail",
averageRating: 2,
location: "Kirkland, WA",
preview: "/images/SampleApp/Snoqualmie.jpg",
pictureArray: [{
type: "item",
picture: "/images/SampleApp/Snoqualmie.jpg"
},
{
type: "item",
picture: "/images/SampleApp/Snoqualmie2.jpg"
}
],
description: "Snoqualmie Falls is one of Washington state's most popular scenic attractions. More than 1.5 million visitors come to the Falls every year. At the falls, you will find a two-acre park, gift shop, observation deck, the Salish Lodge and the famous 270 foot waterfall."
},
{
title: "Foster Island Trail",
averageRating: 4.5,
location: "Bellevue, WA",
preview: "/images/SampleApp/Foster.jpg",
pictureArray: [{
type: "item",
picture: "/images/SampleApp/Foster.jpg"
},
{
type: "item",
picture: "/images/SampleApp/Foster2.jpg"
}
],
description: "Foster Island Trail is a 2 mile loop trail located near Seattle, Washington that features a lake and is good for all skill levels. The trail offers a number of activity options and is accessible year-round."
},
{
title: "Alki Trail",
averageRating: 1.5,
location: "Seattle, WA",
preview: "/images/SampleApp/Alki.jpg",
pictureArray: [{
type: "item",
picture: "/images/SampleApp/Alki.jpg"
},
{
type: "item",
picture: "/images/SampleApp/Alki2.jpg"
}
],
description: "The Alki Trail rides along the northern and eastern shore of West Seattle along Alki Avenue. Largely riding on a widened sidewalk, separated from traffic by a parking lane and curb, traffic on the trail is separated for bikes and walkers, providing a less stressful experience for walkers and bikers alike. "
}
]
//FLIP VIEW
var placeholderArray = [{
type: "item",
picture: "/images/SampleApp/Alki.jpg"
}];
var DefaultData = window.DefaultData = {
bindingList: new WinJS.Binding.List(placeholderArray)
}
// FLIP VIEW
//REPEATER AND LISTVIEW
//create an array of trails to turn the allTrails object into an array
var trailArray = [];
//We've added each trail in the allTrails object into the trailArray
for (var i = 0; i < allTrails.length; ++i) {
trailArray.push(allTrails[i]);
}
//create a binding list out of the trailArray we just created
var myList = window.myList = {
data: new WinJS.Binding.List(trailArray)
};
//END REPEATER AND LISTVIEW
var Contacts;
var ContactManager;
var ContactCardOptions;
var ContactCardTabKind;
var Placement;
var inputEmailAddress;
var inputPhoneNumber;
var Contact;
var ContactEmail;
var ContactPhone;
if (isUWPorWeb) {
Contacts = Windows.ApplicationModel.Contacts;
ContactManager = Contacts.ContactManager;
ContactCardOptions = Contacts.ContactCardOptions;
ContactCardTabKind = Contacts.ContactCardTabKind;
Placement = Windows.UI.Popups.Placement;
Contact = Contacts.Contact;
ContactEmail = Contacts.ContactEmail;
ContactPhone = Contacts.ContactPhone;
}
function createContactFromUserInput(inputEmailAddress, inputPhoneNumber) {
var emailAddress = inputEmailAddress.value;
var phoneNumber = inputPhoneNumber.value;
if (!emailAddress.length && !phoneNumber.length) {
WinJS.log && WinJS.log("You must enter an email address and/or phone number.", "sample", "error");
return null;
}
var contact = new Contact();
// Maximum length for email address is 321, enforced by HTML markup.
if (emailAddress.length) {
var email = new ContactEmail();
email.address = emailAddress;
contact.emails.append(email);
}
// Maximum length for phone number is 50, enforced by HTML markup.
if (phoneNumber.length) {
var phone = new ContactPhone();
phone.number = phoneNumber;
contact.phones.append(phone);
}
return contact;
}
function getElementRect(e) {
var rect = e.getBoundingClientRect();
// Convert from HTML rect to WinRT rect.
return {
x: rect.left,
y: rect.top,
width: rect.width,
height: rect.height
};
}
function onShowContactCard(evt) {
var inputEmailAddress = document.getElementById("inputEmailAddress");
var inputPhoneNumber = document.getElementById("inputPhoneNumber");
var contact = createContactFromUserInput(inputEmailAddress, inputPhoneNumber);
if (contact) {
// Show the contact card next to the button.
var rect = getElementRect(evt.srcElement);
// Show with default placement.
ContactManager.showContactCard(contact, rect);
}
}
document.getElementById("showContactCard").addEventListener("click", onShowContactCard);
//processAll
WinJS.UI.processAll().then(function() {
mySplitView.splitView = document.querySelector(".splitView").winControl;
new WinJS.UI._WinKeyboard(mySplitView.splitView.paneElement);
});
app.start();
})();