-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
155 lines (147 loc) · 4.98 KB
/
index.html
File metadata and controls
155 lines (147 loc) · 4.98 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<!-- Lightweight client-side loader that feature-detects and load polyfills only when necessary -->
<script src="https://cdn.jsdelivr.net/npm/@webcomponents/webcomponentsjs@2/webcomponents-loader.min.js"></script>
<!-- Load the element definition -->
<script
type="module"
src="https://cdn.jsdelivr.net/gh/zerodevx/zero-md@1/src/zero-md.min.js"
></script>
<link rel="stylesheet" type="text/css" href="index.css" />
<title>JavaScript State Management Libraries & Frameworks</title>
</head>
<body>
<a href="https://github.com/prodo-dev/state-management" id="githubLink"
><img src="GitHub-Mark-64px.png" width="40px"
/></a>
<div id="intro"></div>
<br />
<label>
<input type="checkbox" id="filterTypeScript" />
Mentions TypeScript support
</label>
<label>
<input type="checkbox" id="filterPerformance" />
Mentions performance
</label>
<label>
<input type="checkbox" id="filterApi" />
Simple (or medium) API
</label>
<label>
<input type="checkbox" id="filterExtensible" />
Is extensible
</label>
<label>
<input type="checkbox" id="filterDevTools" />
Has developer tools
</label>
<label>
<input type="checkbox" id="filterTimeTravel" />
Has time travel
</label>
<br />
<br />
<div id="table"></div>
<br />
<div id="end"></div>
<script>
const oReq = new XMLHttpRequest();
oReq.addEventListener("load", reqListener);
oReq.open(
"GET",
"https://raw.githubusercontent.com/prodo-dev/state-management/master/README.md"
);
oReq.send();
const mdStart = "<zero-md><template></style><xmp>";
const mdEnd = "</xmp></template></zero-md>";
let table = "";
function updateTable() {
const filteredTable = filterTable(table);
document.getElementById("table").innerHTML =
"<table>" + filteredTable + "</table>";
}
// Name | Notes | Link | Stars | TS | Perf | API | Concepts | Extensible | Devtools | Time travel | Automation
const filters = {
filterTypeScript: 4,
filterPerformance: 5,
filterApi: 6,
filterExtensible: 8,
filterDevTools: 9,
filterTimeTravel: 10
};
Object.keys(filters).forEach(function(filter) {
document.getElementById(filter).addEventListener("change", () => {
updateTable();
});
});
function filterTable(table) {
const tableRows = table
.split(/\r\n|\n/)
.filter(row => row.includes("|"));
let result =
"<thead><th class='nameCol'>" +
tableRows[0]
.slice(1, -1)
.split("|")
.join("</th><th>") +
"</th></thead><tbody>";
tableRows.forEach((row, idx) => {
if (idx > 1) {
const cells = row.split("|").slice(1, -1);
let filteredOut = false;
Object.keys(filters).forEach(function(filter) {
if (document.getElementById(filter).checked) {
const value = cells[filters[filter]].trim();
if (
filter == "filterApi" &&
idx > 0 &&
value.toLowerCase().includes("complex")
) {
filteredOut = true;
} else if (
!value ||
value === "no" ||
value === "not mentioned"
) {
filteredOut = true;
}
}
});
// TODO maybe use regex instead to wrap any links in all fields
if (!filteredOut) {
result +=
"<tr><td class='nameCol'>" +
cells.slice(0, 2).join("</td><td>") +
"</td><td><a href='" +
cells[2] +
"'>" +
cells[2] +
"</a></td><td>" +
cells.slice(3).join("</td><td>") +
"</td></tr>";
}
}
});
return result + "</tbody>";
}
function reqListener() {
const startText = "## Comparison Table";
const endText = "Some other state-related libraries";
const tableStart =
this.responseText.indexOf(startText) + startText.length;
const tableEnd = this.responseText.indexOf(endText);
const intro = this.responseText.substring(0, tableStart);
document.getElementById("intro").innerHTML = mdStart + intro + mdEnd;
const end = this.responseText.substring(tableEnd);
document.getElementById("end").innerHTML = mdStart + end + mdEnd;
table = this.responseText.substring(tableStart, tableEnd);
updateTable();
}
</script>
</body>
</html>