|
@@ -1,50 +1,50 @@
|
|
//表现逻辑层的处理
|
|
//表现逻辑层的处理
|
|
|
|
|
|
-if (window.location.href.indexOf("183.129.170.180") >= 0) {
|
|
|
|
|
|
+if (window.location.href.indexOf("backEndAddressServiceWrapper") >= 0) {
|
|
throw "serviceGrid"; //如果是服务器网页页面,则不执行工具
|
|
throw "serviceGrid"; //如果是服务器网页页面,则不执行工具
|
|
}
|
|
}
|
|
|
|
|
|
-//Vue元素
|
|
|
|
|
|
+//Vueelement
|
|
var app;
|
|
var app;
|
|
generateToolkit();
|
|
generateToolkit();
|
|
//生成Toolkit
|
|
//生成Toolkit
|
|
function generateToolkit() {
|
|
function generateToolkit() {
|
|
$(".tooltips").html(`
|
|
$(".tooltips").html(`
|
|
<div id="realcontent">
|
|
<div id="realcontent">
|
|
- <div class="tooldrag">✍操作提示框(可点此拖动)</div>
|
|
|
|
|
|
+ <div class="tooldrag">✍Operation Toolbox (Can drag)</div>
|
|
<div class="realcontent">
|
|
<div class="realcontent">
|
|
<div v-if="page==0">
|
|
<div v-if="page==0">
|
|
<input type="checkbox" style="width:15px;height:15px;vertical-align:middle;" v-on:mousedown="specialSelect"> </input>
|
|
<input type="checkbox" style="width:15px;height:15px;vertical-align:middle;" v-on:mousedown="specialSelect"> </input>
|
|
- <p style="margin-bottom:10px;display:inline-block">特殊点选模式</p>
|
|
|
|
|
|
+ <p style="margin-bottom:10px;display:inline-block">Special click mode</p>
|
|
<div v-if="list.nl.length==0">
|
|
<div v-if="list.nl.length==0">
|
|
- <p style="color:black">● 鼠标移动到元素上后,请<strong>右键</strong>点击或者按<strong>F7</strong>键选中页面元素。</p>
|
|
|
|
- <p style="color:black">● 如果不小心左键点选了元素导致页面跳转,直接后退或者切换回标签页即可。</p>
|
|
|
|
|
|
+ <p style="color:black">● When your mouse moves to the element, please use your<strong>right mouse button</strong>or<strong>F7</strong> on the keyboard to select it.</p>
|
|
|
|
+ <p style="color:black">● You can click the back button to go back to the page</p>
|
|
{{initial()}}
|
|
{{initial()}}
|
|
</div>
|
|
</div>
|
|
<div v-if="list.nl.length==1">
|
|
<div v-if="list.nl.length==1">
|
|
<div v-if="tname()!='null'">
|
|
<div v-if="tname()!='null'">
|
|
- ● 已选中{{numOfList()}}个{{tname()}},<span v-if="numOfReady()>0&&tname()!='下一页元素'">同时发现{{numOfReady()}}个同类元素,</span>您可以:
|
|
|
|
|
|
+ ● Already selected {{numOfList()}} {{tname()}},<span v-if="numOfReady()>0&&tname()!='Elements in next page'">, meanwhile we find {{numOfReady()}} element with the same type, </span>you can:
|
|
<div class="innercontent">
|
|
<div class="innercontent">
|
|
- <div v-if="numOfReady()>0 && !selectStatus"> <a v-on:mousedown="selectAll">选中全部</a> <span title="">☺</span></div>
|
|
|
|
- <div v-if="existDescendents()&& !selectStatus &&(tname()=='元素' || tname()=='链接')"> <a v-on:mousedown="selectDescendents">选中子元素</a> <span title="">☺</span></div>
|
|
|
|
|
|
+ <div v-if="numOfReady()>0 && !selectStatus"> <a v-on:mousedown="selectAll">Select All</a> <span title="">☺</span></div>
|
|
|
|
+ <div v-if="existDescendents()&& !selectStatus &&(tname()=='element' || tname()=='link')"> <a v-on:mousedown="selectDescendents">Select child elements</a> <span title="">☺</span></div>
|
|
<div v-if="!selectedDescendents && !selectStatus" id="Single">
|
|
<div v-if="!selectedDescendents && !selectStatus" id="Single">
|
|
- <div v-if="tname()=='选择框'"> <a>循环切换下拉选项</a><span title="">☺</span></div>
|
|
|
|
- <div v-if="tname()=='文本框'"> <a v-on:mousedown="setInput">输入文字</a><span title="">☺</span></div>
|
|
|
|
- <div v-if="tname()!='图片'"> <a v-on:mousedown="getText">采集该{{tname()}}的文本</a><span title="采集文本">☺</span></div>
|
|
|
|
- <div v-if="tname()=='选择框'"> <a>采集选中项的文本</a><span title="">☺</span></div>
|
|
|
|
- <div v-if="tname()=='链接'||tname()=='图片'"> <a v-on:mousedown="getLink">采集该{{tname()}}的地址</a><span title="">☺</span></div>
|
|
|
|
- <div v-if="tname()!='选择框' && tname()!='文本框'"> <a v-on:mousedown="clickElement">点击该{{tname()}}</a><span title="">☺</span></div>
|
|
|
|
- <div v-if="tname()!='选择框' && tname()!='文本框'"> <a v-on:mousedown="loopClickSingleElement">循环点击该{{tname()}}</a><span title="">☺</span></div>
|
|
|
|
- <div v-if="tname()=='链接'||tname()=='元素'"> <a v-on:mousedown="getInnerHtml">采集该{{tname()}}的Inner Html</a><span title="">☺</span></div>
|
|
|
|
|
|
+ <div v-if="tname()=='selection box'"> <a>---------</a><span title="">☺</span></div>
|
|
|
|
+ <div v-if="tname()=='text box'"> <a v-on:mousedown="setInput">Input Text</a><span title="">☺</span></div>
|
|
|
|
+ <div v-if="tname()!='Image'"> <a v-on:mousedown="getText">Collect {{tname()}}'s text</a><span title="collet text">☺</span></div>
|
|
|
|
+ <div v-if="tname()=='selection box'"> <a>采集选中项的text</a><span title="">☺</span></div>
|
|
|
|
+ <div v-if="tname()=='link'||tname()=='Image'"> <a v-on:mousedown="getLink">采集该{{tname()}}的Address</a><span title="">☺</span></div>
|
|
|
|
+ <div v-if="tname()!='selection box' && tname()!='text box'"> <a v-on:mousedown="clickElement">点击该{{tname()}}</a><span title="">☺</span></div>
|
|
|
|
+ <div v-if="tname()!='selection box' && tname()!='text box'"> <a v-on:mousedown="loopClickSingleElement">循环点击该{{tname()}}</a><span title="">☺</span></div>
|
|
|
|
+ <div v-if="tname()=='link'||tname()=='element'"> <a v-on:mousedown="getInnerHtml">采集该{{tname()}}的Inner Html</a><span title="">☺</span></div>
|
|
<div> <a v-on:mousedown="getOuterHtml">采集该{{tname()}}的Outer Html</a><span title="">☺</span></div>
|
|
<div> <a v-on:mousedown="getOuterHtml">采集该{{tname()}}的Outer Html</a><span title="">☺</span></div>
|
|
- <div> <a href="#">鼠标移动到该{{tname()}}上</a><span title="">☺</span></div>
|
|
|
|
- <div v-if="tname()=='文本框'"> <a>识别验证码</a><span title="">☺</span></div>
|
|
|
|
|
|
+ <div> <a href="#">----{{tname()}}-</a><span title="">☺</span></div>
|
|
|
|
+ <div v-if="tname()=='text box'"> <a>-----</a><span title="">☺</span></div>
|
|
</div>
|
|
</div>
|
|
<div v-if="selectedDescendents" id="Single">
|
|
<div v-if="selectedDescendents" id="Single">
|
|
- <div><a v-on:mousedown="confirmCollectSingle">采集数据</a><span title="">☺</span></div>
|
|
|
|
|
|
+ <div><a v-on:mousedown="confirmCollectSingle">Collect Data</a><span title="">☺</span></div>
|
|
</div>
|
|
</div>
|
|
<div v-if="selectStatus" id="Confirm">
|
|
<div v-if="selectStatus" id="Confirm">
|
|
- <div><a v-on:mousedown="confirmCollectSingle">确认采集</a><span title="">☺</span></div>
|
|
|
|
|
|
+ <div><a v-on:mousedown="confirmCollectSingle">Confirm Collect</a><span title="">☺</span></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@@ -53,21 +53,21 @@ function generateToolkit() {
|
|
<div v-if="list.nl.length>1">
|
|
<div v-if="list.nl.length>1">
|
|
|
|
|
|
<div v-if="option==100">
|
|
<div v-if="option==100">
|
|
- ● 已选择了以下元素,您可以:
|
|
|
|
|
|
+ ● 已select了以下element,您可以:
|
|
<div class="innercontent">
|
|
<div class="innercontent">
|
|
<div> <a v-on:mousedown="confirmCollectMulti">采集数据</a><span title="">☺</span> </div>
|
|
<div> <a v-on:mousedown="confirmCollectMulti">采集数据</a><span title="">☺</span> </div>
|
|
- <div> <a v-on:mousedown="revoke">撤销本次选择</a><span title="">☺</span></div>
|
|
|
|
|
|
+ <div> <a v-on:mousedown="revoke">撤销本次selection</a><span title="">☺</span></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div v-if="option!=100">
|
|
<div v-if="option!=100">
|
|
- ● 已选择了{{numOfList()}}个同类元素,<span v-if="numOfReady()>0">另外发现{{numOfReady()}}个同类元素,</span>您可以:
|
|
|
|
|
|
+ ● 已select了{{numOfList()}}个同类element,<span v-if="numOfReady()>0">另外发现{{numOfReady()}}个同类element,</span>您可以:
|
|
<div class="innercontent">
|
|
<div class="innercontent">
|
|
<div v-if="numOfReady()>0"> <a v-on:mousedown="selectAll">选中全部</a><span title="">☺</span></div>
|
|
<div v-if="numOfReady()>0"> <a v-on:mousedown="selectAll">选中全部</a><span title="">☺</span></div>
|
|
- <div v-if="existDescendents()&&(tname()=='元素' || tname()=='链接')"> <a v-on:mousedown="selectDescendents">选中子元素</a><span title="">☺</span></div>
|
|
|
|
|
|
+ <div v-if="existDescendents()&&(tname()=='element' || tname()=='link')"> <a v-on:mousedown="selectDescendents">选中子element</a><span title="">☺</span></div>
|
|
<div> <a v-on:mousedown="confirmCollectMultiAndDescendents">采集数据</a><span title="">☺</span></div>
|
|
<div> <a v-on:mousedown="confirmCollectMultiAndDescendents">采集数据</a><span title="">☺</span></div>
|
|
- <div v-if="tname()!='选择框' && tname()!='文本框' && !selectedDescendents"> <a v-on:mousedown="loopClickEveryElement">循环点击每个{{tname()}}</a><span title="">☺</span></div>
|
|
|
|
- <div> <a v-on:mousedown="revoke">撤销本次选择</a><span title="">☺</span></div>
|
|
|
|
|
|
+ <div v-if="tname()!='selection box' && tname()!='text box' && !selectedDescendents"> <a v-on:mousedown="loopClickEveryElement">循环点击每个{{tname()}}</a><span title="">☺</span></div>
|
|
|
|
+ <div> <a v-on:mousedown="revoke">撤销本次selection</a><span title="">☺</span></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
@@ -91,11 +91,11 @@ function generateToolkit() {
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
- <div v-if="valTable.length==0&&tname()!='下一页元素'">{{setWidth("230px")}}</div>
|
|
|
|
|
|
+ <div v-if="valTable.length==0&&tname()!='Elements in next page'">{{setWidth("230px")}}</div>
|
|
|
|
|
|
<div v-if="list.nl.length>0" style="bottom:12px;position:absolute;color:black!important;left:17px;font-size:13px">
|
|
<div v-if="list.nl.length>0" style="bottom:12px;position:absolute;color:black!important;left:17px;font-size:13px">
|
|
<div style="margin-bottom:5px">
|
|
<div style="margin-bottom:5px">
|
|
- <button v-on:mousedown="cancel">取消选择</button>
|
|
|
|
|
|
+ <button v-on:mousedown="cancel">取消selection</button>
|
|
<button v-if="!selectStatus" v-on:mousedown="enlarge">扩大选区</button>
|
|
<button v-if="!selectStatus" v-on:mousedown="enlarge">扩大选区</button>
|
|
</div>
|
|
</div>
|
|
<p style="margin-left:16px;margin-bottom:0px">{{lastElementXPath()}}</p>
|
|
<p style="margin-left:16px;margin-bottom:0px">{{lastElementXPath()}}</p>
|
|
@@ -116,14 +116,14 @@ function generateToolkit() {
|
|
data: {
|
|
data: {
|
|
option: 0,
|
|
option: 0,
|
|
list: { nl: nodeList, opp: outputParameters },
|
|
list: { nl: nodeList, opp: outputParameters },
|
|
- valTable: [], // 用来存储转换后的参数列表
|
|
|
|
- special: false, //是否为特殊选择模式
|
|
|
|
- selectedDescendents: false, // 标记是否选中了子元素
|
|
|
|
- selectStatus: false, //标记单个元素是否点击了采集
|
|
|
|
|
|
+ valTable: [], // 用来存储转换后的para列表
|
|
|
|
+ special: false, //是否为特殊selection模式
|
|
|
|
+ selectedDescendents: false, // 标记是否选中了子element
|
|
|
|
+ selectStatus: false, //标记单个element是否点击了采集
|
|
page: 0, //默认页面,1为输入文字页面
|
|
page: 0, //默认页面,1为输入文字页面
|
|
text: "", // 记录输入的文字
|
|
text: "", // 记录输入的文字
|
|
tNodeName: "", // 记录临时节点列表
|
|
tNodeName: "", // 记录临时节点列表
|
|
- nowPath: "", //现在元素的xpath
|
|
|
|
|
|
+ nowPath: "", //现在element的xpath
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
nowPath: { //变量发生变化的时候进行一些操作
|
|
nowPath: { //变量发生变化的时候进行一些操作
|
|
@@ -133,34 +133,34 @@ function generateToolkit() {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
- initial: function() { //每当元素是0的时候,执行值的初始化操作
|
|
|
|
|
|
+ initial: function() { //每当element是0的时候,执行值的初始化操作
|
|
this.selectedDescendents = false;
|
|
this.selectedDescendents = false;
|
|
this.selectStatus = false;
|
|
this.selectStatus = false;
|
|
this.nowPath = "";
|
|
this.nowPath = "";
|
|
},
|
|
},
|
|
- confirmCollectSingle: function() { //单元素确认采集
|
|
|
|
|
|
+ confirmCollectSingle: function() { //单element确认采集
|
|
collectSingle();
|
|
collectSingle();
|
|
clearEl();
|
|
clearEl();
|
|
},
|
|
},
|
|
- confirmCollectMulti: function() { //无规律多元素确认采集
|
|
|
|
|
|
+ confirmCollectMulti: function() { //无规律多element确认采集
|
|
collectMultiNoPattern();
|
|
collectMultiNoPattern();
|
|
clearEl();
|
|
clearEl();
|
|
},
|
|
},
|
|
- confirmCollectMultiAndDescendents: function() { //有规律多元素确认采集
|
|
|
|
|
|
+ confirmCollectMultiAndDescendents: function() { //有规律多element确认采集
|
|
collectMultiWithPattern();
|
|
collectMultiWithPattern();
|
|
clearEl();
|
|
clearEl();
|
|
},
|
|
},
|
|
- deleteSingleLine: function(event) { //删除单行元素
|
|
|
|
|
|
+ deleteSingleLine: function(event) { //删除单行element
|
|
let at = new Date().getTime()
|
|
let at = new Date().getTime()
|
|
- //流程图送元素的时候,默认的使用不固定循环列表,但是一旦有删除元素的操作发生,则按照固定元素列表采集元素
|
|
|
|
|
|
+ //流程图送element的时候,默认的使用不固定循环列表,但是一旦有删除element的操作发生,则按照固定element列表采集element
|
|
index = event.target.getAttribute("index");
|
|
index = event.target.getAttribute("index");
|
|
- let tnode = nodeList.splice(index, 1)[0]; //删掉当前元素
|
|
|
|
|
|
+ let tnode = nodeList.splice(index, 1)[0]; //删掉当前element
|
|
tnode["node"].style.backgroundColor = tnode["bgColor"];
|
|
tnode["node"].style.backgroundColor = tnode["bgColor"];
|
|
tnode["node"].style.boxShadow = tnode["boxShadow"];
|
|
tnode["node"].style.boxShadow = tnode["boxShadow"];
|
|
if (nodeList.length > 1) { // 如果删到没有就没有其他的操作了
|
|
if (nodeList.length > 1) { // 如果删到没有就没有其他的操作了
|
|
handleElement();
|
|
handleElement();
|
|
if (this.selectedDescendents) {
|
|
if (this.selectedDescendents) {
|
|
- handleDescendents(); //如果之前有选中子元素,新加入的节点又则这里也需要重新选择子元素
|
|
|
|
|
|
+ handleDescendents(); //如果之前有选中子element,新加入的节点又则这里也需要重新selection子element
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
this.valTable = [];
|
|
this.valTable = [];
|
|
@@ -170,25 +170,25 @@ function generateToolkit() {
|
|
let at2 = parseInt(new Date().getTime());
|
|
let at2 = parseInt(new Date().getTime());
|
|
console.log("delete:", at2, at, at2 - at);
|
|
console.log("delete:", at2, at, at2 - at);
|
|
},
|
|
},
|
|
- clickElement: function() { //点击元素操作
|
|
|
|
|
|
+ clickElement: function() { //点击element操作
|
|
sendSingleClick();
|
|
sendSingleClick();
|
|
//先发送数据
|
|
//先发送数据
|
|
- nodeList[0]["node"].focus(); //获得元素焦点
|
|
|
|
- nodeList[0]["node"].click(); //点击元素
|
|
|
|
|
|
+ nodeList[0]["node"].focus(); //获得element焦点
|
|
|
|
+ nodeList[0]["node"].click(); //点击element
|
|
clearEl();
|
|
clearEl();
|
|
},
|
|
},
|
|
- loopClickSingleElement: function() { //循环点击单个元素
|
|
|
|
- sendLoopClickSingle(this.tname()); //识别下一页,循环点击单个元素和点击多个元素
|
|
|
|
- if (this.tname() != "下一页元素") { //下一页元素不进行点击操作
|
|
|
|
- nodeList[0]["node"].focus(); //获得元素焦点
|
|
|
|
- nodeList[0]["node"].click(); //点击元素
|
|
|
|
|
|
+ loopClickSingleElement: function() { //循环点击单个element
|
|
|
|
+ sendLoopClickSingle(this.tname()); //识别下一页,循环点击单个element和点击多个element
|
|
|
|
+ if (this.tname() != "Elements in next page") { //Elements in next page不进行点击操作
|
|
|
|
+ nodeList[0]["node"].focus(); //获得element焦点
|
|
|
|
+ nodeList[0]["node"].click(); //点击element
|
|
}
|
|
}
|
|
clearEl();
|
|
clearEl();
|
|
},
|
|
},
|
|
- loopClickEveryElement: function() { //循环点击每个元素
|
|
|
|
- sendLoopClickEvery(); //识别下一页,循环点击单个元素和点击多个元素
|
|
|
|
- nodeList[0]["node"].focus(); //获得元素焦点
|
|
|
|
- nodeList[0]["node"].click(); //点击元素
|
|
|
|
|
|
+ loopClickEveryElement: function() { //循环点击每个element
|
|
|
|
+ sendLoopClickEvery(); //识别下一页,循环点击单个element和点击多个element
|
|
|
|
+ nodeList[0]["node"].focus(); //获得element焦点
|
|
|
|
+ nodeList[0]["node"].click(); //点击element
|
|
clearEl();
|
|
clearEl();
|
|
},
|
|
},
|
|
setInput: function() { //输入文字
|
|
setInput: function() { //输入文字
|
|
@@ -199,7 +199,7 @@ function generateToolkit() {
|
|
},
|
|
},
|
|
getInput: function() { //得到输入的文字
|
|
getInput: function() { //得到输入的文字
|
|
nodeList[0]["node"].focus(); //获得文字焦点
|
|
nodeList[0]["node"].focus(); //获得文字焦点
|
|
- // nodeList[0]["node"].setAttribute("value", this.text); // 设置输入框内容
|
|
|
|
|
|
+ // nodeList[0]["node"].setAttribute("value", this.text); // 设置输入 box内容
|
|
input(this.text); // 设置输入
|
|
input(this.text); // 设置输入
|
|
this.text = "";
|
|
this.text = "";
|
|
clearEl();
|
|
clearEl();
|
|
@@ -207,7 +207,7 @@ function generateToolkit() {
|
|
cancelInput: function() {
|
|
cancelInput: function() {
|
|
this.page = 0;
|
|
this.page = 0;
|
|
},
|
|
},
|
|
- setWidth: function(width) { //根据是否出现表格调整最外框宽度
|
|
|
|
|
|
+ setWidth: function(width) { //根据是否出现表格调整最外 box宽度
|
|
$(".tooltips").css("width", width);
|
|
$(".tooltips").css("width", width);
|
|
return "";
|
|
return "";
|
|
},
|
|
},
|
|
@@ -216,7 +216,7 @@ function generateToolkit() {
|
|
this.selectStatus = true;
|
|
this.selectStatus = true;
|
|
clearReady();
|
|
clearReady();
|
|
},
|
|
},
|
|
- getLink: function() { //采集链接地址
|
|
|
|
|
|
+ getLink: function() { //采集linkAddress
|
|
generateParameters(0, false, true);
|
|
generateParameters(0, false, true);
|
|
this.selectStatus = true;
|
|
this.selectStatus = true;
|
|
clearReady();
|
|
clearReady();
|
|
@@ -243,22 +243,22 @@ function generateToolkit() {
|
|
return "null";
|
|
return "null";
|
|
} else if ($(nodeList[0]["node"]).contents().filter(function() { return this.nodeType === 3; }).text().indexOf("下一页") >= 0) {
|
|
} else if ($(nodeList[0]["node"]).contents().filter(function() { return this.nodeType === 3; }).text().indexOf("下一页") >= 0) {
|
|
this.setWidth("250px");
|
|
this.setWidth("250px");
|
|
- return "下一页元素";
|
|
|
|
|
|
+ return "Elements in next page";
|
|
} else if (tag == "A") {
|
|
} else if (tag == "A") {
|
|
- return "链接";
|
|
|
|
|
|
+ return "link";
|
|
} else if (tag == "IMG") {
|
|
} else if (tag == "IMG") {
|
|
- return "图片";
|
|
|
|
|
|
+ return "Image";
|
|
} else if (tag == "BUTTON" || (tag == "INPUT" && (inputType == "button" || inputType == "submit"))) {
|
|
} else if (tag == "BUTTON" || (tag == "INPUT" && (inputType == "button" || inputType == "submit"))) {
|
|
- return "按钮";
|
|
|
|
- } else if (tag == "TEXTAREA" || (tag == "INPUT" && (inputType != "checkbox" || inputType != "ratio"))) { //普通输入框
|
|
|
|
- return "文本框";
|
|
|
|
|
|
+ return "Button";
|
|
|
|
+ } else if (tag == "TEXTAREA" || (tag == "INPUT" && (inputType != "checkbox" || inputType != "ratio"))) { //普通输入 box
|
|
|
|
+ return "text box";
|
|
} else if (tag == "SELECT") {
|
|
} else if (tag == "SELECT") {
|
|
- return "选择框";
|
|
|
|
|
|
+ return "selection box";
|
|
} else {
|
|
} else {
|
|
- return "元素";
|
|
|
|
|
|
+ return "element";
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- existDescendents: function() { //检测选中的元素是否存在子元素,已经选中了子元素也不要再出现了
|
|
|
|
|
|
+ existDescendents: function() { //检测选中的element是否存在子element,已经选中了子element也不要再出现了
|
|
return nodeList.length > 0 && nodeList[0]["node"].children.length > 0 && !this.selectedDescendents;
|
|
return nodeList.length > 0 && nodeList[0]["node"].children.length > 0 && !this.selectedDescendents;
|
|
},
|
|
},
|
|
numOfReady: function() {
|
|
numOfReady: function() {
|
|
@@ -267,11 +267,11 @@ function generateToolkit() {
|
|
numOfList: function() {
|
|
numOfList: function() {
|
|
return nodeList.length;
|
|
return nodeList.length;
|
|
},
|
|
},
|
|
- lastElementXPath: function() { //用来显示元素的最大最后5个xpath路劲元素
|
|
|
|
|
|
+ lastElementXPath: function() { //用来显示element的最大最后5个xpath路劲element
|
|
path = nodeList[nodeList.length - 1]["xpath"];
|
|
path = nodeList[nodeList.length - 1]["xpath"];
|
|
path = path.split("/");
|
|
path = path.split("/");
|
|
tp = "";
|
|
tp = "";
|
|
- if (path.length > 5) { //只保留最后五个元素
|
|
|
|
|
|
+ if (path.length > 5) { //只保留最后五个element
|
|
path = path.splice(path.length - 5, 5);
|
|
path = path.splice(path.length - 5, 5);
|
|
tp = ".../"
|
|
tp = ".../"
|
|
}
|
|
}
|
|
@@ -285,7 +285,7 @@ function generateToolkit() {
|
|
cancel: function() {
|
|
cancel: function() {
|
|
clearEl();
|
|
clearEl();
|
|
},
|
|
},
|
|
- specialSelect: function() { //特殊选择模式
|
|
|
|
|
|
+ specialSelect: function() { //特殊selection模式
|
|
if (mousemovebind) {
|
|
if (mousemovebind) {
|
|
tdiv.style.pointerEvents = "none";
|
|
tdiv.style.pointerEvents = "none";
|
|
this.special = false;
|
|
this.special = false;
|
|
@@ -294,10 +294,10 @@ function generateToolkit() {
|
|
}
|
|
}
|
|
mousemovebind = !mousemovebind;
|
|
mousemovebind = !mousemovebind;
|
|
},
|
|
},
|
|
- enlarge: function() { // 扩大选区功能,总是扩大最后一个选中的元素的选区
|
|
|
|
|
|
+ enlarge: function() { // 扩大选区功能,总是扩大最后一个选中的element的选区
|
|
if (nodeList[nodeList.length - 1]["node"].tagName != "BODY") {
|
|
if (nodeList[nodeList.length - 1]["node"].tagName != "BODY") {
|
|
- nodeList[nodeList.length - 1]["node"].style.backgroundColor = nodeList[nodeList.length - 1]["bgColor"]; //之前元素恢复原来的背景颜色
|
|
|
|
- nodeList[nodeList.length - 1]["node"].style.boxShadow = nodeList[nodeList.length - 1]["boxShadow"]; //之前元素恢复原来的背景颜色
|
|
|
|
|
|
+ nodeList[nodeList.length - 1]["node"].style.backgroundColor = nodeList[nodeList.length - 1]["bgColor"]; //之前element恢复原来的背景颜色
|
|
|
|
+ nodeList[nodeList.length - 1]["node"].style.boxShadow = nodeList[nodeList.length - 1]["boxShadow"]; //之前element恢复原来的背景颜色
|
|
tNode = nodeList[nodeList.length - 1]["node"].parentNode; //向上走一层
|
|
tNode = nodeList[nodeList.length - 1]["node"].parentNode; //向上走一层
|
|
if (tNode != NowNode) { //扩大选区之后背景颜色的判断,当前正好选中的颜色应该是不同的
|
|
if (tNode != NowNode) { //扩大选区之后背景颜色的判断,当前正好选中的颜色应该是不同的
|
|
sty = tNode.style.backgroundColor;
|
|
sty = tNode.style.backgroundColor;
|
|
@@ -307,7 +307,7 @@ function generateToolkit() {
|
|
nodeList[nodeList.length - 1]["node"] = tNode;
|
|
nodeList[nodeList.length - 1]["node"] = tNode;
|
|
nodeList[nodeList.length - 1]["bgColor"] = sty;
|
|
nodeList[nodeList.length - 1]["bgColor"] = sty;
|
|
nodeList[nodeList.length - 1]["xpath"] = readXPath(tNode, 1);
|
|
nodeList[nodeList.length - 1]["xpath"] = readXPath(tNode, 1);
|
|
- //显示框
|
|
|
|
|
|
+ //显示 box
|
|
var pos = tNode.getBoundingClientRect();
|
|
var pos = tNode.getBoundingClientRect();
|
|
div.style.display = "block";
|
|
div.style.display = "block";
|
|
div.style.height = tNode.offsetHeight + "px";
|
|
div.style.height = tNode.offsetHeight + "px";
|
|
@@ -316,39 +316,39 @@ function generateToolkit() {
|
|
div.style.top = pos.top + "px";
|
|
div.style.top = pos.top + "px";
|
|
div.style.zIndex = 2147483645;
|
|
div.style.zIndex = 2147483645;
|
|
div.style.pointerEvents = "none";
|
|
div.style.pointerEvents = "none";
|
|
- handleElement(); //每次数组元素有变动,都需要重新处理下
|
|
|
|
|
|
+ handleElement(); //每次数组element有变动,都需要重新处理下
|
|
oe = tNode;
|
|
oe = tNode;
|
|
tNode.style.backgroundColor = "rgba(0,191,255,0.5)";
|
|
tNode.style.backgroundColor = "rgba(0,191,255,0.5)";
|
|
this.selectedDescendents = false;
|
|
this.selectedDescendents = false;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- selectAll: function() { //选中全部元素
|
|
|
|
|
|
+ selectAll: function() { //选中全部element
|
|
step++;
|
|
step++;
|
|
readyToList(step, false);
|
|
readyToList(step, false);
|
|
handleElement();
|
|
handleElement();
|
|
if (this.selectedDescendents) {
|
|
if (this.selectedDescendents) {
|
|
- handleDescendents(); //如果之前有选中子元素,新加入的节点又则这里也需要重新选择子元素
|
|
|
|
|
|
+ handleDescendents(); //如果之前有选中子element,新加入的节点又则这里也需要重新selection子element
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- revoke: function() { //撤销选择当前节点
|
|
|
|
|
|
+ revoke: function() { //撤销selection当前节点
|
|
var tstep = step;
|
|
var tstep = step;
|
|
step--; //步数-1
|
|
step--; //步数-1
|
|
- while (tstep == nodeList[nodeList.length - 1]["step"]) //删掉所有当前步数的元素节点
|
|
|
|
|
|
+ while (tstep == nodeList[nodeList.length - 1]["step"]) //删掉所有当前步数的element节点
|
|
{
|
|
{
|
|
let node = nodeList.splice(nodeList.length - 1, 1)[0]; //删除数组最后一项
|
|
let node = nodeList.splice(nodeList.length - 1, 1)[0]; //删除数组最后一项
|
|
- node["node"].style.backgroundColor = node["bgColor"]; //还原原始属性和边框
|
|
|
|
|
|
+ node["node"].style.backgroundColor = node["bgColor"]; //还原原始属性和边 box
|
|
node["node"].style.boxShadow = node["boxShadow"];
|
|
node["node"].style.boxShadow = node["boxShadow"];
|
|
if (NowNode == node["node"]) {
|
|
if (NowNode == node["node"]) {
|
|
style = node["bgColor"];
|
|
style = node["bgColor"];
|
|
}
|
|
}
|
|
- //处理已经有选中子元素的情况
|
|
|
|
|
|
+ //处理已经有选中子element的情况
|
|
// if (this.selectedDescendents) {
|
|
// if (this.selectedDescendents) {
|
|
clearParameters(); //直接撤销重选
|
|
clearParameters(); //直接撤销重选
|
|
// }
|
|
// }
|
|
}
|
|
}
|
|
- handleElement(); //每次数组元素有变动,都需要重新处理下
|
|
|
|
|
|
+ handleElement(); //每次数组element有变动,都需要重新处理下
|
|
},
|
|
},
|
|
- selectDescendents: function() { //选择所有子元素操作
|
|
|
|
|
|
+ selectDescendents: function() { //selection所有子element操作
|
|
handleDescendents();
|
|
handleDescendents();
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -358,7 +358,7 @@ function generateToolkit() {
|
|
if (difference > 0) {
|
|
if (difference > 0) {
|
|
$(".tooldrag").css("cssText", "height:" + (26 + difference) + "px!important")
|
|
$(".tooldrag").css("cssText", "height:" + (26 + difference) + "px!important")
|
|
}
|
|
}
|
|
- timer = setInterval(function() { //时刻监测相应元素是否存在(防止出现如百度一样元素消失重写body的情况),如果不存在,添加进来
|
|
|
|
|
|
+ timer = setInterval(function() { //时刻监测相应element是否存在(防止出现如百度一样element消失重写body的情况),如果不存在,添加进来
|
|
if (document.body != null && document.getElementById("wrapperToolkit") == null) {
|
|
if (document.body != null && document.getElementById("wrapperToolkit") == null) {
|
|
this.clearInterval(); //先取消原来的计时器,再设置新的计时器
|
|
this.clearInterval(); //先取消原来的计时器,再设置新的计时器
|
|
document.body.append(div); //默认如果toolkit不存在则div和tdiv也不存在
|
|
document.body.append(div); //默认如果toolkit不存在则div和tdiv也不存在
|
|
@@ -381,10 +381,10 @@ function generateToolkit() {
|
|
}, 3000);
|
|
}, 3000);
|
|
}
|
|
}
|
|
|
|
|
|
-//每次对元素进行增删之后需要执行的操作
|
|
|
|
|
|
+//每次对element进行增删之后需要执行的操作
|
|
function handleElement() {
|
|
function handleElement() {
|
|
- clearReady(); //预备元素每次处理都先处理掉
|
|
|
|
- if (nodeList.length > 1) { //选中了许多元素的情况
|
|
|
|
|
|
+ clearReady(); //预备element每次处理都先处理掉
|
|
|
|
+ if (nodeList.length > 1) { //选中了许多element的情况
|
|
app._data.option = relatedTest();
|
|
app._data.option = relatedTest();
|
|
if (app._data.option == 100) {
|
|
if (app._data.option == 100) {
|
|
generateMultiParameters();
|
|
generateMultiParameters();
|
|
@@ -392,13 +392,13 @@ function handleElement() {
|
|
generateParameters(0);
|
|
generateParameters(0);
|
|
}
|
|
}
|
|
} else if (nodeList.length == 1) {
|
|
} else if (nodeList.length == 1) {
|
|
- findRelated(); //寻找和元素相关的元素
|
|
|
|
|
|
+ findRelated(); //寻找和element相关的element
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-function clearParameters(deal = true) //清空参数列表
|
|
|
|
|
|
+function clearParameters(deal = true) //清空para列表
|
|
{
|
|
{
|
|
- if (deal) //是否取消对选中的子元素进行处理
|
|
|
|
|
|
+ if (deal) //是否取消对选中的子element进行处理
|
|
{
|
|
{
|
|
app._data.selectedDescendents = false;
|
|
app._data.selectedDescendents = false;
|
|
}
|
|
}
|
|
@@ -406,20 +406,20 @@ function clearParameters(deal = true) //清空参数列表
|
|
o["node"].style.boxShadow = o["boxShadow"];
|
|
o["node"].style.boxShadow = o["boxShadow"];
|
|
}
|
|
}
|
|
outputParameterNodes.splice(0);
|
|
outputParameterNodes.splice(0);
|
|
- outputParameters.splice(0); //清空原来的参数列表
|
|
|
|
|
|
+ outputParameters.splice(0); //清空原来的para列表
|
|
app._data.valTable = []; //清空展现数组
|
|
app._data.valTable = []; //清空展现数组
|
|
app._data.selectStatus = false;
|
|
app._data.selectStatus = false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-//根据nodelist列表内的元素生成参数列表
|
|
|
|
-//适合:nodelist中的元素为同类型元素
|
|
|
|
-//type:0为全部文本 1为节点内直接的文字 2为innerhtml 3为outerhtml
|
|
|
|
|
|
+//根据nodelist列表内的element生成para列表
|
|
|
|
+//适合:nodelist中的element为同类型element
|
|
|
|
+//type:0为全部text 1为节点内直接的文字 2为innerhtml 3为outerhtml
|
|
//nodetype:0,对应全type0123
|
|
//nodetype:0,对应全type0123
|
|
-//nodetype:1 链接,对应type0123
|
|
|
|
-//nodetype:2 链接地址 对应type0
|
|
|
|
-//nodetype:3 按钮和输入文本框 对应type
|
|
|
|
-//nodetype:4 按钮和输入文本框 对应type
|
|
|
|
|
|
+//nodetype:1 link,对应type0123
|
|
|
|
+//nodetype:2 linkAddress 对应type0
|
|
|
|
+//nodetype:3 按钮和输入text box 对应type
|
|
|
|
+//nodetype:4 按钮和输入text box 对应type
|
|
|
|
|
|
function generateParameters(type, linktext = true, linkhref = true) {
|
|
function generateParameters(type, linktext = true, linkhref = true) {
|
|
clearParameters(false);
|
|
clearParameters(false);
|
|
@@ -432,23 +432,23 @@ function generateParameters(type, linktext = true, linkhref = true) {
|
|
ndPath = nodeList[num]["xpath"];
|
|
ndPath = nodeList[num]["xpath"];
|
|
outputParameterNodes.push({ "node": nd, "boxShadow": nd.style.boxShadow == "" || boxShadowColor ? "none" : nd.style.boxShadow });
|
|
outputParameterNodes.push({ "node": nd, "boxShadow": nd.style.boxShadow == "" || boxShadowColor ? "none" : nd.style.boxShadow });
|
|
nd.style.boxShadow = boxShadowColor;
|
|
nd.style.boxShadow = boxShadowColor;
|
|
- let pname = "文本";
|
|
|
|
|
|
+ let pname = "text";
|
|
let ndText = "";
|
|
let ndText = "";
|
|
if (type == 0) {
|
|
if (type == 0) {
|
|
ndText = $(nd).text();
|
|
ndText = $(nd).text();
|
|
- pname = "文本";
|
|
|
|
|
|
+ pname = "text";
|
|
if (nd.tagName == "IMG") {
|
|
if (nd.tagName == "IMG") {
|
|
ndText = nd.getAttribute("src") == null ? "" : $(nd).prop("src");
|
|
ndText = nd.getAttribute("src") == null ? "" : $(nd).prop("src");
|
|
- pname = "地址";
|
|
|
|
|
|
+ pname = "Address";
|
|
} else if (nd.tagName == "INPUT") {
|
|
} else if (nd.tagName == "INPUT") {
|
|
ndText = nd.getAttribute("value") == null ? "" : nd.getAttribute("value");
|
|
ndText = nd.getAttribute("value") == null ? "" : nd.getAttribute("value");
|
|
}
|
|
}
|
|
} else if (type == 1) {
|
|
} else if (type == 1) {
|
|
ndText = $(nd).contents().filter(function() { return this.nodeType === 3; }).text().replace(/\s+/g, '');
|
|
ndText = $(nd).contents().filter(function() { return this.nodeType === 3; }).text().replace(/\s+/g, '');
|
|
- pname = "文本";
|
|
|
|
|
|
+ pname = "text";
|
|
if (nd.tagName == "IMG") {
|
|
if (nd.tagName == "IMG") {
|
|
ndText = nd.getAttribute("src") == null ? "" : $(nd).prop("src");
|
|
ndText = nd.getAttribute("src") == null ? "" : $(nd).prop("src");
|
|
- pname = "地址";
|
|
|
|
|
|
+ pname = "Address";
|
|
} else if (nd.tagName == "INPUT") {
|
|
} else if (nd.tagName == "INPUT") {
|
|
ndText = nd.getAttribute("value") == null ? "" : nd.getAttribute("value");
|
|
ndText = nd.getAttribute("value") == null ? "" : nd.getAttribute("value");
|
|
}
|
|
}
|
|
@@ -460,24 +460,24 @@ function generateParameters(type, linktext = true, linkhref = true) {
|
|
pname = "outerHTML";
|
|
pname = "outerHTML";
|
|
}
|
|
}
|
|
if (num == 0) { //第一个节点新建,后面的增加即可
|
|
if (num == 0) { //第一个节点新建,后面的增加即可
|
|
- if (nd.tagName == "IMG") { //如果元素是图片
|
|
|
|
|
|
+ if (nd.tagName == "IMG") { //如果element是Image
|
|
outputParameters.push({
|
|
outputParameters.push({
|
|
"nodeType": 4, //节点类型
|
|
"nodeType": 4, //节点类型
|
|
"contentType": type, // 内容类型
|
|
"contentType": type, // 内容类型
|
|
"relative": nodeList.length > 1 ? true : false, //是否为相对xpath路径
|
|
"relative": nodeList.length > 1 ? true : false, //是否为相对xpath路径
|
|
- "name": "参数" + (n++) + "_图片" + pname,
|
|
|
|
- "desc": "", //参数描述
|
|
|
|
|
|
+ "name": "para" + (n++) + "_Image" + pname,
|
|
|
|
+ "desc": "", //para描述
|
|
"relativeXpath": nodeList.length > 1 ? "" : ndPath,
|
|
"relativeXpath": nodeList.length > 1 ? "" : ndPath,
|
|
"exampleValues": [{ "num": num, "value": ndText }]
|
|
"exampleValues": [{ "num": num, "value": ndText }]
|
|
});
|
|
});
|
|
- } else if (nd.tagName == "A") { //如果元素是超链接
|
|
|
|
|
|
+ } else if (nd.tagName == "A") { //如果element是超link
|
|
if (linktext) {
|
|
if (linktext) {
|
|
outputParameters.push({
|
|
outputParameters.push({
|
|
"nodeType": 1,
|
|
"nodeType": 1,
|
|
"contentType": type, // 内容类型
|
|
"contentType": type, // 内容类型
|
|
"relative": nodeList.length > 1 ? true : false, //是否为相对xpath路径
|
|
"relative": nodeList.length > 1 ? true : false, //是否为相对xpath路径
|
|
- "name": "参数" + (n++) + "_链接" + pname,
|
|
|
|
- "desc": "", //参数描述
|
|
|
|
|
|
+ "name": "para" + (n++) + "_link" + pname,
|
|
|
|
+ "desc": "", //para描述
|
|
"relativeXpath": nodeList.length > 1 ? "" : ndPath,
|
|
"relativeXpath": nodeList.length > 1 ? "" : ndPath,
|
|
"exampleValues": [{ "num": num, "value": ndText }]
|
|
"exampleValues": [{ "num": num, "value": ndText }]
|
|
});
|
|
});
|
|
@@ -487,19 +487,19 @@ function generateParameters(type, linktext = true, linkhref = true) {
|
|
"nodeType": 2,
|
|
"nodeType": 2,
|
|
"contentType": type, // 内容类型
|
|
"contentType": type, // 内容类型
|
|
"relative": nodeList.length > 1 ? true : false, //是否为相对xpath路径
|
|
"relative": nodeList.length > 1 ? true : false, //是否为相对xpath路径
|
|
- "name": "参数" + (n++) + "_链接地址",
|
|
|
|
- "desc": "", //参数描述
|
|
|
|
|
|
+ "name": "para" + (n++) + "_linkAddress",
|
|
|
|
+ "desc": "", //para描述
|
|
"relativeXpath": nodeList.length > 1 ? "" : ndPath,
|
|
"relativeXpath": nodeList.length > 1 ? "" : ndPath,
|
|
"exampleValues": [{ "num": num, "value": nd.getAttribute("href") == null ? "" : $(nd).prop("href") }]
|
|
"exampleValues": [{ "num": num, "value": nd.getAttribute("href") == null ? "" : $(nd).prop("href") }]
|
|
});
|
|
});
|
|
}
|
|
}
|
|
- } else if (nd.tagName == "INPUT") { //如果元素是输入项
|
|
|
|
|
|
+ } else if (nd.tagName == "INPUT") { //如果element是输入项
|
|
outputParameters.push({
|
|
outputParameters.push({
|
|
"nodeType": 3,
|
|
"nodeType": 3,
|
|
"contentType": type, // 内容类型
|
|
"contentType": type, // 内容类型
|
|
"relative": nodeList.length > 1 ? true : false, //是否为相对xpath路径
|
|
"relative": nodeList.length > 1 ? true : false, //是否为相对xpath路径
|
|
- "name": "参数" + (n++) + "_" + pname,
|
|
|
|
- "desc": "", //参数描述
|
|
|
|
|
|
+ "name": "para" + (n++) + "_" + pname,
|
|
|
|
+ "desc": "", //para描述
|
|
"relativeXpath": nodeList.length > 1 ? "" : ndPath,
|
|
"relativeXpath": nodeList.length > 1 ? "" : ndPath,
|
|
"exampleValues": [{ "num": num, "value": ndText }]
|
|
"exampleValues": [{ "num": num, "value": ndText }]
|
|
});
|
|
});
|
|
@@ -508,19 +508,19 @@ function generateParameters(type, linktext = true, linkhref = true) {
|
|
"nodeType": 0,
|
|
"nodeType": 0,
|
|
"contentType": type, // 内容类型
|
|
"contentType": type, // 内容类型
|
|
"relative": nodeList.length > 1 ? true : false, //是否为相对xpath路径
|
|
"relative": nodeList.length > 1 ? true : false, //是否为相对xpath路径
|
|
- "name": "参数" + (n++) + "_" + pname,
|
|
|
|
- "desc": "", //参数描述
|
|
|
|
|
|
+ "name": "para" + (n++) + "_" + pname,
|
|
|
|
+ "desc": "", //para描述
|
|
"relativeXpath": nodeList.length > 1 ? "" : ndPath,
|
|
"relativeXpath": nodeList.length > 1 ? "" : ndPath,
|
|
"exampleValues": [{ "num": num, "value": ndText }]
|
|
"exampleValues": [{ "num": num, "value": ndText }]
|
|
});
|
|
});
|
|
}
|
|
}
|
|
- } else { //如果元素节点已经存在,则只需要插入值就可以了
|
|
|
|
- if (nd.tagName == "IMG") { //如果元素是图片
|
|
|
|
|
|
+ } else { //如果element节点已经存在,则只需要插入值就可以了
|
|
|
|
+ if (nd.tagName == "IMG") { //如果element是Image
|
|
outputParameters[0]["exampleValues"].push({ "num": num, "value": ndText });
|
|
outputParameters[0]["exampleValues"].push({ "num": num, "value": ndText });
|
|
- } else if (nd.tagName == "A") { //如果元素是超链接
|
|
|
|
|
|
+ } else if (nd.tagName == "A") { //如果element是超link
|
|
outputParameters[0]["exampleValues"].push({ "num": num, "value": ndText });
|
|
outputParameters[0]["exampleValues"].push({ "num": num, "value": ndText });
|
|
outputParameters[1]["exampleValues"].push({ "num": num, "value": nd.getAttribute("href") == null ? "" : $(nd).prop("href") });
|
|
outputParameters[1]["exampleValues"].push({ "num": num, "value": nd.getAttribute("href") == null ? "" : $(nd).prop("href") });
|
|
- } else if (nd.tagName == "INPUT") { //如果元素是输入项
|
|
|
|
|
|
+ } else if (nd.tagName == "INPUT") { //如果element是输入项
|
|
outputParameters[0]["exampleValues"].push({ "num": num, "value": ndText });
|
|
outputParameters[0]["exampleValues"].push({ "num": num, "value": ndText });
|
|
} else { //其他所有情况
|
|
} else { //其他所有情况
|
|
outputParameters[0]["exampleValues"].push({ "num": num, "value": ndText });
|
|
outputParameters[0]["exampleValues"].push({ "num": num, "value": ndText });
|
|
@@ -536,8 +536,8 @@ function generateParameters(type, linktext = true, linkhref = true) {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-//根据nodelist列表内的元素生成参数列表
|
|
|
|
-//适合:nodelist中的元素为不同类型元素
|
|
|
|
|
|
+//根据nodelist列表内的element生成para列表
|
|
|
|
+//适合:nodelist中的element为不同类型element
|
|
function generateMultiParameters() {
|
|
function generateMultiParameters() {
|
|
clearParameters(false);
|
|
clearParameters(false);
|
|
let n = 1;
|
|
let n = 1;
|
|
@@ -550,23 +550,23 @@ function generateMultiParameters() {
|
|
outputParameterNodes.push({ "node": nd, "boxShadow": nd.style.boxShadow == "" || boxShadowColor ? "none" : nd.style.boxShadow });
|
|
outputParameterNodes.push({ "node": nd, "boxShadow": nd.style.boxShadow == "" || boxShadowColor ? "none" : nd.style.boxShadow });
|
|
nd.style.boxShadow = boxShadowColor;
|
|
nd.style.boxShadow = boxShadowColor;
|
|
ndText = $(nd).text();
|
|
ndText = $(nd).text();
|
|
- if (nd.tagName == "IMG") { //如果元素是图片
|
|
|
|
|
|
+ if (nd.tagName == "IMG") { //如果element是Image
|
|
outputParameters.push({
|
|
outputParameters.push({
|
|
"nodeType": 4, //节点类型
|
|
"nodeType": 4, //节点类型
|
|
"contentType": 0, // 内容类型
|
|
"contentType": 0, // 内容类型
|
|
"relative": false, //是否为相对xpath路径
|
|
"relative": false, //是否为相对xpath路径
|
|
- "name": "参数" + (n++) + "_图片地址",
|
|
|
|
- "desc": "", //参数描述
|
|
|
|
|
|
+ "name": "para" + (n++) + "_imageAddress",
|
|
|
|
+ "desc": "", //para描述
|
|
"relativeXpath": ndPath,
|
|
"relativeXpath": ndPath,
|
|
"exampleValues": [{ "num": 0, "value": nd.getAttribute("src") == null ? "" : $(nd).prop("src") }]
|
|
"exampleValues": [{ "num": 0, "value": nd.getAttribute("src") == null ? "" : $(nd).prop("src") }]
|
|
});
|
|
});
|
|
- } else if (nd.tagName == "A") { //如果元素是超链接
|
|
|
|
|
|
+ } else if (nd.tagName == "A") { //如果element是超link
|
|
outputParameters.push({
|
|
outputParameters.push({
|
|
"nodeType": 1,
|
|
"nodeType": 1,
|
|
"contentType": 0, // 内容类型
|
|
"contentType": 0, // 内容类型
|
|
"relative": false, //是否为相对xpath路径
|
|
"relative": false, //是否为相对xpath路径
|
|
- "name": "参数" + (n++) + "_链接文本",
|
|
|
|
- "desc": "", //参数描述
|
|
|
|
|
|
+ "name": "para" + (n++) + "_linktext",
|
|
|
|
+ "desc": "", //para描述
|
|
"relativeXpath": ndPath,
|
|
"relativeXpath": ndPath,
|
|
"exampleValues": [{ "num": 0, "value": ndText }]
|
|
"exampleValues": [{ "num": 0, "value": ndText }]
|
|
});
|
|
});
|
|
@@ -574,18 +574,18 @@ function generateMultiParameters() {
|
|
"nodeType": 2,
|
|
"nodeType": 2,
|
|
"contentType": 0, // 内容类型
|
|
"contentType": 0, // 内容类型
|
|
"relative": false, //是否为相对xpath路径
|
|
"relative": false, //是否为相对xpath路径
|
|
- "name": "参数" + (n++) + "_链接地址",
|
|
|
|
- "desc": "", //参数描述
|
|
|
|
|
|
+ "name": "para" + (n++) + "_linkAddress",
|
|
|
|
+ "desc": "", //para描述
|
|
"relativeXpath": ndPath,
|
|
"relativeXpath": ndPath,
|
|
"exampleValues": [{ "num": 0, "value": nd.getAttribute("href") == null ? "" : $(nd).prop("href") }]
|
|
"exampleValues": [{ "num": 0, "value": nd.getAttribute("href") == null ? "" : $(nd).prop("href") }]
|
|
});
|
|
});
|
|
- } else if (nd.tagName == "INPUT") { //如果元素是输入项
|
|
|
|
|
|
+ } else if (nd.tagName == "INPUT") { //如果element是输入项
|
|
outputParameters.push({
|
|
outputParameters.push({
|
|
"nodeType": 3,
|
|
"nodeType": 3,
|
|
"contentType": 0, // 内容类型
|
|
"contentType": 0, // 内容类型
|
|
"relative": false, //是否为相对xpath路径
|
|
"relative": false, //是否为相对xpath路径
|
|
- "name": "参数" + (n++) + "_文本",
|
|
|
|
- "desc": "", //参数描述
|
|
|
|
|
|
+ "name": "para" + (n++) + "_text",
|
|
|
|
+ "desc": "", //para描述
|
|
"relativeXpath": ndPath,
|
|
"relativeXpath": ndPath,
|
|
"exampleValues": [{ "num": 0, "value": nd.getAttribute("value") == null ? "" : nd.getAttribute("value") }]
|
|
"exampleValues": [{ "num": 0, "value": nd.getAttribute("value") == null ? "" : nd.getAttribute("value") }]
|
|
});
|
|
});
|
|
@@ -594,8 +594,8 @@ function generateMultiParameters() {
|
|
"nodeType": 0,
|
|
"nodeType": 0,
|
|
"contentType": 0, // 内容类型
|
|
"contentType": 0, // 内容类型
|
|
"relative": false, //是否为相对xpath路径
|
|
"relative": false, //是否为相对xpath路径
|
|
- "name": "参数" + (n++) + "_文本",
|
|
|
|
- "desc": "", //参数描述
|
|
|
|
|
|
+ "name": "para" + (n++) + "_text",
|
|
|
|
+ "desc": "", //para描述
|
|
"relativeXpath": ndPath,
|
|
"relativeXpath": ndPath,
|
|
"exampleValues": [{ "num": 0, "value": ndText }]
|
|
"exampleValues": [{ "num": 0, "value": ndText }]
|
|
});
|
|
});
|
|
@@ -610,22 +610,22 @@ function generateMultiParameters() {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-//处理子元素,对于每个块中多出的特殊元素,需要特殊处理
|
|
|
|
|
|
+//处理子element,对于每个块中多出的特殊element,需要特殊处理
|
|
function handleDescendents() {
|
|
function handleDescendents() {
|
|
let n = 1;
|
|
let n = 1;
|
|
chrome.storage.local.get({ parameterNum: 1 }, function(items) {
|
|
chrome.storage.local.get({ parameterNum: 1 }, function(items) {
|
|
let at = parseInt(new Date().getTime());
|
|
let at = parseInt(new Date().getTime());
|
|
n = items.parameterNum;
|
|
n = items.parameterNum;
|
|
- clearParameters(); //清除原来的参数列表
|
|
|
|
|
|
+ clearParameters(); //清除原来的para列表
|
|
app._data.selectedDescendents = true;
|
|
app._data.selectedDescendents = true;
|
|
for (let num = 0; num < nodeList.length; num++) {
|
|
for (let num = 0; num < nodeList.length; num++) {
|
|
let tnode = nodeList[num]["node"];
|
|
let tnode = nodeList[num]["node"];
|
|
- let stack = new Array(); //深度优先搜索遍历元素
|
|
|
|
|
|
+ let stack = new Array(); //深度优先搜索遍历element
|
|
stack.push(tnode); //从此节点开始
|
|
stack.push(tnode); //从此节点开始
|
|
while (stack.length > 0) {
|
|
while (stack.length > 0) {
|
|
- let nd = stack.pop(); // 挨个取出元素
|
|
|
|
|
|
+ let nd = stack.pop(); // 挨个取出element
|
|
if (nd.parentNode.tagName == "A" && nd.tagName == "SPAN") {
|
|
if (nd.parentNode.tagName == "A" && nd.tagName == "SPAN") {
|
|
- continue; //对A标签内的SPAN元素不进行处理,剪枝,此时子元素根本不加入stack,即实现了此功能
|
|
|
|
|
|
+ continue; //对A标签内的SPANelement不进行处理,剪枝,此时子element根本不加入stack,即实现了此功能
|
|
}
|
|
}
|
|
ndPath = readXPath(nd, 1, tnode);
|
|
ndPath = readXPath(nd, 1, tnode);
|
|
let index = -1;
|
|
let index = -1;
|
|
@@ -643,29 +643,29 @@ function handleDescendents() {
|
|
ndText = $(nd).contents().filter(function() {
|
|
ndText = $(nd).contents().filter(function() {
|
|
return this.nodeType === 3;
|
|
return this.nodeType === 3;
|
|
}).text().replace(/\s+/g, '');
|
|
}).text().replace(/\s+/g, '');
|
|
- if (index == -1) { //从第二个节点开始,只插入那些不在参数列表中的元素,根据xpath进行寻址
|
|
|
|
- //如果当前节点除了子元素外仍然有其他文字或者该元素是图片/表单项,加入子元素节点
|
|
|
|
|
|
+ if (index == -1) { //从第二个节点开始,只插入那些不在para列表中的element,根据xpath进行寻址
|
|
|
|
+ //如果当前节点除了子element外仍然有其他文字或者该element是Image/表单项,加入子element节点
|
|
if (ndText != "" || nd.tagName == "IMG" || nd.tagName == "INPUT" || nd.tagName == "A") {
|
|
if (ndText != "" || nd.tagName == "IMG" || nd.tagName == "INPUT" || nd.tagName == "A") {
|
|
- if (nd.tagName == "IMG") { //如果元素是图片
|
|
|
|
|
|
+ if (nd.tagName == "IMG") { //如果element是Image
|
|
outputParameters.push({
|
|
outputParameters.push({
|
|
"nodeType": 4, //节点类型
|
|
"nodeType": 4, //节点类型
|
|
"contentType": 1, // 内容类型
|
|
"contentType": 1, // 内容类型
|
|
- "relative": nodeList.length > 1 ? true : false, //是否为相对xpath路径,注意当只选择了子元素没有选中全部的时候,需要判断
|
|
|
|
- "name": "参数" + (n++) + "_图片地址",
|
|
|
|
- "desc": "", //参数描述
|
|
|
|
|
|
+ "relative": nodeList.length > 1 ? true : false, //是否为相对xpath路径,注意当只selection了子element没有选中全部的时候,需要判断
|
|
|
|
+ "name": "para" + (n++) + "_imageAddress",
|
|
|
|
+ "desc": "", //para描述
|
|
"relativeXpath": nodeList.length > 1 ? ndPath : readXPath(nd), //同理需要判断
|
|
"relativeXpath": nodeList.length > 1 ? ndPath : readXPath(nd), //同理需要判断
|
|
"exampleValues": [{
|
|
"exampleValues": [{
|
|
"num": num,
|
|
"num": num,
|
|
"value": nd.getAttribute("src") == null ? "" : $(nd).prop("src")
|
|
"value": nd.getAttribute("src") == null ? "" : $(nd).prop("src")
|
|
}]
|
|
}]
|
|
});
|
|
});
|
|
- } else if (nd.tagName == "A") { //如果元素是超链接
|
|
|
|
|
|
+ } else if (nd.tagName == "A") { //如果element是超link
|
|
outputParameters.push({
|
|
outputParameters.push({
|
|
"nodeType": 1,
|
|
"nodeType": 1,
|
|
"contentType": 0, // 内容类型
|
|
"contentType": 0, // 内容类型
|
|
"relative": nodeList.length > 1 ? true : false, //是否为相对xpath路径
|
|
"relative": nodeList.length > 1 ? true : false, //是否为相对xpath路径
|
|
- "name": "参数" + (n++) + "_链接文本",
|
|
|
|
- "desc": "", //参数描述
|
|
|
|
|
|
+ "name": "para" + (n++) + "_linktext",
|
|
|
|
+ "desc": "", //para描述
|
|
"relativeXpath": nodeList.length > 1 ? ndPath : readXPath(nd),
|
|
"relativeXpath": nodeList.length > 1 ? ndPath : readXPath(nd),
|
|
"exampleValues": [{ "num": num, "value": $(nd).text() }] //注意这里的ndtext是整个a的文字!!!
|
|
"exampleValues": [{ "num": num, "value": $(nd).text() }] //注意这里的ndtext是整个a的文字!!!
|
|
});
|
|
});
|
|
@@ -673,21 +673,21 @@ function handleDescendents() {
|
|
"nodeType": 2,
|
|
"nodeType": 2,
|
|
"contentType": 0, // 内容类型
|
|
"contentType": 0, // 内容类型
|
|
"relative": nodeList.length > 1 ? true : false, //是否为相对xpath路径
|
|
"relative": nodeList.length > 1 ? true : false, //是否为相对xpath路径
|
|
- "name": "参数" + (n++) + "_链接地址",
|
|
|
|
- "desc": "", //参数描述
|
|
|
|
|
|
+ "name": "para" + (n++) + "_linkAddress",
|
|
|
|
+ "desc": "", //para描述
|
|
"relativeXpath": nodeList.length > 1 ? ndPath : readXPath(nd),
|
|
"relativeXpath": nodeList.length > 1 ? ndPath : readXPath(nd),
|
|
"exampleValues": [{
|
|
"exampleValues": [{
|
|
"num": num,
|
|
"num": num,
|
|
"value": nd.getAttribute("href") == null ? "" : $(nd).prop("href")
|
|
"value": nd.getAttribute("href") == null ? "" : $(nd).prop("href")
|
|
}]
|
|
}]
|
|
});
|
|
});
|
|
- } else if (nd.tagName == "INPUT") { //如果元素是输入项
|
|
|
|
|
|
+ } else if (nd.tagName == "INPUT") { //如果element是输入项
|
|
outputParameters.push({
|
|
outputParameters.push({
|
|
"nodeType": 3,
|
|
"nodeType": 3,
|
|
"contentType": 1, // 内容类型
|
|
"contentType": 1, // 内容类型
|
|
"relative": nodeList.length > 1 ? true : false, //是否为相对xpath路径
|
|
"relative": nodeList.length > 1 ? true : false, //是否为相对xpath路径
|
|
- "name": "参数" + (n++) + "_文本",
|
|
|
|
- "desc": "", //参数描述
|
|
|
|
|
|
+ "name": "para" + (n++) + "_text",
|
|
|
|
+ "desc": "", //para描述
|
|
"relativeXpath": nodeList.length > 1 ? ndPath : readXPath(nd),
|
|
"relativeXpath": nodeList.length > 1 ? ndPath : readXPath(nd),
|
|
"exampleValues": [{
|
|
"exampleValues": [{
|
|
"num": num,
|
|
"num": num,
|
|
@@ -699,27 +699,27 @@ function handleDescendents() {
|
|
"nodeType": 0,
|
|
"nodeType": 0,
|
|
"contentType": 1, // 内容类型
|
|
"contentType": 1, // 内容类型
|
|
"relative": nodeList.length > 1 ? true : false, //是否为相对xpath路径
|
|
"relative": nodeList.length > 1 ? true : false, //是否为相对xpath路径
|
|
- "name": "参数" + (n++) + "_文本",
|
|
|
|
- "desc": "", //参数描述
|
|
|
|
|
|
+ "name": "para" + (n++) + "_text",
|
|
|
|
+ "desc": "", //para描述
|
|
"relativeXpath": nodeList.length > 1 ? ndPath : readXPath(nd),
|
|
"relativeXpath": nodeList.length > 1 ? ndPath : readXPath(nd),
|
|
"exampleValues": [{ "num": num, "value": ndText }]
|
|
"exampleValues": [{ "num": num, "value": ndText }]
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- } else //如果元素节点已经存在,则只需要插入值就可以了
|
|
|
|
|
|
+ } else //如果element节点已经存在,则只需要插入值就可以了
|
|
{
|
|
{
|
|
- if (nd.tagName == "IMG") { //如果元素是图片
|
|
|
|
|
|
+ if (nd.tagName == "IMG") { //如果element是Image
|
|
outputParameters[index]["exampleValues"].push({
|
|
outputParameters[index]["exampleValues"].push({
|
|
"num": num,
|
|
"num": num,
|
|
"value": nd.getAttribute("src") == null ? "" : $(nd).prop("src")
|
|
"value": nd.getAttribute("src") == null ? "" : $(nd).prop("src")
|
|
});
|
|
});
|
|
- } else if (nd.tagName == "A") { //如果元素是超链接
|
|
|
|
|
|
+ } else if (nd.tagName == "A") { //如果element是超link
|
|
outputParameters[index]["exampleValues"].push({ "num": num, "value": $(nd).text() });
|
|
outputParameters[index]["exampleValues"].push({ "num": num, "value": $(nd).text() });
|
|
outputParameters[index + 1]["exampleValues"].push({
|
|
outputParameters[index + 1]["exampleValues"].push({
|
|
"num": num,
|
|
"num": num,
|
|
"value": nd.getAttribute("href") == null ? "" : $(nd).prop("href")
|
|
"value": nd.getAttribute("href") == null ? "" : $(nd).prop("href")
|
|
});
|
|
});
|
|
- } else if (nd.tagName == "INPUT") { //如果元素是输入项
|
|
|
|
|
|
+ } else if (nd.tagName == "INPUT") { //如果element是输入项
|
|
outputParameters[index]["exampleValues"].push({
|
|
outputParameters[index]["exampleValues"].push({
|
|
"num": num,
|
|
"num": num,
|
|
"value": nd.getAttribute("value") == null ? "" : nd.getAttribute("value")
|
|
"value": nd.getAttribute("value") == null ? "" : nd.getAttribute("value")
|
|
@@ -734,14 +734,14 @@ function handleDescendents() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let at2 = parseInt(new Date().getTime());
|
|
let at2 = parseInt(new Date().getTime());
|
|
- console.log("选中子元素", at2, at, at2 - at);
|
|
|
|
|
|
+ console.log("选中子element", at2, at, at2 - at);
|
|
generateValTable();
|
|
generateValTable();
|
|
});
|
|
});
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-//根据参数列表生成可视化参数界面
|
|
|
|
|
|
+//根据para列表生成可视化para界面
|
|
function generateValTable(multiline = true) {
|
|
function generateValTable(multiline = true) {
|
|
let paravalues = [];
|
|
let paravalues = [];
|
|
for (let i = 0; i < outputParameters.length; i++) {
|
|
for (let i = 0; i < outputParameters.length; i++) {
|
|
@@ -764,7 +764,7 @@ function generateValTable(multiline = true) {
|
|
|
|
|
|
// 选中第一个节点,自动寻找同类节点
|
|
// 选中第一个节点,自动寻找同类节点
|
|
// 方法:/div[1]/div[2]/div[2]/a[1]
|
|
// 方法:/div[1]/div[2]/div[2]/a[1]
|
|
-// 从倒数第一个节点开始找,看去掉方括号之后是否元素数目变多,如上面的变成/div[1]/div[2]/div[2]/a
|
|
|
|
|
|
+// 从倒数第一个节点开始找,看去掉方括号之后是否element数目变多,如上面的变成/div[1]/div[2]/div[2]/a
|
|
// 如果没有,则恢复原状,然后试试倒数第二个:/div[1]/div[2]/div/a[1]
|
|
// 如果没有,则恢复原状,然后试试倒数第二个:/div[1]/div[2]/div/a[1]
|
|
// 直到找到第一个变多的节点或者追溯到根节点为止
|
|
// 直到找到第一个变多的节点或者追溯到根节点为止
|
|
function findRelated() {
|
|
function findRelated() {
|
|
@@ -789,9 +789,9 @@ function findRelated() {
|
|
tempIndexList[i] = -1; //删除索引值
|
|
tempIndexList[i] = -1; //删除索引值
|
|
tempPath = combineXpath(nodeNameList, tempIndexList); //生成新的xpath
|
|
tempPath = combineXpath(nodeNameList, tempIndexList); //生成新的xpath
|
|
var result = document.evaluate(tempPath, document, null, XPathResult.ANY_TYPE, null);
|
|
var result = document.evaluate(tempPath, document, null, XPathResult.ANY_TYPE, null);
|
|
- result.iterateNext(); //枚举第一个元素
|
|
|
|
- if (result.iterateNext() != null) { //如果能枚举到第二个元素,说明存在同类元素,选中同类元素,结束循环
|
|
|
|
- app.$data.nowPath = tempPath; //标记此元素xpath
|
|
|
|
|
|
+ result.iterateNext(); //枚举第一个element
|
|
|
|
+ if (result.iterateNext() != null) { //如果能枚举到第二个element,说明存在同类element,选中同类element,结束循环
|
|
|
|
+ app.$data.nowPath = tempPath; //标记此elementxpath
|
|
pushToReadyList(tempPath);
|
|
pushToReadyList(tempPath);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -801,11 +801,11 @@ function findRelated() {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-//根据path将元素放入readylist中
|
|
|
|
|
|
+//根据path将element放入readylist中
|
|
function pushToReadyList(path) {
|
|
function pushToReadyList(path) {
|
|
result = document.evaluate(path, document, null, XPathResult.ANY_TYPE, null);
|
|
result = document.evaluate(path, document, null, XPathResult.ANY_TYPE, null);
|
|
- var node = result.iterateNext(); //枚举第一个元素
|
|
|
|
- while (node) { //只添加不在已选中列表内的元素
|
|
|
|
|
|
+ var node = result.iterateNext(); //枚举第一个element
|
|
|
|
+ while (node) { //只添加不在已选中列表内的element
|
|
let exist = false;
|
|
let exist = false;
|
|
for (o of nodeList) {
|
|
for (o of nodeList) {
|
|
if (o["node"] == node) {
|
|
if (o["node"] == node) {
|
|
@@ -817,19 +817,19 @@ function pushToReadyList(path) {
|
|
readyList.push({ "node": node, "bgColor": node.style.backgroundColor, "boxShadow": node.style.boxShadow == "" || boxShadowColor ? "none" : node.style.boxShadow });
|
|
readyList.push({ "node": node, "bgColor": node.style.backgroundColor, "boxShadow": node.style.boxShadow == "" || boxShadowColor ? "none" : node.style.boxShadow });
|
|
}
|
|
}
|
|
node.style.boxShadow = boxShadowColor;
|
|
node.style.boxShadow = boxShadowColor;
|
|
- node = result.iterateNext(); //枚举下一个元素
|
|
|
|
|
|
+ node = result.iterateNext(); //枚举下一个element
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-//将readyList中的元素放入选中节点中
|
|
|
|
|
|
+//将readyList中的element放入选中节点中
|
|
function readyToList(step, dealparameters = true) {
|
|
function readyToList(step, dealparameters = true) {
|
|
for (o of readyList) {
|
|
for (o of readyList) {
|
|
nodeList.push({ node: o["node"], "step": step, bgColor: o["bgColor"], "boxShadow": o["boxShadow"], xpath: readXPath(o["node"], 1) });
|
|
nodeList.push({ node: o["node"], "step": step, bgColor: o["bgColor"], "boxShadow": o["boxShadow"], xpath: readXPath(o["node"], 1) });
|
|
o["node"].style.backgroundColor = selectedColor;
|
|
o["node"].style.backgroundColor = selectedColor;
|
|
}
|
|
}
|
|
clearReady();
|
|
clearReady();
|
|
- if (dealparameters) { //防止出现先选中子元素再选中全部失效的问题
|
|
|
|
- generateParameters(0); //根据nodelist列表内的元素生成参数列表,0代表纯文本
|
|
|
|
|
|
+ if (dealparameters) { //防止出现先选中子element再选中全部失效的问题
|
|
|
|
+ generateParameters(0); //根据nodelist列表内的element生成para列表,0代表纯text
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -847,7 +847,7 @@ function combineXpath(nameList, indexList) {
|
|
return finalPath;
|
|
return finalPath;
|
|
}
|
|
}
|
|
|
|
|
|
-//专门测试已经选中的这些元素之间有没有相关性
|
|
|
|
|
|
+//专门测试已经选中的这些element之间有没有相关性
|
|
// 举例:
|
|
// 举例:
|
|
// /html/body/div[3]/div[1]/div[1]/div[1]/div[3]/div[1]/div[3]/a[22]
|
|
// /html/body/div[3]/div[1]/div[1]/div[1]/div[3]/div[1]/div[3]/a[22]
|
|
// /html/body/div[3]/div[1]/div[1]/div[1]/div[3]/div[2]/div[3]/a[25]
|
|
// /html/body/div[3]/div[1]/div[1]/div[1]/div[3]/div[2]/div[3]/a[25]
|
|
@@ -859,7 +859,7 @@ function relatedTest() {
|
|
var testpath = "";
|
|
var testpath = "";
|
|
for (i = 0; i < nodeList.length; i++) {
|
|
for (i = 0; i < nodeList.length; i++) {
|
|
var testnumList = []; //用于比较节点索引号不同
|
|
var testnumList = []; //用于比较节点索引号不同
|
|
- var tpath = nodeList[i]["xpath"].split("/").splice(1); //清理第一个空元素
|
|
|
|
|
|
+ var tpath = nodeList[i]["xpath"].split("/").splice(1); //清理第一个空element
|
|
for (j = 0; j < tpath.length; j++) {
|
|
for (j = 0; j < tpath.length; j++) {
|
|
if (tpath[j].indexOf("[") >= 0) { //如果存在索引值
|
|
if (tpath[j].indexOf("[") >= 0) { //如果存在索引值
|
|
testnumList.push(parseInt(tpath[j].split("[")[1].replace("]", ""))); //只留下数字
|
|
testnumList.push(parseInt(tpath[j].split("[")[1].replace("]", ""))); //只留下数字
|
|
@@ -869,16 +869,16 @@ function relatedTest() {
|
|
tpath[j] = tpath[j].split("[")[0];
|
|
tpath[j] = tpath[j].split("[")[0];
|
|
}
|
|
}
|
|
tp = tpath.join("/");
|
|
tp = tpath.join("/");
|
|
- if (i > 0 && testpath != tp) { //如果去除括号后元素内存在不一致情况,直接返回默认情况代码100
|
|
|
|
- app.$data.nowPath = ""; //标记此元素xpath
|
|
|
|
|
|
+ if (i > 0 && testpath != tp) { //如果去除括号后element内存在不一致情况,直接返回默认情况代码100
|
|
|
|
+ app.$data.nowPath = ""; //标记此elementxpath
|
|
return 100;
|
|
return 100;
|
|
}
|
|
}
|
|
testpath = tp;
|
|
testpath = tp;
|
|
testList.push(testnumList);
|
|
testList.push(testnumList);
|
|
}
|
|
}
|
|
- testpath = testpath.split("/"); //清理第一个空元素
|
|
|
|
|
|
+ testpath = testpath.split("/"); //清理第一个空element
|
|
var indexList = []; //记录新生成的xpath
|
|
var indexList = []; //记录新生成的xpath
|
|
- //如果选中的元素属于同样的序列,则计算出序列的最佳xpath表达式
|
|
|
|
|
|
+ //如果选中的element属于同样的序列,则计算出序列的最佳xpath表达式
|
|
for (j = 0; j < testList[0].length; j++) {
|
|
for (j = 0; j < testList[0].length; j++) {
|
|
indexList.push(testList[0][j]);
|
|
indexList.push(testList[0][j]);
|
|
for (i = 1; i < testList.length; i++) {
|
|
for (i = 1; i < testList.length; i++) {
|
|
@@ -889,14 +889,14 @@ function relatedTest() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var finalPath = combineXpath(testpath, indexList);
|
|
var finalPath = combineXpath(testpath, indexList);
|
|
- app.$data.nowPath = finalPath; //标记此元素xpath
|
|
|
|
|
|
+ app.$data.nowPath = finalPath; //标记此elementxpath
|
|
pushToReadyList(finalPath);
|
|
pushToReadyList(finalPath);
|
|
let at2 = parseInt(new Date().getTime());
|
|
let at2 = parseInt(new Date().getTime());
|
|
console.log("手动:", at2, at, at2 - at);
|
|
console.log("手动:", at2, at, at2 - at);
|
|
return 50; //先返回给默认码
|
|
return 50; //先返回给默认码
|
|
}
|
|
}
|
|
|
|
|
|
-//实现提示框拖拽功能
|
|
|
|
|
|
+//实现提示 box拖拽功能
|
|
$('.tooldrag').mousedown(function(e) {
|
|
$('.tooldrag').mousedown(function(e) {
|
|
// e.pageX
|
|
// e.pageX
|
|
var positionDiv = $(this).offset();
|
|
var positionDiv = $(this).offset();
|