You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
2.2 KiB

//
// variables and constants
//
//apiURL="http://localhost:8888"
apiURL="https://apis.jacquesingram.online"
$(document).ready(function () {
fetch();
setInterval(fetch, 1000*120);
});
function fetch() {
console.debug("enter -> fetchJobs()");
$.ajax({
type: "GET",
url: apiURL + "/jobs/",
dataType: 'json', // <-- Set dataType to 'json'
//contentType: "text/plain",
crossDomain: false,
success: function (data, status, jqXHR) {
console.log("good");
profitleaderboard(data);
},
error: function (error, status) {
console.log("error fetching leaderboard", error);
}
});
}
function load() {
console.debug("enter -> loadJobs()");
$.ajax({
type: "GET",
url: apiURL + "/jobs/load",
dataType: 'json', // <-- Set dataType to 'json'
//contentType: "text/plain",
crossDomain: false,
success: function (data, status, jqXHR) {
console.log("good");
profitleaderboard(data);
},
error: function (error, status) {
console.log("error fetching leaderboard", error);
}
});
}
function profitleaderboard(jobList) {
console.debug("enter -> profitleaderboard()");
console.log("jobList / " ,jobList);
var html = '';
size = jobList.length;
console.log("size / " + size);
for (var i =0;i< jobList.length; i++) {
html += '<tr>';
html += '<td class="METADATA DEBUG">' + (i+1) + '</td>'; // Integer (ranking)
html += '<td class="METADATA DEBUG">' + jobList[i].site + '</td>'; // Integer (ranking)
html += '<td class="METADATA DEBUG">' + jobList[i].company + '</td>'; // String (username)
html += '<td class="METADATA DEBUG"><a target="_job" href="' + jobList[i].job_url + '">'+jobList[i].title+ '</a></td>';
// html += '<td class="METADATA DEBUG">' + + '</td>'; // String (username)
html += '<td class="METADATA DEBUG">' + jobList[i].location + '</td>'; // String (username)
html += '<td class="METADATA DEBUG">' + jobList[i].job_type + '</td>'; // String (username)
html += '<td class="METADATA DEBUG">' + jobList[i].is_remote + '</td>'; // String (username)
html += '<td class="METADATA DEBUG">' + jobList[i].description + '</td>'; // String (username)
html += '</tr>';
}
$('#leaderboard > tbody').html(html);
}