Add: player list navigator

This commit is contained in:
2018-07-03 17:35:40 +09:00
parent e28bcf3437
commit cec8e18470
8 changed files with 122 additions and 122 deletions
+51
View File
@@ -0,0 +1,51 @@
class PlayerListNavigator {
constructor(pageNoArea) {
let self = this;
this.pageNoArea = pageNoArea;
// console.log(parent);
}
addPlayerListPages(playerCount) {
lastPageNo = Math.ceil( (playerCount + 1) / 10 );
$(this.pageNoArea).empty();
for(let pageNo = 1; pageNo < lastPageNo + 1; pageNo++) {
$(this.pageNoArea).append(
"<a onClick='onClickPlayerListPage(" + pageNo + ")'> " + pageNo + " </a>"
);
}
}
}
function onClickPlayerListPage(pageNo) {
switch(pageNo) {
case "first":
playerListPage = 1;
loadPlayerListPage(playerListPage);
return;
case "prev":
if(playerListPage > 1)
playerListPage -= 1;
loadPlayerListPage(playerListPage);
return;
case "next":
if(playerListPage < lastPageNo)
playerListPage += 1;
loadPlayerListPage(playerListPage);
return;
case "last":
loadPlayerListPage(lastPageNo);
return;
}
loadPlayerListPage(pageNo);
}