/* Template Name: Grenviro Monitoring Author: Themesbrand Website: https://Themesbrand.com/ Contact: Themesbrand@gmail.com File: job grid list Js File */ var url = "build/json/"; var allJobList = ''; 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-grid-list.json", function (err, data) { if (err !== null) { console.log("Something went wrong: " + err); } else { allJobList = data; loadJobListData(allJobList, currentPage); paginationEvents(); } }); // load job list data function loadJobListData(datas, page) { var pages = Math.ceil(datas.length / itemsPerPage) if (page < 1) page = 1 if (page > pages) page = pages document.querySelector("#job-list").innerHTML = ''; if (currentPage == 1) { itemsPerPage = 7; document.querySelector("#job-list").insertAdjacentHTML('afterbegin', '
Don\'t miss your opportunity to improve your skills!
\'+ datas[i].companyName + '
\'+ datas[i].description + '
\