-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswitcher.js
More file actions
50 lines (43 loc) · 1.05 KB
/
Copy pathswitcher.js
File metadata and controls
50 lines (43 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { moveOut, moveIn } from "./loader.js";
const mPage = 2;
/**
*
* @param {number} pageNumber
* @param {number} [maxPage=mPage]
*/
function switchPage(pageNumber, maxPage = mPage) {
moveOut("main", () => {
const link = `pages/${pageNumber}.html`;
$("#include").load(link);
if (pageNumber >= maxPage) {
$(".Arrow:last-child").css("visibility", "hidden");
} else {
$(".Arrow:last-child").css("visibility", "visible");
}
if (pageNumber == 1) {
$(".Arrow:first-child").css("visibility", "hidden");
} else {
$(".Arrow:first-child").css("visibility", "visible");
}
});
setTimeout(() => {
moveIn("main");
}, 500);
}
$(function () {
let currPage = 1;
if (currPage == 1) {
$(".Arrow:first-child").css("visibility", "hidden");
$("#include").load("pages/1.html");
} else {
$(".Arrow:first-child").css("visibility", "visible");
}
$(".Arrow:last-child").on("click", function () {
currPage += 1;
switchPage(currPage);
});
$(".Arrow:first-child").on("click", function () {
currPage -= 1;
switchPage(currPage);
});
});