/*
Template Name: Grenviro Monitoring
Author: Themesbrand
Website: https://Themesbrand.com/
Contact: Themesbrand@gmail.com
File: job candidate list init js
*/
var url = "build/json/";
var allcandidateList = '';
var prevButton = document.getElementById('page-prev');
var nextButton = document.getElementById('page-next');
// configuration variables
var currentPage = 1;
var itemsPerPage = 8;
var getJSON = function (jsonurl, callback) {
var xhr = new XMLHttpRequest();
xhr.open("GET", url + jsonurl, true);
xhr.responseType = "json";
xhr.onload = function () {
var status = xhr.status;
if (status === 200) {
callback(null, xhr.response);
} else {
callback(status, xhr.response);
}
};
xhr.send();
};
// get json
getJSON("job-candidate-list.json", function (err, data) {
if (err !== null) {
console.log("Something went wrong: " + err);
} else {
allcandidateList = data;
loadCandidateListData(allcandidateList, currentPage);
paginationEvents();
}
});
function loadCandidateListData(datas, page) {
var pages = Math.ceil(datas.length / itemsPerPage)
if (page < 1) page = 1
if (page > pages) page = pages
document.querySelector("#candidate-list").innerHTML = '';
for (var i = (page - 1) * itemsPerPage; i < (page * itemsPerPage) && i < datas.length; i++) {
// Array.from(datas).forEach(function (listData, index){
if (datas[i]) {
var bookmark = datas[i].bookmark ? "active" : "";
var isUserProfile = datas[i].userImg ? ''
: '
'+ datas[i].designation + '
\