Commit 1650be7b authored by Nicolas Wavrant's avatar Nicolas Wavrant

runner: get rid off bad use of tests on var in javascript

parent 48eeebec
/*jslint undef: true */ /*jslint undef: true */
/*global $, window, $SCRIPT_ROOT, setRunningState, setCookie, getCookie, deleteCookie */ /*global $, window, $SCRIPT_ROOT, setRunningState, setCookie, getCookie, deleteCookie */
/*global currentState: true, running: true, $current: true, processType: true, currentProcess: true */ /*global currentState: true, running: true, $current: true, currentProcess: true, processTypes: true */
/*global sendStop: true, openedlogpage: true, logReadingPosition: true, speed: true */ /*global sendStop: true, openedlogpage: true, logReadingPosition: true, speed: true */
/*global isRunning: true */ /*global isRunning: true */
/* vim: set et sts=4: */ /* vim: set et sts=4: */
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
var url = $SCRIPT_ROOT + "/slapgridResult"; var url = $SCRIPT_ROOT + "/slapgridResult";
var currentState = false; var currentState = false;
var running = true; var running = true;
var processType = ""; var currentProcess = "";
var currentProcess; var processTypes = {instance:"instance", software:"software"};
var sendStop = false; var sendStop = false;
var forcedStop = false; var forcedStop = false;
var openedlogpage = ""; //content software or instance if the current page is software or instance log, otherwise nothing var openedlogpage = ""; //content software or instance if the current page is software or instance log, otherwise nothing
...@@ -91,14 +91,14 @@ function getRunningState() { ...@@ -91,14 +91,14 @@ function getRunningState() {
run_success = 0, run_success = 0,
param = { param = {
position: logReadingPosition, position: logReadingPosition,
log: (openedlogpage !== "") ? processType.toLowerCase() : "" log: (openedlogpage !== "") ? currentProcess : ""
}, },
jqxhr = $.post(url, param, function (data) { jqxhr = $.post(url, param, function (data) {
running = data.result; running = data.result;
if (data.instance.state) { if (data.instance.state) {
processType = "Instance"; currentProcess = processTypes.instance;
} else if (data.software.state) { } else if (data.software.state) {
processType = "Software"; currentProcess = processTypes.software;
} }
//show accurate right panel //show accurate right panel
if (running) { if (running) {
...@@ -108,7 +108,7 @@ function getRunningState() { ...@@ -108,7 +108,7 @@ function getRunningState() {
writeLogs(data); writeLogs(data);
setRunningState(data); setRunningState(data);
if(data.result) { if(data.result) {
updateStatus(processType.toLowerCase(), "running"); updateStatus(currentProcess, "running");
} else { } else {
build_success = (data.software.success === 0)? "terminated":"failed"; build_success = (data.software.success === 0)? "terminated":"failed";
run_success = (data.instance.success === 0)? "terminated":"failed"; run_success = (data.instance.success === 0)? "terminated":"failed";
...@@ -131,7 +131,7 @@ function stopProcess() { ...@@ -131,7 +131,7 @@ function stopProcess() {
var urlfor = $SCRIPT_ROOT + "stopSlapgrid", var urlfor = $SCRIPT_ROOT + "stopSlapgrid",
type = "slapgrid-sr"; type = "slapgrid-sr";
if (processType === "Instance") { if (currentProcess === processTypes.instance) {
type = "slapgrid-cp"; type = "slapgrid-cp";
} }
$.post(urlfor, {type: type}, function (data) { $.post(urlfor, {type: type}, function (data) {
...@@ -229,13 +229,13 @@ function setRunningState(data) { ...@@ -229,13 +229,13 @@ function setRunningState(data) {
} }
} else { } else {
if ( $("#running").is(":visible") ) { if ( $("#running").is(":visible") ) {
$("#error").Popup("Slapgrid finished running your " + processType + " Profile", {type: 'info', duration: 3000}); $("#error").Popup("Slapgrid finished running your " + currentProcess + " profile", {type: 'info', duration: 3000});
if ( forcedStop ) { if ( forcedStop ) {
updateStatus('instance', 'stopped'); updateStatus('instance', 'stopped');
updateStatus('software', 'stopped'); updateStatus('software', 'stopped');
} }
else { else {
updateStatus(processType.toLowerCase(), 'terminated'); updateStatus(currentProcess, 'terminated');
} }
//Update window!!! //Update window!!!
$("#slapswitch").attr('rel', 'opend'); $("#slapswitch").attr('rel', 'opend');
...@@ -256,7 +256,7 @@ function setRunningState(data) { ...@@ -256,7 +256,7 @@ function setRunningState(data) {
function runProcess(urlfor) { function runProcess(urlfor) {
"use strict"; "use strict";
if (!isRunning()) { if (!isRunning()) {
currentProcess = $.post(urlfor); $.post(urlfor);
if ( $("#running_info").children('span').length > 0 ) { if ( $("#running_info").children('span').length > 0 ) {
$("#running_info").children('p').remove(); $("#running_info").children('p').remove();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment