option

wait to trigger action

假装没事ソ 提交于 2020-01-06 17:15:52
问题 I am looking to trigger a while loop, but only after the user selects an option. For some reason now, it is automatically blowing through the entire block of code even before the user picks an option. How can I force it to wait to continue until a user selects something? case R.id.buttonSetPlayers: //**********************// //***SET PLAYER COUNT***// //**********************// AlertDialog.Builder builderPC = new AlertDialog.Builder(this); final CharSequence[] playerCount = {"1", "2", "3", "4

03 canvas帧动画封装案例

我只是一个虾纸丫 提交于 2020-01-06 04:57:28
sprite.js /** * Created by suxiaoxia on 2017/7/15. */ function sprite(option) { this._init(option); } sprite.prototype = { /*初始化*/ _init:function (option) { this.x = option.x || 0; this.y = option.y || 0; this.w = option.w || 40; this.h = option.h || 65; this.fps = option.fps || 10; this.originW = option.originW || 40; this.originH = option.originH || 65; this._dirIndex = 0; this._imgSrc = option.imgSrc || ''; }, render:function (ctx) { var img = new Image(); img.src = this._imgSrc; var self = this; img.onload = function () { var frameIndex = 0; setInterval(function () { ctx.clearRect(0,0,ctx

linux下的dhcp服务的开启

做~自己de王妃 提交于 2020-01-05 20:37:48
第一步: cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf 第二步: 改成自己网卡所在的网段. 第三步: service dhcpd start 成功! 验证也成功 原理:linux的DHCP服务是一个修改配置文件的服务,此配置文件的范本在/usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample 只要拷贝一下到/etc配置目录下就可启动.由于DHCP 能识别自己网段(也就是要跨网段的 话要用到DHCP中继) 查看租约:cat /var/lib/dhcpd/dhcpd.leases 复制配置文件 cp /usr/share/doc/dhcp-3.05/dhcpd.conf.sample /etc/dhcpd.conf vi /etc/dhcpd.conf ①修改子网 subnet、子网掩码netmask、路由routers、dns服务器 ②可分配地址段 ③租约 ④为指定的计算机保留IP [root@localhost ~]# cat /etc/dhcpd.conf ddns-update-style interim; ignore client-updates; subnet 192.168.99.0 netmask 255.255.255.0 { # --- default

How to disable select based on other selected option?

烈酒焚心 提交于 2020-01-05 08:59:18
问题 I have a problem with jQuery function. I want based on one selected option to disable other select. In my case, I want to disable select2 if option 1 from select 1 is chosen. So i use this jQuery function: $(document).ready(function(e) { $('.select1').change(function(e) { if ($('.select1').val()==1){ $('.select2').attr('disabled','disabled'); } else{ $('.select2').removeAttr('disabled'); } }) }); But this works only if I first select option 2(or any other option form this select) and then

jquery 设置 Select CheckBox Radio

吃可爱长大的小学妹 提交于 2020-01-05 04:59:15
一 、Select jQuery获取Select选择的Text和Value: 1. $("#select_id").change(function(){//code...}); //为Select添加事件,当选择其中一项时触发 2. var checkText=$("#select_id").find("option:selected").text(); //获取Select选择的Text 3. var checkValue=$("#select_id").val(); //获取Select选择的Value 4. var checkIndex=$("#select_id ").get(0).selectedIndex; //获取Select选择的索引值 5. var maxIndex=$("#select_id option:last").attr("index"); //获取Select最大的索引值 jQuery设置Select选择的Text和Value: 1. $("#select_id ").get(0).selectedIndex=1; //设置Select索引值为1的项选中 2. $("#select_id ").val(4); //设置Select的Value值为4的项选中 3. $("#select_id option[text='jQuery']").attr(

How to refactor a function that throws exceptions?

主宰稳场 提交于 2020-01-04 06:08:36
问题 Suppose I am refactoring a function like this: def check(ox: Option[Int]): Unit = ox match { case None => throw new Exception("X is missing") case Some(x) if x < 0 => throw new Exception("X is negative") case _ => () } I'd like to get rid of the exceptions but I need to keep the check signature and behavior as is, so I'm factoring out a pure implementation -- doCheck : import scala.util.{Try, Success, Failure} def doCheck(ox: Option[Int]): Try[Unit] = ??? def check(ox: Option[Int]): Unit =

How to refactor a function that throws exceptions?

和自甴很熟 提交于 2020-01-04 06:08:28
问题 Suppose I am refactoring a function like this: def check(ox: Option[Int]): Unit = ox match { case None => throw new Exception("X is missing") case Some(x) if x < 0 => throw new Exception("X is negative") case _ => () } I'd like to get rid of the exceptions but I need to keep the check signature and behavior as is, so I'm factoring out a pure implementation -- doCheck : import scala.util.{Try, Success, Failure} def doCheck(ox: Option[Int]): Try[Unit] = ??? def check(ox: Option[Int]): Unit =

LODOP在页面让客户选择打印机

旧时模样 提交于 2020-01-04 00:00:09
获取打印机列表可以放在onload事件里,如过当前是使用的c-lodop,由于websoket链接需要时间,一进入页面可能会报错,被准备好或网页没下载完成等,也可以在点击事件里让用户获取打印机。 之前写过两个在页面选择打印机的博文: Lodop在页面获取打印机列表 选择打印机预览 C-Lodop获取打印机列表Create_Printer_List (c-lodop独有的方法,集中打印,AO打印可以用这个方法) 都是早期写的博文,搬运到新博客的,没有代码,这里重新介绍一下第一个博文的那种lodop和c-lodop通用的方法,选择打印机也可以不在页面加载的时候获取,点击后获取打印机列表然后选择。 正常情况下点击一次,获取到打印机列表,用户就可以选择打印机了,但是用户也可能手滑或者点了多次等原因,为了避免重新装载打印机到列表里,可以判断为不为空的时候就不再装载了。 在onload理论原来写的这个获取打印机列表方法:(由于之前写过,不再放这个的图)后面的有按钮获取的图。其实和按钮获取的方法是一样的,就是一个在onload理论,一个按钮点击获取。 代码: <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>WEB打印控件LODOP</title> <script

How to write a lazy, variable argument version of “orElse”

非 Y 不嫁゛ 提交于 2020-01-03 16:52:11
问题 Is it possible to write a generalised orElse method from Option that takes a variable number of arguments? That is, instead of: lazy val o1 = { println("foo"); None } lazy val o2 = { println("bar"); Some("bar") } lazy val o3 = { println("baz"); Some("baz") } // ... o1 orElse o2 orElse o3 // orElse ... You could use: orElse(o1, o2, o3) //, ... 回答1: According to the The Scala Language Specification (4.6 Function Declarations and Definitions) you cannot define varargs by-name parameters:

表单操作

╄→尐↘猪︶ㄣ 提交于 2020-01-03 07:41:06
引言:JavaScript最早被设计出来就是为了实现对注册表单的验证,本文简单的介绍了JavaScript的表单操作 1.获取表单对象的方法 1.通过表单ID获取:document.getElementById("formId"); 2.通过表单的索引获取:document.forms[index]; 3.通过表单的name获取:document.forms["formName"]; document.formName; 2.表单对象常用的属性 name 获取或设置表单的 name 属性 action 获取或者设置表单提交的地址 elements 获取一个数组,包括该表单中所有的表单域 length 获取表单的表单域的数量 method 获取或设置表单的表单的提交方式:get(默认)、post enctype 获取或设置表单的编码方式:application/x-www-form-urlencoded(默认)、multipart/form-data、text/plain 3.get方式和post方式的区别 1.get的通过URL参数会显示在URL中,较不安全。 post的参数通过请求实体(Request body)传输,不会显示在URL中,相对安全。 2.get的参数长度有限制,长度视浏览器而定一般在2k左右。post的长度理论上是无限的 3.GET请求会被浏览器主动cache