|
|
|
@ -337,7 +337,7 @@ |
|
|
|
}); |
|
|
|
}); |
|
|
|
// 取得資料夾中的所有檔案名稱 |
|
|
|
// 取得資料夾中的所有檔案名稱 |
|
|
|
function func_getFileList(pyFileName) { |
|
|
|
function func_getFileList(pyFileName) { |
|
|
|
console.log('in get file list'); |
|
|
|
//console.log('in get file list'); |
|
|
|
$.ajax({ |
|
|
|
$.ajax({ |
|
|
|
url: "/python?getfilelist=all", |
|
|
|
url: "/python?getfilelist=all", |
|
|
|
type: "GET", |
|
|
|
type: "GET", |
|
|
|
@ -411,7 +411,7 @@ |
|
|
|
var pyFileName = file_name; |
|
|
|
var pyFileName = file_name; |
|
|
|
pythoncode = editor.getValue(); |
|
|
|
pythoncode = editor.getValue(); |
|
|
|
var encoded = encodeURIComponent(pythoncode); |
|
|
|
var encoded = encodeURIComponent(pythoncode); |
|
|
|
console.log("func_FileSave pyFileName ---------- ",pyFileName) |
|
|
|
//console.log("func_FileSave pyFileName ---------- ",pyFileName) |
|
|
|
$.ajax({ |
|
|
|
$.ajax({ |
|
|
|
url: "/pythonsave?file=" + pyFileName + "&code=" + encoded, |
|
|
|
url: "/pythonsave?file=" + pyFileName + "&code=" + encoded, |
|
|
|
method: "GET", |
|
|
|
method: "GET", |
|
|
|
@ -421,7 +421,7 @@ |
|
|
|
xmlHttp.setRequestHeader("Cache-Control", "no-cache"); |
|
|
|
xmlHttp.setRequestHeader("Cache-Control", "no-cache"); |
|
|
|
}, |
|
|
|
}, |
|
|
|
success: function (response) { |
|
|
|
success: function (response) { |
|
|
|
console.log("response: ", response); |
|
|
|
//console.log("response: ", response); |
|
|
|
// 如果更新成功,則更新列表 |
|
|
|
// 如果更新成功,則更新列表 |
|
|
|
if (response === "File save successfully") { |
|
|
|
if (response === "File save successfully") { |
|
|
|
$('#console').append("Saving successfully"); |
|
|
|
$('#console').append("Saving successfully"); |
|
|
|
@ -446,7 +446,7 @@ |
|
|
|
function func_FileUpload(file_name) { |
|
|
|
function func_FileUpload(file_name) { |
|
|
|
var pyFileName = file_name; |
|
|
|
var pyFileName = file_name; |
|
|
|
var encoded = encodeURIComponent(pythoncode); |
|
|
|
var encoded = encodeURIComponent(pythoncode); |
|
|
|
console.log("func_FileUpload pyFileName ---------- ",pyFileName) |
|
|
|
//console.log("func_FileUpload pyFileName ---------- ",pyFileName) |
|
|
|
$.ajax({ |
|
|
|
$.ajax({ |
|
|
|
url: "/pythonupload?file=" + pyFileName + "&code=" + encoded, |
|
|
|
url: "/pythonupload?file=" + pyFileName + "&code=" + encoded, |
|
|
|
method: "GET", |
|
|
|
method: "GET", |
|
|
|
@ -456,7 +456,7 @@ |
|
|
|
xmlHttp.setRequestHeader("Cache-Control", "no-cache"); |
|
|
|
xmlHttp.setRequestHeader("Cache-Control", "no-cache"); |
|
|
|
}, |
|
|
|
}, |
|
|
|
success: function (response) { |
|
|
|
success: function (response) { |
|
|
|
console.log("response: ", response); |
|
|
|
//console.log("response: ", response); |
|
|
|
// 如果更新成功,則更新列表 |
|
|
|
// 如果更新成功,則更新列表 |
|
|
|
if (response === "File uploaded successfully") { |
|
|
|
if (response === "File uploaded successfully") { |
|
|
|
func_getFileList(pyFileName); |
|
|
|
func_getFileList(pyFileName); |
|
|
|
@ -488,7 +488,7 @@ |
|
|
|
}, |
|
|
|
}, |
|
|
|
success: function (retdata) { |
|
|
|
success: function (retdata) { |
|
|
|
// 直接刷新文件列表,無需指定 Index 刪除行 |
|
|
|
// 直接刷新文件列表,無需指定 Index 刪除行 |
|
|
|
console.log("Delete File successfully !!!") |
|
|
|
//console.log("Delete File successfully !!!") |
|
|
|
$('#console').append(' '); // 換行 |
|
|
|
$('#console').append(' '); // 換行 |
|
|
|
$('#console').append(retdata.replace(/\n/g, '<br>')); |
|
|
|
$('#console').append(retdata.replace(/\n/g, '<br>')); |
|
|
|
|
|
|
|
|
|
|
|
@ -502,7 +502,7 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
// 停止 Python 檔案 |
|
|
|
// 停止 Python 檔案 |
|
|
|
function func_stopPython(file_name) { |
|
|
|
function func_stopPython(file_name) { |
|
|
|
console.log("func_stopPython"); |
|
|
|
//console.log("func_stopPython"); |
|
|
|
|
|
|
|
|
|
|
|
currentRunningFile = ''; // |
|
|
|
currentRunningFile = ''; // |
|
|
|
$('#file-data-grid').datagrid('reload'); |
|
|
|
$('#file-data-grid').datagrid('reload'); |
|
|
|
@ -571,7 +571,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
// 取得 Python 執行狀態 |
|
|
|
// 取得 Python 執行狀態 |
|
|
|
function func_getPythonStatus(){ |
|
|
|
function func_getPythonStatus(){ |
|
|
|
console.log("func_getPythonStatus"); |
|
|
|
//console.log("func_getPythonStatus"); |
|
|
|
if (Status_intervalId !== null) { |
|
|
|
if (Status_intervalId !== null) { |
|
|
|
clearInterval(Status_intervalId); |
|
|
|
clearInterval(Status_intervalId); |
|
|
|
Status_intervalId = null; |
|
|
|
Status_intervalId = null; |
|
|
|
@ -582,7 +582,7 @@ |
|
|
|
method: "GET", |
|
|
|
method: "GET", |
|
|
|
async: true, |
|
|
|
async: true, |
|
|
|
success: function (retdata) { |
|
|
|
success: function (retdata) { |
|
|
|
console.log("-------------------",currentRunningFile); |
|
|
|
//console.log("-------------------",currentRunningFile); |
|
|
|
updateFileIcon(); |
|
|
|
updateFileIcon(); |
|
|
|
// console.log("GET Status Succeeded."); |
|
|
|
// console.log("GET Status Succeeded."); |
|
|
|
// console.log("--------------dataReceivedCount--------------",dataReceivedCount) |
|
|
|
// console.log("--------------dataReceivedCount--------------",dataReceivedCount) |
|
|
|
@ -602,14 +602,14 @@ |
|
|
|
try |
|
|
|
try |
|
|
|
{ |
|
|
|
{ |
|
|
|
var existData = $('#console').html(); |
|
|
|
var existData = $('#console').html(); |
|
|
|
console.log("Get Status: ", retdata); |
|
|
|
//console.log("Get Status: ", retdata); |
|
|
|
var displayData = func_convertSpecialChars(retdata); |
|
|
|
var displayData = func_convertSpecialChars(retdata); |
|
|
|
var data = JSON.parse(displayData); |
|
|
|
var data = JSON.parse(displayData); |
|
|
|
getBufferStatusTemp = parseInt(data['status']); |
|
|
|
getBufferStatusTemp = parseInt(data['status']); |
|
|
|
getBufferSignal = parseInt(data['bufferSignal']); |
|
|
|
getBufferSignal = parseInt(data['bufferSignal']); |
|
|
|
console.log('getBufferStatusTemp',getBufferStatusTemp); |
|
|
|
//console.log('getBufferStatusTemp',getBufferStatusTemp); |
|
|
|
console.log('getBufferSignal',getBufferSignal); |
|
|
|
//console.log('getBufferSignal',getBufferSignal); |
|
|
|
console.log("g_isPythonRunning",g_isPythonRunning); |
|
|
|
//console.log("g_isPythonRunning",g_isPythonRunning); |
|
|
|
} catch (error) { |
|
|
|
} catch (error) { |
|
|
|
console.log(error); |
|
|
|
console.log(error); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -643,7 +643,7 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
// 取得 Python 結果 |
|
|
|
// 取得 Python 結果 |
|
|
|
function func_getPythonBuffer() { |
|
|
|
function func_getPythonBuffer() { |
|
|
|
console.log("func_getPythonBuffer() start"); |
|
|
|
//console.log("func_getPythonBuffer() start"); |
|
|
|
try { |
|
|
|
try { |
|
|
|
$.ajax({ |
|
|
|
$.ajax({ |
|
|
|
url: "/pythongetbuffer?buffersize=" + getPythonBufferSize.toString(), |
|
|
|
url: "/pythongetbuffer?buffersize=" + getPythonBufferSize.toString(), |
|
|
|
@ -653,10 +653,10 @@ |
|
|
|
// console.log("GET request succeeded."); |
|
|
|
// console.log("GET request succeeded."); |
|
|
|
var existData = $('#console').html(); |
|
|
|
var existData = $('#console').html(); |
|
|
|
// console.log("Get Data: ", retdata); |
|
|
|
// console.log("Get Data: ", retdata); |
|
|
|
console.log("Get Data:", JSON.stringify(retdata)); |
|
|
|
//console.log("Get Data:", JSON.stringify(retdata)); |
|
|
|
// $('#console').append(retdata); |
|
|
|
// $('#console').append(retdata); |
|
|
|
displayData = func_checkSpecialChar(retdata); |
|
|
|
displayData = func_checkSpecialChar(retdata); |
|
|
|
console.log("Get displayData",JSON.stringify(displayData)); |
|
|
|
//console.log("Get displayData",JSON.stringify(displayData)); |
|
|
|
$('#console').append(displayData); |
|
|
|
$('#console').append(displayData); |
|
|
|
|
|
|
|
|
|
|
|
// 根據 autoScroll 開關自動滾動 Ming 2024-08-29 |
|
|
|
// 根據 autoScroll 開關自動滾動 Ming 2024-08-29 |
|
|
|
@ -703,19 +703,19 @@ |
|
|
|
func_getPythonStatus(); |
|
|
|
func_getPythonStatus(); |
|
|
|
g_isPythonRunning = 1; |
|
|
|
g_isPythonRunning = 1; |
|
|
|
currentRunningFile = file_name; |
|
|
|
currentRunningFile = file_name; |
|
|
|
console.log("currentFileName",currentFileName); |
|
|
|
//console.log("currentFileName",currentFileName); |
|
|
|
var json_data = '{'; |
|
|
|
var json_data = '{'; |
|
|
|
json_data += '"system_setting": {'; |
|
|
|
json_data += '"system_setting": {'; |
|
|
|
json_data += '"enable_python_file": "' + currentRunningFile + '"'; |
|
|
|
json_data += '"enable_python_file": "' + currentRunningFile + '"'; |
|
|
|
json_data += '}'; |
|
|
|
json_data += '}'; |
|
|
|
json_data += '}'; |
|
|
|
json_data += '}'; |
|
|
|
func_setconfigfile(json_data); |
|
|
|
func_setconfigfile(json_data); |
|
|
|
console.log("func_runPython"); |
|
|
|
//console.log("func_runPython"); |
|
|
|
autoScroll = true; |
|
|
|
autoScroll = true; |
|
|
|
var python_content = editor.getValue(); |
|
|
|
var python_content = editor.getValue(); |
|
|
|
var json_data = "lifile_liname=" + file_name; |
|
|
|
var json_data = "lifile_liname=" + file_name; |
|
|
|
|
|
|
|
|
|
|
|
console.log(file_name); |
|
|
|
//console.log(file_name); |
|
|
|
updateFileIcon(); |
|
|
|
updateFileIcon(); |
|
|
|
|
|
|
|
|
|
|
|
$.ajax({ |
|
|
|
$.ajax({ |
|
|
|
@ -730,7 +730,7 @@ |
|
|
|
xmlHttp.setRequestHeader("Cache-Control", "no-cache"); |
|
|
|
xmlHttp.setRequestHeader("Cache-Control", "no-cache"); |
|
|
|
}, |
|
|
|
}, |
|
|
|
success: function (retdata) { |
|
|
|
success: function (retdata) { |
|
|
|
console.log("[/sendpycode] retdata:", retdata); // 2024/08/21 |
|
|
|
//console.log("[/sendpycode] retdata:", retdata); // 2024/08/21 |
|
|
|
// resolve(retdata); |
|
|
|
// resolve(retdata); |
|
|
|
// $('#console').text("Running.....\n"); |
|
|
|
// $('#console').text("Running.....\n"); |
|
|
|
g_isPythonRunning = 0; |
|
|
|
g_isPythonRunning = 0; |
|
|
|
@ -794,7 +794,7 @@ |
|
|
|
$('#console').append(' '); // 換行 |
|
|
|
$('#console').append(' '); // 換行 |
|
|
|
$('#console').append("Running..."); |
|
|
|
$('#console').append("Running..."); |
|
|
|
$('#console').append(' '); // 換行 |
|
|
|
$('#console').append(' '); // 換行 |
|
|
|
console.log("find enable python file !!!!!!!!!!!!!! "); |
|
|
|
//console.log("find enable python file !!!!!!!!!!!!!! "); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
resolve(); // 結束後解析 Promise |
|
|
|
resolve(); // 結束後解析 Promise |
|
|
|
@ -909,7 +909,7 @@ |
|
|
|
editor.on('keydown', function (instance, event) { |
|
|
|
editor.on('keydown', function (instance, event) { |
|
|
|
if (event.shiftKey && event.which === 13) { |
|
|
|
if (event.shiftKey && event.which === 13) { |
|
|
|
event.preventDefault(); |
|
|
|
event.preventDefault(); |
|
|
|
console.log("Now Running:", currentFileName); |
|
|
|
//console.log("Now Running:", currentFileName); |
|
|
|
// 禁用「Run」,防止連續點擊 |
|
|
|
// 禁用「Run」,防止連續點擊 |
|
|
|
$("#run-button").prop("disabled", true); |
|
|
|
$("#run-button").prop("disabled", true); |
|
|
|
func_runPython(currentFileName); // 使用現在的文件名稱執行 Python |
|
|
|
func_runPython(currentFileName); // 使用現在的文件名稱執行 Python |
|
|
|
@ -945,7 +945,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
// 按儲存按鈕 |
|
|
|
// 按儲存按鈕 |
|
|
|
$('#save-button').click(function (event) { |
|
|
|
$('#save-button').click(function (event) { |
|
|
|
console.log("Click event triggered on #save-button"); |
|
|
|
//console.log("Click event triggered on #save-button"); |
|
|
|
func_FileSave(currentFileName); // 使用現在的文件名稱進行上傳 |
|
|
|
func_FileSave(currentFileName); // 使用現在的文件名稱進行上傳 |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
@ -1007,7 +1007,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
// 將程式碼清空並上傳 |
|
|
|
// 將程式碼清空並上傳 |
|
|
|
$('#delete-button').click(function () { |
|
|
|
$('#delete-button').click(function () { |
|
|
|
console.log(""); |
|
|
|
//console.log(""); |
|
|
|
Swal.fire({ |
|
|
|
Swal.fire({ |
|
|
|
title: MESSAGE109, |
|
|
|
title: MESSAGE109, |
|
|
|
icon: 'warning', |
|
|
|
icon: 'warning', |
|
|
|
|