From 176ff520417f5e021575f2f945a4b9550f6ce9c2 Mon Sep 17 00:00:00 2001 From: bluesaxman Date: Thu, 24 Mar 2022 15:01:45 -0600 Subject: [PATCH] Added blueui for ui functions, this will replace legacy ui things in bluecore --- libs/blueui.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 libs/blueui.js diff --git a/libs/blueui.js b/libs/blueui.js new file mode 100644 index 0000000..bf0c62f --- /dev/null +++ b/libs/blueui.js @@ -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 : () => {}); + } +}