Browse Source

2.0.7.60

master
ming.hong 1 year ago
parent
commit
9e68a43f8c
  1. 92
      Aida/python.html

92
Aida/python.html

@ -186,6 +186,7 @@
<div class="progress" style="background-color:white"> <div class="progress" style="background-color:white">
<div class="progress-bar progress-bar-striped" style="min-width: 20px;visibility:hidden;"></div> <div class="progress-bar progress-bar-striped" style="min-width: 20px;visibility:hidden;"></div>
</div> </div>
<div style="border:1px gray solid;padding:5px;margin:5px 5px 5px 5px;height: 560px;"> <div style="border:1px gray solid;padding:5px;margin:5px 5px 5px 5px;height: 560px;">
<div id="container" style="height: 100vh; display: flex;"> <div id="container" style="height: 100vh; display: flex;">
@ -281,12 +282,10 @@
var getPythonBufferSize = 64; var getPythonBufferSize = 64;
var getBufferStatusTemp = null; var getBufferStatusTemp = null;
var getBufferSignal = null; var getBufferSignal = null;
//var displayDataCounter = 0;
var currentRunningFile = ''; // temp running file name var currentRunningFile = ''; // temp running file name
var g_isPythonRunning = 0; var g_isPythonRunning = 0;
var pythoncode = "" var pythoncode = ""
var currentFileName = ''; var currentFileName = '';
// 初始化為 null,確保 intervalId 定義過
var intervalId = null; // Ming add 2024/08/22 var intervalId = null; // Ming add 2024/08/22
var autoScroll = true; // Ming 2024-08-29 var autoScroll = true; // Ming 2024-08-29
var isUserScrolling = false; // Ming 2024-08-29 var isUserScrolling = false; // Ming 2024-08-29
@ -295,30 +294,28 @@
// 取得語系 // 取得語系
func_get_lang_cookie(); func_get_lang_cookie();
// 當網頁加載完成後自動載入 hello.py // 修改 window.onload 使用 async/await
window.onload = function() { // Ming add 2024/08/22 window.onload = async function() {
// 確認之前執行狀態 // 確認之前執行狀態
func_enablePythonfile(); await func_enablePythonfile();
// 確認有無回傳的資料 // 確認有無回傳的資料
func_getPythonStatus(); func_getPythonStatus();
// 確認是否有 python 文件正在執行
if (currentRunningFile.endsWith('.py')) if (currentRunningFile.endsWith('.py'))
{ {
func_FileGet(currentRunningFile); currentFileName = currentRunningFile;
func_getFileList(currentRunningFile);
} }
else else
{ {
currentFileName = 'hello.py'; currentFileName = 'hello.py';
// 加載文件列表並選中 hello.py
func_FileGet(currentFileName);
// 自動加載並顯示 hello.py 的內容
func_getFileList(currentFileName);
} }
// 加載文件列表並選中 python
func_FileGet(currentFileName);
// 自動加載並顯示 python 的內容
func_getFileList(currentFileName);
}; };
// 初始化 CodeMirror // 初始化 CodeMirror
var editor = CodeMirror.fromTextArea(document.getElementById('code-textarea'), { var editor = CodeMirror.fromTextArea(document.getElementById('code-textarea'), {
lineNumbers: true, lineNumbers: true,
@ -776,44 +773,37 @@
}); });
return false; return false;
} }
// 取得 config.json 中 enable_python_file 的值 // 使用 Promise 取得 config.json 中 enable_python_file 的值後返回
function func_enablePythonfile() { // Ming 2024-10-04 function func_enablePythonfile() {
$.ajax({ return new Promise((resolve, reject) => {
url: "/getconfigfile?ch=all", $.ajax({
type: "GET", url: "/getconfigfile?ch=all",
async: true, type: "GET",
beforeSend: function (xmlHttp) { async: true,
xmlHttp.setRequestHeader("If-Modified-Since", "0"); beforeSend: function (xmlHttp) {
xmlHttp.setRequestHeader("Cache-Control", "no-cache"); xmlHttp.setRequestHeader("If-Modified-Since", "0");
//xmlHttp.setRequestHeader("Authorization", "Basic " + btoa("username:password")); xmlHttp.setRequestHeader("Cache-Control", "no-cache");
}, },
success: function (retdata) { success: function (retdata) {
var jsonbuf = JSON.parse(retdata); var jsonbuf = JSON.parse(retdata);
if ("enable_python_file" in jsonbuf["system_setting"]) {
if ("enable_python_file" in jsonbuf["system_setting"]) { currentRunningFile = jsonbuf["system_setting"]["enable_python_file"];
currentRunningFile = jsonbuf["system_setting"]["enable_python_file"]; g_isPythonRunning = 1;
g_isPythonRunning = 1; if (currentRunningFile.endsWith('.py')) {
if (currentRunningFile.endsWith('.py')) $('#console').html("Execute unfinished python file !!");
{ $('#console').append('&#13;&#10;'); // 換行
$('#console').html("Execute unfinished python file !!"); $('#console').append("Running...");
$('#console').append('&#13;&#10;'); // 換行 $('#console').append('&#13;&#10;'); // 換行
$('#console').append("Running..."); console.log("find enable python file !!!!!!!!!!!!!! ");
$('#console').append('&#13;&#10;'); // 換行 }
console.log("find enable python file !!!!!!!!!!!!!! ");
}
else
{
console.log("not found enable python file !!!!!!!!!!!!!! ");
} }
} else { resolve(); // 結束後解析 Promise
console.log("not found enable python setting"); },
error: function (retdata) {
console.warn(retdata);
reject(retdata); // 發生錯誤時拒絕 Promise
} }
});
},
error: function (retdata) {
// setTimeout(func_enablePythonfile(), 3000);
console.warn(retdata);
}
}); });
} }
// 新建檔案 // 新建檔案

Loading…
Cancel
Save