Files
chocomae/src/web/js/player_list_navigator.js
T
2018-07-04 09:28:43 +09:00

54 lines
1.2 KiB
JavaScript

class PlayerListNavigator {
constructor(pageNoArea) {
let self = this;
this.pageNoArea = pageNoArea;
// console.log(parent);
this.activePageNo = 1;
this.lastPageNo = 1;
}
updateNavigator(activePageNo, lastPageNo) {
this.activePageNo = activePageNo;
this.lastPageNo = lastPageNo;
// this.lastPageNo = Math.ceil( (playerCount + 1) / 10 );
$(this.pageNoArea).empty();
for(let pageNo = 1; pageNo < this.lastPageNo + 1; pageNo++) {
$(this.pageNoArea).append(
"<a onClick='onClickPlayerListPage(this, " + pageNo + ")'> " + pageNo + " </a>"
);
}
}
onClickPlayerListPage(pageNo) {
switch(pageNo) {
case "first":
this.activePageNo = 1;
this.playerList.loadPlayerListPage(this.activePageNo);
return;
case "prev":
if(this.activePageNo > 1)
this.activePageNo -= 1;
this.playerList.loadPlayerListPage(this.activePageNo);
return;
case "next":
if(this.activePageNo < this.lastPageNo)
this.activePageNo += 1;
this.playerList.loadPlayerListPage(this.activePageNo);
return;
case "last":
this.playerList.loadPlayerListPage(this.lastPageNo);
return;
}
this.activePageNo = pageNo;
this.playerList.loadPlayerListPage(this.activePageNo);
}
}