add add device

This commit is contained in:
fanfuxiaoran 2014-05-09 17:58:58 +08:00
parent 77334f78e4
commit 9fa7b989c8
13 changed files with 256 additions and 959 deletions

View File

@ -10,9 +10,8 @@ button {
.containerBox {
width: 80%;
border: 1px solid #d5d5d5;
border: 1px solid #888888;
color: #212121;
margin-top: 20px;
margin-left: auto;
margin-right: auto;
margin-bottom: 20px;
@ -20,24 +19,85 @@ button {
.containerBox .header {
border-bottom: 1px solid #c5d5dd;
height: 25px;
line-height: 25px;
padding-left: 10px;
padding-top: 3px;
font-weight: bold;
text-shadow: 0 1px white;
background: #e5eecc;
/* background: #e5eecc; */
background: #F6F6EA;
box-shadow: 3px 3px 3px #888888;
border-top-right-radius: 4px;
border-top-left-radius: 4px;
color: #3a505b;
border-top-right-radius: 4px;
}
.containerBox .header img {
src: images/device.png;
height: 36;
}
.separator {
width: 80%;
border: 1px solid #d5d5d5;
border-top: 3px solid #212121;
color: #212121;
margin-top: 20px;
margin-left: auto;
margin-right: auto;
height: 50px;
line-height: 50px;
background: #f7f7f7;
text-align: center;
}
.separator label {
margin-right: 10px;
font-weight: bold;
font-size: 25px;
font-weight: bold;
}
.separator input {
width: 100px;
height: 25px;
font-weight: bold;
font-size: 25px;
font-weight: bold;
}
.editor {
background: #f7f7f7;;
background: #f7f7f7;
padding-left: 10px;
padding-right: 30px;
padding-top: 10px;
padding-bottom: 10px;
}
.action {
background-color: #8AC007;
font-weight: bold;
font-size: 12px;
text-align: center;
padding-left: 10px;
padding-right: 10px;
padding-top: 3px;
padding-bottom: 4px;
text-decoration: none;
border-radius: 5px;
white-space: nowrap;
float:right;
color:#FFFFFF;
}
.booter{
width: 80%;
margin-left: auto;
margin-right: auto;
margin-bottom: 20px;
}
tr,thead {
width: 100%;
}

View File

@ -27,15 +27,18 @@ body {
<jsp:include page="publiccontrol/leftmenubar.jsp"></jsp:include>
<div class="span10">
<div id="devices"></div>
<div class="center">
<div class="booter center">
<button type="button" class="btn btn-primary " id="add-device">add</button>
<button type="button" class="btn btn-primary " id="del-device">remove</button>
<button type="button" class="btn btn-primary " id="remove-device">remove</button>
<a class="action">To Configure Data Sender >></a>
</div>
</div>
</div>
</div>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.0.3.min.js"></script>
<script src="lib/HashMap/HashMap.js"></script>
<script src="script/device/EditorFactory.js"></script>
<script src="script/device/DeviceFactory.js"></script>
<script src="script/device/device.js"></script>
</body>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

@ -0,0 +1,63 @@
function HashMap() {
this.arrKey = new Array();
this.arrValue = new Array();
this.exists = function(strKey) {
/*strKey = strKey.toUpperCase();*/
for (var i = 0; i < this.arrKey.length; i++) {
if (this.arrKey[i] == strKey) {
return true;
}
}
return false;
};
this.length = function() {
return this.arrKey.length;
};
this.put = function(strKey, objValue) {
/*strKey = strKey.toUpperCase();*/
for (var i = 0; i < this.arrKey.length; i++) {
if (this.arrKey[i] == strKey) {
this.arrValue[i] = objValue;
return;
}
}
this.arrKey[this.arrKey.length] = strKey;
this.arrValue[this.arrValue.length] = objValue;
};
this.get = function(strKey) {
/*strKey = strKey.toUpperCase();*/
for (var i = 0; i < this.arrKey.length; i++) {
if (this.arrKey[i] == strKey) {
return this.arrValue[i];
}
}
return null;
};
this.remove = function(strKey) {
/*strKey = strKey.toUpperCase();*/
for (var i = 0; i < this.arrKey.length; i++) {
if (this.arrKey[i] == strKey) {
this.arrKey.splice(i, 1);
this.arrValue.splice(i, 1);
return;
}
}
};
this.getKeys = function() {
return this.arrKey;
};
this.getValues = function() {
return this.arrValue;
};
this.clear = function(){
this.arrKey.splice(0, this.arrKey.length);
this.arrValue.splice(0, this.arrValue.length);
};
}

View File

@ -1,278 +0,0 @@
<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<html>
<head>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<meta charset="utf-8">
<title>Bench4Q</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description"
content="Bench4Q, a new method for QOS benchmarking.">
<link id="bs-css" href="lib/chrisma/css/bootstrap-cerulean.css"
rel="stylesheet">
<link href="lib/chrisma/css/opa-icons.css" rel="stylesheet">
<link
href="http://ajax.aspnetcdn.com/ajax/bootstrap/2.3.2/css/bootstrap-responsive.css"
rel="stylesheet">
<link href="lib/chrisma/css/charisma-app.css" rel="stylesheet">
<style type="text/css">
body {
padding-bottom: 40px;
}
.sidebar-nav {
padding: 9px 0;
}
</style>
<link href="lib/chrisma/css/charisma-app.css" rel="stylesheet">
<link href="css/bench4q.css" rel="stylesheet">
<link href='css/plugin.css' rel='stylesheet'>
<link rel="shortcut icon" href="images/bench4q.png">
<!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- The fav icon -->
<link rel="shortcut icon" href="img/favicon.ico">
</head>
<body>
<fmt:bundle basename="i18n">
<!-- topbar starts -->
<jsp:include page="publiccontrol/navigatebar.jsp"></jsp:include>
<!-- topbar ends -->
<div class="container-fluid">
<div class="row-fluid">
<jsp:include page="publiccontrol/leftmenubar.jsp"></jsp:include>
<noscript>
<div class="alert alert-block span10">
<h4 class="alert-heading">
<fmt:message key="warning" />
!
</h4>
<p>
<fmt:message key="warningcontent1" />
<a href="http://en.wikipedia.org/wiki/JavaScript" target="_blank">JavaScript</a>
<fmt:message key="warningcontent2" />
.
</p>
</div>
</noscript>
<div id="content" class="span10">
<!-- content starts -->
<ul class="breadcrumb">
<li><a href="homepage.jsp"><fmt:message key="home" /></a> <span
class="divider">/</span></li>
<li><a href="script.jsp"><fmt:message
key="scriptmanagement" /></a><span class="divider">/</span></li>
<li><a href="plugin.jsp"><fmt:message
key="script_jsp_makeScript" /></a></li>
</ul>
<div class="tab">
<ul style="cursor: pointer" class="nav nav-tabs">
<li id="tow1" onclick='setTab("tow",1,2);' class="on"><a
href="#"><fmt:message key="plugin_jsp_plugins" />(usePlugins)</a></li>
<!-- <li id="tow2" onclick='setTab("tow",2,3);'><a href="#">参数化(Parameters)</a></li> -->
<li id="tow2" onclick='setTab("tow",2,2);'><a href="#"><fmt:message
key="plugin_jsp_behavior" /> (behaviors)</a></li>
</ul>
</div>
<div class="tabContent">
<div class="span12">
<div id="cont_tow_1" class="one block">
<div class="box span6">
<div class="box-header well" data-original-title>
<i class="icon-pencil left"></i>
<h2>
<span><fmt:message key="plugin_jsp_plugins" />(usePlugins)</span>
</h2>
<div class="box-icon">
<a href="#" class="btn btn-minimize btn-round"><i
class="icon-chevron-up"></i></a>
</div>
</div>
<div class="box-content row-fluid">
<div id="pluginArea" class="listArea span8"></div>
<div class=" span4 button-div">
<div>
<button type="submit" class="btn btn-primary btn-width"
id="addPlugin" onClick="addPlugin();">
<fmt:message key="plugin_jsp_add" />
</button>
</div>
<div>
<button type="submit" class="btn btn-primary btn-width"
id="removePlugin" onClick="removePluginByClicked();">
<fmt:message key="plugin_jsp_remove" />
</button>
</div>
<div>
<button type="submit" class="btn btn-primary btn-width"
id="removeAllPlugin" onClick="clearPluginChoosedList();">
<fmt:message key="plugin_jsp_clear" />
</button>
</div>
</div>
</div>
</div>
<div class="span6" id="pluginParams"></div>
</div>
<!-- <div id="cont_tow_2" class="one " style="display: none"></div> -->
<div id="cont_tow_2" class="one " style="display: none">
<div class="box span6">
<div class="box-header well" data-original-title>
<i class="icon-pencil left"></i>
<h2>
<i></i>
<fmt:message key="plugin_jsp_behavior" />
(behaviors)
</h2>
<div class="box-icon">
<a href="#" class="btn btn-minimize btn-round"><i
class="icon-chevron-up"></i></a>
</div>
</div>
<div class="box-content row-fluid">
<div id="behaviorArea" class="listArea span8"></div>
<div class="span4 button-div">
<div class="hide" id="insertBefore">
<button type="submit" class="btn btn-primary btn-width"
onClick="insert();">
<fmt:message key="plugin_jsp_insertBefore" />
</button>
</div>
<div>
<button type="submit" class="btn btn-primary btn-width"
onClick="insertAfter();">
<fmt:message key="plugin_jsp_insertAfter" />
</button>
</div>
<div>
<button type="submit" class="btn btn-primary btn-width"
id="removeBehavior_Plugin"
onClick="removeInsertPluginByClicked();">
<fmt:message key="plugin_jsp_remove" />
</button>
</div>
<div>
<button type="submit" class="btn btn-primary btn-width"
onClick="clearPluginMethodList();">
<fmt:message key="plugin_jsp_clear" />
</button>
</div>
</div>
</div>
</div>
<div class="span6">
<div id="showPluginMethod" class="showPluginMethod"></div>
<div class="hide" id="submitBehaviors">
<p>
<fmt:message key="plugin_jsp_scriptName"></fmt:message>
<input id="writeAScriptName" type="text" name="scriptName"
size=20></input>
</p>
<p>
<button class='btn-large' onClick="submit(this);">
<fmt:message key="plugin_jsp_submit" />
</button>
</p>
</div>
</div>
</div>
</div>
</div>
</div>
<!--/#content.span10-->
</div>
<hr>
<div class="modal hide fade " id="myModal_Plugin">
<div class="modal-header">
<button type="button" id="myModal-close" class="close"
data-dismiss="modal">×</button>
<h3>
<fmt:message key="plugin_jsp_addNewPlugin" />
</h3>
</div>
<div class="modal-body" style="height: 260px;">
<div class="inset scroll" id="choosePlugin"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary btn-width"
id="pluginFinish" onClick="pluginFinish();">
<fmt:message key="plugin_jsp_finish" />
</button>
<button type="button" class="btn btn-primary btn-width"
onClick="pluginCancel();" id="pluginCancel">
<fmt:message key="plugin_jsp_cancel" />
</button>
</div>
</div>
<div class="modal hide fade " id="myModal_Behavior">
<div class="modal-header">
<button type="button" id="myModal-close" class="close"
data-dismiss="modal">×</button>
<h3>
<fmt:message key="plugin_jsp_chooseBehaviors" />
</h3>
</div>
<div class="modal-body">
<div class="row-fluid">
<div class="span6 behavior-box scroll">
<div id="insertPluginAreaPlugins"></div>
</div>
<div class="span6 behavior-box scroll">
<div id="pluginMethod"></div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary btn-width"
onClick="behaviorFinish();" id="behaviorFinish">
<fmt:message key="plugin_jsp_finish" />
</button>
<button type="button" class="btn btn-primary btn-width" onClick=""
id="behaviorCancel">
<fmt:message key="plugin_jsp_cancel" />
</button>
</div>
</div>
<jsp:include page="publiccontrol/footer.jsp"></jsp:include>
</div>
<!--/.fluid-container-->
<!-- external javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<!-- jQuery -->
<script
src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.0.min.js"></script>
<script
src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.4/jquery-ui.min.js"></script>
<script src="lib/jqueryi18n/jquery.i18n.properties-1.0.9.js"></script>
<script src="lib/bootstrap/js/bootstrap-modal.js"></script>
<script
src='http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.js'></script>
<script src="lib/chrisma/js/jquery.cookie.js"></script>
<script src="lib/chrisma/js/theme.js"></script>
<script src="script/base.js"></script>
<script src="script/pluginModel.js"></script>
<script src="script/plugin-new.js"></script>
<script src="script/submitPluginMessage.js"></script>
<script src="script/paramInfosForm.js"></script>
</fmt:bundle>
</body>
</html>

View File

@ -268,6 +268,7 @@ body {
<script src="lib/chrisma/js/jquery.cookie.js"></script>
<script src="lib/chrisma/js/theme.js"></script>
<script src="script/base.js"></script>
<script src="lib/HashMap/HashMap.js"></script>
<script src="script/ScriptEditor/uiCommon.js"></script>
<script src="script/ScriptEditor/plugin.js"></script>
<script src="script/ScriptEditor/paramInfosForm.js"></script>

View File

@ -141,66 +141,3 @@ function loadProperties(){
mode:'map', // 用 Map 的方式使用资源文件中的值
} );
}
function HashMap() {
this.arrKey = new Array();
this.arrValue = new Array();
this.exists = function(strKey) {
/*strKey = strKey.toUpperCase();*/
for (var i = 0; i < this.arrKey.length; i++) {
if (this.arrKey[i] == strKey) {
return true;
}
}
return false;
};
this.length = function() {
return this.arrKey.length;
};
this.put = function(strKey, objValue) {
/*strKey = strKey.toUpperCase();*/
for (var i = 0; i < this.arrKey.length; i++) {
if (this.arrKey[i] == strKey) {
this.arrValue[i] = objValue;
return;
}
}
this.arrKey[this.arrKey.length] = strKey;
this.arrValue[this.arrValue.length] = objValue;
};
this.get = function(strKey) {
/*strKey = strKey.toUpperCase();*/
for (var i = 0; i < this.arrKey.length; i++) {
if (this.arrKey[i] == strKey) {
return this.arrValue[i];
}
}
return null;
};
this.remove = function(strKey) {
/*strKey = strKey.toUpperCase();*/
for (var i = 0; i < this.arrKey.length; i++) {
if (this.arrKey[i] == strKey) {
this.arrKey.splice(i, 1);
this.arrValue.splice(i, 1);
return;
}
}
};
this.getKeys = function() {
return this.arrKey;
};
this.getValues = function() {
return this.arrValue;
};
this.clear = function(){
this.arrKey.splice(0, this.arrKey.length);
this.arrValue.splice(0, this.arrValue.length);
};
}

View File

@ -1,14 +0,0 @@
var EditorType = function(name, type, options) {
this.name = name;
this.type = type;
this.options = options;
}
$(function() {
var editorTypeMap = new HashMap();
var dataType=new EditorType("dataType","select","int;double");
editorTypeMap.put("dataType",dataType);
var generator=new EditorType("generator","select","sin;cosin");
edtiorTypeMap.put("generator",generator);
var min=new EditorType("min")
});

View File

@ -0,0 +1,92 @@
var DeviceFactory = function(deviceEditorInfo, container) {
this.deviceEditorInfo = deviceEditorInfo;
this.container = container;
};
DeviceFactory.prototype.createDevice = function(header, id) {
var deviceSizeConfig = this.createDeviceSizeConfig();
var deviceContainer = this.createEditorContainer(header, id,
this.deviceEditorInfo);
this.container.append(deviceSizeConfig);
this.container.append(deviceContainer);
};
DeviceFactory.prototype.createDeviceSizeConfig = function() {
var deviceSizeConfig = document.createElement("div");
$(deviceSizeConfig).addClass("separator");
var label = document.createElement("label");
$(label).html("Device Size:");
var input = document.createElement("input");
$(input).attr("type", "text");
$(deviceSizeConfig).append(label);
$(deviceSizeConfig).append(input);
return deviceSizeConfig;
}
DeviceFactory.prototype.createEditorContainer = function(header, id,
containerInfo) {
var container = document.createElement("div");
$(container).addClass("containerBox");
if (id != null) {
$(container).attr("id", id);
}
var containerHeader = document.createElement("p");
$(containerHeader).addClass("header");
var img = document.createElement("img");
$(containerHeader).append(img);
$(containerHeader).append(document.createTextNode(header));
$(container).append(containerHeader);
for ( var i = 0; i < containerInfo.length; i++) {
if (containerInfo[i].children == null) {
this.appendEdtiors(container, containerInfo[i].label,
containerInfo[i].name, containerInfo[i].paramTypeModel);
}
else {
$(container).append(
this.createEditorContainer(containerInfo[i].name, null,
containerInfo[i].children));
}
}
return container;
};
DeviceFactory.prototype.appendEdtiors = function(container, label, name,
editorInfo) {
var editorFactory = new EditorFactory();
if (editorInfo.type.toLowerCase() == "field") {
$(container).append(
editorFactory.createField(label, name, editorInfo.size, name));
} else if (editorInfo.type.toLowerCase() == "nfield") {
$(container).append(
editorFactory.createMultiField(label, name, editorInfo.size,
name));
} else if (editorInfo.type.toLowerCase() == "table") {
$(container).append(
editorFactory.createTable(label, name, editorInfo.cols, name));
} else if (editorInfo.type.toLowerCase() == "file") {
$(container).append(
editorFactory.createFile(lable, name, editorInfo.size, name));
} else if (editorInfo.type.toLowerCase() == "date") {
$(container).append(
editorFactory.createDate(label, name, editorInfo.size, name));
} else if (editorInfo.type.toLowerCase() == "select") {
$(container).append(
editorFactory.createSelect(label, name, editorInfo.size,
editorInfo.options, name));
} else {
alert("no such editor type:" + editorInfo.type);
}
};

View File

@ -1,78 +1,9 @@
var Device = function(editorUnit) {
this.deviceTypes = [ "1", "2", "3" ];
};
Device.prototype.createDeviceEditor = function(header, id, editorUnit) {
var deviceContainer = this.createEditorContainer(header, id, editorUnit);
return deviceContainer;
};
Device.prototype.createEditorContainer = function(header, id, containerInfo) {
var container = document.createElement("div");
$(container).addClass("containerBox");
if (id != null) {
$(container).attr("id", id);
}
var containerHeader = document.createElement("p");
$(containerHeader).addClass("header");
$(containerHeader).html(header);
$(container).append(containerHeader);
for ( var i = 0; i < containerInfo.length; i++) {
if (containerInfo[i].children == null) {
this.appendEdtiors(container, containerInfo[i].label,
containerInfo[i].name, containerInfo[i].paramTypeModel);
}
else {
$(container).append(
this.createEditorContainer(containerInfo[i].name, null,
containerInfo[i].children));
}
}
return container;
};
Device.prototype.appendEdtiors = function(container, label, name, editorInfo) {
var editorFactory = new EditorFactory();
if (editorInfo.type.toLowerCase() == "field") {
$(container).append(
editorFactory.createField(label, name, editorInfo.size, name));
} else if (editorInfo.type.toLowerCase() == "nfield") {
$(container).append(
editorFactory.createMultiField(label, name, editorInfo.size,
name));
} else if (editorInfo.type.toLowerCase() == "table") {
$(container).append(
editorFactory.createTable(label, name, editorInfo.cols, name));
} else if (editorInfo.type.toLowerCase() == "file") {
$(container).append(
editorFactory.createFile(lable, name, editorInfo.size, name));
} else if (editorInfo.type.toLowerCase() == "date") {
$(container).append(
editorFactory.createDate(label, name, editorInfo.size, name));
} else if (editorInfo.type.toLowerCase() == "select") {
$(container).append(
editorFactory.createSelect(label, name, editorInfo.size,
editorInfo.options, name));
} else {
alert("no such editor type:" + editorInfo.type);
}
};
Device.prototype.addChildDevice = function() {
};
function dataTransfer(serverData) {
var Container = function(name, children) {
this.name = name;
this.children = children;
};
var editorInfos = new Array();
var paramInfos = serverData.paramInfoModels;
var groupInfos = serverData.groupModels;
@ -92,24 +23,38 @@ function dataTransfer(serverData) {
}
return editorInfos;
}
var Container = function(name, children) {
this.name = name;
this.children = children;
};
$(function() {
var pluginName = "hbase";
var url = "/getPlugin/" + pluginName;
$.get(url, {}, function(data) {
var deviceFactory;
$.get("/getPlugin/" + "hbase", {}, function(data) {
if (data.success) {
var device = new Device();
$("#devices").append(
device.createDeviceEditor("device config", "device-0",
dataTransfer(data.pluginInfo)));
deviceFactory = new DeviceFactory(dataTransfer(data.pluginInfo),
$("#devices"));
deviceFactory.createDevice("device config", "device-0");
$("#add-device").click(
{
deviceFactory : deviceFactory,
},
function(event) {
event.preventDefault();
event.data.deviceFactory.createDevice("device config",
"device-1");
});
$("#remove-device").click(function(event) {
event.preventDefault();
if ($("#devices").children(".containerBox").length <= 1) {
return;
}
$("#devices").children(".containerBox").last().remove();
$("#devices").children(".separator").last().remove();
});
} else {
alert(data.failedMessage);

View File

@ -1,478 +0,0 @@
var pluginChoosedList = new Array();
var pluginIndex = new HashMap();
var pluginList = new Array();
var pluginMethodList = new Array();
var pageList = new Array();
var behaviorList = [];// 存放所有方法及其对应的parameter
var pluginParamList = [];// 一个plug-in名一个paramInfoModels list
var clickPluginMethodNode = -1;
var clickPluginChoosedNode = 0;
var place = "";
var parameters = [];
var files = [];
function setTab(name, m, n) {
for (var i = 1; i <= n; i++) {
var menu = document.getElementById(name + i);
var showDiv = document.getElementById("cont_" + name + "_" + i);
menu.className = i == m ? "on" : "";
showDiv.style.display = i == m ? "block" : "none";
}
}
function fileChange(event){
$.each(event.target.files, function(index, file) {
var reader = new FileReader();
reader.onload = function(event) {
object = {};
object.filename = file.name;
object.data = event.target.result;
files.push(object);
};
reader.readAsDataURL(file);
});
}
$(document).ready(function() {
loadPluginList();
loadPluginParams();
});
function loadPluginList (){
$.post("loadPluginName", {}, function(response) {
if (!response.success) {
alert(response.failedMessage);
return;
}
pluginList=response.data;
for(var i=0;i<pluginList.length;i++){
pluginIndex.put(pluginList[i], 0);
}
});
};
function showScriptByJsonData(jsonData) {
getPluginName(jsonData);
getBehaviorInfo(jsonData);
createPluginChoosedLines();
createPluginMethodLines();
}
function getPluginName(jsonData) {
for (var i = 0; i < jsonData.usePlugins.length; i++) {
var name = jsonData.usePlugins[i].name;
pluginChoosedList.push(name);
var aPluginIndex = pluginIndex.get(name);
pluginIndex.put(name, aPluginIndex + 1);
var data = getParamInfoModelList(name.split("_")[0]);// paramInfoModels
document.getElementById("pluginParams").innerHTML += createAEditText(data,
name, i);
}
}
function loadBehaviorParamInfos(behaviorMethod) {
$.each(modelData.pages, function(i, item) {
$.each(item.batches, function(i, item) {
if (item.Id == plugin_id) {
$.each(item.behaviors, function(i, item) {
if (item.id == behavior_id) {
plugin = item.use;
method = item.name;
$.each(item.parameters, function(i, item) {
parameters.push(item.key);
parameters[item.key] = item.value;
});
}
});
}
});
});
}
function getBehaviorInfo(jsonData) {
var paramInfoModels;
$.each(jsonData.pages, function(i, item) {
$.each(item.batches, function(i, item) {
$.each(item.behaviors, function(i, item) {
pluginMethodList.push(text);
plugin = item.use;
method = item.name;
var text = plugin + "." + methods;
parameters.splice(0, parameters.length);
$.each(item.parameters, function(i, item) {
parameters.push(item.key);
parameters[item.key] = item.value;
});
var data="";
loadBehaviorList(plugin);
for (var i = 0; i < data.length; i++) {
if(data[i].name==item.name){
paramInfoModels = data[i].paramInfoModels;
document.getElementById("showPluginMethod").innerHTML += createAEditText(
paramInfoModels, text, item.id);
createForm(item.id);
}
}
});
});
});
}
function loadPluginParams() {
$
.post(
"loadPluginUIList",
{},
function(data) {
if (!data.success) {
alert(data.failedMessage);
return;
}
data = data.data;// List<PluginUIModel>pluginUIModels
for (var i = 0; i < data.length; i++) {
var pluginInfoModel = data[i].pluginInfoModel;
pluginParamList.push(pluginInfoModel.name);
pluginParamList[pluginInfoModel.name] = pluginInfoModel.paramInfoModels;
}
});
}
function addPlugin() {
var html = "";
for (var j = 0; j < pluginList.length; j++) {
html += createLineWithRadio(pluginList[j], "plugin");
}
$('#choosePlugin').html(html);
$('#myModal_Plugin').modal('show');
$("input:radio").click(function() {
$(this).attr("checked", "checked");
});
}
function createLineWithRadio(lineText, nameAttr) {
var textNode = document.createTextNode(lineText);
var divNode = document.createElement("div");
var inputNode = document.createElement("input");
var brNode = document.createElement("br");
inputNode.setAttribute("type", "radio");
inputNode.setAttribute("name", nameAttr);
inputNode.setAttribute("class", "chooseOnePlugin");
inputNode.setAttribute("value", lineText);
divNode.appendChild(inputNode);
divNode.appendChild(textNode);
divNode.appendChild(brNode);
return $(divNode).html() + "<br>";
}
function createALine(name, index, list) {
var div = document.createElement("div");
var p = document.createElement("p");
var i = document.createElement("i");
var textNode = document.createTextNode(name);
div.setAttribute("id", index);
i.setAttribute("class", "icon-hand-right");
p.setAttribute("id", index);
p.setAttribute("class", "");
if (list == "pluginMethodList") {
p.setAttribute("onClick", "showMethodDocument(this)");// loadMethodParams
} else if (list == "pluginChoosedList") {
p.setAttribute("onClick", "choosePlugin(this);");// 此处用于显示plugin文档
} else if (list == "editPluginChoosedList") {
p.setAttribute("onClick", "chooseEditPlugin(this);");
}
p.setAttribute("style", "cursor:pointer;width:85%");
p.appendChild(i);
p.appendChild(textNode);
div.appendChild(p);
return div;
}
function getParamInfoModelList(plugin) {
return pluginParamList[plugin];
}
function pluginFinish() {
$('#myModal_Plugin').modal('hide');
var pluginName;
var item = $("input[type='radio']:checked").val();
var aPluginIndex = pluginIndex.get(item);
pluginIndex.put(item, aPluginIndex + 1);
pluginName = item + "_" + aPluginIndex;
pluginChoosedList.push(pluginName);
createPluginChoosedLines();
var data = getParamInfoModelList(item);// paramInfoModels
document.getElementById("pluginParams").innerHTML += createAEditText(data,
pluginName, pluginChoosedList.length - 1);
alert($("input[type=file]").length);
$("input[type=file]").change(function(event){
fileChange(event);
});
}
function choosePlugin(selectedNode) {
clickPluginChoosedNode = $(selectedNode).attr("id");
var pluginChoosedNode = $('#pluginArea').children();
var div = document.getElementById("pluginParams").childNodes;
showChoosedPluginInfo(pluginChoosedNode, div);
}
function showChoosedPluginInfo(pluginChoosedNode, div) {
// 显示选中
showChoosedPluginLine(pluginChoosedNode);
// 显示文档
showChoosedPluginParamInfos(div);
}
function showChoosedPluginLine(pluginChoosedNode) {
for (var i = 0; i < pluginChoosedNode.length; i++) {
if (i == clickPluginChoosedNode) {
$(pluginChoosedNode[i]).find("p").attr("class", "visited");
} else {
$(pluginChoosedNode[i]).find("p").attr("class", "");
}
}
}
function showChoosedPluginParamInfos(div) {
for (var j = 0; j < div.length; j++) {
if (div[j].getAttribute("id") == clickPluginChoosedNode) {
$(div[j]).show();
} else {
$(div[j]).hide();
}
}
}
function createPluginChoosedLines() {
document.getElementById('pluginArea').innerHTML = "";
for (var j = 0; j < pluginChoosedList.length; j++) {
var pluginName = pluginChoosedList[j];
var div = createALine(pluginName, j, "pluginChoosedList");
document.getElementById('pluginArea').appendChild(div);
}
}
function removePluginByClicked() {
var length = pluginChoosedList.length;
for (var i = parseInt(clickPluginChoosedNode + 1); i < length; i++) {
pluginChoosedList[i - 1] = pluginChoosedList[i];
}
pluginChoosedList.splice(length - 1, 1);
createPluginChoosedLines();
}
function clearPluginChoosedList() {
pluginChoosedList.splice(0, pluginChoosedList.length);
for (var i = 0; i < pluginList.length; i++) {
pluginIndex.put(pluginList[i], 0);
}
document.getElementById('pluginArea').innerHTML = "";
}
function insert() {
place = "before";
insertPlugin();
}
function insertAfter() {
place = "after";
insertPlugin();
}
function insertPlugin() {
document.getElementById("pluginMethod").innerHTML = "";
$('#myModal_Behavior').modal('show');
var chooesedPluginHtml = "";
for (var i = 0; i < pluginChoosedList.length; i++) {
chooesedPluginHtml += createLineWithRadio(pluginChoosedList[i],
"plugin");
}
$("#insertPluginAreaPlugins").html(chooesedPluginHtml);
}
$('#insertPluginAreaPlugins').click(function() {
var pluginName = $("input[type='radio']:checked").val();
getBehaviorList(pluginName);
});
function loadBehaviorList(plugin){
var behaviors=null;
$.ajax({
type : "POST",
url : "loadBehaviorList",
data:"pluginName="+plugin,
dataType : "json",
async : false,
success : function(response) {
if (!response.success) {
alert(response.failedMessage);
return;
}
behaviors=response.data;
}
});
return behaviors;
}
function getBehaviorList(pluginName) {
var methodHtml = "";
var type = pluginName.split("_");
var plugin = type[0];
behaviorList.splice(0, behaviorList.length);
var behaviors=loadBehaviorList(plugin);
for (var i = 0; i < behaviors.length; i++) {
behaviorList.push(behaviors[i].name);
behaviorList[behaviors[i].name] = behaviors[i].paramInfoModels;
methodHtml += createLineWithRadio(behaviors[i].name, "method");
}
document.getElementById("pluginMethod").innerHTML = methodHtml;
}
function behaviorFinish() {
var plugin = $("input[name='plugin']:checked").val();
var method = $("input[name='method']:checked").val();
if (plugin != null && plugin != "" && method != null && method != "") {
showPluginMethodLine(plugin, method);
} else {
alert("The plugin or the method shouldn't be null!");
$('#myModal_Behavior').modal('hide');
}
}
var mark;
function showPluginMethodLine(plugin, method) {
var behaviorData = plugin + "." + method;
var length = pluginMethodList.length;
var documentChild = document.getElementById("showPluginMethod").childNodes;
if (place == "before") {
for (var j = length - 1; j >= clickPluginMethodNode; j--) {
pluginMethodList[j + 1] = pluginMethodList[j];
$(documentChild[j]).attr("id", parseInt(j + 1));
}
mark = clickPluginMethodNode;
clickPluginMethodNode = parseInt(clickPluginMethodNode + 1);
pluginMethodList[mark] = behaviorData;
} else if (place == "after") {
mark = parseInt(clickPluginMethodNode + 1);
if (clickPluginMethodNode == parseInt(length - 1)
&& clickPluginMethodNode != -1) {
pluginMethodList.push(behaviorData);
} else {
for (var j = parseInt(length - 1); j >= mark; j--) {
pluginMethodList[j + 1] = pluginMethodList[j];
$(documentChild[j]).attr("id", parseInt(j + 1));
}
pluginMethodList[mark] = behaviorData;
}
}
$('#insertBefore').attr("class", "show");
$('#myModal_Behavior').modal('hide');
createPluginMethodLines();
}
function createPluginMethodLines() {
document.getElementById("showPluginMethod").innerHTML = "";
document.getElementById('behaviorArea').innerHTML = "";
for (var j = 0; j < pluginMethodList.length; j++) {
var div = createALine(pluginMethodList[j], j, "pluginMethodList");
if (j == clickPluginMethodNode) {
$(div).find("p").attr("class", "visited");
}
document.getElementById('behaviorArea').appendChild(div);
loadMethodParams(pluginMethodList[j], j);
}
}
function showMethodDocument(selectedNode) {
clickPluginMethodNode = parseInt($(selectedNode).attr("id"));
var length = $("#showPluginMethod").children().length;
var behaviorAreaChild = $('#behaviorArea').children();
var div = $("#showPluginMethod").children();
for (var i = 0; i < length; i++) {
if (behaviorAreaChild[i].getAttribute("id") != clickPluginMethodNode) {
$(behaviorAreaChild[i]).find("p").attr("class", "");
} else {
$(behaviorAreaChild[i]).find("p").attr("class", "visited");
}
}
for (var j = 0; j < length; j++) {
if (div[j].getAttribute("id") == clickPluginMethodNode) {
$(div[j]).show();
} else {
$(div[j]).hide();
}
}
$('#submitBehaviors').attr("class", "show");
}
function removeInsertPluginByClicked() {
var length = $('#behaviorArea').children().length;
var removeDocumentNode = document.getElementById("showPluginMethod").childNodes;
for (var i = parseInt(clickPluginMethodNode + 1); i < length; i++) {
pluginMethodList[i - 1] = pluginMethodList[i];
}
pluginMethodList.splice(length - 1, 1);// js Array remove element
createPluginMethodLines();
for (var j = 0; j < length; j++) {
if ($(removeDocumentNode[j]).attr("id") == clickPluginMethodNode) {
document.getElementById("showPluginMethod").removeChild(
removeDocumentNode[j]);
}
}
}
function clearPluginMethodList() {
pluginMethodList.splice(0, pluginMethodList.length);
document.getElementById('behaviorArea').innerHTML = "";
document.getElementById("showPluginMethod").innerHTML = "";
$('#submitBehaviors').attr("class", "hide");
}
function loadMethodParams(behaviorData, behaviorIndex) {
var temp = behaviorData.split('.');
var method = temp[1];
var data = behaviorList[method];// data 为List<ParamInfoModel>
document.getElementById("showPluginMethod").innerHTML += createAEditText(
data, behaviorData, behaviorIndex);
}
// 生成页面显示
function createAEditText(data, name, index) {
var documentHtml = "";
var boxHeader = "";
var fieldHTML = "";
boxHeader = "<div class='box-header well' data-original-title> "
+ "<i class='icon-pencil left'></i>" + "<h2>sample:<i>" + name
+ "</i></h2></div>";
if (data != null) {
fieldHTML = createPluginsOrBehaviorsForm(data, index);
}
documentHtml = "<div id='" + index + "' class='hide'><p class='hide'>"
+ name + "</p><div class='span12 box' style='margin-left:-2px;'>"
+ boxHeader + "<div class='box-content'>" + fieldHTML + "</div>"
+ "</div></div>";
console.log($("input[type=file]").lenth);
return documentHtml;
}
function cancelBehavior(selectedNode) {
var divNode = selectedNode.parentNode.parentNode.parentNode;
$(divNode).hide();
}
$('#pluginCancel').click(function() {
$('#myModal_Plugin').modal('hide');
});
$('#behaviorCancel').click(function() {
$('#myModal_Behavior').modal('hide');
});

View File

@ -1,30 +0,0 @@
function getvars() {
var vars = [], hash;
var hashes = window.location.href.slice(
window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
$(function() {
var jsonData = getvars()['jsonData'];
if(jsonData!=null){
showScriptByJsonData(jsonData);
}
});

View File

@ -1,11 +1,7 @@
package org.bench4q.web.test.masterMessager;
import static org.junit.Assert.*;
import java.util.List;
import javax.xml.bind.JAXBException;
import org.bench4q.share.helper.MarshalHelper;
import org.bench4q.share.models.master.OperateScriptServerResponseModel;
import org.bench4q.share.models.master.ScriptModel;