Skip to content

Commit f9beecc

Browse files
committed
Merge updateTabRank into calling function
The code is only used in one place with the same branching. Merging it seems more readable. No functional changes intended.
1 parent 5e8942e commit f9beecc

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

webapp/public/js/domjudge.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,8 +1339,9 @@ function initDiffEditor(editorId) {
13391339

13401340
const download = wrapper.find(".download")[0];
13411341
const edit = wrapper.find(".edit")[0];
1342-
const updateTabRank = (rank) => {
1343-
if (rank !== undefined) {
1342+
wrapper.find(".nav").on('show.bs.tab', (e) => {
1343+
if (e.target.dataset.rank.length > 0) {
1344+
const rank = parseInt(e.target.dataset.rank);
13441345
let url = new URL(download.href);
13451346
url.searchParams.set("fetch", rank);
13461347
enableButton(download, url);
@@ -1352,14 +1353,6 @@ function initDiffEditor(editorId) {
13521353
disableButton(download);
13531354
disableButton(edit);
13541355
}
1355-
};
1356-
wrapper.find(".nav").on('show.bs.tab', (e) => {
1357-
if (e.target.dataset.rank.length > 0) {
1358-
const rank = parseInt(e.target.dataset.rank);
1359-
updateTabRank(rank);
1360-
} else {
1361-
updateTabRank(undefined);
1362-
}
13631356
})
13641357

13651358
const diffTitle = document.getElementById(`${editorId}-title-diff`);

0 commit comments

Comments
 (0)