Skip to content

Commit a5627f3

Browse files
committed
packages json cleanup, navbar filters shown if any set, packagist url validation fix
Signed-off-by: Jurj-Bogdan <jurj@dotkernel.com>
1 parent f15b4dd commit a5627f3

File tree

7 files changed

+193
-163
lines changed

7 files changed

+193
-163
lines changed

bootstrap/gulpfile.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ function js() {
5959
'node_modules/@popperjs/core/dist/umd/popper.min.js',
6060
'node_modules/bootstrap/dist/js/bootstrap.min.js',
6161
'js/base.js',
62-
'js/_integration.js'
62+
'js/_integration.js',
63+
'js/_maintenance-overview.js'
6364
]))
6465
.pipe(concat({path: 'laminas.js'}))
6566
.pipe(terser({mangle: false}).on('error', function (e) {

bootstrap/js/_integration.js

Lines changed: 86 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,114 @@
11
'use strict';
22

3-
document.querySelectorAll('.package-button.type, .package-button.category, .package-button.usage').forEach(button => {
4-
button.addEventListener('click', handleFilters);
5-
})
6-
7-
document.querySelectorAll('.package-button.keyword').forEach(button => {
8-
button.addEventListener('click', handleKeywords);
9-
})
10-
11-
document.querySelectorAll('.integration-filter').forEach(button => {
12-
button.addEventListener('click', removeKeyword);
13-
})
14-
15-
document.querySelectorAll('#integration-pagination a').forEach(a => {
16-
const url = new URL(a.href)
17-
for (let [k,v] of new URLSearchParams(window.location.search).entries()) {
18-
if (k === 'keywords[]' || k === 'q' || k === 'type' || k === 'category' || k === 'usage') {
19-
url.searchParams.set(k,v);
20-
}
3+
document.addEventListener('DOMContentLoaded', () => {
4+
const onIntegrationPage = document.querySelector('.package-button');
5+
if (! onIntegrationPage) {
6+
return;
217
}
22-
a.href = url.toString();
23-
})
248

25-
document.querySelector('#clear-filters-button')?.addEventListener('click', function () {
26-
const url = new URL(window.location.href);
9+
loadIntegrationPage();
10+
});
2711

28-
for (let [k,v] of new URLSearchParams(window.location.search).entries()) {
29-
if (k !== 'page') {
30-
url.searchParams.delete(k);
12+
function loadIntegrationPage()
13+
{
14+
document.querySelectorAll('.package-button.type, .package-button.category, .package-button.usage').forEach(button => {
15+
button.addEventListener('click', handleFilters);
16+
})
17+
18+
document.querySelectorAll('.package-button.keyword').forEach(button => {
19+
button.addEventListener('click', handleKeywords);
20+
})
21+
22+
document.querySelectorAll('.integration-filter').forEach(button => {
23+
button.addEventListener('click', removeKeyword);
24+
})
25+
26+
document.querySelectorAll('#integration-pagination a').forEach(a => {
27+
const url = new URL(a.href)
28+
for (let [k,v] of new URLSearchParams(window.location.search).entries()) {
29+
if (k === 'keywords[]' || k === 'q' || k === 'type' || k === 'category' || k === 'usage') {
30+
url.searchParams.set(k,v);
31+
}
3132
}
32-
}
33+
a.href = url.toString();
34+
})
3335

34-
window.location.replace(url.toString());
35-
});
36+
document.querySelector('#clear-filters-button')?.addEventListener('click', function () {
37+
const url = new URL(window.location.href);
3638

37-
document.querySelector('#integration-search-btn').addEventListener('click', function () {
38-
setSearchQuery(document.querySelector('#integration-search').value);
39-
});
39+
for (let [k,v] of new URLSearchParams(window.location.search).entries()) {
40+
if (k !== 'page') {
41+
url.searchParams.delete(k);
42+
}
43+
}
4044

41-
document.querySelector('#integration-search').addEventListener('keypress', function (e) {
42-
const search = this.value;
43-
if (e.which === 13) {
44-
setSearchQuery(search);
45-
}
46-
})
45+
window.location.replace(url.toString());
46+
});
47+
48+
document.querySelector('#integration-search-btn').addEventListener('click', function () {
49+
setSearchQuery(document.querySelector('#integration-search').value);
50+
});
4751

48-
function handleFilters() {
49-
for (const filter of ['type', 'category', 'usage']) {
50-
if (this.classList.contains(filter)) {
51-
handleParams(filter, this.dataset.value);
52+
document.querySelector('#integration-search').addEventListener('keypress', function (e) {
53+
const search = this.value;
54+
if (e.which === 13) {
55+
setSearchQuery(search);
56+
}
57+
})
58+
59+
function handleFilters() {
60+
for (const filter of ['type', 'category', 'usage']) {
61+
if (this.classList.contains(filter)) {
62+
handleParams(filter, this.dataset.value);
63+
}
5264
}
5365
}
54-
}
5566

56-
function handleParams(filterKey, filterValue) {
57-
const url = new URL(window.location.href);
58-
const params = new URLSearchParams(url.search);
67+
function handleParams(filterKey, filterValue) {
68+
const url = new URL(window.location.href);
69+
const params = new URLSearchParams(url.search);
5970

60-
if (filterValue === 'all' || params.get(filterKey) === filterValue) {
61-
url.searchParams.delete(filterKey);
71+
if (filterValue === 'all' || params.get(filterKey) === filterValue) {
72+
url.searchParams.delete(filterKey);
6273

63-
window.location.replace(url.toString());
64-
} else if (! params.has(filterKey, filterValue)) {
65-
url.searchParams.set(filterKey, filterValue);
74+
window.location.replace(url.toString());
75+
} else if (! params.has(filterKey, filterValue)) {
76+
url.searchParams.set(filterKey, filterValue);
6677

67-
window.location.replace(url.toString());
78+
window.location.replace(url.toString());
79+
}
6880
}
69-
}
7081

71-
function handleKeywords() {
72-
const url = new URL(window.location.href);
73-
const params = new URLSearchParams(url.search);
74-
const keyword = this.dataset.value;
82+
function handleKeywords() {
83+
const url = new URL(window.location.href);
84+
const params = new URLSearchParams(url.search);
85+
const keyword = this.dataset.value;
7586

76-
if (! params.has("keywords[]", keyword)) {
77-
params.append("keywords[]", keyword);
78-
url.search = params.toString();
87+
if (! params.has("keywords[]", keyword)) {
88+
params.append("keywords[]", keyword);
89+
url.search = params.toString();
7990

80-
window.location.replace(url.toString());
91+
window.location.replace(url.toString());
92+
}
8193
}
82-
}
8394

84-
function removeKeyword() {
85-
const url = new URL(window.location.href);
86-
const params = new URLSearchParams(url.search);
87-
const keyword = this.dataset.value;
95+
function removeKeyword() {
96+
const url = new URL(window.location.href);
97+
const params = new URLSearchParams(url.search);
98+
const keyword = this.dataset.value;
8899

89-
if (params.has("keywords[]", keyword)) {
90-
params.delete("keywords[]", keyword);
91-
url.search = params.toString();
100+
if (params.has("keywords[]", keyword)) {
101+
params.delete("keywords[]", keyword);
102+
url.search = params.toString();
92103

93-
window.location.replace(url.toString());
104+
window.location.replace(url.toString());
105+
}
94106
}
95-
}
96107

97-
function setSearchQuery(search) {
98-
const url = new URL(window.location.href);
108+
function setSearchQuery(search) {
109+
const url = new URL(window.location.href);
99110

100-
url.searchParams.set('q', search);
101-
window.location.replace(url.toString());
111+
url.searchParams.set('q', search);
112+
window.location.replace(url.toString());
113+
}
102114
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
'use strict';
2+
3+
document.addEventListener('DOMContentLoaded', () => {
4+
const onMaintenanceOverviewPage = document.querySelector('.status-button');
5+
if (! onMaintenanceOverviewPage) {
6+
return
7+
};
8+
9+
loadMaintenanceOverview();
10+
});
11+
12+
function loadMaintenanceOverview()
13+
{
14+
document.querySelectorAll('.status-button').forEach(button => {
15+
button.addEventListener('click', handleKeywords);
16+
})
17+
18+
function handleKeywords() {
19+
const url = new URL(window.location.href);
20+
const params = new URLSearchParams(url.search);
21+
const keyword = this.dataset.value;
22+
23+
if (! params.has("status[]", keyword)) {
24+
params.append("status[]", keyword);
25+
url.search = params.toString();
26+
27+
window.location.replace(url.toString());
28+
}
29+
}
30+
31+
document.querySelectorAll('.status-button.active').forEach(button => {
32+
button.addEventListener('click', removeStatus);
33+
})
34+
35+
function removeStatus() {
36+
const url = new URL(window.location.href);
37+
const params = new URLSearchParams(url.search);
38+
const status = this.dataset.value;
39+
40+
if (params.has("status[]", status)) {
41+
params.delete("status[]", status);
42+
url.search = params.toString();
43+
44+
window.location.replace(url.toString());
45+
}
46+
}
47+
48+
document.querySelector('#clear-filters-button')?.addEventListener('click', function () {
49+
const url = new URL(window.location.href);
50+
51+
for (let [k,v] of new URLSearchParams(window.location.search).entries()) {
52+
if (k !== 'page') {
53+
url.searchParams.delete(k);
54+
}
55+
}
56+
57+
window.location.replace(url.toString());
58+
});
59+
60+
document.querySelector('#package-search-btn').addEventListener('click', function () {
61+
setSearchQuery(document.querySelector('#package-search').value);
62+
});
63+
64+
document.querySelector('#package-search').addEventListener('keypress', function (e) {
65+
const search = this.value;
66+
if (e.which === 13) {
67+
setSearchQuery(search);
68+
}
69+
})
70+
71+
function setSearchQuery(search) {
72+
const url = new URL(window.location.href);
73+
74+
url.searchParams.set('q', search);
75+
window.location.replace(url.toString());
76+
}
77+
}

bootstrap/js/base.js

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -11,69 +11,3 @@
1111
}
1212
});
1313
}
14-
15-
{
16-
document.querySelectorAll('.status-button').forEach(button => {
17-
button.addEventListener('click', handleKeywords);
18-
})
19-
20-
function handleKeywords() {
21-
const url = new URL(window.location.href);
22-
const params = new URLSearchParams(url.search);
23-
const keyword = this.dataset.value;
24-
25-
if (! params.has("status[]", keyword)) {
26-
params.append("status[]", keyword);
27-
url.search = params.toString();
28-
29-
window.location.replace(url.toString());
30-
}
31-
}
32-
33-
document.querySelectorAll('.status-button.active').forEach(button => {
34-
button.addEventListener('click', removeStatus);
35-
})
36-
37-
function removeStatus() {
38-
const url = new URL(window.location.href);
39-
const params = new URLSearchParams(url.search);
40-
const status = this.dataset.value;
41-
42-
if (params.has("status[]", status)) {
43-
params.delete("status[]", status);
44-
url.search = params.toString();
45-
46-
window.location.replace(url.toString());
47-
}
48-
}
49-
50-
document.querySelector('#clear-filters-button')?.addEventListener('click', function () {
51-
const url = new URL(window.location.href);
52-
53-
for (let [k,v] of new URLSearchParams(window.location.search).entries()) {
54-
if (k !== 'page') {
55-
url.searchParams.delete(k);
56-
}
57-
}
58-
59-
window.location.replace(url.toString());
60-
});
61-
62-
document.querySelector('#package-search-btn').addEventListener('click', function () {
63-
setSearchQuery(document.querySelector('#package-search').value);
64-
});
65-
66-
document.querySelector('#package-search').addEventListener('keypress', function (e) {
67-
const search = this.value;
68-
if (e.which === 13) {
69-
setSearchQuery(search);
70-
}
71-
})
72-
73-
function setSearchQuery(search) {
74-
const url = new URL(window.location.href);
75-
76-
url.searchParams.set('q', search);
77-
window.location.replace(url.toString());
78-
}
79-
}

0 commit comments

Comments
 (0)