54 lines
1.9 KiB
HTML
54 lines
1.9 KiB
HTML
![]() |
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<meta charset="utf-8">
|
||
|
<title>CheerpJ test</title>
|
||
|
<script src="https://cjrtnc.leaningtech.com/2.3/loader.js"></script>
|
||
|
|
||
|
</head>
|
||
|
<body>
|
||
|
</body>
|
||
|
<br />{{ py2htmlstr }}
|
||
|
<script>
|
||
|
function showPreloadProgress(loadedFiles, totalFiles)
|
||
|
{
|
||
|
console.log("Percentage loaded "+(loadedFiles*100/totalFiles));
|
||
|
}
|
||
|
//上传测井数据表到服务器数据库
|
||
|
function PostToServer(data) {
|
||
|
|
||
|
var httpRequest = new XMLHttpRequest();//第一步:建立所需的对象
|
||
|
httpRequest.open("POST",""); //调用AddDataToServer
|
||
|
httpRequest.setRequestHeader("Content-Type", "application/json"); //设置请求头信息
|
||
|
httpRequest.onreadystatechange = function () {
|
||
|
if (httpRequest.readyState == 4 && httpRequest.status == 200) {
|
||
|
alert('添加成功');
|
||
|
}
|
||
|
}
|
||
|
console.log(typeof Array.from(data));
|
||
|
console.log(Array.from(data));
|
||
|
httpRequest.send(JSON.stringify(Array.from(data))); //设置为发送给服务器数据
|
||
|
//httpRequest.send((""+data));
|
||
|
}
|
||
|
|
||
|
var cheerpjListener = {preloadProgress:showPreloadProgress};
|
||
|
cheerpjInit({listener:cheerpjListener});
|
||
|
//cheerpjInit();
|
||
|
cheerpjCreateDisplay(800,600);
|
||
|
//cheerpjRunMain("Play", "/app/Mario-AI-Interface.jar", "0", "f_l", "0");
|
||
|
|
||
|
console.log("done");
|
||
|
|
||
|
cheerpjRunJar("/app/Mario-AI-Interface.jar");
|
||
|
var returnVal = cjCall("Play", "otherMain", "0", "f_l", "0");//
|
||
|
returnVal.then(function(e) {
|
||
|
console.log("the return val is ready");
|
||
|
console.log(returnVal.value);
|
||
|
PostToServer(returnVal.value);
|
||
|
|
||
|
}).catch(e => console.log("Critical failure: " + e.message));
|
||
|
//console.log(returnVal);
|
||
|
// cheerpjRunJar("/app/Mario-AI-Interface.jar");
|
||
|
// var actionSequenceInBytes = cjCall("MarioProxy", "play", "0", "f_l", "0");
|
||
|
</script>
|
||
|
</html>
|