var newsContent = new function() { this.pagination = null; this.getPageCount = function() { return ((null !== this.pagination) ? this.pagination.length : 0); }; this.excluir = function(id, itensFile) { var self = this; $.ajax({ url: '../gigi/news/delete.php', data: { id: id, itensFile: itensFile, c: new Date().getTime() }, dataType: 'json', type: 'POST', beforeSend: function() { }, complete: function() { }, error: function() { }, success: function(data) { if ((null !== data) && (0 === data.itens.length)) { self.pagination = null; self.loadNewsContentsByPage(0); } else { self.loadNewsContentsByFile(itensFile); } } }); }; this.loadNewsPagination = function() { var self = this; $.ajax({ url: "db/pages.json", data: { c: new Date().getTime() }, dataType: 'json', type: 'GET', beforeSend: function() { }, complete: function() { }, error: function() { }, success: function(data) { if ((null != data) && (null != data.pages)) { this.pagination = data.pages; } } }); }; this.loadNewsContentsByPage = function(currentPage) { var self = this; if (null !== this.pagination) { var pageCount = this.pagination.length; currentPage--; if ((-1 < currentPage) && (pageCount > currentPage)) { this.loadNewsContentsByFile(this.pagination[currentPage]); } else if (0 < pageCount) { this.loadNewsContentsByFile(this.pagination[0]); } else { // CRIAR PAGINA DEFAULT $("#news").empty(); $("#news").append("
" + item.mensagem + "
"; _html += "