diff --git a/Bench4Q-Web/src/main/webapp/login.jsp b/Bench4Q-Web/src/main/webapp/login.jsp index 0313b83d..7636c92b 100644 --- a/Bench4Q-Web/src/main/webapp/login.jsp +++ b/Bench4Q-Web/src/main/webapp/login.jsp @@ -1,154 +1,154 @@ -<%@page language="java" contentType="text/html; charset=GBK" pageEncoding="GBK"%> - - - - - - - Bench4Q - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - -
-
-
-
-

-Bench4Q is a new methodology for QoS benchmarking - -

-
-
-
-
- -
-
-
-

Welcome to Bench4Q!

-
- -
-
-
- - - - -
-
-
-
Sign in - (Register) -
-
-
-
-
-
- -
-
-    Username -
-
-
-
- - -
-
-
-
- -
-
-    Password -
-
-
-
- - -
-
-
- - -
-
- -
- - - -
-
- -
- - - - - +<%@page language="java" contentType="text/html; charset=GBK" pageEncoding="GBK"%> + + + + + + + Bench4Q + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+
+
+
+

+Bench4Q is a new methodology for QoS benchmarking + +

+
+
+
+
+ +
+
+
+

Welcome to Bench4Q!

+
+ +
+
+
+ + + + +
+
+
+
Sign in + (Register) +
+
+
+
+
+
+ +
+
+    Username +
+
+
+
+ + +
+
+
+
+ +
+
+    Password +
+
+
+
+ + +
+
+
+ + +
+
+ +
+ + + +
+
+ +
+ + + + + diff --git a/Bench4Q-Web/src/main/webapp/plugin.jsp b/Bench4Q-Web/src/main/webapp/plugin.jsp index c65f5db0..300ceeed 100644 --- a/Bench4Q-Web/src/main/webapp/plugin.jsp +++ b/Bench4Q-Web/src/main/webapp/plugin.jsp @@ -1,262 +1,262 @@ - -<%@ page language="java" contentType="text/html; charset=UTF-8" - pageEncoding="UTF-8"%> - - -<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> - -Bench4Q - - - -Create scripts by yourself. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - -
- -
- -
- -
-
-
-
- -

- Plug-ins -

-
- -
-
-
-
-
-
-
-
-

- -

- -

- -

-

- -

-
-
-
-
-
- - -
-
-
- -

- Behavior -

-
- -
-
-
-
-
-
- -
-
-
-

- -

- -

- -

-
-
- -
-
-
- -
- - - -
-
- -
- - -
- -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - -
- - + +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + +<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> + +Bench4Q + + + +Create scripts by yourself. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + +
+ +
+ +
+ +
+
+
+
+ +

+ Plug-ins +

+
+ +
+
+
+
+
+
+
+
+

+ +

+ +

+ +

+

+ +

+
+
+
+
+
+ + +
+
+
+ +

+ Behavior +

+
+ +
+
+
+
+
+
+ +
+
+
+

+ +

+ +

+ +

+
+
+ +
+
+
+ +
+ + + +
+
+ +
+ + +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + diff --git a/Bench4Q-Web/src/main/webapp/script/plugin-new.js b/Bench4Q-Web/src/main/webapp/script/plugin-new.js index ad85069e..05b60c7c 100644 --- a/Bench4Q-Web/src/main/webapp/script/plugin-new.js +++ b/Bench4Q-Web/src/main/webapp/script/plugin-new.js @@ -1,574 +1,591 @@ -PluginMethodListModel = function(pluginName, methodList) { - this.pluginName = pluginName; - this.methodList = methodList; -}; -var pluginList = new Array(); -var pluginMethodList = new Array(); - -$(document).ready(function() { - loadPluginList(); -}); - -function loadPluginList() { - $.post("loadPlugin", {}, function(data) { - if (!data.success) { - alert(data.failedMessage); - return; - } - data = data.data;// List pluginList - for (var i = 0; i < data.length; i++) { - pluginList.push(data[i]); - } - }); -} - -function getMethod(pluglin) { - var aMethodList = ""; - $.post("loadMethod", { - pluginName : plugin - }, function(data) { - if (!data.success) { - alert(data.failedMessage); - return; - } - data = data.data;// List methodList - for (var i = 0; i < data.length; i++) { - aMethodList.push(data[i]); - } - }); - return aMethodList; -} - -function addPlugin() { - - var html = ""; - for (var j = 0; j < pluginList.length; j++) { - var textNode = document.createTextNode(pluginList[j]); - var divNode = document.createElement("div"); - var inputNode = document.createElement("input"); - var brNode = document.createElement("br"); - inputNode.setAttribute("type", "radio"); - inputNode.setAttribute("name", "radio"); - inputNode.setAttribute("class", "chooseOnePlugin"); - inputNode.setAttribute("value", pluginList[j]); - divNode.appendChild(inputNode); - divNode.appendChild(textNode); - divNode.appendChild(brNode); - html += $(divNode).html() + "
"; - } - document.getElementById("choosePlugin").innerHTML = html; - $('#myModal_Plugin').modal('show'); - - $("input:radio").click(function() { - $(this).attr("checked", "checked"); - }); -} -// 选中的plug-in list -var pluginChoosedList = new Array(); -var num = 0; -function pluginFinish() { - - $('#myModal_Plugin').modal('hide'); - var data; - var item = $("input[name='radio']:checked").val(); - data = item + "_" + num; - pluginChoosedList.push(data); - num++; - /* - * //load选择的plugin的MethodList var aMethodList=getMethod(item); - * document.write(data); pluginMethodList.push(new - * PluginMethodListModel(data,aMethodList)); - */ - var div = document.createElement("div"); - var p = document.createElement("p"); - var textNode = document.createTextNode(data); - p.setAttribute("class", "pluginChoosedList");// 样式设计 - p.setAttribute("onClick", "showInsertPlugin(this)");// 引入的plugin - p.setAttribute("style", "cursor:pointer;float:left;"); - p.appendChild(textNode); - div.appendChild(p); - - document.getElementById("pluginArea").innerHTML += $(div).html(); -} - -function removePlugin() { - pluginChoosedList.pop(); - var last = document.getElementById("pluginArea").lastChild; - document.getElementById("pluginArea").removeChild(last); -} - -function insertPlugin() { - document.getElementById("pluginMethod").innerHTML = ""; - $('#myModal_Behavior').modal('show'); - var table = $('#pluginArea').html(); - document.getElementById("insertPluginAreaPlugins").innerHTML = table; -} - -function showInsertPlugin(selectNode) { - $('#behaviorFinish').attr('disabled', true); - var textNode = selectNode.firstChild; - var methodData = textNode.nodeValue; - - // 请求master获取其method方法 - getMethodList(methodData); - -} - -function getMethodList(methodData) { - var methodHtml = ""; - var methodList = new Array(); - // plug-in.method列表 - var plugin_method_List = new Array(); - var plugin_method_List_count = 0; - - // 得到_前的内容 - var type = methodData.split("_"); - var plugin = type[0]; - - $.post("loadMethod", { - pluginName : plugin - }, function(data) { - if (!data.success) { - alert(data.failedMessage); - return; - } - data = data.data;// List methodList - for (var i = 0; i < data.length; i++) { - plugin_method_List.push(methodData + "." + data[i]);// httpPlugin_0.post - plugin_method_List_count++; - methodList.push(data[i]); - } - for (var j = 0; j < methodList.length; j++) { - var hideTextNode = document.createTextNode(plugin_method_List - .valueOf(j)); - var hideNode = document.createElement("p"); - hideNode.setAttribute("class", "hide"); - hideNode.appendChild(hideTextNode); - - methodHtml += "
" - + methodList[j] + "

" - + plugin_method_List.valueOf(j) + "

"; - } - document.getElementById("pluginMethod").innerHTML = methodHtml; - }); -} -function show(selectedNode) { - var node = selectedNode.nextSibling.firstChild; - var behaviorData = node.nodeValue; - - $('#myModal_Behavior').modal('hide'); - - // 显示到showBehaviorsTable中 - var div = document.createElement("div"); - var a = document.createElement("a"); - var textNode = document.createTextNode(behaviorData); - a.setAttribute("class", "pluginChoosedList");// 样式设计 - a.setAttribute("onClick", "showMethodDocument(this)");// loadMethodParams - a.setAttribute("style", "cursor:pointer;float:left;"); - a.appendChild(textNode); - div.appendChild(a); - - document.getElementById('behaviorArea').appendChild(div); - -} - -function showMethodDocument(selectedNode) { - - var behaviorData = selectedNode.firstChild.nodeValue; - var temp; - var flag = false; - var length = $("#showPluginMethod").children().length; - if (length == 0) { - flag = false; - } else { - for (var j = 0; j < length; j++) { - var data=document.getElementById("showPluginMethod").childNodes[length].firstChild.firstChild.nodeValue; - if (data==behaviorData) { - // 该文档已经生成 - // document.getElementById("showPluginMethod").childNodes[j].firstChild.firstChild.nodeValue==behaviorData; - flag = true; - temp = j; - for (var m = 0; m < length; m++) { - $('#showPluginMethod').children()[m].Attr("class", "hide"); - } - $('#showPluginMethod').children()[temp].Attr("class", ""); - break; - } - } - } - if (flag == false) { - // 文档没有生成过,需要调用函数生成该文档 - for (var i = 0; i < length; i++) { - if ($('#showPluginMethod').children()[i].Attr("class", "")) { - $('#showPluginMethod').children()[i].Attr("class", "hide"); - } - } - loadMethodParams(behaviorData); - } -} - -var methodParams = new Array(); -var temp; -function loadMethodParams(behaviorData) { - var temp = behaviorData.split('.'); - var plugin = temp[0].split('_')[0]; - var method = temp[1]; - var fieldHTML = ""; - var documentHtml = ""; - var boxHeader=""; - - $ - .post( - "loadMethodParameters", - { - pluginName : plugin, - methodName : method - }, - function(data) { - if (!data.success) { - alert(data.failedMessage); - return; - } - data=data.data; - for (var i = 0; i < data.length; i++) { - methodParams.push(data[i]); - } - for (var j = 0; j < methodParams.length; j++) { - var methodParamModel = new MethodParamModel( - methodParams[j].name, - methodParams[j].lable, - methodParams[j].paramTypeModel); - var paramTypeModel = methodParamModel.paramTypeModel; - if (paramTypeModel.type == "field") { - fieldHTML += createField( - methodParamModel.lable, - methodParamModel.name, - paramTypeModel.size); - } else if (paramTypeModel.type == "multiField") { - fieldHTML += createMultiField( - methodParamModel.lable, - methodParamModel.name, - paramTypeModel.size); - } else if (paramTypeModel.type == "Table") { - fieldHTML += createTable(methodParamModel); - } else if (paramTypeModel.type == "CheckBox") { - fieldHTML += createTable(methodParamModel); - } - } - - boxHeader = "
" - + "" - + "

sample:" - + behaviorData - + "

" - + "" - + "
"; - - documentHtml = "

" - + behaviorData - + "

" - + boxHeader - + "
" - + fieldHTML - + "
"; - - document.getElementById("showPluginMethod").innerHTML += documentHtml; - }); -} - - -// 创建一个Table域 -function createTable(methodParamModel) { - - var name = methodParamModel.name; - var label = methodParamModel.label; - var table = methodParamModel.paramTypeModel; - var cols = table.cols; - var table_content = cols.split(table.valueSeperator); - /* - * var divNode = document.createElement("div"); var p = - * document.createElement("p"); var div = document.createElement("div"); var - * addCol = document.createElement("button"); var removeCol = - * document.createElement("button"); var tableNode = - * document.createElement("table"); var br1 = document.createElement("br"); - * var br2 = document.createElement("br"); var labelNode = - * document.createTextNode(label); var nameNode = - * document.createTextNode(name); - */ - - var th = document.createElement("th"); - var tr_content = document.createElement("tr"); - for (var i = 0; i < table_content.length; i++) { - var td = document.createElement("td"); - var text = document.createTextNode(table_content[i]); - var td_content = document.createElement("td"); - var text_content = document.createTextNode(""); - - td.appendChild(text); - th.appendChild(td); - td.appendChild(text_content); - tr_content.appendChild(td_content); - } - - var tableHead = th.innerHTML + tr_content.innerHTML; - var tableHtml = "

" - + label - + "

" - + name - + ":

" - + tableHead + "
"; - /* - * // divNode.setAttribute("class","sample_frame"); - * divNode.setAttribute("class", "Table"); divNode.setAttribute("id", name); - * div.setAttribute("class", "sample_sub_frame"); - * addCol.setAttribute("type", "submit"); addCol.setAttribute("onClick", - * "addCol(this);");// 添加一行 tableNode.setAttribute("class", - * "operateTableCols");// 便于为该Table添加删除行 removeCol.setAttribute("type", - * "submit"); removeCol.setAttribute("onClick", "removeCol();");// 删除一行 - * - * tableNode.appendChild(tr); tableNode.appendChild(tr_content); - * p.appendChild(labelNode); div.appendChild(nameNode + ":"); - * div.appendChild(br1); div.appendChild(addCol); - * div.appendChild(removeCol); div.appendChild(br2); - * div.appendChild(tableNode); divNode.appendChild(p); - * divNode.appendChild(div); - * - * return divNode; - */ - return tableHtml; - -} - -function addCol(selectedNode) { - var table = selectedNode.nextSibling.nextSibling.nextSibling; - var length = $(table).find("th").find("td").length; - var tr = document.createElement("tr"); - for (var i = 0; i < length; i++) { - var td = document.createElement("td"); - var text = document.createTextNode(""); - td.appendChild(text); - tr.appendChild(td); - } - table.appendChild(tr); -} - -function removeCol(selectedNode) { - var table = selectedNode.nextSibling.nextSibling; - var removeNode = table.lastChild; - table.removeChild(removeNode); -} - -// 创建一个CheckBox域 -function createCheckBox(methodParamModel) { - var name = methodParamModel.name; - var label = methodParamModel.label; - var checkBox = methodParamModel.paramTypeModel; - var rows = checkBox.rows; - var cb_content = rows.split(checkBox.valueSeperator); - - var divNode = document.createElement("div"); - var p = document.createElement("p"); - var div = document.createElement("div"); - var br = document.createElement("br"); - var labelNode = document.createTextNode(label); - var nameNode = document.createTextNode(name); - - // divNode.setAttribute("class","sample_frame"); - divNode.setAttribute("class", "CheckBox sample_frame"); - divNode.setAttribute("id", name); - div.setAttribute("class", "sample_sub_frame"); - p.appendChild(labelNode); - div.appendChild(nameNode + ":"); - div.appendChild(br); - for (var i = 0; i < cb_content.length; i++) { - var checkBoxNode = document.createElement("input"); - checkBoxNode.setAttribute("type", "checkbox"); - checkBoxNode.setAttribute("name", "checkbox_" + name); - checkBoxNode.setAttribute("value", cb_content[i]); - var checkBoxValue = document.createTextNode(cb_content[i]); - - checkBoxNode.appendChild(checkBoxValue); - div.appendChild(checkBoxNode); - - } - - divNode.appendChild(p); - divNode.appendChild(div); - - return divNode.innerHTML; - -} -// 创建一个label加一个input的域 -function createField(label, name, size) { - - // document.write(label+","+name+","+size); - if (size == 0) { - size = 20; - } - - var fieldHTML = "

" + label - + "

" + name - + ":
"; - return fieldHTML; - -} -// 创建一个可以增加field的域 -function createMultiField(label, name, size) { - if (size == 0) { - size = 20; - } - var multiFieldHTML = "

" - + name - + ":" - + label - + "


"; - - return multiFieldHTML; -} - -var field = 0; -function addField(size) { - var data = "field_" + field + ":"; - field = field + 1; - var newTrNode = document.createElement("tr"); - var newTdNode1 = document.createElement("td"); - var newTdNode2 = document.createElement("td"); - var newTdNode3 = document.createElement("td"); - var i = document.createElement("i"); - i.setAttribute("class", "icon-trash"); - i.setAttribute("style", "cursor:pointer"); - i.setAttribute("onClick", "deleteField(this)"); - newTdNode1.setAttribute("style", "width:40px;cursor:pointer;"); - newTdNode1.setAttribute("class", data); - newTdNode2.setAttribute("style", "width:40px;"); - var textNode = document.createTextNode(data); - var inputNode = document.createElement("input"); - inputNode.setAttribute("type", "text"); - inputNode.setAttribute("size", size); - - newTdNode1.appendChild(textNode); - newTdNode2.appendChild(inputNode); - newTdNode3.appendChild(i); - newTrNode.appendChild(newTdNode1); - newTrNode.appendChild(newTdNode2); - newTrNode.appendChild(newTdNode3); - document.getElementById("addFieldTable").appendChild(newTrNode); -} -function deleteField(selectedNode) { - var deletedNode = selectedNode.parentNode.parentNode; - var parentNode = deletedNode.parentNode; - parentNode.removeChild(deletedNode); -} -function removeField() { - $('#addFieldTable').empty(); -} - -$('#removeAllPlugin').click(function() { - document.getElementById('pluginArea').innerHTML = ""; -}); - -$('#pluginCancel').click(function() { - $('#myModal_Plugin').modal('hide'); -}); - -$('#behaviorFinish').click(function() { - $('#myModal_Behavior').modal('hide'); -}); - -$('#behaviorCancel').click(function() { - $('#myModal_Behavior').modal('hide'); -}); - -function uploadBehavior(selectNode) { - var uploadNode = selectNode.parentNode.parentNode; - var tableNum = 0; - var tableList = ""; - var tableNode = new Array(); - var checkList = ""; - var fieldList = ""; - var multiField = new Array(); - var multiFieldList = ""; - var multiFieldNum = 0; - var temp; - - var childNode = new Array(); - var length = uploadNode.children().length; - for (var i = 0; i < length; i++) { - childNode[i] = uploadNode.children()[i]; - } - for (var j = 0; j < length; j++) { - var child = childNode[i]; - if (child.Attr("class") == "Table") { - var table = child.find("div").find("table"); - var col = table.find("tr"); - var row = table.find("th").find("td"); - tableNode[tableNum] = ""; - for (var p = 1; p <= col; p++) { - for (var q = 0; q < row; q++) { - tableNode[tableNum] += $(table.children()[p].children()[q]) - .val() - + ","; - } - } - tableList += tableNode[tableNum] + ";"; - tableNum++; - - } else if (child.Attr("class") == "CheckBox") { - var chk_value = []; - $('input[name="checkbox_"' + child.attr("id") + ']:checked').each( - function() { - chk_value.push($(this).val()); - }); - var length = chk_value.length; - for (var p = 0; p < length; p++) { - checkList += chk_value[p] + ","; - } - - } else if (child.Attr("class") == "Field") { - var input = child.find("div").find("input"); - var value = $(input).val(); - fieldList += value + ";"; - } else if (child.Attr("class") == "MultiField") { - var table = child.find("div").find("table"); - var length = table.children().length; - multiField[multiFieldNum] = ""; - for (var p = 0; p < length; p++) { - temp = $(table.children()[p].children()[1]).val(); - multiField[multiFieldNum] += temp + ";"; - } - multiFieldList += multiField[multiFieldNum] + ";"; - multiFieldNum++; - - } - } - var uploadBehavior = new UploadBehaviorRequestModel(tableList, checkList, - fieldList, multiFieldList); - upload(uploadBehavior); -} -// 未完待续 -function upload(uploadBehavior) { - $.ajax({ - type : "POST", - url : "uploadBehavior", - contentType : "application/json", - data : JSON.stringify(uploadBehavior), - success : function(data) { - if (data.success) - alert("Congratulations! You have upload this behavior!"); - else - alert(data.failedMessage); - }, - error : function(request, status, error) { - } - }); +PluginMethodListModel = function(pluginName, methodList) { + this.pluginName = pluginName; + this.methodList = methodList; +}; +var pluginList = new Array(); +var pluginMethodList = new Array(); +var index = 0; +$(document).ready(function() { + loadPluginList(); +}); + +function loadPluginList() { + $.post("loadPlugin", {}, function(data) { + if (!data.success) { + alert(data.failedMessage); + return; + } + data = data.data;// List pluginList + for (var i = 0; i < data.length; i++) { + pluginList.push(data[i]); + } + }); +} + +function getMethod(pluglin) { + var aMethodList = ""; + $.post("loadMethod", { + pluginName : plugin + }, function(data) { + if (!data.success) { + alert(data.failedMessage); + return; + } + data = data.data;// List methodList + for (var i = 0; i < data.length; i++) { + aMethodList.push(data[i]); + } + }); + return aMethodList; +} + +function addPlugin() { + + var html = ""; + for (var j = 0; j < pluginList.length; j++) { + var textNode = document.createTextNode(pluginList[j]); + var divNode = document.createElement("div"); + var inputNode = document.createElement("input"); + var brNode = document.createElement("br"); + inputNode.setAttribute("type", "radio"); + inputNode.setAttribute("name", "radio"); + inputNode.setAttribute("class", "chooseOnePlugin"); + inputNode.setAttribute("value", pluginList[j]); + divNode.appendChild(inputNode); + divNode.appendChild(textNode); + divNode.appendChild(brNode); + html += $(divNode).html() + "
"; + } + document.getElementById("choosePlugin").innerHTML = html; + $('#myModal_Plugin').modal('show'); + + $("input:radio").click(function() { + $(this).attr("checked", "checked"); + }); +} +// 选中的plug-in list +var pluginChoosedList = new Array(); +var num = 0; +function pluginFinish() { + + $('#myModal_Plugin').modal('hide'); + var data; + var item = $("input[name='radio']:checked").val(); + data = item + "_" + num; + pluginChoosedList.push(data); + num++; + + var div = document.createElement("div"); + var p = document.createElement("p"); + var textNode = document.createTextNode(data); + p.setAttribute("class", "pluginChoosedList");// 样式设计 + p.setAttribute("onClick", "showInsertPlugin(this)");// 引入的plugin + p.setAttribute("style", "cursor:pointer;float:left;"); + p.appendChild(textNode); + div.appendChild(p); + + document.getElementById("pluginArea").innerHTML += $(div).html(); +} + +function removePlugin() { + pluginChoosedList.pop(); + var last = document.getElementById("pluginArea").lastChild; + document.getElementById("pluginArea").removeChild(last); +} + +function insertPlugin() { + document.getElementById("pluginMethod").innerHTML = ""; + $('#myModal_Behavior').modal('show'); + var table = $('#pluginArea').html(); + document.getElementById("insertPluginAreaPlugins").innerHTML = table; +} + +function showInsertPlugin(selectNode) { + $('#behaviorFinish').attr('disabled', true); + var textNode = selectNode.firstChild; + var methodData = textNode.nodeValue; + getMethodList(methodData); +} + +function removeInsertPlugin(){ + var last=document.getElementById("behaviorArea").lastChild; + document.getElementById("behaviorArea").removeChild(last); +} + +function getMethodList(methodData) { + var methodHtml = ""; + var methodList = new Array(); + // plug-in.method列表 + var plugin_method_List = new Array(); + var plugin_method_List_count = 0; + + // 得到_前的内容 + var type = methodData.split("_"); + var plugin = type[0]; + + $.post("loadMethod", { + pluginName : plugin + }, function(data) { + if (!data.success) { + alert(data.failedMessage); + return; + } + data = data.data;// List methodList + for (var i = 0; i < data.length; i++) { + plugin_method_List.push(methodData + "." + data[i]);// httpPlugin_0.post + plugin_method_List_count++; + methodList.push(data[i]); + } + for (var j = 0; j < methodList.length; j++) { + var hideTextNode = document.createTextNode(plugin_method_List + .valueOf(j)); + var hideNode = document.createElement("p"); + hideNode.setAttribute("class", "hide"); + hideNode.appendChild(hideTextNode); + + methodHtml += "
" + + methodList[j] + "

" + + plugin_method_List.valueOf(j) + "

"; + } + document.getElementById("pluginMethod").innerHTML = methodHtml; + }); +} +function show(selectedNode) { + var node = selectedNode.nextSibling.firstChild; + var behaviorData = node.nodeValue; + + $('#myModal_Behavior').modal('hide'); + + // 显示到showBehaviorsTable中 + var div = document.createElement("div"); + var a = document.createElement("a"); + var textNode = document.createTextNode(behaviorData); + a.setAttribute("class", index);// 样式设计 + a.setAttribute("onClick", "showMethodDocument(this)");// loadMethodParams + a.setAttribute("style", "cursor:pointer;float:left;"); + a.appendChild(textNode); + div.appendChild(a); + + document.getElementById('behaviorArea').appendChild(div); + loadMethodParams(behaviorData, index); + index++; +} + +function showMethodDocument(selectedNode) { + var behaviorIndex = $(selectedNode).attr("class"); + var length = $("#showPluginMethod").children().length; + var div = $("#showPluginMethod").children(); + $(div[behaviorIndex]).attr("class", "show"); + $(div[behaviorIndex]).show(); + for (var i = 0; i < length; i++) { + // alert("i is "+i); + // alert("id is "+div[i].getAttribute("id")); + if (div[i].getAttribute("id") != behaviorIndex) { + // alert(div[i].getAttribute("id")+"!="+behaviorIndex); + $(div[i]).hide(); + } + } +} + +function loadMethodParams(behaviorData, behaviorIndex) { + var methodParams = new Array(); + var temp = behaviorData.split('.'); + var plugin = temp[0].split('_')[0]; + var method = temp[1]; + var fieldHTML = ""; + var documentHtml = ""; + var boxHeader = ""; + + $ + .post( + "loadMethodParameters", + { + pluginName : plugin, + methodName : method + }, + function(data) { + if (!data.success) { + alert(data.failedMessage); + return; + } + data = data.data; + for (var i = 0; i < data.length; i++) { + methodParams.push(data[i]); + } + for (var j = 0; j < methodParams.length; j++) { + var methodParamModel = new MethodParamModel( + methodParams[j].name, + methodParams[j].lable, + methodParams[j].paramTypeModel); + var paramTypeModel = methodParamModel.paramTypeModel; + if (paramTypeModel.type == "field") { + fieldHTML += createField( + methodParamModel.lable, + methodParamModel.name, + paramTypeModel.size, behaviorIndex); + } else if (paramTypeModel.type == "multiField") { + fieldHTML += createMultiField( + methodParamModel.lable, + methodParamModel.name, + paramTypeModel.size, behaviorIndex); + } else if (paramTypeModel.type == "Table") { + fieldHTML += createTable(methodParamModel); + } else if (paramTypeModel.type == "CheckBox") { + fieldHTML += createTable(methodParamModel); + } + } + + boxHeader = "
" + + "" + + "

sample:" + + behaviorData + + "

" + + "" + + "
"; + + documentHtml = "

" + + behaviorData + + "

" + + boxHeader + + "
" + + fieldHTML + + "
"; + document.getElementById("showPluginMethod").innerHTML += documentHtml; + }); +} + +//创建一个label加一个input的域 +function createField(label, name, size, behaviorIndex) { + if (size == 0) { + size = 20; + } + var fieldHTML = "

" + label + + "

" + name + + ":
"; + return fieldHTML; +} + +// 创建一个可以增加field的域 +function createMultiField(label, name, size, behaviorIndex) { + if (size == 0) { + size = 20; + } + var multiFieldHTML = "

" + + name + + ":" + + label + + "


"; + return multiFieldHTML; +} + +var field; +function addField(size,addId) { + if(document.getElementById("addFieldTable_"+addId).childNodes.length==0){ + field=0; + } + //alert("addId:"+addId+",field:"+field); + var data = "field_" + field + ":"; + field = field + 1; + var newTrNode = document.createElement("tr"); + var newTdNode1 = document.createElement("td"); + var newTdNode2 = document.createElement("td"); + var newTdNode3 = document.createElement("td"); + var i = document.createElement("i"); + i.setAttribute("class", "icon-trash"); + i.setAttribute("style", "cursor:pointer"); + i.setAttribute("onClick", "deleteField(this)"); + newTdNode1.setAttribute("style", "width:40px;cursor:pointer;"); + newTdNode1.setAttribute("class", data); + newTdNode2.setAttribute("style", "width:40px;"); + var textNode = document.createTextNode(data); + var inputNode = document.createElement("input"); + inputNode.setAttribute("type", "text"); + inputNode.setAttribute("size", size); + + newTdNode1.appendChild(textNode); + newTdNode2.appendChild(inputNode); + newTdNode3.appendChild(i); + newTrNode.appendChild(newTdNode1); + newTrNode.appendChild(newTdNode2); + newTrNode.appendChild(newTdNode3); + document.getElementById("addFieldTable_"+addId).appendChild(newTrNode); +} + +function deleteField(selectedNode) { + var deletedNode = selectedNode.parentNode.parentNode; + var parentNode = deletedNode.parentNode; + parentNode.removeChild(deletedNode); +} + +// 创建一个Table域 +function createTable(methodParamModel) { + + var name = methodParamModel.name; + var label = methodParamModel.label; + var table = methodParamModel.paramTypeModel; + var cols = table.cols; + var table_content = cols.split(table.valueSeperator); + /* + * var divNode = document.createElement("div"); var p = + * document.createElement("p"); var div = document.createElement("div"); var + * addCol = document.createElement("button"); var removeCol = + * document.createElement("button"); var tableNode = + * document.createElement("table"); var br1 = document.createElement("br"); + * var br2 = document.createElement("br"); var labelNode = + * document.createTextNode(label); var nameNode = + * document.createTextNode(name); + */ + + var th = document.createElement("th"); + var tr_content = document.createElement("tr"); + for (var i = 0; i < table_content.length; i++) { + var td = document.createElement("td"); + var text = document.createTextNode(table_content[i]); + var td_content = document.createElement("td"); + var text_content = document.createTextNode(""); + + td.appendChild(text); + th.appendChild(td); + td.appendChild(text_content); + tr_content.appendChild(td_content); + } + + var tableHead = th.innerHTML + tr_content.innerHTML; + var tableHtml = "

" + + label + + "

" + + name + + ":

" + + tableHead + "
"; + /* + * // divNode.setAttribute("class","sample_frame"); + * divNode.setAttribute("class", "Table"); divNode.setAttribute("id", name); + * div.setAttribute("class", "sample_sub_frame"); + * addCol.setAttribute("type", "submit"); addCol.setAttribute("onClick", + * "addCol(this);");// 添加一行 tableNode.setAttribute("class", + * "operateTableCols");// 便于为该Table添加删除行 removeCol.setAttribute("type", + * "submit"); removeCol.setAttribute("onClick", "removeCol();");// 删除一行 + * + * tableNode.appendChild(tr); tableNode.appendChild(tr_content); + * p.appendChild(labelNode); div.appendChild(nameNode + ":"); + * div.appendChild(br1); div.appendChild(addCol); + * div.appendChild(removeCol); div.appendChild(br2); + * div.appendChild(tableNode); divNode.appendChild(p); + * divNode.appendChild(div); + * + * return divNode; + */ + return tableHtml; + +} + +function addCol(selectedNode) { + var table = selectedNode.nextSibling.nextSibling.nextSibling; + var length = $(table).find("th").find("td").length; + var tr = document.createElement("tr"); + for (var i = 0; i < length; i++) { + var td = document.createElement("td"); + var text = document.createTextNode(""); + td.appendChild(text); + tr.appendChild(td); + } + table.appendChild(tr); +} + +function removeCol(selectedNode) { + var table = selectedNode.nextSibling.nextSibling; + var removeNode = table.lastChild; + table.removeChild(removeNode); +} + +// 创建一个CheckBox域 +function createCheckBox(methodParamModel) { + var name = methodParamModel.name; + var label = methodParamModel.label; + var checkBox = methodParamModel.paramTypeModel; + var rows = checkBox.rows; + var cb_content = rows.split(checkBox.valueSeperator); + + var divNode = document.createElement("div"); + var p = document.createElement("p"); + var div = document.createElement("div"); + var br = document.createElement("br"); + var labelNode = document.createTextNode(label); + var nameNode = document.createTextNode(name); + + // divNode.setAttribute("class","sample_frame"); + divNode.setAttribute("class", "CheckBox sample_frame"); + divNode.setAttribute("id", name); + div.setAttribute("class", "sample_sub_frame"); + p.appendChild(labelNode); + div.appendChild(nameNode + ":"); + div.appendChild(br); + for (var i = 0; i < cb_content.length; i++) { + var checkBoxNode = document.createElement("input"); + checkBoxNode.setAttribute("type", "checkbox"); + checkBoxNode.setAttribute("name", "checkbox_" + name); + checkBoxNode.setAttribute("value", cb_content[i]); + var checkBoxValue = document.createTextNode(cb_content[i]); + + checkBoxNode.appendChild(checkBoxValue); + div.appendChild(checkBoxNode); + + } + + divNode.appendChild(p); + divNode.appendChild(div); + + return divNode.innerHTML; + +} + +function removeField() { + $('#addFieldTable').empty(); +} + +$('#removeAllPlugin').click(function() { + document.getElementById('pluginArea').innerHTML = ""; +}); + +$('#pluginCancel').click(function() { + $('#myModal_Plugin').modal('hide'); +}); + +$('#behaviorFinish').click(function() { + $('#myModal_Behavior').modal('hide'); +}); + +$('#behaviorCancel').click(function() { + $('#myModal_Behavior').modal('hide'); +}); + +function uploadBehavior(selectedNode){ + var uploadNode = selectNode.parentNode.previousSibling; + var div=uploadNode.childNodes; + var length=div.length; + + var fieldList=""; + var multiFieldList=""; + var tableList=""; + var checkList=""; + + for(var i=0;i