add two bootstrap js and modify script js

This commit is contained in:
zhengyingying 2014-04-15 11:20:04 +08:00
parent ff1bb8bee4
commit 8402fe13d9
10 changed files with 1248 additions and 793 deletions

View File

@ -59,6 +59,7 @@ choose=choose
testplanrunid=TestPlanRunId
createdatetime=Create
agentmanagement=Agent Management
portmanagement=Port Management
agents=Agents
hostname=HostName
port=Port
@ -132,6 +133,7 @@ index_jsp_Bench4Q_as_a_Service=Bench4Q_as_a_Service is based on Bench4Q project.
index_jsp_Bench4Q=Bench4Q is a very new methodology for QoS oriented the E-commerce benchmarking.Bench4Q has many features to deduce the controllable and flexible representation of complex session-based workloads,and to simulate authentic customer behavior.
index_jsp_FreeRegister=Free register, signing, load test, real-time monitoring, analysis report download, view history data and much more ...
index_jsp_Title=Bench4Q is A Cloud-based Load Testing Platform
register_jsp_Title=Bench4Q is A Cloud-based Load Testing Platform
index_jsp_registerAndSign=Register and Sign
index_jsp_weAreFree=We are free!
login_jsp_home=Home

View File

@ -59,6 +59,7 @@ choose=\u9009\u62E9
testplanrunid=\u8FD0\u884CID
createdatetime=\u521B\u5EFA
agentmanagement=\u4EE3\u7406\u7BA1\u7406
portmanagement=\u7AEF\u53E3\u7BA1\u7406
agents=\u4EE3\u7406
hostname=\u4E3B\u673A\u540D
port=\u7AEF\u53E3
@ -131,13 +132,14 @@ index_jsp_Bench4Q_as_a_Service=Bench4Q_as_a_Service \u662F\u57FA\u4E8EBench4Q\u
index_jsp_Bench4Q=Bench4Q\u662F\u8D28\u91CF\u670D\u52A1\u5BFC\u5411\u7535\u5B50\u5546\u52A1\u6807\u6746\u7684\u4E00\u4E2A\u975E\u5E38\u65B0\u7684\u65B9\u6CD5\u5B66 \u3002Bench4Q\u6709\u5F88\u591A\u7279\u70B9\u6765\u63A8\u8BBA\u590D\u6742\u7684\u57FA\u4E8E\u4F1A\u8BDD\u7684\u5DE5\u4F5C\u8D1F\u8F7D\u7684\u53EF\u63A7\u7684\u548C\u7075\u6D3B\u7684\u8868\u793A\u6CD5\uFF0C\u5E76\u4E14\u53EF\u4EE5\u6A21\u62DF\u771F\u5B9E\u7528\u6237\u7684\u884C\u4E3A\u3002
index_jsp_FreeRegister=\u514D\u8D39\u6CE8\u518C\uFF0C\u8BA4\u8BC1\uFF0C\u4E0B\u8F7D\u6D4B\u8BD5\uFF0C\u5B9E\u65F6\u76D1\u63A7\uFF0C\u5206\u6790\u62A5\u544A\u4E0B\u8F7D\uFF0C\u67E5\u770B\u5386\u53F2\u6570\u636E...
index_jsp_Title=Bench4Q\u2014\u2014\u57FA\u4E8E\u4E91\u7684\u6D4B\u8BD5\u4E0B\u8F7D\u5E73\u53F0
register_jsp_Title=Bench4Q\u2014\u2014\u57FA\u4E8E\u4E91\u7684\u6D4B\u8BD5\u4E0B\u8F7D\u5E73\u53F0
index_jsp_register=\u6CE8\u518C
index_jsp_login=\u767B\u5F55
index_jsp_registerAndSign=\u6CE8\u518C\u5E76\u8BA4\u8BC1
index_jsp_weAreFree=\u6211\u4EEC\u662F\u514D\u8D39\u7684\u54DF\uFF01
login_jsp_home=\u4E3B\u9875
login_jsp_register=\u6CE8\u518C
login_jsp_Title=Bench4Q\u2014\u2014QOS\u57FA\u51C6\u6D4B\u8BD5\u7684\u65B0\u65B9\u6CD5
login_jsp_Title=Bench4Q \u2014\u2014 QOS\u57FA\u51C6\u6D4B\u8BD5\u7684\u65B0\u65B9\u6CD5
login_jsp_welcome=\u6B22\u8FCE\u4F7F\u7528Bench4Q\uFF01
login_jsp_signIn=\u767B\u5F55
login_jsp_username=\u7528\u6237\u540D

View File

@ -0,0 +1,169 @@
/* ==========================================================
* bootstrap-carousel.js v2.0.4
* http://twitter.github.com/bootstrap/javascript.html#carousel
* ==========================================================
* Copyright 2012 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ========================================================== */
!function ($) {
"use strict"; // jshint ;_;
/* CAROUSEL CLASS DEFINITION
* ========================= */
var Carousel = function (element, options) {
this.$element = $(element)
this.options = options
this.options.slide && this.slide(this.options.slide)
this.options.pause == 'hover' && this.$element
.on('mouseenter', $.proxy(this.pause, this))
.on('mouseleave', $.proxy(this.cycle, this))
}
Carousel.prototype = {
cycle: function (e) {
if (!e) this.paused = false
this.options.interval
&& !this.paused
&& (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
return this
}
, to: function (pos) {
var $active = this.$element.find('.active')
, children = $active.parent().children()
, activePos = children.index($active)
, that = this
if (pos > (children.length - 1) || pos < 0) return
if (this.sliding) {
return this.$element.one('slid', function () {
that.to(pos)
})
}
if (activePos == pos) {
return this.pause().cycle()
}
return this.slide(pos > activePos ? 'next' : 'prev', $(children[pos]))
}
, pause: function (e) {
if (!e) this.paused = true
clearInterval(this.interval)
this.interval = null
return this
}
, next: function () {
if (this.sliding) return
return this.slide('next')
}
, prev: function () {
if (this.sliding) return
return this.slide('prev')
}
, slide: function (type, next) {
var $active = this.$element.find('.active')
, $next = next || $active[type]()
, isCycling = this.interval
, direction = type == 'next' ? 'left' : 'right'
, fallback = type == 'next' ? 'first' : 'last'
, that = this
, e = $.Event('slide')
this.sliding = true
isCycling && this.pause()
$next = $next.length ? $next : this.$element.find('.item')[fallback]()
if ($next.hasClass('active')) return
if ($.support.transition && this.$element.hasClass('slide')) {
this.$element.trigger(e)
if (e.isDefaultPrevented()) return
$next.addClass(type)
$next[0].offsetWidth // force reflow
$active.addClass(direction)
$next.addClass(direction)
this.$element.one($.support.transition.end, function () {
$next.removeClass([type, direction].join(' ')).addClass('active')
$active.removeClass(['active', direction].join(' '))
that.sliding = false
setTimeout(function () { that.$element.trigger('slid') }, 0)
})
} else {
this.$element.trigger(e)
if (e.isDefaultPrevented()) return
$active.removeClass('active')
$next.addClass('active')
this.sliding = false
this.$element.trigger('slid')
}
isCycling && this.cycle()
return this
}
}
/* CAROUSEL PLUGIN DEFINITION
* ========================== */
$.fn.carousel = function (option) {
return this.each(function () {
var $this = $(this)
, data = $this.data('carousel')
, options = $.extend({}, $.fn.carousel.defaults, typeof option == 'object' && option)
if (!data) $this.data('carousel', (data = new Carousel(this, options)))
if (typeof option == 'number') data.to(option)
else if (typeof option == 'string' || (option = options.slide)) data[option]()
else if (options.interval) data.cycle()
})
}
$.fn.carousel.defaults = {
interval: 5000
, pause: 'hover'
}
$.fn.carousel.Constructor = Carousel
/* CAROUSEL DATA-API
* ================= */
$(function () {
$('body').on('click.carousel.data-api', '[data-slide]', function ( e ) {
var $this = $(this), href
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
, options = !$target.data('modal') && $.extend({}, $target.data(), $this.data())
$target.carousel(options)
e.preventDefault()
})
})
}(window.jQuery);

View File

@ -0,0 +1,157 @@
/* =============================================================
* bootstrap-collapse.js v2.0.4
* http://twitter.github.com/bootstrap/javascript.html#collapse
* =============================================================
* Copyright 2012 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============================================================ */
!function ($) {
"use strict"; // jshint ;_;
/* COLLAPSE PUBLIC CLASS DEFINITION
* ================================ */
var Collapse = function (element, options) {
this.$element = $(element)
this.options = $.extend({}, $.fn.collapse.defaults, options)
if (this.options.parent) {
this.$parent = $(this.options.parent)
}
this.options.toggle && this.toggle()
}
Collapse.prototype = {
constructor: Collapse
, dimension: function () {
var hasWidth = this.$element.hasClass('width')
return hasWidth ? 'width' : 'height'
}
, show: function () {
var dimension
, scroll
, actives
, hasData
if (this.transitioning) return
dimension = this.dimension()
scroll = $.camelCase(['scroll', dimension].join('-'))
actives = this.$parent && this.$parent.find('> .accordion-group > .in')
if (actives && actives.length) {
hasData = actives.data('collapse')
if (hasData && hasData.transitioning) return
actives.collapse('hide')
hasData || actives.data('collapse', null)
}
this.$element[dimension](0)
this.transition('addClass', $.Event('show'), 'shown')
this.$element[dimension](this.$element[0][scroll])
}
, hide: function () {
var dimension
if (this.transitioning) return
dimension = this.dimension()
this.reset(this.$element[dimension]())
this.transition('removeClass', $.Event('hide'), 'hidden')
this.$element[dimension](0)
}
, reset: function (size) {
var dimension = this.dimension()
this.$element
.removeClass('collapse')
[dimension](size || 'auto')
[0].offsetWidth
this.$element[size !== null ? 'addClass' : 'removeClass']('collapse')
return this
}
, transition: function (method, startEvent, completeEvent) {
var that = this
, complete = function () {
if (startEvent.type == 'show') that.reset()
that.transitioning = 0
that.$element.trigger(completeEvent)
}
this.$element.trigger(startEvent)
if (startEvent.isDefaultPrevented()) return
this.transitioning = 1
this.$element[method]('in')
$.support.transition && this.$element.hasClass('collapse') ?
this.$element.one($.support.transition.end, complete) :
complete()
}
, toggle: function () {
this[this.$element.hasClass('in') ? 'hide' : 'show']()
}
}
/* COLLAPSIBLE PLUGIN DEFINITION
* ============================== */
$.fn.collapse = function (option) {
return this.each(function () {
var $this = $(this)
, data = $this.data('collapse')
, options = typeof option == 'object' && option
if (!data) $this.data('collapse', (data = new Collapse(this, options)))
if (typeof option == 'string') data[option]()
})
}
$.fn.collapse.defaults = {
toggle: true
}
$.fn.collapse.Constructor = Collapse
/* COLLAPSIBLE DATA-API
* ==================== */
$(function () {
$('body').on('click.collapse.data-api', '[data-toggle=collapse]', function ( e ) {
var $this = $(this), href
, target = $this.attr('data-target')
|| e.preventDefault()
|| (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
, option = $(target).data('collapse') ? 'toggle' : $this.data()
$(target).collapse(option)
})
})
}(window.jQuery);

View File

@ -146,7 +146,7 @@ function HashMap() {
this.arrValue = new Array();
this.exists = function(strKey) {
strKey = strKey.toUpperCase();
/*strKey = strKey.toUpperCase();*/
for (var i = 0; i < this.arrKey.length; i++) {
if (this.arrKey[i] == strKey) {
return true;
@ -159,7 +159,7 @@ function HashMap() {
};
this.put = function(strKey, objValue) {
strKey = strKey.toUpperCase();
/*strKey = strKey.toUpperCase();*/
for (var i = 0; i < this.arrKey.length; i++) {
if (this.arrKey[i] == strKey) {
this.arrValue[i] = objValue;
@ -171,7 +171,7 @@ function HashMap() {
};
this.get = function(strKey) {
strKey = strKey.toUpperCase();
/*strKey = strKey.toUpperCase();*/
for (var i = 0; i < this.arrKey.length; i++) {
if (this.arrKey[i] == strKey) {
return this.arrValue[i];
@ -181,7 +181,7 @@ function HashMap() {
};
this.remove = function(strKey) {
strKey = strKey.toUpperCase();
/*strKey = strKey.toUpperCase();*/
for (var i = 0; i < this.arrKey.length; i++) {
if (this.arrKey[i] == strKey) {
this.arrKey.splice(i, 1);

View File

@ -1,279 +1,287 @@
var pluginNameList = new Array();
var parameters = new HashMap();
var parameterList = new HashMap();
var pluginName;
function loadUsePluigns(data) {
for (var i = 0; i < data.usePlugins.length; i++) {
var usePlugin = data.usePlugins[i];
pluginNameList.push(usePlugin.id);
}
var selectNode = document.getElementsByName("usePlugins")[0];
for (var j = 0; j < pluginNameList.length; j++) {
var textNode = document.createTextNode(pluginNameList[j]);
var optionNode = document.createElement("option");
optionNode.setAttribute("value", pluginNameList[j]);
optionNode.appendChild(textNode);
selectNode.appendChild(optionNode);
}
}
function choosePlugin() {
var plugin = document.getElementById("usePlugins");
if (plugin.options[plugin.selectedIndex].value != 0) {
pluginName = plugin.options[plugin.selectedIndex].value;
}
loadBehaviors();
}
var clickScriptId;
function chooseBehavior() {
var behaviorMethod = 0;
var behaviors = document.getElementById("behaviors");
if (behaviors.options[behaviors.selectedIndex].value != 0) {
behaviorMethod = behaviors.options[behaviors.selectedIndex].value;
}
document.getElementById("showPluginMethodForm").innerHTML = "";
var plugin_id = behaviorMethod.split("_")[0];
var behavior_id = behaviorMethod.split("_")[1];
clickScriptId = plugin_id + "_" + behavior_id;
loadFormParameters(plugin_id, behavior_id);
}
function loadBehaviors() {
$('#behaviors').html("");
var selectNode = document.getElementsByName("behaviors")[0];
var text = document.createTextNode("Please choose one behavior");
var option = document.createElement("option");
option.appendChild(text);
selectNode.appendChild(option);
$.each(modelData.pages, function(i, item) {
$.each(item.batches, function(i, item) {
var id = item.Id;
$.each(item.behaviors, function(i, item) {
if (item.use == pluginName) {
var textNode = document.createTextNode(item.use + "_" + id
+ "." + item.name + "_" + item.id);
var optionNode = document.createElement("option");
optionNode.setAttribute("value", id + "_" + item.id);
optionNode.appendChild(textNode);
selectNode.appendChild(optionNode);
}
});
});
});
}
function loadFormParameters(plugin_id, behavior_id) {
var plugin = "", method = "";
alert("parameters");
$.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.put(item.key, item.value);
alert("key="+item.key+",value="+item.value);
});
}
});
}
});
});
loadMethodParameters(plugin, method, plugin_id, behavior_id);
}
function loadMethodParameters(plugin, method, plugin_id, behavior_id) {
var behaviorData = plugin + "_" + plugin_id + "." + method + "_"
+ behavior_id;
var behaviorIndex = /*plugin_id+"_"+*/ behavior_id;
$
.post(
"loadMethodParameters",
{
pluginName : plugin,
methodName : method
},
function(data) {
if (!data.success) {
alert(data.failedMessage);
return;
}
data = data.data;
var documentHtml = "";
var boxHeader = "";
var fieldHTML = createBehaviorsForm(data, behaviorData,
behaviorIndex);
boxHeader = "<div class='box-header well' data-original-title> "
+ "<i class='icon-pencil left'></i>"
+ "<h2>sample:<i>"
+ behaviorData
+ "</i></h2></div>";
documentHtml = "<div id='"
+ behaviorIndex
+ "' class=''><p class='hide'>"
+ behaviorData
+ "</p><div class='span10 box' style='margin-left:15px;'>"
+ boxHeader + "<div class='box-content'>"
+ fieldHTML + "</div></div></div>";
document.getElementById("showPluginMethodForm").innerHTML += documentHtml;
createForm(behaviorIndex);
});
}
function createForm(behaviorIndex) {
var formNode = document.getElementById(behaviorIndex);
var contents = formNode.lastChild.lastChild.childNodes;
var contentLength = contents.length;
for (var j = 0; j < contentLength; j++) {
var type = $(contents[j]).attr("class");
if (type == "Field sample_frame") {
var key = contents[j].lastChild.firstChild.nodeValue;
var value = parameters.get(key);
if (value != "" && value != null) {
$(contents[j].lastChild.lastChild).val(value);
}
} else if (type == "MultiField sample_frame") {
var key = contents[j].firstChild.firstChild.nodeValue.split(":")[0];
var value = parameters.get(key);
if(value==null){
addField(20,behaviorIndex);
}
else {
value = value.split(";");
var fieldLength = value.length;
for (var t = 0; t < fieldLength; t++) {
addField(20, behaviorIndex);
$($(contents[j]).find("table").children()[t]).find("input")
.val(value[t]);
}
}
} else if (type == "Table sample_frame") {
var key = contents[j].lastChild.firstChild.nodeValue;
/*//参数不统一
if(key=="header"){
key="headers";
}*/
var value = parameters.get(key);
alert("key="+key+",value="+value);
if (value != "" && value != null) {
value = parameters.get(key).split("|;");
var table = $(contents[j]).find("table");
var col = table.find("th").length;
var row = value.length - 1;
var tbody = $(contents[j]).find("tbody");
for (var m = 0; m < row; m++) {
var input = value[m].split("|");
if (m != 0) {
var selectedNode = contents[j].lastChild.firstChild.nextSibling.nextSibling;
addCol(selectedNode);
}
for (var n = 0; n < col; n++) {
var rowNode = $(tbody).children()[m];
var colNode = $(rowNode).children()[n];
$(colNode).find("input").val(input[n]);
alert("input["+n+"]="+input[n]);
}
}
}
}
}
}
function saveFormModification() {
alert("saveFormModification");
var div = document.getElementById("showPluginMethodForm").firstChild;
var plugin_method = div.firstChild.firstChild.nodeValue.split(".");
var pluginId = plugin_method[0].split("_")[1];
var behaviorId = plugin_method[1].split("_")[1];
var contents = div.lastChild.lastChild.childNodes;
var length = contents.length;
for (var i = 0; i < length; i++) {
var node = contents[i];
var key = "", value = "", temp = "";
if ($(node).attr("class") == "Field sample_frame") {
key = node.lastChild.firstChild.nodeValue;
temp = $(node).find("input").val();
if (temp != "") {
value = temp;
}
} else if ($(node).attr("class") == "MultiField sample_frame") {
key = node.firstChild.firstChild.nodeValue.split(":")[0];
var fieldNode = $(node).find("table").children();
var fieldLength = $(fieldNode).length;
for (var j = 0; j < fieldLength; j++) {
temp = $(fieldNode[j]).find("input").val();
if (temp != "") {
value += temp;
}
if (j != fieldLength - 1) {
value += ";";
}
}
} else if ($(node).attr("class") == "Table sample_frame") {
key = node.lastChild.firstChild.nodeValue;
var table = $(node).find("table");
var col = table.find("th").length;
var row = table.find("tbody").children().length;
var tbody = $(node).find("tbody");
for (var m = 0; m < row; m++) {
for (var n = 0; n < col; n++) {
var rowNode = $(tbody).children()[m];
var colNode = $(rowNode).children()[n];
temp = $(colNode).find("input").val();
if (temp != "") {
value += temp + "|";
}
}
if (value != "") {
value += ";";
}
}
} else if ($(node).attr("class") == "CheckBox sample_frame") {
key = node.lastChild.firstChild.nodeValue;
var id = $(node).attr("id");
$('input[name=' + id + ']:checked').each(function() {
temp = $(this).val();
if (temp != "") {
value += temp + ";";
}
});
}
parameterList.put(key, value);
}
modifyJsonData(pluginId, behaviorId);
}
function modifyJsonData(pluginId, behaviorId) {
alert("modifyJsonData");
$.each(modelData.pages, function(i, item) {
$.each(item.batches, function(i, item) {
if (item.Id == pluginId) {
$.each(item.behaviors, function(i, item) {
if (item.id == behaviorId) {
$.each(item.parameters, function(i, item) {
if(parameterList.exists(item.key)){
item.value = parameterList.get(item.key);
}
});
/*var keyList=parameterList.getKeys();
for(var i=0;i<keyList.length;i++){
alert("keyList is "+keyList[i]);
var parameterModel=new ParameterModel(keyList[i],parameterList.get(keyList[i]));
item.parameters[i] = JSON.stringify(parameterModel);
alert("json is "+item.parameters[i]);
}
alert("item.parameters="+item.parameters);*/
}
});
}
});
});
var pluginNameList = new Array();
var parameters = [];
var parameterList = [];
var behaviorChoosed;
var behaviorName;
var pluginName;
var plugin_id;
var behavior_id;
var clickScriptId;
function loadUsePluigns(data) {
for (var i = 0; i < data.usePlugins.length; i++) {
var flag = false;
var usePlugin = data.usePlugins[i];
for (var j = 0; j < pluginNameList.length; j++) {
if (pluginNameList[j] == usePlugin.id) {
flag = true;
}
}
if (flag == false) {
pluginNameList.push(usePlugin.id);
}
}
var ulNode = document.getElementById("allPlugins");
for (var p = 0; p < pluginNameList.length; p++) {
createALi(ulNode, pluginNameList[p], "choosePlugin");
}
loadBehaviors("all");
}
function createALi(ulNode, name, action) {
var textNode = document.createTextNode(name);
var li = document.createElement("li");
var divider = document.createElement("li");
var a = document.createElement("a");
divider.setAttribute("class", "divider");
if (action == "choosePlugin") {
a.setAttribute("onClick", "choosePlugin(this);");
} else {
a.setAttribute("onClick", "chooseBehavior(this);");
}
a.appendChild(textNode);
li.appendChild(a);
ulNode.appendChild(li);
ulNode.appendChild(divider);
}
function choosePlugin(selectedNode) {
pluginName = selectedNode.firstChild.nodeValue;
loadBehaviors("other");
}
function loadBehaviors(mark) {
var ul = document.getElementById("behaviorUl");
$(ul).html("");
$.each(modelData.pages, function(i, item) {
$.each(item.batches, function(i, item) {
var Id = item.Id;
if (mark == "other") {
$.each(item.behaviors, function(i, item) {
if (item.use == pluginName) {
var text = item.use + ":" + Id + "." + item.name + ":"
+ item.id;
createALi(ul, text, "");
}
});
} else if (mark == "all") {
$.each(item.behaviors, function(i, item) {
var text = item.use + ":" + Id + "." + item.name + ":"
+ item.id;
createALi(ul, text, "");
});
}
});
});
}
function chooseBehavior(selectedNode) {
document.getElementById("action").style.display = "none";
document.getElementById("showPluginMethodForm").innerHTML = "";
var behaviorMethod = selectedNode.firstChild.nodeValue;
var bm = behaviorMethod.split(".");
plugin_id = bm[0].split(":")[1];
behavior_id = bm[1].split(":")[1];
behaviorName = bm[1].split(":")[0];
loadFormParameters(behaviorMethod);
}
function loadFormParameters(behaviorMethod) {
var plugin = "", method = "";
$.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;
});
}
});
}
});
});
loadMethodParameters(plugin, method, behaviorMethod);
}
function loadMethodParameters(plugin, method, behaviorData) {
if (plugin.indexOf("_") >= 0) {
plugin = plugin.split("_")[0];
}
var behaviorIndex = behavior_id;
$
.post(
"loadMethodParameters",
{
pluginName : plugin,
methodName : method
},
function(data) {
if (!data.success) {
alert(data.failedMessage);
return;
}
data = data.data;
var documentHtml = "";
var boxHeader = "";
var fieldHTML = createBehaviorsForm(data, behaviorData,
behaviorIndex);
boxHeader = "<div class='box-header well' data-original-title> "
+ "<i class='icon-pencil left'></i>"
+ "<h2>sample:<i>"
+ behaviorData
+ "</i></h2></div>";
documentHtml = "<div id='"
+ behaviorIndex
+ "' class=''><p class='hide'>"
+ behaviorData
+ "</p><div class='span10 box' style='margin-left:15px;margin-top:-2px;'>"
+ boxHeader + "<div class='box-content'>"
+ fieldHTML + "</div></div></div>";
document.getElementById("showPluginMethodForm").innerHTML = documentHtml;
document.getElementById("action").style.display = "block";
createForm(behaviorIndex);
});
}
function createForm(behaviorIndex) {
var formNode = document.getElementById(behaviorIndex);
var contents = formNode.lastChild.lastChild.childNodes;
var contentLength = contents.length;
for (var j = 0; j < contentLength; j++) {
var type = $(contents[j]).attr("class");
if (type == "Field sample_frame") {
var key = contents[j].lastChild.firstChild.nodeValue;
var value = parameters[key];
if (value != "" && value != null) {
$(contents[j].lastChild.lastChild).val(value);
}
} else if (type == "MultiField sample_frame") {
var key = contents[j].firstChild.firstChild.nodeValue.split(":")[0];
var value = parameters[key];
if (value == null) {
addField(20, behaviorIndex);
} else {
value = value.split(";");
var fieldLength = value.length;
for (var t = 0; t < fieldLength; t++) {
addField(20, behaviorIndex);
$($(contents[j]).find("table").children()[t]).find("input")
.val(value[t]);
}
}
} else if (type == "Table sample_frame") {
var key = contents[j].lastChild.firstChild.nodeValue;
var value = parameters[key];
if (value != "" && value != null) {
value = parameters[key].split("|;");
var table = $(contents[j]).find("table");
var col = table.find("th").length;
var row = value.length - 1;
var tbody = $(contents[j]).find("tbody");
for (var m = 0; m < row; m++) {
var input = value[m].split("|");
if (m != 0) {
var selectedNode = contents[j].lastChild.firstChild.nextSibling.nextSibling;
addCol(selectedNode);
}
for (var n = 0; n < col; n++) {
var rowNode = $(tbody).children()[m];
var colNode = $(rowNode).children()[n];
$(colNode).find("input").val(input[n]);
}
}
}
}
}
}
function saveFormModification() {
var div = document.getElementById("showPluginMethodForm").firstChild;
var contents = div.lastChild.lastChild.childNodes;
var length = contents.length;
for (var i = 0; i < length; i++) {
var node = contents[i];
var key = "", value = "", temp = "";
if ($(node).attr("class") == "Field sample_frame") {
key = node.lastChild.firstChild.nodeValue;
temp = $(node).find("input").val();
if (temp != "") {
value = temp;
}
} else if ($(node).attr("class") == "MultiField sample_frame") {
key = node.firstChild.firstChild.nodeValue.split(":")[0];
var fieldNode = $(node).find("table").children();
var fieldLength = $(fieldNode).length;
for (var j = 0; j < fieldLength; j++) {
temp = $(fieldNode[j]).find("input").val();
if (temp != "") {
value += temp;
}
if (j != fieldLength - 1) {
value += ";";
}
}
} else if ($(node).attr("class") == "Table sample_frame") {
key = node.lastChild.firstChild.nodeValue;
var table = $(node).find("table");
var col = table.find("th").length;
var row = table.find("tbody").children().length;
var tbody = $(node).find("tbody");
for (var m = 0; m < row; m++) {
for (var n = 0; n < col; n++) {
var rowNode = $(tbody).children()[m];
var colNode = $(rowNode).children()[n];
temp = $(colNode).find("input").val();
if (temp != "") {
value += temp + "|";
}
}
if (value != "") {
value += ";";
}
}
} else if ($(node).attr("class") == "CheckBox sample_frame") {
key = node.lastChild.firstChild.nodeValue;
var id = $(node).attr("id");
$('input[name=' + id + ']:checked').each(function() {
temp = $(this).val();
if (temp != "") {
value += temp + ";";
}
});
}
parameterList.push(key);
parameterList[key] = value;
}
modifyJsonData();
}
function modifyJsonData() {
$.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) {
for (var i = 0; i < parameterList.length; i++) {
var key = parameterList.valueOf()[i];
var parameterModel = new ParameterModel(key,
parameterList[key]);
item.parameters[i] = parameterModel;
}
}
});
}
});
});
parameterList.splice(0, parameterList.length);
}

View File

@ -74,7 +74,6 @@ editor.load = function(scriptId) {
codeEditor.set(modelData);
if (codeEditor != null) {
var script = codeEditor.get();
/*alert("script is "+JSON.stringify(script));*/
$.ajax({
url : "saveEditScript",
data : {
@ -98,3 +97,26 @@ editor.load = function(scriptId) {
/* treeEditor.set(editor.originalData); */
}
};
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 toggleAPI() {
$("#apiDocumentation").slideToggle();
if ($("#icon-user").attr("class") == "icon-chevron-down") {
$("#icon-user").attr("class", "icon-chevron-up");
} else {
$("#icon-user").attr("class", "icon-chevron-down");
}
}
function refresh(){
location.replace(location) ;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,45 @@
function ScenarioModel(scriptName,runScenarioModel){
this.scriptName=scriptName;
this.runScenarioModel=runScenarioModel;
}
function RunScenarioModel(poolSize,usePlugins,definedParameters,pages){
this.poolSize=poolSize;
this.usePlugins=usePlugins;
this.definedParameters=definedParameters;
this.pages=pages;
}
function PageModel(batches){
this.batches=batches;
}
function BatchModel(Id,parentId,childId,behaviors){
this.Id=Id;
this.parentId=parentId;
this.childId=childId;
this.behaviors=behaviors;
}
function BehaviorModel(id, use, name, type, parameters) {
this.id = id;
this.use = use;
this.name = name;
this.type = type;
this.parameters = parameters;
}
function ParameterModel(key, value) {
this.key = key;
this.value = value;
}
function UsePluginModel(id, name, parameters) {
this.id = id;
this.name = name;
this.parameters = parameters;
}
function PluginEditScriptRequestModel(behaviorModels, usePluginModels,
scriptName) {
this.behaviorModels = behaviorModels;
@ -20,31 +62,13 @@ function MethodParamPropertyModel(key, value) {
this.value = value;
}
function BatchModel(behaviors) {
/*function BatchModel(behaviors) {
this.behaviors = behaviors;
}
function BehaviorModel(id, use, name, type, parameters) {
this.id = id;
this.use = use;
this.name = name;
this.type = type;
this.parameters = parameters;
}
function ParameterModel(key, value) {
this.key = key;
this.value = value;
}
*/
function pluignChoosedModel(pluginName, index) {
this.pluginName = pluginName;
this.index = index;
}
function UsePluginModel(id, name, parameters) {
this.id = id;
this.name = name;
this.parameters = parameters;
}

View File

@ -51,19 +51,22 @@ function addScriptTableRow(table, data, actionId) {
}
}
function deleteScript(obj) {
var scriptId = getScriptId(obj);
$.post("deleteScript", {
scriptId : scriptId
}, function(data) {
if (data.success) {
table.dataTable().fnDeleteRow(row.rowIndex - 1);
} else {
alert("this script can not be delete in DB:"+data.failedMessage);
// error message
}
});
if (confirm("Are you sure you want to delete this script?")) {
$.post("deleteScript", {
scriptId : scriptId
}, function(data) {
if (data.success) {
alert("delete success,please refresh this page");
table.dataTable().fnDeleteRow(row.rowIndex - 1);
} else {
alert("this script can not be delete in DB:"+data.failedMessage);
// error message
}
});
}
}
function editScript(obj) {
var scriptId = getScriptId(obj);