-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
161 lines (136 loc) · 4.57 KB
/
index.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
import { walletData } from "./walletData.js";
const criteriaCheckbox = document.getElementById("criteria-checkbox");
const featureCheckbox = document.getElementById("feature-checkbox");
const userTypeRadio = document.getElementById("ux-radio");
// ================================================ USER TYPE ================================================
// Puts all the wallets their user type in one array.
function getUserTypeArray(wallets) {
const userTypeArray = [];
for (let wallet of wallets) {
for (let userType of wallet.userType) {
// if it does (!) NOT have duplicates execute this code.
if (!userTypeArray.includes(userType)) {
userTypeArray.push(userType);
}
}
}
return userTypeArray.sort();
}
// render out user type radio buttons
function renderUserTypeRadio(wallets) {
let radioItems = ``;
const userTypes = getUserTypeArray(wallets);
for (let userType of userTypes) {
radioItems += `<div class="radio-row">
<label for="${userType}">${userType}</label>
<input
class="radio-ux"
type="radio"
id="${userType}"
value="${userType}"
name="userType"
>
</div>`;
}
userTypeRadio.innerHTML = radioItems;
}
renderUserTypeRadio(walletData);
//sort wallets on user type filter
const wallets = walletData.filter(function (wallet) {
return wallet.userType.includes("linux");
});
console.log(wallets);
// ================================================ CRITERIA ================================================
// Puts all the wallets their criteria in one array.
function getCriteriaArray(wallets) {
const criteriaArray = [];
for (let wallet of wallets) {
for (let criteria of wallet.criteria) {
// if it does (!) NOT have duplicates execute this code.
if (!criteriaArray.includes(criteria)) {
criteriaArray.push(criteria);
}
}
}
return criteriaArray.sort();
}
// render out criteria checkbox buttons
function renderCriteriaCheckbox(wallets) {
let checkboxItems = ``;
const criterias = getCriteriaArray(wallets);
for (let criteria of criterias) {
checkboxItems += `<div class="checkbox-row">
<label for="${criteria}">${criteria}</label>
<input
class="checkbox"
type="checkbox"
id="${criteria}"
value="${criteria}"
name="criteria"
>
</div>`;
}
criteriaCheckbox.innerHTML = checkboxItems;
}
renderCriteriaCheckbox(walletData);
// ================================================ FEATURES ================================================
// Puts all the wallets their features in one array.
function getFeatureArray(wallets) {
const featureArray = [];
for (let wallet of wallets) {
for (let feature of wallet.features) {
// if it does (!) NOT have duplicates execute this code.
if (!featureArray.includes(feature)) {
featureArray.push(feature);
}
}
}
return featureArray.sort();
}
// render out criteria checkbox buttons
function renderFeatureCheckbox(wallets) {
let checkboxItems = ``;
const features = getFeatureArray(wallets);
for (let feature of features) {
checkboxItems += `<div class="checkbox-row">
<label for="${feature}">${feature}</label>
<input
class="checkbox"
type="checkbox"
id="${feature}"
value="${feature}"
name="feature"
>
</div>`;
}
featureCheckbox.innerHTML = checkboxItems;
}
renderFeatureCheckbox(walletData);
//getCriteriaArray(walletData);
//============================================ TOGGLE DISPLAY NONE/BLOCK WHEN CLICKED ON SKIP HELPER BUTTON ===============================================
const btnSkipHelp = document.getElementById("btn-skip-help-toggle");
btnSkipHelp.addEventListener("click", function () {
const hideGuide = document.getElementsByClassName("container");
const showTable = document.getElementsByClassName("second-wrapper");
for (let container of hideGuide) {
container.classList.remove("visible");
container.classList.add("hidden");
}
for (let table of showTable) {
table.classList.remove("hidden");
table.classList.add("visible");
}
});
const btnUseHelp = document.getElementById("btn-use-help-toggle");
btnUseHelp.addEventListener("click", function () {
const hideGuide = document.getElementsByClassName("container");
const showTable = document.getElementsByClassName("second-wrapper");
for (let container of hideGuide) {
container.classList.remove("hidden");
container.classList.add("visible");
}
for (let table of showTable) {
table.classList.remove("visible");
table.classList.add("hidden");
}
});