mirror of
https://github.com/luc-github/ESP3D-WEBUI.git
synced 2026-02-20 01:11:21 +01:00
## What's Changed * Complete refactoring using spectre.css and correct Preact API per @alexblog suggestion * Smaller footprint * Add support for extensions/pluggins * Add theme support by using external css * Remove banner as unnecessary * Remove information bar and put information to separate page and respective panel * Add audio and haptic feedback * Add Repetier / ESP3DLib V2 / Smoothieware / GRBL support * Split code for 3DPrinter / CNC / Sand Table ## Limitations * CNC / Sand Table specific UI is still not defined * Wizard is not implemented yet * Works with ESP3D 3.0- alpha-2 - no backward compatibility * Language packs are not ready to be translated yet as UI is not finished ## Discussion / status [Discussion](https://github.com/luc-github/ESP3D-WEBUI/discussions/94) ## New Contributors @alexblog made several contributions like https://github.com/luc-github/ESP3D-WEBUI/pull/236
46 lines
1.5 KiB
HTML
46 lines
1.5 KiB
HTML
<script type="text/javascript">
|
|
function sendMessage(msg){
|
|
window.parent.postMessage(msg, '*');
|
|
}
|
|
|
|
function processMessage(eventMsg){
|
|
if (eventMsg.data.type && (!eventMsg.data.id||eventMsg.data.id=="uploadpanel")){
|
|
if (eventMsg.data.type=="upload"){
|
|
const line = eventMsg.data.content
|
|
if (line.status=="success"){
|
|
const resultPanel = document.getElementById("output");
|
|
resultPanel.innerHTML = resultPanel.innerHTML + "<br>" + line.initiator.filename + " is uploaded<br><hr />";
|
|
}
|
|
if (line.status=="error"){
|
|
//TBD
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function uploadFile(){
|
|
const files = document.getElementById("uploadBtn").files
|
|
if (files.length>0){
|
|
const reader = new FileReader();
|
|
reader.onload = function (e) {
|
|
sendMessage({type:'upload', target:"webui", id:'uploadpanel', url:"files", content:e.target.result,size:e.target.result.byteLength, path:"/", filename:files[0].name});
|
|
document.getElementById("uploadBtn").value="";
|
|
}
|
|
reader.readAsArrayBuffer(files[0]);
|
|
}
|
|
};
|
|
|
|
window.onload = (event) => {
|
|
window.addEventListener("message", processMessage, false);
|
|
};
|
|
|
|
</script>
|
|
|
|
<div class="container">
|
|
<button class="btn m-1" onclick="document.getElementById('uploadBtn').click();">Upload</button>
|
|
<input type="file" class="d-none" id="uploadBtn" onChange="uploadFile()" />
|
|
<div class="container m-2" id="output">
|
|
</div>
|
|
</div>
|
|
|