-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
329 lines (282 loc) · 16.2 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Strava Challenges Global</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.3/font/bootstrap-icons.css" rel="stylesheet">
<link rel="icon" type="image/png" href="img/wrench-adjustable-circle.png" />
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@3.4.31/dist/vue.global.min.js"></script>
<style>
.text-orange, a:hover {
color: orangered;
}
.btn {
border-radius: 0px;
}
a.btn-orange.btn:hover,
.btn-orange.btn.active {
color: white;
background-color: orangered;
}
.btn-orange {
color: orangered;
border-color: orangered;
}
.col-1-96{
/* width: 9.6%; */
width: 160px;
}
footer .logo {
width: 5%;
margin-right: 10px;
filter: opacity(0.6);
}
.text-justify{
text-align: justify;
}
</style>
</head>
<body id="app">
<header class="d-flex flex-wrap justify-content-center pt-3 pb-1 border-bottom text-orange">
<a href="https://qlefevre.github.io/strava-challenges-global/"
class="d-flex align-items-center mb-3 mb-md-0 me-md-auto text-orange text-decoration-none ps-5">
<i class="bi bi-strava fs-1 me-2"></i>
<span class="fs-4">Strava Challenges Global</span>
</a>
<ul class="nav nav-pills mt-3 pe-5 align-bottom">
<li class="nav-item">
<a href="?activities=Run" class="nav-link text-orange" v-html="svg('Run')+' Running challenges'"></a>
</li>
<li class="nav-item">
<a href="?activities=Ride" class="nav-link text-orange" v-html="svg('Ride')+' Cycling challenges'"></a>
</li>
<li class="nav-item">
<a href="?activities=Swim" class="nav-link text-orange" v-html="svg('Swim')+' Swimming challenges'"></a>
</li>
</ul>
</header>
<article class="col-10 mx-auto mt-4 fw-light">
<p>Strava Challenges Global lists all active challenges from global partners, excluding those issued by the official Strava club.<br>
Strava is an interactive platform that allows athletes, particularly runners, to track and compare their performance across a variety of global challenges.<br>
By following the challenge link, users can easily view their progress, see how they rank against others, and stay motivated to achieve their personal goals.<br>
The platform provides a dynamic leaderboard, detailed activity metrics, and a user-friendly interface, making it a great tool for anyone looking to push their limits and participate in running challenges around the world.</p>
</article>
<article id="challenges" class="col-10 mx-auto">
<div class="row mt-3">
<div class="text-orange col-1 col-1-96">Filtered activities: </div>
<div class="col-10 ps-0">
<div>
<a :class="'btn btn-orange btn-sm me-1 my-1'+cssActive(activity)" @click="toggle(activity)"
role="button" v-for="activity in highlightedActivities" v-html="svg(activity)+' '+activity"></a>
<a :class="'btn btn-outline-secondary btn-sm me-1 my-1 '+(showMore?'btn secondary active':'')"
@click="toggleShowMore" role="button">{{showMore?'⊖ Show Less':'⊕ Show More'}}</a>
</div>
<div :class="'mb-4 '+(showMore?'':'d-none')">
<a :class="'btn btn-orange btn-sm me-1 my-1'+cssActive(activity)" @click="toggle(activity)"
role="button" v-for="activity in notHighlightedActivities">{{activity}}</a>
</div>
</div>
</div>
<div class="fs-2 display-6 text-orange my-3">Ongoing challenges <span class="fs-5">({{filteredOngoingChallenges.length}}) - {{displayPeriod(filteredOngoingChallenges)}}</span></div>
<div class="text-center">
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-4 row-cols-lg-6">
<div class="col" v-for="challenge in filteredOngoingChallenges">
<a :href="'https://www.strava.com/challenges/'+challenge.challengeId" target="_blank">
<img :src="challenge.challengeLogoUrl" class="img-fluid px-5 pb-3 pt-4" />
</a>
<a :href="'https://www.strava.com/challenges/'+challenge.challengeId"
class="link-dark link-underline link-underline-opacity-10 link-opacity-50-hover"
target="_blank">
{{challenge.name}}
</a>
<br><a :href="'https://www.strava.com/challenges/'+challenge.challengeId"
class="link-dark link-opacity-50-hover text-decoration-none"
target="_blank">
<small>{{challenge.period}}</small>
</a>
</div>
</div>
</div>
<div class="fs-2 display-6 text-orange my-3 mt-5 pt-5">Past challenges <span class="fs-5">({{filteredChallenges.length}}) - {{displayPeriod(filteredChallenges)}}</span></div>
<span class="fs-5 display-6 text-orange ms-5 me-4">Years</span><span class="fs-5 display-6 text-orange me-4 mt-2 mb-0" v-for="year in years"><a class="text-decoration-none text-orange" :href="'#'+year">{{year}}</a> </span>
<div v-for="year in years">
<div class="d-block" :id="year"> </div>
<div class="fs-3 display-6 text-orange my-4" >{{year}}</div>
<div class="text-center">
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-4 row-cols-lg-6">
<div class="col" v-for="challenge in filteredChallengesByYear[year]">
<a :href="'https://www.strava.com/challenges/'+challenge.challengeId" target="_blank">
<img :src="challenge.challengeLogoUrl" class="img-fluid px-5 pb-3 pt-4" />
</a>
<a :href="'https://www.strava.com/challenges/'+challenge.challengeId"
class="link-dark link-underline link-underline-opacity-10 link-opacity-50-hover"
target="_blank">
{{challenge.name}}
</a>
<br><a :href="'https://www.strava.com/challenges/'+challenge.challengeId"
class="link-dark link-opacity-50-hover text-decoration-none"
target="_blank">
<small>{{challenge.period}}</small>
</a>
</div>
</div>
</div>
</div>
</article>
<footer
class="d-flex flex-wrap justify-content-between align-items-center py-0 mt-5 mb-3 border-top d-print-none text-orange">
<div class="row w-100">
<div class="col-md-7 d-flex align-items-center ps-5">
<i class="bi bi-strava fs-1 me-2"></i>
<p class="mb-3 mb-md-0 text-orange w-100">
2024 <a class="text-decoration-none text-orange"
href="https://qlefevre.github.io/strava-challenges-global/">Strava Challenges Global</a>.
</p>
</div>
<ul class="nav col-md-5 justify-content-end pe-5">
<li class="nav-item">
<a href="?activities=Run" class="nav-link text-orange" v-html="svg('Run')+' Running challenges'"></a>
</li>
<li class="nav-item">
<a href="?activities=Ride" class="nav-link text-orange" v-html="svg('Ride')+' Cycling challenges'"></a>
</li>
<li class="nav-item">
<a href="?activities=Swim" class="nav-link text-orange" v-html="svg('Swim')+' Swimming challenges'"></a>
</li>
</ul>
</div>
<div class="row">
<div class="col-md-8 d-flex align-items-center ps-5">
<p class="fw-lighter text-secondary text-justify ps-5">This site is not affiliated with Strava.com in any way, shape, or form. The content
provided on this site is for informational purposes only and is not endorsed by, sponsored by, or
otherwise associated with Strava. All trademarks and service marks are the property of their respective
owners. The use of any trade name or trademark is for identification and reference purposes only and
does not imply any association with the trademark holder. The information on this site is provided "as
is" without any representations or warranties, express or implied. Users should independently verify any
information before relying on it.</p>
</div>
</div>
</footer>
<script>
const { createApp } = Vue;
createApp({
data() {
return {
challenges: [],
ongoingchallenges: [],
years:[2024,2023,2022,2021,2020,2019],
activities: ["Rowing","Canoeing","Run","VirtualRun","Crossfit","Elliptical","Workout","WeightTraining","RockClimbing","Wheelchair","Soccer","Golf","Handcycle","Kayaking","Kitesurf","Walk","Swim","IceSkate","Hike","Snowshoe","InlineSkate","StairStepper","Skateboard","AlpineSki","BackcountrySki","NordicSki","RollerSki","Snowboard","StandUpPaddling","Surfing","Sail","Ride","VirtualRide","EBikeRide","Velomobile","Windsurf","Yoga"],
highlightedActivities: ["Run", "Ride", "Swim","Walk", "Hike"],
activeFilters: [],
showMore: false,
}
},
computed: {
icons: function () {
return [...new Set(Object.values(this.applications))];
},
filteredChallenges: function () {
return this.filterChallenges(this.challenges);
},
filteredChallengesByYear:function(){
// tableau temporaire : challenges regroupés par année
let challengesByYear = {};
// tri des challenges
this.filteredChallenges.forEach(challenge => {
const year = parseInt(challenge.startDate.slice(0,4));
if (!challengesByYear[year]) {
challengesByYear[year] = [];
}
challengesByYear[year].push(challenge);
});
return challengesByYear;
},
filteredOngoingChallenges: function () {
return this.filterChallenges(this.ongoingchallenges);
},
notHighlightedActivities: function () {
return this.activities.filter(activity => !this.highlightedActivities.includes(activity));
}
},
methods: {
filterChallenges: function (challenges) {
if (this.activeFilters.length === 0){
return challenges;
}
return challenges.filter(challenge => challenge.qualifyingActivities.some(qual => this.activeFilters.includes(qual)));
},
displayPeriod: function(challenges){
if(challenges.length <=2){
return '';
}
let dates = [challenges[0],challenges[challenges.length-1]];
dates.sort((a, b) => new Date(a.endDate) - new Date(b.endDate));
return dates[0].period.split('to')[0]+'to'+dates[1].period.split('to')[1];
},
cssActive: function (activity) {
return this.activeFilters.includes(activity) ? ' active' : '';
},
toggle: function (activity) {
return this.activeFilters.includes(activity) ?
this.activeFilters = this.activeFilters.filter(aFilter => aFilter !== activity) : this.activeFilters.push(activity);
},
toggleShowMore: function () {
return this.showMore = !this.showMore;
},
svg: function (activity){
switch (activity) {
case 'Run':
return '<svg class="me-1" fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M6.03 13.29a7.45 7.45 0 005.28 2.21h2.19a2 2 0 00.3-3.98L9.96 4.33a1.747 1.747 0 00-2.443-.653c-.274.17-.495.414-.637.703l-.27.56a.873.873 0 01-.33-.8V2.17A1.3 1.3 0 004.97.75a1.433 1.433 0 00-1.34.93L2.16 4.67l-.95.7A1.819 1.819 0 00.5 6.74a1.942 1.942 0 00.6 1.53l4.93 5.02zM1.79 6.18l.4-.3 5.14 5.07h1.42l-5.77-5.7L4.54 2.1a.475.475 0 01.43-.35c.15 0 .31.04.31.42v1.97c0 1.13.63 1.87 1.61 1.87h.31l.58-1.19a.729.729 0 011.29-.02l.63 1.17-1.26.67v1.14l1.73-.92.41.78-1.34.71v1.14l1.82-.96.39.74-1.56.83v1.14l2.03-1.09 1.12 2.09.16.26h.3a1 1 0 010 2h-2.19a6.492 6.492 0 01-4.57-1.91L1.79 7.55a.96.96 0 01-.29-.75.87.87 0 01.29-.62z" fill=""></path></svg>';
case 'Ride':
return '<svg class="me-1" fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M4 13.01a3.5 3.5 0 003.46-3h1.08a3.5 3.5 0 102.42-3.84L9.83 4.01H11a.5.5 0 01.5.5h1a1.5 1.5 0 00-1.5-1.5H8.17l1.05 2h-3.1l-.532-1h.982l-.53-1H3.05l.53 1h.879l.747 1.407-.376.693a3.5 3.5 0 10-.83 6.9zm6.52-5.51l1.32 2.51h1.13l-1.54-2.93a2.12 2.12 0 01.57-.07 2.5 2.5 0 11-2.233 1.372c.178-.35.436-.652.753-.882zm-.78-1.49l.31.6a3.452 3.452 0 00-1.51 2.4h-.291l-1.6-3H9.74zm-3.972.463L7.117 9.01H4.4l1.368-2.537zM4 7.01c.11 0 .221.01.33.03L3.22 9.1l.47.91h2.76a2.5 2.5 0 11-2.45-3z" fill=""></path></svg>';
case 'Swim':
return '<svg class="me-1" fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><g clip-path="url(#sports_water_normal_xsmall_svg__clip0_138_646)"><path d="M8 13.5a2.82 2.82 0 01-2.51-1.51h-1a2.823 2.823 0 01-2.5 1.51A2.779 2.779 0 010 12.69v1.26a3.743 3.743 0 001.99.55 3.822 3.822 0 003-1.45A3.8 3.8 0 008 14.5a3.742 3.742 0 003-1.46v-1.05h-.5A2.793 2.793 0 018 13.5zm3.51-6.51H10.5a2.833 2.833 0 01-5 0H4.49a2.8 2.8 0 01-2.5 1.5A2.813 2.813 0 010 7.69v1.25a3.743 3.743 0 001.99.55 3.762 3.762 0 003-1.45 3.849 3.849 0 006.02 0 3.845 3.845 0 004.99.9V7.69a2.85 2.85 0 01-4.49-.7zM11.52 2h-1.03A2.787 2.787 0 018 3.5 2.814 2.814 0 015.5 2H5v1.05a3.839 3.839 0 006.01 0 3.762 3.762 0 003 1.45A3.743 3.743 0 0016 3.95V2.69a2.78 2.78 0 01-1.99.81A2.8 2.8 0 0111.52 2z" fill=""></path></g><defs><clipPath id="sports_water_normal_xsmall_svg__clip0_138_646"><path fill="#fff" d="M0 0h16v16H0z"></path></clipPath></defs></svg>';
case 'Walk':
return '<svg class="me-1" fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><g fill=""><path d="M7.5 11.5h-2v1h2z"></path><path d="M15 8.06a1.646 1.646 0 00-1.22-.56h-1.41L7.65 4.99l-.42-.7a1.65 1.65 0 00-2.97.33l-.13.4A1.478 1.478 0 003 4.5 1.5 1.5 0 001.5 6v3.59A1.5 1.5 0 00.5 11 1.45 1.45 0 002 12.5h2.5v-1H2a.452.452 0 01-.5-.5.5.5 0 01.5-.5h5.5v-1h-5V6a.5.5 0 011 0v.5h1.19l.52-1.56a.668.668 0 011.16-.13l.57.94.65.35-.58 1.09.88.47.58-1.1.95.51-.58 1.09.88.47.58-1.09.95.5-.59 1.1.88.47.59-1.11h1.65a.644.644 0 01.48.23.84.84 0 01.22.56.959.959 0 01-.28.69l-.49.47a3.718 3.718 0 01-2.21 1.02v1.01a4.736 4.736 0 002.9-1.31l.5-.47c.37-.376.579-.882.58-1.41 0-.456-.17-.895-.48-1.23z"></path><path d="M10.5 11.5h-2v1h2z"></path></g></svg>';
case 'Hike':
return '<svg class="me-1" fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M5.75 12.88l.24-.24a.329.329 0 01.46-.01l.24.25a2.18 2.18 0 001.5.62h1.63l-.72-1h-.91a1.13 1.13 0 01-.79-.33l-.24-.24a1.315 1.315 0 00-1.87 0l-.24.24c-.213.21-.5.328-.8.33h-.06l-.72 1h.78a2.119 2.119 0 001.5-.62z" fill=""></path><path d="M2.24 13.49l.72-.99h-.58a.876.876 0 01-.88-.88 5.98 5.98 0 01.1-1.12h2.8l.72-1H1.78v-.02l.15-.7a1.52 1.52 0 01.74-.99L6.5 5.65V4.51L2.29 6.86l.21-1.09a1.462 1.462 0 01.72-.99l2.12-1.17.38-.76a.567.567 0 01.5-.31A1.287 1.287 0 017.5 3.82V7.9l1 .53V6.9c.033.03.07.053.11.07l.89.47v1.52l1 .54V7.98l1 .53v1.52l1 .53V9.04l.37.2h1.12a.512.512 0 01.51.51 2.747 2.747 0 01-2.75 2.75h-1.42l.72 1h.7a3.751 3.751 0 003.75-3.75 1.515 1.515 0 00-1.51-1.51h-.87L9.08 6.09a1.084 1.084 0 01-.58-.96V3.82a2.285 2.285 0 00-2.28-2.28 1.543 1.543 0 00-1.39.86l-.25.49-1.84 1.02a2.43 2.43 0 00-1.22 1.67l-.87 4.45c-.1.524-.15 1.056-.15 1.59a1.87 1.87 0 001.74 1.87z" fill=""></path></svg>';
}
}
},
mounted() {
const urlParams = new URLSearchParams(window.location.search);
let activitiesdata = urlParams.get('activities');
if(activitiesdata){
values = activitiesdata.split('-').filter(activity => this.activities.includes(activity));
this.activeFilters = values;
}
const url = "challenges.json";
// date du jour à minuit
const today = new Date();
today.setHours(0);
today.setMinutes(0);
today.setSeconds(0);
today.setMilliseconds(0);
fetch(url)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok ' + response.statusText);
}
return response.json();
})
.then(data => {
// Liste des challenges en cours
this.ongoingchallenges= data
.filter(a => new Date(a.endDate) >= today)
.sort((a, b) => new Date(a.endDate) - new Date(b.endDate));
// Liste des challenges
this.challenges = data
.filter(a => new Date(a.endDate) < today)
.sort((a, b) => new Date(b.endDate) - new Date(a.endDate));
})
.catch(error => {
console.error('Il y a eu un problème avec votre requête fetch:', error);
});
}
}).mount('#app');
</script>
</body>
</html>