-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.html
367 lines (317 loc) · 14.7 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
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
364
365
366
367
<!--suppress JSUnresolvedVariable, JSIncompatibleTypesComparison, HtmlRequiredLangAttribute -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dalamud Plugin Browser</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="./style.css">
</head>
<body class="loading">
<header>
<h1>Dalamud Plugins</h1>
<div class="right">
<button id="color-scheme" type="button"></button>
<input id="search" type="search" placeholder="Filter">
</div>
</header>
<main>
<section id="available">
<h2>Available Plugins</h2>
<ol class="plugin-list"></ol>
</section>
<section id="outdated">
<h2>Outdated Plugins</h2>
<p>These plugins have not been updated by the developer for the current API level. Please be patient while they are being updated!</p>
<ol class="plugin-list"></ol>
</section>
<section id="adoptable">
<h2>Adoptable Plugins</h2>
<p>These plugins have been abandoned by their original developer. If you're interested in taking over development, please reach out to the developer and let us know on Discord.</p>
<ol class="plugin-list"></ol>
</section>
<section id="stale">
<h2>Stale Plugins</h2>
<p>These plugins have not been officially discontinued but have not been updated for the current API level in over six months. The developer remains active in the community. They may be coming back.</p>
<ol class="plugin-list"></ol>
</section>
<section id="discontinued">
<h2>Discontinued Plugins</h2>
<p>These plugins have been discontinued due to our plugin rules or the developer's discretion. They won't be coming back.</p>
<ol class="plugin-list"></ol>
</section>
<section id="obsolete">
<h2>Obsolete Plugins</h2>
<p>These plugins are now obsolete and are no longer needed. This can be due to new features added to the game or by being replaced by another plugin. They won't be coming back.</p>
<ol class="plugin-list"></ol>
</section>
<p id="no-plugins-found" class="hidden">No plugins match your search criteria.</p>
</main>
<script type="module">
// dark mode
function setDarkMode(dark, noSave) {
document.getElementById('color-scheme').innerText = dark ? '🌕' : '☀️';
document.body.style.colorScheme = dark ? 'dark' : 'light';
if (!noSave) {
localStorage.setItem('colorScheme', dark ? 'dark' : 'light');
}
}
function toggleDarkMode() {
setDarkMode(document.body.style.colorScheme === 'dark' ? false : true);
}
const savedColorScheme = localStorage.getItem('colorScheme');
if (!savedColorScheme) {
const darkModeQuery = matchMedia('(prefers-color-scheme: dark)');
setDarkMode(darkModeQuery.matches, true);
} else {
setDarkMode(savedColorScheme === 'dark', true);
}
document.getElementById('color-scheme').addEventListener('click', toggleDarkMode);
// plugins
const data = await fetch('data.json')
.then((response) => response.json())
.then((json) => {
return json;
});
const currentApi = await fetch(data.dalamudProjUrl)
.then((response) => response.text())
.then((dalamudProjUrlText) => {
const match = dalamudProjUrlText.match(/<DalamudVersion>(\d+)\.\d+\.\d+\.\d+<\/DalamudVersion>/);
return match ? parseInt(match[1].trim()) : null;
});
const bannedPlugins = await fetch(data.bannedPluginUrl)
.then((response) => response.json());
const pluginMaster = location.hostname === 'localhost' || location.hostname === '127.0.0.1' ? './PluginMaster.json' : data.pluginMasterUrl;
const availablePlugins = document.getElementById('available').querySelector('ol');
const outdatedPlugins = document.getElementById('outdated').querySelector('ol');
const adoptablePlugins = document.getElementById('adoptable').querySelector('ol');
const stalePlugins = document.getElementById('stale').querySelector('ol');
const discontinuedPlugins = document.getElementById('discontinued').querySelector('ol');
const obsoletePlugins = document.getElementById('obsolete').querySelector('ol');
const adoptableInternalNames = data.adoptable;
const staleInternalNames = data.stale;
const discontinuedInternalNames = data.discontinued;
const obsoleteInternalNames = data.obsolete;
const validNonCurrent = adoptableInternalNames + staleInternalNames + discontinuedInternalNames + Object.keys(obsoleteInternalNames);
const isValidPlugin = (plugin) => plugin.DalamudApiLevel >= currentApi - 1 || validNonCurrent.includes(plugin.InternalName);
function createCard(plugin, type) {
const listElement = document.createElement('li');
const card = document.createElement('div');
listElement.append(card);
// class (for label) and visual indicator for testing exclusive plugins
if (plugin.IsTestingExclusive) {
card.classList.add('testing');
const testingIndicator = document.createElement('div');
testingIndicator.classList.add('testing-indicator');
testingIndicator.title = 'Testing Exclusive';
listElement.append(testingIndicator);
}
// ribbon, for categories other than "available" plugins
let ribbon;
if (type) {
ribbon = document.createElement('div');
ribbon.classList.add('ribbon', type.toLowerCase());
ribbon.innerText = type;
card.append(ribbon);
}
const header = document.createElement('header');
card.append(header);
// plugin icon
const icon = document.createElement('img');
icon.classList.add('icon');
icon.src = plugin.IconUrl ?? `https://raw.githubusercontent.com/goatcorp/PluginDistD17/main/${plugin._Dip17Channel}/${plugin.InternalName}/images/icon.png`;
icon.addEventListener('error', function() {
this.src = 'https://github.com/goatcorp/DalamudAssets/blob/master/UIRes/defaultIcon.png?raw=true';
});
header.append(icon);
// plugin name
const name = document.createElement('h3');
if (plugin.RepoUrl) {
const link = document.createElement('a');
name.append(link);
link.href = plugin.RepoUrl;
link.innerText = plugin.Name;
} else {
name.innerText = plugin.Name;
}
header.append(name);
// fields every plugin has: author, punchline and description
const attributeElements = {};
['Author', 'Punchline', 'Description'].forEach((attribute) => {
const e = document.createElement('div');
e.innerText = plugin[attribute];
e.classList.add(attribute.toLowerCase());
attributeElements[attribute] = e;
});
header.append(attributeElements.Author);
// obsolete reason
if (type === 'Obsolete') {
const e = document.createElement('div');
e.innerText = obsoleteInternalNames[plugin.InternalName];
e.classList.add('hint');
card.append(e);
}
// banned plugin indicator
const bannedPlugin = bannedPlugins.find((p) => p.Name === plugin.InternalName && p.AssemblyVersion === plugin.AssemblyVersion);
if (bannedPlugin) {
const e = document.createElement('div');
e.innerText = 'Current version can not be installed. Please wait for an update.';
e.classList.add('hint');
card.append(e);
if (!ribbon) {
ribbon = document.createElement('div');
card.insertBefore(ribbon, header);
}
ribbon.classList.add('ribbon', 'banned');
ribbon.innerText = 'Blocked';
if (bannedPlugin.Reason) {
ribbon.title = bannedPlugin.Reason;
}
}
card.append(attributeElements.Punchline);
card.append(attributeElements.Description);
// list of tags
if (plugin.Tags) {
const tags = document.createElement('ul');
tags.classList.add('tags');
plugin.Tags.sort().forEach(tag => {
const e = document.createElement('li');
e.innerText = tag;
tags.append(e);
});
card.append(tags);
}
// outdated icon overlay
if (plugin.DalamudApiLevel === currentApi - 1) {
const outdated = document.createElement('img');
outdated.src = 'https://github.com/goatcorp/DalamudAssets/blob/master/UIRes/outdatedInstallableIcon.png?raw=true';
outdated.classList.add('outdated');
header.append(outdated);
}
switch (type) {
case 'Outdated':
outdatedPlugins.append(listElement);
break;
case 'Adoptable':
adoptablePlugins.append(listElement);
break;
case 'Stale':
stalePlugins.append(listElement);
break;
case 'Discontinued':
discontinuedPlugins.append(listElement);
break;
case 'Obsolete':
obsoletePlugins.append(listElement);
break;
default:
availablePlugins.append(listElement);
break;
}
return listElement;
}
// set up filter
const searchablePlugins = [];
function shouldHidePlugin(plugin, searchText) {
if (plugin.name.includes(searchText)) {
return false;
}
if (plugin.internalName.includes(searchText)) {
return false;
}
if (plugin.author.includes(searchText)) {
return false;
}
if (plugin.punchline?.includes(searchText)) {
return false;
}
if (plugin.description?.includes(searchText)) {
return false;
}
if (plugin.tags?.includes(searchText)) {
return false;
}
return true;
}
function filterPlugins(searchText) {
const numPluginsVisible = {
available: 0,
outdated: 0,
adoptable: 0,
stale: 0,
discontinued: 0,
obsolete: 0
};
for (const category of Object.keys(numPluginsVisible)) {
document.getElementById(category).classList.remove('hidden');
}
document.getElementById('no-plugins-found').classList.add('hidden');
searchablePlugins.forEach((plugin) => {
plugin.element.classList.remove('hidden');
if (searchText !== '') {
const hide = shouldHidePlugin(plugin.plugin, searchText);
if (hide) {
plugin.element.classList.add('hidden');
} else {
numPluginsVisible[plugin.plugin.type]++;
}
} else {
numPluginsVisible[plugin.plugin.type]++;
}
});
let someVisible = false;
for (const [category, numVisible] of Object.entries(numPluginsVisible)) {
if (numVisible === 0) {
document.getElementById(category).classList.add('hidden');
} else {
someVisible = true;
}
}
if (!someVisible) {
document.getElementById('no-plugins-found').classList.remove('hidden');
}
}
document.getElementById('search').value = '';
document.getElementById('search').addEventListener('input', (event) => {
const searchText = event.target.value.toLowerCase().trim();
filterPlugins(searchText);
});
// fetch plugins
fetch(pluginMaster)
.then((response) => response.json())
.then(async (json) => {
document.body.classList.remove('loading');
json.filter((plugin) => isValidPlugin(plugin))
.sort((a, b) => a.Name.toLowerCase().localeCompare(b.Name.toLowerCase()))
.forEach((plugin) => {
let type;
if (Object.keys(obsoleteInternalNames).includes(plugin.InternalName)) {
type = 'Obsolete';
} else if (adoptableInternalNames.includes(plugin.InternalName)) {
type = 'Adoptable';
} else if (staleInternalNames.includes(plugin.InternalName)) {
type = 'Stale';
} else if (discontinuedInternalNames.includes(plugin.InternalName)) {
type = 'Discontinued';
} else if (plugin.DalamudApiLevel === currentApi - 1) {
type = 'Outdated';
}
searchablePlugins.push({
plugin: {
name: plugin.Name.toLowerCase(),
internalName: plugin.InternalName.toLowerCase(),
author: plugin.Author.toLowerCase(),
punchline: plugin.Punchline?.toLowerCase(),
description: plugin.Description?.toLowerCase(),
tags: plugin.Tags?.join(' ').toLowerCase(),
type: type?.toLowerCase() ?? 'available'
},
element: createCard(plugin, type)
});
});
// run once to hide empty categories
filterPlugins('');
});
</script>
</body>
</html>