Skip to content

Commit e2b33be

Browse files
fix: Replace jQuery with fetch and vanilla DOM
Migrate project scripts away from jQuery: add onDocumentReady, fetchWithNoCache and fetchJson helpers; replace $.ajax and $(document).ready usages with fetch/Promise APIs and DOMContentLoaded handling; convert remove-widgetbot-crate to vanilla DOM. Also update _data/licenses.yml with renovate datasource comments and bump Chart.js and Marked versions, and remove the jQuery CDN reference from index.html.
1 parent 1e6fb8c commit e2b33be

4 files changed

Lines changed: 86 additions & 67 deletions

File tree

_data/licenses.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ beautiful-jekyll:
55
license: MIT
66
gamepad-helper:
77
name: LizardByte/gamepad-helper
8+
# renovate: datasource=npm depName=@lizardbyte/gamepad-helper
89
version: '2026.219.34512'
910
url: https://github.com/LizardByte/gamepad-helper/
1011
license: MIT
1112
shared-web:
1213
name: LizardByte/shared-web
14+
# renovate: datasource=npm depName=@lizardbyte/shared-web
1315
version: '2026.314.32913'
1416
url: https://github.com/LizardByte/shared-web/
1517
license: AGPL-3.0
@@ -27,7 +29,8 @@ button-icons:
2729
license: CC BY 3.0
2830
chartjs:
2931
name: Chart.js
30-
version: '4.4.9'
32+
# renovate: datasource=cdnjs depName=Chart.js packageName=Chart.js/chart.umd.min.js versioning=semver
33+
version: '4.5.0'
3134
url: https://www.chartjs.org/
3235
license: MIT
3336
giscus:
@@ -38,13 +41,9 @@ jekyll:
3841
name: Jekyll
3942
url: https://jekyllrb.com/
4043
license: MIT
41-
jquery:
42-
name: jQuery
43-
version: '3.7.1'
44-
url: https://jquery.com/
45-
license: MIT
4644
marked:
4745
name: Marked
48-
version: '15.0.8'
46+
# renovate: datasource=cdnjs depName=marked packageName=marked/lib/marked.umd.min.js versioning=semver
47+
version: '16.3.0'
4948
url: https://marked.js.org/
5049
license: MIT

assets/js/projects.js

Lines changed: 69 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,39 @@
11
// projects section script
22

33
// get project container
4-
let container = document.getElementById("project-container")
4+
let container
55
let org_name = "LizardByte"
66
let base_url = `https://app.${org_name.toLowerCase()}.dev`
77
let cache_repo = "dashboard"
88

99

10+
function onDocumentReady(callback) {
11+
if (document.readyState === "loading") {
12+
document.addEventListener("DOMContentLoaded", callback)
13+
return
14+
}
15+
16+
callback()
17+
}
18+
19+
function fetchWithNoCache(url, options = {}) {
20+
return fetch(url, {
21+
...options,
22+
cache: "no-store",
23+
})
24+
}
25+
26+
function fetchJson(url) {
27+
return fetchWithNoCache(url)
28+
.then(function (response) {
29+
if (!response.ok) {
30+
throw new Error(`Request failed for ${url}: ${response.status}`)
31+
}
32+
33+
return response.json()
34+
})
35+
}
36+
1037
function shouldProcessRepo(repo) {
1138
if (repo['archived'] === true) return false;
1239
if (repo['description'] === null) return false;
@@ -64,16 +91,13 @@ function createCardBody(repo) {
6491
}
6592

6693
function loadCommitActivity(repo, card_footer) {
67-
$.ajax({
68-
url: `${base_url}/${cache_repo}/github/commitActivity/${repo['name']}.json`,
69-
type: "GET",
70-
dataType: "json",
71-
success: function (commitActivity) {
94+
fetchJson(`${base_url}/${cache_repo}/github/commitActivity/${repo['name']}.json`)
95+
.then(function (commitActivity) {
7296
let activity_container = document.createElement("div")
7397
activity_container.className = "commit-activity-graph mt-2 mb-2 mx-3"
7498
activity_container.style.cssText = "display: flex; gap: 2px; height: 32px; align-items: flex-end;"
7599

76-
let maxCommits = Math.max(...commitActivity.map(week => week.total))
100+
let maxCommits = Math.max(...commitActivity.map(week => week.total), 0)
77101

78102
for (let week of commitActivity) {
79103
let bar = document.createElement("div")
@@ -94,11 +118,10 @@ function loadCommitActivity(repo, card_footer) {
94118
}
95119

96120
card_footer.insertBefore(activity_container, card_footer.firstChild)
97-
},
98-
error: function() {
121+
})
122+
.catch(function () {
99123
console.log(`No commit activity data available for ${repo['name']}`)
100-
}
101-
})
124+
})
102125
}
103126

104127
function createRepoDataRow(repo, card_footer, banner_link, card_title_link) {
@@ -116,14 +139,14 @@ function createRepoDataRow(repo, card_footer, banner_link, card_title_link) {
116139
github_link_image.className = "fa-fw fa-brands fa-github"
117140
github_link.prepend(github_link_image)
118141

119-
$.ajax({
120-
url: `${base_url}/${repo['name']}/`,
121-
type: "GET",
122-
success: function () {
142+
fetchWithNoCache(`${base_url}/${repo['name']}/`)
143+
.then(function (response) {
144+
if (!response.ok) return
145+
123146
banner_link.href = `${base_url}/${repo['name']}/`
124147
card_title_link.href = `${base_url}/${repo['name']}/`
125-
},
126-
})
148+
})
149+
.catch(function () {})
127150

128151
let star_link = document.createElement("a")
129152
star_link.className = "nav-link nav-link-sm project-nav-link ms-3 crowdin-ignore"
@@ -184,11 +207,8 @@ function addDocsLink(repo, readthedocs, repo_data_row) {
184207
}
185208

186209
function loadLanguageIcons(repo, card_footer) {
187-
$.ajax({
188-
url: `${base_url}/${cache_repo}/github/languages/${repo['name']}.json`,
189-
type: "GET",
190-
dataType: "json",
191-
success: function (languages) {
210+
fetchJson(`${base_url}/${cache_repo}/github/languages/${repo['name']}.json`)
211+
.then(function (languages) {
192212
let language_data_row = document.createElement("div")
193213
language_data_row.className = "card-group p-3 align-items-center"
194214
card_footer.appendChild(language_data_row)
@@ -202,8 +222,8 @@ function loadLanguageIcons(repo, card_footer) {
202222
language_icon.title = language
203223
language_data_row.append(language_icon)
204224
}
205-
}
206-
});
225+
})
226+
.catch(function () {})
207227
}
208228

209229
function buildRepoCard(repo, readthedocs) {
@@ -234,37 +254,32 @@ function buildRepoCard(repo, readthedocs) {
234254

235255

236256
// create project cards
237-
$(document).ready(function(){
238-
// Set cache = false for all jquery ajax requests.
239-
$.ajaxSetup({
240-
cache: false,
241-
});
242-
243-
// get readthedocs projects
244-
let readthedocs = []
245-
$.ajax({
246-
url: `${base_url}/${cache_repo}/readthedocs/projects.json`,
247-
type: "GET",
248-
dataType: "json",
249-
success: function (data) {
250-
for (let item in data) {
251-
readthedocs.push(data[item])
252-
}
253-
}
254-
});
255-
256-
$.ajax({
257-
url: `${base_url}/${cache_repo}/github/repos.json`,
258-
type: "GET",
259-
dataType:"json",
260-
success: function (result) {
257+
onDocumentReady(function () {
258+
container = document.getElementById("project-container")
259+
if (!container) return
260+
261+
let readthedocsRequest = fetchJson(`${base_url}/${cache_repo}/readthedocs/projects.json`)
262+
.then(function (data) {
263+
return Object.values(data)
264+
})
265+
.catch(function (error) {
266+
console.log("No ReadTheDocs project data available", error)
267+
return []
268+
})
269+
270+
let reposRequest = fetchJson(`${base_url}/${cache_repo}/github/repos.json`)
271+
272+
Promise.all([readthedocsRequest, reposRequest])
273+
.then(function ([readthedocs, result]) {
261274
let sorted = result.sort(globalThis.rankingSorter("stargazers_count", "name"))
262275

263-
for(let repo in sorted) {
264-
if (shouldProcessRepo(sorted[repo])) {
265-
buildRepoCard(sorted[repo], readthedocs)
276+
for (let repo of sorted) {
277+
if (shouldProcessRepo(repo)) {
278+
buildRepoCard(repo, readthedocs)
266279
}
267280
}
268-
}
269-
});
270-
});
281+
})
282+
.catch(function (error) {
283+
console.error("Error loading project data:", error)
284+
})
285+
})
Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
$(document).ready(function(){
2-
// remove the widgetbot-crate
3-
$("widgetbot-crate").remove()
4-
});
1+
function removeWidgetbotCrates() {
2+
document.querySelectorAll("widgetbot-crate").forEach(function (crate) {
3+
crate.remove()
4+
})
5+
}
6+
7+
if (document.readyState === "loading") {
8+
document.addEventListener("DOMContentLoaded", removeWidgetbotCrates)
9+
} else {
10+
removeWidgetbotCrates()
11+
}

index.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
- /assets/img/banners/AdobeStock_306976163_1920x1280.jpg
1212
- /assets/img/banners/AdobeStock_372471479_1920x1280.jpg
1313
ext-js:
14-
- href: "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"
15-
sri: "sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g=="
1614
- href: "https://cdn.jsdelivr.net/npm/@lizardbyte/shared-web@2026.314.32913/dist/format-number.js"
1715
- href: "https://cdn.jsdelivr.net/npm/@lizardbyte/shared-web@2026.314.32913/dist/ranking-sorter.js"
1816
js:

0 commit comments

Comments
 (0)