Added blueui for ui functions, this will replace legacy ui things in bluecore

This commit is contained in:
bluesaxman 2022-03-24 15:01:45 -06:00
parent e28c88c233
commit 176ff52041

36
libs/blueui.js Normal file
View File

@ -0,0 +1,36 @@
class buiProgressBar {
constructor (name) {
this.root = document.createElement("span");
this.lable = document.createElement("span");
this.progress = document.createElement("span");
this.progressFilled = document.createElement("span");
this.root.setAttribute("class","bui_progress_bar_root");
this.lable.setAttribute("class","bui_progress_bar_lable");
this.progress.setAttribute("class","bui_progress_bar_progress");
this.progressFilled.setAttribute("class","buo_progress_bar_progress_filled");
this.root.appendChild(this.progress);
this.progress.appendChild(this.progressFilled);
this.root.appendChild(this.lable);
this.name = "string" == typeof name ? name : "";
this.value = 0;
this.progress = 0;
}
function update (value,progress) {
this.value = !isNaN(value) ? value : 0;
this.progress = !isNaN(progress) ? Math.max(0,Math.min(1,progress)) : 0;
this.lable.innerText = this.name+": "+numberShorten(this.value,4);
this.progressFilled.style.width = (this.progress*100)+"%";
}
}
class buiButton {
constructor (name, myFunction) {
this.root = document.createElement("span");
this.lable = document.createElement("span");
this.root.setAttribute("class","bui_button_root");
this.lable.setAttribute("class","bui_button_lable");
this.root.appendChild(this.lable);
this.root.addEventListener("click", "function" == typeof myFunction ? myFunction : () => {});
}
}