Repository navigation
Expand file tree
/
Copy pathactivities.js
More file actions
51 lines (48 loc) · 2.64 KB
/
Copy pathactivities.js
File metadata and controls
51 lines (48 loc) · 2.64 KB
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
/* Shared activity catalogue + renderers.
Used by product pages (mountActivities) and the compare page (buildCompareActivities / toggleAct).
Single source of truth so the list never drifts between pages. */
var GACT = {
base: ["Running","Treadmill","Outdoor cycling","Indoor cycling","Pool swim","Walking","Hiking","Yoga","Pilates","Strength","HIIT","Cardio","Elliptical","Stair stepper","Indoor rowing","Breathwork","Tennis","Pickleball","Basketball","Soccer"],
outdoor: ["Trail running","Track running","Open-water swim","Alpine skiing","Snowboarding","Cross-country skiing","Climbing","Bouldering","Surfing","Stand-up paddleboarding","Kayaking","Mountain biking","Gravel riding","Rowing (outdoor)","Golf round","Skydiving"],
adventure: ["Expedition","Mountaineering","Backcountry skiing","Ultra running","Kiteboarding","Windsurfing","Hunting","Fishing","Overlanding","Sailing race"]
};
/* ---- product pages: chip cloud of included activities (tier's own additions highlighted) ---- */
function _achips(list, add){
var cls = add ? "achip add" : "achip", s = "";
for (var i = 0; i < list.length; i++) s += '<span class="' + cls + '">' + list[i] + '</span>';
return s;
}
function mountActivities(level, hostId){
var host = document.getElementById(hostId);
if (!host) return;
var html;
if (level === "everyday") html = _achips(GACT.base, false);
else if (level === "outdoor") html = _achips(GACT.base, false) + _achips(GACT.outdoor, true);
else html = _achips(GACT.base, false) + _achips(GACT.outdoor, false) + _achips(GACT.adventure, true);
host.innerHTML = '<div class="achips">' + html + '</div>';
}
/* ---- compare page: per-activity availability matrix + expand toggle ---- */
function _acell(on){ return "<td>" + (on ? '<span class="yes">✓</span>' : '<span class="nope">—</span>') + "</td>"; }
function _arows(list, e, o, a){
var s = "";
for (var i = 0; i < list.length; i++)
s += '<tr class="actrow"><td class="feat">' + list[i] + "</td>" + _acell(e) + _acell(o) + _acell(a) + _acell(a) + _acell(a) + _acell(a) + "</tr>";
return s;
}
function buildCompareActivities(){
var tb = document.getElementById("actlist");
if (!tb) return;
tb.innerHTML = _arows(GACT.base, 1, 1, 1) + _arows(GACT.outdoor, 0, 1, 1) + _arows(GACT.adventure, 0, 0, 1);
}
function toggleAct(){
var tb = document.getElementById("actlist"), b = document.getElementById("expBtn");
if (!tb) return;
if (tb.style.display === "none"){
if (!tb.innerHTML) buildCompareActivities();
tb.style.display = "";
if (b) b.innerHTML = "Hide full activity list ▾";
} else {
tb.style.display = "none";
if (b) b.innerHTML = "Show full activity list ▸";
}
}