Skip to content

Commit bbd969b

Browse files
Reformat scripts & update icon font
1 parent e0542b0 commit bbd969b

File tree

6 files changed

+60
-47
lines changed

6 files changed

+60
-47
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ quote_type = double
1818

1919
[*.js]
2020
indent_size = 2
21+
max_line_length = 80
2122
quote_type = single
2223
curly_bracket_next_line = false
2324

MangAdventure/templates/layout.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
<link href="{% url 'manifest' %}" rel="manifest" type="application/manifest+json">
4949
<link href="{% url 'opensearch' %}" rel="search" title="{{ config.NAME }}"
5050
type="application/opensearchdescription+xml">
51-
<link href="https://cdn.statically.io/gh/mangadventure/font/a894374/dist/mangadventure.css"
52-
integrity="sha384-5/9RTmWZsNNhnHvp5fVgGoWBJoUAdWMMZ2XAYLJA5eT2pt5Bu+sYnYv+7to8veuZ"
51+
<link href="https://cdn.statically.io/gh/mangadventure/font/6363939/dist/mangadventure.css"
52+
integrity="sha384-H1ngkuzUHs3gdzggMN3f3+uloJM6QYgmJhtIMaTbcXk9UymtkKk4PAjsCajEmDxi"
5353
rel="stylesheet" type="text/css" crossorigin="anonymous">
5454
<link href="{{ config.FONT_URL }}" rel="stylesheet" type="text/css" crossorigin="anonymous">
5555
{% endcache %}

static/scripts/bookmark.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@
66
data.append('series', btn.dataset.series);
77
xhr.open('POST', btn.dataset.target, true);
88
xhr.onload = function() {
9-
switch(xhr.status) {
10-
case 201: btn.className = 'mi mi-bookmark bookmark-btn'; break;
11-
case 204: btn.className = 'mi mi-bookmark-o bookmark-btn'; break;
12-
default: console.error(xhr.statusText);
9+
switch (xhr.status) {
10+
case 201:
11+
btn.className = 'mi mi-bookmark bookmark-btn';
12+
break;
13+
case 204:
14+
btn.className = 'mi mi-bookmark-o bookmark-btn';
15+
break;
16+
default:
17+
console.error(xhr.statusText);
1318
}
1419
};
1520
xhr.send(data);

static/scripts/chapter.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
const img = ph.nextElementSibling;
66

7-
if(img.complete) ph.remove();
7+
if (img.complete) ph.remove();
88
else img.addEventListener('load', () => ph.remove(), true);
99

1010
img.addEventListener('click', function(evt) {
@@ -18,20 +18,25 @@
1818
document.getElementById('controls').removeAttribute('class');
1919
document.querySelector('.curr-page input')
2020
.addEventListener('keyup', function(evt) {
21-
if(evt.keyCode !== 13) return;
21+
if (evt.code !== 'Enter') return;
2222
const n = Number(this.value);
23-
if(!n || !Number.isInteger(n)) return;
24-
if(n === Number(this.placeholder)) return;
25-
if(n > Number(this.dataset.max)) return;
26-
if(n > 0) location.href = `../${n}/`;
23+
if (!n || !Number.isInteger(n)) return;
24+
if (n === Number(this.placeholder)) return;
25+
if (n > Number(this.dataset.max)) return;
26+
if (n > 0) location.href = `../${n}/`;
2727
});
2828
});
2929

3030
document.body.addEventListener('keyup', evt => {
31-
switch(evt.keyCode) {
32-
case 37: location.href = changePage('prev'); break;
33-
case 39: location.href = changePage('next'); break;
34-
default: return;
31+
switch (evt.code) {
32+
case 'ArrowLeft':
33+
location.href = changePage('prev');
34+
break;
35+
case 'ArrowRight':
36+
location.href = changePage('next');
37+
break;
38+
default:
39+
return;
3540
}
3641
});
3742
})(document.getElementById('placeholder'));

static/scripts/search.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
}
1313

1414
function matchQuery(q) {
15-
if(q.matches) {
15+
if (q.matches) {
1616
document.querySelectorAll('td.s-hidden').forEach((elem, i) => {
1717
const n = (i / 6 >> 0) + 1;
18-
switch(elem.className) {
18+
switch (elem.className) {
1919
case 'result-people s-hidden':
2020
appendInfo(n, 'people', 'Author/Artist', elem.innerHTML);
2121
break;
@@ -46,29 +46,30 @@
4646
const form = document.getElementById('search-form');
4747
const table = document.getElementById('result-table');
4848

49-
if(table && window.Tablesort) {
49+
if (table && window.Tablesort) {
5050
new window.Tablesort(table);
5151
table.querySelector('th').removeAttribute('data-sort-default');
5252
}
5353

5454
matchQuery(query);
5555

56-
form['categories[]'].forEach(c => {c.indeterminate = true});
56+
form['categories[]'].forEach(c => { c.indeterminate = true });
5757
(url.searchParams.get('categories') || '').split(',')
5858
.filter(e => e !== '').forEach(c => {
5959
c = c.trim().toLowerCase();
6060
const val = c[0] === '-' ? c.slice(1) : c;
61-
const input = Array.from(form['categories[]']).find(e => e.value === val);
61+
const input = Array.from(form['categories[]'])
62+
.find(e => e.value === val);
6263
input.indeterminate = false;
6364
input.checked = c[0] !== '-';
6465
});
6566
form.elements[5].lastChild.addEventListener('click', evt => {
6667
let el = evt.target;
67-
if(el.tagName === 'I' || el.nodeType === 3)
68+
if (el.tagName === 'I' || el.nodeType === 3)
6869
el = el.parentNode;
69-
if(el.className !== 'tooltip category') return;
70+
if (el.className !== 'tooltip category') return;
7071
const [state, input] = el.children;
71-
switch(state.className) {
72+
switch (state.className) {
7273
case 'mi mi-circle':
7374
state.className = 'mi mi-ok-circle';
7475
input.indeterminate = false;
@@ -92,19 +93,19 @@
9293
evt.stopPropagation();
9394
form.categories.value = Array.from(form['categories[]'])
9495
.reduce((acc, cur) => {
95-
if(cur.indeterminate) return acc;
96-
if(acc !== '') acc += ',';
97-
if(!cur.checked) acc += '-';
96+
if (cur.indeterminate) return acc;
97+
if (acc !== '') acc += ',';
98+
if (!cur.checked) acc += '-';
9899
return acc + cur.value;
99100
}, '');
100101
Array.from(form.elements).slice(0, 5).concat(form.categories)
101-
.forEach(el => {el.disabled = !el.value});
102+
.forEach(el => { el.disabled = !el.value });
102103
const search = form.action + '?' +
103104
new URLSearchParams(new FormData(form)).toString();
104105
const xhr = new XMLHttpRequest();
105106
xhr.open(form.method, search, true);
106107
xhr.onload = function() {
107-
if(this.status !== 200) {
108+
if (this.status !== 200) {
108109
document.open();
109110
document.write(this.responseText);
110111
document.close();
@@ -123,7 +124,9 @@
123124
history.replaceState({name: 'search'}, document.title, search);
124125
initialize();
125126
};
126-
xhr.onerror = function() {console.error(this.statusText)};
127+
xhr.onerror = function() {
128+
console.error(this.statusText);
129+
};
127130
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
128131
xhr.send(null);
129132
});

static/scripts/tinymce-init.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,27 @@
33
window.addEventListener('DOMContentLoaded', () => {
44
document.querySelectorAll('.tinymce').forEach(el => {
55
const mce_conf = JSON.parse(el.dataset.tinymceConfig);
6-
if('replace_icons' in mce_conf) {
6+
if ('replace_icons' in mce_conf) {
77
const old_setup = mce_conf.setup;
88
mce_conf.setup = editor => {
9-
if(typeof old_setup === 'function') old_setup(editor);
9+
if (typeof old_setup === 'function') old_setup(editor);
1010
editor.on('init', evt => {
11-
evt.target.editorContainer.querySelectorAll('i')
12-
.forEach(ico => {
13-
if(ico.className === 'mce-caret') {
14-
ico.className = 'mi mi-down';
15-
} else if(ico.className.endsWith('save')) {
16-
ico.className = 'mi mi-send';
17-
ico.nextElementSibling.innerHTML =
18-
mce_conf.submit_text || 'Send';
19-
} else {
20-
ico.className = ico.className
21-
.replace('mce-ico', 'mi')
22-
.replace('mce-i-', 'mi-');
23-
}
24-
});
11+
evt.target.editorContainer.querySelectorAll('i').forEach(ico => {
12+
if (ico.className === 'mce-caret') {
13+
ico.className = 'mi mi-down';
14+
} else if (ico.className.endsWith('save')) {
15+
ico.className = 'mi mi-send';
16+
ico.nextElementSibling.innerHTML =
17+
mce_conf.submit_text || 'Send';
18+
} else {
19+
ico.className = ico.className
20+
.replace('mce-ico', 'mi')
21+
.replace('mce-i-', 'mi-');
22+
}
23+
});
2524
});
2625
};
2726
}
28-
if(!tinyMCE.editors[el.id]) tinyMCE.init(mce_conf);
27+
if (!tinyMCE.editors[el.id]) tinyMCE.init(mce_conf);
2928
});
3029
});

0 commit comments

Comments
 (0)