[fix] notify user to add name and desc

This commit is contained in:
2021-01-07 20:22:20 +00:00
parent 040feb01c4
commit c309a5cc30
6 changed files with 105 additions and 17 deletions

View File

@@ -61,33 +61,52 @@ $( document ).ready( () => {
$('#dsj1000_submit').hide();
$( "#ulysses16_submit" ).click(function() {
upload_leaderboard('ulysses16');
disable_btn($('#ulysses16_submit'));
if (check_submit_info())
{
upload_leaderboard('ulysses16');
disable_btn($('#ulysses16_submit'));
}
});
$( "#att48_submit" ).click(function() {
upload_leaderboard('att48');
disable_btn($('#att48_submit'));
if (check_submit_info())
{
upload_leaderboard('att48');
disable_btn($('#att48_submit'));
}
});
$( "#st70_submit" ).click(function() {
upload_leaderboard('st70');
disable_btn($('#st70_submit'));
if (check_submit_info())
{
upload_leaderboard('st70');
disable_btn($('#st70_submit'));
}
});
$( "#a280_submit" ).click(function() {
upload_leaderboard('a280');
disable_btn($('#a280_submit'));
if (check_submit_info())
{
upload_leaderboard('a280');
disable_btn($('#a280_submit'));
}
});
$( "#pcb442_submit" ).click(function() {
upload_leaderboard('pcb442');
disable_btn($('#pcb442_submit'));
if (check_submit_info())
{
upload_leaderboard('pcb442');
disable_btn($('#pcb442_submit'));
}
});
$( "#dsj1000_submit" ).click(function() {
upload_leaderboard('dsj1000');
disable_btn($('#dsj1000_submit'));
if (check_submit_info())
{
upload_leaderboard('dsj1000');
disable_btn($('#dsj1000_submit'));
}
});
// Initialize file uploader
@@ -116,7 +135,11 @@ $( document ).ready( () => {
var fileName = e.target.files[0].name;
if(fileName !== "my_model.py")
{
alert('Please upload my_model.py');
Snackbar.show({
text: 'Please only upload my_model.py.',
pos: 'bottom-right',
duration: 10000
});
$('#btnSubmit').prop('disabled', true);
}
else
@@ -134,6 +157,30 @@ $( document ).ready( () => {
});
})
function check_submit_info() {
if(!$("#submit_name").val())
{
Snackbar.show({
text: 'Please tell us your name.',
pos: 'bottom-right',
duration: 10000
});
$("#submit_name").focus();
return false;
}
if(!$("#submit_desc").val())
{
Snackbar.show({
text: 'You forget to leave some comment.',
pos: 'bottom-right',
duration: 10000
});
$("#submit_desc").focus();
return false;
}
return true;
}
function disable_btn(btn) {
btn.show();
btn.removeClass('btn-primary');

17
resources/js/snackbar.min.js vendored Normal file
View File

@@ -0,0 +1,17 @@
/*!
* Snackbar v0.1.14
* http://polonel.com/Snackbar
*
* Copyright 2018 Chris Brame and other contributors
* Released under the MIT license
* https://github.com/polonel/Snackbar/blob/master/LICENSE
*/
!function(a,b){"use strict";"function"==typeof define&&define.amd?define([],function(){return a.Snackbar=b()}):"object"==typeof module&&module.exports?module.exports=a.Snackbar=b():a.Snackbar=b()}(this,function(){var a={};a.current=null;var b={text:"Default Text",textColor:"#FFFFFF",width:"auto",showAction:!0,actionText:"Dismiss",actionTextAria:"Dismiss, Description for Screen Readers",alertScreenReader:!1,actionTextColor:"#4CAF50",showSecondButton:!1,secondButtonText:"",secondButtonAria:"Description for Screen Readers",secondButtonTextColor:"#4CAF50",backgroundColor:"#323232",pos:"bottom-left",duration:5e3,customClass:"",onActionClick:function(a){a.style.opacity=0},onSecondButtonClick:function(a){},onClose:function(a){}};a.show=function(d){var e=c(!0,b,d);a.current&&(a.current.style.opacity=0,setTimeout(function(){var a=this.parentElement;a&&
// possible null if too many/fast Snackbars
a.removeChild(this)}.bind(a.current),500)),a.snackbar=document.createElement("div"),a.snackbar.className="snackbar-container "+e.customClass,a.snackbar.style.width=e.width;var f=document.createElement("p");if(f.style.margin=0,f.style.padding=0,f.style.color=e.textColor,f.style.fontSize="14px",f.style.fontWeight=300,f.style.lineHeight="1em",f.innerHTML=e.text,a.snackbar.appendChild(f),a.snackbar.style.background=e.backgroundColor,e.showSecondButton){var g=document.createElement("button");g.className="action",g.innerHTML=e.secondButtonText,g.setAttribute("aria-label",e.secondButtonAria),g.style.color=e.secondButtonTextColor,g.addEventListener("click",function(){e.onSecondButtonClick(a.snackbar)}),a.snackbar.appendChild(g)}if(e.showAction){var h=document.createElement("button");h.className="action",h.innerHTML=e.actionText,h.setAttribute("aria-label",e.actionTextAria),h.style.color=e.actionTextColor,h.addEventListener("click",function(){e.onActionClick(a.snackbar)}),a.snackbar.appendChild(h)}e.duration&&setTimeout(function(){a.current===this&&(a.current.style.opacity=0,
// When natural remove event occurs let's move the snackbar to its origins
a.current.style.top="-100px",a.current.style.bottom="-100px")}.bind(a.snackbar),e.duration),e.alertScreenReader&&a.snackbar.setAttribute("role","alert"),a.snackbar.addEventListener("transitionend",function(b,c){"opacity"===b.propertyName&&"0"===this.style.opacity&&("function"==typeof e.onClose&&e.onClose(this),this.parentElement.removeChild(this),a.current===this&&(a.current=null))}.bind(a.snackbar)),a.current=a.snackbar,document.body.appendChild(a.snackbar);getComputedStyle(a.snackbar).bottom,getComputedStyle(a.snackbar).top;a.snackbar.style.opacity=1,a.snackbar.className="snackbar-container "+e.customClass+" snackbar-pos "+e.pos},a.close=function(){a.current&&(a.current.style.opacity=0)};
// Pure JS Extend
// http://gomakethings.com/vanilla-javascript-version-of-jquery-extend/
var c=function(){var a={},b=!1,d=0,e=arguments.length;"[object Boolean]"===Object.prototype.toString.call(arguments[0])&&(b=arguments[0],d++);for(var f=function(d){for(var e in d)Object.prototype.hasOwnProperty.call(d,e)&&(b&&"[object Object]"===Object.prototype.toString.call(d[e])?a[e]=c(!0,a[e],d[e]):a[e]=d[e])};d<e;d++){var g=arguments[d];f(g)}return a};return a});
//# sourceMappingURL=snackbar.min.js.map

View File

@@ -43,7 +43,7 @@ socket.on('start', () => {
// Update Leaderboard Table
socket.on('leaderboard', (obj) => {
console.log(obj);
// console.log(obj);
$(".leaderboard-table").find("tr:not(:first):not(:last)").remove();
if(obj.ulysses16.length != 0) {
obj.ulysses16.forEach(element => {