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 : () => {}); + } +}