function onLoad() { $("#upload-file-button").click(onClickUploadFileButton); $.getJSON( "/command/get-all-project-metadata", null, function(data) { renderProjects(data); }, "json" ); } $(onLoad); function onClickUploadFileButton(evt) { if ($("#project-name-input")[0].value.trim().length == 0) { window.alert("You must specify a project name."); evt.preventDefault(); return false; } else { $("#file-upload-form").attr("action", "/command/create-project-from-upload?" + [ "skip=" + $("#skip-input")[0].value, "limit=" + $("#limit-input")[0].value ].join("&")); } } function renderProjects(data) { var projects = []; for (var n in data.projects) { if (data.projects.hasOwnProperty(n)) { var project = data.projects[n]; project.id = n; project.date = Date.parseExact(project.modified, "yyyy-MM-ddTHH:mm:ssZ"); projects.push(project); } } if (projects.length == 0) { $('#body-empty').show(); $('#create-project-panel').remove().appendTo($('#body-empty-create-project-panel-container')); } else { $('#body-nonempty').show(); $('#create-project-panel').remove().appendTo($('#body-nonempty-create-project-panel-container')); projects.sort(function(a, b) { return b.date.getTime() - a.date.getTime(); }); if (projects.length > 10) { $('#body-nonempty-logo-container').css("vertical-align", "top"); $('#body-nonempty-create-project-panel-container').css("vertical-align", "top"); } var container = $("#projects").empty().show(); $('