WM Test Object

This is the post test class which is created under the WM version 4.x script

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.gf.qytechs.cn/scripts/6899/27565/WM%20Test%20Object.js

  1. // ==UserScript==
  2. // @name WM Test Object
  3. // @namespace MerricksdadWMHostObject
  4. // @description This is the post test class which is created under the WM version 4.x script
  5. // @license http://creativecommons.org/licenses/by-nc-nd/3.0/us/
  6. // @version 4.0.0.0
  7. // @copyright Charlie Ewing except where noted
  8. // ==/UserScript==
  9.  
  10. //this script requires some functions in the WM Common Library
  11. //this script needs access to a pre-defined JSON object
  12.  
  13.  
  14. (function(){
  15.  
  16. //***************************************************************************************************************************************
  17. //***** Test Class
  18. //***************************************************************************************************************************************
  19. WM.Test = function(params){try{
  20. this.objType="test";
  21. var self=this;
  22. params=params||{};
  23. //defaults
  24. this.enabled=!(params.disabled||false); //check for WM2 disabled param
  25. this.expanded=true;
  26. this.title="";
  27. this.search=[]; //strings array
  28. this.find=""; //string
  29. this.findArray=[]; //string array
  30. this.kids=[]; //test array
  31. this.subTests=[]; //strings array
  32. this.parent=null;
  33. this.appID="";
  34. this.ret="dynamic";
  35. this._findMode="basic";
  36. this.subNumRange={low:0,high:0};
  37. this._isGlobal=false;
  38. this.__defineGetter__("saveableData",function(){try{
  39. var dat={};
  40. //dat.id=this.id;
  41. dat.label=this.title;
  42. dat.enabled=this.enabled;
  43. dat.search=this.search;
  44. dat.find=(this.findMode=="basic")?this.findArray:this.find;
  45. dat.ret=this.ret;
  46. dat.expanded=this.expanded;
  47. if (this.findMode=="subtests") dat.subTests=this.subTests;
  48. if (this.findMode=="subnumrange") {
  49. dat.subNumRange=this.subNumRange.low+","+this.subNumRange.high;
  50. }
  51. if (this.findMode=="regex") dat.regex=this.regex;
  52. dat.appID=this.appID;
  53. dat.kids=[];
  54. if (isArrayAndNotEmpty(this.kids)) for (var i=0,kid;(kid=this.kids[i]);i++) {
  55. dat.kids.push(kid.saveableData);
  56. }
  57. return dat;
  58. }catch(e){log("WM.Test.saveableData: "+e);}});
  59. //set/get wether this test is saved as global or profile
  60. this.__defineGetter__("isGlobal",function(){try{
  61. return this._isGlobal;
  62. }catch(e){log("WM.Test.isGlobal: "+e);}});
  63. this.__defineSetter__("isGlobal",function(v){try{
  64. //only top level tests can be global
  65. if (this.parent) {
  66. confirm("Only top level tests can be set to global.");
  67. return;
  68. }
  69. if (!v) {
  70. if (!confirm("Disabling profile sharing on this test will prevent other users on this machine from loading it. Are you sure you wish to make this test locally available only?")) return;
  71. }
  72. this._isGlobal=v;
  73. //make sure we have a uniqueID
  74. //but don't destroy one that already exists
  75. if (v && !exists(this.uniqueID)) this.uniqueID = unique();
  76. //change the color/icon of the isGlobal button
  77. if (this.toggleGlobalButton) {
  78. var s=WM.opts.littleButtonSize;
  79. with (this.toggleGlobalButton) className=className.swapWordB(v,"removeGlobal"+s,"addGlobal"+s);
  80. with (this.toggleGlobalButton.parentNode) {
  81. className=className.swapWordB(v,"oddOrange","oddGreen");
  82. title=(v)?"Disable Profile Sharing":"Share With Other Profiles";
  83. }
  84. }
  85. }catch(e){log("WM.Test.isGlobal: "+e);}});
  86. //use passed params
  87. for (var p in params) {
  88. //omit specific params
  89. if (!(["subNumRange","kids","disabled","label","find"].inArray(p)) ) {
  90. //copy only params that make it past the checker
  91. this[p]=params[p];
  92. }
  93. }
  94. //calculate subNumRange as an object
  95. if (exists(params.subNumRange)) {
  96. var p=params.subNumRange.split(",");
  97. this.subNumRange={low:p[0]||0, high:p[1]||0};
  98. this._findMode="subnumrange";
  99. }
  100. //get the title from the label field
  101. if (exists(params.label)) this.title=params.label;
  102. //detect which findMode we are using
  103. //subNumRange was already inspected above
  104. if (this.regex) this._findMode="regex";
  105. else if (exists(params.subTests)) this._findMode="subtests";
  106. //and we default to "basic" already
  107. //import the find field now
  108. if (isArray(params.find)) this.findArray=params.find;
  109. else this.find=params.find;
  110. this.enable=function(){try{
  111. this.enabled=true;
  112. this.node.className=this.node.className.removeWord("disabled");
  113. WM.grabber.save();
  114. }catch(e){log("WM.Test.enable: "+e);}};
  115.  
  116. this.disable=function(){try{
  117. this.enabled=false;
  118. this.node.className=this.node.className.addWord("disabled");
  119. WM.grabber.save();
  120. }catch(e){log("WM.Test.disable: "+e);}};
  121.  
  122. this.remove=function(noConfirm){try{
  123. var ask=WM.opts.dynamicConfirmDeleteTest;
  124. if (noConfirm || (this.isGlobal && confirm("This test is shared with other profiles. Deleting it here will prevent it from loading for other users. Are you sure you wish to delete this test and its children.")) || !ask || (!this.isGlobal && ask && confirm("Delete test and all of its child nodes?"))){
  125. //remove my data
  126. var parentContainer=(this.parent)?this.parent.kids:WM.grabber.tests;
  127. parentContainer.removeByValue(this);
  128. //remove my node
  129. remove(this.node);
  130. doAction(WM.grabber.save);
  131. }
  132. }catch(e){log("WM.Test.remove: "+e);}};
  133.  
  134. this.moveUp=function(){try{
  135. //where is this
  136. var parentContainer=(this.parent)?this.parent.kids:WM.grabber.tests;
  137. //only affects items not already the first in the list
  138. //and not the only child in the list
  139. if ((parentContainer.length>1) && (parentContainer[0]!=this)) {
  140. //which index is this?
  141. var myIndex=parentContainer.inArrayWhere(this);
  142. if (myIndex != -1) {
  143. //I have a proper index here
  144. //who is my sibling
  145. var sibling = parentContainer[myIndex-1];
  146. //swap me with my sibling
  147. parentContainer[myIndex-1]=this;
  148. parentContainer[myIndex]=sibling;
  149. //place my node before my sibling node
  150. sibling.node.parentNode.insertBefore(this.node,sibling.node);
  151. //save it
  152. WM.grabber.save();
  153. }
  154. }
  155. }catch(e){log("WM.Test.moveUp: "+e);}};
  156. this.moveDown=function(){try{
  157. //where is this
  158. var parentContainer=(this.parent)?this.parent.kids:WM.grabber.tests;
  159. //only affects items not already the last in the list
  160. //and not the only child in the list
  161. if ((parentContainer.length>1) && (parentContainer.last()!=this)) {
  162. //which index is this?
  163. var myIndex=parentContainer.inArrayWhere(this);
  164. if (myIndex != -1) {
  165. //I have a proper index here
  166. //who is my sibling
  167. var sibling = parentContainer[myIndex+1];
  168. //swap me with my sibling
  169. parentContainer[myIndex+1]=this;
  170. parentContainer[myIndex]=sibling;
  171. //place my node before my sibling node
  172. sibling.node.parentNode.insertBefore(sibling.node,this.node);
  173. //save it
  174. WM.grabber.save();
  175. }
  176. }
  177. }catch(e){log("WM.Test.moveDown: "+e);}};
  178.  
  179. this.moveUpLevel=function(){try{
  180. if (this.parent) {
  181. //this is not a top level node, so we can move it
  182. var targetContainer=((this.parent.parent)?this.parent.parent.kids:WM.grabber.tests);
  183. //remove from parent
  184. this.parent.kids.removeByValue(this);
  185. //set new parent
  186. this.parent=(this.parent.parent||null); //never point to the top level
  187. //move the object
  188. targetContainer.push(this);
  189. //move the node
  190. if (this.parent) this.parent.kidsNode.appendChild(this.node);
  191. else WM.console.dynamicBuild.appendChild(this.node);
  192. //save it
  193. WM.grabber.save();
  194. }
  195. }catch(e){log("WM.Test.moveUpLevel: "+e);}};
  196. this.moveDownLevel=function(){try{
  197. //where is this
  198. var parentContainer=(this.parent)?this.parent.kids:WM.grabber.tests;
  199. //create a new rule at my level
  200. var newTest = new WM.Test({
  201. parent:this.parent||null,
  202. });
  203. parentContainer.push(newTest);
  204. //remove me from my current parent
  205. parentContainer.removeByValue(this);
  206. //attach me to my new parent
  207. this.parent=newTest;
  208. newTest.kids.push(this);
  209. //move my node
  210. newTest.kidsNode.appendChild(this.node);
  211. //save it
  212. WM.grabber.save();
  213. }catch(e){log("WM.Test.moveDownLevel: "+e);}};
  214. this.clone=function(){try{
  215. var cloneTest=this.saveableData;
  216. //global clones are not global
  217. if (this.parent) this.parent.addChild(cloneTest);
  218. else WM.grabber.newTest(cloneTest);
  219. }catch(e){log("WM.Test.clone: "+e);}};
  220.  
  221. this.addChild=function(p){try{
  222. var isNew=!exists(p);
  223. p=p||{};
  224. p.parent=this;
  225. var test=new WM.Test(p);
  226. this.kids.push(test);
  227. if (isNew) WM.grabber.save();
  228. }catch(e){log("WM.Test.addChild: "+e);}};
  229.  
  230. this.toggleContent=function(){try{
  231. this.expanded=!this.expanded;
  232. var btnSize=WM.opts.littleButtonSize;
  233. with (this.contentNode)
  234. className=className.swapWordB(this.expanded,"expanded","collapsed");
  235. with (this.toggleImgNode)
  236. className=className.swapWordB(this.expanded,"treeCollapse"+btnSize,"treeExpand"+btnSize);
  237. WM.grabber.save();
  238. }catch(e){log("WM.Test.toggleContent: "+e);}};
  239. this.populateBonusList=function(){try{
  240. var node=this.bonusNode;
  241. var bonuses={};
  242. //get the list of accept texts for this app
  243. if (this.appID!="") {
  244. if (this.appID=="*") {
  245. //populate list with bonuses from ALL docked sidekicks
  246. } else {
  247. //make sure the app is ready
  248. //if it has not yet docked, it wont be
  249. var app=WM.apps[this.appID];
  250. bonuses = (app?(mergeJSON(app.accText,app.userDefinedTypes)||{}):{});
  251. }
  252. }
  253. //add special return values
  254. bonuses["dynamic"]="* Dynamic grab";
  255. bonuses["none"]="* None";
  256. bonuses["wishlist"]="* Flaged as Wishlist";
  257. bonuses["exclude"]="* Excluded types";
  258. bonuses["send"]="* Send Unknown";
  259. bonuses["doUnknown"]="* Get Unknown";
  260. bonuses["{%1}"]="* Subtest Value";
  261.  
  262. //sort by display text
  263. bonuses=sortCollection(bonuses,"value");
  264. //add each element to the dropdown
  265. var elem;
  266. node.innerHTML=""; //wipe previous list
  267. for (var i in bonuses) {
  268. var showI=i.removePrefix(this.appID);
  269. node.appendChild(
  270. elem=createElement("option",{textContent:((bonuses[i].startsWith("*"))?"":((showI.startsWith("send"))?"Send ":"Get "))+bonuses[i], value:i, selected:(this.ret==i)})
  271. );
  272. }
  273.  
  274. }catch(e){log("WM.Test.populateBonusList: "+e);}};
  275. this.populateAppList=function(){try{
  276. var node=this.appListNode;
  277. var a={};
  278. for (var i in WM.apps){
  279. a[WM.apps[i].appID]=WM.apps[i].name;
  280. }
  281.  
  282. //add special return values
  283. a["*"]="* All";
  284.  
  285. //add each element to the dropdown
  286. var elem;
  287. node.innerHTML=""; //wipe previous list
  288. for (var i in a) {
  289. node.appendChild(elem=createElement("option",{textContent:a[i], value:i,selected:(this.appID==i)}));
  290. }
  291.  
  292. //sort it
  293. elementSortChildren(node,"textContent");
  294. }catch(e){log("WM.Test.populateAppList: "+e);}};
  295.  
  296. this.calcSearch=function(){try{
  297. //collect the checked search fields in their listed order
  298. if (self.searchNode) {
  299. self.search=[];
  300. forNodes(".//input[(@type='checkbox')]",{node:self.searchNode},function(e){
  301. if (e && e.checked){
  302. self.search.push(e.value);
  303. log(e.value);
  304. }
  305. });
  306. }
  307. WM.grabber.save();
  308. }catch(e){log("WM.Test.calcSearch: "+e);}};
  309. this.convertToRule=function(p){try{
  310. var rule;
  311. WM.rulesManager.rules.push(
  312. rule=new WM.rulesManager.Rule( WM.rulesManager.ruleFromTest( this.saveableData ) )
  313. );
  314. if (WM.opts.rulesJumpToNewRule){
  315. //jump to rule view
  316. WM.console.tabContainer.selectTab(3);
  317. //scroll to new rule
  318. rule.node.scrollIntoView();
  319. }
  320. }catch(e){log("WM.Test.convertToRule: "+e);}};
  321. //set/get find field modes
  322. this.__defineGetter__("findMode",function(){try{
  323. return this._findMode;
  324. }catch(e){log("WM.Test.findMode: "+e);}});
  325. this.__defineSetter__("findMode",function(v){try{
  326. var lastV = this._findMode;
  327. this._findMode=v;
  328. if (lastV==v) return; //no change
  329. //enable disable regex type
  330. this.regex=(v=="regex" || v=="regexp");
  331. //switch to array/string find field type
  332. //this.setFindType((v=="basic")?"array":"string");
  333. //show the correct find field
  334. if (this.findNode) this.findNode.value=((v=="basic")?this.findArray.join("\n"):this.find);
  335.  
  336. //show/hide the subtests box
  337. if (this.subTestsBoxNode) with (this.subTestsBoxNode) className=className.toggleWordB((v!="subtests"),"hidden");
  338. //show/hide the subnumrange picker
  339. if (this.subNumRangeBoxNode) with (this.subNumRangeBoxNode) className=className.toggleWordB((v!="subnumrange"),"hidden");
  340. WM.grabber.save();
  341.  
  342. }catch(e){log("WM.Test.findMode: "+e);}});
  343.  
  344. //draw it
  345. try{(((this.parent)?this.parent.kidsNode:null)||$("wmDynamicBuilder")).appendChild(
  346. this.node=createElement("div",{className:"listItem "+((this.enabled)?"enabled":"disabled")},[
  347. createElement("div",{className:"line"},[
  348. createElement("div",{className:"littleButton",title:"Toggle Content",onclick:function(){self.toggleContent();}},[
  349. this.toggleImgNode=createElement("img",{className:"resourceIcon "+(this.expanded?"treeCollapse"+WM.opts.littleButtonSize:"treeExpand"+WM.opts.littleButtonSize)}),
  350. ]),
  351. this.toggleNode=createElement("input",{type:"checkbox",checked:this.enabled,onchange:function(){
  352. self.enabled=this.checked;
  353. with (self.node) className=className.toggleWordB(!this.checked,"disabled");
  354. WM.grabber.save();
  355. }}),
  356. createElement("label",{textContent:"Title:"}),
  357. this.titleNode=createElement("input",{value:(this.title||""), onchange:function(){self.title=this.value; WM.grabber.save();}}),
  358. //toolbox
  359. createElement("div",{className:"littleButton oddOrange", title:"Remove Test"},[
  360. createElement("img",{className:"resourceIcon trash"+WM.opts.littleButtonSize,onclick:function(){self.remove();}})]),
  361. createElement("div",{className:"littleButton oddBlue", title:"Clone Test"},[
  362. createElement("img",{className:"resourceIcon clone"+WM.opts.littleButtonSize,onclick:function(){self.clone();}})]),
  363. createElement("div",{className:"littleButton oddGreen", title:"Move Up"},[
  364. createElement("img",{className:"resourceIcon arrowUp"+WM.opts.littleButtonSize,onclick:function(){self.moveUp();}})]),
  365. createElement("div",{className:"littleButton oddOrange", title:"Move Down"},[
  366. createElement("img",{className:"resourceIcon arrowDown"+WM.opts.littleButtonSize,onclick:function(){self.moveDown();}})]),
  367. createElement("div",{className:"littleButton oddGreen", title:"Move Up Level"},[
  368. createElement("img",{className:"resourceIcon moveUpLevelLeft"+WM.opts.littleButtonSize,onclick:function(){self.moveUpLevel();}})]),
  369. createElement("div",{className:"littleButton oddOrange", title:"Move Down Level"},[
  370. createElement("img",{className:"resourceIcon moveInLevel"+WM.opts.littleButtonSize,onclick:function(){self.moveDownLevel();}})]),
  371. createElement("div",{className:"littleButton oddBlue", title:"Show Source"},[
  372. createElement("img",{className:"resourceIcon object"+WM.opts.littleButtonSize,onclick:function(){promptText(JSON.stringify(self.saveableData),true);}})]),
  373.  
  374. createElement("div",{className:"indent littleButton oddBlue", title:"Convert To Rule"},[
  375. createElement("img",{className:"resourceIcon exportGrab"+WM.opts.littleButtonSize,onclick:function(){self.convertToRule();}})]),
  376.  
  377. createElement("div",{className:"indent littleButton "+((this.isGlobal)?"oddOrange":"oddGreen"), title:((this.isGlobal)?"Disable Profile Sharing":"Share With Other Profiles")},[
  378. this.toggleGlobalButton=createElement("img",{className:"resourceIcon "+((this.isGlobal)?"removeGlobal":"addGlobal")+WM.opts.littleButtonSize,onclick:function(){self.isGlobal=!self.isGlobal; WM.grabber.save();}})]),
  379. ]),
  380. this.contentNode=createElement("div",{className:"subsection "+(this.expanded?"expanded":"collapsed")},[
  381. //appID
  382. createElement("div",{className:"line"},[
  383. createElement("label",{textContent:"appID:"}),
  384. this.appIDNode=createElement("input",{value:(this.appID||""), onchange:function(){self.appID=this.value;WM.grabber.save();self.populateBonusList();}}),
  385. this.appListNode=createElement("select",{onchange:function(){self.appIDNode.value=this.value; self.appID=this.value; WM.grabber.save(); self.populateBonusList();}}),
  386. createElement("div",{className:"littleButton oddBlue", title:"Refresh App List"},[
  387. createElement("img",{className:"resourceIcon refresh"+WM.opts.littleButtonSize,onclick:function(){self.populateAppList();}})]),
  388. ]),
  389. //return type
  390. createElement("div",{className:"line"},[
  391. createElement("label",{textContent:"Return Type ('which'):"}),
  392. this.retNode=createElement("input",{value:(this.ret||"dynamic"), onchange:function(){self.ret=this.value;WM.grabber.save();}}),
  393. this.bonusNode=createElement("select",{onchange:function(){self.retNode.value=this.value; self.ret=this.value; WM.grabber.save();}}),
  394. createElement("div",{className:"littleButton oddBlue", title:"Refresh Bonus List"},[
  395. createElement("img",{className:"resourceIcon refresh"+WM.opts.littleButtonSize,onclick:function(){self.populateBonusList();}})]),
  396. ]),
  397. //search list
  398. createElement("div",{className:"line"},[
  399. createElement("label",{textContent:"Search In Field(s):",title:"Specify fields in which to look for data. Adjust order as needed."}),
  400. this.searchNode=createElement("div",{className:"subsection optioncontainer"},(function(){
  401. var ret=[];
  402. //draw first the methods we have already selected
  403. if (isArrayAndNotEmpty(self.search)) for (var m=0; m<self.search.length; m++) {
  404. var s = self.search[m];
  405. ret.push(createElement("div",{className:"line"},[
  406. createElement("div",{className:"littleButton oddGreen", title:"Move Up"},[
  407. createElement("img",{className:"resourceIcon nomargin arrowUp16",onclick:function(){elementMoveUp(this.parentNode.parentNode); self.calcSearch();}})
  408. ]),
  409. createElement("div",{className:"littleButton oddOrange", title:"Move Down"},[
  410. createElement("img",{className:"resourceIcon nomargin arrowDown16",onclick:function(){elementMoveDown(this.parentNode.parentNode); self.calcSearch();}})
  411. ]),
  412. createElement("div",{className:"littleButton oddGreen", title:"Move To Top"},[
  413. createElement("img",{className:"resourceIcon nomargin moveTopLeft16",onclick:function(){elementMoveTop(this.parentNode.parentNode); self.calcSearch();}})
  414. ]),
  415. createElement("div",{className:"littleButton oddOrange", title:"Move To Bottom"},[
  416. createElement("img",{className:"resourceIcon nomargin moveBottomLeft16",onclick:function(){elementMoveBottom(this.parentNode.parentNode); self.calcSearch();}})
  417. ]),
  418. createElement("input",{type:"checkbox",value:s,checked:true,onchange:function(){self.calcSearch();}}),
  419. createElement("label",{textContent:s,title:WM.rulesManager.postParts[s]}),
  420. ]));
  421. }
  422. //draw the remaining items in their normal order
  423. for (var m=0; m<WM.grabber.methods.length; m++){
  424. var s = WM.grabber.methods[m];
  425. //prevent duplicates
  426. if (self.search.inArray(s)) continue;
  427. ret.push(createElement("div",{className:"line"},[
  428. createElement("div",{className:"littleButton oddGreen", title:"Move Up"},[
  429. createElement("img",{className:"resourceIcon nomargin arrowUp16",onclick:function(){elementMoveUp(this.parentNode.parentNode); self.calcSearch();}})
  430. ]),
  431. createElement("div",{className:"littleButton oddOrange", title:"Move Down"},[
  432. createElement("img",{className:"resourceIcon nomargin arrowDown16",onclick:function(){elementMoveDown(this.parentNode.parentNode); self.calcSearch();}})
  433. ]),
  434. createElement("div",{className:"littleButton oddGreen", title:"Move To Top"},[
  435. createElement("img",{className:"resourceIcon nomargin moveTopLeft16",onclick:function(){elementMoveTop(this.parentNode.parentNode); self.calcSearch();}})
  436. ]),
  437. createElement("div",{className:"littleButton oddOrange", title:"Move To Bottom"},[
  438. createElement("img",{className:"resourceIcon nomargin moveBottomLeft16",onclick:function(){elementMoveBottom(this.parentNode.parentNode); self.calcSearch();}})
  439. ]),
  440. createElement("input",{type:"checkbox",value:s,onchange:function(){self.calcSearch();}}),
  441. createElement("label",{textContent:s,title:WM.rulesManager.postParts[s]}),
  442. ]));
  443. }
  444. return ret;
  445. })()),
  446. ]),
  447. //find mode
  448. createElement("div",{className:"line"},[
  449. createElement("label",{textContent:"Find Mode:",title:"Choose the mode you will use to find text."}),
  450. this.findModeNode=createElement("select",{onchange:function(){self.findMode=this.value;}},[
  451. createElement("option",{selected:(this.findMode=="basic"),value:"basic",textContent:"Basic",title:"Search for a list of words or phrases."}),
  452. createElement("option",{selected:(this.findMode=="subnumrange"),value:"subnumrange",textContent:"Number Range",title:"Search for a range of numbers using an insertion point '{%1}' in your find parameter."}),
  453. createElement("option",{selected:(this.findMode=="subtests"),value:"subtests",textContent:"Sub Tests",title:"Search for a list of words or phrases using an insertion point '{%1}' in your find parameter."}),
  454. createElement("option",{selected:(this.findMode=="regex"),value:"regex",textContent:"Registered Expression",title:"Search for complex phrases using a regular expression."})
  455. ]),
  456. ]),
  457. //find list
  458. createElement("div",{className:"line"},[
  459. createElement("label",{textContent:"Find:",title:"One per line (basic mode), or a single regular expression. First match is used, so mind the order."}),
  460. createElement("div",{className:"subsection"},[
  461. this.findNode=createElement("textarea",{className:"fit",textContent:((this.findMode=="basic")?this.findArray.join("\n"):this.find), onchange:function(){
  462. if (self.findMode=="basic") self.findArray=this.value.split("\n");
  463. else self.find=this.value;
  464. WM.grabber.save();
  465. }}),
  466. ])
  467. ]),
  468. //subtests list
  469. this.subTestsBoxNode=createElement("div",{className:("line").toggleWordB(this.findMode!="subtests","hidden")},[
  470. createElement("label",{textContent:"Subtest Texts:",title:"Provide text replacements for the insertion point. No regular expressions."}),
  471. createElement("div",{className:"subsection"},[
  472. this.subTestsNode=createElement("textarea",{className:"fit",textContent:((isArray(this.subTests)?this.subTests.join("\n"):"")||""), onchange:function(){self.subTests=this.value.split("\n"); WM.grabber.save();}}),
  473. ])
  474. ]),
  475. //subnumrange picker
  476. this.subNumRangeBoxNode=createElement("div",{className:("line").toggleWordB(this.findMode!="subnumrange","hidden")},[
  477. createElement("label",{textContent:"Subtest Number Range:",title:"Provide a start and end range for the insertion point."}),
  478. this.subNumRangeLowNode=createElement("input",{value:this.subNumRange.low||0, onchange:function(){self.subNumRange.low=this.value; WM.grabber.save();}}),
  479. this.subNumRangeHighNode=createElement("input",{value:this.subNumRange.high||0, onchange:function(){self.subNumRange.high=this.value; WM.grabber.save();}}),
  480. ]),
  481. //kids subbox
  482. createElement("div",{className:"line"},[
  483. createElement("label",{textContent:"Child Tests:",title:"Child tests are nested tests which are applied to matching posts at the same time the parent test is applied. Child rules can have different return values that override the parent return value."}),
  484. createElement("div",{className:"littleButton oddGreen",onclick:function(){self.addChild();},title:"Add Child"},[
  485. createElement("img",{className:"resourceIcon plus"+WM.opts.littleButtonSize}),
  486. ]),
  487. this.kidsNode=createElement("div",{className:"subsection"}),
  488. ]),
  489. ]),
  490. ])
  491. );}catch(e){log("WM.Test.init.drawTest: "+e);}
  492. //populate my bonus list
  493. this.populateAppList();
  494. this.populateBonusList();
  495.  
  496. //list the kids for this test
  497. if (isArrayAndNotEmpty(params.kids)) for (var i=0,kid; (kid=params.kids[i]); i++) {
  498. this.addChild(kid);
  499. }
  500. return self;
  501. }catch(e){log("WM.Test.init: ")+e}};
  502.  
  503.  
  504. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址