add samples, fix require()
This commit is contained in:
@@ -9,7 +9,7 @@ dialogs.rawInput = function(title, prefill){
|
||||
};
|
||||
|
||||
dialogs.input = function(title, prefill){
|
||||
return eval(rawInput(title, prefill));
|
||||
return eval(dialogs.rawInput(title, prefill) + "");
|
||||
}
|
||||
|
||||
dialogs.prompt = dialogs.rawInput;
|
||||
@@ -28,15 +28,18 @@ dialogs.select = function(title, items){
|
||||
return __runtime__.dialogs.select(title, [].slice.call(arguments, 1));
|
||||
}
|
||||
|
||||
dialogs.singleChoice = function(title, index, items){
|
||||
return __runtime__.dialogs.singleChoice(title, index, [].slice.call(arguments, 2));
|
||||
dialogs.singleChoice = function(title, items, index){
|
||||
index = index || 0;
|
||||
return __runtime__.dialogs.singleChoice(title, index, items);
|
||||
}
|
||||
|
||||
dialogs.multiChoice = function(title, index, items){
|
||||
var javaArray = __runtime__.dialogs.multiChoice(title, index, [].slice.call(arguments, 2));
|
||||
var jsArray = {};
|
||||
for each(i in javaArray){
|
||||
jsArray.push(i);
|
||||
dialogs.multiChoice = function(title, items, index){
|
||||
index = index || [];
|
||||
var javaArray = __runtime__.dialogs.multiChoice(title, index, items);
|
||||
var jsArray = [];
|
||||
var len = javaArray.length;
|
||||
for (var i = 0;i < len;i++){
|
||||
jsArray.push(javaArray[i]);
|
||||
}
|
||||
return jsArray;
|
||||
}
|
||||
@@ -56,23 +59,3 @@ var confirm = function(title, prefill){
|
||||
var prompt = function(title, prefill){
|
||||
return dialogs.prompt(title, prefill);
|
||||
}
|
||||
/*
|
||||
|
||||
dialogs.rawInput = function(title, prefill){
|
||||
prefill = prefill || "";
|
||||
return __runtime__.dialogs.rawInput(title, prefill);
|
||||
}
|
||||
|
||||
dialogs.input = function(title, prefill){
|
||||
return eval(rawInput(title, prefill));
|
||||
}
|
||||
|
||||
dialogs.alert = function(title, content){
|
||||
__runtime__.dialogs.alert(title, content);
|
||||
}
|
||||
|
||||
dialogs.select = function(title, content){
|
||||
__runtime__.dialogs.alert(title, content);
|
||||
}
|
||||
|
||||
*/
|
||||
3
app/src/main/assets/modules/dialogs.js
Normal file
3
app/src/main/assets/modules/dialogs.js
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = function(){
|
||||
|
||||
}
|
||||
2
app/src/main/assets/sample/对话框/单选框.js
Normal file
2
app/src/main/assets/sample/对话框/单选框.js
Normal file
@@ -0,0 +1,2 @@
|
||||
var sex = dialogs.singleChoice("请选择性别", ["男", "女", "基佬", "女装", "其他"], 2);
|
||||
toast("选择了第" + (sex + 1) + "个选项");
|
||||
7
app/src/main/assets/sample/对话框/多选框.js
Normal file
7
app/src/main/assets/sample/对话框/多选框.js
Normal file
@@ -0,0 +1,7 @@
|
||||
var i = dialogs.multiChoice("下列作品出自李贽的是", ["《焚书》", "《西湖寻梦》", "《高太史全集》", "《续焚烧书》", "《藏书》"]);
|
||||
toast("选择了: " + i);
|
||||
if(i.length == 2 && i.toString() == [0, 4].toString()){
|
||||
toast("答对辣");
|
||||
}else{
|
||||
toast("答错辣");
|
||||
}
|
||||
9
app/src/main/assets/sample/对话框/确认框.js
Normal file
9
app/src/main/assets/sample/对话框/确认框.js
Normal file
@@ -0,0 +1,9 @@
|
||||
var handsome = confirm("你帅吗?");
|
||||
if(handsome){
|
||||
toast("真不要脸!");
|
||||
toast("真不要脸!");
|
||||
toast("真不要脸!");
|
||||
alert("真不要脸!");
|
||||
}else{
|
||||
toast("嗯");
|
||||
}
|
||||
15
app/src/main/assets/sample/对话框/菜单.js
Normal file
15
app/src/main/assets/sample/对话框/菜单.js
Normal file
@@ -0,0 +1,15 @@
|
||||
while(true){
|
||||
var i = dialogs.select("哲学的基本问题是", "社会和自然的关系问题", "思维与存在的关系问题", "政治和经济的关系问题", "实践和理论的关系问题");
|
||||
if(i == -1){
|
||||
toast("猜一下呗");
|
||||
continue;
|
||||
}
|
||||
if(i == 1){
|
||||
toast("答对辣");
|
||||
break;
|
||||
}else{
|
||||
toast("答错辣")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
4
app/src/main/assets/sample/对话框/输入框.js
Normal file
4
app/src/main/assets/sample/对话框/输入框.js
Normal file
@@ -0,0 +1,4 @@
|
||||
var name = rawInput("请输入名字");
|
||||
alert("(•́へ•́╬)", "你好~ " + name);
|
||||
var expr = dialogs.input("请输入简单的算式", "1+1");
|
||||
alert("计算结果为 " + expr);
|
||||
Reference in New Issue
Block a user