12 var logger = Logger('model/JobPagingModel.js');
20 var JobPagingModel = function (paramObj) {
21 logger.info('new JobPagingModel');
26 this.currentPoint = 1;
31 this.itemsOnPage = 10;
36 JobPagingModel.prototype.init = function (obj) {
37 logger.info('JobPagingModel.init : ' + JSON.stringify(obj));
39 this.setTotalCount(obj.totalCount);
40 this.setCurrentPoint(obj.currentPageNum);
43 JobPagingModel.prototype.getMaxPoint = function () {
47 JobPagingModel.prototype.setMaxPoint = function (value) {
48 this.maxPoint = value;
51 JobPagingModel.prototype.getEndPoint = function () {
55 JobPagingModel.prototype.setEndPoint = function () {
56 var total, start, max, diff;
57 total = this.getTotalPage();
58 start = this.getStartPoint();
59 max = this.getMaxPoint();
63 this.endPoint = start;
64 } else if (diff < max) {
65 this.endPoint = total;
67 this.endPoint = start + max - 1;
72 JobPagingModel.prototype.getStartPoint = function () {
73 return this.startPoint;
76 JobPagingModel.prototype.setStartPoint = function () {
78 current = this.getCurrentPoint();
79 max = this.getMaxPoint();
84 this.startPoint = (Math.floor(current / max) * max) + 1;
88 JobPagingModel.prototype.getCurrentPoint = function () {
89 return this.currentPoint;
92 JobPagingModel.prototype.setCurrentPoint = function (value) {
93 this.currentPoint = value || 1;
99 JobPagingModel.prototype.getTotalPage = function (value) {
100 return this.totalPage;
103 JobPagingModel.prototype.setTotalPage = function (value) {
104 this.totalPage = Math.ceil(this.getTotalCount() / this.itemsOnPage);
107 JobPagingModel.prototype.getTotalCount = function () {
108 return this.totalCount;
111 JobPagingModel.prototype.setTotalCount = function (value) {
112 this.totalCount = value || 0;
117 return JobPagingModel;