How to use getWindow method in Cypress

Best JavaScript code snippet using cypress

zDialog.js

Source:zDialog.js Github

copy

Full Screen

...143 }144 return topWin;145};146Dialog.prototype.attachBehaviors = function () {147 if (this.Drag && this.getWindow().Drag) this.getWindow().Drag.init(this.getWindow().$id("_Draghandle_" + this.ID), this.getWindow().$id("_DialogDiv_" + this.ID)); //注册拖拽方法148 if (!isIE && this.URL) { //非ie浏览器下在拖拽时用一个层遮住iframe,以免光标移入iframe失去拖拽响应149 var self = this;150 var topWin = this.getWindow();151 this.getWindow().$id("_DialogDiv_" + this.ID).onDragStart = function () {152 topWin.$id("_Covering_" + self.ID).style.display = ""153 }154 this.getWindow().$id("_DialogDiv_" + this.ID).onDragEnd = function () {155 topWin.$id("_Covering_" + self.ID).style.display = "none"156 }157 }158};159Dialog.prototype.displacePath = function () {160 if (this.URL.substr(0, 7) == "http://" || this.URL.substr(0, 1) == "/" || this.URL.substr(0, 11) == "javascript:") {161 return this.URL;162 } else {163 var thisPath = this.URL;164 var locationPath = window.location.href;165 locationPath = locationPath.substring(0, locationPath.lastIndexOf('/'));166 while (thisPath.indexOf('../') >= 0) {167 thisPath = thisPath.substring(3);168 locationPath = locationPath.substring(0, locationPath.lastIndexOf('/'));169 }170 return locationPath + '/' + thisPath;171 }172};173Dialog.prototype.setPosition = function () {174 var bd = $bodyDimensions(this.getWindow());175 var thisTop = this.Top,176 thisLeft = this.Left,177 thisdialogDiv = this.getDialogDiv();178 if (typeof this.Top == "string" && this.Top.substring(this.Top.length - 1, this.Top.length) == "%") {179 var percentT = this.Top.substring(0, this.Top.length - 1) * 0.01;180 thisTop = bd.clientHeight * percentT - thisdialogDiv.scrollHeight * percentT + bd.scrollTop;181 }182 if (typeof this.Left == "string" && this.Left.substring(this.Left.length - 1, this.Left.length) == "%") {183 var percentL = this.Left.substring(0, this.Left.length - 1) * 0.01;184 thisLeft = bd.clientWidth * percentL - thisdialogDiv.scrollWidth * percentL + bd.scrollLeft;185 }186 thisdialogDiv.style.top = Math.round(thisTop) + "px";187 thisdialogDiv.style.left = Math.round(thisLeft) + "px";188};189Dialog.setBgDivSize = function (topWin) {190 var bd = $bodyDimensions(topWin);191 if (Dialog.bgDiv) {192 if (isIE6) {193 Dialog.bgDiv.style.height = bd.clientHeight + "px";194 Dialog.bgDiv.style.top = bd.scrollTop + "px";195 Dialog.bgDiv.childNodes[0].style.display = "none"; //让div重渲染,修正IE6下尺寸bug196 Dialog.bgDiv.childNodes[0].style.display = "";197 } else {198 Dialog.bgDiv.style.height = bd.scrollHeight + "px";199 }200 }201};202Dialog.resetPosition = function (topWin) {203 if (typeof Dialog != "undefined") {204 Dialog.setBgDivSize(topWin);205 for (var i = 0, len = this.getWindow().Dialog._Array.length; i < len; i++) {206 topWin.Dialog._Array[i].setPosition();207 }208 }209};210Dialog.prototype.create = function () {211 var bd = $bodyDimensions(this.getWindow());212 if (typeof (this.OKEvent) == "function") this.ShowButtonRow = true;213 if (!this.Width) this.Width = Math.round(bd.clientWidth * 4 / 10);214 if (!this.Height) this.Height = Math.round(this.Width / 2);215 if (this.MessageTitle || this.Message) this.ShowMessageRow = true;216 var DialogDivWidth = this.Width + 8 + 8;217 var DialogDivHeight = this.Height + 27 + 8 + (this.ShowButtonRow ? 40 : 0) + (this.ShowMessageRow ? 50 : 0);218 if (DialogDivWidth > bd.clientWidth) this.Width = Math.round(bd.clientWidth - 16);219 if (DialogDivHeight > bd.clientHeight) this.Height = Math.round(bd.clientHeight - 35 - (this.ShowButtonRow ? 40 : 0) - (this.ShowMessageRow ? 50 : 0));220 var html = '\221 <div id="_DialogTable_' + this.ID + '" style="width:'+(this.Width)+'px;height:'+(this.Height+35)+'px;background-color: #E1E1E1;box-shadow: 1px 1px 50px rgba(0,0,0,.3);">\222 <div id="_Draghandle_' + this.ID + '" style="' + (this.Drag ? "cursor: move;" : "") + ';height:32px;border-bottom:1px #ddd solid;">\223 <div style="padding: 6px 0 0 6px; float: left; color:#0E2D5F;"><img id="_DialogIcon_' + this.ID + '" align="absmiddle" src="' + IMAGESPATH + 'loading.gif;" style="width:15px;height:15px"/><span id="_Title_' + this.ID + '" style="padding:1px 0px 0px 3px">' + this.Title + '</span></div>\224 <div id="_ButtonClose_' + this.ID + '" onmouseout="this.style.backgroundImage=\'url(' + IMAGESPATH + 'dialog_closebtn.png)\'" onmouseover="this.style.backgroundImage=\'url(' + IMAGESPATH + 'dialog_closebtn_over.png)\'" style="margin-top:3px;margin-right:5px; position: relative; cursor: pointer; float: right; height:26px; width: 26px;background-position:center center; background-image: url(' + IMAGESPATH + 'dialog_closebtn.png);' + (this.ShowCloseButton ? "" : "display:none;") + '"></div>\225 <div id="_ButtonMax_' + this.ID + '" style="margin-top:3px;margin-right:5px; position: relative; cursor: pointer; float: right; height:26px; width: 26px;background-position:center center; background-repeat:no-repeat;background-image: url(' + IMAGESPATH + 'dialog_max.png);' + (this.ShowMaxButton ? "" : "display:none;") + '"></div>\226 </div>\227 <div id="_Container_' + this.ID + '" style="background:#ffffff;position: relative; width: ' + this.Width + 'px; height: ' + (this.Height+2) + 'px;text-align:left;overflow:auto;padding:0px">\228 <div style="position: absolute; height: 100%; width: 100%; display: none; background-color:#fff; opacity: 0.5;" id="_Covering_' + this.ID + '">&nbsp;</div>\229 ' + (function (obj) {230 if (obj.InnerHtml) return obj.InnerHtml;231 if (obj.URL) return '<iframe frameborder="0" style="border:none 0;width:100%;height:100%;display: block;margin:0px;padding:0px;" allowtransparency="true" id="_DialogFrame_' + obj.ID + '" src="' + obj.displacePath() + '"></iframe>';232 return "";233 })(this) + '\234 </div>\235 <div id="_ButtonRow_' + this.ID + '" style="' + (this.ShowButtonRow ? "" : "display:none") + '">\236 <div id="_DialogButtons_' + this.ID + '" style="border: 1px solid #95B8E7;border-width:0px; padding: 4px 10px; text-align: right; background-color:#f6f6f6;">\237 <input type="button" class="layui-btn layui-btn-mini" value="确 定" id="_ButtonOK_' + this.ID + '" style="margin:0px 10px;width:55px"/>\238 <input type="button" class="layui-btn layui-btn-warm layui-btn-mini" value="取 消" id="_ButtonCancel_' + this.ID + '" style="margin: 0px 10px;width:55px"/>\239 </div>\240 </div>\241 </div>\242 '243 var div = this.getWindow().$id("_DialogDiv_" + this.ID);244 if (!div) {245 div = this.getWindow().document.createElement("div");246 div.id = "_DialogDiv_" + this.ID;247 div.style.border = "1px #ccc solid";248 this.getWindow().document.getElementsByTagName("BODY")[0].appendChild(div);249 }250 div.style.position = "absolute";251 div.style.left = "-9999px";252 div.style.top = "-9999px";253 div.innerHTML = html;254 if (this.InvokeElementId) {255 var element = $id(this.InvokeElementId);256 element.style.position = "";257 element.style.display = "";258 if (!this.ShowTop) {259 this.getWindow().$id("_Covering_" + this.ID).parentNode.appendChild(element)260 } else {261 if (isIE) {262 var fragment = this.getWindow().document.createElement("div");263 fragment.innerHTML = element.outerHTML;264 element.outerHTML = "";265 this.getWindow().$id("_Covering_" + this.ID).parentNode.appendChild(fragment)266 } else {267 this.getWindow().$id("_Covering_" + this.ID).parentNode.appendChild(element)268 }269 }270 }271 this.parentWindow = window;272 if (this.URL) {273 if (this.getWindow().$id("_DialogFrame_" + this.ID)) {274 this.innerFrame = this.getWindow().$id("_DialogFrame_" + this.ID);275 };276 var self = this;277 innerFrameOnload = function () {278 try {279 self.innerWin = self.innerFrame.contentWindow;280 self.innerWin.parentDialog = self;281 self.innerDoc = self.innerWin.document;282 if (!self.Title && self.innerDoc && self.innerDoc.title) {283 if (self.innerDoc.title) self.getWindow().$id("_Title_" + self.ID).innerHTML = self.innerDoc.title;284 }285 if(self.getWindow().$id("_DialogIcon_" + self.ID)){286 self.getWindow().$id("_DialogIcon_" + self.ID).src = IMAGESPATH+"icon_dialog.gif";287 }288 } catch (e) {289 if (console && console.log) console.log(e)290 }291 if (typeof (self.OnLoad) == "function") self.OnLoad();292 self.innerWin.document.body.focus();293 };294 if (this.innerFrame.attachEvent) {295 this.innerFrame.attachEvent("onload", innerFrameOnload);296 } else {297 this.innerFrame.onload = innerFrameOnload;298 };299 }else{300 if(this.getWindow().$id("_DialogIcon_" + this.ID)){301 this.getWindow().$id("_DialogIcon_" + this.ID).src = IMAGESPATH+"icon_dialog.gif";302 }303 var thisWin =this.getWindow();304// window.setTimeout(function(){305// var inputs = $("input[type='text']",thisWin.$id("_Container_" + this.ID));306// if(inputs.length>0){307// $(inputs[0]).focus();308// }309// },10)310 311 }312 this.getWindow().$id("_DialogDiv_" + this.ID).dialogId = this.ID;313 this.getWindow().$id("_DialogDiv_" + this.ID).dialogInstance = this;314 this.attachBehaviors();315 this.okButton = this.getWindow().$id("_ButtonOK_" + this.ID);316 this.cancelButton = this.getWindow().$id("_ButtonCancel_" + this.ID);317 this.closeButton = this.getWindow().$id("_ButtonClose_" + this.ID);318 this.maxButton = this.getWindow().$id("_ButtonMax_" + this.ID);319 var topWin = this.getWindow();320 var id = this.ID;321 var self = this;322 $(this.cancelButton).bind("click", function () {323 self.close();324 });325 $(this.closeButton).bind("click", function () {326 if (self.CallBack != null) {327 self.CallBack(null)328 }329 self.close();330 });331 $(this.maxButton).bind("click", function () {332 self.maxAndReset();333 if (self.MaxCallBack != null) {334 self.MaxCallBack(null)335 }336 });337 div = null;338};339Dialog.prototype.setSize = function (w, h) {340 if (w && w > 20) {341 this.Width = w;342 this.getWindow().$id("_Container_" + this.ID).style.width = this.Width + "px";343 this.getWindow().$id("_DialogTable_" + this.ID).style.width = this.Width+ "px";344 }345 if (h && +h > 10) {346 this.Height = +h;347 this.getWindow().$id("_Container_" + this.ID).style.height = (this.Height-66) + "px";348 this.getWindow().$id("_DialogTable_" + this.ID).style.height = (this.Height)+ "px";349 }350 this.setPosition();351};352Dialog.prototype.maxAndReset = function () {353 if(this.maxed == null || this.maxed !=true){354 this.orgWidth = this.Width;355 this.orgHeight = this.Height;356 this.maxed =true;357 358 var bd = $bodyDimensions(this.getWindow());359 this.Width = Math.round(bd.clientWidth - 10);360 this.Height = Math.round(bd.clientHeight - 35 - (this.ShowButtonRow ? 40 : 0) - (this.ShowMessageRow ? 50 : 0));361 362 this.getWindow().$id("_Container_" + this.ID).style.width = this.Width + "px";363 this.getWindow().$id("_DialogTable_" + this.ID).style.width = this.Width+ "px";364 365 this.getWindow().$id("_Container_" + this.ID).style.height = (this.Height) + "px";366 this.getWindow().$id("_DialogTable_" + this.ID).style.height = (this.Height-66)+ "px";367 }else{368 this.Width = this.orgWidth;369 this.Height = this.orgHeight;370 this.maxed = null;371 372 this.getWindow().$id("_Container_" + this.ID).style.width = this.Width + "px";373 this.getWindow().$id("_DialogTable_" + this.ID).style.width = this.Width+ "px";374 375 this.getWindow().$id("_Container_" + this.ID).style.height = (this.Height) + "px";376 this.getWindow().$id("_DialogTable_" + this.ID).style.height = (this.Height-66)+ "px";377 }378 this.setPosition();379};380Dialog.prototype.show = function () {381 this.create();382 var bgdiv = Dialog.getBgdiv(this.getWindow()),383 thisdialogDiv = this.getDialogDiv();384 this.zindex = thisdialogDiv.style.zIndex = parseInt(this.getWindow().Dialog.bgDiv.style.zIndex) + 1;385 if (this.getWindow().Dialog._Array.length > 0) {386 this.zindex = thisdialogDiv.style.zIndex = this.getWindow().Dialog._Array[this.getWindow().Dialog._Array.length - 1].zindex + 2;387 } else {388 var topWinBody = this.getWindow().document.getElementsByTagName(this.getWindow().document.compatMode == "BackCompat" ? "BODY" : "HTML")[0];389 //topWinBody.styleOverflow = topWinBody.style.overflow; 去除滚动条390 //topWinBody.style.overflow = "hidden"; 去除滚动条391 bgdiv.style.display = "none";392 }393 this.getWindow().Dialog._Array.push(this);394 if (this.Modal) {395 bgdiv.style.zIndex = this.getWindow().Dialog._Array[this.getWindow().Dialog._Array.length - 1].zindex - 1;396 Dialog.setBgDivSize(this.getWindow());397 if (bgdiv.style.display == "none") {398 if (this.Animator) {399 var bgMask = this.getWindow().$id("_DialogBGMask");400 bgMask.style.opacity = 0;401 bgMask.style.filter = "alpha(opacity=0)";402 bgdiv.style.display = "";403 fadeEffect(bgMask, 0, 40, isIE6 ? 20 : 10);404 bgMask = null;405 } else {406 bgdiv.style.display = "";407 }408 }409 }410 this.setPosition();411 if (this.CancelEvent) {412 this.cancelButton.onclick = this.CancelEvent;413 if (this.ShowButtonRow) this.cancelButton.focus();414 }415 if (this.OKEvent) {416 this.okButton.onclick = this.OKEvent;417 if (this.ShowButtonRow) this.okButton.focus();418 }419 if (this.AutoClose && this.AutoClose > 0) this.autoClose();420 this.opened = true;421 bgdiv = null;422};423Dialog.prototype.close = function () {424 var thisdialogDiv = this.getDialogDiv();425 if (this == this.getWindow().Dialog._Array[this.getWindow().Dialog._Array.length - 1]) {426 var isTopDialog = this.getWindow().Dialog._Array.pop();427 } else {428 this.getWindow().Dialog._Array.remove(this)429 }430 if (this.InvokeElementId) {431 var innerElement = this.getWindow().$id(this.InvokeElementId);432 innerElement.style.display = "none";433 if (!this.ShowTop) {434 document.getElementsByTagName("BODY")[0].appendChild(innerElement)435 } else {436 if (isIE) {437 //ie下不能跨窗口拷贝元素,只能跨窗口拷贝html代码438 var fragment = document.createElement("div");439 fragment.innerHTML = innerElement.outerHTML;440 innerElement.outerHTML = "";441 document.getElementsByTagName("BODY")[0].appendChild(fragment)442 } else {443 document.getElementsByTagName("BODY")[0].appendChild(innerElement)444 }445 }446 }447 if (this.getWindow().Dialog._Array.length > 0) {448 if (this.Modal && isTopDialog) this.getWindow().Dialog.bgDiv.style.zIndex = parseInt(this.getWindow().Dialog._Array[this.getWindow().Dialog._Array.length - 1].zindex) - 1;449 } else {450 this.getWindow().Dialog.bgDiv.style.zIndex = "900";451 this.getWindow().Dialog.bgDiv.style.display = "none";452 var topWinBody = this.getWindow().document.getElementsByTagName(this.getWindow().document.compatMode == "BackCompat" ? "BODY" : "HTML")[0];453 //if (topWinBody.styleOverflow != undefined) topWinBody.style.overflow = topWinBody.styleOverflow; 去除滚动条454 }455 if (isIE) {456 /*****释放引用,以便浏览器回收内存**/457 thisdialogDiv.dialogInstance = null;458 if (this.innerFrame) this.innerFrame.detachEvent("onload", innerFrameOnload);459 this.innerFrame = null;460 this.parentWindow = null;461 this.bgDiv = null;462 if (this.CancelEvent) { this.cancelButton.onclick = null; };463 if (this.OKEvent) { this.okButton.onclick = null; };464 this.getWindow().$id("_DialogDiv_" + this.ID).onDragStart = null;465 this.getWindow().$id("_DialogDiv_" + this.ID).onDragEnd = null;466 this.getWindow().$id("_Draghandle_" + this.ID).onmousedown = null;467 this.getWindow().$id("_Draghandle_" + this.ID).root = null;468 /**end释放引用**/469 thisdialogDiv.outerHTML = "";470 if(typeof(CollectGarbage)=="function"){471 CollectGarbage();472 }473 474 } else {475 var RycDiv = this.getWindow().$id("_RycDiv");476 if (!RycDiv) {477 RycDiv = this.getWindow().document.createElement("div");478 RycDiv.id = "_RycDiv";479 }480 RycDiv.appendChild(thisdialogDiv);481 RycDiv.innerHTML = "";482 RycDiv = null;483 }484 thisdialogDiv = null;485 this.closed = true;486};487Dialog.prototype.autoClose = function () {488 if (this.closed) {489 clearTimeout(this._closeTimeoutId);490 return;491 }492 this.AutoClose -= 1;493 this.getWindow().$id("_Title_" + this.ID).innerHTML = this.AutoClose + " 秒后自动关闭";494 if (this.AutoClose <= 0) {495 this.close();496 } else {497 var self = this;498 this._closeTimeoutId = setTimeout(function () {499 self.autoClose();500 },501 1000);502 }503};504Dialog.getInstance = function (topWin, id) {505 var dialogDiv = topWin.$id("_DialogDiv_" + id);506 if (!dialogDiv) alert("没有取到对应ID的弹出框页面对象");507 try {508 return dialogDiv.dialogInstance;509 } finally {510 dialogDiv = null;511 }512};513Dialog.prototype.addButton = function (id, txt, func) {514 this.getWindow().$id("_ButtonRow_" + this.ID).style.display = "";515 this.ShowButtonRow = true;516 var button = this.getWindow().document.createElement("input");517 button.id = "_Button_" + this.ID + "_" + id;518 button.type = "button";519 button.style.cssText = "margin:0px 10px;padding:0px 10px;";520 button.value = txt;521 button.onclick = func;522 button.className = "layui-btn layui-btn-mini layui-btn-normal";523 var input0 = this.getWindow().$id("_DialogButtons_" + this.ID).getElementsByTagName("INPUT")[0];524 input0.parentNode.insertBefore(button, input0);525 return button;526};527Dialog.prototype.removeButton = function (btn) {528 var input0 = this.getWindow().$id("_DialogButtons_" + this.ID).getElementsByTagName("INPUT")[0];529 input0.parentNode.removeChild(btn);530};531Dialog.getBgdiv = function (topWin) {532 if (topWin.Dialog.bgDiv) return topWin.Dialog.bgDiv;533 var bgdiv = topWin.$id("_DialogBGDiv");534 if (!bgdiv) {535 bgdiv = topWin.document.createElement("div");536 bgdiv.id = "_DialogBGDiv";537 bgdiv.style.cssText = "position:absolute;left:0px;top:0px;width:100%;height:100%;z-index:900";538 var bgIframeBox = '<div style="position:relative;width:100%;height:100%;">';539 var bgIframeMask = '<div id="_DialogBGMask" style="position:absolute;background-color:#000;opacity:0.2;filter:alpha(opacity=20);width:100%;height:100%;"></div>';540 var bgIframe = isIE || isShowBgIframe ? '<iframe src="about:blank" style="filter:alpha(opacity=0);border:none 0;" width="100%" height="100%" ></iframe>' : '';541 bgdiv.innerHTML = bgIframeBox + bgIframeMask + bgIframe + '</div>';542 topWin.document.getElementsByTagName("BODY")[0].appendChild(bgdiv);543 if (isIE6) {544 var bgIframeDoc = bgdiv.getElementsByTagName("IFRAME")[0].contentWindow.document;545 bgIframeDoc.open();546 bgIframeDoc.write("<body style='background-color:#000' oncontextmenu='return false;'></body>");547 bgIframeDoc.close();548 bgIframeDoc = null;549 }550 }551 topWin.Dialog.bgDiv = bgdiv;552 bgdiv = null;553 return topWin.Dialog.bgDiv;554};555Dialog.prototype.getDialogDiv = function () {556 var dialogDiv = this.getWindow().$id("_DialogDiv_" + this.ID)557 if (!dialogDiv) alert("获取弹出层页面对象出错!");558 try {559 return dialogDiv;560 } finally {561 dialogDiv = null;562 }563};564Dialog.onKeyDown = function (event) {565 if (event.shiftKey && event.keyCode == 9) { //shift键566 if (topWin.Dialog._Array.length > 0) {567 stopEvent(event);568 return false;569 }570 }...

Full Screen

Full Screen

WSReport.js

Source:WSReport.js Github

copy

Full Screen

...77 this.deleteQuotaReturnSubscribe(data1);78 break;79 //ws重连超过最大次数80 case 14:81 this.mainWindow.getWindow().send("crossMaxReconnectCount");82 break;83 //持仓订阅84 case 15:85 this.positionReturnSubscribe(data1, data2);86 break;87 //持仓推送88 case 16:89 this.positionReturnReceive(data1);90 break;91 //资金订阅92 case 17:93 this.balanceSubscribe(data1, data2);94 break;95 //资金推送96 case 18:97 this.balanceReceive(data1);98 break;99 //理论价行情订阅100 case 19:101 this.theoryPriceSubscribe(data1, data2);102 break;103 //理论价行情推送104 case 20:105 this.theoryPriceReceive(data1);106 break;107 //删除理论价行情订阅108 case 21:109 this.deleteTheoryPriceSubscribe(data1);110 break;111 //做市委托回报价格订阅112 case 30:113 this.quoteTotalTradePriceSubscribe(data1, data2);114 break;115 //做市委托回报持仓订阅116 case 31:117 this.quoteTotalTradePositionSubscribe(data1, data2);118 break;119 //做市委托回报价格接收120 case 32:121 this.quoteTotalTradePriceReceive(data1);122 break;123 //做市委托回报持仓接收124 case 33:125 this.quoteTotalTradePositionReceive(data1);126 break;127 //做市策略设置订阅128 case 24:129 this.markerStrategySubscribe(data1, data2);130 break;131 //做市策略设置接收132 case 25:133 this.markerStrategyReceive(data1);134 break;135 //删除做市策略设置订阅136 case 26:137 this.deleteMarkerStrategySubscribe(data1);138 break;139 //用户开关订阅140 case 27:141 this.userSwitchSubscribe(data1, data2);142 break;143 //用户开关订阅接收144 case 28:145 this.userSwitchReceive(data1);146 break;147 //atm订阅148 case 34:149 this.atmInfolSubscribe(data1, data2);150 break;151 //删除atm订阅152 case 35:153 this.DeleteatmInfolSubscribe(data1);154 break;155 //atm订阅接收156 case 36:157 this.atmInfoReceive(data1);158 break;159 //期货做市订阅160 case 38:161 this.futureMakerHedgeSubscribe(data1, data2);162 break;163 //期货做市接收164 case 39:165 this.futureMakerHedgeStatusReceive(data1);166 break;167 }168 }169 setMainWindow(mainWindow){170 this.mainWindow = mainWindow;171 }172 /**173 * 委托订阅174 * @param data1175 * @param data2176 */177 orderReturnSubscribe(data1, data2){178 if (this.mainWindow && this.mainWindow.getWindow()) {179 if (data1 && data2 && data2 !== -1) {180 this.mainWindow.getWindow().send('orderReturnSubscribe', data1);181 let windowId = Number(data2);182 if (this.orderReturnWindowIds.indexOf(windowId) == -1) {183 this.orderReturnWindowIds.push(windowId);184 }185 if (this.totalSubscribeWindowIds.indexOf(windowId) == -1) {186 this.totalSubscribeWindowIds.push(windowId);187 }188 } else {189 this.mainWindow.getWindow().send("subscribeError", "orderReturnSubscribe", data1, data2);190 }191 }192 }193 /**194 * atm订阅195 * @param data1196 * @param data2197 */198 atmInfolSubscribe(data1, data2){199 if (this.mainWindow && this.mainWindow.getWindow()) {200 if (data1 && data2 && data2 !== -1) {201 this.mainWindow.getWindow().send('atmInfoReturnSubscribe', data1);202 let windowId = Number(data2);203 if (this.atmReturnWindowIds.indexOf(windowId) == -1) {204 this.atmReturnWindowIds.push(windowId);205 }206 if (this.totalSubscribeWindowIds.indexOf(windowId) == -1) {207 this.totalSubscribeWindowIds.push(windowId);208 }209 } else {210 this.mainWindow.getWindow().send("subscribeError", "atmInfoReturnSubscribe", data1, data2);211 }212 }213 }214 /**215 * 委托回报接收216 * @param data1217 */218 orderReturnReceive(data1){219 if (this.mainWindow && this.mainWindow.getWindow()) {220 for (let i = 0; i < this.orderReturnWindowIds.length; i++) {221 let window = BrowserWindow.fromId(this.orderReturnWindowIds[i]);222 if (window != null) {223 window.send('orderReturn', data1)224 }225 }226 }227 }228 /**229 * 成交回报订阅230 * @param data1231 * @param data2232 */233 tradeReturnSubscribe(data1, data2){234 if (this.mainWindow && this.mainWindow.getWindow()) {235 if (data1 && data2 && data2 !== -1) {236 this.mainWindow.getWindow().send('tradeReturnSubscribe', data1);237 let windowId = Number(data2);238 if (this.tradeReturnWindowIds.indexOf(windowId) == -1) {239 this.tradeReturnWindowIds.push(windowId);240 }241 if (this.totalSubscribeWindowIds.indexOf(windowId) == -1) {242 this.totalSubscribeWindowIds.push(windowId);243 }244 } else {245 this.mainWindow.getWindow().send("subscribeError", "tradeReturnSubscribe", data1, data2);246 }247 }248 }249 tradeReturnReceive(data1){250 if (this.mainWindow && this.mainWindow.getWindow()) {251 for (let i = 0; i < this.tradeReturnWindowIds.length; i++) {252 let window = BrowserWindow.fromId(this.tradeReturnWindowIds[i]);253 if (window != null) {254 window.send('tradeReturn', data1)255 }256 }257 }258 }259 /**260 * 行情订阅261 * @param data1262 * @param data2263 */264 optionalSubscribe(data1, data2){265 if (this.mainWindow && this.mainWindow.getWindow()) {266 if (data1 && data2 && data2 !== -1) {267 this.mainWindow.getWindow().send('optionSubscribe', data1);268 let windowId = Number(data2);269 if (this.optionalReturnWindowIds.indexOf(windowId) == -1) {270 this.optionalReturnWindowIds.push(windowId);271 }272 if (this.totalSubscribeWindowIds.indexOf(windowId) == -1) {273 this.totalSubscribeWindowIds.push(windowId);274 }275 } else {276 this.mainWindow.getWindow().send("subscribeError", "optionalSubscribe", data1, data2);277 }278 }279 }280 /**281 * 行情接收282 * @param data1283 */284 optionalReceive(data1){285 if (this.mainWindow && this.mainWindow.getWindow()) {286 for (let i = 0; i < this.optionalReturnWindowIds.length; i++) {287 let window = BrowserWindow.fromId(this.optionalReturnWindowIds[i]);288 if (window != null) {289 window.send('optional', data1);290 }291 }292 }293 }294 /**295 * atmInfo接收296 * @param data1297 */298 atmInfoReceive(data1){299 if (this.mainWindow && this.mainWindow.getWindow()) {300 for (let i = 0; i < this.atmReturnWindowIds.length; i++) {301 let window = BrowserWindow.fromId(this.atmReturnWindowIds[i]);302 if (window != null) {303 window.send('atmInfoReturn', data1);304 }305 }306 }307 }308 /**309 * 期货做市商接收310 * @param data1311 */312 futureMakerHedgeStatusReceive(data1){313 if (this.mainWindow && this.mainWindow.getWindow()) {314 for (let i = 0; i < this.futureMakerReturnWindowIds.length; i++) {315 let window = BrowserWindow.fromId(this.futureMakerReturnWindowIds[i]);316 if (window != null) {317 window.send('futureMakerHedgeStatusReturn', data1);318 }319 }320 }321 }322 /**323 * 删除atm行情订阅324 * @param data1325 */326 DeleteatmInfolSubscribe(data1){327 if (this.mainWindow && this.mainWindow.getWindow()) {328 this.mainWindow.getWindow().send('deleteAtmSubscribe', data1);329 }330 }331 /**332 * 删除行情订阅333 * @param data1334 */335 deleteOptionalSubscribe(data1){336 if (this.mainWindow && this.mainWindow.getWindow()) {337 this.mainWindow.getWindow().send('deleteOptionalSubscribe', data1);338 }339 }340 /**341 * 重连342 */343 wsReconnect(){344 if (this.mainWindow && this.mainWindow.getWindow()) {345 for (let i = 0; i < this.totalSubscribeWindowIds.length; i++) {346 let window = BrowserWindow.fromId(this.totalSubscribeWindowIds[i]);347 if (window != null) {348 window.send('wsReconnect');349 }350 }351 }352 }353 /**354 * 指令订阅355 * @param data1356 * @param data2357 */358 instructionSubscribe(data1, data2){359 if (this.mainWindow && this.mainWindow.getWindow()) {360 if (data2) {361 this.mainWindow.getWindow().send('instructionSubscribe', data1);362 let windowId = Number(data2);363 if (this.strategyReturnWindowIds.indexOf(windowId) == -1) {364 this.strategyReturnWindowIds.push(windowId);365 }366 if (this.totalSubscribeWindowIds.indexOf(windowId) == -1) {367 this.totalSubscribeWindowIds.push(windowId);368 }369 } else {370 this.mainWindow.getWindow().send("subscribeError", "instructionSubscribe", data1, data2);371 }372 }373 }374 /**375 * 指令接收376 * @param data1377 */378 instructionReceive(data1){379 if (this.mainWindow && this.mainWindow.getWindow()) {380 for (let i = 0; i < this.strategyReturnWindowIds.length; i++) {381 let window = BrowserWindow.fromId(this.strategyReturnWindowIds[i]);382 if (window != null) {383 window.send('instructionReturn', data1);384 }385 }386 }387 }388 /**389 * 指标订阅390 * @param data1391 * @param data2392 */393 quotaReturnSubscribe(data1, data2){394 if (this.mainWindow && this.mainWindow.getWindow()) {395 if (data2) {396 this.mainWindow.getWindow().send('quotaReturnSubscribe', data1);397 let windowId = Number(data2);398 if (this.quotaReturnWindowIds.indexOf(windowId) == -1) {399 this.quotaReturnWindowIds.push(windowId);400 }401 if (this.totalSubscribeWindowIds.indexOf(windowId) == -1) {402 this.totalSubscribeWindowIds.push(windowId);403 }404 } else {405 this.mainWindow.getWindow().send("subscribeError", "quotaReturnSubscribe", data1, data2);406 }407 }408 }409 /**410 * 指标接收411 * @param data1412 */413 quotaReturnReceive(data1){414 if (this.mainWindow && this.mainWindow.getWindow()) {415 for (let i = 0; i < this.quotaReturnWindowIds.length; i++) {416 let window = BrowserWindow.fromId(this.quotaReturnWindowIds[i]);417 if (window != null) {418 window.send('quotaReturn', data1);419 }420 }421 }422 }423 /**424 * 删除指标订阅425 * @param data1426 */427 deleteQuotaReturnSubscribe(data1){428 if (this.mainWindow && this.mainWindow.getWindow()) {429 this.mainWindow.getWindow().send('deleteQuotaReturnSubscribe', data1);430 }431 }432 /**433 * 持仓订阅434 * @param data1435 * @param data2436 */437 positionReturnSubscribe(data1, data2){438 if (this.mainWindow && this.mainWindow.getWindow()) {439 if (data2) {440 this.mainWindow.getWindow().send('positionReturnSubscribe', data1);441 let windowId = Number(data2);442 if (this.positionReturnWindowIds.indexOf(windowId) == -1) {443 this.positionReturnWindowIds.push(windowId);444 }445 if (this.totalSubscribeWindowIds.indexOf(windowId) == -1) {446 this.totalSubscribeWindowIds.push(windowId);447 }448 } else {449 this.mainWindow.getWindow().send("subscribeError", "positionReturnSubscribe", data1, data2);450 }451 }452 }453 /**454 * 持仓接收455 * @param data1456 */457 positionReturnReceive(data1){458 if (this.mainWindow && this.mainWindow.getWindow()) {459 for (let i = 0; i < this.positionReturnWindowIds.length; i++) {460 let window = BrowserWindow.fromId(this.positionReturnWindowIds[i]);461 if (window != null) {462 window.send('positionReturn', data1);463 }464 }465 }466 }467 /**468 * 资金订阅469 * @param data1470 * @param data2471 */472 balanceSubscribe(data1, data2){473 if (this.mainWindow && this.mainWindow.getWindow()) {474 if (data2) {475 this.mainWindow.getWindow().send('portfolioBalanceSubscribe', data1);476 let windowId = Number(data2);477 if (this.portfolioBalanceReturnWindowIds.indexOf(windowId) == -1) {478 this.portfolioBalanceReturnWindowIds.push(windowId);479 }480 if (this.totalSubscribeWindowIds.indexOf(windowId) == -1) {481 this.totalSubscribeWindowIds.push(windowId);482 }483 } else {484 this.mainWindow.getWindow().send("subscribeError", "portfolioBalanceSubscribe", data1, data2);485 }486 }487 }488 /**489 * 资金订阅接收490 * @param data1491 */492 balanceReceive(data1){493 if (this.mainWindow && this.mainWindow.getWindow()) {494 for (let i = 0; i < this.portfolioBalanceReturnWindowIds.length; i++) {495 let window = BrowserWindow.fromId(this.portfolioBalanceReturnWindowIds[i]);496 if (window != null) {497 window.send('portfolioBalanceReturn', data1);498 }499 }500 }501 }502 /**503 * 理论价订阅504 * @param data1505 * @param data2506 */507 theoryPriceSubscribe(data1, data2){508 if (this.mainWindow && this.mainWindow.getWindow()) {509 if (data2) {510 this.mainWindow.getWindow().send('theoryPriceSubscribe', data1);511 let windowId = Number(data2);512 if (this.theoryPriceReturnWindowIds.indexOf(windowId) == -1) {513 this.theoryPriceReturnWindowIds.push(windowId);514 }515 if (this.totalSubscribeWindowIds.indexOf(windowId) == -1) {516 this.totalSubscribeWindowIds.push(windowId);517 }518 } else {519 this.mainWindow.getWindow().send("subscribeError", "theoryPriceSubscribe", data1, data2);520 }521 }522 }523 /**524 * 理论价接收525 * @param data1526 */527 theoryPriceReceive(data1){528 if (this.mainWindow && this.mainWindow.getWindow()) {529 for (let i = 0; i < this.theoryPriceReturnWindowIds.length; i++) {530 let window = BrowserWindow.fromId(this.theoryPriceReturnWindowIds[i]);531 if (window != null) {532 window.send('theoryPriceReturn', data1);533 }534 }535 }536 }537 /**538 * 删除理论价订阅539 * @param data1540 */541 deleteTheoryPriceSubscribe(data1){542 if (this.mainWindow && this.mainWindow.getWindow()) {543 this.mainWindow.getWindow().send('deleteTheoryPriceSubscribe', data1);544 }545 }546 /**547 * 做市委托回报价格订阅548 * @param data1549 * @param data2550 */551 quoteTotalTradePriceSubscribe(data1, data2){552 if (this.mainWindow && this.mainWindow.getWindow()) {553 if (data2) {554 this.mainWindow.getWindow().send('quoteTotalTradePriceSubscribe', data1);555 let windowId = Number(data2);556 if (this.quoteTotalTradeWindowIds.indexOf(windowId) == -1) {557 this.quoteTotalTradeWindowIds.push(windowId);558 }559 if (this.totalSubscribeWindowIds.indexOf(windowId) == -1) {560 this.totalSubscribeWindowIds.push(windowId);561 }562 } else {563 this.mainWindow.getWindow().send("subscribeError", "quoteTotalTradePriceSubscribe", data1, data2);564 }565 }566 }567 /**568 * 做市委托回报持仓订阅569 * @param data1570 * @param data2571 */572 quoteTotalTradePositionSubscribe(data1, data2){573 if (this.mainWindow && this.mainWindow.getWindow()) {574 if (data2) {575 this.mainWindow.getWindow().send('quoteTotalTradePositionSubscribe', data1);576 let windowId = Number(data2);577 if (this.quoteTotalTradePositionWindowIds.indexOf(windowId) == -1) {578 this.quoteTotalTradePositionWindowIds.push(windowId);579 }580 if (this.totalSubscribeWindowIds.indexOf(windowId) == -1) {581 this.totalSubscribeWindowIds.push(windowId);582 }583 } else {584 this.mainWindow.getWindow().send("subscribeError", "quoteTotalTradePositionSubscribe", data1, data2);585 }586 }587 }588 /**589 * 做市委托回报价格接收590 * @param data1591 */592 quoteTotalTradePriceReceive(data1){593 if (this.mainWindow && this.mainWindow.getWindow()) {594 for (let i = 0; i < this.quoteTotalTradeWindowIds.length; i++) {595 let window = BrowserWindow.fromId(this.quoteTotalTradeWindowIds[i]);596 if (window != null) {597 window.send('quoteTotalTradePriceReturn', data1);598 }599 }600 }601 }602 /**603 * 做市委托回报持仓接收604 * @param data1605 */606 quoteTotalTradePositionReceive(data1){607 if (this.mainWindow && this.mainWindow.getWindow()) {608 for (let i = 0; i < this.quoteTotalTradePositionWindowIds.length; i++) {609 let window = BrowserWindow.fromId(this.quoteTotalTradePositionWindowIds[i]);610 if (window != null) {611 window.send('quoteTotalTradePositionReturn', data1);612 }613 }614 }615 }616 /**617 * 做市策略设置订阅618 * @param data1619 * @param data2620 */621 markerStrategySubscribe(data1, data2){622 if (this.mainWindow && this.mainWindow.getWindow()) {623 if (data2) {624 this.mainWindow.getWindow().send('markerStrategySubscribe', data1);625 let windowId = Number(data2);626 if (this.markerStrategyReturnWindowIds.indexOf(windowId) == -1) {627 this.markerStrategyReturnWindowIds.push(windowId);628 }629 if (this.totalSubscribeWindowIds.indexOf(windowId) == -1) {630 this.totalSubscribeWindowIds.push(windowId);631 }632 } else {633 this.mainWindow.getWindow().send("subscribeError", "markerStrategySubscribe", data1, data2);634 }635 }636 }637 /**638 * 期货对冲报价订阅639 * @param data1640 * @param data2641 */642 futureMakerHedgeSubscribe(data1, data2){643 if (this.mainWindow && this.mainWindow.getWindow()) {644 if (data2) {645 this.mainWindow.getWindow().send('futureMakerHedgeStatusSubscribe', data1);646 let windowId = Number(data2);647 if (this.futureMakerReturnWindowIds.indexOf(windowId) == -1) {648 this.futureMakerReturnWindowIds.push(windowId);649 }650 if (this.totalSubscribeWindowIds.indexOf(windowId) == -1) {651 this.totalSubscribeWindowIds.push(windowId);652 }653 } else {654 this.mainWindow.getWindow().send("subscribeError", "futureMakerHedgeStatusSubscribe", data1, data2);655 }656 }657 }658 /**659 * 做市策略设置接收660 * @param data1661 */662 markerStrategyReceive(data1){663 if (this.mainWindow && this.mainWindow.getWindow()) {664 for (let i = 0; i < this.markerStrategyReturnWindowIds.length; i++) {665 let window = BrowserWindow.fromId(this.markerStrategyReturnWindowIds[i]);666 if (window != null) {667 window.send('markerStrategyReturn', data1);668 }669 }670 }671 }672 /**673 * 删除做市策略设置订阅674 * @param data1675 */676 deleteMarkerStrategySubscribe(data1){677 if (this.mainWindow && this.mainWindow.getWindow()) {678 this.mainWindow.getWindow().send('deleteMarkerStrategySubscribe', data1);679 }680 }681 /**682 * user开关订阅683 * @param data1684 * @param data2685 */686 userSwitchSubscribe(data1, data2){687 if (this.mainWindow && this.mainWindow.getWindow()) {688 if (data2) {689 this.mainWindow.getWindow().send('userSwitchSubscribe', data1);690 this.userSwitchWindowId = Number(data2);691 } else {692 this.mainWindow.getWindow().send("subscribeError", "userSwitchSubscribe", data1, data2);693 }694 }695 }696 /**697 * user开关订阅接收698 * @param data1699 */700 userSwitchReceive(data1){701 if (this.mainWindow && this.mainWindow.getWindow()) {702 let window = BrowserWindow.fromId(this.userSwitchWindowId);703 if (window != null) {704 window.send('userSwitchReturn', data1);705 }706 }707 }708}...

Full Screen

Full Screen

window.js

Source:window.js Github

copy

Full Screen

...119 this.getPageIndicator().hide();120 }121 },122 show: function () {123 $('body').append(this.getWindow());124 this.getWindow().show();125 var top = $(document).scrollTop() + 15;126 $(this.getWindow()).offset({top: top});127 },128 hide: function () {129 this.getWindow().hide();130 },131 updatePosition: function () {132 //this.getWindowPreviewBody().width(this.getLoadedPreviewImgEl().width() + 100);133 if (this.getLoadedPreviewImgEl().width() > this.getWindow().width()) {134 this.getLoadedPreviewImgEl().width(this.getWindow().width());135 }136 var width = this.getWindow().width();137 this.getWindow().css('margin-left', -width / 2);138 },139 startHidePageIndicatorTimer: function () {140 this.stopHidePageIndicatorTimer();141 this.hide_page_indicator_timer = setTimeout($.proxy(this.onAutoHidePageIndicator, this), this.hide_page_indicator_delay);142 },143 stopHidePageIndicatorTimer: function () {144 if (this.hide_page_indicator_timer) {145 clearTimeout(this.hide_page_indicator_timer);146 this.hide_page_indicator_timer = null;147 }148 },149 hasServeralWebPreviews: function () {150 return this.web_preview_count > 0;151 },152 getWebPreview: function () {153 return $('.web-preview', this.getWindow());154 },155 getNextButton: function () {156 return $('.next', this.getWindow());157 },158 getPrevButton: function () {159 return $('.prev', this.getWindow());160 },161 getPageIndicatorNumbers: function () {162 return $('.numbers', this.getPageIndicator());163 },164 getPageIndicator: function () {165 return $('.page-indicator', this.getWindow());166 },167 getFilePreviewLink: function () {168 return $('a', this.getFilePreview());169 },170 getFilePreviewIcon: function () {171 return $('.ext-icon', this.getFilePreview());172 },173 getFilePreviewName: function () {174 return $('.name', this.getFilePreview());175 },176 getFilePreview: function () {177 return $('.preview', this.getWindow());178 },179 getSourcesBlock: function () {180 return $('.sources', this.getWindow());181 },182 getCloseButton: function () {183 return $('.close', this.getWindow());184 },185 getHeader: function () {186 return $('.header', this.getWindow());187 },188 getLoader: function () {189 return $('.loader', this.getWindow());190 },191 getWindow: function () {192 return $(this.selector);193 },194 onLoad: function (data) {195 this.applyData(data);196 },197 onClickCloseButton: function () {198 this.hide();199 },200 onLoadPreview: function () {201 this.getWindow().width('auto');202 setTimeout($.proxy(function () {203 this.updatePosition();204 this.showWebPreview();205 this.getWindow().width(this.getWindow().width());206 }, this), 50);207 },208 onClickNext: function () {209 this.next();210 },211 onClickPrev: function () {212 this.prev();213 },214 onClickButton: function (e) {215 if ($(e.target).closest('a').length == 0) {216 $('a', e.target).clickAnchor();217 }218 },219 onAutoHidePageIndicator: function () {220 if (this.hasServeralWebPreviews())221 this.getPageIndicator().fadeOut('slow');222 },223 getLoadedPreviewImgEl: function() {224 return $('.web-preview', this.getWindow());225 },226 getWindowPreviewBody: function() {227 return $('.popup-preview-layout__body', this.getWindow());228 },...

Full Screen

Full Screen

background.js

Source:background.js Github

copy

Full Screen

...47 }48})49app.on('second-instance', () => {50 // Someone tried to run a second instance, we should focus our window.51 if (LoginWindow.getWindow()) {52 if (LoginWindow.getWindow().isMinimized()) LoginWindow.getWindow().restore()53 LoginWindow.getWindow().focus()54 } else if (CheckUpdateWindow.getWindow()) {55 if (CheckUpdateWindow.getWindow().isMinimized()) CheckUpdateWindow.getWindow().restore()56 CheckUpdateWindow.getWindow().focus()57 } else if (MainWindow.getWindow()) {58 if (MainWindow.getWindow().isMinimized()) MainWindow.getWindow().restore()59 MainWindow.getWindow().focus()60 }61})62// Exit cleanly on request from parent process in development mode.63if (isDevelopment) {64 if (process.platform === 'win32') {65 process.on('message', (data) => {66 if (data === 'graceful-exit') {67 app.quit()68 }69 })70 } else {71 process.on('SIGTERM', () => {72 app.quit()73 })74 }75}76/**77 * --------------------------------------------------------78 * Auto Updater Events79 * --------------------------------------------------------80 */81autoUpdater.on('update-available', () => {82 // version can be updated83 if (CheckUpdateWindow.getWindow()) {84 CheckUpdateWindow.sendStatusToWindow('versionUpdate', 'preparing to download')85 } else if (MainWindow.getWindow()) {86 MainWindow.getWindow().webContents.send('newUpdate')87 }88})89autoUpdater.on('update-not-available', () => {90 // no update available91 if (CheckUpdateWindow.getWindow()) {92 CheckUpdateWindow.sendStatusToWindow('versionUpdate', 'up to date')93 setTimeout(() => {94 MainWindow.createWindow()95 CheckUpdateWindow.getWindow().destroy()96 }, 3000)97 } else if (MainWindow.getWindow()) {98 MainWindow.getWindow().webContents.send('noUpdate')99 }100})101autoUpdater.on('error', () => {102 // Update Error103 if (CheckUpdateWindow.getWindow()) {104 CheckUpdateWindow.sendStatusToWindow('versionUpdate', 'oops! something went wrong')105 setTimeout(() => {106 CheckUpdateWindow.getWindow().destroy()107 app.exit()108 }, 5000)109 } else if (MainWindow.getWindow()) {110 MainWindow.getWindow().webContents.send('errorUpdate')111 }112})113autoUpdater.on('download-progress', (progressObj) => {114 // download progress being downloaded115 if (CheckUpdateWindow.getWindow()) {116 CheckUpdateWindow.sendStatusToWindow('versionUpdate', `downloading... ${progressObj.percent.toFixed()}%`)117 } else if (MainWindow.getWindow()) {118 MainWindow.getWindow().webContents.send('progressUpdate', progressObj.percent.toFixed())119 }120})121autoUpdater.on('update-downloaded', (info) => {122 // Download completed123 if (CheckUpdateWindow.getWindow()) {124 this.sendStatusToWindow('versionUpdate', 'relaunching')125 setTimeout(() => {126 autoUpdater.quitAndInstall()127 }, 3000)128 } else if (MainWindow.getWindow()) {129 MainWindow.getWindow().webContents.send('doneUpdate', info.version)130 }131})132/**133 * --------------------------------------------------------134 * Electron Main Remove Events135 * --------------------------------------------------------136 */137ipcMain.on('update-task', (event, arg) => {138 if (MainWindow.getWindow()) MainWindow.getWindow().webContents.send('updateTask', arg)139})140ipcMain.on('logout', async (event, arg) => {141 if (!LoginWindow.getWindow()) LoginWindow.createWindow()142 if (MainWindow.getWindow()) MainWindow.getWindow().destroy()143})144ipcMain.on('login', (event, arg) => {145 initializeWindows()146 if (LoginWindow.getWindow()) LoginWindow.getWindow().destroy()147})148ipcMain.on('relaunch', (event, arg) => {149 app.relaunch()150 app.exit()151})152ipcMain.on('check-update', (event, arg) => {153 autoUpdater.checkForUpdatesAndNotify()154})155ipcMain.on('quit-install', (event, arg) => {156 autoUpdater.quitAndInstall()...

Full Screen

Full Screen

picker.js

Source:picker.js Github

copy

Full Screen

...5let pickerClosed = false;6module.exports = (handlers) => {7 const { colorPicker, picker, storage, colorProperty } = handlers;8 let closePicker = () => {9 if (picker.getWindow()) {10 pickerClosed = true;11 ipcMain.removeListener('closePicker', closePicker);12 ipcMain.removeListener('enablePicker', event => { });13 picker.getWindow().close();14 }15 }16 const linuxMouse = () => {17 const ioHook = require('iohook');18 ioHook.start();19 ioHook.on('mousemove', event => {20 if(!picker.getWindow()) return21 let realtime = storage.get('realtime', 'picker')22 let {x, y} = event;23 let color = '#' + robot.getPixelColor(parseInt(x), parseInt(y))24 picker.getWindow().setPosition(parseInt(x) - 50, parseInt(y) - 50)25 picker.getWindow().webContents.send('updatePicker', color)26 if (realtime) colorpicker.getWindow().webContents.send('previewColor', color)27 })28 ioHook.on('mouseup', event => {29 if(!picker.getWindow()) return30 if(event.button == 2) return closePicker();31 let {x, y} = event;32 closePicker('#' + robot.getPixelColor(parseInt(x), parseInt(y)))33 })34 let pos = robot.getMousePos();35 picker.getWindow().setPosition(parseInt(pos.x) - 50, parseInt(pos.y) - 50);36 picker.getWindow().webContents.send(37 'updatePicker',38 robot.getPixelColor(pos.x, pos.y)39 );40 ipcMain.on('closePicker', closePicker);41 }42 const hideWindows = () => {43 if(colorPicker.getWindow() && colorPicker.getWindow().isVisible()) colorPicker.getWindow().hide();44 if(storage.getWindow() && storage.getWindow().isVisible()) storage.getWindow().hide();45 if(colorProperty.getWindow() && colorProperty.getWindow().isVisible()) colorProperty.getWindow().hide();46 }47 const showWindows = () => {48 if(colorPicker.getWindow() && !colorPicker.getWindow().isVisible()) colorPicker.getWindow().show();49 if(storage.getWindow() && !storage.getWindow().isVisible()) storage.getWindow().show();50 if(colorProperty.getWindow() && !colorProperty.getWindow().isVisible()) colorProperty.getWindow().show();51 }52 ipcMain.on('enablePicker', (event, sendToColorPicker) => {53 pickerClosed = false;54 hideWindows();55 if(!picker.getWindow()) picker.init();56 if(process.platform !== 'win32' && process.platform !== 'darwin') return linuxMouse();57 if (process.platform === 'win32') mouseEvent = require('win-mouse')();58 picker.getWindow().on('close', () => mouseEvent.destroy());59 60 mouseEvent.on('move', (x, y) => {61 if(picker.getWindow()){62 let color = "#" + robot.getPixelColor(parseInt(x), parseInt(y));63 picker.getWindow().setPosition(parseInt(x) - 50, parseInt(y) - 50);64 picker.getWindow().webContents.send('updatePicker', color);65 let mousePos = robot.getMousePos();66 picker.getWindow().setPosition(parseInt(mousePos.x) - 50, parseInt(mousePos.y) - 50);67 }68 });69 ipcMain.on('closePicker', () => {70 closePicker();71 showWindows();72 });73 74 mouseEvent.once('left-down', (x, y) => {75 if(sendToColorPicker){76 const color = "#" + robot.getPixelColor(parseInt(x), parseInt(y));77 78 if(!colorPicker.getWindow()) colorPicker.init();79 80 showWindows();81 closePicker();82 83 colorPicker.getWindow().webContents.send('picked-color', color);84 colorPicker.getWindow().focus();85 86 pickerClosed = false;87 }88 else{89 if(!pickerClosed){90 const color = '#' + robot.getPixelColor(parseInt(x), parseInt(y));91 colorProperty.getWindow().webContents.send('newColor', color);92 mouseEvent.destroy();93 showWindows();94 closePicker();95 }96 }97 });98 });...

Full Screen

Full Screen

window-behaviors.js

Source:window-behaviors.js Github

copy

Full Screen

...35 }36 }37 },38 ready() {39 this.getWindow(w =>40 w.setHandler(() => this.onAttached && this.onAttached(), () => this.onDetached && this.onDetached())41 );42 },43 methods: {44 getWindow(f) {45 if (!this.w) {46 this.w = this.selectComponent(".window");47 }48 if (this.w) {49 return f(this.w);50 }51 },52 setOnDetachedHandler(handler) {53 this.getWindow(w => w.setOnDetachedHandler(handler));54 return this;55 },56 setMask(enable) {57 this.getWindow(w => w.setMask(enable));58 return this;59 },60 setMaskBg(bg) {61 this.getWindow(w => w.setMaskBg(bg));62 return this;63 },64 setTouchCancel(enable) {65 this.getWindow(w => {66 w.setTouchCancel(enable);67 });68 return this;69 },70 setJustHidden(enable) {71 this.getWindow(w => w.setJustHidden(enable));72 return this;73 },74 setMaskBgHidden(enable){75 this.getWindow(w => w.setMaskBgHidden(enable));76 return this;77 },78 show() {79 return this.getWindow(w => w.attachedToWindow()) || Promise.reject();80 },81 dismiss() {82 return this.getWindow(w => w.detachedFromWindow()) || Promise.reject();83 },84 isShowed() {85 return this.getWindow(w => w.isShowed());86 },87 lockPageScroll() {88 return this.getWindow(w => w._lockPageScroll())89 },90 unLockPageScroll() {91 return this.getWindow(w => w._unLockPageScroll())92 },93 _noFn() {}94 }...

Full Screen

Full Screen

getWindow.js

Source:getWindow.js Github

copy

Full Screen

...12 expect(5);13 var div = document.createElement('div');14 document.body.appendChild(div);15 div.id = 'div_id';16 equal(baidu.dom(div).getWindow(), window);17 equal(baidu.dom(document).getWindow(), window);// document18 equal(baidu.dom(document.body).getWindow(), window);// body19 equal(baidu.dom(document.documentElement).getWindow(), window);20 equal(baidu.dom('#div_id').getWindow(), window);21 document.body.removeChild(div);22});23test('iframe', function() {24 ua.frameExt(function(w){25 var gw = w.parent.baidu.dom.getWindow;26 w.$(w.document.body).append('<div id="test_div"></div>');27 equals(gw(w.$('div#test_div')[0]), w);28 equals(gw(w.document), w);29 equals(w.baidu.dom.getWindow(w.parent.document), w.parent);30 this.finish();31 });32});33test("dom为空的情况",function(){34 var result = baidu("#baidujsxiaozu").getWindow("wangxiao");35 equal(result,undefined);36});37// 老接口38test('当前页元素window', function() {39 expect(5);40 var div = document.createElement('div');41 document.body.appendChild(div);42 div.id = 'div_id';43 equal(baidu.dom.getWindow(div), window);44 equal(baidu.dom.getWindow(document), window);// document45 equal(baidu.dom.getWindow(document.body), window);// body46 equal(baidu.dom.getWindow(document.documentElement), window);47 equal(baidu.dom.getWindow('div_id'), window);48 document.body.removeChild(div);49});50test('iframe', function() {51 ua.frameExt(function(w){52 var gw = w.parent.baidu.dom.getWindow;53 w.$(w.document.body).append('<div id="test_div"></div>');54 equals(gw(w.$('div#test_div')[0]), w);55 equals(gw(w.document), w);56 equals(w.baidu.dom.getWindow(w.parent.document), w.parent);57 this.finish();58 });...

Full Screen

Full Screen

is-high-resolution.test.js

Source:is-high-resolution.test.js Github

copy

Full Screen

1'use strict';2const isHighResolution = require('../lib/is-high-resolution');3const getWindow = require('../lib/get-window');4jest.mock('../lib/get-window', () => {5 const win = {6 matchMedia: jest.fn().mockReturnValue({ matches: false }),7 };8 const m = () => win;9 m.win = win;10 return m;11});12describe('isHighResolution', () => {13 afterEach(() => {14 isHighResolution.clearCache();15 });16 test('basically works', () => {17 expect(isHighResolution(1.3)).toBe(false);18 expect(getWindow.win.matchMedia).toHaveBeenCalledTimes(1);19 expect(getWindow.win.matchMedia).toHaveBeenCalledWith(20 `only screen and (-webkit-min-device-pixel-ratio: 1.3), only screen and (min-resolution: 124.800dpi)`21 );22 });23 test('can return true', () => {24 getWindow.win.matchMedia.mockReturnValueOnce({ matches: true });25 expect(isHighResolution(1.3)).toBe(true);26 expect(getWindow.win.matchMedia).toHaveBeenCalledTimes(1);27 expect(getWindow.win.matchMedia).toHaveBeenCalledWith(28 `only screen and (-webkit-min-device-pixel-ratio: 1.3), only screen and (min-resolution: 124.800dpi)`29 );30 });31 test('uses cache for equal ratios', () => {32 isHighResolution(1.3);33 isHighResolution(1.3);34 expect(getWindow.win.matchMedia).toHaveBeenCalledTimes(1);35 });36 test('does not use cache for different ratios', () => {37 isHighResolution(1.5);38 isHighResolution(2);39 expect(getWindow.win.matchMedia).toHaveBeenCalledTimes(2);40 expect(getWindow.win.matchMedia).toHaveBeenCalledWith(41 `only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144.000dpi)`42 );43 expect(getWindow.win.matchMedia).toHaveBeenCalledWith(44 `only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-resolution: 192.000dpi)`45 );46 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Window', () => {2 it('cy.window() - get the global window object', () => {3 cy.window().should('have.property', 'top')4 })5})6describe('Document', () => {7 it('cy.document() - get the document object', () => {8 cy.document()9 .should('have.property', 'charset')10 .and('eq', 'UTF-8')11 })12})13describe('Iframe', () => {14 it('cy.iframe() - get the iframe DOM element', () => {15 cy.get('iframe').its('0.contentDocument.body').should('not.be.empty')16 cy.get('iframe').its('0.contentDocument.body').find('button').should('contain', 'Button')17 })18})19describe('Iframe', () => {20 it('cy.iframe() - get the iframe DOM element', () => {21 cy.get('iframe').its('0.contentDocument.body').should('not.be.empty')22 cy.get('iframe').its('0.contentDocument.body').find('button').should('contain', 'Button')23 })24})25describe('Iframe', () => {26 it('cy

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', () => {2 it('Does not do much!', () => {3 cy.window().then((win) => {4 win.document.querySelector('h1').innerText = 'Hello World'5 })6 })7})8{9}10describe('My First Test', () => {11 it('Does not do much!', () => {12 cy.visit('/')13 cy.window().then((win) => {14 win.document.querySelector('h1').innerText = 'Hello World'15 })16 })17})18{19}20describe('My First Test', () => {21 it('Does not do much!', () => {22 cy.visit('/')23 cy.window().then((win) => {24 win.document.querySelector('h1').innerText = 'Hello World'25 })26 })27})28{29}30describe('My First Test', () => {31 it('Does not do much!', () => {32 cy.visit('/')33 cy.window().then((win) => {34 win.document.querySelector('h1').innerText = 'Hello World'35 })36 })37})38{39}40describe('My First Test', () => {41 it('Does not do much!', () => {42 cy.visit('/')43 cy.window().then((win) => {44 win.document.querySelector('h1').innerText = 'Hello World'45 })46 })47})48{

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.window().then((win) => {2 win.getWindow();3});4Cypress.Commands.add('getWindow', () => {5 return cy.window();6});7import './commands';8{9 "testFiles": "**/*.{js,feature}"10}11describe('My First Test', () => {12 it('Does not do much!', () => {13 cy.contains('type').click();14 cy.get('.action-email').type('

Full Screen

Using AI Code Generation

copy

Full Screen

1const win = cy.state('window');2const doc = win.document;3const el = doc.querySelector('div')4const doc = cy.state('document');5const el = doc.querySelector('div')6const doc = cy.state('document');7const el = doc.querySelector('div')8const doc = cy.state('document');9const el = doc.querySelector('div')10const doc = cy.state('document');11const el = doc.querySelector('div')12const doc = cy.state('document');13const el = doc.querySelector('div')14const doc = cy.state('document');15const el = doc.querySelector('div')16const doc = cy.state('document');17const el = doc.querySelector('div')

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.window().then(win => {2 win.getWindow();3});4 function getWindow() {5 return window;6 }7Cypress has a method called cy.viewportHeight() to set the viewport height. The cy.viewportHeight() method returns the viewport height. The viewport height is the height of the browser window. We can access the viewport height by using cy.viewportHeight() method. The cy.viewportHeight() method returns the

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.window().then((win) => {2 win.console.log("Hello World")3})4cy.window().then((win) => {5 win.alert("Hello World")6})7cy.window().then((win) => {8 win.confirm("Hello World")9})10cy.window().then((win) => {11 win.prompt("Hello World")12})13cy.window().then((win) => {14})15cy.window().then((win) => {16 win.close()17})18cy.window().then((win) => {19 win.print()20})21cy.window().then((win) => {22 win.stop()23})24cy.window().then((win) => {25 win.focus()26})27cy.window().then((win) => {28 win.blur()29})30cy.window().then((win) => {31 win.find()32})33cy.window().then((win) => {34 win.getSelection()35})36cy.window().then((win) => {37 win.getSelection().toString()

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.window().then(win => {2 win.methodName();3});4window.methodName = function() {5};6window.methodName();7cy.window().then(win => {8 win.methodName();9});10window.methodName = function() {11};12window.methodName();

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress 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