How to use popTarget method in Playwright Internal

Best JavaScript code snippet using playwright-internal

monitor.js

Source:monitor.js Github

copy

Full Screen

1define([2 "jquery",3 "underscore",4 "backbone",5 "circleprogress",6 "text!views/monitor",7 "text!views/header",8 // "css!cs/stylesheets/css/layout.css",9 // "css!cs/stylesheets/css/common.css",10 // "css!cs/stylesheets/main.css",11 // "css!cs/stylesheets/css/animate.css",12 // "css!cs/stylesheets/css/all.css",13 // "css!cs/stylesheets/css/component.css",14 // "css!cs/stylesheets/css/interaction.css"15], function (16 $,17 _,18 Backbone,19 circleprogress,20 monitor,21 header22) {23 var NetworkModel = Backbone.Model.extend({24 url: '/network/networks',25 parse: function (result) {26 return result;27 }28 });29 var UpsModel = Backbone.Model.extend({30 url: '/ups/list',31 parse: function (result) {32 return result;33 }34 });35 var UpsDeviceModel = Backbone.Model.extend({36 url: '/ups/device',37 parse: function (result) {38 return result;39 }40 });41 var ManagerModel = Backbone.Model.extend({42 url: '/manager/managers',43 parse: function (result) {44 return result;45 }46 });47 return Backbone.View.extend({48 el: '.wrapper',49 selectedRow: undefined,50 upsList: undefined,51 initialize: function () {52 this.$el.html(monitor);53 this.$el.closest('body').find('header').html(header);54 this.upsModel = new UpsModel();55 this.listenTo(this.upsModel, "sync", this.getUpsList);56 this.upsModel.fetch();57 },58 events: {59 "click #btn": "imgTest",60 "click .fa-search": "imageShow",61 "click .fa-times": "closePopup"62 },63 imageShow: function (event) {64 var target = event.currentTarget;65 var targetPopup = $(target).closest('.popBox');66 var imgPopTitle = targetPopup.find('.popTit').find('.popText').text();67 var imageFile = $(target).attr('value');68 var imagePath = 'http://119.207.78.144:9091/upload/read/'+imageFile; 69 //var imagePath = 'http://127.0.0.1:9091/upload/read/'+imageFile; 70 this.$el.find(".photoPOP").css('display','block');71 this.$el.find(".photoPOP").find('.tit').find('span').text(imgPopTitle);72 this.$el.find(".photoPOP").find('.imgBox').find("img").attr('src',imagePath);73 },74 closePopup: function(){75 this.$el.find(".photoPOP").css('display','none');76 },77 getNetworkList: function (model) {78 var _this = this;79 var data = model.toJSON();80 var _networkList = Object.keys(data).map(function (i) {81 var _upsId = data[i]["ups_id"] || null;82 if (_upsId) {83 var _networkId = data[i]["id"];84 var _deviceId = data[i]["device_id"];85 var $target = $("#ups-panel-" + _upsId).find(".devList");86 var $mapTarget = $('.upsArea-' + _upsId);87 if (_deviceId === 1) {88 // ups 영역89 var leng = $target.find('.cctv-state').length;90 if (leng === 1) {91 $target.find('.cctv-state').attr("id", "cctv-" + _networkId);92 $target.find('.cctv-state').attr("device-type", _deviceId);93 } else {94 var hasId = $($target.find('.cctv-state')[0]).attr("id");95 $($target.find('.cctv-state')[0]).attr("id", "cctv-" + _networkId);96 $($target.find('.cctv-state')[0]).attr("device-type", _deviceId);97 if (!hasId) {98 $($target.find('.cctv-state')[1]).attr("id", "cctv-" + _networkId);99 $($target.find('.cctv-state')[1]).attr("device-type", _deviceId);100 }101 }102 }103 else if (_deviceId === 2) {104 var leng = $target.find('.scanner-state').length;105 if (leng === 1) {106 $target.find('.scanner-state').attr("id", "scanner-" + _networkId);107 } else {108 var hasId = $($target.find('.scanner-state')[0]).attr("id");109 $($target.find('.scanner-state')[0]).attr("id", "scanner-" + _networkId);110 if (!hasId) {111 $($target.find('.scanner-state')[1]).attr("id", "scanner-" + _networkId);112 }113 }114 }115 else if (_deviceId === 3) {116 var leng = $target.find('.ups-state').length;117 if (leng === 1) {118 $target.find('.ups-state').attr("id", "ups-" + _networkId);119 } else {120 var hasId = $($target.find('.ups-state')[0]).attr("id");121 $($target.find('.ups-state')[0]).attr("id", "ups-" + _networkId);122 if (!hasId) {123 $($target.find('.ups-state')[1]).attr("id", "ups-" + _networkId);124 }125 }126 }127 else if (_deviceId === 4) {128 var leng = $target.find('.server-state').length;129 if (leng === 1) {130 $target.find('.server-state').attr("id", "server-" + _networkId);131 } else {132 var hasId = $($target.find('.server-state')[0]).attr("id");133 $($target.find('.server-state')[0]).attr("id", "server-" + _networkId);134 if (!hasId) {135 $($target.find('.server-state')[1]).attr("id", "server-" + _networkId);136 }137 }138 }139 else if (_deviceId === 5) {140 var leng = $target.find('.wifi-state').length;141 if (leng === 1) {142 $target.find('.wifi-state').attr("id", "wifi-" + _networkId);143 } else {144 var hasId = $($target.find('.wifi-state')[0]).attr("id");145 $($target.find('.wifi-state')[0]).attr("id", "wifi-" + _networkId);146 if (!hasId) {147 $($target.find('.wifi-state')[1]).attr("id", "wifi-" + _networkId);148 }149 }150 }151 else if (_deviceId === 6) {152 var leng = $target.find('.repeater-state').length;153 if (leng === 1) {154 $target.find('.repeater-state').attr("id", "repeater-" + _networkId);155 } else {156 var hasId = $($target.find('.repeater-state')[0]).attr("id");157 $($target.find('.repeater-state')[0]).attr("id", "repeater-" + _networkId);158 if (!hasId) {159 $($target.find('.repeater-state')[1]).attr("id", "repeater-" + _networkId);160 }161 }162 }163 else if (_deviceId === 7) {164 $target.find('.gas-state').attr("id", "gas-status");165 }166 else if (_deviceId === 8) {167 $target.find('.phpoc-state').attr("id", "phpoc-" + _networkId);168 var leng = $target.find('.phpoc-state').length;169 if (leng === 1) {170 $target.find('.phpoc-state').attr("id", "phpoc-" + _networkId);171 } else {172 var hasId = $($target.find('.phpoc-state')[0]).attr("id");173 $($target.find('.phpoc-state')[0]).attr("id", "phpoc-" + _networkId);174 if (!hasId) {175 $($target.find('.phpoc-state')[1]).attr("id", "phpoc-" + _networkId);176 }177 }178 }179 }180 return data[i];181 });182 _this.upsDeviceRead(); // 여기서 setInterval183 this.interval = setInterval(_this.upsDeviceRead, 5000);184 window.logData = _this.logData;185 this.timeout = setTimeout(_this.logData, 6000);186 console.log(this);187 //setTimeout(_this.setLogData, 6000);188 },189 getUpsList: function (model) {190 var _this = this;191 var data = model.toJSON();192 _this.render(data);193 this.networkModel = new NetworkModel();194 this.listenTo(this.networkModel, "sync", this.getNetworkList);195 this.networkModel.fetch();196 },197 render: function (data) {198 var _this = this;199 _this.upsList = {};200 var _upsList = Object.keys(data).map(function (i) {201 // ups 영역 렌더링202 _this.$el.find(".panel-list-" + i).attr("id", "ups-panel-" + data[i].id);203 _this.$el.find(".panel-list-" + i).find(".Plocation-name").text(data[i].location);204 // map 영역 렌더링205 var j = parseInt(i) + 1;206 // upspoint id 할당207 _this.$el.find('.mapArea').find(".ups_" + j).attr("id", "upsPoint-" + data[i].id);208 // popup id 할당209 _this.$el.find('.mapArea').find('.pop_' + j).attr('id', 'popup-panel-' + data[i].id);210 _this.$el.find('.mapArea').find('.pop_' + j).find('.popTit').find('.popText').text(j+". "+data[i].location);211 _this.$el.find('.mapArea').find('.pop_' + j).find('.fa-search').attr('value', data[i].image_path);212 //network upsPoint id 할당213 _this.$el.find('#netBox').find('.ups_' + j).attr('id', 'upsPosition-' + data[i].id);;214 var _devArea = _this.$el.find('.devArea-' + j);215 for (let index = 0; index < _devArea.length; index++) {216 _this.$el.find('.devArea-' + j).addClass("upsArea-" + data[i].id);217 }218 data[i].deviceList = [];219 _this.upsList[data[i].id] = data[i];220 return data[i];221 });222 window.upsList = _this.upsList;223 this.managerModel = new ManagerModel();224 this.listenTo(this.managerModel, "sync", this.getManagerList);225 this.managerModel.fetch();226 },227 getManagerList: function (model) {228 var _this = this;229 var data = model.toJSON();230 var _managerList = Object.keys(data).map(function (i) {231 var _upsId = data[i]['ups_id'];232 var _level = data[i]['level'];233 var _name = data[i]['name'];234 var _tel = data[i]['tel'];235 //$target.append(data[i]);236 var $target = $('#popup-panel-' + _upsId);237 var _text = '';238 if (_level === 0) {239 _text = '담당자(정) : ' + _name + ' ' + _tel;240 $target.find('.main').text(_text);241 }242 else if (_level === 1) {243 _text = '담당자(부) : ' + _name + ' ' + _tel;244 $target.find('.sub').text(_text);245 }246 return data[i];247 });248 },249 upsDeviceRead: function () {250 var _this = this;251 var model = new UpsDeviceModel();252 model.fetch({253 success: function (model, response) {254 var data = model.toJSON()255 var gasList = {};256 var upsDeviceList = Object.keys(data).map(function (i) {257 var _id = data[i]['id'];258 var hasProp = window.upsList.hasOwnProperty(_id);259 if (hasProp) {260 window.upsList[_id]["error_type"] = data[i]['error_type'];261 window.upsList[_id]["use_time"] = data[i]["use_time"];262 window.upsList[_id]["battery_remain"] = data[i]["battery_remain"];263 //window.upsList[_id]["deviceList"].push(data[i]);264 var upsId = data[i]['ups_id'];265 var deviceId = data[i]['device_id'];266 var networkId = data[i]['network_id'];267 var result = data[i]['result'];268 var $target = $('#ups-panel-' + upsId).find('.devList');269 if (deviceId === 1) {270 if (result === 'open') {271 $target.find('#cctv-' + networkId).removeClass('demer');272 $target.find('#cctv-' + networkId).addClass('dnomal');273 $(".mapArea").find('#cctv_icon-' + networkId).removeClass('demer');274 $(".mapArea").find('#cctv_icon-' + networkId).addClass('dnomal');275 276 $(".mapArea").find('#cctv_icon-' + networkId).removeClass('iconVisible');277 278 $("#netBox").find('#cctv_net-' + networkId).removeClass('demer');279 $("#netBox").find('#cctv_net-' + networkId).addClass('dnomal');280 281 }282 else if (result === 'closed') {283 $target.find('#cctv-' + networkId).removeClass('dnomal');284 $target.find('#cctv-' + networkId).addClass('demer');285 286 287 $(".mapArea").find('#cctv_icon-' + networkId).removeClass('dnomal');288 $(".mapArea").find('#cctv_icon-' + networkId).addClass('demer');289 290 var devShowClz = $(".mapArea").find('#cctv_icon-' + networkId).hasClass('devShow');291 if(devShowClz){292 $(".mapArea").find('#cctv_icon-' + networkId).removeClass('devShow');293 }294 $("#netBox").find('#cctv_net-' + networkId).removeClass('dnomal');295 $("#netBox").find('#cctv_net-' + networkId).addClass('demer');296 }297 }298 else if (deviceId === 2) {299 if (result === 'open') {300 $target.find('#scanner-' + networkId).removeClass('demer');301 $target.find('#scanner-' + networkId).addClass('dnomal');302 $target.find('#scanner-' + networkId).html('<img src="./images/scanner_nomal.png">스캐너');303 $(".mapArea").find('#scanner_icon-' + networkId).removeClass('demer');304 $(".mapArea").find('#scanner_icon-' + networkId).addClass('dnomal');305 $(".mapArea").find('#scanner_icon-' + networkId).html('<img src="./images/scanner_nomal.png">');306 307 $("#netBox").find('#scanner_net-' + networkId).removeClass('demer');308 $("#netBox").find('#scanner_net-' + networkId).addClass('dnomal');309 $("#netBox").find('#scanner_net-' + networkId).html('<img src="./images/scanner_nomal.png">');310 311 312 313 }314 else if (result === 'closed') {315 $target.find('#scanner-' + networkId).removeClass('dnomal');316 $target.find('#scanner-' + networkId).addClass('demer');317 $target.find('#scanner-' + networkId).html('<img src="./images/scanner_emer.png">스캐너');318 319 $(".mapArea").find('#scanner_icon-' + networkId).removeClass('dnomal');320 $(".mapArea").find('#scanner_icon-' + networkId).addClass('demer');321 $(".mapArea").find('#scanner_icon-' + networkId).html('<img src="./images/scanner_emer.png">');322 323 var devShowClz = $(".mapArea").find('#scanner_net-' + networkId).hasClass('devShow');324 if(devShowClz){325 $(".mapArea").find('#scanner_net-' + networkId).removeClass('devShow');326 }327 $("#netBox").find('#scanner_net-' + networkId).removeClass('dnomal');328 $("#netBox").find('#scanner_net-' + networkId).addClass('demer');329 $("#netBox").find('#scanner_net-' + networkId).html('<img src="./images/scanner_emer.png">');330 }331 }332 else if (deviceId === 3) {333 if (result === 'open') {334 $target.find('#ups-' + networkId).removeClass('demer');335 $target.find('#ups-' + networkId).addClass('dnomal');336 $(".mapArea").find('#ups_icon-' + networkId).removeClass('demer');337 $(".mapArea").find('#ups_icon-' + networkId).addClass('dnomal');338 $("#netBox").find('#ups_net-' + networkId).removeClass('demer');339 $("#netBox").find('#ups_net-' + networkId).addClass('dnomal');340 }341 else if (result === 'closed') {342 $target.find('#ups-' + networkId).removeClass('dnomal');343 $target.find('#ups-' + networkId).addClass('demer');344 $(".mapArea").find('#ups_icon-' + networkId).removeClass('dnomal');345 $(".mapArea").find('#ups_icon-' + networkId).addClass('demer');346 347 var devShowClz = $(".mapArea").find('#ups_icon-' + networkId).hasClass('devShow');348 if(devShowClz){349 $(".mapArea").find('#ups_icon-' + networkId).removeClass('devShow');350 }351 $("#netBox").find('#ups_net-' + networkId).removeClass('dnomal');352 $("#netBox").find('#ups_net-' + networkId).addClass('demer');353 354 }355 }356 else if (deviceId === 4) {357 if (result === 'open') {358 $target.find('#server-' + networkId).removeClass('demer');359 $target.find('#server-' + networkId).addClass('dnomal');360 $(".mapArea").find('#server_icon-' + networkId).removeClass('demer');361 $(".mapArea").find('#server_icon-' + networkId).addClass('dnomal');362 $("#netBox").find('#server_net-' + networkId).removeClass('demer');363 $("#netBox").find('#server_net-' + networkId).addClass('dnomal');364 }365 else if (result === 'closed') {366 $target.find('#server-' + networkId).removeClass('dnomal');367 $target.find('#server-' + networkId).addClass('demer');368 $(".mapArea").find('#server_icon-' + networkId).removeClass('dnomal');369 $(".mapArea").find('#server_icon-' + networkId).addClass('demer');370 var devShowClz = $(".mapArea").find('#server_icon-' + networkId).hasClass('devShow');371 if(devShowClz){372 $(".mapArea").find('#server_icon-' + networkId).removeClass('devShow');373 }374 $("#netBox").find('#server_net-' + networkId).removeClass('dnomal');375 $("#netBox").find('#server_net-' + networkId).addClass('demer');376 }377 }378 else if (deviceId === 5) {379 if (result === 'open') {380 $target.find('#wifi-' + networkId).removeClass('demer');381 $target.find('#wifi-' + networkId).addClass('dnomal');382 $(".mapArea").find('#wifi_icon-' + networkId).removeClass('demer');383 $(".mapArea").find('#wifi_icon-' + networkId).addClass('dnomal');384 $("#netBox").find('#wifi_net-' + networkId).removeClass('demer');385 $("#netBox").find('#wifi_net-' + networkId).addClass('dnomal');386 }387 else if (result === 'closed') {388 $target.find('#wifi-' + networkId).removeClass('dnomal');389 $target.find('#wifi-' + networkId).addClass('demer');390 $(".mapArea").find('#wifi_icon-' + networkId).removeClass('dnomal');391 $(".mapArea").find('#wifi_icon-' + networkId).addClass('demer');392 var devShowClz = $(".mapArea").find('#wifi_icon-' + networkId).hasClass('devShow');393 if(devShowClz){394 $(".mapArea").find('#wifi_icon-' + networkId).removeClass('devShow');395 }396 $("#netBox").find('#wifi_net-' + networkId).removeClass('dnomal');397 $("#netBox").find('#wifi_net-' + networkId).addClass('demer');398 }399 }400 else if (deviceId === 6) {401 if (result === 'open') {402 $target.find('#repeater-' + networkId).removeClass('demer');403 $target.find('#repeater-' + networkId).addClass('dnomal');404 $(".mapArea").find('#repeater_icon-' + networkId).removeClass('demer');405 $(".mapArea").find('#repeater_icon-' + networkId).addClass('dnomal');406 $("#netBox").find('#repeater_net-' + networkId).removeClass('demer');407 $("#netBox").find('#repeater_net-' + networkId).addClass('dnomal');408 }409 else if (result === 'closed') {410 $target.find('#repeater-' + networkId).removeClass('dnomal');411 $target.find('#repeater-' + networkId).addClass('demer');412 $(".mapArea").find('#repeater_icon-' + networkId).removeClass('dnomal');413 $(".mapArea").find('#repeater_icon-' + networkId).addClass('demer');414 var devShowClz = $(".mapArea").find('#repeater_icon-' + networkId).hasClass('devShow');415 if(devShowClz){416 $(".mapArea").find('#repeater_icon-' + networkId).removeClass('devShow');417 }418 $("#netBox").find('#repeater_net-' + networkId).removeClass('dnomal');419 $("#netBox").find('#repeater_net-' + networkId).addClass('demer');420 }421 }422 else if (deviceId === 7) {423 var hasProp = gasList.hasOwnProperty(upsId);424 if (!hasProp) {425 gasList[upsId] = [];426 }427 gasList[upsId].push(result);428 var gasLeng = gasList[upsId].length;429 if (gasLeng === 4) {430 var _index = gasList[upsId].indexOf('closed');431 if (_index === -1) {432 $target.find('#gas-status').removeClass('demer');433 $target.find('#gas-status').addClass('dnomal');434 $(".mapArea").find('.upsArea-' + upsId + '#gas-status').removeClass('demer');435 $(".mapArea").find('.upsArea-' + upsId + '#gas-status').addClass('dnomal');436 } else {437 $target.find('#gas-status').removeClass('dnomal');438 $target.find('#gas-status').addClass('demer');439 var devShowClz = $(".mapArea").find('.upsArea-' + upsId + '#gas-status').hasClass('devShow');440 if(devShowClz){441 $(".mapArea").find('.upsArea-' + upsId + '#gas-status').removeClass('devShow');442 }443 $(".mapArea").find('.upsArea-' + upsId + '#gas-status').removeClass('dnomal');444 $(".mapArea").find('.upsArea-' + upsId + '#gas-status').addClass('demer');445 }446 }447 }448 else if (deviceId === 8) {449 if (result === 'open') {450 $target.find('#phpoc-' + networkId).removeClass('demer');451 $target.find('#phpoc-' + networkId).addClass('dnomal');452 $("#netBox").find('#phpoc_net-' + networkId).removeClass('demer');453 $("#netBox").find('#phpoc_net-' + networkId).addClass('dnomal');454 455 }456 else if (result === 'closed') {457 $target.find('#phpoc-' + networkId).removeClass('dnomal');458 $target.find('#phpoc-' + networkId).addClass('demer');459 $("#netBox").find('#phpoc_net-' + networkId).removeClass('dnomal');460 $("#netBox").find('#phpoc_net-' + networkId).addClass('demer');461 }462 }463 } // end hasProp 유무464 return data[i];465 });466 window.main.view.upsBinding();467 window.upsDeviceList = [];468 window.upsDeviceList = upsDeviceList;469 },470 error: function (model, response) {471 },472 });473 },474 upsBinding: function () {475 var _this = this;476 var upsList = window.upsList;477 for (var key in upsList) {478 if (upsList.hasOwnProperty(key)) {479 var _id = upsList[key]["id"];480 var $upsTarget = $('#ups-panel-' + _id);481 var $popTarget = $('#popup-panel-' + _id);482 var errorType = upsList[key]["error_type"]; // 0:정상, 1: 정전, 2: 방전, 3:네트웍크 장애483 var upsHasNormalClz = $upsTarget.find(".line-condition").hasClass("nomal");484 var upsHasEmerClz = $upsTarget.find(".line-condition").hasClass("emer");485 var networkHasNormalClz = $upsTarget.find(".network-condition").hasClass("nomal");486 var networkHasEmerClz = $upsTarget.find(".network-condition").hasClass("emer");487 var _bottomNomalHTHML = '<img src="./images/1st.png"><img src="./images/1st.png"><img src="./images/1st.png">';488 var _bottomErrorHTHML = '<img src="./images/2nd.png"><img src="./images/2nd.png"><img src="./images/2nd.png">';489 var upsCanvasLeng = $upsTarget.find('.circle').find('canvas').length;490 var popCanvasLeng = $popTarget.find('.circle').find('canvas').length;491 var upsSpanLeng = $upsTarget.find(".line-condition").find('span').length;492 if (errorType !== 1) {493 // ups 영역494 if (upsCanvasLeng === 1) {495 $upsTarget.find('.circle').children().css('display', 'none');496 $upsTarget.find(".line-condition").removeClass("circle");497 }498 // 팝업 영역499 if (popCanvasLeng === 1) {500 $popTarget.find('.circle').children().css('display', 'none');501 $popTarget.find(".line-condition").removeClass("circle");502 }503 // // $upsTarget.find(".circle").empty();504 }505 else if (errorType === 1) {506 //ups 영역507 $upsTarget.find(".line-condition").removeClass("nomal");508 $upsTarget.find(".line-condition").removeClass("emer");509 $upsTarget.find(".line-condition").addClass("circle");510 // if(upsSpanLeng === 0){511 // $upsTarget.find(".line-condition").html("<span></span>");512 // }513 $upsTarget.find(".ac").empty();514 $upsTarget.find('.ups-state').find('.bottom').empty();515 // 팝업 영역516 $popTarget.find(".line-condition").removeClass("nomal");517 $popTarget.find(".line-condition").removeClass("emer");518 $popTarget.find(".line-condition").addClass("circle");519 // if(popCanvasLeng === 0){520 // $popTarget.find(".line-condition").html("<span></span>");521 // }522 $popTarget.find(".ac").empty();523 $popTarget.find('.ups-state').find('.bottom').empty();524 }525 /** upsPoint 상태표시 - errorType=0 이외의 값에는 class=Pemer 추가 **/526 if (errorType === 0) {527 $('#upsPoint-' + _id).removeClass('Pemer');528 $('#upsPosition-' + _id).removeClass('Pemer');529 $('#popup-panel-' + _id).removeClass('pop-emer');530 $('#popup-panel-' + _id).addClass('pop-nomal');531 } else {532 $('#upsPoint-' + _id).addClass('Pemer');533 $('#upsPosition-' + _id).addClass('Pemer');534 $('#popup-panel-' + _id).removeClass('pop-nomal');535 $('#popup-panel-' + _id).addClass('pop-emer');536 $('#popup-panel-' + _id + '.pop-emer').css('display', 'block');537 var hasShow = $('#popup-panel-' + _id).hasClass('show');538 if (hasShow) {539 $('#popup-panel-' + _id).removeClass('show');540 }541 }542 /** ups 상태 표시 **/543 // 전원 공급 정상544 if (errorType === 0) {545 // ups 영역546 // ups-state 영역 인터렉션547 if (!upsHasNormalClz && upsHasEmerClz) {548 $upsTarget.find(".line-condition").removeClass("emer");549 $upsTarget.find(".line-condition").addClass("nomal");550 $upsTarget.find('.ups-state').find('.bottom').html(_bottomNomalHTHML);551 $popTarget.find(".line-condition").removeClass("emer");552 $popTarget.find(".line-condition").addClass("nomal");553 $popTarget.find('.ups-state').find('.bottom').html(_bottomNomalHTHML);554 }555 else if (!upsHasNormalClz && !upsHasEmerClz) {556 $upsTarget.find(".line-condition").addClass("nomal");557 $upsTarget.find('.ups-state').find('.bottom').html(_bottomNomalHTHML);558 $popTarget.find(".line-condition").addClass("nomal");559 $popTarget.find('.ups-state').find('.bottom').html(_bottomNomalHTHML);560 }561 // network-state 영역 인터렉션562 if (!networkHasNormalClz && networkHasEmerClz) {563 // ups-state564 $upsTarget.find(".network-condition").removeClass("emer");565 $upsTarget.find(".network-condition").addClass("nomal");566 $upsTarget.find('.network-state').find('.bottom').html(_bottomNomalHTHML);567 $popTarget.find(".network-condition").removeClass("emer");568 $popTarget.find(".network-condition").addClass("nomal");569 $popTarget.find('.network-state').find('.bottom').html(_bottomNomalHTHML);570 }571 else if (!networkHasNormalClz && !networkHasEmerClz) {572 $upsTarget.find(".network-condition").addClass("nomal");573 $upsTarget.find('.network-state').find('.bottom').html(_bottomNomalHTHML);574 $popTarget.find(".network-condition").addClass("nomal");575 $popTarget.find('.network-state').find('.bottom').html(_bottomNomalHTHML);576 }577 var _html = '<i class="fas fa-plug"></i><br>'578 + '<span>220 V</span>';579 $upsTarget.find(".ac").html(_html);580 $popTarget.find(".ac").html(_html);581 $('#popup-panel-' + _id + '.pop-nomal').css('display', 'none');582 var hasShow = $(".popBox").siblings().hasClass('show');583 if (hasShow) {584 $('#popup-panel-' + _id + '.pop-nomal').addClass('show');585 }586 }587 // 정전-전원 공급 장애(배터리 사용)588 else if (errorType === 1) {589 console.log('errorType-->',upsList[key]);590 // ups 영역 차트591 $upsTarget.find('.circle').children().css('display', 'block');592 var _batteryRemain = upsList[key]["battery_remain"];593 594 var $upsCircle = $upsTarget.find('.circle');595 var upsHasCanvas = $upsCircle.find('canvas').length;596 var _percentVal = _batteryRemain / 100;597 if (upsHasCanvas === 0) {598 //_this.chartFnc(_batteryRemain);599 $upsTarget.find(".circle").html("<span class='bettery-per'></span>");600 $upsTarget.find('.circle').children().css('display', 'block');601 $upsCircle.find('span').html('<i class="fas fa-car-battery"></i><br>' + _batteryRemain + '<i>%</i>');602 603 $upsCircle.circleProgress({604 value: _percentVal,605 startAngle: -Math.PI / 6 * 3,606 lineCap: 'round',607 fill: { color: '#22BD09' }608 }).on('circle-animation-progress', function (event, progress) {609 610 });611 }612 else if (upsHasCanvas >= 1) {613 $upsCircle.circleProgress('value', _percentVal);614 $upsCircle.find('span').html('<i class="fas fa-car-battery"></i><br>' + _batteryRemain + '<i>%</i>');615 }616 //popup 영역 차트617 $popTarget.find('.circle').children().css('display', 'block');618 var _batteryRemain = upsList[key]["battery_remain"];619 var $popCircle = $popTarget.find('.circle');620 var popHasCanvas = $popCircle.find('canvas').length;621 var _percentVal = _batteryRemain / 100;622 if (popHasCanvas === 0) {623 //_this.chartFnc(_batteryRemain);624 $popTarget.find(".line-condition").html("<span class='bettery-per'></span>");625 $popTarget.find('.circle').children().css('display', 'block');626 $popCircle.find('span').html('<i class="fas fa-car-battery"></i><br>' + _batteryRemain + '<i>%</i>');627 $popCircle.circleProgress({628 value: _percentVal,629 startAngle: -Math.PI / 6 * 3,630 lineCap: 'round',631 fill: { color: '#22BD09' }632 }).on('circle-animation-progress', function (event, progress) {633 });634 }635 else if (popHasCanvas >= 1) {636 $popCircle.circleProgress('value', _percentVal);637 $popCircle.find('span').html('<i class="fas fa-car-battery"></i><br>' + _batteryRemain + '<i>%</i>');638 }639 // 배터리 사용시간 적용640 /* sample */ 641 // var _useTime = String(1.26);642 var usedTime = upsList[key]["use_time"];643 if(usedTime){644 var _useTime = String(upsList[key]["use_time"]);645 var subTime = _useTime.split('.');646 var usedHour = subTime[0] * 60;647 var subMin = (subTime[1].length !== 1) ? subTime[1] : subTime[1] + "0";648 var usedMinute = Math.round(60 * (subMin / 100));649 var _time = usedHour + usedMinute;650 //$upsTarget.find('.bottom').text('29min');651 $upsTarget.find('.ups-state').find('.bottom').text(_time + 'min');652 $popTarget.find('.ups-state').find('.bottom').text(_time + 'min');653 } else {654 $upsTarget.find('.ups-state').find('.bottom').text('--min');655 $popTarget.find('.ups-state').find('.bottom').text('--min');656 }657 // network-state 영역 인터렉션658 if (!networkHasNormalClz && networkHasEmerClz) {659 $upsTarget.find(".network-condition").removeClass("emer");660 $upsTarget.find(".network-condition").addClass("nomal");661 $upsTarget.find('.network-state').find('.bottom').html(_bottomNomalHTHML);662 $popTarget.find(".network-condition").removeClass("emer");663 $popTarget.find(".network-condition").addClass("nomal");664 $popTarget.find('.network-state').find('.bottom').html(_bottomNomalHTHML);665 }666 else if (!networkHasNormalClz && !networkHasEmerClz) {667 $upsTarget.find(".network-condition").addClass("nomal");668 $upsTarget.find('.network-state').find('.bottom').html(_bottomNomalHTHML);669 $popTarget.find(".network-condition").addClass("nomal");670 $popTarget.find('.network-state').find('.bottom').html(_bottomNomalHTHML);671 }672 }673 // 방전, 네트워크 장애674 else if (errorType === 2) {675 // ups-state 영역 676 if (upsHasNormalClz && !upsHasEmerClz) {677 // ups 영역678 $upsTarget.find(".line-condition").removeClass("nomal");679 $upsTarget.find(".line-condition").addClass("emer");680 $upsTarget.find('.bottom').html(_bottomErrorHTHML);681 // pop 영역682 $popTarget.find(".line-condition").removeClass("nomal");683 $popTarget.find(".line-condition").addClass("emer");684 $popTarget.find('.bottom').html(_bottomErrorHTHML);685 }686 else if (!upsHasNormalClz && !upsHasEmerClz) {687 $upsTarget.find(".line-condition").addClass("emer");688 $upsTarget.find('.bottom').html(_bottomErrorHTHML);689 $popTarget.find(".line-condition").addClass("emer");690 $popTarget.find('.bottom').html(_bottomErrorHTHML);691 }692 // network-state 영역693 if (networkHasNormalClz && !networkHasEmerClz) {694 $upsTarget.find(".network-condition").removeClass("nomal");695 $upsTarget.find(".network-condition").addClass("emer");696 $upsTarget.find('.network-state').find('.bottom').html(_bottomErrorHTHML);697 $popTarget.find(".network-condition").removeClass("nomal");698 $popTarget.find(".network-condition").addClass("emer");699 $popTarget.find('.network-state').find('.bottom').html(_bottomErrorHTHML);700 }701 else if (!networkHasNormalClz && !networkHasEmerClz) {702 $upsTarget.find(".network-condition").addClass("emer");703 $upsTarget.find('.network-state').find('.bottom').html(_bottomErrorHTHML);704 $popTarget.find(".network-condition").addClass("emer");705 $popTarget.find('.network-state').find('.bottom').html(_bottomErrorHTHML);706 }707 var _html = '<i class="fas fa-car-battery"></i><br>'708 + '<span>00 %</span>';709 $upsTarget.find(".ac").html(_html);710 $popTarget.find(".ac").html(_html);711 }712 // 네트워크 장애713 else if (errorType === 3) {714 // ups-state 영역 715 if (!upsHasNormalClz && upsHasEmerClz) {716 $upsTarget.find(".line-condition").removeClass("emer");717 $upsTarget.find(".line-condition").addClass("nomal");718 $upsTarget.find('.ups-state').find('.bottom').html(_bottomNomalHTHML);719 $popTarget.find(".line-condition").removeClass("emer");720 $popTarget.find(".line-condition").addClass("nomal");721 $popTarget.find('.ups-state').find('.bottom').html(_bottomNomalHTHML);722 }723 else if (!upsHasNormalClz && !upsHasEmerClz) {724 $upsTarget.find(".line-condition").addClass("nomal");725 $upsTarget.find('.ups-state').find('.bottom').html(_bottomNomalHTHML);726 $popTarget.find(".line-condition").addClass("nomal");727 $popTarget.find('.ups-state').find('.bottom').html(_bottomNomalHTHML);728 }729 // network-state 영역 730 if (networkHasNormalClz && !networkHasEmerClz) {731 $upsTarget.find(".network-condition").removeClass("nomal");732 $upsTarget.find(".network-condition").addClass("emer");733 $upsTarget.find('.network-state').find('.bottom').html(_bottomErrorHTHML);734 $popTarget.find(".network-condition").removeClass("nomal");735 $popTarget.find(".network-condition").addClass("emer");736 $popTarget.find('.network-state').find('.bottom').html(_bottomErrorHTHML);737 }738 else if (!networkHasNormalClz && !networkHasEmerClz) {739 $upsTarget.find(".network-condition").addClass("emer");740 $upsTarget.find('.network-state').find('.bottom').html(_bottomErrorHTHML);741 $popTarget.find(".network-condition").addClass("emer");742 $popTarget.find('.network-state').find('.bottom').html(_bottomErrorHTHML);743 }744 var _html = '<i class="fas fa-plug"></i><br>'745 + '<span>220 V</span>';746 $upsTarget.find(".ac").html(_html);747 $popTarget.find(".ac").html(_html);748 }749 }750 }751 },752 logData: function () {753 var _this = this;754 var upsDeviceList = window.upsDeviceList;755 if (upsDeviceList) {756 var delaySec = 200;757 for (i in upsDeviceList) {758 (function (ii) {759 setTimeout(function () {760 var deviceId = upsDeviceList[ii].device_id;761 var _logListLeng = $('.logList').find('li').length;762 if (_logListLeng >= 50) {763 $('.logList').find('li:last').remove();764 }765 if (upsDeviceList[ii].result === 'open') {766 //$('.logList').prepend('<li>' + upsDeviceList[ii].device_name + '&nbsp;&nbsp;&nbsp;' + upsDeviceList[ii].ups_location + '&nbsp;&nbsp;&nbsp; -->&nbsp;&nbsp;&nbsp; 정상</li>');767 $('.logList').prepend('<li>NMS' + upsDeviceList[ii].device_idx + 'A' + upsDeviceList[ii].device_index + '&nbsp;&nbsp;&nbsp;'+upsDeviceList[ii].port+'</li>');768 }769 else if (upsDeviceList[ii].result === 'closed') {770 //$('.logList').prepend('<li style="color:#ff0000;">' + upsDeviceList[ii].device_name + '&nbsp;&nbsp;&nbsp;' + upsDeviceList[ii].ups_location + '&nbsp;&nbsp;&nbsp; -->&nbsp;&nbsp;&nbsp; 장애</li>');771 $('.logList').prepend('<li style="color:#ff0000;">NMS' + upsDeviceList[ii].device_idx + 'A' + upsDeviceList[ii].device_index + '&nbsp;&nbsp;&nbsp;'+upsDeviceList[ii].port+'</li>');772 }773 if (ii == (upsDeviceList.length - 1)) {774 this.logData();775 }776 }, ii * delaySec)777 })(i);778 }779 }780 },781 destroy: function () {782 clearInterval(this.interval);783 clearTimeout(this.timeout);784 this.undelegateEvents();785 },786 });...

Full Screen

Full Screen

memoryRoomMine.js

Source:memoryRoomMine.js Github

copy

Full Screen

1var memoryRoomMine = {2 setup: function(room){3 var runLinks = require('runLinks');4 // Memory objects5 var mem = Memory.rooms[room.name];6 for (i in mem.sources) {7 mem.sources[i]['slots'] = mem.sources[i].plain;8 mem.sources[i]['work'] = 5;9 mem.sources[i]['energy'] = Game.getObjectById(mem.sources[i].id).energy;10 }11 // Uniquely initialised room properties ================================12 // Get position of spawn13 if (typeof mem.posSpawn === 'undefined') {14 var spawn = room.find(FIND_STRUCTURES, {15 filter: (structure) => {return (structure.structureType == STRUCTURE_SPAWN)}});16 if (spawn.length) {17 var spawn = spawn[0];18 mem.posSpawn = {x: spawn.pos.x, y:spawn.pos.y};19 }20 }21 // Dynamic room properties =============================================22 // Find construction sites23 var sites = room.find(FIND_CONSTRUCTION_SITES);24 // Find dropped energy25 var piles = room.find(FIND_DROPPED_RESOURCES,26 {filter: (dropped) => {return (dropped.energy > (room.carryCapacity / 3))}});27 // Find energy sinks28 var sinks = room.find(FIND_STRUCTURES, {29 filter: (structure) => {return (((30 structure.structureType == STRUCTURE_EXTENSION ||31 structure.structureType == STRUCTURE_SPAWN) &&32 structure.energy < structure.energyCapacity) ||33 (structure.structureType == STRUCTURE_TOWER &&34 structure.energy < structure.energyCapacity / 2) ||35 (structure.structureType == STRUCTURE_TERMINAL &&36 _.sum(Game.rooms.E54N48.terminal.store) < 200000));}});37 mem.links_sinks = [];38 mem.links_sources = [];39 mem.objectsSites = sites;40 mem.objectsPiles = piles;41 mem.objectsSinks = sinks;42 // List jobs ===========================================================43 mem.joblistPickup = [];44 mem.joblistRepairRoads = [];45 mem.joblistRepairContainers = [];46 mem.joblistRepairWalls = [];47 mem.joblistRepairRamps = [];48 var defense = 1000;49 // List of pickup jobs -----------------------------------------------50 // Currently, list of pickups is generated afresh every single tick51 // Any worker thats full52 //for(var i in mem.creeps.workers) {53 // var worker = Game.getObjectById(mem.creeps.workers[i])54 // if (worker.carry.energy == worker.carryCapacity &&55 // !_.some(worker.id, mem.jobs.pickups)) {56 // mem.jobs.pickups.push(worker.id)57 // }58 //}59 // Any dropped ressources 100+60 var drops = (room.find(FIND_DROPPED_RESOURCES, {61 filter: {resourceType: RESOURCE_ENERGY}}))62 if (drops.length) {63 for(var i = 0; i < drops.length; i++) {64 var drop = drops[i]65 if (!_.some( mem.joblistPickup, drop.id) &&66 drop.amount >= 100) {67 mem.joblistPickup.push(drop.id)68 }69 }70 }71 // Any container with 500+72 var containers = room.find(FIND_STRUCTURES, {filter: {structureType: STRUCTURE_CONTAINER}});73 if (containers.length) {74 for(var c = 0; c < containers.length; c++) {75 var cont = containers[c]76 if (!_.some(cont.id, mem.joblistPickup) &&77 cont.store[RESOURCE_ENERGY] >= 200) {78 mem.joblistPickup.push(cont.id)79 }80 }81 }82 // Run Links -----------------------------------------------------------83 // /*/*84 // //Links given my run.links85 // var links = mem.links86 // if (typeof links != 'undefined' &&87 // links.length) {88 // for(var link in links) {89 // thislink = Game.getObjectById(link)90 // mem.joblistPickup.push(thislink.id)91 // }92 // }93 // // Links if three links and link 3 full94 // var links = room.find(FIND_STRUCTURES, {95 // filter: (structure) => {96 // return (structure.structureType == STRUCTURE_LINK)}});97 // if (links.length > 2 &&98 // links[2].energy > 0 &&99 // links[0].energy > 0) {100 // mem.joblistPickup.push(links[0].id)101 // }*/*/102 var storage = room.storage103 if (typeof storage !== 'undefined') {104 if (storage.length > 0) {105 mem.joblistPickup.push(storage.id)106 }107 }108 // List of upkeep jobs -----------------------------------------------109 // Add new jobs110 // Find all ramps111 var jobRamps = room.find(FIND_MY_STRUCTURES, {112 filter: (structure) => {113 return (structure.structureType == 'rampart' &&114 structure.hits < defense)}});115 _.forEach(jobRamps, function(job) {116 if (!_.some(mem.joblistRepairRamps, job.id)) {117 mem.joblistRepairRamps.push(job.id)118 }119 })120 // Find all roads121 var jobRoads = room.find(FIND_STRUCTURES, {122 filter: (structure) => {123 return (structure.structureType == 'road' &&124 structure.hits < (structure.hitsMax - 1000))}});125 for (j in jobRoads){126 if (!_.some(mem.joblistRepairRoads, jobRoads[j].id)) {127 mem.joblistRepairRoads.push(jobRoads[j].id)128 }129 }130 // Find all containers131 var jobConts = room.find(FIND_STRUCTURES, {132 filter: (structure) => {133 return (structure.structureType == 'container' &&134 structure.hits < 200000)}});135 for (j in jobConts){136 if (!_.some(mem.joblistRepairContainers, jobConts[j].id)) {137 mem.joblistRepairContainers.push(jobConts[j].id)138 }139 }140 // Find all walls141 var jobsWalls = room.find(FIND_STRUCTURES, {142 filter: (structure) => {143 return (structure.structureType == 'constructedWall' &&144 structure.hits < defense)}});145 for (j in jobsWalls){146 if (!_.some(mem.joblistRepairWalls, jobsWalls[j].id)) {147 mem.joblistRepairWalls.push(jobsWalls[j].id)148 }149 }150 // Remove done jobs151 // Done ramps152 var joblist = mem.joblistRepairRamps;153 var jobRamps = room.find(FIND_MY_STRUCTURES, {154 filter: (structure) => {return155 (structure.structureType == 'rampart' &&156 (structure.hits > defense ||157 structure.hits == structure.hitsMax))}});158 _.forEach(jobRamps, function(job) {159 if (_.some(mem.joblistRepairRamps, job.id)) {160 joblist.splice(joblist.indexOf(job.id),1)161 }162 })163 // Done roads164 var joblist = mem.joblistRepairRamps;165 var jobRoads = room.find(FIND_STRUCTURES, {166 filter: (structure) => {167 return (structure.structureType == 'road' &&168 structure.hits >= (structure.hitsMax - 2000))}});169 for (j in jobRoads){170 if (_.some(joblist, jobRoads[j].id)) {171 joblist.splice(joblist.indexOf(jobRoads[j]),1)172 }173 }174 // Done conts175 var joblist = mem.joblistRepairContainers;176 var jobConts = room.find(FIND_STRUCTURES, {177 filter: (structure) => {178 return (structure.structureType == 'container' &&179 structure.hits >= (structure.hitsMax - 2000))}});180 for (j in jobConts){181 if (_.some(joblist, jobConts[j].id)) {182 joblist.splice(joblist.indexOf(jobConts[j]),1)183 }184 }185 // Done walls186 var joblist = mem.joblistRepairWalls;187 var jobsWalls = room.find(FIND_STRUCTURES, {188 filter: (structure) => {189 return (structure.structureType == 'constructedWall' &&190 structure.hits >= 5000)}});191 for (j in jobsWalls){192 if (_.some(joblist, jobsWalls[j].id)) {193 joblist.splice(joblist.indexOf(jobsWalls[j]),1)194 }195 }196 // Generate spawning list ==============================================197 // Creep population targets:198 var popTarget = {199 generalist: 0,200 worker: 0,201 carrier: 0,202 upgrader: 0,203 builder: 0,204 defender: 0,205 hauler: 0,206 miner: 0,207 warrior: 0,208 healer: 0209 };210 // Number of plain fields next to sources211 var slots = _.sum(mem.sources, function(source) {return source.plain});212 var nSources = Object.keys(mem.sources).length;213 // If low lvl room, use generalists214 if (room.energyCapacityAvailable <= 300) {215 popTarget['generalist'] = Math.min(216 Math.floor(slots * 1.5),217 nSources * 1); //5218 }219 else if (room.energyCapacityAvailable <= 400) {220 popTarget['generalist'] = Math.min(221 Math.floor(slots * 1.5),222 nSources * 1); //3223 }224 else if (room.energyCapacityAvailable <= 600) {225 popTarget['generalist'] = Math.min(226 Math.floor(slots * 1.5),227 nSources * 1); //2228 }229 else if (room.energyCapacityAvailable <= 800) {230 popTarget['generalist'] = Math.min(231 Math.floor(slots * 1.5),232 nSources * 1); //1.5233 }234 // Else, user worker carrier model235 else if (room.energyCapacityAvailable > 800) {236 popTarget['worker'] = nSources;237 popTarget['carrier'] = 2;238 popTarget['upgrader'] = 1;239 // If there is a construction site, there should be a builder240 if (sites.length) {241 popTarget['builder'] = 1;242 }243 // If there is an extractor, there should be a miner244 if (room.find(FIND_MY_STRUCTURES, {245 filter: { structureType: STRUCTURE_EXTRACTOR}}).length) {246 popTarget['miner'] = 1;247 }248 }249 // Census of actual creep population -----------------------------------250 // Get all creeps in this room251 var creeps = _.filter(Game.creeps, function(o) {252 return o.room.name == room.name;253 });254 // Get number of creeps per role255 var pop = _.countBy(creeps, 'memory.role');256 var joblistSpawn = [];257 for (role in popTarget) {258 // Fill in zero values259 if (typeof pop[role] === 'undefined') {260 pop[role] = 0;261 }262 // Compare actual to target263 if (pop[role] < popTarget[role]) {264 joblistSpawn.push(role);265 }266 }267 mem['joblistSpawn'] = joblistSpawn;268 // Restart room ========================================================269 if (pop['generalist'] < 4 &&270 pop['carrier'] === 0) {271 var spawns = room.find(FIND_MY_STRUCTURES, {filter: {structureType: STRUCTURE_SPAWN}});272 if (spawns.length) {273 var spawn = _.sortByOrder(spawns, 'energy', 'desc')[0];274 if (room.energyCapacityAvailable <= 800) {275 spawn.spawnGeneralist(spawn.room.energyAvailable)276 }277 else if (room.energyCapacityAvailable > 800) {278 // If storage is non-empty279 if (typeof room.storage !== 'undefined' &&280 room.storage.store[RESOURCE_ENERGY] > 1000) {281 spawn.spawnCarrier(spawn.room.energyAvailable);282 }283 else {284 spawn.spawnGeneralist(spawn.room.energyAvailable);285 }286 }287 }288 }289 }290};...

Full Screen

Full Screen

vueselect.js

Source:vueselect.js Github

copy

Full Screen

1Vue.component('vueselect',{2 template: `3<div class="ui-select">4 <div style="position:relative !important;" :class="{'popup':ispop}">5 <div class="ui-mini ui-btn ui-icon-carat-d ui-btn-icon-right ui-corner-all"6 @click="pop($event)" :class="{'ui-btn-active': isactive}" @mousedown="mousedown" @mouseup="mouseup" @mouseleave="mouseup">7 <a>{{ options[data.selected] }}</a>8 </div>9 <div v-show="options.length != 0 && ispop" class="overlayMask" :class="{'fullscreen':isFullScreen}" @click="!isFullScreen?hide():''"></div>10 <ul v-show="options.length != 0 && ispop" class="ui-selectmenu ui-selectmenu-list ui-listview ui-corner-all" style="position:absolute !important;overflow:auto;" :style="optionBoxPos">11 <div v-if="isFullScreen" class="ui-header ui-first-child">12 <div class="ui-btn ui-corner-all ui-icon-delete ui-btn-icon-notext ui-btn-left" @click="hide"></div>13 <div class="ui-title">{{ title() }}</div>14 </div>15 <li @click="select($event)" :value="key" :class="{'ui-first-child': key === 0 && !isFullScreen, 'ui-last-child': key === (options.length - 1)}" v-for="(item, key) in options" :key="key">16 <div class="ui-btn" :class="{'ui-btn-active':key === data.selected}">{{item}}</div>17 </li>18 </ul>19 </div>20</div>`,21 data () {22 return {23 oldoptions: [],24 ispop: false,25 isactive: false,26 poptarget: undefined,27 isFullScreen: false,28 optionBoxPos: {29 top: 0,30 left: 031 },32 poptargetPos: JSON.stringify({33 top: 0,34 left: 0,35 offsetHeight: 0,36 offsetWidth: 037 }),38 objPos: {39 width: 0,40 height: 041 }42 }43 },44 computed: {45 options () {46 return this.data.options47 }48 },49 props: {50 label: {51 type: String,52 default: () => {53 return ''54 }55 },56 data: {57 type: Object,58 default: () => {59 return {60 options: [' '],61 selected: 062 }63 },64 required: true65 }66 },67 methods: {68 newPoptargetPos () {69 return {70 top: common.getElementTop(this.poptarget),71 left: common.getElementLeft(this.poptarget),72 offsetHeight: this.poptarget.offsetHeight,73 offsetWidth: this.poptarget.offsetWidth74 }75 },76 title () {77 return this.label === '' ? ' ' : document.getElementById(this.label).innerText78 },79 pop (event) {80 if (this.options.length === 0) {81 return82 }83 this.ispop = true84 this.poptarget = event.currentTarget85 },86 hide () {87 this.ispop = false88 },89 mousedown () {90 this.isactive = true91 },92 mouseup () {93 this.isactive = false94 },95 select (event) {96 this.data.selected = event.currentTarget.value * 197 this.ispop = false98 },99 listSize (obj) {100 let objarr = Array.from(obj.children)101 if (objarr.length !== this.options.length) {102 objarr.shift()103 }104 return {105 width: obj.offsetWidth,106 height: objarr.reduce((accumulator, currentValue) => {107 return accumulator + currentValue.offsetHeight108 }, 0)109 }110 },111 relocate (obj) {112 let listSize = this.listSize(obj)113 let pageArea = common.getPagearea()114 if (JSON.stringify(this.objPos) !== JSON.stringify(listSize)) {115 if (this.objPos.width === 0 || this.objPos.width === pageArea.width - 32 || listSize.width !== pageArea.width - 32) {116 this.objPos = JSON.parse(JSON.stringify(listSize))117 }118 }119 let newPoptargetPos = this.newPoptargetPos()120 let top = (newPoptargetPos.offsetHeight - listSize.height) / 2121 let left = (newPoptargetPos.offsetWidth - this.objPos.width) / 2122 let right = 'auto'123 let bottom = 'auto'124 let position = 'absolute !important'125 let maxtop = pageArea.height - listSize.height - 16126 let maxleft = pageArea.width - this.objPos.width - 16127 top = (top + newPoptargetPos.top) <= 16 ? (16 - newPoptargetPos.top)128 : ((top + newPoptargetPos.top) > maxtop ? (maxtop - newPoptargetPos.top) : top)129 left = (left + newPoptargetPos.left) <= 16 ? (16 - newPoptargetPos.left)130 : ((left + newPoptargetPos.left) > maxleft ? (maxleft - newPoptargetPos.left) : left)131 if (left + this.objPos.width + newPoptargetPos.left >= pageArea.width - 32) {132 right = '16px'133 }134 if (top + listSize.height + newPoptargetPos.top >= pageArea.height - 32) {135 position = 'fixed !important'136 top = 16137 left = 16138 right = '16px'139 bottom = '16px'140 this.isFullScreen = true141 } else {142 this.isFullScreen = false143 }144 return {145 top: top + 'px',146 left: left + 'px',147 right: right,148 bottom: bottom,149 position: position150 }151 }152 },153 beforeUpdate () {154 if (this.oldoptions.toString() !== this.options.toString()) {155 if (this.data.selected > this.options.length - 1) {156 this.data.selected = 0157 }158 }159 },160 updated () {161 // this.poptarget作为定位目标,判断options和目标位置发生修改才重新定位,避免发生死循环162 if (this.poptarget !== undefined &&163 (this.oldoptions.toString() !== this.options.toString() ||164 JSON.stringify(this.newPoptargetPos()) !== this.poptargetPos)) {165 let obj = this.poptarget.nextElementSibling.nextElementSibling166 if (obj.style.display === 'none') {167 return168 }169 this.oldoptions = this.options.slice()170 this.poptargetPos = JSON.stringify(this.newPoptargetPos())171 this.optionBoxPos = this.relocate(obj)172 }173 }...

Full Screen

Full Screen

aim trainer.js

Source:aim trainer.js Github

copy

Full Screen

...23 24 // 显示目标,目标剩余,以及时间25 document.querySelector('.play-sets').style.display = 'flex'26 details.beginAt = new Date()27 popTarget(details.target)28}29function saveScore(){30 alert('saved to your account')31}32function popTarget(target,ev){33 target.style.display = 'none'34 if(ev){35 let screenW = ev.target.parentNode.parentNode.clientWidth36 let screenH = ev.target.parentNode.parentNode.clientHeight37 // let tW = ev.target.clientWidth38 // let tH = ev.target.clientHeight39 let tW = 10040 let tH = 10041 //变化target的位置42 let rleft = parseInt(Math.random() * screenW-tW)43 let rtop = parseInt(Math.random() * screenH-tH)44 if(rleft<0)rleft = 045 if(rtop<0)rtop = 046 target.style.left = rleft + 'px'47 target.style.top = rtop + 'px'48 }49 target.style.display = 'block'50}51function hitTarget(ev){52 let {currentScore,totalSum} = details53 details.currentScore++54 if(totalSum-currentScore<=1){55 playEnd()56 }else{57 details.remainCount.innerHTML = details.totalSum - details.currentScore58 popTarget(details.target,ev)59 }60}61function playEnd(){62 details.isPlaying = false63 details.endAt = new Date()64 document.querySelector('.play-sets').style.display = 'none'65 document.querySelector('.result').style.display = 'flex'66 document.querySelector('.avarage-time').innerHTML = parseInt((details.endAt - details.beginAt) / details.totalSum) +"ms"67}68function drawTarget(canvas,flag){69 const ctx = canvas.getContext('2d')70 71 ctx.save()72 ...

Full Screen

Full Screen

main.js

Source:main.js Github

copy

Full Screen

1import $ from 'jquery';2(function($) {3if (typeof window === 'undefined') return;4var popTarget;5$.fn.instancitePopup = function(){6 7 $(document).on('click', '.pop-up__btn', function (e) {8 e.preventDefault();9 if ($(this).is('[data-href]')) {10 popTarget = $(this).data("href");11 } else {12 popTarget = $(this).attr("href");13 }14 $(popTarget).wrap("<span class='pop-up__placeholder'></span>")15 $(popTarget).prependTo(".pop-up__content");16 $(".pop-up__content > *").addClass("popWrap");17 $(".pop-up").fadeIn();18 $("body").addClass("popOpen");19 $(".close").click(function() {20 closePopup();21 });22 });23 $(document).keydown(function (e) {24 if (e.keyCode === 27) {25 closePopup();26 }27 });28 $('body').on('click touchstart', function (e) {29 if ($(".pop-up").is(":visible")) {30 if ($(e.target).closest(".popWrap").length === 0) {31 closePopup();32 }33 }34 });35};36function closePopup() {37 if ($(".pop-up").is(":visible")) {38 $(".pop-up").fadeOut(function () {39 $("body").removeClass("popOpen");40 $(".pop-up__content > *").removeClass("popWrap");41 $(popTarget).appendTo(".pop-up__placeholder");42 // $(popTarget).unwrap();43 $(".pop-up__content").html("");44 });45 }46}47$.fn.instancitePopup();...

Full Screen

Full Screen

pop.js

Source:pop.js Github

copy

Full Screen

1var popOpen = null;2var popClose = null;3var popTarget = null;4$(document).ready(function(){5 init();6 popupControl(popOpen,popClose,popTarget);7 // ! popOpen => callPopup을 click 했을 때 popup대상이름을 불러와서 변수에 담아.8 // ! 그 대상이 곧 = popup 변수가 됨.9});10function init(){11 popOpen = $('.callPopup');12 popClose = $('.pop_close');13 popTarget = $('.popup');14}15function popupControl(popOpen,popClose,popTarget){16 $(popOpen).click(function(){17 var activePopName = $(this).attr('data-popName');18 $("#" + activePopName).addClass('active');19 $(popTarget).css({20 "top": (($(window).height()-$(popTarget).outerHeight())/2+$(window).scrollTop())+"px"21 });22 $("body").css("overflow","hidden");23 });24 $(popClose).click(function(){25 $(popTarget).removeClass('active');26 $("body").css("overflow","auto");27 });...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1$(document).ready(function(){2 var popTarget = $(".popup");3 var popClose = $(".pop_close");4 popup($(".callPopup"),popTarget,popClose);5 toggle();6 $('.slider').bxSlider({7 speed: 750,8 infiniteLoop: true,9 touchEnabled: false,10 pager: true11 });12});13function toggle(){14 var $activeTarget = $('header > div > div');15 $('header > div > nav > button').click(function(){16 $activeTarget.toggleClass('active');17 });18}19function popup(popOpen,popTarget,popClose){20 popOpen.click(function(){21 popTarget.addClass("activate");22 });23 popClose.click(function(){24 popTarget.removeClass("activate");25 });...

Full Screen

Full Screen

popup.js

Source:popup.js Github

copy

Full Screen

1function cleanPopup(){2 $('.popup').removeClass('popactive');3}4function openPopup(poptarget){5 console.log('hoa');6 cleanPopup();7 $(poptarget).addClass('popactive').fadeIn();8}9function closePopup(poptarget){10 $('.popactive').fadeOut();11 cleanPopup();12}13$('.popup_opener').on('click', function(){14 var poptarget = '#' + $(this).attr('poptarget');15 openPopup(poptarget);16})17$('.popup_close').on('click', function(){18 closePopup();...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { popTarget } = require('playwright/lib/server/browserContext');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const target = await page.target();8 await popTarget(context, target);9 await browser.close();10})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { popTarget } = require('playwright/lib/server/supplements/recorder/recorderSupplement');2popTarget();3const { pushTarget } = require('playwright/lib/server/supplements/recorder/recorderSupplement');4pushTarget();5const { getTarget } = require('playwright/lib/server/supplements/recorder/recorderSupplement');6getTarget();7const { getAction } = require('playwright/lib/server/supplements/recorder/recorderSupplement');8getAction();9const { setAction } = require('playwright/lib/server/supplements/recorder/recorderSupplement');10setAction();11const { setTarget } = require('playwright/lib/server/supplements/recorder/recorderSupplement');12setTarget();13const { setSelector } = require('playwright/lib/server/supplements/recorder/recorderSupplement');14setSelector();15const { getSelector } = require('playwright/lib/server/supplements/recorder/recorderSupplement');16getSelector();17const { setActionOptions } = require('playwright/lib/server/supplements/recorder/recorderSupplement');18setActionOptions();19const { getActionOptions } = require('playwright/lib/server/supplements/recorder/recorderSupplement');20getActionOptions();21const { setActionText } = require('playwright/lib/server/supplements/recorder/recorderSupplement');22setActionText();23const { getActionText } = require('playwright/lib/server/supplements/recorder/recorderSupplement');24getActionText();25const { setActionURL } = require('playwright/lib/server/supplements/recorder/recorderSupplement');26setActionURL();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { popTarget } = require('playwright/lib/server/supplements/recorder/recorderSupplement.js');2popTarget();3const { pushTarget } = require('playwright/lib/server/supplements/recorder/recorderSupplement.js');4pushTarget();5const { setTarget } = require('playwright/lib/server/supplements/recorder/recorderSupplement.js');6setTarget();7const { setTarget } = require('playwright/lib/server/supplements/recorder/recorderSupplement.js');8setTarget();9const { setTarget } = require('playwright/lib/server/supplements/recorder/recorderSupplement.js');10setTarget();11const { setTarget } = require('playwright/lib/server/supplements/recorder/recorderSupplement.js');12setTarget();13const { setTarget } = require('playwright/lib/server/supplements/recorder/recorderSupplement.js');14setTarget();15const { setTarget } = require('playwright/lib/server/supplements/recorder/recorderSupplement.js');16setTarget();17const { setTarget } = require('playwright/lib/server/supplements/recorder/recorderSupplement.js');18setTarget();19const { setTarget } = require('playwright/lib/server/supplements/recorder/recorderSupplement.js');20setTarget();21const { setTarget } = require('playwright/lib/server/supplements/recorder/recorderSupplement.js');22setTarget();23const {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { popTarget } = require('@playwright/test/lib/server/frames');2const { test, expect } = require('@playwright/test');3test('test', async ({ page }) => {4 await page.click('text="Docs"');5 await page.click('text="API"');6 await page.click('text="Page"');7 await page.click('text="page.$"');8 popTarget();9 await page.click('text="page.$eval"');10 await page.click('text="page.$$"');11 await page.click('text="page.$$eval"');12 await page.click('text="page.$x"');13 await page.click('text="page.$eval"');14 await page.click('text="page.$"');15 await page.click('text="page.$eval"');16 await page.click('text="page.$$eval"');17 await page.click('text="page.$x"');18 await page.click('text="page.$eval"');19 await page.click('text="page.$"');20 await page.click('text="page.$eval"');21 await page.click('text="page.$$eval"');22 await page.click('text="page.$x"');23 await page.click('text="page.$eval"');24 await page.click('text="page.$"');25 await page.click('text="page.$eval"');26 await page.click('text="page.$$eval"');27 await page.click('text="page.$x"');28 await page.click('text="page.$eval"');29 await page.click('text="page.$"');30 await page.click('text="page.$eval"');31 await page.click('text="page.$$eval"');32 await page.click('text="page.$x"');33 await page.click('text="page.$eval"');34 await page.click('text="page.$"');35 await page.click('text="page.$eval"');36 await page.click('text="page.$$eval"');37 await page.click('text="page.$x"');38 await page.click('text="page.$eval"');39 await page.click('text="page.$"');40 await page.click('text="page.$eval"');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { popTarget } = require('@playwright/test/lib/server/frames');2const { popTarget } = require('@playwright/test/lib/server/frames');3const { popTarget } = require('@playwright/test/lib/server/frames');4const { popTarget } = require('@playwright/test/lib/server/frames');5const { popTarget } = require('@playwright/test/lib/server/frames');6const { popTarget } = require('@playwright/test/lib/server/frames');7const { popTarget } = require('@playwright/test/lib/server/frames');8const { popTarget } = require('@playwright/test/lib/server/frames');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { popTarget } = require('playwright/lib/server/browserContext');2const target = popTarget();3const page = await target.page();4const browser = await target.browserContext().browser();5const context = await target.browserContext();6const { popTarget } = require('playwright/lib/server/browserContext');7const target = popTarget();8const page = await target.page();9const browser = await target.browserContext().browser();10const context = await target.browserContext();11const { popTarget } = require('playwright/lib/server/browserContext');12const target = popTarget();13const page = await target.page();14const browser = await target.browserContext().browser();15const context = await target.browserContext();16const { popTarget } = require('playwright/lib/server/browserContext');17const target = popTarget();18const page = await target.page();19const browser = await target.browserContext().browser();20const context = await target.browserContext();21const { popTarget } = require('playwright/lib/server/browserContext');22const target = popTarget();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { popTarget, currentTarget } = require('playwright/lib/internal/frames');2popTarget();3console.log(currentTarget());4const { popTarget, currentTarget } = require('playwright/lib/internal/frames');5test('test', async ({ page }) => {6 await page.evaluate(() => {7 popTarget();8 console.log(currentTarget());9 });10});

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal 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