Skip to content

Commit 4f3df8a

Browse files
Rename some variables and files (#3)
* Rename some bits * Remove script from rspack
1 parent 9d8cb3f commit 4f3df8a

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

rspack.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export default defineConfig({
2828
"./scripts/graft-studio/header-scroll.js",
2929
"./scripts/graft-studio/jquery.mmenu.all.js",
3030
"./scripts/graft-studio/jquery.matchHeight.js",
31-
"./scripts/post_counts.ts",
3231
"applause-button/dist/applause-button.js",
3332
"cookieconsent/build/cookieconsent.min.js",
3433
],

scripts/post_counts.ts renamed to scripts/author-list.ts

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export function loadAuthorList() {
1212
});
1313
}
1414

15+
const PAGE_SIZE = 12;
16+
1517
function loadAuthorListForLetter(letter: string) {
1618
const activeAuthors: Author[] = JSON.parse(
1719
localStorage.getItem("activeAuthors") ?? "",
@@ -24,36 +26,22 @@ function loadAuthorListForLetter(letter: string) {
2426
displayCarousel(filteredAuthors);
2527
}
2628

27-
/*
28-
* Sort by number of posts descending, then by name
29-
*/
30-
function compareAuthor(a: Author, b: Author) {
31-
if (a.postCount > b.postCount) {
32-
return -1;
33-
}
34-
if (a.postCount < b.postCount) {
35-
return 1;
36-
}
37-
return a.name.localeCompare(b.name);
38-
}
39-
4029
function displayCarousel(authorList: Author[]) {
4130
authorList.sort(compareAuthor);
4231

43-
const pageSize = 12;
44-
const pageCount = Math.floor(authorList.length / pageSize);
45-
const remainder = authorList.length % pageSize;
32+
const pageCount = Math.floor(authorList.length / PAGE_SIZE);
33+
const remainder = authorList.length % PAGE_SIZE;
4634

4735
for (let i = 0; i < pageCount; i++) {
48-
const start = i * pageSize;
49-
const end = (i + 1) * pageSize;
36+
const start = i * PAGE_SIZE;
37+
const end = (i + 1) * PAGE_SIZE;
5038

5139
const authorsForPage = authorList.slice(start, end);
5240
displayPage(i, authorsForPage);
5341
}
5442

5543
if (remainder) {
56-
const start = pageCount * pageSize;
44+
const start = pageCount * PAGE_SIZE;
5745
const end = authorList.length;
5846

5947
const authorsForPage = authorList.slice(start, end);
@@ -203,3 +191,16 @@ interface Author {
203191
postCount: number;
204192
isActive: boolean;
205193
}
194+
195+
/*
196+
* Sort by number of posts descending, then by name
197+
*/
198+
function compareAuthor(a: Author, b: Author) {
199+
if (a.postCount > b.postCount) {
200+
return -1;
201+
}
202+
if (a.postCount < b.postCount) {
203+
return 1;
204+
}
205+
return a.name.localeCompare(b.name);
206+
}

scripts/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import jQuery from "jquery";
55
import { initialiseMenu } from "./initialise-menu";
66
import { loadClapCount } from "./load-clap-count";
77
import { makeTimestampsRelative } from "./elapsed";
8-
import { loadAuthorList } from "./post_counts";
8+
import { loadAuthorList } from "./author-list";
99

1010
jQuery(() => {
1111
initialiseMenu();

0 commit comments

Comments
 (0)