How to use nowText method in mountebank

Best JavaScript code snippet using mountebank

MakeProject.js

Source:MakeProject.js Github

copy

Full Screen

1$("#TextBoxView").hide();2/* 3 *4 * |------------------------------------------------------------------------5 * | [JS] [C3] X的圖表設定6 * |------------------------------------------------------------------------7 * | Name : chartX8 * | About : 設定X的圖表9 * | UpDate : 2018.04.1410 * | Writer : Lian012311 *12 */ 13var chartX = c3.generate({14 bindto: "#C3ViewX",15 data: {16 x: 'x',17 colors:{18 X:"#86C166"19 },20 columns: [21 ["x",-5,-4,-3,-2,-1,0,1,2,3,4,5],22 ["X",0,0,0,0,0,0,0,0,0,0,0]23 ],24 type: 'bar'25 },26 bar: {27 width: {28 ratio: 0.529 }30 },31 axis:{32 x: {33 tick: {34 format: '%d',35 }36 }37 }38});39/* 40 *41 * |------------------------------------------------------------------------42 * | [JS] [C3] H的圖表設定43 * |------------------------------------------------------------------------44 * | Name : chartH45 * | About : 設定H的圖表46 * | UpDate : 2018.04.1447 * | Writer : Lian012348 *49 */ 50var chartH = c3.generate({51 bindto: "#C3ViewH",52 data: {53 x: 'x',54 colors:{55 H:"#00AA90"56 },57 columns: [58 ["x",-5,-4,-3,-2,-1,0,1,2,3,4,5],59 ["H",0,0,0,0,0,0,0,0,0,0,0]60 ],61 type: 'bar'62 },63 bar: {64 width: {65 ratio: 0.566 }67 },68 axis:{69 x: {70 tick: {71 format: '%d',72 }73 }74 }75});76/* 77 *78 * |------------------------------------------------------------------------79 * | [JS] [C3] Y的圖表設定80 * |------------------------------------------------------------------------81 * | Name : chartY82 * | About : 設定Y的圖表83 * | UpDate : 2018.04.1484 * | Writer : Lian012385 *86 */ 87var chartY = c3.generate({88 bindto: "#C3ViewY",89 data: {90 x: 'x',91 colors:{92 H:"#555555"93 },94 columns: [95 ["x",-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9.10,11],96 ["Y",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]97 ],98 type: 'bar'99 },100 bar: {101 width: {102 ratio: 0.5103 }104 },105 axis:{106 x: {107 tick: {108 format: '%d',109 }110 }111 }112});113/* 114 *115 * |------------------------------------------------------------------------116 * | [JS] [Vue] 模擬終端機的Vue模組117 * |------------------------------------------------------------------------118 * | Name : Terminal119 * | About : 模擬終端機的Vue模組120 * | UpDate : 2018.04.14121 * | Writer : Lian0123122 *123 */ 124var Terminal = new Vue({125 el:"#Terminal",126 data:{127 TerminalText : ["","[請輸入操作指令] 預設X與H位於-5~+5",] , //模擬終端的內容128 TerminalCounter : 1 , //終端行數計數129 NowText : " >" , //現在輸入指令的內容130 },131 methods:{132 /*讀取每次程式的輸入指令*/133 ReadText:function ReadText(event){134 if (event.keyCode == 13) {135 if(Terminal.NowText.trim()[0]=='>'||Terminal.NowText.trim()[0]=='#'){136 if(Terminal.NowText.trim()[0]=='>'){137 var Str = Terminal.NowText.trim().slice(1,Terminal.NowText.length).toUpperCase().trim();138 if(Str.search("HELP")==0&&Str.length==4){139 Terminal.TerminalText.push(Terminal.NowText);140 $("#TextBoxView").show();141 }else if(Str.search("CLEAR")==0&&Str.length==5){142 Terminal.TerminalText = [];143 Terminal.TerminalText.push(" ");144 Terminal.TerminalText.push("[請輸入操作指令]");145 Terminal.TerminalCounter=1;146 }else if(Str.search("SET")==0){147 Str = Str.slice(Str.search("SET")+3,Terminal.NowText.length).trim();148 if (Str.search("X") == 0) {149 Str = Str.slice(1,Terminal.NowText.length).trim();150 if (Str.search("=") == 0){151 Str = Str.slice(1,Terminal.NowText.length).trim();152 if(Str!=""){153 if(!isNaN(Number(Str))){154 if(Number(Str)>4){155 ConvolutionX.DotID=Number(Str);156 Terminal.TerminalText.push(Terminal.NowText);157 }else{158 ConvolutionX.DotID=5;159 Terminal.TerminalText.push("[參數需大於等於5 自動修正] SET X = 5");160 }161 ConvolutionX.XSet();162 ConvolutionX.GUI();163 }else{164 Terminal.TerminalText.push("[Error25 賦予值的語意錯誤] " + Terminal.NowText);165 }166 }else{167 Terminal.TerminalText.push("[Error24 未指派數值] " + Terminal.NowText);168 }169 }else{170 Terminal.TerminalText.push("[Error23 未指派運算子] " + Terminal.NowText);171 }172 }else if(Str.search('H') == 0){173 Str = Str.slice(1,Terminal.NowText.length).trim();174 if (Str.search("=") == 0){175 Str = Str.slice(1,Terminal.NowText.length).trim();176 if(Str!=""){177 if(!isNaN(Number(Str))){178 if(Number(Str)>4){179 ConvolutionH.DotID=Number(Str);180 Terminal.TerminalText.push(Terminal.NowText);181 }else{182 ConvolutionH.DotID=5;183 Terminal.TerminalText.push("[參數需大於等於5 自動修正] SET H = 5");184 }185 ConvolutionH.HSet();186 ConvolutionH.GUI();187 }else{188 Terminal.TerminalText.push("[Error25 賦予值的語意錯誤] " + Terminal.NowText);189 }190 }else{191 Terminal.TerminalText.push("[Error24 未指派數值] " + Terminal.NowText);192 }193 }else{194 Terminal.TerminalText.push("[Error23 未指派運算子] " + Terminal.NowText);195 }196 }else if(Str.search("ALL") == 0){197 Str = Str.slice(3,Terminal.NowText.length).trim();198 if (Str.search("=") == 0){199 Str = Str.slice(1,Terminal.NowText.length).trim();200 if(Str!=""){201 if(!isNaN(Number(Str))){202 if(Number(Str)>4){203 ConvolutionX.DotID=Number(Str);204 ConvolutionH.DotID=Number(Str);205 Terminal.TerminalText.push(Terminal.NowText);206 }else{207 ConvolutionX.DotID=Number(Str);208 ConvolutionH.DotID=Number(Str);209 Terminal.TerminalText.push("[參數需大於等於5 自動修正] SET ALL = 5");210 }211 ConvolutionX.XSet();212 ConvolutionH.HSet();213 ConvolutionX.GUI();214 ConvolutionH.GUI();215 }else{216 Terminal.TerminalText.push("[Error25 賦予值的語意錯誤] " + Terminal.NowText);217 }218 }else{219 Terminal.TerminalText.push("[Error24 未指派數值] " + Terminal.NowText);220 }221 }else{222 Terminal.TerminalText.push("[Error23 未指派運算子] " + Terminal.NowText);223 }224 }else{225 Terminal.TerminalText.push("[Error22 參數錯誤] " + Terminal.NowText);226 }227 }else if(Str.search("LET")==0){228 Str = Str.slice(Str.search("LET")+3,Terminal.NowText.length).trim();229 if (Str.search("X") == 0) {230 Str = Str.slice(1,Terminal.NowText.length).trim();231 if(Str.search("<") == 0){232 Str = Str.slice(1,Terminal.NowText.length).trim();233 if(Str.search(">")!=-1){234 var AID= Number(Str.slice(0,Str.search(">")).trim());235 Str = Str.slice(Str.search(">")+1,Terminal.NowText.length).trim()236 if (Str.search("=") == 0){237 Str = Str.slice(1,Terminal.NowText.length).trim();238 if(Str!=""){239 if(!isNaN(Number(Str))&&!isNaN(Number(AID))){240 if(Number(AID)<=ConvolutionX.DotID && Number(AID)>=-ConvolutionX.DotID){241 if(ConvolutionX.DotArray[0]==undefined){242 ConvolutionX.XSet();243 }244 ConvolutionX.DotArray[AID] = Number(Str);245 ConvolutionX.GUI();246 Terminal.TerminalText.push(Terminal.NowText);247 }else{248 Terminal.TerminalText.push("[Error28 存取範圍錯誤] " + Terminal.NowText);249 }250 }else{251 Terminal.TerminalText.push("[Error22 參數錯誤] " + Terminal.NowText);252 }253 }else{254 Terminal.TerminalText.push("[Error24 未指派數值] " + Terminal.NowText);255 }256 }else{257 Terminal.TerminalText.push("[Error23 未指派運算子] " + Terminal.NowText);258 }259 }else{260 Terminal.TerminalText.push("[Error27 陣列語法錯誤] " + Terminal.NowText);261 }262 }else{263 Terminal.TerminalText.push("[Error26 未位指派操作陣列] " + Terminal.NowText);264 }265 }else if(Str.search('H') == 0){266 Str = Str.slice(1,Terminal.NowText.length).trim();267 if(Str.search("<") == 0){268 Str = Str.slice(1,Terminal.NowText.length).trim();269 if(Str.search(">")!=-1){270 var AID= Number(Str.slice(0,Str.search(">")).trim());271 Str = Str.slice(Str.search(">")+1,Terminal.NowText.length).trim()272 if (Str.search("=") == 0){273 Str = Str.slice(1,Terminal.NowText.length).trim();274 if(Str!=""){275 if(!isNaN(Number(Str))&&!isNaN(Number(AID))){276 if(Number(AID)<=ConvolutionH.DotID && Number(AID)>=-ConvolutionH.DotID){277 if(ConvolutionH.DotArray[0]==undefined){278 ConvolutionH.HSet();279 }280 ConvolutionH.DotArray[AID] = Number(Str);281 ConvolutionH.GUI();282 Terminal.TerminalText.push(Terminal.NowText);283 }else{284 Terminal.TerminalText.push("[Error28 存取範圍錯誤] " + Terminal.NowText);285 }286 }else{287 Terminal.TerminalText.push("[Error22 參數錯誤] " + Terminal.NowText);288 }289 }else{290 Terminal.TerminalText.push("[Error24 未指派數值] " + Terminal.NowText);291 }292 }else{293 Terminal.TerminalText.push("[Error23 未指派運算子] " + Terminal.NowText);294 }295 }else{296 Terminal.TerminalText.push("[Error27 陣列語法錯誤] " + Terminal.NowText);297 }298 }else{299 Terminal.TerminalText.push("[Error26 未位指派操作陣列] " + Terminal.NowText);300 }301 }else if(Str.search("ALL") == 0){302 Str = Str.slice(3,Terminal.NowText.length).trim();303 if(Str.search("<") == 0){304 Str = Str.slice(1,Terminal.NowText.length).trim();305 if(Str.search(">")!=-1){306 var AID= Number(Str.slice(0,Str.search(">")).trim());307 Str = Str.slice(Str.search(">")+1,Terminal.NowText.length).trim()308 if (Str.search("=") == 0){309 Str = Str.slice(1,Terminal.NowText.length).trim();310 if(Str!=""){311 if(!isNaN(Number(Str))&&!isNaN(Number(AID))){312 if(Number(AID)<=ConvolutionX.DotID && Number(AID)>=-ConvolutionX.DotID && Number(AID)<=ConvolutionH.DotID && Number(AID)>=-ConvolutionH.DotID){313 if(ConvolutionX.DotArray[0]==undefined){314 ConvolutionX.XSet();315 }316 if(ConvolutionH.DotArray[0]==undefined){317 ConvolutionH.HSet();318 }319 ConvolutionX.DotArray[AID] = Number(Str);320 ConvolutionH.DotArray[AID] = Number(Str);321 ConvolutionX.GUI();322 ConvolutionH.GUI();323 Terminal.TerminalText.push(Terminal.NowText);324 }else{325 Terminal.TerminalText.push("[Error28 存取範圍錯誤] " + Terminal.NowText);326 }327 }else{328 Terminal.TerminalText.push("[Error22 參數錯誤] " + Terminal.NowText);329 }330 }else{331 Terminal.TerminalText.push("[Error24 未指派數值] " + Terminal.NowText);332 }333 }else{334 Terminal.TerminalText.push("[Error23 未指派運算子] " + Terminal.NowText);335 }336 }else{337 Terminal.TerminalText.push("[Error27 陣列語法錯誤] " + Terminal.NowText);338 }339 }else{340 Terminal.TerminalText.push("[Error26 未位指派操作陣列] " + Terminal.NowText);341 }342 }else{343 Terminal.TerminalText.push("[Error22 參數錯誤] " + Terminal.NowText);344 }345 }else if(Str.search("OPEN")==0){346 Str = Str.slice(Str.search("OPEN")+4,Terminal.NowText.length).trim();347 if(Str.search("X") == 0 && Str.length==1) {348 Terminal.TerminalText.push(Terminal.NowText);349 ConvolutionX.Show();350 }else if(Str.search("H") == 0 && Str.length==1) {351 Terminal.TerminalText.push(Terminal.NowText);352 ConvolutionH.Show();353 }else if(Str.search("Y") == 0 && Str.length==1) {354 Terminal.TerminalText.push(Terminal.NowText);355 ConvolutionY.Show();356 }else if (Str.search("ALL") == 0 && Str.length==3) {357 Terminal.TerminalText.push(Terminal.NowText);358 ConvolutionX.Show();359 ConvolutionH.Show();360 ConvolutionY.Show();361 }else{362 Terminal.TerminalText.push("[Error22 參數錯誤] " + Terminal.NowText);363 }364 }else if(Str.search("CLOSE")==0){365 Str = Str.slice(Str.search("CLOSE")+5,Terminal.NowText.length).trim();366 if(Str.search("X") == 0 && Str.length==1) {367 Terminal.TerminalText.push(Terminal.NowText);368 ConvolutionX.Hidden();369 }else if(Str.search("H") == 0 && Str.length==1) {370 Terminal.TerminalText.push(Terminal.NowText);371 ConvolutionH.Hidden();372 }else if(Str.search("Y") == 0 && Str.length==1) {373 Terminal.TerminalText.push(Terminal.NowText);374 ConvolutionY.Hidden();375 }else if (Str.search("ALL") == 0 && Str.length==3) {376 Terminal.TerminalText.push(Terminal.NowText);377 ConvolutionX.Hidden();378 ConvolutionH.Hidden();379 ConvolutionY.Hidden();380 }else{381 Terminal.TerminalText.push("[Error22 參數錯誤] " + Terminal.NowText);382 }383 }else if(Str.search("RESET")==0){384 Str = Str.slice(Str.search("RESET")+5,Terminal.NowText.length).trim();385 if(Str.search("X") == 0 && Str.length==1) {386 Terminal.TerminalText.push(Terminal.NowText);387 ConvolutionX.ColorX = "#86C166";388 ConvolutionX.DotID=5;389 ConvolutionX.XSet();390 ConvolutionX.GUI();391 }else if(Str.search("H") == 0 && Str.length==1) {392 Terminal.TerminalText.push(Terminal.NowText);393 ConvolutionH.ColorH = "#00AA90";394 ConvolutionH.DotID=5;395 ConvolutionH.HSet();396 ConvolutionH.GUI();397 }else if (Str.search("Y") == 0 && Str.length==1) {398 Terminal.TerminalText.push(Terminal.NowText);399 ConvolutionY.ColorY = "#555555";400 ConvolutionY.GUI();401 }else if (Str.search("ALL") == 0 && Str.length==3) {402 Terminal.TerminalText.push(Terminal.NowText);403 ConvolutionX.ColorX = "#86C166";404 ConvolutionX.DotID=5;405 ConvolutionX.XSet();406 ConvolutionX.GUI();407 ConvolutionH.DotID=5;408 ConvolutionH.ColorH = "#00AA90";409 ConvolutionH.HSet();410 ConvolutionH.GUI();411 ConvolutionY.ColorY = "#555555";412 ConvolutionY.GUI();413 }else{414 Terminal.TerminalText.push("[Error22 參數錯誤] " + Terminal.NowText);415 }416 }else if(Str.search("COLOR")==0){417 Str = Str.slice(Str.search("COLOR")+5,Terminal.NowText.length).trim();418 if(Str.search("X") == 0) {419 Str = Str.slice(1,Str.length).trim();420 if(Str.search("#") == 0 && Str.length==7 && Str.search("[G-Z]") == -1){421 Str = Str.slice(1,Str.length).trim();422 ConvolutionX.ColorX = Str;423 ConvolutionX.GUI();424 Terminal.TerminalText.push(Terminal.NowText);425 }else{426 Terminal.TerminalText.push("[Error30 色彩參數錯誤] " + Terminal.NowText);427 }428 }else if(Str.search("H") == 0) {429 Str = Str.slice(1,Str.length).trim();430 if(Str.search("#") == 0 &&Str.length==7 && Str.search("[G-Z]") == -1){431 Str = Str.slice(1,Str.length).trim();432 ConvolutionH.ColorH = Str;433 ConvolutionH.GUI();434 Terminal.TerminalText.push(Terminal.NowText);435 }else{436 Terminal.TerminalText.push("[Error30 色彩參數錯誤] " + Terminal.NowText);437 }438 }else if(Str.search("Y") == 0) {439 Str = Str.slice(1,Str.length).trim();440 if(Str.search("#") == 0 &&Str.length==7 && Str.search("[G-Z]") == -1){441 Str = Str.slice(1,Str.length).trim();442 ConvolutionY.ColorY = Str;443 ConvolutionY.GUI();444 Terminal.TerminalText.push(Terminal.NowText);445 }else{446 Terminal.TerminalText.push("[Error30 色彩參數錯誤] " + Terminal.NowText);447 }448 }else if (Str.search("ALL") == 0) {449 Str = Str.slice(3,Str.length).trim();450 if(Str.search("#") == 0 &&Str.length==7){451 Str = Str.slice(1,Str.length).trim();452 ConvolutionX.ColorX = Str;453 ConvolutionX.GUI();454 ConvolutionH.ColorH = Str;455 ConvolutionH.GUI();456 ConvolutionY.ColorY = Str;457 ConvolutionY.GUI();458 Terminal.TerminalText.push(Terminal.NowText);459 }else{460 Terminal.TerminalText.push("[Error30 色彩參數錯誤] " + Terminal.NowText);461 }462 }else{463 Terminal.TerminalText.push("[Error22 參數錯誤] " + Terminal.NowText);464 }465 }else if(Str.search("X")!=-1){466 if(Str.trim().search("X") == 0 && Str.length==1) {467 var ValueX = "ValueX: "468 if(ConvolutionX.DotArray[0]==undefined){469 ConvolutionX.XSet();470 }471 for (let j = -ConvolutionX.DotID; j <= ConvolutionX.DotID; j++) {472 ValueX += ConvolutionX.DotArray[j];473 if(j!=ConvolutionX.DotID){474 ValueX += ","475 }476 }477 ValueX += " | From "+ (-ConvolutionX.DotID) +" ~ " + ConvolutionX.DotID ;478 Terminal.TerminalText.push(Terminal.NowText);479 Terminal.TerminalText.push(ValueX);480 Terminal.TerminalCounter++;481 }else{482 Terminal.TerminalText.push("[Error21 錯誤指令] " + Terminal.NowText);483 }484 }else if(Str.search("H")!=-1){485 if(Str.trim().search("H") == 0 && Str.length==1) {486 var ValueH = "ValueH: "487 if(ConvolutionH.DotArray[0]==undefined){488 ConvolutionH.HSet();489 }490 for (let j = -ConvolutionH.DotID; j <= ConvolutionH.DotID; j++) {491 ValueH += ConvolutionH.DotArray[j];492 if(j!=ConvolutionH.DotID){493 ValueH += ","494 }495 }496 ValueH += " | From "+ (-ConvolutionH.DotID) +" ~ " + ConvolutionH.DotID ;497 Terminal.TerminalText.push(Terminal.NowText);498 Terminal.TerminalText.push(ValueH);499 Terminal.TerminalCounter++;500 }else{501 Terminal.TerminalText.push("[Error21 錯誤指令] " + Terminal.NowText);502 }503 }else if(Str.search("Y")!=-1){504 if(Str.trim().search("Y") == 0 && Str.length==1) {505 var ValueY = "ValueY: "506 Terminal.TerminalText.push(Terminal.NowText);507 if(ConvolutionY.DotArray[0]==undefined){508 Terminal.TerminalText.push("ValueY: [Error29 使用尚未被定義Y] ");509 }else{510 for (let j = -ConvolutionY.DotID; j <= ConvolutionY.DotID; j++) {511 ValueY += ConvolutionY.DotArray[j];512 if(j!=ConvolutionY.DotID){513 ValueY += ","514 }515 }516 ValueY += " | From "+ (-ConvolutionY.DotID) +" ~ " + ConvolutionY.DotID ;517 Terminal.TerminalText.push(ValueY);518 }519 Terminal.TerminalCounter++;520 }else{521 Terminal.TerminalText.push("[Error21 錯誤指令] " + Terminal.NowText);522 }523 }else if(Str.search("ALL")!=-1){524 if(Str.trim().search("ALL") == 0 && Str.length==3) {525 var ValueX = "ValueX: ";526 var ValueH = "ValueH: ";527 var ValueY = "ValueY: ";528 if(ConvolutionX.DotArray[0]==undefined){529 ConvolutionX.XSet();530 }531 if(ConvolutionH.DotArray[0]==undefined){532 ConvolutionH.HSet();533 }534 for (let j = -ConvolutionX.DotID; j <= ConvolutionX.DotID; j++) {535 ValueX += ConvolutionX.DotArray[j];536 if(j!=ConvolutionX.DotID){537 ValueX += ",";538 }539 }540 ValueX += " | From "+ (-ConvolutionX.DotID) +" ~ " + ConvolutionX.DotID ;541 542 for (let j = -ConvolutionH.DotID; j <= ConvolutionH.DotID; j++) {543 ValueH += ConvolutionH.DotArray[j];544 if(j!=ConvolutionH.DotID){545 ValueH += ",";546 }547 }548 ValueH += " | From "+ (-ConvolutionH.DotID) +" ~ " + ConvolutionH.DotID ;549 Terminal.TerminalText.push(Terminal.NowText);550 Terminal.TerminalText.push(ValueX);551 Terminal.TerminalText.push(ValueH);552 if(ConvolutionY.DotArray[0]==undefined){553 Terminal.TerminalText.push("ValueY: [Error29 使用尚未被定義Y] ");554 }else{555 for (let j = -ConvolutionY.DotID; j <= ConvolutionY.DotID; j++) {556 ValueY += ConvolutionY.DotArray[j];557 if(j!=ConvolutionY.DotID){558 ValueY += ",";559 }560 }561 ValueY += " | From "+ (-ConvolutionY.DotID) +" ~ " + ConvolutionY.DotID ;562 Terminal.TerminalText.push(ValueY);563 }564 Terminal.TerminalCounter+=3;565 }else{566 Terminal.TerminalText.push("[Error21 錯誤指令] " + Terminal.NowText);567 }568 }else if(Str.search("START")==0&&Str.length==5){569 Terminal.TerminalText.push(Terminal.NowText);570 ConvolutionY.Count();571 ConvolutionY.GUI();572 //SHOW573 }else{574 Terminal.TerminalText.push("[Error21 錯誤指令] " + Terminal.NowText);575 }576 }577 if(Terminal.NowText.trim()[0]=='#'){578 Terminal.TerminalText.push(Terminal.NowText);579 }580 }else{581 Terminal.TerminalText.push("[Error21 錯誤指令] " + Terminal.NowText);582 }583 while(Terminal.TerminalCounter>11){584 Terminal.TerminalText.shift();585 Terminal.TerminalCounter--;586 }587 588 Terminal.TerminalCounter++;589 Terminal.NowText = " >";590 }591 },592 /*將其輸出為檔案*/593 OutPutFile:function OutPutFile() {594 var NowDate = new Date();595 var NowTime = "" + NowDate.getFullYear() + '-' + (NowDate.getMonth()+1) + '-' + NowDate.getDate() + '-' + NowDate.getHours() + '-' + NowDate.getMinutes() + '-' + NowDate.getSeconds();596 var MainValueX = "";597 var MainValueH = "";598 599 if(ConvolutionX.DotArray[0]==undefined){600 ConvolutionX.XSet();601 }602 if(ConvolutionH.DotArray[0]==undefined){603 ConvolutionH.HSet();604 }605 for (let s = -ConvolutionX.DotID; s <= ConvolutionX.DotID; s++) {606 MainValueX += "" + ConvolutionX.DotArray[s];607 if(s!=ConvolutionX.DotID){608 MainValueX +=",";609 }610 }611 for (let t = -ConvolutionH.DotID; t <= ConvolutionH.DotID; t++) {612 MainValueH += "" + ConvolutionH.DotArray[t];613 if(t!=ConvolutionH.DotID){614 MainValueH +=",";615 } 616 }617 fs.writeFile(__dirname + '/../../file/' + NowTime + '.sscm', 618 "@ProjectName: " + NowTime + ".sscm" + "\r\n" +619 "@Who: CM" + "\r\n" +620 "@MakeTime: " + NowDate.getFullYear() + "-" + (NowDate.getMonth()+1) + "-" + NowDate.getDate() + "\r\n" +621 "@UpdateTime: " + NowDate.getFullYear() + "-" + (NowDate.getMonth()+1) + "-" + NowDate.getDate() + "\r\n" +622 "\r\n" +623 "** 程式主體 **" + "\r\n" +624 "\r\n" +625 "#InX: " + ConvolutionX.DotID + "\r\n" +626 "#InH: " + ConvolutionH.DotID + "\r\n" +627 "ValueX: " + MainValueX + "\r\n" + "\r\n" +628 "ValueH: " + MainValueH + "\r\n" 629 , (error) => {630 if (error) throw error;631 });632 alert("已輸出結束");633 }634 },635});636/* 637 *638 * |------------------------------------------------------------------------639 * | [JS] [Vue] X的資料與圖表操作640 * |------------------------------------------------------------------------641 * | Name : ConvolutionX642 * | About : X的資料與圖表操作643 * | UpDate : 2018.04.14644 * | Writer : Lian0123645 *646 */ 647var ConvolutionX = new Vue({648 el:"#ConvolutionX",649 data:{650 SumDot : 11 , //開始的初始值(為abs(MaxDotID)+abs(MinDotID)+1)651 DotID : 5 , //至少要-5~+5652 SelectDot : 0 , //紀錄目前游標移動到的ID653 DotArray : [] , //各點上存的值654 ColorX : "#86C166" , //X的色彩655 },656 methods:{657 /*初始化X陣列的內容空間*/658 XSet : function XSet() { 659 this.DotArray = [];660 for (let i = -this.DotID; i <= this.DotID; i++) {661 this.DotArray[i] = 0;662 }663 },664 /*隱藏ConvolutionX的內容*/665 Hidden: function Hidden() {666 $("#ConvolutionX").hide();667 },668 /*顯示ConvolutionX的內容*/669 Show: function Show() {670 $("#ConvolutionX").show();671 },672 /*建立ConvolutionX的GUI*/673 GUI:function GUI() {674 var test = false;675 var OutDotX = ["x"];676 var OutDotY = ["X"];677 for(var m = -ConvolutionX.DotID;m<=ConvolutionX.DotID;m++){678 OutDotX.push(m);679 OutDotY.push(ConvolutionX.DotArray[m]);680 }681 test=true;682 if(test){683 test =false;684 /* c3.js設定 */685 var chartX = c3.generate({686 bindto: "#C3ViewX",687 data: {688 x: 'x',689 colors:{690 X:ConvolutionX.ColorX691 },692 columns: [693 OutDotX,694 OutDotY695 ],696 type: 'bar'697 },698 bar: {699 width: {700 ratio: 0.5701 }702 },703 axis:{704 x: {705 tick: {706 format: '%d',707 }708 }709 }710 });711 }712 },713 },714});715/* 716 *717 * |------------------------------------------------------------------------718 * | [JS] [Vue] H的資料與圖表操作719 * |------------------------------------------------------------------------720 * | Name : ConvolutionH721 * | About : H的資料與圖表操作722 * | UpDate : 2018.04.14723 * | Writer : Lian0123724 *725 */ 726var ConvolutionH = new Vue({727 el:"#ConvolutionH",728 data:{729 SumDot : 11 , //開始的初始值(為abs(MaxDotID)+abs(MinDotID)+1)730 DotID : 5 , //至少要-5~+5731 SelectDot : 0 , //紀錄目前游標移動到的ID732 DotArray : [] , //各點上存的值733 ColorH : "#00AA90" , //H的色彩734 },735 methods:{736 /*初始化H陣列的內容空間*/737 HSet : function HSet() { 738 this.DotArray = [];739 for (let i = -this.DotID; i <= this.DotID; i++) {740 this.DotArray[i] = 0;741 }742 },743 /*隱藏ConvolutionH的內容*/744 Hidden: function Hidden() {745 $("#ConvolutionH").hide();746 },747 /*顯示ConvolutionH的內容*/748 Show: function Show() {749 $("#ConvolutionH").show();750 },751 /*建立ConvolutionH的GUI*/752 GUI:function GUI() {753 var test = false;754 var OutDotX = ["x"];755 var OutDotY = ["H"];756 for(var m = -ConvolutionH.DotID;m<=ConvolutionH.DotID;m++){757 OutDotX.push(m);758 OutDotY.push(ConvolutionH.DotArray[m]);759 }760 test=true;761 if(test){762 test =false;763 /* c3.js設定 */764 var chartH = c3.generate({765 bindto: "#C3ViewH",766 data: {767 x: 'x',768 colors:{769 H:ConvolutionH.ColorH770 },771 columns: [772 OutDotX,773 OutDotY774 ],775 type: 'bar'776 },777 bar: {778 width: {779 ratio: 0.5780 }781 },782 axis:{783 x: {784 tick: {785 format: '%d',786 }787 }788 }789 });790 }791 },792 }793});794/* 795 *796 * |------------------------------------------------------------------------797 * | [JS] [Vue] Y的資料與圖表操作798 * |------------------------------------------------------------------------799 * | Name : ConvolutionY800 * | About : Y的資料與圖表操作801 * | UpDate : 2018.04.14802 * | Writer : Lian0123803 *804 */ 805var ConvolutionY = new Vue({806 el:"#ConvolutionY",807 data:{808 SumDot : 21 , //開始的初始值(為abs(MaxDotID)+abs(MinDotID)+1)809 DotID : 10 , //至少要-10~+10810 SelectDot : 0 , //紀錄目前游標移動到的ID811 ColorY : "#555555" , //Y的色彩812 DotArray : [] , //各點上存的值813 },814 methods:{815 /*隱藏ConvolutionY的內容*/816 Hidden: function Hidden() {817 $("#ConvolutionY").hide();818 },819 /*顯示ConvolutionY的內容*/820 Show: function Show() {821 $("#ConvolutionY").show();822 },823 /*計算Y的結果*/824 Count:function Count(ID) { 825 ConvolutionY.DotArray = [];826 ConvolutionY.DotID=ConvolutionX.DotID+ConvolutionH.DotID+1;827 for (let i = -ConvolutionY.DotID; i <= ConvolutionY.DotID; i++) {828 ConvolutionY.DotArray[i] = 0;829 }830 for(let n=-ConvolutionY.DotID;n<=ConvolutionY.DotID;n++){831 for(let k=-ConvolutionY.DotID;k<=ConvolutionY.DotID;k++){832 if(!isNaN(ConvolutionH.DotArray[n-k])&&!isNaN(ConvolutionX.DotArray[k]))833 ConvolutionY.DotArray[n]+=ConvolutionX.DotArray[k] * ConvolutionH.DotArray[n-k];834 }835 }836 },837 /*建立ConvolutionY的GUI*/838 GUI:function GUI() {839 var test = false;840 var OutDotX = ["x"];841 var OutDotY = ["Y"];842 for(var m = -ConvolutionY.DotID;m<=ConvolutionY.DotID;m++){843 OutDotX.push(m);844 OutDotY.push(ConvolutionY.DotArray[m]);845 }846 test=true;847 if(test){848 test =false;849 /* c3.js設定 */850 var chartY = c3.generate({851 bindto: "#C3ViewY",852 data: {853 x: 'x',854 colors:{855 Y:ConvolutionY.ColorY856 },857 columns: [858 OutDotX,859 OutDotY860 ],861 type: 'bar'862 },863 bar: {864 width: {865 ratio: 0.5866 }867 },868 axis:{869 x: {870 tick: {871 format: '%d',872 }873 }874 }875 });876 }877 },878 GStart:function GStart() {879 ConvolutionY.Count();880 ConvolutionY.GUI();881 },882 },883});884/* 885 *886 * |------------------------------------------------------------------------887 * | [JS] [Vue] 說明內容的顯示888 * |------------------------------------------------------------------------889 * | ModelName : BlockList890 * | About : 說明內容的顯示(移植於AM)891 * | UpDate : 2018.02.19892 * | Writer : Lian0123893 * 894 */895var TextBoxView = new Vue({896 el: '#TextBoxView',897 methods:{898 TextBoxViewClose: function TextBoxViewClose() {899 $("#TextBoxView").hide();900 }901 }...

Full Screen

Full Screen

caseConvert.js

Source:caseConvert.js Github

copy

Full Screen

1function convertReset(){2 document.getElementById('beforeConverTextarea').value = '';3 document.getElementById('afterConverTextarea').value = '';4}5function convert(enter){6 let convertType = document.querySelector('input[name="convertType"]:checked').value;7 if(convertType == 'camel' || convertType == 'pascal'){8 camelOrPascalChange(enter, convertType);9 } else if(convertType == 'snake'){10 snakeChange(enter);11 } else if(convertType == 'kebab'){12 kebabChange(enter);13 }14}15function typeChange(){16 let convertType = document.querySelector('input[name="convertType"]:checked').value;17 if(convertType == 'camel'){18 document.getElementById('divTitle').innerHTML = '카멜 표기법';19 document.getElementById('divContent').innerHTML = '띄어쓰기, 언더바를 변환합니다. (ex: camel_var -> camelVar)';20 } else if(convertType == 'snake'){21 document.getElementById('divTitle').innerHTML = '스네이크 표기법';22 document.getElementById('divContent').innerHTML = '띄어쓰기를 변환합니다. (ex: snake var -> snake_var 혹은 SNAKE_VAR)';23 } else if(convertType == 'pascal'){24 document.getElementById('divTitle').innerHTML = '파스칼 표기법';25 document.getElementById('divContent').innerHTML = '띄어쓰기, 언더바를 변환합니다. (ex: pascal_var -> PascalVar)';26 } else if(convertType == 'kebab'){27 document.getElementById('divTitle').innerHTML = '케밥 표기법';28 document.getElementById('divContent').innerHTML = '띄어쓰기, 언더바를 변환합니다. (kebab_var -> kebab-var)';29 }30 if(convertType == 'snake'){31 document.getElementById('typeForm').style.display = 'block';32 } else {33 document.getElementById('typeForm').style.display = 'none';34 }35 convert(document.getElementById('beforeConverTextarea').value);36}37function camelOrPascalChange(enter, convertType){38 let enterTextLength = enter.length;39 let afterText = '';40 let beforeUnderbar = false;41 for(var i = 0; i < enterTextLength; i++){42 var beforeText = enter.substr(i - 1, 1);43 var nowText = enter.substr(i, 1);44 /* 파스칼은 앞글자를 대문자로 표기한다 */45 if(convertType == 'pascal'){46 if(i == 0 || beforeText == '\n'){47 nowText = nowText.toUpperCase();48 }49 }50 if(nowText == '_' || nowText == ' '){51 beforeUnderbar = true;52 continue;53 }54 if(beforeUnderbar == true){55 nowText = nowText.toUpperCase();56 beforeUnderbar = false;57 }58 afterText += nowText;59 }60 61 document.getElementById('afterConverTextarea').value = afterText;62}63function snakeChange(enter){64 /* 대소문자 구분 필요 */65 let enterTextLength = enter.length;66 let afterText = '';67 let caseType = document.querySelector('input[name="caseType"]:checked').value;68 for(var i = 0; i < enterTextLength; i++){69 var nowText = enter.substr(i, 1);70 if(nowText == ' '){71 nowText = '_';72 } else {73 if(caseType == 'enBig'){74 nowText = nowText.toUpperCase();75 } else{76 nowText = nowText.toLowerCase();77 }78 }79 afterText += nowText;80 }81 82 document.getElementById('afterConverTextarea').value = afterText;83}84function kebabChange(enter){85 let enterTextLength = enter.length;86 let afterText = '';87 for(var i = 0; i < enterTextLength; i++){88 var nowText = enter.substr(i, 1);89 if(nowText == '_' || nowText == ' '){90 nowText = '-';91 }92 afterText += nowText;93 }94 95 document.getElementById('afterConverTextarea').value = afterText;...

Full Screen

Full Screen

dxs.js

Source:dxs.js Github

copy

Full Screen

1// Componet/select/dselect/dxs.js2Component({3 /**4 * 组件的属性列表5 */6 properties: {7 propArray: {8 type: Array,9 },10 nowText: {11 type: String,12 value: ''13 }14 },15 /**16 * 组件的初始数据17 */18 data: {19 selectShow: false, //初始option不显示20 animationData: {}, //右边箭头的动画 21 },22 /**23 * 组件的方法列表24 */25 methods: {26 loadSelect:function(){ //初始化加载自定义事件27 this.selectToggle();28 this.setData({29 selectShow: false,30 nowText: '',31 propArray:[]32 })33 },34 //option的显示与否35 selectToggle: function () {36 var nowShow = this.data.selectShow; //获取当前option显示的状态37 //创建动画38 var animation = wx.createAnimation({39 timingFunction: "ease"40 })41 this.animation = animation;42 if (nowShow) {43 animation.rotate(0).step();44 this.setData({45 animationData: animation.export()46 })47 } else {48 animation.rotate(180).step();49 this.setData({50 animationData: animation.export()51 })52 }53 this.setData({54 selectShow: !nowShow55 })56 },57 //设置内容58 setText: function (e) {59 var nowData = this.properties.propArray; //当前option的数据是引入组件的页面传过来的,所以这里获取数据只有通过this.properties60 var nowIdx = e.target.dataset.index; //当前点击的索引61 var nowText = nowData[nowIdx].text; //当前点击的内容 62 //再次执行动画,注意这里一定,一定,一定是this.animation来使用动画63 this.animation.rotate(0).step();64 //确定已选是否 不存在65 var isY = true;66 nowText = nowText.replace(/√/g, '');67 let o = this.properties.nowText.split(',');68 o.forEach(str => {69 if (str === nowText) {70 isY = false71 }72 })73 if (isY) { //不在所选列表 --add74 let itxt = nowText + ',' + this.properties.nowText;75 if ((itxt.charAt(itxt.length - 1)) == ',') {76 itxt = itxt.substring(0, itxt.lastIndexOf(','));77 }78 this.properties.nowText = itxt;79 this.properties.propArray[nowIdx].text += "√"; //选中80 } else {81 let txt = this.properties.nowText;82 if (txt.indexOf(nowText) > -1) {83 let a = txt.split(',');84 a.forEach(item => {85 if (item == nowText) {86 a.splice(a.indexOf(item), 1);87 }88 });89 txt = a.join(',');90 }91 if ((txt.charAt(txt.length - 1)) == ',') {92 txt = txt.substring(0, txt.lastIndexOf(','));93 }94 this.properties.nowText = txt;95 this.properties.propArray[nowIdx].text = nowText; //取消选中96 }97 this.setData({98 nowText: this.properties.nowText,99 propArray: this.properties.propArray100 })101 this.triggerEvent('myget', {102 text: this.properties.nowText103 });104 },105 zdgb() {106 if (this.data.selectShow) {107 // this.setData({108 // selectShow: false,109 // })110 }111 },112 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var request = require('request');2var options = {3 json: {4 stubs: [{5 predicates: [{6 equals: {7 }8 }],9 responses: [{10 is: {11 headers: {12 },13 },14 _behaviors: {15 decorate: function (request, response) {16 response.body = response.body + 'Text';17 }18 }19 }]20 }]21 }22};23request(options, function (error, response, body) {24 if (!error && response.statusCode == 201) {25 console.log(body);26 }27});28var request = require('request');29var options = {30 json: {31 stubs: [{32 predicates: [{33 equals: {34 }35 }],36 responses: [{37 is: {38 headers: {39 },40 },41 _behaviors: {42 decorate: function (request, response) {43 response.body = response.body + 'Text';44 }45 }46 }]47 }]48 }49};50request(options, function (error, response, body) {51 if (!error && response.statusCode == 201) {52 console.log(body);53 }54});55var request = require('request');56var options = {57 json: {58 stubs: [{59 predicates: [{60 equals: {61 }62 }],63 responses: [{

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var imposters = {3 {4 {5 equals: {6 }7 }8 {9 is: {10 headers: {11 },12 }13 }14 }15};16mb.create(imposters).then(function (server) {17 console.log('server started');18});19var mb = require('mountebank');20var imposters = {21 {22 {23 equals: {24 }25 }26 {27 is: {28 headers: {29 },30 }31 }32 }33};34mb.create(imposters).then(function (server) {35 console.log('server started');36});37var mb = require('mountebank');38var imposters = {39 {40 {41 equals: {42 }43 }44 {45 is: {46 headers: {47 },48 }49 }50 }51};52mb.create(imposters).then(function (server) {53 console.log('server started');54});55var mb = require('mountebank');56var imposters = {57 {58 {59 equals: {

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var imposter = { port: 3000, protocol: 'http', stubs: [{ responses: [{ is: { body: 'Hello world!' } }] }] };3mb.create(imposter, function (error, imposters) {4 var client = mb.createClient({ port: 2525 });5 });6});

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2mb.nowText('Hello World!');3var mb = require('mountebank');4mb.nowText('Hello World!');5var mb = require('mountebank');6mb.nowText('Hello World!');7var mb = require('mountebank');8mb.nowText('Hello World!');9var mb = require('mountebank');10mb.nowText('Hello World!');11var mb = require('mountebank');12mb.nowText('Hello World!');13var mb = require('mountebank');14mb.nowText('Hello World!');15var mb = require('mountebank');16mb.nowText('Hello World!');17var mb = require('mountebank');18mb.nowText('Hello World!');19var mb = require('mountebank');20mb.nowText('Hello World!');21var mb = require('mountebank');22mb.nowText('Hello World!');23var mb = require('mountebank');24mb.nowText('Hello World!');25var mb = require('mountebank');26mb.nowText('Hello World!');27var mb = require('mountebank');28mb.nowText('Hello World!');29var mb = require('mountebank

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var nowText = mb.nowText();3console.log(nowText);4var mb = require('mountebank');5var nowText = mb.nowText();6var now = mb.now();7console.log(nowText);8console.log(now);9var mb = require('mountebank');10var nowText = mb.nowText();11var now = mb.now();12console.log(nowText);13console.log(now);14var mb = require('mountebank');15var nowText = mb.nowText();16var now = mb.now();17console.log(nowText);18console.log(now);19var mb = require('mountebank');20var nowText = mb.nowText();21var now = mb.now();22console.log(nowText);23console.log(now);24var mb = require('mountebank');25var nowText = mb.nowText();26var now = mb.now();27console.log(nowText);28console.log(now);29var mb = require('mountebank');30var nowText = mb.nowText();31var now = mb.now();32console.log(nowText);33console.log(now);34var mb = require('mountebank');35var nowText = mb.nowText();36var now = mb.now();37console.log(nowText);38console.log(now);39var mb = require('mountebank');40var nowText = mb.nowText();41var now = mb.now();42console.log(nowText);43console.log(now);44var mb = require('mountebank');45var nowText = mb.nowText();46var now = mb.now();47console.log(nowText);48console.log(now);49var mb = require('mountebank');50var nowText = mb.nowText();51var now = mb.now();52console.log(nowText);53console.log(now);

Full Screen

Using AI Code Generation

copy

Full Screen

1var request = require('request');2var nowText = require('mountebank').nowText;3var options = {4};5request(options, function (error, response, body) {6 if (!error && response.statusCode == 200) {7 var now = nowText();8 console.log('now: ' + now);9 console.log('response: ' + body);10 }11});12var request = require('request');13var nowText = require('mountebank').nowText;14var options = {15};16request(options, function (error, response, body) {17 if (!error && response.statusCode == 200) {18 var now = nowText();19 console.log('now: ' + now);20 console.log('response: ' + body);21 }22});23var request = require('request');24var nowText = require('mountebank').nowText;25var options = {26};27request(options, function (error, response, body) {28 if (!error && response.statusCode == 200) {29 var now = nowText();30 console.log('now: ' + now);31 console.log('response: ' + body);32 }33});

Full Screen

Using AI Code Generation

copy

Full Screen

1const request = require('request');2const nowText = require('mountebank').nowText;3const imposter = { protocol: 'http', port: 3000 };4const stub = {5 {6 is: {7 }8 }9};10const predicate = { equals: { method: 'GET', path: '/' } };11const mb = require('mountebank').create({ port: 2525, pidfile: 'mb.pid', logfile: 'mb.log', ipWhitelist: ['*'] });12mb.start()13 .then(() => mb.post('/imposters', imposter))14 .then(response => mb.post(`/imposters/${response.body.port}/stubs`, { stubs: [stub] }))15 .then(response => console.log(response.body))16 .then(() => mb.del('/imposters'))17 .then(() => mb.stop())18 .then(() => console.log('Done!'))19 .catch(error => console.error(error));

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var assert = require('assert');3var port = 2525;4var host = "localhost";5var protocol = "http";6var imposterPort = 4545;7var imposterProtocol = "http";8var imposterName = "imposter1";9var path = "/api/test";10var method = "POST";11var stubs = [{12 predicates: [{13 equals: {14 }15 }],16 responses: [{17 is: {18 }19 }]20}];21mb.create({22 },23 function (error) {24 assert.ok(!error, "No error should be returned when creating mb");25 mb.start(port, host, function (error) {26 assert.ok(!error, "No error should be returned when starting mb");27 mb.post("/imposters", {28 }, function (error, response) {29 assert.ok(!error, "No error should be returned when creating imposter");30 assert.equal(response.statusCode, 201, "Should return 201 when creating imposter");31 mb.get("/imposters/" + imposterPort, function (error, response) {32 assert.ok(!error, "No error should be returned when getting imposter");33 assert.equal(response.statusCode, 200, "Should return 200 when getting imposter");34 mb.nowText(port, host, function (error, response, body) {35 assert.ok(!error, "No error should be returned when getting now text");36 assert.equal(response.statusCode, 200, "Should return 200 when getting now text");37 assert.ok(body, "Should return now text");38 mb.stop(port, host, function (error) {39 assert.ok(!error, "No error should be returned when stopping mb");40 mb.del("/imposters/" + imposterPort, function (error, response) {41 assert.ok(!error, "No error should be returned

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var nowText = mb.nowText();3console.log(nowText);4{5 "scripts": {6 },7 "dependencies": {8 }9}

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run mountebank automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful