-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.js
363 lines (318 loc) · 10 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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
var SearchBoxInput;
window.onload = function(){
ThemeInitialize();
};
function OnLoaded(){
ThemeInitialize();
}
var ScreenshotsFlipViewCounter = 0;
function FlipScreenshot(count){
try{
var pipsPager = document.getElementById("screenshots-pager");
switch(count){
case 0:
if(GetCurrentEnviromentTheme() == RequestedTheme.Light){
$('#app-preview-image').css("background-image", "url('assets/light-screen.png')");
}
else if(GetCurrentEnviromentTheme() == RequestedTheme.Dark){
$('#app-preview-image').css("background-image", "url('assets/dark-screen.png')");
}
pipsPager.children[0].className = "ms-pippager-active-dot";
pipsPager.children[1].className = "ms-pippager-dot";
pipsPager.children[2].className = "ms-pippager-dot";
pipsPager.children[3].className = "ms-pippager-dot";
break;
case 1:
if(GetCurrentEnviromentTheme() == RequestedTheme.Light){
$('#app-preview-image').css("background-image", "url('assets/Light-screen-laptop.png')");
}
else if(GetCurrentEnviromentTheme() == RequestedTheme.Dark){
$('#app-preview-image').css("background-image", "url('assets/Dark-screen-laptop.png')");
}
pipsPager.children[0].className = "ms-pippager-dot";
pipsPager.children[1].className = "ms-pippager-active-dot";
pipsPager.children[2].className = "ms-pippager-dot";
pipsPager.children[3].className = "ms-pippager-dot";
break;
case 2:
$('#app-preview-image').css("background-image", "url('assets/Dark-screen-hub.png')");
pipsPager.children[0].className = "ms-pippager-dot";
pipsPager.children[1].className = "ms-pippager-dot";
pipsPager.children[2].className = "ms-pippager-active-dot";
pipsPager.children[3].className = "ms-pippager-dot";
break;
case 3:
$('#app-preview-image').css("background-image", "url('assets/Dark-screen-xbox.png')");
pipsPager.children[0].className = "ms-pippager-dot";
pipsPager.children[1].className = "ms-pippager-dot";
pipsPager.children[2].className = "ms-pippager-dot";
pipsPager.children[3].className = "ms-pippager-active-dot";
break;
}
}
catch(e){
console.log(e.toString());
}
}
function NextFlipScreenshot_Click(){
try{
if(ScreenshotsFlipViewCounter < 3){
ScreenshotsFlipViewCounter++;
FlipScreenshot(ScreenshotsFlipViewCounter);
}
else{
ScreenshotsFlipViewCounter = 0;
FlipScreenshot(ScreenshotsFlipViewCounter);
}
}
catch(e){
console.log(e.toString());
}
}
function PreviousFlipScreenshot_Click(){
try{
if(ScreenshotsFlipViewCounter >= 0){
ScreenshotsFlipViewCounter--;
FlipScreenshot(ScreenshotsFlipViewCounter);
}
else{
ScreenshotsFlipViewCounter = 0;
FlipScreenshot(ScreenshotsFlipViewCounter);
}
}
catch(e){
console.log(e.toString());
}
}
function CloseFlyoutMenu(){
$('#menu-flyout').css("visibility", "collapse");
}
function OpenFlyoutMenu(){
$('#menu-flyout').css("visibility", "visible");
}
function CloseSearch(){
$('#search-flyout').css("visibility", "collapse");
}
function OpenSearch(){
$('#search-flyout').css("visibility", "visible");
}
function ShowShareDialog(title, content){
try{
if(navigator.share){
navigator.share({
title: title,
text: content,
url: "https://www.microsoft.com/store/productId/9NLHP5KRXZQ7"
})
.then(function(){
console.log("Share success!");
})
.catch(function(){
console.log("Share failed.");
});
}
else{
console.log("Share APIs don't supported.");
}
}
catch(e){
console.log(e.toString());
}
}
function SearchBoxInput_OnLoad(){
SearchBoxInput = document.getElementById("SearchBoxInput");
//debugger;
SearchBoxInput.addEventListener("keydown", SearchBoxInput_KeyDown);
}
function SearchBoxInput_KeyDown(key){
try{
if(key != null){
if(key.code == "Enter"){
//debugger;
SearchBing($('#SearchBoxInput').val());
}
}
}
catch(e){
console.log(e.toString());
}
}
function FlyoutSearchInput_KeyDown(key){
try{
if(key != null){
if(key.code == "Enter"){
//debugger;
SearchBing($('#FlyoutSearchInput').val());
}
}
}
catch(e){
console.log(e.toString());
}
}
function SearchButton_Click(){
try{
SearchBing($('#SearchBoxInput').val());
}
catch(e){
console.log(e.toString());
}
}
function FlyoutSearch_Find(){
try{
SearchBing($('#FlyoutSearchInput').val());
}
catch(e){
console.log(e.toString());
}
}
function ThemeInitialize(){
try{
const darkThemeMq = window.matchMedia("(prefers-color-scheme: dark)");
if (darkThemeMq.matches) {
var cssId = 'dark';
if (!document.getElementById(cssId))
{
var head = document.getElementsByTagName('head')[0];
var link = document.createElement('link');
link.id = cssId;
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'style_dark.css';
link.media = 'all';
head.appendChild(link);
}
}
else {
var cssId = 'light';
if (!document.getElementById(cssId))
{
var head = document.getElementsByTagName('head')[0];
var link = document.createElement('link');
link.id = cssId;
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'style.css';
link.media = 'all';
head.appendChild(link);
}
}
}
catch(e){
console.log(e.toString());
}
}
function NavigateTo(url){
try{
document.location.href = url.toString();
}
catch(e){
console.log(e.toString());
}
}
function SendReview(){
window.open("mailto:[email protected]");
}
function SearchBing(query){
try{
var request = "https://www.bing.com/search?q=" + query.toString();
window.open(request.toString());
}
catch(e){
console.log(e.toString());
}
}
function OpenInMicrosoftStore(){
try{
if(navigator.appVersion.indexOf("Windows ")!=-1){
if(getWindowsOS() == "Windows 10"){
window.open("ms-windows-store://pdp/?productid=9NLHP5KRXZQ7");
}
else{
window.open("https://www.microsoft.com/en-us/p/power-widgets-customize-your-at-a-glance-info/9nlhp5krxzq7");
}
}
else{
window.open("https://www.microsoft.com/en-us/p/power-widgets-customize-your-at-a-glance-info/9nlhp5krxzq7");
}
}
catch(e){
console.log(e.toString());
}
}
function getWindowsOS() {
// http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx#PltToken
if (navigator.appVersion.indexOf("Windows NT 10.") != -1) {
return 'Windows 10';
} else if (navigator.appVersion.indexOf("Windows NT 6.3") != -1) {
return "Windows 8.1";
} else if (navigator.appVersion.indexOf("Windows NT 6.2") != -1) {
return "Windows 8";
} else if (navigator.appVersion.indexOf("Windows NT 6.1") != -1) {
return "Windows 7";
} else if (navigator.appVersion.indexOf("Windows NT 6.0") != -1) {
return "Windows Vista";
} else if (navigator.appVersion.indexOf("Windows NT 5.2") != -1) {
return "Windows Server 2003; Windows XP x64 Edition";
} else if (navigator.appVersion.indexOf("Windows NT 5.1") != -1) {
return "Windows XP";
} else if (navigator.appVersion.indexOf("Windows NT 5.01") != -1) {
return "Windows 2000, Service Pack 1 (SP1)";
} else if (navigator.appVersion.indexOf("Windows NT 5.0") != -1) {
return "Windows 2000";
} else if (navigator.appVersion.indexOf("Windows NT 4.0") != -1) {
return "Windows NT 4.0";
} else if (navigator.appVersion.indexOf("Windows 98; Win 9x 4.90") != -1) {
return "Windows Millennium Edition (Windows Me)";
} else if (navigator.appVersion.indexOf("Windows 98") != -1) {
return "Windows 98";
} else if (navigator.appVersion.indexOf("Windows 95") != -1) {
return "Windows 95";
} else if (navigator.appVersion.indexOf("Windows CE") != -1) {
return "Windows CE";
} else {
return "Windows OS, Version nicht bekannt";
}
}
function Message(content){
alert(content.toString());
}
function OutlookFeatureShare(){
var content =
"All important Outlook features in one small widget." +
"Try it right now!";
var title = "Try Outlook widget in Power Widgets app";
ShowShareDialog(title.toString(), content.toString());
}
function FastActionsFeatureShare(){
var content =
"Get fast access to important system or device features." +
"Try it right now!";
var title = "Try fast actions in Power Widgets app";
ShowShareDialog(title.toString(), content.toString());
}
function WeatherCardShare() {
var content = "Get a quick weather information in a handy widget." +
"Try it right now!";
var title = "Try weather widget in Power Widgets app";
ShowShareDialog(title.toString(), content.toString());
}
function ClockCardShare() {
var content = "Beautiful clock widget will decorate your widget feed and desktop." +
"Try it right now!";
var title = "Try clock widget in Power Widgets app";
ShowShareDialog(title.toString(), content.toString());
}
function EdgeCardShare() {
var content = "Perform quick web searches, pin sites, and get Bing picture of the day" +
"Try it right now!";
var title = "Try Microsoft Edge widget in Power Widgets app";
ShowShareDialog(title.toString(), content.toString());
}
function StickyCardShare() {
var content = "Write down everything you need and pin it to the notes panel." +
"Try it right now!";
var title = "Try create sticky notes in Power Widgets app";
ShowShareDialog(title.toString(), content.toString());
}
setInterval(NextFlipScreenshot_Click, 15000);