14 var logger = Logger('model/JobPagingModel.js');
22 var JobPagingModel = function (paramObj) {
23 logger.info('new JobPagingModel');
28 this.currentPoint = 1;
33 this.itemsOnPage = 10;
38 JobPagingModel.prototype.init = function (obj) {
39 logger.info('JobPagingModel.init : ' + JSON.stringify(obj));
41 this.setTotalCount(obj.totalCount);
42 this.setCurrentPoint(obj.currentPageNum);
45 JobPagingModel.prototype.getMaxPoint = function () {
49 JobPagingModel.prototype.setMaxPoint = function (value) {
50 this.maxPoint = value;
53 JobPagingModel.prototype.getEndPoint = function () {
57 JobPagingModel.prototype.setEndPoint = function () {
58 var total, start, max, diff;
59 total = this.getTotalPage();
60 start = this.getStartPoint();
61 max = this.getMaxPoint();
65 this.endPoint = start;
66 } else if (diff < max) {
67 this.endPoint = total;
69 this.endPoint = start + max - 1;
74 JobPagingModel.prototype.getStartPoint = function () {
75 return this.startPoint;
78 JobPagingModel.prototype.setStartPoint = function () {
80 current = this.getCurrentPoint();
81 max = this.getMaxPoint();
86 this.startPoint = (Math.floor(current / max) * max) + 1;
90 JobPagingModel.prototype.getCurrentPoint = function () {
91 return this.currentPoint;
94 JobPagingModel.prototype.setCurrentPoint = function (value) {
95 this.currentPoint = value || 1;
101 JobPagingModel.prototype.getTotalPage = function (value) {
102 return this.totalPage;
105 JobPagingModel.prototype.setTotalPage = function (value) {
106 this.totalPage = Math.ceil(this.getTotalCount() / this.itemsOnPage);
109 JobPagingModel.prototype.getTotalCount = function () {
110 return this.totalCount;
113 JobPagingModel.prototype.setTotalCount = function (value) {
114 this.totalCount = value || 0;
119 return JobPagingModel;