com2014-server/resources/static/js/getrequest.js

142 lines
4.3 KiB
JavaScript

$( document ).ready( () => {
$('body').scrollspy({ target: '#main-nav', offset: 130 })
$('#fullpage').fullpage({
// anchors: ['underPage', 'gradPage', 'phdPage'],
sectionsColor: ['#ffffff', '#f8f8f8'],
autoScrolling: false,
css3: true,
fitToSection: false,
afterLoad: function(anchorLink, index) {
// history.pushState(null, null, "");
// console.log(anchorLink);
}
});
$(".navbar a").on('click', function(event) {
// Make sure this.hash has a value before overriding default behavior
if (this.hash !== "") {
// Prevent default anchor click behavior
event.preventDefault();
// Store hash
var hash = this.hash;
// Using jQuery's animate() method to add smooth page scroll
// The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area
var offset = 0;
if (hash === "#home")
{
offset = -100;
}
else {
offset = -60;
}
$('html, body').animate({
scrollTop: ($(hash).offset().top + offset)
}, 1000, function(){
// Add hash (#) to URL when done scrolling (default click behavior)
// window.location.hash = hash;
});
}
});
$('#submission_info').hide();
$('#ulysses16_submit').hide();
$('#att48_submit').hide();
$('#st70_submit').hide();
$('#a280_submit').hide();
$('#pcb442_submit').hide();
$('#dsj1000_submit').hide();
$( "#ulysses16_submit" ).click(function() {
upload_loaderboard('ulysses16');
$('#ulysses16_submit').removeClass('btn-primary');
$('#ulysses16_submit').text('Submitted');
$('#ulysses16_submit').prop('disabled', true);
});
$( "#att48_submit" ).click(function() {
upload_loaderboard('att48');
$('#att48_submit').removeClass('btn-primary');
$('#att48_submit').text('Submitted');
$('#att48_submit').prop('disabled', true);
});
$( "#st70_submit" ).click(function() {
upload_loaderboard('st70');
$('#st70_submit').removeClass('btn-primary');
$('#st70_submit').text('Submitted');
$('#st70_submit').prop('disabled', true);
});
$( "#a280_submit" ).click(function() {
upload_loaderboard('a280');
$('#a280_submit').removeClass('btn-primary');
$('#a280_submit').text('Submitted');
$('#a280_submit').prop('disabled', true);
});
$( "#pcb442_submit" ).click(function() {
upload_loaderboard('pcb442');
$('#pcb442_submit').removeClass('btn-primary');
$('#pcb442_submit').text('Submitted');
$('#pcb442_submit').prop('disabled', true);
});
$( "#dsj1000_submit" ).click(function() {
upload_loaderboard('dsj1000');
$('#dsj1000_submit').removeClass('btn-primary');
$('#dsj1000_submit').text('Submitted');
$('#dsj1000_submit').prop('disabled', true);
});
// initialize with defaults
// $("#uploadfile").fileinput();
// with plugin options
$("#uploadfile").fileinput({
// theme: "fa",
'theme': 'fas',
showUpload:false,
previewFileType:'py',
maxFileCount: 1,
allowedFileExtensions: ["py"]
});
ConsoleLogHTML.connect(document.getElementById("console")); // Redirect log messages
// ConsoleLogHTML.disconnect(); // Stop redirecting
var url = window.location;
// GET REQUEST
$("#btnGetFiles").click( (event) => {
event.preventDefault();
ajaxGet();
});
// DO GET
function ajaxGet(){
$.ajax({
type : "GET",
url : "/api/files/getall",
success: (data) => {
//clear old data
$("#listFiles").html("");
/*
render list of files
*/
$("#listFiles").append('<ul>');
$.each(data, (index, filename) => {
$("#listFiles").append('<li><a href=' + url + 'api/files/' + filename +'>' + filename + '</a></li>');
});
$("#listFiles").append('</ul>');
},
error : (err) => {
$("#listFiles").html(err.responseText);
}
});
}
})