Best JavaScript code snippet using nightwatch
AjaxRequest.js
Source:AjaxRequest.js
1/// <reference path="Common.js" />2/// <reference path="Ipt.js" />3var PayUrl = "/GameCenter/Pay.htm";4function Register() {5 if (blurNameStyle() && blurPassStyle() && blurPass1Style()&&blurSCodeStyle()) {6 var uName = $.trim($("#u_name").val());7 var uPas = $.trim($("#u_pas").val());8 var uPas1 = $.trim($("#u_pas1").val());9 var sCode = $.trim($("#s_code").val());10 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "Register", uName: uName, uPas: uPas, sCode: sCode,Sid: GetParasValue("Sid") }, function (msg) {11 HideLoading(); //ä¸ç®¡æ¯å¦æåï¼é½è¦Hide12 if (msg.indexOf("æå") > 0)13 ShowModalAndRedirect(FormatMsg(msg, "green"), "/UserCenter/");14 else15 ShowModal(FormatMsg(msg, "red"));16 });17 }18}19function Login() {20 if (blurNameStyle() && blurPassStyle()) {21 var uName = $.trim($("#u_name").val());22 var uPas = $.trim($("#u_pas").val());23 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "Login", uName: uName, uPas: uPas }, function (msg) {24 HideLoading();25 if (msg.indexOf("æå") > 0) {26 ShowModalAndRedirect(FormatMsg(msg, "green"), "/UserCenter/");27 } else {28 ShowModal(FormatMsg(msg, "red"));29 }30 });31 }32}33function SignOut() {34 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "SignOut" }, function (msg) {35 HideLoading();36 if (msg.indexOf("æå") > 0) {37 ShowModalAndRedirect(FormatMsg(msg, "green"), "/UserCenter/Login.php");38 } else {39 ShowModal(FormatMsg("ç½ç»ç¹å¿ï¼è¯·ç¨ååè¯ã", "red"));40 }41 });42}43function ChangePass() {44 if (blurOPassStyle && blurPassStyle() && blurPass1Style()) {45 var oPas = $.trim($("#o_pas").val());46 var uPas = $.trim($("#u_pas").val());47 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "ChangePass", oPas: oPas, uPas: uPas }, function (msg) {48 HideLoading();49 if (msg.indexOf("æå") > 0) {50 ShowModalAndRedirect(FormatMsg(msg, "green"), "/UserCenter/Login.php");51 } else {52 ShowModal(FormatMsg(msg, "red"));53 }54 });55 }56}57function SecurityEmail() {58 if (blurUMailStyle() && blurRMailStyle()) {59 var uMail = $.trim($("#u_mail").val());60 var rMail = $.trim($("#r_mail").val());61 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "SecurityEmail", uMail: uMail }, function (msg) {62 HideLoading();63 if (msg.indexOf("æå") > 0) {64 ShowModal(FormatMsg(msg, "green"));65 } else {66 ShowModal(FormatMsg(msg, "red"));67 }68 });69 }70}71function BackPass() {72 if (blurNameStyle() && blurPassStyle() && blurPass1Style() && blurSCodeStyle()) {73 var uName = $.trim($("#u_name").val());74 var uPas = $.trim($("#u_pas").val());75 var sCode = $.trim($("#s_code").val());76 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "BackPass", uName: uName, uPas: uPas, sCode: sCode }, function (msg) {77 HideLoading();78 if (msg.indexOf("æå") > 0) {79 ShowModalAndRedirect(FormatMsg(msg, "green"), "/UserCenter/Login.aspx");80 } else {81 ShowModal(FormatMsg(msg, "red"));82 }83 });84 }85}86function SpreadTran() {87 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "SpreadTran" }, function (msg) {88 HideLoading();89 if (msg.indexOf("æå") > 0) {90 ShowModal(FormatMsg(msg, "green"));91 } else {92 ShowModal(FormatMsg(msg, "red"));93 }94 });95}96function shouchong() {97 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "shouchong" }, function (msg) {98 HideLoading();99 if (msg.indexOf("æå") > 0) {100 ShowModal(FormatMsg(msg, "green"));101 } else {102 ShowModal(FormatMsg(msg, "red"));103 }104 });105}106function kahaozijiu() {107 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "kahaozijiu" }, function (msg) {108 HideLoading();109 if (msg.indexOf("æå") > 0) {110 ShowModal(FormatMsg(msg, "green"));111 } else {112 ShowModal(FormatMsg(msg, "red"));113 }114 });115}116function logingame() {117 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "logingame" }, function (msg) {118 HideLoading();119 if (msg.indexOf("æå") > 0) {120 ShowModal(FormatMsg(msg, "green"));121 } else {122 ShowModal(FormatMsg(msg, "red"));123 }124 });125}126function zhizunshangcheng() {127 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "zhizunshangcheng" }, function (msg) {128 HideLoading();129 if (msg.indexOf("æå") > 0) {130 ShowModal(FormatMsg(msg, "green"));131 } else {132 ShowModal(FormatMsg(msg, "red"));133 }134 });135}136function zhanshi() {137 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "zhanshi" }, function (msg) {138 HideLoading();139 if (msg.indexOf("æå") > 0) {140 ShowModal(FormatMsg(msg, "green"));141 } else {142 ShowModal(FormatMsg(msg, "red"));143 }144 });145}146function daoshi() {147 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "yiqianwulibao" }, function (msg) {148 HideLoading();149 if (msg.indexOf("æå") > 0) {150 ShowModal(FormatMsg(msg, "green"));151 } else {152 ShowModal(FormatMsg(msg, "red"));153 }154 });155}156function fashi() {157 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "jiubailibao" }, function (msg) {158 HideLoading();159 if (msg.indexOf("æå") > 0) {160 ShowModal(FormatMsg(msg, "green"));161 } else {162 ShowModal(FormatMsg(msg, "red"));163 }164 });165}166function yuyi() {167 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "wubailibao" }, function (msg) {168 HideLoading();169 if (msg.indexOf("æå") > 0) {170 ShowModal(FormatMsg(msg, "green"));171 } else {172 ShowModal(FormatMsg(msg, "red"));173 }174 });175}176function meili() {177 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "sanbailibao" }, function (msg) {178 HideLoading();179 if (msg.indexOf("æå") > 0) {180 ShowModal(FormatMsg(msg, "green"));181 } else {182 ShowModal(FormatMsg(msg, "red"));183 }184 });185}186function daoshiyuan() {187 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "daoshiyuan" }, function (msg) {188 HideLoading();189 if (msg.indexOf("æå") > 0) {190 ShowModal(FormatMsg(msg, "green"));191 } else {192 ShowModal(FormatMsg(msg, "red"));193 }194 });195}196function wushiyuan() {197 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "wushiyuan" }, function (msg) {198 HideLoading();199 if (msg.indexOf("æå") > 0) {200 ShowModal(FormatMsg(msg, "green"));201 } else {202 ShowModal(FormatMsg(msg, "red"));203 }204 });205}206function yibaiyuan() {207 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "yibaiyuan" }, function (msg) {208 HideLoading();209 if (msg.indexOf("æå") > 0) {210 ShowModal(FormatMsg(msg, "green"));211 } else {212 ShowModal(FormatMsg(msg, "red"));213 }214 });215}216function shiyuana() {217 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "shiyuana" }, function (msg) {218 HideLoading();219 if (msg.indexOf("æå") > 0) {220 ShowModal(FormatMsg(msg, "green"));221 } else {222 ShowModal(FormatMsg(msg, "red"));223 }224 });225}226function daoshiyuana() {227 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "daoshiyuana" }, function (msg) {228 HideLoading();229 if (msg.indexOf("æå") > 0) {230 ShowModal(FormatMsg(msg, "green"));231 } else {232 ShowModal(FormatMsg(msg, "red"));233 }234 });235}236function wushiyuana() {237 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "wushiyuana" }, function (msg) {238 HideLoading();239 if (msg.indexOf("æå") > 0) {240 ShowModal(FormatMsg(msg, "green"));241 } else {242 ShowModal(FormatMsg(msg, "red"));243 }244 });245}246function shiyuanwocao() {247 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "shiyuanwocao" }, function (msg) {248 HideLoading();249 if (msg.indexOf("æå") > 0) {250 ShowModal(FormatMsg(msg, "green"));251 } else {252 ShowModal(FormatMsg(msg, "red"));253 }254 });255}256function yibaiyuana() {257 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "yibaiyuana" }, function (msg) {258 HideLoading();259 if (msg.indexOf("æå") > 0) {260 ShowModal(FormatMsg(msg, "green"));261 } else {262 ShowModal(FormatMsg(msg, "red"));263 }264 });265}266function shiyuanaa() {267 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "shiyuanaa" }, function (msg) {268 HideLoading();269 if (msg.indexOf("æå") > 0) {270 ShowModal(FormatMsg(msg, "green"));271 } else {272 ShowModal(FormatMsg(msg, "red"));273 }274 });275}276function daoshiyuanaa() {277 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "daoshiyuanaa" }, function (msg) {278 HideLoading();279 if (msg.indexOf("æå") > 0) {280 ShowModal(FormatMsg(msg, "green"));281 } else {282 ShowModal(FormatMsg(msg, "red"));283 }284 });285}286function daoshiyuanaaa() {287 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "daoshiyuanaaa" }, function (msg) {288 HideLoading();289 if (msg.indexOf("æå") > 0) {290 ShowModal(FormatMsg(msg, "green"));291 } else {292 ShowModal(FormatMsg(msg, "red"));293 }294 });295}296function daoshiyuanbbb() {297 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "daoshiyuanbbb" }, function (msg) {298 HideLoading();299 if (msg.indexOf("æå") > 0) {300 ShowModal(FormatMsg(msg, "green"));301 } else {302 ShowModal(FormatMsg(msg, "red"));303 }304 });305}306function daoshiyuanccc() {307 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "daoshiyuanccc" }, function (msg) {308 HideLoading();309 if (msg.indexOf("æå") > 0) {310 ShowModal(FormatMsg(msg, "green"));311 } else {312 ShowModal(FormatMsg(msg, "red"));313 }314 });315}316function daoshiyuanddd() {317 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "daoshiyuanddd" }, function (msg) {318 HideLoading();319 if (msg.indexOf("æå") > 0) {320 ShowModal(FormatMsg(msg, "green"));321 } else {322 ShowModal(FormatMsg(msg, "red"));323 }324 });325}326function daoshiyuaneee() {327 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "daoshiyuaneee" }, function (msg) {328 HideLoading();329 if (msg.indexOf("æå") > 0) {330 ShowModal(FormatMsg(msg, "green"));331 } else {332 ShowModal(FormatMsg(msg, "red"));333 }334 });335}336function daoshiyuanfff() {337 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "daoshiyuanfff" }, function (msg) {338 HideLoading();339 if (msg.indexOf("æå") > 0) {340 ShowModal(FormatMsg(msg, "green"));341 } else {342 ShowModal(FormatMsg(msg, "red"));343 }344 });345}346function daoshiyuanggg() {347 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "daoshiyuanggg" }, function (msg) {348 HideLoading();349 if (msg.indexOf("æå") > 0) {350 ShowModal(FormatMsg(msg, "green"));351 } else {352 ShowModal(FormatMsg(msg, "red"));353 }354 });355}356function daoshiyuanhhh() {357 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "daoshiyuanhhh" }, function (msg) {358 HideLoading();359 if (msg.indexOf("æå") > 0) {360 ShowModal(FormatMsg(msg, "green"));361 } else {362 ShowModal(FormatMsg(msg, "red"));363 }364 });365}366function daoshiyuankkk() {367 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "daoshiyuankkk" }, function (msg) {368 HideLoading();369 if (msg.indexOf("æå") > 0) {370 ShowModal(FormatMsg(msg, "green"));371 } else {372 ShowModal(FormatMsg(msg, "red"));373 }374 });375}376function wushiyuanaa() {377 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "wushiyuanaa" }, function (msg) {378 HideLoading();379 if (msg.indexOf("æå") > 0) {380 ShowModal(FormatMsg(msg, "green"));381 } else {382 ShowModal(FormatMsg(msg, "red"));383 }384 });385}386function yibaiyuanaa() {387 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "yibaiyuanaa" }, function (msg) {388 HideLoading();389 if (msg.indexOf("æå") > 0) {390 ShowModal(FormatMsg(msg, "green"));391 } else {392 ShowModal(FormatMsg(msg, "red"));393 }394 });395}396function wuxianbangdingyuanbao() {397 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "wuxianbangdingyuanbao" }, function (msg) {398 HideLoading();399 if (msg.indexOf("æå") > 0) {400 ShowModal(FormatMsg(msg, "green"));401 } else {402 ShowModal(FormatMsg(msg, "red"));403 }404 });405}406function GetYuanBaoFromUser() {407 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "GetYuanBaoFromUser" }, function (msg) {408 HideLoading();409 if (msg.indexOf("æå") > 0) {410 ShowModal(FormatMsg(msg, "green"));411 $("#tabs").tabs("refresh");412 } else if (msg.indexOf("å
å¼") > 0) {413 ShowModalAndOpenNewWindow(FormatMsg(msg, "red"), PayUrl);414 } else {415 ShowModal(FormatMsg(msg, "red"));416 }417 });418}419function FreeRwardCash(oid) {420 DoAjax("/AjaxRequest/PlayInfoHandeler.php", { Action: "FreeRwardCash", oId: oid }, function (msg) {421 HideLoading();422 if (msg.indexOf("æå") > 0) {423 ShowModal(FormatMsg(msg, "green"));424 $("#tabs").tabs("refresh");425 } else {426 ShowModal(FormatMsg(msg, "red"));427 }428 });429}430function FreeRwardGold(oid) {431 DoAjax("/AjaxRequest/PlayInfoHandeler.php", { Action: "FreeRwardGold", oId: oid }, function (msg) {432 HideLoading();433 if (msg.indexOf("æå") > 0) {434 ShowModal(FormatMsg(msg, "green"));435 $("#tabs").tabs("refresh");436 } else {437 ShowModal(FormatMsg(msg, "red"));438 }439 });440}441function RwardLevelGold(oid) {442 DoAjax("/AjaxRequest/PlayInfoHandeler.php", { Action: "RwardLevelGold", oId: oid }, function (msg) {443 HideLoading();444 if (msg.indexOf("æå") > 0) {445 ShowModal(FormatMsg(msg, "green"));446 $("#tabs").tabs("refresh");447 } else {448 ShowModal(FormatMsg(msg, "red"));449 }450 });451}452function RoleBuyExp(oid, buyType) {453 DoAjax("/AjaxRequest/PlayInfoHandeler.php", { Action: "RoleBuyExp", oId: oid, buyType: buyType }, function (msg) {454 HideLoading();455 if (msg.indexOf("æå") > 0) {456 ShowModal(FormatMsg(msg, "green"));457 $("#tabs").tabs("refresh");458 } else if (msg.indexOf("å
å¼") > 0) {459 ShowModalAndOpenNewWindow(FormatMsg(msg, "red"), PayUrl);460 } else {461 ShowModal(FormatMsg(msg, "red"));462 }463 });464}465function PetBuyExp(rOid, pOid, buyType) {466 DoAjax("/AjaxRequest/PetInfoHandeler.php", { Action: "PetBuyExp", rOid: rOid, pOid: pOid, buyType: buyType }, function (msg) {467 HideLoading();468 if (msg.indexOf("æå") > 0) {469 ShowModal(FormatMsg(msg, "green"));470 $("#tabs").tabs("refresh");471 } else if (msg.indexOf("å
å¼") > 0) {472 ShowModalAndOpenNewWindow(FormatMsg(msg, "red"), PayUrl);473 } else {474 ShowModal(FormatMsg(msg, "red"));475 }476 });477}478function PetRebirth(rOid, pOid) {479 DoAjax("/AjaxRequest/PetInfoHandeler.php", { Action: "PetRebirth", rOid: rOid, pOid: pOid }, function (msg) {480 HideLoading();481 if (msg.indexOf("æå") > 0) {482 ShowModal(FormatMsg(msg, "green"));483 $("#tabs").tabs("refresh");484 } else if (msg.indexOf("å
å¼") > 0) {485 ShowModalAndOpenNewWindow(FormatMsg(msg, "red"), PayUrl);486 } else {487 ShowModal(FormatMsg(msg, "red"));488 }489 });490}491function BuyMallItem(itemId) {492 DoAjax("/AjaxRequest/MallShopHandler.php", { Action: "BuyMallItem", ItemId: itemId }, function (msg) {493 HideLoading();494 if (msg.indexOf("æå") > 0) {495 ShowModal(FormatMsg(msg, "green"));496 } else if (msg.indexOf("å
å¼") > 0) {497 ShowModalAndOpenNewWindow(FormatMsg(msg, "red"), PayUrl);498 } else {499 ShowModal(FormatMsg(msg, "red"));500 }501 });...
AjaxRequest22.js
Source:AjaxRequest22.js
1/// <reference path="Common.js" />2/// <reference path="Ipt.js" />3var PayUrl = "/GameCenter/Pay.htm";4function Register() {5 if (blurNameStyle() && blurPassStyle() && blurPass1Style()) {6 var uName = $.trim($("#u_name").val());7 var uPas = $.trim($("#u_pas").val());8 var uPas1 = $.trim($("#u_pas1").val());9 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "Register", uName: uName, uPas: uPas, Sid: GetParasValue("Sid") }, function (msg) {10 HideLoading(); //ä¸ç®¡æ¯å¦æåï¼é½è¦Hide11 if (msg.indexOf("æå") > 0)12 ShowModalAndRedirect(FormatMsg(msg, "green"), "/UserCenter/");13 else14 ShowModal(FormatMsg(msg, "red"));15 });16 }17}18function Login() {19 if (blurNameStyle() && blurPassStyle()) {20 var uName = $.trim($("#u_name").val());21 var uPas = $.trim($("#u_pas").val());22 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "Login", uName: uName, uPas: uPas }, function (msg) {23 HideLoading();24 if (msg.indexOf("æå") > 0) {25 ShowModalAndRedirect(FormatMsg(msg, "green"), "/UserCenter/");26 } else {27 ShowModal(FormatMsg(msg, "red"));28 }29 });30 }31}32function SignOut() {33 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "SignOut" }, function (msg) {34 HideLoading();35 if (msg.indexOf("æå") > 0) {36 ShowModalAndRedirect(FormatMsg(msg, "green"), "/UserCenter/Login.php");37 } else {38 ShowModal(FormatMsg("ç½ç»ç¹å¿ï¼è¯·ç¨ååè¯ã", "red"));39 }40 });41}42function ChangePass() {43 if (blurOPassStyle && blurPassStyle() && blurPass1Style()) {44 var oPas = $.trim($("#o_pas").val());45 var uPas = $.trim($("#u_pas").val());46 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "ChangePass", oPas: oPas, uPas: uPas }, function (msg) {47 HideLoading();48 if (msg.indexOf("æå") > 0) {49 ShowModalAndRedirect(FormatMsg(msg, "green"), "/UserCenter/Login.php");50 } else {51 ShowModal(FormatMsg(msg, "red"));52 }53 });54 }55}56function SecurityEmail() {57 if (blurUMailStyle() && blurRMailStyle()) {58 var uMail = $.trim($("#u_mail").val());59 var rMail = $.trim($("#r_mail").val());60 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "SecurityEmail", uMail: uMail }, function (msg) {61 HideLoading();62 if (msg.indexOf("æå") > 0) {63 ShowModal(FormatMsg(msg, "green"));64 } else {65 ShowModal(FormatMsg(msg, "red"));66 }67 });68 }69}70function BackPass() {71 if (blurNameStyle() && blurPassStyle() && blurPass1Style() && blurSCodeStyle()) {72 var uName = $.trim($("#u_name").val());73 var uPas = $.trim($("#u_pas").val());74 var sCode = $.trim($("#s_code").val());75 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "BackPass", uName: uName, uPas: uPas, sCode: sCode }, function (msg) {76 HideLoading();77 if (msg.indexOf("æå") > 0) {78 ShowModalAndRedirect(FormatMsg(msg, "green"), "/UserCenter/Login.aspx");79 } else {80 ShowModal(FormatMsg(msg, "red"));81 }82 });83 }84}85function SpreadTran() {86 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "SpreadTran" }, function (msg) {87 HideLoading();88 if (msg.indexOf("æå") > 0) {89 ShowModal(FormatMsg(msg, "green"));90 } else {91 ShowModal(FormatMsg(msg, "red"));92 }93 });94}95function kahaozijiu() {96 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "kahaozijiu" }, function (msg) {97 HideLoading();98 if (msg.indexOf("æå") > 0) {99 ShowModal(FormatMsg(msg, "green"));100 } else {101 ShowModal(FormatMsg(msg, "red"));102 }103 });104}105function zhizunshangcheng() {106 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "zhizunshangcheng" }, function (msg) {107 HideLoading();108 if (msg.indexOf("æå") > 0) {109 ShowModal(FormatMsg(msg, "green"));110 } else {111 ShowModal(FormatMsg(msg, "red"));112 }113 });114}115function shiyuanabc() {116 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "shiyuanabc" }, function (msg) {117 HideLoading();118 if (msg.indexOf("æå") > 0) {119 ShowModal(FormatMsg(msg, "green"));120 } else {121 ShowModal(FormatMsg(msg, "red"));122 }123 });124}125function kadengjizijiu() {126 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "kadengjizijiu" }, function (msg) {127 HideLoading();128 if (msg.indexOf("æå") > 0) {129 ShowModal(FormatMsg(msg, "green"));130 } else {131 ShowModal(FormatMsg(msg, "red"));132 }133 });134}135function shiyuan() {136 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "shiyuan" }, function (msg) {137 HideLoading();138 if (msg.indexOf("æå") > 0) {139 ShowModal(FormatMsg(msg, "green"));140 } else {141 ShowModal(FormatMsg(msg, "red"));142 }143 });144}145function daoshiyuan() {146 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "daoshiyuan" }, function (msg) {147 HideLoading();148 if (msg.indexOf("æå") > 0) {149 ShowModal(FormatMsg(msg, "green"));150 } else {151 ShowModal(FormatMsg(msg, "red"));152 }153 });154}155function wushiyuan() {156 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "wushiyuan" }, function (msg) {157 HideLoading();158 if (msg.indexOf("æå") > 0) {159 ShowModal(FormatMsg(msg, "green"));160 } else {161 ShowModal(FormatMsg(msg, "red"));162 }163 });164}165function yibaiyuan() {166 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "yibaiyuan" }, function (msg) {167 HideLoading();168 if (msg.indexOf("æå") > 0) {169 ShowModal(FormatMsg(msg, "green"));170 } else {171 ShowModal(FormatMsg(msg, "red"));172 }173 });174}175function shiyuana() {176 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "shiyuana" }, function (msg) {177 HideLoading();178 if (msg.indexOf("æå") > 0) {179 ShowModal(FormatMsg(msg, "green"));180 } else {181 ShowModal(FormatMsg(msg, "red"));182 }183 });184}185function daoshiyuana() {186 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "daoshiyuana" }, function (msg) {187 HideLoading();188 if (msg.indexOf("æå") > 0) {189 ShowModal(FormatMsg(msg, "green"));190 } else {191 ShowModal(FormatMsg(msg, "red"));192 }193 });194}195function wushiyuana() {196 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "wushiyuana" }, function (msg) {197 HideLoading();198 if (msg.indexOf("æå") > 0) {199 ShowModal(FormatMsg(msg, "green"));200 } else {201 ShowModal(FormatMsg(msg, "red"));202 }203 });204}205function zhuansheng() {206 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "zhuansheng" }, function (msg) {207 HideLoading();208 if (msg.indexOf("æå") > 0) {209 ShowModal(FormatMsg(msg, "green"));210 } else {211 ShowModal(FormatMsg(msg, "red"));212 }213 });214}215function yibaiyuana() {216 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "yibaiyuana" }, function (msg) {217 HideLoading();218 if (msg.indexOf("æå") > 0) {219 ShowModal(FormatMsg(msg, "green"));220 } else {221 ShowModal(FormatMsg(msg, "red"));222 }223 });224}225function shiyuanaa() {226 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "shiyuanaa" }, function (msg) {227 HideLoading();228 if (msg.indexOf("æå") > 0) {229 ShowModal(FormatMsg(msg, "green"));230 } else {231 ShowModal(FormatMsg(msg, "red"));232 }233 });234}235function daoshiyuanaa() {236 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "daoshiyuanaa" }, function (msg) {237 HideLoading();238 if (msg.indexOf("æå") > 0) {239 ShowModal(FormatMsg(msg, "green"));240 } else {241 ShowModal(FormatMsg(msg, "red"));242 }243 });244}245function wushiyuanaa() {246 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "wushiyuanaa" }, function (msg) {247 HideLoading();248 if (msg.indexOf("æå") > 0) {249 ShowModal(FormatMsg(msg, "green"));250 } else {251 ShowModal(FormatMsg(msg, "red"));252 }253 });254}255function yibaiyuanaa() {256 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "yibaiyuanaa" }, function (msg) {257 HideLoading();258 if (msg.indexOf("æå") > 0) {259 ShowModal(FormatMsg(msg, "green"));260 } else {261 ShowModal(FormatMsg(msg, "red"));262 }263 });264}265function wuxianbangdingyuanbao() {266 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "wuxianbangdingyuanbao" }, function (msg) {267 HideLoading();268 if (msg.indexOf("æå") > 0) {269 ShowModal(FormatMsg(msg, "green"));270 } else {271 ShowModal(FormatMsg(msg, "red"));272 }273 });274}275function GetYuanBaoFromUser() {276 DoAjax("/AjaxRequest/AccountHandler.php", { Action: "GetYuanBaoFromUser" }, function (msg) {277 HideLoading();278 if (msg.indexOf("æå") > 0) {279 ShowModal(FormatMsg(msg, "green"));280 $("#tabs").tabs("refresh");281 } else if (msg.indexOf("å
å¼") > 0) {282 ShowModalAndOpenNewWindow(FormatMsg(msg, "red"), PayUrl);283 } else {284 ShowModal(FormatMsg(msg, "red"));285 }286 });287}288function FreeRwardCash(oid) {289 DoAjax("/AjaxRequest/PlayInfoHandeler.php", { Action: "FreeRwardCash", oId: oid }, function (msg) {290 HideLoading();291 if (msg.indexOf("æå") > 0) {292 ShowModal(FormatMsg(msg, "green"));293 $("#tabs").tabs("refresh");294 } else {295 ShowModal(FormatMsg(msg, "red"));296 }297 });298}299function FreeRwardGold(oid) {300 DoAjax("/AjaxRequest/PlayInfoHandeler.php", { Action: "FreeRwardGold", oId: oid }, function (msg) {301 HideLoading();302 if (msg.indexOf("æå") > 0) {303 ShowModal(FormatMsg(msg, "green"));304 $("#tabs").tabs("refresh");305 } else {306 ShowModal(FormatMsg(msg, "red"));307 }308 });309}310function RwardLevelGold(oid) {311 DoAjax("/AjaxRequest/PlayInfoHandeler.php", { Action: "RwardLevelGold", oId: oid }, function (msg) {312 HideLoading();313 if (msg.indexOf("æå") > 0) {314 ShowModal(FormatMsg(msg, "green"));315 $("#tabs").tabs("refresh");316 } else {317 ShowModal(FormatMsg(msg, "red"));318 }319 });320}321function RoleBuyExp(oid, buyType) {322 DoAjax("/AjaxRequest/PlayInfoHandeler.php", { Action: "RoleBuyExp", oId: oid, buyType: buyType }, function (msg) {323 HideLoading();324 if (msg.indexOf("æå") > 0) {325 ShowModal(FormatMsg(msg, "green"));326 $("#tabs").tabs("refresh");327 } else if (msg.indexOf("å
å¼") > 0) {328 ShowModalAndOpenNewWindow(FormatMsg(msg, "red"), PayUrl);329 } else {330 ShowModal(FormatMsg(msg, "red"));331 }332 });333}334function PetBuyExp(rOid, pOid, buyType) {335 DoAjax("/AjaxRequest/PetInfoHandeler.php", { Action: "PetBuyExp", rOid: rOid, pOid: pOid, buyType: buyType }, function (msg) {336 HideLoading();337 if (msg.indexOf("æå") > 0) {338 ShowModal(FormatMsg(msg, "green"));339 $("#tabs").tabs("refresh");340 } else if (msg.indexOf("å
å¼") > 0) {341 ShowModalAndOpenNewWindow(FormatMsg(msg, "red"), PayUrl);342 } else {343 ShowModal(FormatMsg(msg, "red"));344 }345 });346}347function PetRebirth(rOid, pOid) {348 DoAjax("/AjaxRequest/PetInfoHandeler.php", { Action: "PetRebirth", rOid: rOid, pOid: pOid }, function (msg) {349 HideLoading();350 if (msg.indexOf("æå") > 0) {351 ShowModal(FormatMsg(msg, "green"));352 $("#tabs").tabs("refresh");353 } else if (msg.indexOf("å
å¼") > 0) {354 ShowModalAndOpenNewWindow(FormatMsg(msg, "red"), PayUrl);355 } else {356 ShowModal(FormatMsg(msg, "red"));357 }358 });359}360function BuyMallItem(itemId) {361 DoAjax("/AjaxRequest/MallShopHandler.php", { Action: "BuyMallItem", ItemId: itemId }, function (msg) {362 HideLoading();363 if (msg.indexOf("æå") > 0) {364 ShowModal(FormatMsg(msg, "green"));365 } else if (msg.indexOf("å
å¼") > 0) {366 ShowModalAndOpenNewWindow(FormatMsg(msg, "red"), PayUrl);367 } else {368 ShowModal(FormatMsg(msg, "red"));369 }370 });...
AjaxRequest1.js
Source:AjaxRequest1.js
1/// <reference path="Common.js" />2/// <reference path="Ipt.js" />3var PayUrl = "/xfd2/GameCenter/Pay.htm";4function Register() {5 if (blurNameStyle() && blurPassStyle() && blurPass1Style()) {6 var uName = $.trim($("#u_name").val());7 var uPas = $.trim($("#u_pas").val());8 var uPas1 = $.trim($("#u_pas1").val());9 DoAjax("/xfd2/AjaxRequest/AccountHandler.php", { Action: "Register", uName: uName, uPas: uPas, Sid: GetParasValue("Sid") }, function (msg) {10 HideLoading(); //ä¸ç®¡æ¯å¦æåï¼é½è¦Hide11 if (msg.indexOf("æå") > 0)12 ShowModalAndRedirect(FormatMsg(msg, "green"), "/xfd2/UserCenter/");13 else14 ShowModal(FormatMsg(msg, "red"));15 });16 }17}18function Login() {19 if (blurNameStyle() && blurPassStyle()) {20 var uName = $.trim($("#u_name").val());21 var uPas = $.trim($("#u_pas").val());22 DoAjax("/xfd2/AjaxRequest/AccountHandler.php", { Action: "Login", uName: uName, uPas: uPas }, function (msg) {23 HideLoading();24 if (msg.indexOf("æå") > 0) {25 ShowModalAndRedirect(FormatMsg(msg, "green"), "/xfd2/UserCenter/");26 } else {27 ShowModal(FormatMsg(msg, "red"));28 }29 });30 }31}32function SignOut() {33 DoAjax("/xfd2/AjaxRequest/AccountHandler.php", { Action: "SignOut" }, function (msg) {34 HideLoading();35 if (msg.indexOf("æå") > 0) {36 ShowModalAndRedirect(FormatMsg(msg, "green"), "/xfd2/UserCenter/Login.php");37 } else {38 ShowModal(FormatMsg("ç½ç»ç¹å¿ï¼è¯·ç¨ååè¯ã", "red"));39 }40 });41}42function ChangePass() {43 if (blurOPassStyle && blurPassStyle() && blurPass1Style()) {44 var oPas = $.trim($("#o_pas").val());45 var uPas = $.trim($("#u_pas").val());46 DoAjax("/xfd2/AjaxRequest/AccountHandler.php", { Action: "ChangePass", oPas: oPas, uPas: uPas }, function (msg) {47 HideLoading();48 if (msg.indexOf("æå") > 0) {49 ShowModalAndRedirect(FormatMsg(msg, "green"), "/xfd2/UserCenter/Login.php");50 } else {51 ShowModal(FormatMsg(msg, "red"));52 }53 });54 }55}56function SecurityEmail() {57 if (blurUMailStyle() && blurRMailStyle()) {58 var uMail = $.trim($("#u_mail").val());59 var rMail = $.trim($("#r_mail").val());60 DoAjax("/xfd2/AjaxRequest/AccountHandler.php", { Action: "SecurityEmail", uMail: uMail }, function (msg) {61 HideLoading();62 if (msg.indexOf("æå") > 0) {63 ShowModal(FormatMsg(msg, "green"));64 } else {65 ShowModal(FormatMsg(msg, "red"));66 }67 });68 }69}70function BackPass() {71 if (blurNameStyle() && blurPassStyle() && blurPass1Style() && blurSCodeStyle()) {72 var uName = $.trim($("#u_name").val());73 var uPas = $.trim($("#u_pas").val());74 var sCode = $.trim($("#s_code").val());75 DoAjax("/xfd2/AjaxRequest/AccountHandler.php", { Action: "BackPass", uName: uName, uPas: uPas, sCode: sCode }, function (msg) {76 HideLoading();77 if (msg.indexOf("æå") > 0) {78 ShowModalAndRedirect(FormatMsg(msg, "green"), "/xfd2/UserCenter/Login.aspx");79 } else {80 ShowModal(FormatMsg(msg, "red"));81 }82 });83 }84}85function SpreadTran() {86 DoAjax("/xfd2/AjaxRequest/AccountHandler.php", { Action: "SpreadTran" }, function (msg) {87 HideLoading();88 if (msg.indexOf("æå") > 0) {89 ShowModal(FormatMsg(msg, "green"));90 } else {91 ShowModal(FormatMsg(msg, "red"));92 }93 });94}95function kahaozijiu() {96 DoAjax("/xfd2/AjaxRequest/AccountHandler.php", { Action: "kahaozijiu" }, function (msg) {97 HideLoading();98 if (msg.indexOf("æå") > 0) {99 ShowModal(FormatMsg(msg, "green"));100 } else {101 ShowModal(FormatMsg(msg, "red"));102 }103 });104}105function wuxianbangdingyuanbao() {106 DoAjax("/xfd2/AjaxRequest/AccountHandler.php", { Action: "wuxianbangdingyuanbao" }, function (msg) {107 HideLoading();108 if (msg.indexOf("æå") > 0) {109 ShowModal(FormatMsg(msg, "green"));110 } else {111 ShowModal(FormatMsg(msg, "red"));112 }113 });114}115function GetYuanBaoFromUser() {116 DoAjax("/xfd2/AjaxRequest/AccountHandler.php", { Action: "GetYuanBaoFromUser" }, function (msg) {117 HideLoading();118 if (msg.indexOf("æå") > 0) {119 ShowModal(FormatMsg(msg, "green"));120 $("#tabs").tabs("refresh");121 } else if (msg.indexOf("å
å¼") > 0) {122 ShowModalAndOpenNewWindow(FormatMsg(msg, "red"), PayUrl);123 } else {124 ShowModal(FormatMsg(msg, "red"));125 }126 });127}128function FreeRwardCash(oid) {129 DoAjax("/xfd2/AjaxRequest/PlayInfoHandeler.php", { Action: "FreeRwardCash", oId: oid }, function (msg) {130 HideLoading();131 if (msg.indexOf("æå") > 0) {132 ShowModal(FormatMsg(msg, "green"));133 $("#tabs").tabs("refresh");134 } else {135 ShowModal(FormatMsg(msg, "red"));136 }137 });138}139function FreeRwardGold(oid) {140 DoAjax("/xfd2/AjaxRequest/PlayInfoHandeler.php", { Action: "FreeRwardGold", oId: oid }, function (msg) {141 HideLoading();142 if (msg.indexOf("æå") > 0) {143 ShowModal(FormatMsg(msg, "green"));144 $("#tabs").tabs("refresh");145 } else {146 ShowModal(FormatMsg(msg, "red"));147 }148 });149}150function RwardLevelGold(oid) {151 DoAjax("/xfd2/AjaxRequest/PlayInfoHandeler.php", { Action: "RwardLevelGold", oId: oid }, function (msg) {152 HideLoading();153 if (msg.indexOf("æå") > 0) {154 ShowModal(FormatMsg(msg, "green"));155 $("#tabs").tabs("refresh");156 } else {157 ShowModal(FormatMsg(msg, "red"));158 }159 });160}161function RoleBuyExp(oid, buyType) {162 DoAjax("/xfd2/AjaxRequest/PlayInfoHandeler.php", { Action: "RoleBuyExp", oId: oid, buyType: buyType }, function (msg) {163 HideLoading();164 if (msg.indexOf("æå") > 0) {165 ShowModal(FormatMsg(msg, "green"));166 $("#tabs").tabs("refresh");167 } else if (msg.indexOf("å
å¼") > 0) {168 ShowModalAndOpenNewWindow(FormatMsg(msg, "red"), PayUrl);169 } else {170 ShowModal(FormatMsg(msg, "red"));171 }172 });173}174function PetBuyExp(rOid, pOid, buyType) {175 DoAjax("/xfd2/AjaxRequest/PetInfoHandeler.php", { Action: "PetBuyExp", rOid: rOid, pOid: pOid, buyType: buyType }, function (msg) {176 HideLoading();177 if (msg.indexOf("æå") > 0) {178 ShowModal(FormatMsg(msg, "green"));179 $("#tabs").tabs("refresh");180 } else if (msg.indexOf("å
å¼") > 0) {181 ShowModalAndOpenNewWindow(FormatMsg(msg, "red"), PayUrl);182 } else {183 ShowModal(FormatMsg(msg, "red"));184 }185 });186}187function PetRebirth(rOid, pOid) {188 DoAjax("/xfd2/AjaxRequest/PetInfoHandeler.php", { Action: "PetRebirth", rOid: rOid, pOid: pOid }, function (msg) {189 HideLoading();190 if (msg.indexOf("æå") > 0) {191 ShowModal(FormatMsg(msg, "green"));192 $("#tabs").tabs("refresh");193 } else if (msg.indexOf("å
å¼") > 0) {194 ShowModalAndOpenNewWindow(FormatMsg(msg, "red"), PayUrl);195 } else {196 ShowModal(FormatMsg(msg, "red"));197 }198 });199}200function BuyMallItem(itemId) {201 DoAjax("/xfd2/AjaxRequest/MallShopHandler.php", { Action: "BuyMallItem", ItemId: itemId }, function (msg) {202 HideLoading();203 if (msg.indexOf("æå") > 0) {204 ShowModal(FormatMsg(msg, "green"));205 } else if (msg.indexOf("å
å¼") > 0) {206 ShowModalAndOpenNewWindow(FormatMsg(msg, "red"), PayUrl);207 } else {208 ShowModal(FormatMsg(msg, "red"));209 }210 });...
assert.js
Source:assert.js
1export const config = {};2export function setConfig(options) {3 Object.assign(config, options);4}5function formatMsg(msg) {6 return `${msg}${msg ? ': ' : ''}`;7}8export function assertTruthy(actual, msg = '') {9 if (!actual) {10 throw new Error(`${formatMsg(msg)}expected: truthy, actual: ${actual}`);11 }12}13export function assertFalsy(actual, msg = '') {14 if (actual) {15 throw new Error(`${formatMsg(msg)}expected: falsy, actual: ${actual}`);16 }17}18export function assertStringMatchesRegEx(actual, regex, msg = '') {19 if (!regex.test(actual)) {20 throw new Error(`${formatMsg(msg)}expected: ${regex}, actual: ${actual}`);21 }22}23export function assertLessThan(actual, expected, msg = '') {24 if (actual >= expected) {25 throw new Error(`${formatMsg(msg)}expected: ${actual} to be less than: ${expected}`);26 }27}28export function assertEqualApproximately(actual, expected, range, msg = '') {29 const diff = Math.abs(actual - expected);30 if (diff > range) {31 throw new Error(`${formatMsg(msg)}expected: ${actual} to be less ${range} different than: ${expected}`);32 }33}34export function assertInstanceOf(actual, expectedType, msg = '') {35 if (!(actual instanceof expectedType)) {36 throw new Error(`${formatMsg(msg)}expected: ${actual} to be of type: ${expectedType.constructor.name}`);37 }38}39export function assertIsArray(actual, msg = '') {40 if (!Array.isArray(actual)) {41 throw new Error(`${formatMsg(msg)}expected: ${actual} to be an Array`);42 }43}44export function assertEqual(actual, expected, msg = '') {45 // I'm sure this is not sufficient46 if (actual.length && expected.length) {47 assertArrayEqual(actual, expected);48 } else if (actual !== expected) {49 throw new Error(`${formatMsg(msg)}expected: ${expected} to equal actual: ${actual}`);50 }51}52export function assertStrictEqual(actual, expected, msg = '') {53 if (actual !== expected) {54 throw new Error(`${formatMsg(msg)}expected: ${expected} to equal actual: ${actual}`);55 }56}57export function assertNotEqual(actual, expected, msg = '') {58 if (actual === expected) {59 throw new Error(`${formatMsg(msg)}expected: ${expected} to not equal actual: ${actual}`);60 }61}62export function assertStrictNotEqual(actual, expected, msg = '') {63 if (actual === expected) {64 throw new Error(`${formatMsg(msg)}expected: ${expected} to not equal actual: ${actual}`);65 }66}67export function assertArrayEqual(actual, expected, msg = '') {68 if (actual.length !== expected.length) {69 throw new Error(`${formatMsg(msg)}expected: array.length ${expected.length} to equal actual.length: ${actual.length}`);70 }71 const errors = [];72 for (let i = 0; i < actual.length; ++i) {73 if (actual[i] !== expected[i]) {74 errors.push(`${formatMsg(msg)}expected: expected[${i}] ${expected[i]} to equal actual[${i}]: ${actual[i]}`);75 if (errors.length === 10) {76 break;77 }78 }79 }80 if (errors.length > 0) {81 throw new Error(errors.join('\n'));82 }83}84export function assertThrowsWith(func, expectations, msg = '') {85 let error = '';86 if (config.throwOnError === false) {87 const origFn = console.error;88 const errors = [];89 console.error = function(...args) {90 errors.push(args.join(' '));91 };92 func();93 console.error = origFn;94 if (errors.length) {95 error = errors.join('\n');96 console.error(error);97 }98 } else {99 try {100 func();101 } catch (e) {102 console.error(e); // eslint-disable-line103 error = e;104 }105 }106 if (config.noLint) {107 return;108 }109 assertStringMatchesREs(error.toString().replace(/\n/g, ' '), expectations, msg);110}111// check if it throws it throws with x112export function assertIfThrowsItThrowsWith(func, expectations, msg = '') {113 let error = '';114 let threw = false;115 if (config.throwOnError === false) {116 const origFn = console.error;117 const errors = [];118 console.error = function(...args) {119 errors.push(args.join(' '));120 };121 func();122 console.error = origFn;123 if (errors.length) {124 error = errors.join('\n');125 console.error(error);126 }127 } else {128 try {129 func();130 } catch (e) {131 console.error(e); // eslint-disable-line132 error = e;133 threw = true;134 }135 }136 if (config.noLint) {137 return;138 }139 if (!threw) {140 return;141 }142 assertStringMatchesREs(error.toString().replace(/\n/g, ' '), expectations, msg);143}144function assertStringMatchesREs(actual, expectations, msg) {145 for (const expectation of expectations) {146 if (expectation instanceof RegExp) {147 if (!expectation.test(actual)) {148 throw new Error(`${formatMsg(msg)}expected: ${expectation}, actual: ${actual}`);149 }150 }151 }152}153export function assertWarnsWith(func, expectations, msg = '') {154 const warnings = [];155 const origWarnFn = console.warn;156 console.warn = function(...args) {157 origWarnFn.call(this, ...args);158 warnings.push(args.join(' '));159 };160 let error;161 try {162 func();...
validator.js
Source:validator.js
1/**2 * @ignore3 * @fileoverview å¼æ¥æ件ä¸ä¼ çéªè¯å¨4 * @author ç´¢ä¸ zengyue.yezy@alibaba-inc.com5 **/6define('bui/uploader/validator',['bui/common'], function (require) {7 var BUI = require('bui/common');8 /**9 * å¼æ¥æ件ä¸ä¼ çéªè¯å¨10 * @class BUI.Uploader.Validator11 * @extend BUI.Base12 *13 * <pre><code>14 * //é»è®¤å·²ç»å®ä¹çä¸äºè§å15 * rules: {16 * maxSize: [1024, 'æ件æ大ä¸è½è¶
è¿1M!'],17 * minSize: [1, 'æ件æå°ä¸è½å°äº1k!'],18 * max: [5, 'æ件æå¤ä¸è½è¶
è¿{0}个ï¼'],19 * min: [1, 'æ件æå°ä¸è½å°äº{0}个!'],20 * ext: ['.png','æ件类ååªè½ä¸º{0}']21 * }22 * </code></pre>23 */24 function Validator(config){25 Validator.superclass.constructor.call(this, config);26 }27 Validator.ATTRS = {28 /**29 * ä¸ä¼ ç»ä»¶çæ ¡éªè§å30 * @type {Object}31 */32 rules: {33 },34 queue: {35 }36 }37 BUI.extend(Validator, BUI.Base);38 BUI.augment(Validator, {39 /**40 * æ ¡éªæ件æ¯å¦ç¬¦åè§åï¼å¹¶è®¾ç½®æ件çç¶æ41 * @param {Object} item42 * @return {Boolean} æ ¡éªç»æ43 */44 valid: function(item){45 return this._validItem(item);46 },47 _validItem: function(item){48 var _self = this,49 rules = _self.get('rules'),50 isValid = true;51 BUI.each(rules, function(rule, name){52 isValid = isValid && _self._validRule(item, name, rule);53 return isValid;54 })55 return isValid;56 },57 _validRule: function(item, name, rule, msg){58 if(BUI.isArray(rule)){59 msg = BUI.substitute(rule[1], rule);60 rule = rule[0];61 }62 var ruleFn = Validator.getRule(name),63 validMsg = ruleFn && ruleFn.call(this, item, rule, msg),64 result = this._getResult(validMsg);65 if(result){66 item.result = result;67 return false;68 }69 return true;70 },71 /**72 * è·åæ ¡éªçç»æ73 * @param {String} msg74 */75 _getResult: function(msg){76 if(msg){77 return {78 msg: msg79 }80 }81 }82 });83 var ruleMap = {};84 Validator.addRule = function(name, fn){85 ruleMap[name] = fn;86 }87 Validator.getRule = function(name){88 return ruleMap[name];89 }90 //æ件æ大å¼91 Validator.addRule('maxSize', function(item, baseValue, formatMsg){92 if(item.size > baseValue * 1024){93 return formatMsg;94 }95 });96 //æ件æå°å¼97 Validator.addRule('minSize', function(item, baseValue, formatMsg){98 if(item.size < baseValue * 1024){99 return formatMsg;100 }101 });102 //ä¸ä¼ æ件çæ大个æ°103 Validator.addRule('max', function(item, baseValue, formatMsg){104 var count = this.get('queue').getCount();105 if(count > baseValue){106 return formatMsg;107 }108 });109 //ä¸ä¼ æ件çæå°ä¸ªæ°110 Validator.addRule('min', function(item, baseValue, formatMsg){111 var count = this.get('queue').getCount();112 if(count < baseValue){113 return formatMsg;114 }115 });116 //ä¸ä¼ æ件çæ件类å117 Validator.addRule('ext', function(item, baseValue, formatMsg){118 var ext = item.ext,119 baseValue = baseValue.split(',');120 if($.inArray(ext, baseValue) === -1){121 return formatMsg;122 }123 });124 return Validator;...
format_msg.test.js
Source:format_msg.test.js
...19import { formatMsg } from './format_msg';20import expect from '@kbn/expect';21describe('formatMsg', () => {22 test('should prepend the second argument to result', () => {23 const actual = formatMsg('error message', 'unit_test');24 expect(actual).to.equal('unit_test: error message');25 });26 test('should handle a simple string', () => {27 const actual = formatMsg('error message');28 expect(actual).to.equal('error message');29 });30 test('should handle a simple Error object', () => {31 const err = new Error('error message');32 const actual = formatMsg(err);33 expect(actual).to.equal('error message');34 });35 test('should handle a simple Angular $http error object', () => {36 const err = {37 data: {38 statusCode: 403,39 error: 'Forbidden',40 message:41 '[security_exception] action [indices:data/read/msearch] is unauthorized for user [user]',42 },43 status: 403,44 config: {},45 statusText: 'Forbidden',46 };47 const actual = formatMsg(err);48 expect(actual).to.equal(49 'Error 403 Forbidden: [security_exception] action [indices:data/read/msearch] is unauthorized for user [user]'50 );51 });52 test('should handle an extended elasticsearch error', () => {53 const err = {54 resp: {55 error: {56 root_cause: [57 {58 reason: 'I am the detailed message',59 },60 ],61 },62 },63 };64 const actual = formatMsg(err);65 expect(actual).to.equal('I am the detailed message');66 });...
_format_msg.js
Source:_format_msg.js
1import { formatMsg } from 'ui/notify/lib/_format_msg';2import expect from 'expect.js';3describe('formatMsg', function () {4 it('should prepend the second argument to result', function () {5 const actual = formatMsg('error message', 'unit_test');6 expect(actual).to.equal('unit_test: error message');7 });8 it('should handle a simple string', function () {9 const actual = formatMsg('error message');10 expect(actual).to.equal('error message');11 });12 it('should handle a simple Error object', function () {13 const err = new Error('error message');14 const actual = formatMsg(err);15 expect(actual).to.equal('error message');16 });17 it('should handle a simple Angular $http error object', function () {18 const err = {19 data: {20 statusCode: 403,21 error: 'Forbidden',22 message: '[security_exception] action [indices:data/read/mget] is unauthorized for user [user]'23 },24 status: 403,25 config: {},26 statusText: 'Forbidden'27 };28 const actual = formatMsg(err);29 expect(actual).to.equal('Error 403 Forbidden: [security_exception] action [indices:data/read/mget] is unauthorized for user [user]');30 });31 it('should handle an extended elasticsearch error', function () {32 const err = {33 resp : {34 error : {35 root_cause : [36 {37 reason : 'I am the detailed message'38 }39 ]40 }41 }42 };43 const actual = formatMsg(err);44 expect(actual).to.equal('I am the detailed message');45 });...
bot.js
Source:bot.js
...8/* Shortcuts to sys functions */9Bot.prototype.sendAll = function(message, channel)10{11 if (channel === undefined || channel == -1)12 sendChanAll(this.formatMsg(message),-1);13 else14 sendChanAll(this.formatMsg(message), channel);15}16Bot.prototype.sendMessage = function(tar, message, channel)17{18 if (channel === undefined)19 sys.sendMessage(tar, this.formatMsg(message));20 else21 sys.sendMessage(tar, this.formatMsg(message), channel);22}23Bot.prototype.sendMainTour = function(message)24{25 this.sendAll(message, 0);26 // Relies on Tournaments channel27 this.sendAll(message, sys.channelId("Tournaments"));28}29/* Following two rely on global channel parameter */30Bot.prototype.sendChanMessage = function(tar, message)31{32 this.sendMessage(tar, message, channel);33}34Bot.prototype.sendChanAll = function(message)35{...
Using AI Code Generation
1module.exports = {2 'Demo test Google' : function (browser) {3 .waitForElementVisible('body', 1000)4 .setValue('input[type=text]', 'nightwatch')5 .waitForElementVisible('input[name=btnK]', 1000)6 .click('input[name=btnK]')7 .pause(1000)8 .assert.containsText('#main', 'Night Watch')9 .end();10 }11};
Using AI Code Generation
1module.exports = {2 'Demo test Google' : function (browser) {3 .waitForElementVisible('body', 1000)4 .setValue('input[type=text]', 'nightwatch')5 .waitForElementVisible('button[name=btnG]', 1000)6 .click('button[name=btnG]')7 .pause(1000)8 .assert.containsText('#main', 'Night Watch')9 .end();10 }11};
Using AI Code Generation
1module.exports = {2 'Demo test Google' : function (browser) {3 .waitForElementVisible('body', 1000)4 .setValue('input[type=text]', 'nightwatch')5 .waitForElementVisible('button[name=btnG]', 1000)6 .click('button[name=btnG]')7 .pause(1000)8 .assert.containsText('#main', 'Night Watch')9 .end();10 }11};12var formatMsg = require('./lib/formatMsg');13module.exports = {14 reporter: function(results) {15 console.log(formatMsg(results));16 }17};18var util = require('util');19module.exports = function(results) {20 var output = '';21 results.modules.forEach(function(module) {22 output += util.format('Module: %s\n', module.name);23 module.completed.forEach(function(test) {24 output += util.format('\t PASS: %s\n', test.name);25 });26 module.failed.forEach(function(test) {27 output += util.format('\t FAIL: %s\n', test.name);28 test.errors.forEach(function(error) {29 output += util.format('\t\t %s\n', error.message);30 });31 });32 });33 return output;34};35* **[Saurabh Sharma](
Using AI Code Generation
1module.exports = {2 'Demo test Google' : function (browser) {3 .waitForElementVisible('body', 1000)4 .setValue('input[type=text]', 'nightwatch')5 .waitForElementVisible('input[name=btnK]', 1000)6 .click('input[name=btnK]')7 .pause(1000)8 .end();9 }10 };
Using AI Code Generation
1module.exports = {2 'Demo test Google' : function (browser) {3 .waitForElementVisible('body', 1000)4 .assert.title('Google')5 .assert.visible('input[type=text]')6 .setValue('input[type=text]', 'nightwatch')7 .waitForElementVisible('button[name=btnG]', 1000)8 .click('button[name=btnG]')9 .pause(1000)10 .assert.containsText('#main', 'Night Watch')11 .end();12 }13 };14- `browser.url()`15- `browser.waitForElementVisible()`16- `browser.assert.title()`17- `browser.assert.visible()`18- `browser.setValue()`19- `browser.click()`20- `browser.assert.containsText()`21- `browser.end()`22- `browser.assert.visible()`23- `browser.assert.hidden()`24- `browser.assert.elementPresent()`25- `browser.assert.elementNotPresent()`26- `browser.assert.containsText()`27- `browser.assert.title()`28- `browser.assert.urlContains()`29- `browser.assert.urlEquals()`30- `browser.assert.value()`31- `browser.assert.cssClassPresent()`32- `browser.assert.cssClassNotPresent()`33- `browser.assert.attributeEquals()`34- `browser.assert.attributeContains()`35- `browser.assert.containsText()`36- `browser.assert.containsValue()`37- `browser.assert.cssProperty()`38- `browser.element()`39- `browser.elements()`40- `browser.elementIdAttribute()`41- `browser.elementIdClear()`42- `browser.elementIdClick()`43- `browser.elementIdCssProperty()`44- `browser.elementIdDisplayed()`45- `browser.elementIdEnabled()`46- `browser.elementIdEquals()`47- `browser.elementIdLocation()`48- `browser.elementIdLocationInView()`49- `browser.elementIdName()`50- `browser.elementIdSelected()`51- `browser.elementIdSize()`52- `browser.elementIdText()`53- `browser.elementIdValue()`54- `browser.elementIdValue()`55- `browser.elementIdValue()`56- `browser.getCookie()`57- `browser.getCookies()`58- `browser.setCookie()`59- `browser.deleteCookie()`
Using AI Code Generation
1module.exports = {2 'Demo test Google' : function (browser) {3 .waitForElementVisible('body', 1000)4 .setValue('input[type=text]', 'nightwatch')5 .waitForElementVisible('input[name=btnK]', 1000)6 .click('input[name=btnK]')7 .pause(1000)8 .assert.containsText('#main', 'Night Watch')9 .end();10 }11};12module.exports = {13 'Demo test Google' : function (browser) {14 var google = browser.page.google();15 .navigate()16 .waitForElementVisible('@body', 1000)17 .setValue('@searchBar', 'nightwatch')18 .waitForElementVisible('@searchButton', 1000)19 .click('@searchButton')20 .pause(1000)21 .assert.containsText('@main', 'Night Watch');22 browser.end();23 }24};25#### Test with Page Object Model (ES6)26module.exports = {27 'Demo test Google' : function (browser) {28 const google = browser.page.google();29 .navigate()30 .waitForElementVisible('@body', 1000)31 .setValue('@searchBar', 'nightwatch')32 .waitForElementVisible('@searchButton', 1000)33 .click('@searchButton')34 .pause(1000)35 .assert.containsText('@main', 'Night Watch');36 browser.end();37 }38};39#### Test with Page Object Model (ES6) and async/await40module.exports = {41 'Demo test Google' : async function (browser) {42 const google = browser.page.google();43 await google.navigate();44 await google.waitForElementVisible('@body', 1000);45 await google.setValue('@searchBar', 'nightwatch');46 await google.waitForElementVisible('@searchButton', 1000);47 await google.click('@searchButton');48 await google.pause(1000);49 await google.assert.containsText('@main
Using AI Code Generation
1module.exports = {2 'Demo test Google' : function (browser) {3 .waitForElementVisible('body', 1000)4 .assert.title('Google')5 .assert.visible('input[type=text]')6 .setValue('input[type=text]', 'nightwatch')7 .waitForElementVisible('button[name=btnK]', 1000)8 .click('button[name=btnK]')9 .pause(1000)10 .assert.containsText('#main', 'Night Watch')11 .end();12 }13 };14 {15 "selenium" : {16 "cli_args" : {17 }18 },19 "test_settings" : {20 "default" : {21 "screenshots" : {22 },23 "desiredCapabilities": {24 }25 },26 "chrome" : {27 "desiredCapabilities": {28 }29 }30 }31 }32 {33 "scripts": {34 },
Using AI Code Generation
1module.exports = {2 'Demo test Google' : function (browser) {3 .waitForElementVisible('body', 1000)4 .pause(1000)5 .end();6 }7};
Using AI Code Generation
1var formatMsg = require('nightwatch/lib/api/util/formatMsg.js');2module.exports = {3 'Test Example' : function (browser) {4 .waitForElementVisible('body', 1000)5 .assert.title('Google')6 .assert.visible('input[type=text]')7 .setValue('input[type=text]', 'nightwatch')8 .waitForElementVisible('button[name=btnG]', 1000)9 .assert.visible('button[name=btnG]')10 .click('button[name=btnG]')11 .pause(1000)12 .assert.containsText('#main', 'Night Watch')13 .end();14 }15};16var formatMsg = require('nightwatch/lib/api/util/formatMsg.js');17module.exports = {18 'Test Example' : function (browser) {19 .waitForElementVisible('body', 1000)20 .assert.title('Google')21 .assert.visible('input[type=text]')22 .setValue('input[type=text]', 'nightwatch')23 .waitForElementVisible('button[name=btnG]', 1000)24 .assert.visible('button[name=btnG]')25 .click('button[name=btnG]')26 .pause(1000)27 .assert.containsText('#main', 'Night Watch')28 .end();29 }30};31var formatMsg = require('nightwatch/lib/api/util/formatMsg.js');32module.exports = {33 'Test Example' : function (browser) {34 .waitForElementVisible('body', 1000)35 .assert.title('Google')36 .assert.visible('input[type=text]')37 .setValue('input[type=text]', 'nightwatch')38 .waitForElementVisible('button[name=btnG]', 1000)39 .assert.visible('button[name=btnG]')40 .click('button[name=btnG]')41 .pause(1000)42 .assert.containsText('#main', 'Night Watch')43 .end();44 }45};
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!