/* HeuristicLab * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ var hubber = $.connection.progressHub; $(function () { // $.connection.hub.logging = true; $("#success-alert").hide(); var v = document.getElementById("userId").innerHTML; var busy = false; console.log(v); $.connection.hub.qs = { 'userid': v }; $.connection.hub.start().done(function () { $("#progress").css("width", 0 + '%'); $('#progress').attr('aria-valuenow', 0); //Initial connection to server hubber.server.handleMessage("Looking for connection..."); }); //Processes progress update received from server hubber.client.processMessage = function (message, value) { if (value > $('#progress').attr('aria-valuenow')) { $("#progress").css("width", value + '%'); $('#progress').attr('aria-valuenow', value); $("#progress").html(value + '%'); $("#result").html(message); } }; hubber.client.processName = function (name, random) { $("#nameCarrier" + random).html(name); }; hubber.client.saveComplete = function (text) { if(busy) window.setTimeout(1500); busy = true; $("#succText").html(text); $("#success-alert").alert(); $("#success-alert").fadeTo(2000, 500).slideUp(500, function () { $("#success-alert").hide(); busy = false; }); } hubber.client.createAlert = function (text, type) { $("#logs").html( "" + $("#logs").html()); } hubber.client.formatWrong = function (name, type) { addAlert("Format wrong for " + name + " of type " + type + ". Make sure you follow the right format pattern.", "warning"); } }); //Adds the current loaded job to Hive. function addtoHive() { var jobname = document.getElementById("jname").value; var resource = document.getElementById("jresource").value; if (jobname && jobname != "" && jobname != null) { hubber.server.changeNameResource(jobname, resource); document.getElementById("fakehiveadd").style.display = "none"; document.getElementById("progdiv").style.display = ""; document.getElementById("result").style.display = ""; document.getElementById("realhiveadd").click(); } else { alert("Job name not set!"); } } //Toggles a tasks child distribution function toggleChild(arr, idchilds) { console.log(arr + " toggled"); hubber.server.toggleChild(arr); if ($("#childs" + idchilds).css("display") == "none") $("#childs" + idchilds).css("display", ""); else $("#childs" + idchilds).css("display", "none"); $('body').click(); } //Changes a tasks priority function changePriority(arr, prior, idprior) { hubber.server.changePriority(arr, prior); resetPrior(idprior); switch (prior) { case 0: document.getElementById("prior" + idprior).className += "btn-default"; document.getElementById("prior" + idprior).innerHTML = "Low" break; case 1: document.getElementById("prior" + idprior).className += "btn-info"; document.getElementById("prior" + idprior).innerHTML = "Normal" break; case 2: document.getElementById("prior" + idprior).className += "btn-warning"; document.getElementById("prior" + idprior).innerHTML = "Urgent" break; case 3: document.getElementById("prior" + idprior).className += "btn-danger"; document.getElementById("prior" + idprior).innerHTML = "Critical"; break; } document.getElementById("prior" + idprior).innerHTML += ""; } //Resets the priorities from a view function resetPrior(id) { document.getElementById("prior" + id).className = "btn dropdown-toggle "; } //changes name of a task function changeName(arr, name, idname) { hubber.server.changeName(arr, name, idname); } function changeRepit(arr, repit) { hubber.server.changeRepit(arr, repit); } function paraEdit(arr, problem, name, type, value) { hubber.server.paraEdit(arr, problem, name, type, value); }