modify login.jsp and plugin-new.js

This commit is contained in:
zhengyingying 2014-03-20 15:19:12 +08:00
parent 6ae331e61d
commit e0e3c9c184
3 changed files with 1006 additions and 989 deletions

View File

@ -115,7 +115,7 @@ Bench4Q is a new methodology for QoS benchmarking
</div>
<div style="height:2px; width:100%"></div>
<div>
<input type="text" id="username" name="username" style="font-size:18px; margin-left:40px; height:30px; width:300px;" onblur="checkName(this.value)"/>
<input autofocus type="text" id="username" name="username" style="font-size:18px; margin-left:40px; height:30px; width:300px;" onblur="checkName(this.value)"/>
<div id='alertUserName' style='display:none;color:red;margin-left:40px'>The username cannot be empty!</div>
</div>
<div style="height:10px; width:100%"></div>

View File

@ -164,7 +164,7 @@ body {
</div>
</div>
<div id="showPluginMethod">
<div id="showPluginMethod" class="showPluginMethod">
<!-- 显示方法文档,开始动态生成 ,只显示一个-->

View File

@ -4,7 +4,7 @@ PluginMethodListModel = function(pluginName, methodList) {
};
var pluginList = new Array();
var pluginMethodList = new Array();
var index = 0;
$(document).ready(function() {
loadPluginList();
});
@ -74,11 +74,7 @@ function pluginFinish() {
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);
@ -108,10 +104,12 @@ function showInsertPlugin(selectNode) {
$('#behaviorFinish').attr('disabled', true);
var textNode = selectNode.firstChild;
var methodData = textNode.nodeValue;
// 请求master获取其method方法
getMethodList(methodData);
}
function removeInsertPlugin(){
var last=document.getElementById("behaviorArea").lastChild;
document.getElementById("behaviorArea").removeChild(last);
}
function getMethodList(methodData) {
@ -163,60 +161,41 @@ function show(selectedNode) {
var div = document.createElement("div");
var a = document.createElement("a");
var textNode = document.createTextNode(behaviorData);
a.setAttribute("class", "pluginChoosedList");// 样式设计
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 behaviorData = selectedNode.firstChild.nodeValue;
var temp;
var flag = false;
var behaviorIndex = $(selectedNode).attr("class");
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) {
// 文档没有生成过,需要调用函数生成该文档
var div = $("#showPluginMethod").children();
$(div[behaviorIndex]).attr("class", "show");
$(div[behaviorIndex]).show();
for (var i = 0; i < length; i++) {
if ($('#showPluginMethod').children()[i].Attr("class", "")) {
$('#showPluginMethod').children()[i].Attr("class", "hide");
// 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();
}
}
loadMethodParams(behaviorData);
}
}
var methodParams = new Array();
var temp;
function loadMethodParams(behaviorData) {
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="";
var boxHeader = "";
$
.post(
@ -230,7 +209,7 @@ function loadMethodParams(behaviorData) {
alert(data.failedMessage);
return;
}
data=data.data;
data = data.data;
for (var i = 0; i < data.length; i++) {
methodParams.push(data[i]);
}
@ -244,12 +223,12 @@ function loadMethodParams(behaviorData) {
fieldHTML += createField(
methodParamModel.lable,
methodParamModel.name,
paramTypeModel.size);
paramTypeModel.size, behaviorIndex);
} else if (paramTypeModel.type == "multiField") {
fieldHTML += createMultiField(
methodParamModel.lable,
methodParamModel.name,
paramTypeModel.size);
paramTypeModel.size, behaviorIndex);
} else if (paramTypeModel.type == "Table") {
fieldHTML += createTable(methodParamModel);
} else if (paramTypeModel.type == "CheckBox") {
@ -266,19 +245,89 @@ function loadMethodParams(behaviorData) {
+ "<a class='btn btn-minimize btn-round'><i class='icon-chevron-up'></i></a></div></div>";
documentHtml = "<div id='"
+ behaviorData
+ "' class=''><p class='hide'>"
+ behaviorIndex
+ "' class='hide'><p class='hide'>"
+ behaviorData
+ "</p><div class='span10 showPluginDetails box'>"
+ boxHeader
+ "<div class='box-content'>"
+ fieldHTML
+ "</div><div><button id='' type='submit' onClick='uploadBehavior(this);'>submit</button></div></div></div>";
document.getElementById("showPluginMethod").innerHTML += documentHtml;
});
}
//创建一个label加一个input的域
function createField(label, name, size, behaviorIndex) {
if (size == 0) {
size = 20;
}
var fieldHTML = "<div class='Field sample_frame' id='" + behaviorIndex
+ "_" + name + "'><p>" + label
+ "</p><div class='sample_sub_frame'>" + name
+ ":<input type='text' size=" + size + " id='" + name
+ "_input' value=''></input></div></div>";
return fieldHTML;
}
// 创建一个可以增加field的域
function createMultiField(label, name, size, behaviorIndex) {
if (size == 0) {
size = 20;
}
var multiFieldHTML = "<div class='MultiField sample_frame' id='"
+ behaviorIndex
+ "_"
+ name
+ "'><p>"
+ name
+ ":"
+ label
+ "</p><div class='sample_sub_frame'><button type='submit' onClick='addField("
+ size+","+ behaviorIndex
+ ");'>Add Field</button><button type='submit' onClick='removeField();'>RemoveAll</button><br><table id='addFieldTable_"
+ behaviorIndex + "'></table></div></div>";
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) {
@ -403,72 +452,7 @@ function createCheckBox(methodParamModel) {
return divNode.innerHTML;
}
// 创建一个label加一个input的域
function createField(label, name, size) {
// document.write(label+","+name+","+size);
if (size == 0) {
size = 20;
}
var fieldHTML = "<div class='Field sample_frame' id='" + name + "'><p>" + label
+ "</p><div class='sample_sub_frame'>" + name
+ ":<input type='text' size=" + size + " id='" + name
+ "_input' value=''></input></div></div>";
return fieldHTML;
}
// 创建一个可以增加field的域
function createMultiField(label, name, size) {
if (size == 0) {
size = 20;
}
var multiFieldHTML = "<div class='MultiField sample_frame' id='"
+ name
+ "'><p>"
+ name
+ ":"
+ label
+ "</p><div class='sample_sub_frame'><button type='submit' onClick='addField("
+ size
+ ");'>Add Field</button><button type='submit' onClick='removeField();'>RemoveAll</button><br><table id='addFieldTable'></table></div></div>";
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();
}
@ -489,7 +473,40 @@ $('#behaviorCancel').click(function() {
$('#myModal_Behavior').modal('hide');
});
function uploadBehavior(selectNode) {
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<length;i++){
var node=div[i];
if(node.Attr("class")=="Field sample_frame"){
fieldList+=$(node).find("input").val()+",";
}else if(node.Attr("class")=="multiField sample_frame"){
var fieldNode=$(node.lastNode).find("table").children();
var fieldLength=fieldNode.length;
for(var j=0;j<fieldLength;j++){
multiFieldList+=$(fieldNode[j]).find("input").val()+",";
}
//多个multiField如何解决
}else if(node.Attr("class")=="Table sample_frame"){
}else if(node.Attr("class")=="CheckBox sample_frame"){
}
}
var uploadBehavior = new UploadBehaviorRequestModel(tableList, checkList,
fieldList, multiFieldList);
upload(uploadBehavior);
}
function uploadBehavior1(selectNode) {
var uploadNode = selectNode.parentNode.parentNode;
var tableNum = 0;
var tableList = "";