diff --git a/Bench4Q-Web/src/main/webapp/script/scriptManager/behavior.js b/Bench4Q-Web/src/main/webapp/script/scriptManager/behavior.js index 13b3950c..9ef1a00e 100644 --- a/Bench4Q-Web/src/main/webapp/script/scriptManager/behavior.js +++ b/Bench4Q-Web/src/main/webapp/script/scriptManager/behavior.js @@ -325,6 +325,10 @@ function Behavior(usePlugin, containerId) { "behavior_usePlugin", "batch")); } + + this.getBehaviorEditorMap = function(){ + return behaviorEditorMap; + } this.getPages = function() { updateBehaviorEditors(); diff --git a/Bench4Q-Web/src/main/webapp/script/scriptManager/contentVerification.js b/Bench4Q-Web/src/main/webapp/script/scriptManager/contentVerification.js index 3f2f7b85..c083fe5e 100644 --- a/Bench4Q-Web/src/main/webapp/script/scriptManager/contentVerification.js +++ b/Bench4Q-Web/src/main/webapp/script/scriptManager/contentVerification.js @@ -16,24 +16,48 @@ $(function() { }); }); -function checkPluginsInput(plugins) { +function checkPluginsInput(plugins, usePlugin) { + for (var i = 0; i < plugins.length; i++){ for (var j = 0; j < plugins[i].parameters.length; j++){ - if (plugins[i].parameters[j].check =="false") - return false; + if (plugins[i].parameters[j].check =="false"){ + $("#tabs").tabs("option", "active", 0 ); + + var usePluginEditorMap = usePlugin.getUsePluginEditorMap(); + $("#pluginEditor").append(usePluginEditorMap.get(plugins[i].id)); + var inputs = $("#"+ plugins[i].parameters[j].key + " input"); + for (var p = 0; p < inputs.length; p++){ + if ($(inputs[p]).val() == ""){ + $(inputs[p]).focus(); + break; + } + } + return false; + } } } return true; } -function checkPagesInput(pages) { +function checkPagesInput(pages, usePlugin) { + for (var i = 0;i < pages.length; i++){ for (var j = 0; j < pages[i].batches.length; j++){ for (var k = 0; k < pages[i].batches[j].behaviors.length; k++){ for (var q = 0; q < pages[i].batches[j].behaviors[k].parameters.length; q++){ - if (pages[i].batches[j].behaviors[k].parameters[q].check == "false"){ - return false; - } + if (pages[i].batches[j].behaviors[k].parameters[q].check =="false"){ + $("#tabs").tabs("option", "active", 1 ); + var behaviorEditorMap = usePlugin.getBehaviorEditorMap(); + $("#behaviorEditor").append(behaviorEditorMap.get(pages[i].batches[j].behaviors[k].id)); + var inputs = $("#"+ pages[i].batches[j].behaviors[k].parameters[q].key + " input"); + for (var p = 0; p < inputs.length; p++){ + if ($(inputs[p]).val() == ""){ + $(inputs[p]).focus(); + break; + } + } + return false; + } } } diff --git a/Bench4Q-Web/src/main/webapp/script/scriptManager/createScript.js b/Bench4Q-Web/src/main/webapp/script/scriptManager/createScript.js index b07a4ca9..4ceefa21 100644 --- a/Bench4Q-Web/src/main/webapp/script/scriptManager/createScript.js +++ b/Bench4Q-Web/src/main/webapp/script/scriptManager/createScript.js @@ -5,11 +5,12 @@ $(function() { $("#submitScript").click(function() { var formData = new FormData(); - var plugins = usePlugin.getPlugins( formData ); + var plugins = usePlugin.getPlugins(formData); var pages = usePlugin.getPages(); - if(checkPluginsInput(plugins) && checkPagesInput(pages)) + if(checkPluginsInput(plugins, usePlugin) && checkPagesInput(pages, usePlugin)) submitScript(pages, plugins, formData); - else + else{ information("Please complete the required parameters."); + } }); }); diff --git a/Bench4Q-Web/src/main/webapp/script/scriptManager/scriptEditor.js b/Bench4Q-Web/src/main/webapp/script/scriptManager/scriptEditor.js index 40e05caf..22c149ef 100644 --- a/Bench4Q-Web/src/main/webapp/script/scriptManager/scriptEditor.js +++ b/Bench4Q-Web/src/main/webapp/script/scriptManager/scriptEditor.js @@ -39,7 +39,7 @@ $(function() { var formData = new FormData(); var plugins = usePlugin.getPlugins(formData); var pages = usePlugin.getPages(); - if(checkPluginsInput(plugins) && checkPagesInput(pages)) + if(checkPluginsInput(plugins, usePlugin) && checkPagesInput(pages, usePlugin)) updateScript(scriptId,pages,plugins,formData); else information("Please complete the required parameters."); diff --git a/Bench4Q-Web/src/main/webapp/script/scriptManager/usePlugin.js b/Bench4Q-Web/src/main/webapp/script/scriptManager/usePlugin.js index 89d37f63..7ca6f3a5 100644 --- a/Bench4Q-Web/src/main/webapp/script/scriptManager/usePlugin.js +++ b/Bench4Q-Web/src/main/webapp/script/scriptManager/usePlugin.js @@ -85,6 +85,11 @@ function UsePlugin(behaviorListContainerId) { }); }); + + this.getUsePluginEditorMap = function() { + return usePluginEditorMap; + } + function getPluginList() { var usePlugin = this; $.post("loadPluginName", {}, function(data) { @@ -197,6 +202,10 @@ function UsePlugin(behaviorListContainerId) { return behavior.getPages(); } + this.getBehaviorEditorMap = function(){ + return behavior.getBehaviorEditorMap(); + } + this.initPluginAndPages = function(scriptObj){ initPluginList(scriptObj.usePlugins); behavior.initBehaviorList(scriptObj.pages);