/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2019, b3log.org & hacpai.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
var bootstyle = {
getCurrentPage: function () {
var $next = $(".pagination-btn");
if ($next.length > 0) {
window.currentPage = $next.data("page");
}
},
setNavCurrent: function () {
$(".nav li a").each(function () {
var $this = $(this);
var path1 = latkeConfig.servePath + location.pathname,
path2 = latkeConfig.servePath + location.pathname.substr(0, location.pathname.length - 1);
if ($this.attr("href") === path1 || $this.attr("href") === path2) {
$this.parent().addClass("active");
} else if (/\/[0-9]+$/.test(location.pathname)) {
$(".nav li")[0].className = "current";
}
});
},
setCommentEmotions: function () {
// comments emotions
$(".comments").each(function () {
$(this).html(Util.replaceEmString($(this).html()));
});
},
init: function () {
this.getCurrentPage();
this.setNavCurrent();
this.setCommentEmotions();
}
};
$(function () {
bootstyle.init();
})
var getNextPage = function () {
var $more = $(".pagination-btn");
currentPage += 1;
var path = "/articles/";
if (location.pathname.indexOf("tags") > -1) {
var tagsPathnaem = location.pathname.split("/tags/");
var tags = tagsPathnaem[1].split("/");
path = "/articles/tags/" + tags[0] + "/";
} else if (location.pathname.indexOf("archives") > -1) {
var archivesPathname = location.pathname.split("/archives/");
var archives = archivesPathname[1].split("/");
path = "/articles/archives/" + archives[0] + "/" + archives[1] + "/";
}
var nextLabel = '',btn_background = '';
$.ajax({
url: latkeConfig.servePath + path + currentPage,
type: "GET",
beforeSend: function () {
nextLabel = $more.text();
btn_background = $more.css('background');
$more.text(' ').css("background",
"url(" + latkeConfig.staticServePath + "/skins/ease/images/ajax-loader.gif) no-repeat scroll center center #fefefe");
},
success: function (result, textStatus) {
var pagination = result.rslts.pagination;
for (var i = 0; i < result.rslts.articles.length; i++) {
var article = result.rslts.articles[i];
var articleHTML = new Array();
articleHTML.push('
');
articleHTML.push('');
articleHTML.push(article.articleAbstract);
articleHTML.push('');
articleHTML.push('
'+Label.tag1Label);
var articleTags = article.articleTags.split(',');
for(var j = 0;j < articleTags.length;j++){
var articleTag = articleTags[j];
articleHTML.push('
');
articleHTML.push('');
articleHTML.push(articleTag);
articleHTML.push('');
}
articleHTML.push('
');
$more.before(articleHTML.join(''));
}
if (pagination.paginationPageCount === currentPage) {
$more.remove();
} else {
$more.text(nextLabel).css("background", '');
}
}
});
};