add samples, fix require()

This commit is contained in:
hyb1996
2017-05-09 20:01:04 +08:00
parent 956f064737
commit e5ade55519
31 changed files with 325 additions and 135 deletions

View File

@@ -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);
}
*/

View File

@@ -0,0 +1,3 @@
module.exports = function(){
}

View File

@@ -0,0 +1,2 @@
var sex = dialogs.singleChoice("请选择性别", ["男", "女", "基佬", "女装", "其他"], 2);
toast("选择了第" + (sex + 1) + "个选项");

View File

@@ -0,0 +1,7 @@
var i = dialogs.multiChoice("下列作品出自李贽的是", ["《焚书》", "《西湖寻梦》", "《高太史全集》", "《续焚烧书》", "《藏书》"]);
toast("选择了: " + i);
if(i.length == 2 && i.toString() == [0, 4].toString()){
toast("答对辣");
}else{
toast("答错辣");
}

View File

@@ -0,0 +1,9 @@
var handsome = confirm("你帅吗?");
if(handsome){
toast("真不要脸!");
toast("真不要脸!");
toast("真不要脸!");
alert("真不要脸!");
}else{
toast("嗯");
}

View File

@@ -0,0 +1,15 @@
while(true){
var i = dialogs.select("哲学的基本问题是", "社会和自然的关系问题", "思维与存在的关系问题", "政治和经济的关系问题", "实践和理论的关系问题");
if(i == -1){
toast("猜一下呗");
continue;
}
if(i == 1){
toast("答对辣");
break;
}else{
toast("答错辣")
}
}

View File

@@ -0,0 +1,4 @@
var name = rawInput("请输入名字");
alert("(•́へ•́╬)", "你好~ " + name);
var expr = dialogs.input("请输入简单的算式", "1+1");
alert("计算结果为 " + expr);