How to use pullSettings method in Appium

Best JavaScript code snippet using appium

ui.js

Source:ui.js Github

copy

Full Screen

1/*2 * version:2.13 * author:pa_dev4 * date:2014-2-145 * */6var Utils = {7 isPC: function () {8 var userAgentInfo = navigator.userAgent;9 var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");10 var flag = true;11 for (var v = 0; v < Agents.length; v++) {12 if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }13 }14 return flag;15 },16 setViewPort: function () {17 //android viewport18 var viewport = "";19 var userAgent = navigator.userAgent.toLowerCase();20 if (window.devicePlatform == "android") {21 viewport ="width=device-width,initial-scale=1,user-scalable=no,target-densitydpi =240";22 } else if (window.devicePlatform = "iOS") {23 if(userAgent.match(/ipad/i)){24 viewport = "width=640,user-scalable=no";25 }else if(userAgent.match(/iphone os/i) == "iphone os"){26 viewport = "width=480,user-scalable=no";27 }28 }29 //add view30 if ($("meta[name='viewport']").length > 0) {31 $("meta[name='viewport']").attr("content", viewport);32 } else {33 var element = document.createElement('meta');34 element.name = "viewport";35 element.content = viewport;36 var head = document.getElementsByTagName('head')[0];37 head.appendChild(element);38 }39 }40}41Utils.setViewPort();42/*43 * IScroll extend44 */45var myScroll ;46var pullSettings = {47 enablePullDown: false,48 enablePullUp:false,49 loadingLabel:"加载中...",50 flipLabel:"释放刷新",51 pullDownlabel:"下拉刷新",52 pullUplabel:"上拉加载更多",53 pullDownAction:function(){},54 pullUpAction:function(){}55};56var IScrollController = {57 set : function(params){58 $.extend(pullSettings,params) ;59 }60}61//var myScroll;62$(function(){63 if( $(".iscroll-wrapper").length ){64 $(".iscroll-wrapper").addClass("iscroll-wrapper-clz") ;65 66 if($(".footer").length){67 $(".iscroll-wrapper").css("bottom", $(".footer").height()+"px" ) ;68 }69 if($(".header").length){70 $(".iscroll-wrapper").css("top", $(".header").height()+"px" ) ;71 }72 //alert($(".iscroll-wrapper").css("padding-top"));73 74 document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);75 var pullContainer = $(".iscroll-wrapper").children();76 var pullDownEl,pullUpEl ;77 var pullDownOffset = pullUpOffset = 0 ;78 if( pullSettings.enablePullDown ){79 pullContainer.css("margin-top", "23px");80 var paddingTop = pullContainer.css("padding-top")||"" ;81 paddingTop = paddingTop.replace("px","") ;82 83 pullDownEl = $('<div id="pullDown"><span class="pullDownIcon"></span><span class="pullDownLabel">下拉刷新</span></div>').prependTo(pullContainer) ;84 //alert($(".header").height());85 pullDownOffset = ($(".header").height()||pullDownEl.height())-paddingTop;86 pullDownEl.hide();87 }88 89 if( pullSettings.enablePullUp ){90 pullUpEl = $('<div id="pullUp"><span class="pullUpIcon"></span><span class="pullUpLabel">上拉显示更多</span></div>').appendTo(pullContainer) ;91 pullUpOffset = $(".footer").height() || pullUpEl.height();92 pullUpEl.hide();93 }94 95 var _pervScroll = 0 ;96 var scrollParams = {97 hScrollbar: false, //是否显示水平滚动条 98 vScrollbar: false,99 checkDOMChanges:true,100 useTransition: false ,101 topOffset : pullDownOffset ,102 onRefresh: function () {103 if( pullSettings.enablePullDown && pullDownEl.hasClass("loading") ){104 pullDownEl.removeClass("loading") ;105 pullDownEl.find(".pullDownLabel").html( pullSettings.pullDownlabel ) ;106 //pullDownEl.hide();107 }else if( pullSettings.enablePullUp && pullUpEl.hasClass("loading") ){108 pullUpEl.removeClass("loading") ;109 pullUpEl.find(".pullUpLabel").html( pullSettings.pullUplabel ) ;110 pullUpEl.hide();111 }112 },113 onScrollMove: function () {114 if( pullSettings.enablePullDown ){115 pullDownEl.show();116 }117 if( pullSettings.enablePullUp ){118 pullUpEl.show();119 }120 121 if (pullSettings.enablePullDown && this.y > 10 && !pullDownEl.hasClass('flip') ) {122 pullDownEl.addClass("flip") ;123 pullDownEl.find(".pullDownLabel").html( pullSettings.flipLabel ) ;124 this.minScrollY = 0;125 } else if (pullSettings.enablePullDown && this.y < 10 && pullDownEl.hasClass('flip') ) {126 pullDownEl.show().removeClass("flip") ;127 pullDownEl.find(".pullDownLabel").html( pullSettings.pullDownlabel) ;128 this.minScrollY = -pullDownOffset;129 } else if (pullSettings.enablePullUp &&(this.maxScrollY - this.y) >20 && !pullUpEl.hasClass('flip') ) {130 pullUpEl.addClass("flip") ;131 pullUpEl.find(".pullUpLabel").html( pullSettings.flipLabel ) ;132 //this.maxScrollY = this.maxScrollY;133 //alert(this.maxScrollY+","+this.y);134 } else if (pullSettings.enablePullUp &&(this.maxScrollY - this.y) < 20 && pullUpEl.hasClass('flip')) {135 //alert("2");136 pullUpEl.show().removeClass("flip") ;137 pullUpEl.find(".pullUpLabel").html( pullSettings.pullUplabel ) ;138 //alert(this.maxScrollY+","+this.y);139 }140 //alert(this.scrollMaxY);141 },142 onScrollEnd: function () {143 //阻止重复调用144 if( new Date().getTime() - _pervScroll <= 1000 ){145 return ;146 }147 _pervScroll = new Date().getTime() ;148 149 if (pullSettings.enablePullDown&&pullDownEl.hasClass('flip')) {150 pullDownEl.addClass("loading") ;151 pullDownEl.find(".pullDownLabel").html( pullSettings.loadingLabel ) ;152 153 setTimeout(function () { 154 pullSettings.pullDownAction() ;155 myScroll.refresh();156 }, 1000); 157 } else if (pullSettings.enablePullUp&&pullUpEl.hasClass('flip') ) {158 pullUpEl.addClass("loading") ;159 pullUpEl.find(".pullUpLabel").html( pullSettings.loadingLabel ) ;160 161 setTimeout(function () { 162 pullSettings.pullUpAction() ;163 myScroll.refresh();164 }, 1000); 165 }166 }167 };168 169 myScroll = new iScroll( $(".iscroll-wrapper")[0] ,scrollParams );170 171 if( pullSettings.enablePullDown ){172 pullDownEl.show();173 }174 175 if( pullSettings.enablePullUp ){176 //pullUpEl.show();177 }178 }179}) ;180/*181* Object String extend182*/183String.prototype.startWith = function (str) {184 var reg = new RegExp("^" + str);185 return reg.test(this);186}187String.prototype.endWith = function (str) {188 var reg = new RegExp(str + "$");189 return reg.test(this);190}191String.prototype.getQueryString = function (name) { //name 是URL的参数名字 192 var reg = new RegExp("(^|&|\\?)" + name + "=([^&]*)(&|$)"), r;193 if (r = this.match(reg)) return (unescape(r[2]) || "").split("#")[0]; return null;194};195//UI控件 form list collapse navbar btngroup196(function () {197 window.ui = {};198 ui.form = {};199 ui.list = {};200 $.bt_jqprefix = "bt";201 $.bt_staticprefix = "ui";202 $.bt_options = {203 val: function (defaultValue) {204 return $(this).attr("value") || defaultValue;205 }206 };207 $.bt = function (type, options) {208 $.fn[$.bt_jqprefix + type] = function (type) {209 var args = [];210 for(var i=1 ;i<arguments.length ;i++){211 args.push(arguments[i]);212 }213 var func = options[type];214 return func.apply(this, args);215 };216 };217 ui._off = function (obj, event, widgetType) {218 obj = obj || 'div[data-role=' + widgetType + ']';219 $(obj).unbind(event || 'tap');220 return obj;221 }222 window.st = null;223 ui.bindTouchStart = function (obj) {224 $(obj).bind('touchstart', function (e) {225 //alert('touchstart');226 //st = new Date().getTime();227 $(this).addClass('btn-active');228 //会让默认的滚动事件在按钮上失效229 //e.preventDefault(); 230 //防止按钮有链接时会触发2次231 //e.stopPropagation();232 })233 }234 ui.bindTouchEnd = function (obj) {235 $(obj).bind('touchend', function (e) {236 //alert('touchend');237 $(this).removeClass('btn-active');238 //e.stopPropagation();239 })240 }241 /*242 * 控件初始化243 */244 $.uiwidget = {245 mark: "data-role",246 map: {},247 dependMap: {},248 funcs: [],249 /*250 * eg: $.widget.register("combotree",function(){})251 */252 register: function () {//type ,depend , func253 var type = arguments[0];254 var func = null;255 var depend = null;256 if (arguments.length == 1) {257 func = arguments[0];258 $.uiwidget.funcs.push(func);259 return;260 } else if (arguments.length == 2) {261 func = arguments[1];262 } else if (arguments.length == 3) {263 func = arguments[2];264 depend = arguments[1];265 }266 $.uiwidget.map[type] = func;267 $.uiwidget.dependMap[type] = depend;268 },269 init: function (options, target) {270 var widgetTrack = [];271 var pushed = {};272 //format dependMap273 for (var o in $.uiwidget.map) {274 _addTypeTrack(o);275 }276 options = options || {};277 options.before && options.before(target);278 var cacheType = {};279 $(widgetTrack).each(function (index, type) {280 if ($.uiwidget.map[type]) {281 var selector = $("[" + $.uiwidget.mark + "^='" + type + "'],[" + $.uiwidget.mark + "*='," + type + "']", target)282 if (selector.length > 0) {283 $.uiwidget.map[type](selector, target);284 }285 }286 });287 $($.uiwidget.funcs).each(function (index, func) {288 func && func();289 });290 options.after && options.after(target);291 function _addTypeTrack(o) {292 var depend = $.uiwidget.dependMap[o];293 if (depend) {//存在依赖294 $(depend).each(function (index, type) {295 _addTypeTrack(type);296 });297 }298 (!pushed[o]) && widgetTrack.push(o);299 pushed[o] = true;300 }301 pushed = null;302 widgetTrack = null;303 }304 }305 $.fn.uiwidget = function () {306 $.uiwidget.init({}, $(this).parent());307 }308 $.pageLoad = { before: [], after: [] };309 $.pageLoad.register = function (type, func) {310 $.pageLoad[type].push(func);311 };312 $(function () {313 $($.pageLoad.before).each(function (index, func) {314 func();315 });316 //控件初始化317 $(document.body).uiwidget();318 $($.pageLoad.after).each(function (index, func) {319 func();320 });321 });322 ui.init = function () {323 $(document.body).uiwidget();324 };325})();326$.pageLoad.after.push(function(){327 if( !$(".iscroll-wrapper").length ){328 329 if( $("[data-fixed='top']").length ){330 $(".content").css("padding-top", ($("[data-fixed='top']").height())+"px") ;331 }332 333 if( $("[data-fixed='bottom']").length ){334 $(".content").css("padding-bottom", ($("[data-fixed='bottom']").height())+"px") ;335 }336 337 $("[data-fixed='top']").addClass("fixed-top");338 $("[data-fixed='left']").addClass("fixed-left") ;339 $("[data-fixed='right']").addClass("fixed-right") ;340 $("[data-fixed='bottom']").addClass("fixed-bottom") ;341 342 }343});344/*345* button.js346*/347//select348(function (undefined) {349 $.bt("button", {350 off: function (event) {351 return ui._off(this, event, 'BTButton');352 }353 });354 /*355 * 初始化控件356 */357 $.uiwidget.register("BTButton", function (selector) {358 selector.each(function () {359 var status = $(this).attr('data-status'); //是否要渲染360 var url = $(this).attr('data-url'); //跳转地址361 var urlArg = $(this).attr('data-urlarg'); //跳转地址带参数362 var mousedown = $(this).attr('mousedown'); //是否取消点击高亮363 var mouseup = $(this).attr('mouseup'); //是否取消点击高亮364 var disabled = $(this).attr('disabled'); //是否取消点击高亮365 var icon = $(this).attr('data-icon'); //图标class或图片路径 366 var badges = $(this).attr('data-badges'); //提示文本367 //是否要内嵌一层以及渲染图标368 if (status != 1) {369 $(this).wrapInner('<span class="btn-text"/>');370 //是否有图标371 if (icon != null) {372 if (icon.indexOf('/') > -1) {373 $(this).append('<span class="icon"><img src="' + icon + '" alt=""/></span>');374 } else {375 $(this).append('<span class="icon ' + icon + '"></span>');376 }377 }378 379 //如果按钮有这个属性,则去掉跳转跟高亮等属性380 if (disabled == 'ture' || disabled == 'disabled') {381 }382 }383 384 if (badges != undefined) {385 if( $(this).find("span.badges").length ){386 //do nothing387 $(this).find("span.badges").html(badges) ;388 }else{389 $(this).append('<span class="badges">' + badges + '</span>');390 }391 }else{392 $(this).find("span.badges").remove() ;393 }394 395 $(this).attr('data-status', 1);396 //是否跳转 397 if (url != undefined && url != '') {398 if (urlArg != undefined && urlArg != '') {399 $(this).bind('tap', function (e) {400 //urlArg获取到的是json字符串401 var args=eval('(' + urlArg + ')');402 app.load({ url: url, params:args.params||args,slideType:args.slideType,progress:args.progress});403 e.stopPropagation();404 });405 406 407 } else {408 $(this).bind('tap', function (e) {409 app.load({url: url, slideType:'left'})410 e.stopPropagation();411 });412 }413 }414 //如果 mousedown=false 就取消默认点击高亮事件415 if (mousedown == null || mousedown != 'false') {416 ui.bindTouchStart(this);417 }418 //如果 mouseup=false 就默认点击高亮 419 if (mouseup == null || mouseup != 'false') {420 //if( mouseup !=null) alert(mouseup);421 ui.bindTouchEnd(this);422 }423 });424 });425})();426/*427* btngroup.js428* */429$.uiwidget.register(function (selector) {430 $('div[data-role="BTSwitchs"] >[data-role=BTButton]').btbutton("off", 'touchstart touchend');431 //btn-group 432 $('div[data-role="BTSwitchs"]>[data-role=BTButton]').bind('tap', function (e) {433 $(this).addClass('btn-active').siblings().removeClass('btn-active');434 e.stopPropagation();435 })436});437/*438* check.js439* */440/**441 表单元素、日期组件等调用接口442 @class UI443*/444$.bt("check", {445 val: function (data,callback) {446 var len = arguments.length;447 //参数大于0,即为设值操作448 /**449 设置checkbox值,<font color='red'>这个方法会先将所有checkbox清空,再根据data参数勾选。<br/>450 此方法提供给BingoTouch定义的checkbox</font>451 @method $(selector).btcheck("val",data ,callback)452 @param data {string|Array} 需要选中的checkbox的value,可传入单个字符串或字符串数组453 @param callback {Function} 状态改变<font color='red'>前</font>的操作,当callback返回true时,状态才允许被改变 454 @return {Object} 返回当前链式对象455 @chainable456 @example457 HTML:458 <div data-role="BTCheck" id="checkg" name="csex" value="girl">女</div>459 <div data-role="BTCheck" id="checkb" name="csex" value="boy">男</div>460 <div data-role="BTCheck" id="checkz" name="csex" value="rao">中</div>461 JS:462 //设置选中,checkbox的value为["boy","rao"]会被选中463 $("div[name='csex']").btcheck("val",["boy","rao"],function(obj,data){464 //这里做改变状态之前的操作...........465 //obj selector的DOM对象,data 是传入data参数466 //return true 允许改变状态 ,return false不允许改变状态467 return true;468 }); 469 //也可以这样设值470 $("div[name='csex']").btcheck("val","rao")471 */ 472 if(len > 0){473 var bool = callback ? callback(this, data) : true;//状态改变前的操作,决定是否改变状态474 //主动JS设置475 if(data!=null){ 476 if (bool == true) {477 var objs = this, dt ; 478 var isArray =typeof data =="object" ? true : false;479 if(!isArray){ dt = []; dt.push(data); }480 else { dt = data ; }481 482 $(objs).each(function (index ,obj){483 $(obj).removeClass('BTCheck_ON').addClass('BTCheck_OFF');484 }); 485 for(var i=0 ;i< dt.length ;i++){486 $(objs).each(function (index ,obj){487 if($(obj).attr("value")==dt[i]){488 $(obj).removeClass('BTCheck_OFF').addClass('BTCheck_ON'); 489 } 490 }); 491 }492 }493 }else{494 var btCheck_ON = $(this).hasClass('BTCheck_ON'); 495 if (bool == true) {496 if (!btCheck_ON) {497 $(this).removeClass('BTCheck_OFF').addClass('BTCheck_ON');498 }499 if (btCheck_ON) {500 $(this).removeClass('BTCheck_ON').addClass('BTCheck_OFF');501 }502 } 503 }504 return $(this); 505 }506 /**507 获取checkbox值,<font color='red'>此方法提供给BingoTouch定义的checkbox</font>508 @method $(selector).btcheck("val")509 @return {Object} checkbox选中值 ⇒ null | {value:'',label:''} | [{value:'',label:''} ,{value:'',label:''}]510 @example511 HTML:512 <div data-role="BTCheck" id="checkg" name="csex" value="girl">女</div>513 <div data-role="BTCheck" id="checkb" name="csex" value="boy">男</div>514 <div data-role="BTCheck" id="checkz" name="csex" value="rao">中</div>515 JS:516 //建议这种取值方式517 //return [{"value":"girl","label":"女"},{"value":"boy","label":"男"}]518 $("div[name='csex']").btcheck("val")519 //也可以这样取值520 //return {"value":"boy","label":"男"}521 $("#checkb").btcheck("val")522 */ 523 else{524 var result =[];525 $(this).each(function (index, obj) {526 var $obj = $(obj);527 if($obj.hasClass('BTCheck_ON')){528 var res ={};529 res.value = $obj.attr("value");530 res.label = $obj.text();531 result.push(res); 532 }533 });534 return result;535 /*if(result.length<1){536 return null;537 }else if(result.length==1){538 return result[0];539 }else{540 return result;541 }*/542 }543 }544});545$.uiwidget.register("BTCheck", function (selector) {546 selector.each(function(index, item){547 var callback = $(this).attr('callback');548 callback = callback?eval("("+callback+")"):function(){return true;} ;549 $(this).unbind().bind('tap', function (e) {550 $(this).btcheck('val',null,callback);551 e.stopPropagation();552 });553 }) ;554});555/*556* checkbox.js557* */558$.bt("checkbox", {559 off: function (event) {560 return ui._off(this, event, 'BTCheckbox');561 }562});563/*564* collapse.js565* */566$.uiwidget.register(function (selector) {567 //collapse的点击事件568 $('.collapse-header > [data-role=BTButton]').bind('tap', function () {569 $(this).toggleClass('btn-active');570 $(this).find('.icon').toggleClass('icon-minus');571 $(this).parent().next().toggle();572 })573 $('.collapse.show').find('.collapse-header [data-role=BTButton]').addClass('btn-active')574 .find('.icon').toggleClass('icon-minus');575});576/*577* select.js578* */579$.bt("select", {580 val: function (data,callback) {581 var len = arguments.length;582 //参数大于0,即为设值操作583 /**584 设置select值,<font color='red'>此方法提供给BingoTouch定义的select</font>585 @method $(selector).btselect("val",data ,callback)586 @param data {JSON对象} 设置的值 ⇒ {value:'',label:''}587 @param callback {Function} 状态改变<font color='red'>前</font>的操作,当callback返回true时,状态才允许被改变 588 @return {Object} 返回当前链式对象589 @chainable590 @example591 HTML:592 <div id="BTSelect" data-role="BTSelect" value="" name="selectsex" data='[{"value":"female","label":"女"},{"value":"male","label":"男"}]' title="请选择性别"><span>请选择性别</span></div>593 JS: 594 //设置选中,参数格式{value:'',label:''}595 $("#BTSelect").btselect("val",{value:'female',label:'女'},function(obj,data){596 //这里做改变状态之前的操作...........597 //obj selector的DOM对象,data 是传入data参数598 //return true 允许改变状态 ,return false不允许改变状态599 return true;600 });601 */602 if(len > 0){603 var obj = this;604 var bool = callback ? callback(obj, data) : true;605 if(bool){606 //保存进data属性 607 var json =typeof data =="object"?data:$.parseJSON(data);608 var value =json.key||json.value;609 var label = json.label||json.value;610 $(obj).attr('value', value).find('span').text(label);611 }612 return $(obj); 613 }614 /**615 获取select值, <font color='red'>此方法提供给BingoTouch定义的select</font>616 @method $(selector).btselect("val")617 @return {JSON对象} select选中值 ⇒ {value:'',label:''}618 @example619 HTML:620 <div id="BTSelect" data-role="BTSelect" value="" name="selectsex" data='[{"value":"female","label":"女"},{"value":"male","label":"男"}]' title="请选择性别"><span>请选择性别</span></div>621 JS: 622 //return {"value":"female",label:"女"}623 $("#BTSelect").btselect("val")624 */ 625 else{626 var $obj = $(this);627 var res = {};628 res.value = $obj.attr('value') == undefined ? '' : $obj.attr('value');629 res.label = $obj.text() == undefined ? '' : $obj.text();630 return res; 631 }632 },633 off: function (event) {634 return ui._off(this, event, 'BTSelect');635 }636});637$.uiwidget.register( function (selector) {638 $('div[data-role=BTSelect],div[data-role=BTButton][type="select"]').each(function(){639 640 var attrType = $(this).attr("type") ;641 if( attrType && attrType != 'select' ) return ;642 643 var self = this;644 //选中以后的数据645 var data = eval($(this).attr('data'));646 var value = $(this).attr('value');647 var title = $(this).attr('title');648 var callback = $(this).attr('callback');649 callback = callback?eval("("+callback+")"):function(){return true;} ;650 651 if(!data) return;652 if(data[0].label!=null){653 for(var i=0;i<data.length;i++ ){654 data[i].key =data[i].value;655 data[i].value = data[i].label;656 }657 }658 659 var selected = null ;660 for(var i=0;i<data.length;i++ ){661 if(value == data[i].key){662 selected = data[i] ;663 }664 }665 if(value == undefined || value == ''){666 }else {667 $(self).btselect("val",selected,callback) ;668 }669 670 $(this).unbind('tap').bind('tap',function(e){671 if(value == undefined || value == ''){672 app.wheelSelect.oneSelect(data,function(res){673 //设置Select的值674 $(self).btselect("val",res,callback) ;675 value = res.value;676 },data[0].key,title);677 }else {678 app.wheelSelect.oneSelect(data,function(res){679 //设置Select的值680 $(self).btselect("val",res,callback) ;681 value = res.value;682 },value,title);683 684 //$(self).btselect("val",selected,callback) ;685 }686 });687 688 }) ;689 690 //每个select date 的点击效果691 $('div[data-role="BTSelect"]').bind('touchstart', function () {692 $(this).addClass('btn-active');693 }).bind('touchend', function () {694 $(this).removeClass('btn-active');695 }); 696});697/*698* datepicker.js699* 700* */701//select702$.bt("datepicker", {703 val: function (data, callback) {704 var len = arguments.length;705 //参数大于0,即为设值操作706 /**707 设置日期或时间,<font color='red'>此方法提供给BingoTouch定义的datepicker</font>708 @method $(selector).btdatepicker("val",data ,callback)709 @param data {string} 设置的日期或时间值 ⇒ "2013-9-4" | "10:04"710 @param callback {Function} 状态改变<font color='red'>前</font>的操作,当callback返回true时,状态才允许被改变 711 @return {Object} 返回当前链式对象712 @chainable713 @example714 HTML:715 <div id="BTDate" data-role="BTSelect" value="" name="date" data='2013-4-3' type="date"><span>请选择日期</span></div>716 <div id="BTTime" data-role="BTSelect" value="" name="time" data='16:29' type="time"><span>请选择时间</span></div> 717 JS:718 //设置日期719 $("#BTDate").btdatepicker("val","2013-2-30",function(obj,data){720 //obj selector的DOM对象,data 是传入data参数721 //return true 允许改变状态 ,return false不允许改变状态722 return true;723 });724 //设置时间725 $("#BTTime").btdatepicker("val","10:30");726 */727 if(len > 0){728 var obj = this;729 var bool = callback ? callback(obj, data) : true;730 if(bool){ 731 $(obj).attr('value',data).find('span').text(data);732 }733 return $(obj); 734 }735 /**736 日期或时间的取值,<font color='red'>此方法提供给BingoTouch定义的datepicker</font>737 @method $(selector).btdatepicker("val")738 @return {string} datepicker选中值 739 @example740 HTML:741 <div id="BTDate" data-role="BTSelect" value="" name="date" data='2013-4-3' type="date"><span>请选择日期</span></div>742 <div id="BTTime" data-role="BTSelect" value="" name="time" data='16:29' type="time"><span>请选择时间</span></div> 743 JS:744 //日期和时间的取值都是使用这个方法745 //return "2013-9-4"746 $("#BTDate").btdatepicker("val");747 //return "10:4"748 $("#BTTime").btdatepicker("val");749 */750 else{751 var $obj = $(this);752 return $obj.attr('value'); 753 }754 }755});756$.uiwidget.register(function (selector) {757 //如果有初始值就把值替换原来的文本提示758 var obj = "div[data-role='BTSelect'][type='date'],div[data-role='BTSelect'][type='wheeldate'],div[data-role='BTSelect'][type='time'],div[data-role='BTSelect'][type='wheeltime'],div[data-role='BTButton'][type='date'],div[data-role='BTButton'][type='wheeldate'],div[data-role='BTButton'][type='time'],div[data-role='BTButton'][type='wheeltime']";759 760 $(obj).each(function () {761 var callback = $(this).attr('callback');762 callback = callback?eval("("+callback+")"):function(){return true;} ;763 764 var value = $(this).attr('data');765 if (value != undefined && value != '') {766 $(this).btdatepicker("val",value,callback);767 }768 769 $(this).unbind('tap').bind('tap', function (e) {770 //选中以后的数据 {"year":2013,"month":4,"day":3,"full":"2013-4-3"}771 var self = this;772 var type = $(this).attr('type'); //日期还是时间773 var value = $(this).attr('value');774 var action = null;775 if (type == 'date') {776 action = 'selectDate';777 } else if (type == 'wheeldate') {778 action = 'wheelSelectDate';779 } else if (type == 'time') {780 action = 'selectTime';781 } else if (type == 'wheeltime') {782 action = 'wheelSelectTime';783 }784 785 __datepicker(value, action, type);786 function __datepicker(value, action, type) {787 if (value == undefined || value == '') {788 app.dateTimePicker[action](function (res) {789 //设置Select的值790 $(self).btdatepicker("val",res.full,callback);791 });792 } else {793 var dateGroup = [];794 795 var nowDate = {};796 if (type == 'date' || type == 'wheeldate') {797 dateGroup = value.split('-');798 nowDate.year = dateGroup[0];799 nowDate.month = dateGroup[1];800 nowDate.day = dateGroup[2];801 } else {802 dateGroup = value.split(':');803 nowDate.hour = dateGroup[0];804 nowDate.minute = dateGroup[1];805 }806 app.dateTimePicker[action](function (res) {807 //设置Select的值808 $(self).btdatepicker("val", res.full,callback);809 }, nowDate);810 }811 }812 //设置Select的值813 //ui.setDatepickerValue(this,data);814 //获取Select值的json对象815 //alert(ui.getDatepickerValue(this));816 e.stopPropagation();817 })818 });819 820 //每个select date 的点击效果821 $('div[data-role="BTDate"]').bind('touchstart', function () {822 $(this).addClass('btn-active');823 }).bind('touchend', function () {824 $(this).removeClass('btn-active');825 });826});827/*828* dropdown.js829* */830$.bt("dropdown", {831 val: function (data, callback) {832 var len = arguments.length;833 //参数大于0,即为设值操作834 /**835 设置下拉菜单值,<font color='red'>此方法提供给BingoTouch定义的dropdown</font>836 @method $(selector).btdropdown("val",data ,callback)837 @param data {string} 设置的下拉菜单值 838 @param callback {Function} 状态改变<font color='red'>前</font>的操作,当callback返回true时,状态才允许被改变 839 @return {Object} 返回当前链式对象840 @chainable841 @example842 HTML:843 <div class="dropdown" data-menupos="top" date-inline='true'>844 <div data-role="BTButton" id="BTDropdown" data-theme="a" data-icon="icon-list-down" data-iconpos="right" align="center" name="dropdownBT">下拉菜单</div>845 <ul class="list-view" data-theme="b" data-corner="all">846 <li><div data-role="BTButton" align="center">Button1</div></li>847 <li><div data-role="BTButton" align="center">Button2</div></li>848 <li><div data-role="BTButton" align="center">Button3</div></li>849 <li><div data-role="BTButton" align="center">Button4</div></li>850 </ul>851 </div>852 JS:853 $("#BTDropdown").btdropdown("val","我是设置",function(obj,data){854 //这里做改变状态之前的操作...........855 //obj selector的DOM对象,data 是传入data参数856 //return true 允许改变状态 ,return false不允许改变状态857 return true;858 });859 */860 if(len > 0){861 var obj = this;862 var bool = callback ? callback(obj, data) : true;863 if(bool){864 $(obj).find('.btn-text').text(data);865 }866 return $(obj); 867 }868 /**869 下拉菜单取值,<font color='red'>此方法提供给BingoTouch定义的dropdown</font>870 @method $(selector).btdropdown("val")871 @return {string} dropdown选中值 872 @example873 HTML:874 <div class="dropdown" data-menupos="top" date-inline='true'>875 <div data-role="BTButton" id="BTDropdown" data-theme="a" data-icon="icon-list-down" data-iconpos="right" align="center" name="dropdownBT">下拉菜单</div>876 <ul class="list-view" data-theme="b" data-corner="all">877 <li><div data-role="BTButton" align="center">Button1</div></li>878 <li><div data-role="BTButton" align="center">Button2</div></li>879 <li><div data-role="BTButton" align="center">Button3</div></li>880 <li><div data-role="BTButton" align="center">Button4</div></li>881 </ul>882 </div>883 JS:884 //return "下拉菜单"885 $("#BTDropdown").btdropdown("val")886 */ 887 else{888 return $(this).find('.btn-text').text();889 }890 },891 off: function (event) {892 var obj = this;893 $(obj || '.dropdown > div[data-role=BTButton]').unbind(event || 'tap');894 return obj;895 }896});897$.uiwidget.register(function (selector) {898 $('.dropdown > div[data-role="BTButton"]').append('<span class="angle"></span>');899 //点击切换隐藏下拉菜单900 $('.dropdown > div[data-role="BTButton"]').unbind().bind('tap', function (e) {901 $(this).toggleClass('btn-active');902 $(this).find('.angle').toggle();903 $(this).next().toggle();904 e.stopPropagation();905 });906 $('.dropdown > ul div[data-role="BTButton"]').bind('tap', function (e) {907 908 var callback = $(this).closest(".dropdown").attr('callback');909 callback = callback?eval("("+callback+")"):function(){return true;} ;910 911 var obj = $(this).parents('ul').prev();912 var value = $(this).find('.btn-text').text();913 $(obj).btdropdown("val", value,callback);914 //alert(ui.getDropdownValue(obj))915 $('.dropdown ul').hide();916 $('.angle').hide();917 obj.removeClass('btn-active');918 e.stopPropagation();919 });920});921/*922* list.js923* */924$.uiwidget.register(function (selector) {925 //list-view926 $('.list-view li > [data-role=BTButton]').bind('tap', function (e) {927 $(this).parent().siblings()928 .find('[data-role=BTButton]').removeClass('btn-active');929 //e.stopPropagation();930 })931 //list-collapse 932 $('.list-collapse > li > [data-role=BTButton]').unbind().bind('tap', function () {933 $(this).toggleClass('btn-active')934 .parent().siblings().find('[data-role=BTButton]')935 .removeClass('btn-active');936 })937 //取消绑定头部的事件938 $('.list-collapse.list-view-head > li:first-child > [data-role=BTButton]').unbind();939 //list-collapse data-multipe="true"940 $('.list-collapse[data-multiple="true"] > li > [data-role=BTButton]').unbind().bind('tap', function () {941 $(this).toggleClass('btn-active');942 });943});944/*945* navbar.js946* */947$.uiwidget.register(function (selector) {948 //关闭touchmstart 跟 touchend 事件949 var button = $('.navbar > ul > li >[data-role=BTButton]');950 button.btbutton('off', 'touchstart touchend');951 //navbar952 $('.navbar > ul > li ,.navbar table tr td ').bind('tap', function (e) {953 $(this).siblings()954 .find('[data-role=BTButton]').removeClass('btn-active');955 $(this).find('[data-role=BTButton]').addClass('btn-active');956 e.stopPropagation();957 });958 if ($('.navbar .sonmenu').length > 0) {959 $('.navbar > ul').each(function () {960 //有下拉菜单时,动态添加三角形图标,默认隐藏961 $(this).find('ul').hide().prev().append('<span class="angle"></span>');962 $(this).find('.angle').hide();963 });964 //一级菜单点击965 $('.navbar > ul > li >[data-role="BTButton"]').bind('tap', function (e) {966 $(this).parent().siblings().find('[data-role="BTButton"]').removeClass('btn-active');967 $(this).addClass('btn-active');968 $('.angle').hide();969 $('ul.sonmenu').hide();970 971 $(this).find('.angle').show() ;972 $(this).next().show();973 974 // $(this).find('.angle').show().end().next().show();975 e.stopPropagation();976 })977 //二级菜单点击 978 $('.sonmenu [data-role="BTButton"]').bind('tap', function (e) {979 $('.sonmenu').hide().prev().find('.angle').hide();980 e.stopPropagation();981 })982 }983 $('body').tap(function () {984 $('.sonmenu').hide().prev().find('.angle').hide();985 });986});987/*988* radio.js989* */990//radio991$.bt("radio", {992 993 val: function (data,callback) {994 var len = arguments.length;995 //参数大于0,即为设值操作996 /**997 设置radio值,<font color='red'>此方法提供给BingoTouch定义的radio</font>998 @method $(selector).btradio("val",data ,callback)999 @param data {string} 需要选中的radio的value1000 @param callback {Function} 状态改变<font color='red'>前</font>的操作,当callback返回true时,状态才允许被改变 1001 @return {Object} 返回当前链式对象1002 @chainable1003 @example1004 HTML:1005 <div data-role="BTRadio" name="rsex" id="radioboy" class="BTCheck_ON" value="boy">男</div>1006 <div data-role="BTRadio" name="rsex" id="radiogirl" value="girl">女</div>1007 JS:1008 $("div[name='rsex']").btradio("val","boy",function(obj,data){1009 //这里做改变状态之前的操作...........1010 //obj selector的DOM对象,data 是传入data参数1011 //return true 允许改变状态 ,return false不允许改变状态1012 return true;1013 });1014 */ 1015 if(len > 0){1016 var objs = this;1017 var bool = callback ? callback(objs,data) : true;1018 if (bool == true) {1019 $(objs).each(function (index, obj) {1020 if($(obj).attr('value')==data){1021 var name = $(obj).attr('name'); 1022 if (!$(obj).hasClass('BTCheck_ON')) {1023 $('div[data-role="BTRadio"][name="' + name + '"]').removeClass('BTCheck_ON');1024 $(obj).addClass('BTCheck_ON');1025 } 1026 }1027 });1028 }1029 return $(objs); 1030 }1031 /**1032 获取单选框值,<font color='red'>此方法提供给BingoTouch定义的radio</font>1033 @method $(selector).btradio("val")1034 @return {JSON对象} radio选中值 ⇒ {value:'',label:''}1035 @example1036 HTML:1037 <div data-role="BTRadio" name="rsex" id="radioboy" class="BTCheck_ON" value="boy">男</div>1038 <div data-role="BTRadio" name="rsex" id="radiogirl" value="girl">女</div>1039 JS: 1040 //建议这样获取radio值1041 //return {"value":"girl","label":"女"}1042 $("div[name='rsex']").btradio("val")1043 //获取id为radioboy的radio的值,如果被选中,则返回{value:'',label:''},如果未被选中,则返回null1044 //return {"value":"boy","label":"男"}1045 $("#radioboy").btradio("val");1046 */ 1047 else{1048 var res = null;1049 $(this).each(function (index, obj) {1050 var $obj = $(obj);1051 if($(obj).hasClass('BTCheck_ON')){1052 res ={};1053 res.value = $obj.attr("value");1054 res.label = $obj.text();1055 }1056 });1057 return res;1058 }1059 },1060 off: function (event) {1061 return ui._off(this, event, 'BTRadio');1062 }1063});1064$.uiwidget.register("BTRadio", function (selector) {1065 selector.unbind().bind('tap', function (e) {1066 var callback = $(this).attr('callback');1067 callback = callback?eval("("+callback+")"):function(){return true;} ;1068 $(this).btradio('val',$(this).attr("value"),callback);1069 e.stopPropagation();1070 });1071});1072/*1073* switch.js1074* */1075$.bt("switch", {1076 val: function (data,callback){1077 var len = arguments.length;1078 //参数大于0,即为设值操作1079 /**1080 设置switch值,<font color='red'>此方法提供给BingoTouch定义的switch</font>1081 @method $(selector).btswitch("val",data ,callback)1082 @param data {boolean} switch值 ⇒ true | false1083 @param callback {Function} 状态改变<font color='red'>前</font>的操作,当callback返回true时,状态才允许被改变 1084 @return {Object} 返回当前链式对象1085 @chainable1086 @example1087 HTML:1088 <div id="btswitch" name="switchB" class="BTCheck_OFF" data-role="BTSwitch" ></div>1089 JS:1090 //设置为开1091 $("#btswitch").btswitch("val",true,function(obj,data){1092 //这里做改变状态之前的操作...........1093 //obj selector的DOM对象,data 是传入data参数1094 //return true 允许改变状态 ,return false不允许改变状态1095 return true;1096 });1097 */ 1098 if(len > 0){1099 var obj = this;1100 var btCheck_ON = $(obj).hasClass('BTCheck_ON');1101 var bool = callback ? callback(obj ,data) : true;1102 if (bool == true) {1103 if(data!=null){1104 if (data) {1105 $(obj).removeClass('BTCheck_OFF').addClass('BTCheck_ON');1106 } else if (btCheck_ON) {1107 $(obj).removeClass('BTCheck_ON').addClass('BTCheck_OFF');1108 } 1109 }else{1110 if (!btCheck_ON) {1111 $(obj).removeClass('BTCheck_OFF').addClass('BTCheck_ON');1112 } else if (btCheck_ON) {1113 $(obj).removeClass('BTCheck_ON').addClass('BTCheck_OFF');1114 } 1115 }1116 }1117 return $(obj); 1118 }1119 //取值操作1120 /**1121 获取switch值, <font color='red'>此方法提供给BingoTouch定义的switch</font>1122 @method $(selector).btswitch("val")1123 @return {boolean} switch值 ⇒ true | false1124 @example1125 HTML:1126 <div id="btswitch" name="switchB" class="BTCheck_OFF" data-role="BTSwitch" ></div>1127 JS:1128 //return true1129 $("#btswitch").btswitch("val")1130 */ 1131 else{ 1132 if ($(this).hasClass('BTCheck_ON')){1133 return true;1134 }else{1135 return false;1136 }1137 }1138 },1139 off: function (event) {1140 return ui._off(this, event, 'BTSwitch');1141 }1142});1143$.uiwidget.register("BTSwitch", function (selector) {1144 selector.unbind().bind('tap', function (e) {1145 var callback = $(this).attr('callback');1146 callback = callback?eval("("+callback+")"):function(){return true;} ;1147 $(this).btswitch('val',null,callback);1148 e.stopPropagation();1149 });1150});1151//表单数据 toJSON1152/**1153 将表单数据封装成为一个JSON对象 ,1154 <span><font color='red'>不论是BingoTouch定义的表单元素还是传统表单元素,都能被封装。</font></span>1155 @method $(selector).toJSON(justValue)1156 @param justValue {boolean} 只封装值 ⇒ true | false1157 @return {JSON对象} 表单数据1158 @example1159 HTML:1160 <div id="test">1161 <div id="btswitch" name="switchB" class="BTCheck_OFF" data-role="BTSwitch" ></div>1162 <div data-role="BTCheck" name="csex" value="girl">女</div>1163 <div data-role="BTCheck" name="csex" value="boy">男</div>1164 <div data-role="BTCheck" name="csex" value="rao">中</div>1165 <div data-role="BTRadio" name="rsex" value="boy">男</div>1166 <div data-role="BTRadio" name="rsex" value="girl">女</div>1167 <div id="BTSelect" data-role="BTSelect" name="selectsex" data='[{"value":"female","label":"女"},{"value":"male","label":"男"}]' title="请选择性别"><span>请选择性别</span></div>1168 <div id="BTTime" data-role="BTSelect" name="time" data='{"hour":16,"minute":29,"full":"16:29"}' type="time"><span>请选择时间</span></div>1169 </div>1170 JS:1171 $("#test").toJSON(false);1172 //return JSON对象如下1173 { 1174 "csex":[{"value":"girl","label":"女"},{"value":"boy","label":"男"}],1175 "rsex":{"value":"boy","label":"男"},1176 "switchB":true,1177 "selectsex":{"value":"female","label":"女"},1178 "time":"10:4"1179 }1180 $("#test").toJSON(true);1181 //return JSON对象如下1182 { 1183 "csex":["girl","boy"],1184 "rsex":"boy",1185 "switchB":true,1186 "selectsex":"female",1187 "time":"10:4"1188 }1189*/1190$.fn.toJSON= function(justValue){1191 //BingoTouch定义表单元素1192 var selector =$(this);1193 var result={};1194 $("[data-role='BTCheck']",selector).each(function(){1195 var $obj = $(this);1196 var name = $obj.attr("name"), val =$obj.btcheck("val") ;1197 if(name!=null&&val!=null){1198 result[name] = result[name]||[] ;1199 if(justValue){ result[name].push(val.value) ; }1200 else{ result[name].push(val) ; } 1201 }1202 }) ;1203 $("[data-role='BTRadio']",selector).each(function(){1204 var $obj = $(this);1205 var name = $obj.attr("name"), val =$obj.btradio("val");1206 if(name!=null&&val!=null){1207 if(justValue){ result[name] = val.value; }1208 else{ result[name] =val; } 1209 }1210 }) ;1211 $("[data-role='BTSwitch']",selector).each(function(){1212 var $obj = $(this);1213 var name = $obj.attr("name"), val =$obj.btswitch("val") ;1214 if(name!=null){1215 result[name] = val;1216 }1217 }) ;1218 $("[data-role='BTSelect']",selector).each(function(){1219 var $obj = $(this);1220 var type = $obj.attr("type"),name = $obj.attr("name"),val;1221 if(type=='date'||type=='time'){1222 val =$obj.btdatepicker("val") ;1223 }1224 else{1225 val =$obj.btselect("val") ;1226 }1227 if(name!=null){1228 if(justValue){ result[name] = val.value; }1229 else{ result[name] =val; } 1230 }1231 }) ;1232 $('.dropdown > div[data-role="BTButton"]',selector).each(function(){1233 var $obj = $(this);1234 var name = $obj.attr("name"), val =$obj.btdropdown("val");1235 if(name!=null){1236 result[name] =val;1237 }1238 }) ;1239 //传统表单元素1240 $("input",selector).each(function(){1241 var $obj = $(this);1242 var type = $obj.attr('type'),name= $obj.attr("name");1243 if(type=='text'||type=='password'){1244 result[name] = $obj.attr('value');1245 }1246 else if( type =='checkbox'){1247 if($obj.attr("checked")){1248 result[name] = result[name]||[] ;1249 result[name].push($obj.attr("value")) ; 1250 } 1251 }1252 else if( type=='radio') {1253 if($obj.attr("checked")){1254 result[name] = $obj.attr("value") ;1255 } 1256 }1257 });1258 $("textarea",selector).each(function(){1259 var $obj = $(this);1260 result[$obj.attr("name")] = $obj.attr('value');1261 });1262 $("select",selector).each(function(){1263 var $obj = $(this);1264 result[$obj.attr("name")] = $obj.attr('value');1265 });1266 return result; 1267}...

Full Screen

Full Screen

utils-specs.js

Source:utils-specs.js Github

copy

Full Screen

...170 'appium:yetAnotherCap': 'yetAnotherCap',171 });172 });173 });174 describe('pullSettings()', function () {175 it('should pull settings from caps', function () {176 const caps = {177 platformName: 'foo',178 browserName: 'bar',179 'settings[settingName]': 'baz',180 'settings[settingName2]': 'baz2',181 };182 const settings = pullSettings(caps);183 settings.should.eql({184 settingName: 'baz',185 settingName2: 'baz2',186 });187 caps.should.eql({188 platformName: 'foo',189 browserName: 'bar',190 });191 });192 it('should pull settings dict if object values are present in caps', function () {193 const caps = {194 platformName: 'foo',195 browserName: 'bar',196 'settings[settingName]': {key: 'baz'},197 };198 const settings = pullSettings(caps);199 settings.should.eql({200 settingName: {key: 'baz'},201 });202 caps.should.eql({203 platformName: 'foo',204 browserName: 'bar',205 });206 });207 it('should pull empty dict if no settings are present in caps', function () {208 const caps = {209 platformName: 'foo',210 browserName: 'bar',211 'setting[settingName]': 'baz',212 };213 const settings = pullSettings(caps);214 settings.should.eql({});215 caps.should.eql({216 platformName: 'foo',217 browserName: 'bar',218 'setting[settingName]': 'baz',219 });220 });221 it('should pull empty dict if caps are empty', function () {222 const caps = {};223 const settings = pullSettings(caps);224 settings.should.eql({});225 caps.should.eql({});226 });227 });...

Full Screen

Full Screen

main.js

Source:main.js Github

copy

Full Screen

1var weather_url = "/api/weather/?current=true";//"http://api.openweathermap.org/data/2.5/weather?q=Westminster,US&units=imperial&appid=de70cab93f8df394687971295474e104"2var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];3var day_of_week = ["Sun", "Mon", "Tue", "Wed","Thu", "Fri", "Sat"];4var stndrdth = ["st","nd","rd","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","th","st","nd","rd","th","th","th","th","th","th","th","st"];5/*68 888888888o. 8 8888888888 .8. 8 888888888o. `8.`8888. ,8' 78 8888 `88. 8 8888 .888. 8 8888 `^888. `8.`8888. ,8' 88 8888 `88 8 8888 :88888. 8 8888 `88. `8.`8888. ,8' 98 8888 ,88 8 8888 . `88888. 8 8888 `88 `8.`8888.,8' 108 8888. ,88' 8 888888888888 .8. `88888. 8 8888 88 `8.`88888' 118 888888888P' 8 8888 .8`8. `88888. 8 8888 88 `8. 8888 128 8888`8b 8 8888 .8' `8. `88888. 8 8888 ,88 `8 8888 138 8888 `8b. 8 8888 .8' `8. `88888. 8 8888 ,88' 8 8888 148 8888 `8b. 8 8888 .888888888. `88888. 8 8888 ,o88P' 8 8888 158 8888 `88. 8 888888888888 .8' `8. `88888. 8 888888888P' 8 8888 16*/17$(document).ready(function(){18 LoadSettings();19 DisplayTime();20 window.timeTimer = setInterval(DisplayTime,1000);21});22function min_to_millisecond(min){23 return min * 60 * 1000;24}25function LoadSettings(){26 $.get("/api/settings").done(function(settings){27 console.log(settings);28 window.settings = settings;29 PullWeather();30 LoadPhoto();31 window.settingsTimer = setTimeout(PullSettings,window.settings.local_refresh); 32 });33}34function PullSettings(){35 clearTimeout(window.settingsTimer);36 window.settingsTimer = setTimeout(PullSettings,window.settings.local_refresh); 37 $.get("/api/settings").done(function(settings){38 console.log(settings);39 window.settings = settings;40 });41}42function DisplayTime(){43 var date = new Date(Date.now());44 //console.log(date);45 var hours = date.getHours();46 var am = "am";47 if(hours == 12)48 am = "pm";49 if(hours > 12){50 hours -= 12;51 am = "pm";52 }53 if(hours == 0){54 hours = 12;55 am = "am";56 }57 var mins = date.getMinutes();58 if(mins < 10){59 mins = "0" + mins60 }61 var time = hours + ":" + mins + am;62 //console.log(time);63 $("header [var=current_time]").html(time);64 $("header [var=current_time]").attr("time",time);65 $("header [var=current_date]").html(day_of_week[date.getDay()] + ", " + months[date.getMonth()] + " " + date.getDate() + stndrdth[date.getDate()-1] + ", " + date.getFullYear());66 $("header [var=current_date]").attr("date",date.getMonth() + "/" + date.getDate());67}68function PullWeather(){69 if(window.weatherTimer)70 clearTimeout(window.weatherTimer);71 window.weatherTimer = setTimeout(PullWeather,min_to_millisecond(window.settings.weather_refresh));72 $.get(weather_url).done(function(weather){73 console.log(weather);74 $("#live_weather").attr("weather",weather.current.weather[0].description);75 $("#live_weather").attr("icon",weather.current.weather[0].icon);76 $("#live_weather [var=temp]").html(Math.round(weather.current.main.temp));77 $("#live_weather [var=temp]").attr("temp_range",Math.floor(weather.current.main.temp/10));78 $("#live_weather [var=feels_like]").html(Math.round(weather.current.main.feels_like));79 $("#live_weather [var=feels_like]").attr("temp_range",Math.floor(weather.current.main.feels_like/10));80 $("#live_weather [var=humidity]").html(Math.round(weather.current.main.humidity));81 });...

Full Screen

Full Screen

initializer.js

Source:initializer.js Github

copy

Full Screen

...46 localStorage.setItem('button-4', '{"text":"Complement","color":"rgb(255, 255, 0)"}');47 48 loadButtons();49 fillPreviewBtns();50 pullSettings();51 applyPreferences();52 } else {53 disableInputOnStart();54 55 loadButtons();56 fillPreviewBtns();57 pullSettings();58 applyPreferences();59 }...

Full Screen

Full Screen

PullSet.js

Source:PullSet.js Github

copy

Full Screen

1import React, { Component } from 'react';2import router from 'umi/router';3import { connect } from 'dva';4import { Input } from 'antd';5import PageHeaderWrapper from '@/components/PageHeaderWrapper';6@connect()7class PullSet extends Component {8 handleTabChange = key => {9 const { match } = this.props;10 switch (key) {11 case 'pullopus':12 router.push(`${match.url}/pullopus`);13 break;14 case 'pullactivity':15 router.push(`${match.url}/pullactivity`);16 break;17 case 'pullbanner':18 router.push(`${match.url}/pullbanner`);19 break;20 case 'pullsettings':21 router.push(`${match.url}/pullsettings`);22 break;23 case 'pullbutton':24 router.push(`${match.url}/pullbutton`);25 break;26 case 'pulllogin':27 router.push(`${match.url}/pulllogin`);28 break;29 default:30 break;31 }32 };33 render() {34 const tabList = [35 {36 key: 'pullopus',37 tab: '作品',38 },39 {40 key: 'pullactivity',41 tab: '活动',42 },43 {44 key: 'pullbanner',45 tab: '广告',46 },47 {48 key: 'pullsettings',49 tab: '配置',50 },51 // {52 // key: 'pullbutton',53 // tab: '按钮',54 // },55 // {56 // key: 'pulllogin',57 // tab: '登录背景',58 // },59 ];60 const { match, children, location } = this.props;61 return (62 <PageHeaderWrapper63 tabList={tabList}64 tabActiveKey={location.pathname.replace(`${match.path}/`, '')}65 onTabChange={this.handleTabChange}66 >67 {children}68 {/* <Switch>69 {routes.map(item => (70 <Route key={item.key} path={item.path} component={item.component} exact={item.exact} />71 ))}72 </Switch> */}73 </PageHeaderWrapper>74 );75 }76}...

Full Screen

Full Screen

pull.js

Source:pull.js Github

copy

Full Screen

1#!/usr/bin/env node2"use strict";3/**4 * Synchronize a Mimic managed collection.5 * 6 * @author Todd King7 *8 * Provided under the Apache License 2.09 */10const yargs = require('yargs');11// Mimic modules12const config = require('./lib/config.js');13const bundle = require('./lib/bundle.js');14const mimic = require('./lib/mimic.js');15// Configure the app16var options = yargs17 .version('1.0.0')18 .usage('Synchronize the local copy of a Mimic collection with the source collection.')19 .usage('mimic-pull [args] <files...>')20 .example('mimic-pull .', 'synchonize the local file collection with the original source.')21 .epilog("Development funded by NASA's VMO and PDS projects at UCLA\nand provided under the Apache License 2.0.")22 .showHelpOnFail(false, "Specify --help for available options")23 .help('h')24 25 // version26 .options({27 // help text28 'h' : {29 alias : 'help',30 description: 'Show information about the app.'31 },32 33 // Verbose flag34 'v' : {35 alias: 'verbose',36 describe : 'Show information while processing request.',37 type: 'boolean',38 default: false39 },40 41 // Tag42 't' : {43 alias: 'tag',44 describe : 'Name tag for the action.',45 type: 'string'46 },47 })48 .argv49 ;50var args = options._; // None option command line arguments51var main = function(args)52{53 // If no files or options show help54 if (args.length == 0) {55 yargs.showHelp();56 return;57 }58 var filePath = args[0];59 var root = mimic.findRoot(filePath);60 61 // Test if under mimic management62 if(root === undefined || root === null) { // Not initialized63 return;64 }65 var settings = config.load(filePath);66 var pullSettings = settings["Pull"];67 if( ! pullSettings ) {68 console.log("No 'pull' source is defined. Mimic collection is not configured to pull.");69 return;70 }71 // Process main collection72 mimic.syncWithPull(root, pullSettings.uri, pullSettings.username, pullSettings.keyfile, options.verbose);73 74}...

Full Screen

Full Screen

useFontSize.js

Source:useFontSize.js Github

copy

Full Screen

...16};17const useFontSize = (originalFontsize) => {18 const [settings, setSettings] = useState(defaultSettings)19 useEffect(() => {20 pullSettings()21 .then((setting) => setSettings(setting));22 }, []);23 const asyncFontSize = settings.fontSize;24 const ratio = asyncFontSize / 20;25 const og = originalFontsize || 14;26 const additional = Platform.isPad ? 10 : 027 return og >= 30 ? og + additional : og * ratio + additional;28};...

Full Screen

Full Screen

useSoundSetting.js

Source:useSoundSetting.js Github

copy

Full Screen

...15};16const useSoundSetting = () => {17 const [settings, setSettings] = useState(defaultSettings)18 useEffect(() => {19 pullSettings()20 .then((setting) => setSettings(setting));21 }, []);22 const soundObj = {23 soundEffectsOn: settings.soundEffectsOn,24 voiceOverOn: settings.voiceOverOn,25 }26 return soundObj;27};...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var settings = driver.pullSettings();2driver.pushSettings(settings);3var fileContent = driver.pullFile("/sdcard/DCIM/Camera/IMG_20150811_112138.jpg");4driver.pushFile("/sdcard/DCIM/Camera/IMG_20150811_112138.jpg", fileContent);5var logTypes = driver.getLogTypes();6var log = driver.getLog("logcat");7var deviceTime = driver.getDeviceTime();8var isInstalled = driver.isAppInstalled("com.android.calculator2");9driver.installApp("C:\\Users\\Appium\\Downloads\\Calculator_v1.0.apk");10driver.removeApp("com.android.calculator2");11driver.runAppInBackground(5);12driver.closeApp();13driver.launchApp();14driver.startActivity("com.android.calculator2", "com.android.calculator2.Calculator");15driver.resetApp();16driver.endTestCoverage("intent", "coverage.ec");17driver.lock(5);18driver.unlock();19var isLocked = driver.isLocked();20driver.shake();21var orientation = driver.getOrientation();22driver.setOrientation("LANDSCAPE");

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var Q = require('q');4var _ = require('underscore');5var path = require('path');6var fs = require('fs');7var settings = require('./settings');8var log = require('./logger').getLogger('appium');9var logger = require('./logger').getLogger('appium');10var test = require('selenium-webdriver/testing');11var webdriver = require('selenium-webdriver');12var until = webdriver.until;13var By = webdriver.By;14var driver = wd.promiseChainRemote(settings.appium.host, settings.appium.port);15var desiredCaps = {16};17driver.init(desiredCaps).then(function() {18 driver.pullSettings().then(function(result) {19 console.log(result);20 });21});

Full Screen

Using AI Code Generation

copy

Full Screen

1var AppiumSettings = require('appium-settings');2var settings = new AppiumSettings();3settings.pullSettings('test', function(err, res) {4 if (err) {5 console.log('Error: ' + err);6 } else {7 console.log('Result: ' + res);8 }9});10var AppiumSettings = require('appium-settings');11var settings = new AppiumSettings();12settings.pushSettings('test', function(err, res) {13 if (err) {14 console.log('Error: ' + err);15 } else {16 console.log('Result: ' + res);17 }18});19var AppiumSettings = require('appium-settings');20var settings = new AppiumSettings();21settings.getSettings('test', function(err, res) {22 if (err) {23 console.log('Error: ' + err);24 } else {25 console.log('Result: ' + res);26 }27});28var AppiumSettings = require('appium-settings');29var settings = new AppiumSettings();30settings.putSettings('test', function(err, res) {31 if (err) {32 console.log('Error: ' + err);33 } else {34 console.log('Result: ' + res);35 }36});37var AppiumSettings = require('appium-settings');38var settings = new AppiumSettings();39settings.deleteSettings('test', function(err, res) {40 if (err) {41 console.log('Error: ' + err);42 } else {43 console.log('Result: ' + res);44 }45});46var AppiumSettings = require('appium-settings');47var settings = new AppiumSettings();48settings.getSettings('test', function(err, res) {49 if (err) {50 console.log('Error: ' + err);51 } else {52 console.log('Result: ' + res);53 }54});55var AppiumSettings = require('appium-settings');56var settings = new AppiumSettings();57settings.deleteSettings('test', function(err, res) {58 if (err

Full Screen

Using AI Code Generation

copy

Full Screen

1var pullSettings = driver.pullSettings();2console.log(pullSettings);3driver.quit();4{5}6AppiumDriver.pullFile()7driver.pullFile(path)8var pullFile = driver.pullFile("/data/local/tmp/sample.txt");9console.log(pullFile);10driver.quit();11AppiumDriver.pushFile()12driver.pushFile(path, base64Data)13var pushFile = driver.pushFile("/data/local/tmp/sample.txt", "VGhpcyBpcyBhIHNhbXBsZSBmaWxlLg==");14console.log(pushFile);15driver.quit();16AppiumDriver.lock()17driver.lock(duration)18driver.lock(5);19driver.quit();

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