How to use cd.stop method in Appium Android Driver

Best JavaScript code snippet using appium-android-driver

index.js

Source:index.js Github

copy

Full Screen

1var a_get = getGETArray();2//var g_s_api = 'php/';3var g_s_api = 'https://figurosity.glitch.me/';4var g_localKey = 'figurosity_';5// 本地储存前缀6var g_config = local_readJson('config', {7 thumb_size: 512,8 image_size: 512,9 autoloadThumbs: false,10 viewer_on_click: 0,11 dark_mode: false,12});13var g_v_quickPose = local_readJson('quickPose', {14 "durations": [1],15 "camera_angle": [0, 1, 2],16 "pose_direction": [0, 1],17 "models": [0, 1, 2, 3],18 "gender": [0],19 "light_direction": [0, 1]20});21var g_v_poseSearch = {22 "Drawing references": {23 "page": 1,24 "slug": "" // dogs25 },26 "pose": {27 "page": 1,28 "models": [],29 "cameras": [],30 "gender": [],31 "style": [],32 "action": [],33 "props": [] 34 }35};36var g_v_poseSearch_default = g_v_poseSearch; // 默认37var g_b_loading = false;38var g_i_loading_last = 0;39var g_s_ui_last = 'main';40// 返回到的ui41$(function() {42 if(g_config.dark_mode){43 switchDarkMode();44 }45 if(window.location.protocol == 'file:'){46 $('#option-Image-Size,#option-Thumb-Image-Size,a[href="#modal_fitler"], #option-autoload-thumbs, #camera_angle, #models, #gender').hide();47 $('#load_count').show();48 }49 window.history.pushState(null, null, "#");50 window.addEventListener("popstate", function(event) {51 window.history.pushState(null, null, "#");52 event.preventDefault(true);53 event.stopPropagation();54 showUI();55 //$('#modal1').modal('close');56 }); 57 M.AutoInit();58 $('.chips-placeholder').chips();59 //showUI("pose-search");60 initQuickPose();61 $(document).on('click', '#quick-pose .row div', function(event) {62 if ($(this).attr('data-disable') !== undefined)63 return;64 var parent = $(this).parents(".section");65 if (parent.attr('data-mult') == 'false') {66 parent.find('._active').removeClass('_active');67 }68 $(this).toggleClass('_active');69 if (this.id != '_custom-time') {70 saveQuickPose();71 }72 }).on('change', '#modal_fitler select', function(event) {73 var parent = $(this).parents('.section');74 M.Chips.getInstance(parent.find('.chips')[0]).addChip({75 tag: parent.find('.selected').find('span').html(),76 });77 //getSearchPoseParams();78 });79 $(window).scroll(function() {80 var scrollTop = $(this).scrollTop();81 var i = $(document).height() - (scrollTop + $(this).height());82 if (i <= 30) {83 //滚动条到达底部84 var type;85 var now = new Date().getTime() / 1000;86 if (!g_b_loading && now - g_i_loading_last >= 3) {87 if (!$('#pose-favorites').hasClass('hide')) { // 收藏夹是一次显示完毕88 return;89 }else 90 if (!$('#pose-search').hasClass('hide')) {91 type = 'pose-search';92 }else93 if (!$('#sets').hasClass('hide')) {94 type = $('#sets').attr('data-type');95 } 96 if(type != undefined){97 g_i_loading_last = now;98 g_b_loading = true;99 g_v_poseSearch[g_api.paramType].page++;100 data_query(type); 101 } 102 }103 } else if (scrollTop <= 0) {//滚动条到达顶部104 }105 });106 $('.chips-placeholder input').attr('disabled', true);107 // $('#main').addClass('hide');108 // $('#ui_viewer').removeClass('hide');109 //quickPose_preload();110 //loadId(JSON.parse(`{"id":622,"uuid":"7572040f-60c4-438e-9934-50fb98696be5","render_count":36,"camera_id":1,"favorited_by_current_user":false,"favorite_count":6,"favorite_text":"6 people just love this.","models":[{"id":5,"name":"Mei Lin","slug":"mei-lin","machine_name":"mei-lin","gender_id":111}],"states":[{"id":1,"name":"Dressed","slug":"normal","type":"normal","machine_name":"normal","order":1}]}`));111 // openModal('#modal_setting');112 //showUI('ui_viewer');113});114function viewer_click(){115 switch(g_config.viewer_on_click){116 case '1':117 stop();118 break;119 case '2':120 next_pose();121 break;122 }123}124function saveQuickPose() {125 for (let key of Object.keys(g_v_quickPose)) {126 g_v_quickPose[key] = [];127 $('#' + key + " .row .col").each(function(index, dom) {128 if ($(dom).hasClass('_active')) {129 if (key == 'durations') {130 if ($('#_custom-time').hasClass('_active')) {131 var s = parseInt($('#_custom-time').html().replace('s', ''));132 g_v_quickPose[key] = [-1, s];133 g_v_cd.default = s;134 return false;135 } else {136 g_v_cd.default = $(dom).attr('data-sec');137 }138 }139 g_v_quickPose[key].push(index);140 }141 });142 }143 local_saveJson('quickPose', g_v_quickPose);144 console.log(g_v_quickPose);145}146function getSearchPoseParams(type = '') {147 //{"page":1,"models":["ashley","cara"],"cameras":["default"],"gender":[],"style":["martial-arts-poses"],"action":["flying"],"props":["bow"]}148 var dom;149 if(type == '') type = g_api.paramType;150 if(g_v_poseSearch[type] === undefined) return;151 var value, params = {};152 for (let key in g_v_poseSearch[type]) {153 value = g_v_poseSearch[type][key];154 if (key == "page") {155 params["page"] = value;156 continue;157 }158 dom = $('#ps_' + key + ' .chips');159 if(dom.length > 0){160 params[key] = []; // 数组参数161 for (var d of M.Chips.getInstance(dom[0]).chipsData) {162 params[key].push(d.tag);163 } 164 }else{165 params[key] = value; // 文本参数166 }167 }168 return JSON.stringify(params);169}170function getQuickPoseParams() {171 // {"states":["normal","nude","muscle","smooth"],"gender":[110,111],"cameras":[1,2,3],"museCount":"single","count":10}172 var value, params = {173 "museCount": "single",174 "count": 20175 };176 for (let key in g_v_quickPose) {177 value = g_v_quickPose[key];178 switch (key) {179 case 'models':180 params["states"] = getOtherArrayKey(value, ["normal", "nude", "muscle", "smooth"]);181 break;182 case 'gender':183 params["gender"] = getOtherArrayKey(value, [110, 111]);184 break;185 case 'camera_angle':186 params["cameras"] = getOtherArrayKey(value, [1, 2, 3]);187 break;188 }189 }190 return JSON.stringify(params);191}192function getOtherArrayKey(value, list) {193 var res = [];194 value.forEach(function(index) {195 if (list[index] !== undefined) {196 res.push(list[index]);197 }198 });199 return res;200}201function initQuickPose() {202 var value;203 for (let key in g_v_quickPose) {204 value = g_v_quickPose[key];205 if (key == 'durations') {206 if (value.length > 1) {207 $('#_custom-time').html(value[1] + 's').addClass('_active');208 g_v_cd.default = value[1];209 continue;210 }211 }212 for (let index of value) {213 $('#' + key + " .row .col:eq(" + (index) + ")").addClass('_active');214 }215 }216}217function confirm_setCustomTime() {218 x0p({219 title: 'Custom Duration',220 type: 'warning',221 inputType: 'text',222 inputPlaceholder: 'Seconed',223 inputColor: '#F29F3F',224 inputPromise: function(button, value) {225 var p = new Promise(function(resolve, reject) {226 if (value == '' || isNaN(value) || value <= 0)227 resolve('Not a number!');228 resolve(null);229 }230 );231 return p;232 }233 }, function(button, text) {234 if (button == 'warning') {235 $('#_custom-time').html(text + 's').addClass('_active');236 saveQuickPose();237 }238 });239}240var g_dirs = [];241var g_b_stopAjax = false;242function loadJs(file, success = function(){}, fail = function(){}){243 var D = document;244 var scriptNode = D.createElement('script');245 scriptNode.type = "text/javascript";246 scriptNode.src = file;247 var targ = D.getElementsByTagName('head')[0] || D.body || D.documentElement;248 targ.appendChild(scriptNode);249 scriptNode.onload = function() {250 success();251 } 252 scriptNode.onerror = function() {253 fail();254 } 255 return scriptNode; 256}257function loadLocalData(success = function(){}, fail = function(){}){258 loadJs('./figurosity.js', function(){259 console.log(g_dirs.length);260 success();261 }, function(){262 fail();263 });264}265function quickPose_preload() {266 setLoading(true);267 if (window.location.protocol == 'file:') {268 loadLocalData(function(){269 if(g_dirs.length === 0){270 setLoading(false);271 return alert('请先运行 "点我更新figurosity图片目录.exe" 程序再使用此功能!');272 } 273 var json = {274 data: shuffle(g_dirs, $('#load_count input').val())275 };276 data_load('quickpose', json); 277 278 }, function(){279 setLoading(false);280 alert('请先运行 "点我更新figurosity图片目录.exe" 程序再使用此功能!');281 });282 }else{283 var url = g_s_api+'api.php?type=quick-pose&data=' + getQuickPoseParams();284 g_ajax = $.ajax({285 url: url,286 method: 'GET',287 // async: false,288 dataType: 'json',289 success: function(json) {290 if(g_b_stopAjax){g_b_stopAjax = false; return};291 data_load('quickpose', json);292 }293 }).always(function() {294 //setLoading(false);295 }); 296 }297 298}299var g_v_poses = [];300//加载的pose列表301var g_i_list_index = 0; // 本地列表查看的索引302function data_query(type) {303 switch(type){304 case 'pose-search':305 $('#'+type+' .-count').html('Loading...');306 break;307 case 'pose-favorites':308 $('#pose-favorites .-list').html('');309 var data = {data: []};310 for(var d in g_v_favorites){311 data.data.push(d.replace('id-', ''));312 }313 data_load(type, data);314 return;315 }316 if (window.location.protocol == 'file:') {317 loadLocalData(function(){318 if(g_dirs.length === 0){319 setLoading(false);320 return alert('请先运行 "点我更新figurosity图片目录.exe" 程序再使用此功能!');321 } 322 var start = g_i_list_index;323 g_i_list_index += 30;324 var json = {325 data: g_dirs.slice(start, g_i_list_index)326 };327 data_load(type, json);328 setLoading(false);329 }, function(){330 setLoading(false);331 alert('加载数据失败!');332 }); 333 }else{334 var url = g_s_api+'api.php?type='+g_api.type+'&data=' + getSearchPoseParams();335 g_i_loading_last = new Date().getTime() / 1000; // 防止直接进入页尾触发刷新336 setLoading(true);337 g_ajax = $.ajax({338 url: url,339 method: 'GET',340 // async: false,341 dataType: 'json',342 success: function(json) {343 if(g_b_stopAjax){g_b_stopAjax = false; return};344 data_load(type, json);345 }346 }).always(function() {347 $('#btn-search').html('SEARCH');348 setLoading(false);349 }); 350 }351 352}353function data_load(type, json){354 console.log(json);355 var selecter;356 switch(type){357 case 'pose-search':358 case 'pose-favorites':359 g_s_ui_last = type;360 // total: 7633 total_pages: 191361 selecter = '#'+type+' .-list';362 $('#'+type+' .-count').html((window.location.protocol == 'file:' ? type == 'pose-favorites' ? json.data.length : g_dirs.length : json.poses.meta.total) + ' Poses'); 363 break;364 case 'dogs':365 case 'horses':366 case 'superhero-poses':367 case 'martial-arts-poses':368 case 'girls-with-guns-poses': 369 g_s_ui_last = 'sets';370 selecter = '#sets .-cover_list';371 break;372 case 'quickpose':373 g_s_ui_last = 'quick-pose';374 $('#quick-pose').addClass('hide');375 $('#ui_viewer').removeClass('hide');376 // json.total377 if ($('#x0popup').length > 0) {378 x0p('Done', null, 'ok', false);379 }380 return quickPose_load(json.data);381 }382 var html = '';383 var data = json.poses != undefined ? json.poses.data : json.data;384 for (var d of data) {385 if(typeof(d) !== 'object'){ // 本地数据386 d = {387 id: d,388 uuid: d389 };390 }391 g_v_poses["id-" + d.id] = d;392 html = html + `<div class="col s6">393 <img class="lazyload" onclick="loadViewer(` + d.id + `)" src="images/loading.gif" data-src="` + getImageUrl(d.uuid, 'normal').replace('{size}', g_config.thumb_size).replace('{offset}', getOffsetString('00')) + `">394 <p>`+d.id+`</p>395 </div>`;396 }397 $(selecter).append(html); 398 $(selecter + " .lazyload").lazyload({effect: "fadeIn"});399}400// 定时器401var g_v_timer = {402 'quick_pose': 0,403};404// 倒计时405var g_v_cd = {406 'playTime': 0,407 // 总计时408 'default': 3,409 // 默认值410 'main': -1,411 // 倒计时412 'stop': true,413 'next': -1,414 //到下张的倒计时415 'next_default': 3,416 //默认到下张的倒计时417};418var g_quickPose = {};419function quickPose_load(data) {420 g_s_ui_last = 'main';421 g_quickPose = data;422 g_quickPose.index = 0;423 $(window).bind('keydown', function(ev) {424 switch (ev.key) {425 case 'ArrowRight':426 offset_next();427 break;428 case 'ArrowLeft':429 offset_prev();430 break;431 }432 });433 var t;434 g_v_timer.quick_pose = setInterval(function() {435 g_v_cd.playTime++;436 $('#_playSec').html(getTimeString(g_v_cd.playTime));437 t = g_v_cd.next;438 if (t > 0) {439 $('#_sec-next').html(_s1(t));440 if (--g_v_cd.next == 0) {441 stop(true);442 // 稍微延迟看起来更自然443 setTimeout(function() {444 next_pose(true);445 }, 500);446 }447 return;448 }449 if (!g_v_cd.stop) {450 var sec = --g_v_cd.main;451 if (sec < 0) {452 if (g_v_cd.next_default > 0) {453 $('#viewer img').css('opacity', 0);454 g_v_cd.next = g_v_cd.next_default;455 $('#_sec-next').html('').removeClass('hide');456 return;457 }458 stop(true);459 next_pose(true);460 }else{461 let s = _s1(sec);462 $('#_sec').html(s == '' ? '<i class="material-icons">refresh</i>' : s);463 }464 }465 }, 1000);466 loadIndex(g_quickPose.index);467 // 预加载所有图片第一张468 g_a_offsets = [];469 var offset, key, img, model = '', size = g_config.image_size;470 for (var d of data) {471 if(typeof(d) !== 'object'){ // 本地数据472 d = {473 id: d,474 uuid: d475 };476 } 477 offset = getOffsetString(randNum(0, 32));478 // TODO 随机479 g_a_offsets["id-" + d.id] = offset;480 model = getDefaultModel();481 if (g_v_viewing.model != 'normal' && d.states != undefined) {482 // 默认的不用找483 for (var m of d.states) {484 if (m.type == g_v_viewing.model) {485 model = m.type;486 // 找到了487 break;488 }489 }490 }491 key = model + '-' + offset + '-' + size;492 preloadImage(d.id, key, getImageUrl(d.uuid, model).replace('{size}', size).replace('{offset}', offset));493 }494 // start_countDown();495}496var g_v_style;497function switchDarkMode(){498 if(g_v_style === undefined){499 g_v_style = insertStyle(`500 * {501 background-color: #2f2f2f !important;502 color: #c5c5c5 !important;503 }`); 504 }else{505 g_v_style.remove();506 g_v_style = undefined;507 }508}509function getDefaultModel(){510 return $('#model-Always').prop("checked") ? $('#dropdown1 .active').attr('data-value') : 'normal';511}512function getImageUrl(uuid, model) {513 if (window.location.protocol == 'file:') {514 return '../figurosity/'+uuid+'/'+model + '/{offset}.jpg';515 }516 return 'https://love.figurosity.com/muses/' + uuid.substr(0, 2) + '/' + uuid.substr(2, 2) + '/' + uuid.substr(4, 2) + '/' + uuid + '/' + model + '/{size}/pose-{offset}.jpg';517}518var g_b_autoStart = true; // 是否在图片加载完毕后自动开始计时519function next_pose(start = false) {520 if(g_quickPose.length == {}) return;521 g_b_autoStart = start;522 if (g_quickPose.index == g_quickPose.length - 1) {523 // 到底了524 x0p({525 title: 'Want load more?',526 text: '',527 icon: 'info',528 animationType: 'fadeIn',529 buttons: [{530 type: 'cancel'531 }, {532 type: 'ok',533 text: 'More',534 showLoading: true535 }, {536 type: 'info',537 text: 'Again'538 }]539 }).then(function(data) {540 if (data.button == 'ok') {541 quickPose_preload();542 // setTimeout(function() {543 // }, 1500);544 } else if (data.button == 'info') {545 g_quickPose.index = 0;546 loadIndex(0);547 start_countDown();548 }549 });550 quickPose_end();551 return;552 }553 loadIndex(++g_quickPose.index);554}555function loadViewer(id) {556 var json = g_v_poses["id-" + id];557 g_v_showing = json;558 showUI("ui_viewer");559 loadId(json);560}561function reset_fitler() {562 $('.chips').each(function(index, el) {563 M.Chips.getInstance(el).chipsData = [];564 });565 $('.chips-placeholder').chips();566}567function showUI(id = '') {568 var back = id == '';569 if(back) id = g_s_ui_last;570 $('.container').each(function(index, el) {571 if (el.id == id) {572 $(el).removeClass('hide');573 } else {574 $(el).addClass('hide');575 }576 });577 if(back){578 g_s_ui_last = 'main';579 quickPose_end(); // 结束计时580 }581}582function prev_pose() {583 if(g_quickPose.length == {}) return;584 if (g_quickPose.index == 0) {585 // 到底了586 return;587 }588 loadIndex(--g_quickPose.index);589}590var g_v_showing; // 正在展示的json信息591function loadIndex(index) {592 $('#_index').html((index + 1) + '/' + g_quickPose.length);593 g_v_showing = g_quickPose[index];594 loadId(g_v_showing);595}596function quickPose_end() {597 if (g_v_timer.quick_pose > 0) {598 clearInterval(g_v_timer.quick_pose);599 g_v_timer.quick_pose = 0;600 }601}602var g_v_viewing;603// json604var g_a_offsets = [];605// 预先加载的offset - quickpose606function loadId(json) {607 if(typeof(json) !== 'object'){ // 本地数据608 json = {609 id: json,610 uuid: json611 };612 } 613 $('#_sec').html('<i class="material-icons">refresh</i>');614 g_v_viewing = {615 'data': json,616 'model': getDefaultModel(),617 'eyeLevel': 'Street'618 };619 g_v_cd.main = g_v_cd.default;620 // 读取预先随机生成的offset621 var offset = g_a_offsets["id-" + json.id] == undefined ? 0 : g_a_offsets["id-" + json.id];622 loadImage(json.id, json.uuid, offset, '', g_v_viewing.model);623 // {"id":5,"name":"Mei Lin","slug":"mei-lin","machine_name":"mei-lin","gender_id":111}624 //model.name; 625 626 var arr1 = [], dom;627 if(json.states == undefined){ // 本地没有数据记录628 arr1 = ["normal", "nude", "muscle", "smooth"];629 }else{630 for(var d of json.states) arr1.push(d.type);631 }632 for(var skin of ["normal", "nude", "muscle", "smooth"]){633 dom = $('#dropdown1 li[data-value="'+skin+'"]');634 if(g_api.type != 'quick-pose' && arr1.indexOf(skin) === -1){635 // quickpose 只会返回一种模型,直接无视掉636 dom.hide();637 }else{638 dom.show();639 }640 }641}642function start_countDown() {643 g_v_cd.stop = false;644 stop(false);645}646function loadImage(id, uuid, offset='00', size='', model='normal') {647 if(size == '') size = g_config.image_size;648 setRotate(0);649 $('#range').val(parseInt(offset)).focus();650 if (g_v_favorites["id-" + id] !== undefined) {651 $('#favorite').html('favorite');652 } else {653 $('#favorite').html('favorite_border');654 }655 offset = getOffsetString(offset);656 var img = getImageUrl(uuid, model);657 var key = model + '-' + offset + '-' + size;658 if (g_a_preloadImages[id] !== undefined && g_a_preloadImages[id][key] !== undefined && g_a_preloadImages[id][key][1]) {659 // 已经预加载过660 $('._control ._title').html('');661 imageLoader($('#viewer img').attr('src', img.replace('{size}', size).replace('{offset}', offset)), function(){662 checkAutoStart();663 });664 } else {665 g_v_cd.stop = true // 先暂停666 if($('#pause').html() == 'play_arrow'){ // 倒计时中,没有人为暂停667 if (window.location.protocol !== 'file:') {668 imageLoader($('#viewer img').attr('src', img.replace('{size}', 100).replace('{offset}', offset)), function(){669 console.log('11');670 g_v_cd.stop = false;671 }); 672 }673 }674 // 675 preloadImage_single(img.replace('{size}', size).replace('{offset}', offset));676 }677 if (g_v_viewing.thumbs == undefined && $('#autoload-thumbs').prop('checked')) { // 加载略缩图678 g_v_viewing.thumbs = true;679 // preload all images680 for (var i = 0; i <= 32; i++) {681 preloadImage(id, model + '-' + _s(i) + '-100', img.replace('{size}', 100).replace('{offset}', _s(i)));682 // preloadImage(id, model + '-' + _s(i) + '-' + size, img.replace('{size}', size).replace('{offset}', _s(i)));683 }684 } 685}686function getOffsetString(offset){687 return window.location.protocol == 'file:' ? parseInt(offset) : _s(offset);688}689// TODO690function imageLoader(dom, f) {691 dom.imagesLoaded().fail(function(instance) {692 console.log('加载失败');693 // instance.images[0].img.src = instance.images[0].src;694 // instance.images[0].src = ''; // 404695 }).done(function(instance) {696 instance.images[0].img.style.opacity = 1;697 //console.log('加载成功');698 }).always(function(instance) {699 $('#_sec-next').html('').addClass('hide');700 f();701 })702 // .progress(function(instace, image){703 // console.log("progress");704 // });705}706function setModel(model) {707 if (model != g_v_viewing.model) {708 $('.active').removeClass('active');709 $('#dropdown1 li[data-value="'+model+'"]').addClass('active');710 g_v_viewing.model = model;711 $('._control ._title').html('Loading ' + model);712 initImage();713 }714}715function setEyeLevel(level) {716 if (level != g_v_viewing.level) {717 g_v_viewing.eyeLevel = level;718 initImage();719 }720}721function initImage(thumb=false) {722 loadImage(g_v_viewing.data.id, g_v_viewing.data.uuid, g_v_viewing.offset, thumb ? 100 : g_v_viewing.size, g_v_viewing.model);723}724function event_rangeChange(thumb=false) {725 g_v_viewing.offset = getOffsetString($('#range').val());726 initImage(thumb);727}728var g_api = {729 'type': '', // api类型730 'paramType': '', //参数类型731}732function _view(name) {733 g_s_ui_last = 'main';734 var f = function(){};735 g_api.type = name;736 switch (name) {737 case 'quick-pose':738 g_api.paramType = 'pose';739 f = function(){740 showUI('quick-pose');741 }742 break;743 case 'pose-search':744 g_api.paramType = 'pose';745 f = function(){746 showUI('pose-search');747 if (g_v_poses.length == 0) {748 data_query('pose-search');749 } 750 }751 752 break;753 case 'favorites':754 g_api.paramType = 'favorites';755 f = function(){756 showUI('pose-favorites');757 data_query('pose-favorites');758 }759 break; 760 case 'dogs':761 case 'horses':762 case 'superhero-poses':763 case 'martial-arts-poses':764 case 'girls-with-guns-poses':765 if(window.location.protocol == 'file:') return alert('本地端暂不支持,可以在网页版查看!');766 g_api.paramType = 'Drawing references';767 f = function(){768 g_v_poseSearch[g_api.paramType]['slug'] = name;769 var d = $('#sets').attr('data-type', name);770 d.find('.-header img')[0].src = './images/'+name+'.jpg';771 d.find('.-cover_list').html('');772 data_query(name);773 showUI('sets');774 }775 break; 776 }777 g_v_poseSearch[g_api.paramType] = g_v_poseSearch_default[g_api.paramType]; // 重置参数778 f();779}780function offset_next() {781 var offset = parseInt($('#range').val());782 if (offset < 32) {783 setOffset(++offset);784 }785}786function offset_prev() {787 var offset = parseInt($('#range').val());788 if (offset > 0) {789 setOffset(--offset);790 }791}792function setOffset(offset) {793 g_b_autoStart = false; // 在调整的时候不自动开始计时794 $('#range').val(offset).focus();795 g_v_viewing.offset = offset;796 initImage();797}798var g_v_image_single = new Image();799g_v_image_single.onload = function() {800 // 图片加载完毕801 $('#viewer img').attr('src', this.src).css('opacity', 1);802 $('._control ._title').html('');803 setLoading(false);804 if($('#pause').html() == 'pause'){805 start_countDown();806 }807}808function checkAutoStart(){809 if(g_b_autoStart) {810 g_b_autoStart = false;811 start_countDown();812 }813}814function preloadImage_single(src) {815 g_v_image_single.src = src;816}817function stop(b) {818 if (g_v_timer.quick_pose === 0) return;819 if(b === undefined){820 g_v_cd.stop = !g_v_cd.stop;821 }else{822 g_v_cd.stop = b;823 }824 $('#pause').html(g_v_cd.stop ? 'play_arrow' : 'pause');825}826function download(url='') {827 if (url == '')828 url = $('#viewer img').attr('src');829 fetch(url).then(res=>res.blob().then(blob=>{830 var a = document.createElement('a');831 var url = window.URL.createObjectURL(blob);832 a.href = url;833 a.download = g_v_viewing.data.id + '-' + g_v_viewing.model + '-' + g_v_viewing.offset + '.jpg';834 a.click();835 window.URL.revokeObjectURL(url);836 }837 ))838}839function setLoading(b, title = 'cancel'){840 g_b_loading = b;841 if(b){842 hsycms.loading('loading', title);843 }else{844 hsycms.hideLoading('loading');845 }846}847var g_ajax; // 网络请求848function cancelLoading(){849 g_b_stopAjax = true;850 if(g_ajax !== undefined){851 g_ajax.fail();852 g_ajax = undefined;853 }854}855var g_v_favorites = local_readJson('favorites', {});856function favorite(dom=null, json=null, b=null) {857 if (json === null)858 json = g_v_viewing.data;859 var key = "id-" + json.id;860 if (g_v_favorites[key] == undefined) {861 if (b === null)862 b = true;863 } else {864 if (b === null)865 b = false;866 }867 if (b) {868 g_v_favorites[key] = json;869 } else {870 delete (g_v_favorites[key]);871 }872 if (dom !== null) {873 dom.html(b ? 'favorite' : 'favorite_border');874 }875 local_saveJson('favorites', g_v_favorites);876 return b;877}878var g_a_preloadImages = [];879function preloadImage(id, offset, src) {880 // console.log('preload : ' + id + ' ' + offset);881 return new Promise(function(resolve, reject) {882 if (g_a_preloadImages[id] == undefined) {883 g_a_preloadImages[id] = [];884 }885 let img = new Image();886 g_a_preloadImages[id][offset] = [img, false];887 img.onload = function() {888 g_a_preloadImages[id][offset][1] = true;889 // console.log('图像加载完毕');890 // checkAutoStart();891 resolve(img);892 //加载时执行resolve函数893 }894 img.onerror = function() {895 reject(src + '这个地址错误');896 //抛出异常时执行reject函数897 }898 img.src = src;899 }900 )901}902var g_i_current = 0;903function spturn(){904 g_i_current = 0;905 var d = $('#ui_viewer img');906 //d[0].style.transform = 'rotate(0deg)';907 d.toggleClass('mirrorRotateLevel');908}909function czturn(){910 g_i_current = 0;911 var d = $('#ui_viewer img');912 //d[0].style.transform = 'rotate(0deg)';913 d.toggleClass('mirrorRotateVertical');914}915function turnLeft(){916 g_i_current = (g_i_current-90)%360;917 setRotate(g_i_current);918}919function turnRight(){920 g_i_current = (g_i_current+90)%360;921 setRotate(g_i_current);922}923function setRotate(rotate){924 $('#ui_viewer img')925 .removeClass('mirrorRotateLevel')926 .removeClass('mirrorRotateVertical')927 [0].style.transform = 'rotate('+rotate+'deg)'; 928}929function openModal(type){930 switch(type){931 case '#modal_setting':932 $('#Thumb-Image-Size option[value="'+g_config.thumb_size+'"]')[0].selected = true;933 $('#Image-Size option[value="'+g_config.image_size+'"]')[0].selected = true;934 $('#viewer-click-action option[value="'+g_config.viewer_on_click+'"]')[0].selected = true;935 $('#autoload-thumbs').prop("checked", g_config.autoloadThumbs);936 $('#dark-mode').prop("checked", g_config.dark_mode);937 break;938 default:939 return;940 }941 $('select').formSelect(); // 更新942 $(type).modal('open');943}944function applySetting(){945 g_config.thumb_size = $('#Thumb-Image-Size').val();946 g_config.image_size = $('#Image-Size').val();947 g_config.viewer_on_click = $('#viewer-click-action').val();948 g_config.autoloadThumbs = $('#autoload-thumbs').prop('checked');949 g_config.dark_mode = $('#dark-mode').prop('checked');950 local_saveJson('config', g_config);...

Full Screen

Full Screen

timer.js

Source:timer.js Github

copy

Full Screen

1$(document).ready(function() {2 (function($){3 4 $.extend({5 6 APP : { 7 8 formatTimer : function(a) {9 if (a < 10) {10 a = '0' + a;11 } 12 return a;13 }, 14 15 startTimer : function(dir) {16 17 var a;18 19 // save type20 $.APP.dir = dir;21 22 // get current date23 $.APP.d1 = new Date();24 25 switch($.APP.state) {26 27 case 'pause' :28 29 // resume timer30 // get current timestamp (for calculations) and31 // substract time difference between pause and now32 $.APP.t1 = $.APP.d1.getTime() - $.APP.td; 33 34 break;35 36 default :37 38 // get current timestamp (for calculations)39 $.APP.t1 = $.APP.d1.getTime(); 40 41 // if countdown add ms based on seconds in textfield42 if ($.APP.dir === 'cd') {43 $.APP.t1 += parseInt($('#cd_seconds').val())*1000;44 } 45 46 break;47 48 } 49 50 // reset state51 $.APP.state = 'alive'; 52 $('#' + $.APP.dir + '_status').html('Running');53 54 // start loop55 $.APP.loopTimer();56 57 },58 59 pauseTimer : function() {60 61 // save timestamp of pause62 $.APP.dp = new Date();63 $.APP.tp = $.APP.dp.getTime();64 65 // save elapsed time (until pause)66 $.APP.td = $.APP.tp - $.APP.t1;67 68 // change button value69 $('#' + $.APP.dir + '_start').val('Resume');70 71 // set state72 $.APP.state = 'pause';73 $('#' + $.APP.dir + '_status').html('Paused');74 75 },76 77 stopTimer : function() {78 79 // change button value80 $('#' + $.APP.dir + '_start').val('Restart'); 81 82 // set state83 $.APP.state = 'stop';84 $('#' + $.APP.dir + '_status').html('Stopped');85 86 },87 88 resetTimer : function() {89 // reset display90 $('#' + $.APP.dir + '_ms,#' + $.APP.dir + '_s,#' + $.APP.dir + '_m,#' + $.APP.dir + '_h').html('00'); 91 92 // change button value93 $('#' + $.APP.dir + '_start').val('Start'); 94 95 // set state96 $.APP.state = 'reset'; 97 $('#' + $.APP.dir + '_status').html('Reset & Idle again');98 99 },100 101 endTimer : function(callback) {102 103 // change button value104 $('#' + $.APP.dir + '_start').val('Restart');105 106 // set state107 $.APP.state = 'end';108 109 // invoke callback110 if (typeof callback === 'function') {111 callback();112 } 113 114 }, 115 116 loopTimer : function() {117 118 var td;119 var d2,t2;120 121 var ms = 0;122 var s = 0;123 var m = 0;124 var h = 0;125 126 if ($.APP.state === 'alive') {127 128 // get current date and convert it into 129 // timestamp for calculations130 d2 = new Date();131 t2 = d2.getTime(); 132 133 // calculate time difference between134 // initial and current timestamp135 if ($.APP.dir === 'sw') {136 td = t2 - $.APP.t1;137 // reversed if countdown138 } else {139 td = $.APP.t1 - t2;140 if (td <= 0) {141 // if time difference is 0 end countdown142 $.APP.endTimer(function(){143 $.APP.resetTimer();144 $('#' + $.APP.dir + '_status').html('Ended & Reset');145 });146 } 147 } 148 149 // calculate milliseconds150 ms = td%1000;151 if (ms < 1) {152 ms = 0;153 } else { 154 // calculate seconds155 s = (td-ms)/1000;156 if (s < 1) {157 s = 0;158 } else {159 // calculate minutes 160 var m = (s-(s%60))/60;161 if (m < 1) {162 m = 0;163 } else {164 // calculate hours165 var h = (m-(m%60))/60;166 if (h < 1) {167 h = 0;168 } 169 } 170 }171 }172 173 // substract elapsed minutes & hours174 ms = Math.round(ms/100);175 s = s-(m*60);176 m = m-(h*60); 177 178 // update display179 $('#' + $.APP.dir + '_ms').html($.APP.formatTimer(ms));180 $('#' + $.APP.dir + '_s').html($.APP.formatTimer(s));181 $('#' + $.APP.dir + '_m').html($.APP.formatTimer(m));182 $('#' + $.APP.dir + '_h').html($.APP.formatTimer(h));183 184 // loop185 $.APP.t = setTimeout($.APP.loopTimer,1);186 187 } else {188 189 // kill loop190 clearTimeout($.APP.t);191 return true;192 193 } 194 195 }196 197 } 198 199 });200 201 $('#record').on('click', function() {202 document.getElementById('status').innerHTML = "Recording";203 $.APP.startTimer('sw');204 }); 205 $('#start').on('click', function() {206 $.APP.startTimer('cd');207 }); 208 209 $('#stop,#cd_stop').on('click', function() {210 document.getElementById('status').innerHTML = "Recording Stopped";211 $.APP.stopTimer();212 });213 214 $('#reset,#cd_reset').on('click', function() {215 $('#time').show();216 document.getElementById('status').innerHTML = "No Recording";217 $.APP.resetTimer();218 }); 219 220 $('#sw_pause,#cd_pause').on('click', function() {221 $.APP.pauseTimer();222 }); 223 224 })(jQuery);225 ...

Full Screen

Full Screen

stop-watch.js

Source:stop-watch.js Github

copy

Full Screen

1$(document).ready(function() {2 (function($){3 4 $.extend({5 6 APP : { 7 8 formatTimer : function(a) {9 if (a < 10) {10 a = '0' + a;11 } 12 return a;13 }, 14 15 startTimer : function(dir) {16 17 var a;18 19 // save type20 $.APP.dir = dir;21 22 // get current date23 $.APP.d1 = new Date();24 25 switch($.APP.state) {26 27 case 'pause' :28 29 // resume timer30 // get current timestamp (for calculations) and31 // substract time difference between pause and now32 $.APP.t1 = $.APP.d1.getTime() - $.APP.td; 33 34 break;35 36 default :37 38 // get current timestamp (for calculations)39 $.APP.t1 = $.APP.d1.getTime(); 40 41 // if countdown add ms based on seconds in textfield42 if ($.APP.dir === 'cd') {43 $.APP.t1 += parseInt($('#cd_seconds').val())*1000;44 } 45 46 break;47 48 } 49 50 // reset state51 $.APP.state = 'alive'; 52 $('#' + $.APP.dir + '_status').html('Running');53 54 // start loop55 $.APP.loopTimer();56 57 },58 59 pauseTimer : function() {60 61 // save timestamp of pause62 $.APP.dp = new Date();63 $.APP.tp = $.APP.dp.getTime();64 65 // save elapsed time (until pause)66 $.APP.td = $.APP.tp - $.APP.t1;67 68 // change button value69 $('#' + $.APP.dir + '_start').val('Resume');70 71 // set state72 $.APP.state = 'pause';73 $('#' + $.APP.dir + '_status').html('Paused');74 75 },76 77 stopTimer : function() {78 79 // change button value80 $('#' + $.APP.dir + '_start').val('Restart'); 81 82 // set state83 $.APP.state = 'stop';84 $('#' + $.APP.dir + '_status').html('Stopped');85 86 },87 88 resetTimer : function() {89 // reset display90 $('#' + $.APP.dir + '_ms,#' + $.APP.dir + '_s,#' + $.APP.dir + '_m,#' + $.APP.dir + '_h').html('00'); 91 92 // change button value93 $('#' + $.APP.dir + '_start').val('Start'); 94 95 // set state96 $.APP.state = 'reset'; 97 $('#' + $.APP.dir + '_status').html('Reset & Idle again');98 99 },100 101 endTimer : function(callback) {102 103 // change button value104 $('#' + $.APP.dir + '_start').val('Restart');105 106 // set state107 $.APP.state = 'end';108 109 // invoke callback110 if (typeof callback === 'function') {111 callback();112 } 113 114 }, 115 116 loopTimer : function() {117 118 var td;119 var d2,t2;120 121 var ms = 0;122 var s = 0;123 var m = 0;124 var h = 0;125 126 if ($.APP.state === 'alive') {127 128 // get current date and convert it into 129 // timestamp for calculations130 d2 = new Date();131 t2 = d2.getTime(); 132 133 // calculate time difference between134 // initial and current timestamp135 if ($.APP.dir === 'sw') {136 td = t2 - $.APP.t1;137 // reversed if countdown138 } else {139 td = $.APP.t1 - t2;140 if (td <= 0) {141 // if time difference is 0 end countdown142 $.APP.endTimer(function(){143 $.APP.resetTimer();144 $('#' + $.APP.dir + '_status').html('Ended & Reset');145 });146 } 147 } 148 149 // calculate milliseconds150 ms = td%1000;151 if (ms < 1) {152 ms = 0;153 } else { 154 // calculate seconds155 s = (td-ms)/1000;156 if (s < 1) {157 s = 0;158 } else {159 // calculate minutes 160 var m = (s-(s%60))/60;161 if (m < 1) {162 m = 0;163 } else {164 // calculate hours165 var h = (m-(m%60))/60;166 if (h < 1) {167 h = 0;168 } 169 } 170 }171 }172 173 // substract elapsed minutes & hours174 ms = Math.round(ms/100);175 s = s-(m*60);176 m = m-(h*60); 177 178 // update display179 $('#' + $.APP.dir + '_ms').html($.APP.formatTimer(ms));180 $('#' + $.APP.dir + '_s').html($.APP.formatTimer(s));181 $('#' + $.APP.dir + '_m').html($.APP.formatTimer(m));182 $('#' + $.APP.dir + '_h').html($.APP.formatTimer(h));183 184 // loop185 $.APP.t = setTimeout($.APP.loopTimer,1);186 187 } else {188 189 // kill loop190 clearTimeout($.APP.t);191 return true;192 193 } 194 195 }196 197 } 198 199 });200 201 $('#sw_start').live('click', function() {202 $.APP.startTimer('sw');203 }); 204 $('#cd_start').live('click', function() {205 $.APP.startTimer('cd');206 }); 207 208 $('#sw_stop,#cd_stop').live('click', function() {209 $.APP.stopTimer();210 });211 212 $('#sw_reset,#cd_reset').live('click', function() {213 $.APP.resetTimer();214 }); 215 216 $('#sw_pause,#cd_pause').live('click', function() {217 $.APP.pauseTimer();218 }); 219 220 })(jQuery);221 ...

Full Screen

Full Screen

app_stopwatch.js

Source:app_stopwatch.js Github

copy

Full Screen

1/**2 * 3 * Modified version of JQUERY: STOPWATCH & COUNTDOWN by marc.fuehnen(at)gmail.com4 * 5 */6$(document).ready(function() {7 (function($){8 $.extend({9 APP : { 10 formatTimer : function(a) {11 if (a < 10) {12 a = '0' + a;13 } 14 return a;15 }, 16 17 startTimer : function(dir) {18 var a;19 20 // save type21 $.APP.dir = dir;22 23 // get current date24 $.APP.d1 = new Date();25 26 switch($.APP.state) {27 case 'pause' :28 // resume timer29 // get current timestamp (for calculations) and30 // substract time difference between pause and now31 $.APP.t1 = $.APP.d1.getTime() - $.APP.td; 32 break;33 34 default :35 // get current timestamp (for calculations)36 $.APP.t1 = $.APP.d1.getTime(); 37 38 // if countdown add ms based on seconds in textfield39 if ($.APP.dir === 'cd') {40 $.APP.t1 += parseInt($('#cd_seconds').val())*1000;41 }42 break;43 } 44 45 // reset state46 $.APP.state = 'alive';47 48 // start loop49 $.APP.loopTimer();50 },51 52 pauseTimer : function() {53 // save timestamp of pause54 $.APP.dp = new Date();55 $.APP.tp = $.APP.dp.getTime();56 57 // save elapsed time (until pause)58 $.APP.td = $.APP.tp - $.APP.t1;59 60 // set state61 $.APP.state = 'pause';62 },63 resumeTimer : function(dir, string_date) {64 // save timestamp of pause65 $.APP.dp = new Date(string_date);66 $.APP.tp = new Date();67 68 // save elapsed time (until pause)69 $.APP.td = $.APP.tp.getTime() - $.APP.dp.getTime();70 $.APP.state = 'pause';71 this.startTimer(dir);72 },73 74 stopTimer : function() {75 $.APP.state = 'stop';76 },77 78 resetTimer : function() {79 $.APP.state = 'reset';80 },81 82 endTimer : function(callback) {83 $.APP.state = 'end';84 85 // invoke callback86 if (typeof callback === 'function') {87 callback();88 }89 }, 90 91 loopTimer : function() {92 93 var td;94 var d2,t2;95 96 var ms = 0;97 var s = 0;98 var m = 0;99 var h = 0;100 101 if ($.APP.state === 'alive') {102 103 // get current date and convert it into 104 // timestamp for calculations105 d2 = new Date();106 t2 = d2.getTime(); 107 108 // calculate time difference between109 // initial and current timestamp110 if ($.APP.dir === 'sw') {111 td = t2 - $.APP.t1;112 // reversed if countdown113 } else {114 td = $.APP.t1 - t2;115 if (td <= 0) {116 // if time difference is 0 end countdown117 $.APP.endTimer(function(){118 $.APP.resetTimer();119 //# $('#' + $.APP.dir + '_status').html('Ended & Reset');120 });121 } 122 } 123 124 // calculate milliseconds125 ms = td%1000;126 if (ms < 1) {127 ms = 0;128 } else { 129 // calculate seconds130 s = (td-ms)/1000;131 if (s < 1) {132 s = 0;133 } else {134 // calculate minutes 135 var m = (s-(s%60))/60;136 if (m < 1) {137 m = 0;138 } else {139 // calculate hours140 var h = (m-(m%60))/60;141 if (h < 1) {142 h = 0;143 } 144 } 145 }146 }147 148 // substract elapsed minutes & hours149 ms = Math.round(ms/100);150 s = s-(m*60);151 m = m-(h*60); 152 153 // update display154 // appTimer.ts.ms = $.APP.formatTimer(ms);155 // hardcoding the appTimer variable here156 appTimer.sw.s = $.APP.formatTimer(s);157 appTimer.sw.m = $.APP.formatTimer(m);158 appTimer.sw.h = $.APP.formatTimer(h);159 //# $('#' + $.APP.dir + '_ms').html($.APP.formatTimer(ms));160 //# $('#' + $.APP.dir + '_s').html($.APP.formatTimer(s));161 //# $('#' + $.APP.dir + '_m').html($.APP.formatTimer(m));162 //# $('#' + $.APP.dir + '_h').html($.APP.formatTimer(h));163 164 // loop165 $.APP.t = setTimeout($.APP.loopTimer,1);166 167 } else {168 169 // kill loop170 clearTimeout($.APP.t);171 return true;172 173 } 174 175 }176 177 } 178 179 });180 181 /*$('#sw_start').live('click', function() {182 $.APP.startTimer('sw');183 }); 184 $('#cd_start').live('click', function() {185 $.APP.startTimer('cd');186 }); 187 188 $('#sw_stop,#cd_stop').live('click', function() {189 $.APP.stopTimer();190 });191 192 $('#sw_reset,#cd_reset').live('click', function() {193 $.APP.resetTimer();194 }); 195 196 $('#sw_pause,#cd_pause').live('click', function() {197 $.APP.pauseTimer();198 }); */ 199 200 })(jQuery);201 ...

Full Screen

Full Screen

chromedriver-e2e-specs.js

Source:chromedriver-e2e-specs.js Github

copy

Full Screen

...111 await restartPromise;112 });113 it('should stop a session', async function () {114 let nextStatePromise = nextState(cd);115 cd.stop();116 await nextStatePromise.should.become(Chromedriver.STATE_STOPPING);117 should.not.exist(cd.sessionId());118 await nextState(cd).should.become(Chromedriver.STATE_STOPPED);119 should.not.exist(cd.sessionId());120 await assertNoRunningChromedrivers();121 });122 it.skip('should change state to stopped if chromedriver crashes', async function () {123 // test works but is skipped because it leaves a chrome window orphaned124 // and I can't figure out a way to safely kill only that one125 cd.state.should.eql(Chromedriver.STATE_STOPPED);126 let nextStatePromise = nextState(cd);127 cd.start(caps);128 _.size(cd.capabilities).should.be.at.least(_.size(caps));129 await nextStatePromise.should.become(Chromedriver.STATE_STARTING);130 await nextState(cd).should.become(Chromedriver.STATE_ONLINE);131 should.exist(cd.jwproxy.sessionId);132 should.exist(cd.sessionId());133 nextStatePromise = nextState(cd);134 await cd.killAll();135 await nextStatePromise.should.become(Chromedriver.STATE_STOPPED);136 });137 it('should throw an error when chromedriver does not exist', async function () {138 let cd2 = new Chromedriver({139 executable: '/does/not/exist',140 });141 let nextErrP = nextError(cd2);142 await cd2.start({}).should.eventually.be.rejectedWith(/Trying to use/);143 let err = await nextErrP;144 err.message.should.contain('Trying to use');145 });146});147describe('chromedriver with async/await', function () {148 this.timeout(120000);149 let cd = null;150 before(function () {151 cd = new Chromedriver({});152 });153 it('should start a session', async function () {154 cd.state.should.eql('stopped');155 should.not.exist(cd.sessionId());156 await cd.start(caps);157 _.size(cd.capabilities).should.be.at.least(_.size(expectedCaps));158 cd.state.should.eql(Chromedriver.STATE_ONLINE);159 should.exist(cd.jwproxy.sessionId);160 should.exist(cd.sessionId());161 });162 it('should restart a session', async function () {163 cd.state.should.eql(Chromedriver.STATE_ONLINE);164 await cd.restart();165 cd.state.should.eql(Chromedriver.STATE_ONLINE);166 });167 it('should stop a session', async function () {168 cd.state.should.eql(Chromedriver.STATE_ONLINE);169 await cd.stop();170 cd.state.should.eql(Chromedriver.STATE_STOPPED);171 should.not.exist(cd.sessionId());172 await assertNoRunningChromedrivers();173 });174 it('should throw an error during start if spawn does not work', async function () {175 let badCd = new Chromedriver({176 port: 1,177 });178 await badCd.start(caps).should.eventually.be.rejectedWith('ChromeDriver crashed during startup');179 await assertNoRunningChromedrivers();180 });181 it('should throw an error during start if session does not work', async function () {182 let badCd = new Chromedriver({});183 await badCd.start({chromeOptions: {badCap: 'foo'}})...

Full Screen

Full Screen

ManageUdpValues.js

Source:ManageUdpValues.js Github

copy

Full Screen

1/** SpagoBI, the Open Source Business Intelligence suite23 * Copyright (C) 2012 Engineering Ingegneria Informatica S.p.A. - SpagoBI Competency Center4 * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0, without the "Incompatible With Secondary Licenses" notice. 5 * If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. **/6 7 8 9 1011/**12 * Object name13 * 14 * [description]15 * 16 * 17 * Public Properties18 * 19 * [list]20 * 21 * 22 * Public Methods23 * 24 * [list]25 * 26 * 27 * Public Events28 * 29 * [list]30 * 31 * Authors - Giulio Gavardi32 */33Ext.ns("Sbi.kpi");3435Sbi.kpi.ManageUdpValues = function(config) { 36 37 // create the editor grid38 var grid = {39 xtype: 'grid',40 width: 380,41 autoHeight: true,42 source: config.udpEmptyList,43 forceLayout: true,44 deferRowRender : false,45 propertyNames: {46 tested: 'QA',47 borderWidth: 'Border Width'48 },49 viewConfig : {50 forceFit: true,51 scrollOffset: 2 // the grid will never have scrollbars52 }53 };5455 var c = Ext.apply( {}, config, grid);56 57 // constructor58 Sbi.kpi.ManageUdpValues.superclass.constructor.call(this, c);59 60 this.on('beforeedit', function(e) {61 var t = Ext.apply({}, e);62 var col = t.column;63 this.currentRowRecordEdited = t.row; 64 65 }, this);66 67 this.on('afteredit', function(e) {68 69 var col = e.column;70 var row = e.row; 71 72 }, this);7374};7576Ext.extend(Sbi.kpi.ManageUdpValues, Ext.grid.PropertyGrid, {77 78 // fills value if present: if not present set defaults type in order to have right editors79 fillUdpValues:function(udpValues){8081 // remove preceding content82 this.store.removeAll(true);83 // get selected kpi udp values84 85 var udpEmptyList = this.udpEmptyList;86 var udpList = this.udpList;87 88 // if not defined give a default89 if(!udpValues){90 udpValues = new Array();91 }92 93 if(udpList){94 // fill udp st if present with values associated 95 for(i = 0; i<udpList.length;i++){96 var udp = udpList[i];97 // check if udp.label has a value associated for present KPI98 // check if udo.label is present among udpValues99 var valueToInsert = null;100 var stop = false;101 for ( var j = 0; j < udpValues.length && stop == false; j++) {102 var udpVal = udpValues[j];103 if(udpVal.label == udp.label || udpVal.name == udp.label){104 valueToInsert = udpVal.value; 105 stop = true;106 }107 }108 109 // get UDP type110 var typeData = udp.dataTypeCd;111 if(!typeData){112 typeData = 'TEXT';113 }114 else{115 typeData = typeData.toUpperCase();116 }117 //convert value to th right type118 if(typeData == 'INTEGER'){119 if(valueToInsert == null){120 valueToInsert = parseFloat(0); 121 }122 else{123 valueToInsert = parseFloat(valueToInsert);124 }125 }else if (typeData == 'BOOLEAN'){126 var boolToInsert;127 if(valueToInsert === 'true' || valueToInsert === true){128 boolToInsert = true;129 }else{130 boolToInsert = false;131 }132 valueToInsert = boolToInsert; 133 } else {134 // case text135 if(valueToInsert == null){136 valueToInsert = '';137 }138 }139 140 var tempRecord = new Ext.data.Record({"name": udp.label,"value": valueToInsert}); 141 this.store.add(tempRecord);142 }143 this.doLayout();144 }145 }146 ,147 // return array with values in grid148 saveUdpValues:function(type){149 var arrayUdps = new Array();150 var storeUdps = this.getStore();151 for(var i = 0;i< storeUdps.getCount();i++){152 var item = storeUdps.getAt(i);153 var data = item.data;154 // want to add type and family to this record155 data.familyId = type;156 var stop = false;157 for ( var j = 0; j < this.udpList.length && stop == false; j++) {158 var udpVal = this.udpList[j];159 if(udpVal.label == data.name){160 data.dataTypeCd = udpVal.dataTypeCd;161 stop = true;162 }163 }164 arrayUdps.push(data);165 }166 return arrayUdps;167 }168 , clearGrid: function(){169 this.fillUdpValues(new Array());170 }171}); ...

Full Screen

Full Screen

utils.js

Source:utils.js Github

copy

Full Screen

1/*2 * Copyright 2015 Google Inc. All rights reserved.3 *4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not5 * use this file except in compliance with the License. You may obtain a copy of6 * the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the13 * License for the specific language governing permissions and limitations under14 * the License.15 */16goog.provide('app.utils');17app.utils = function() {18 var audioProxy = {};19 return {20 distance: function(p1, p2) {21 var x = p2.x - p1.x;22 var y = p2.y - p1.y;23 return Math.sqrt(x * x + y * y);24 },25 angle: function(point1, point2) {26 return Math.atan2(point2.y - point1.y, point2.x - point1.x);27 },28 midpoint: function(start, end) {29 return {30 x: start.x + (end.x - start.x) / 2,31 y: start.y + (end.y - start.y) / 232 };33 },34 pointInCurve: function(t, start, control, end) {35 var u = (1 - t);36 var x = u * u * start.x + 2 * u * t * control.x + t * t * end.x;37 var y = u * u * start.y + 2 * u * t * control.y + t * t * end.y;38 var dx = (u * control.x + t * end.x) - (u * start.x + t * control.x);39 var dy = (u * control.y + t * end.y) - (u * start.y + t * control.y);40 return {41 x: x,42 y: y,43 angle: Math.atan2(dy, dx)44 };45 },46 curveLength: function(start, control, end) {47 var ax = start.x - 2 * control.x + end.x;48 var ay = start.y - 2 * control.y + end.y;49 var bx = 2 * control.x - 2 * start.x;50 var by = 2 * control.y - 2 * start.y;51 var A = 4 * (ax * ax + ay * ay);52 var B = 4 * (ax * bx + ay * by);53 var C = bx * bx + by * by;54 var Sabc = 2 * Math.sqrt(A+B+C);55 var A_2 = Math.sqrt(A);56 var A_32 = 2 * A * A_2;57 var C_2 = 2 * Math.sqrt(C);58 var BA = B / A_2;59 return (A_32 * Sabc + A_2 * B * (Sabc - C_2) + (4 * C * A - B * B) * Math.log((2 * A_2 + BA + Sabc) / (BA + C_2))) / (4 * A_32);60 },61 map: function(value, min, max) {62 return min + (max - min) * value;63 },64 svgToImage: function(svgString, callback) {65 var data = svgString;66 var DOMURL = window.URL || window.webkitURL || window;67 var img = new Image();68 var svg = new Blob([data], {type: 'image/svg+xml'});69 var url = DOMURL.createObjectURL(svg);70 if (callback) {71 img.onload = function() {72 callback(img);73 }74 }75 img.src = url;76 return img;77 },78 simpleTimeout: function(fn) {79 window.setTimeout(fn, 0);80 },81 randomLoop: function(fn, minInterval, maxInterval) {82 var random = Math.max(minInterval, Math.random() * maxInterval);83 window.setTimeout(function() {84 fn();85 app.utils.randomLoop(fn, minInterval, maxInterval);86 }, random);87 },88 triggerStart: function(event, args) {89 if (!audioProxy[event]) {90 args = args || [];91 window.santaApp.fire('sound-trigger', 'cd_stop_all_drawing');92 window.santaApp.fire('sound-trigger', {name: this.cleanNameForKlang(event) + '_start', args: args});93 audioProxy[event] = true;94 }95 },96 triggerStop: function(event) {97 if (audioProxy[event]) {98 window.santaApp.fire('sound-trigger', 'cd_stop_all_drawing');99 window.santaApp.fire('sound-trigger', this.cleanNameForKlang(event) + '_stop');100 audioProxy[event] = false;101 }102 },103 triggerOnce: function(event, args) {104 if (!audioProxy[event]) {105 args = args || [];106 window.santaApp.fire('sound-trigger', {name: event, args: args});107 audioProxy[event] = true;108 }109 },110 triggerReset: function(event) {111 audioProxy[event] = false;112 },113 cleanNameForKlang: function(event) {114 return 'cd_' + event.replace(/-/ig, '_')115 }116 };...

Full Screen

Full Screen

countDown.js

Source:countDown.js Github

copy

Full Screen

1//倒计时2/*3*2015-01-21 顾家进创建4*使用:eg var cd=new countDown();5*1)设置倒计时参数6*@parm obj 倒计时要加到的对象7*@parm time 倒计时长8*@parm speed 倒计时速度 1单位为毫秒9*@parm title 倒计时静止时显示的标题10*2)开启倒计时 cd.beginCountDown();11*3) 停止倒计时 cd.stopCountDown();12*/13 var countDown=function(){14 this.obj='';15 this.time=60;16 this.speed=1000;17 this.title='获取验证码';18 this.timerInterval=null;19 this.beginCountDown=function(){20 if(!this.obj){21 return false;22 }23 this.timerInterval = setInterval(this.callBackFunc(this,this.display), this.speed);24 };25 this.stopCountDown=function(){26 if(!this.obj){27 return false;28 }29 if(this.timerInterval){30 clearInterval(this.timerInterval);31 this.showUI(false);32 }33 } ;34 this.callBackFunc=function(obj, cb){35 return function(){36 cb.apply(obj, arguments);37 }38 }39 this.display=function(){40 if (this.time != 1) {41 this.time--;42 this.showUI(true);43 } else {44 clearInterval(this.timerInterval);45 this.showUI(false);46 }47 } 48 this.showUI=function(isCountDown){49 if(!this.obj){50 return false;51 }52 if(isCountDown){53 this.obj.value ='获取中('+this.time+')';54 $(this.obj).attr('disabled','disabled');55 }56 else{57 this.obj.value = this.title; 58 $(this.obj).removeAttr('disabled');59 }60 }; ...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var desired = {3};4var driver = wd.promiseChainRemote('localhost', 4723);5 .init(desired)6 .elementByName('Add Contact')7 .click()8 .elementByName('Save')9 .click()10 .elementByName('OK')11 .click()12 .then(function() {13 return driver.source();14 })15 .then(function(src) {16 console.log(src);17 })18 .then(function() {19 return driver.stop();20 })21 .done();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require("wd");2driver.init({ platformName: "Android",3 }).done();4 .sleep(5000)5 .click()6 .sleep(5000)7 .click()8 .sleep(5000)9 .click()10 .sleep(5000)11 .click()12 .sleep(5000)13 .click()14 .sleep(5000)15 .click()16 .sleep(5000)17 .click()18 .sleep(5000)19 .click()20 .sleep(5000)21 .click()22 .sleep(5000)23 .click()24 .sleep(5000)25 .click()26 .sleep(5000)27 .click()28 .sleep(5000)29 .click()30 .sleep(5000)31 .click()32 .sleep(5000)33 .click()34 .sleep(5000)

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd'),2 assert = require('assert'),3 _ = require('underscore'),4 fs = require('fs'),5 path = require('path'),6 serverConfigs = require('./appium-servers'),7 desired = require('./desired');8var browser = wd.promiseChainRemote(serverConfigs.local);9browser.on('status', function(info) {10 console.log('\x1b[36m%s\x1b[0m', info);11});12browser.on('command', function(meth, path, data) {13 console.log(' > \x1b[33m%s\x1b[0m: %s', meth, path, data || '');14});15 .init(desired)16 .setImplicitWaitTimeout(10000)17 .click()18 .sleep(5000)19 .click()20 .sleep(5000)21 .click()22 .sleep(5000)23 .click()24 .sleep(5000)25 .click()26 .sleep(5000)27 .click()28 .sleep(5000)29 .click()30 .sleep(5000)31 .click()32 .sleep(5000)33 .click()34 .sleep(5000)35 .click()36 .sleep(5000)37 .click()38 .sleep(5000)39 .click()40 .sleep(5000)41 .click()42 .sleep(5000)

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var driver = wd.promiseChainRemote("localhost",4723);4.init({5})6.sleep(5000)7.click()8.sleep(5000)9.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var desiredCaps = {3};4var driver = wd.promiseChainRemote('localhost', 4723);5driver.init(desiredCaps).then(function () {6 return driver.sleep(10000);7}).then(function () {8}).then(function (el) {9 return el.click();10}).then(function () {11}).then(function (el) {12 return el.click();13}).then(function () {14}).then(function (el) {15 return el.click();16}).then(function () {17}).then(function (el) {18 return el.click();19}).then(function () {20}).then(function (el) {21 return el.click();22}).then(function () {23}).then(function (el) {24 return el.click();25}).then(function () {26}).then(function (el) {27 return el.click();28}).then(function () {29}).then(function (el) {30 return el.click();31}).then(function () {32}).then(function (el) {33 return el.click();34}).then(function () {35}).then(function (el) {36 return el.click();37}).then(function () {38}).then(function (el) {39 return el.click();40}).then(function () {

Full Screen

Using AI Code Generation

copy

Full Screen

1var driver = require('appium-android-driver');2var cd = require('appium-android-driver/lib/commands/context');3var adb = require('appium-adb');4var desiredCaps = {5};6var adb = new ADB();7var driver = new AndroidDriver();8driver.createSession(desiredCaps).then(function () {9 return driver.start();10}).then(function () {11 return adb.getFocusedPackageAndActivity();12}).then(function (activity) {13 return driver.stop();14}).then(function () {15 console.log("Appium Android Driver stopped");16}).catch(function (err) {17 console.log("Error occurred while stopping Appium Android Driver");18 console.log(err);19});20I am using appium-android-driver and appium-adb npm packages to create an android driver and start it. I am able to start the driver successfully using driver.start() method. But I am not able to stop the driver using driver.stop() method. I am getting error as "TypeError: Cannot read property 'stop' of undefined". I am not able to find any examples on how to use driver.stop() method. Can you please help me with this?21driver.context('WEBVIEW_com.my.app');22driver.wait(function() {23 return driver.getPageSource().then(function(source) {24 return source.indexOf('Sign In') > -1;25 });26}, 5000);27The problem is that sometimes the web page loads so quickly that the driver.getPageSource() method is called before the web page is fully loaded. In this case the test fails because the page source does not contain the string 'Sign In'. I would like to be able to retry the getPageSource() call if it fails, but I can't figure out how to do this. I have tried using the following code:28driver.context('WEBVIEW_com.my.app');29driver.wait(function() {30 return driver.getPageSource().then(function(source) {31 return source.indexOf('Sign

Full Screen

Automation Testing Tutorials

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

LambdaTest Learning Hubs:

YouTube

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

Run Appium Android Driver 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