basic-ui-js
Version:
A lightweight JavaScript library for building web-based applications with simple code. No need to write HTML or CSS — just use basic JavaScript.
1 lines • 29.7 kB
JavaScript
!function(){"use strict";const t={};window.basic=t,t.startTime=Date.now(),t.ACTION_COLOR="#689BD2",t.ACTION2_COLOR="cadetblue",t.WARNING_COLOR="tomato",t.ALERT_COLOR="gold",t.CANCEL_COLOR="lightgray",t.TEXT_COLOR="rgba(0, 0, 0, 0.8)",t.BACKGROUND_COLOR="whitesmoke",t.DARK_BACKGROUND_COLOR="#141414",t.FONT_SIZE=20,t.BUTTON_WIDTH=130,t.BUTTON_HEIGHT=50,t.BUTTON_COLOR=t.ACTION_COLOR,t.BUTTON_TEXT_COLOR="rgba(0, 0, 0, 0.65)",t.TEXTBOX_WIDTH=270,t.TEXTBOX_HEIGHT=50,t.gunler=["Pazar","Pazartesi","Salı","Çarşamba","Perşembe","Cuma","Cumartesi"],t.days=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],t.aylar=["Ocak","Şubat","Mart","Nisan","Mayıs","Haziran","Temmuz","Ağustos","Eylül","Ekim","Kasım","Aralık"],t.months=["January","February","March","April","May","June","July","August","September","October","November","December"],window.that=null,window.previousThat=null,window.prevThat=null;let e,n,i=null;const o={objectAndFunctionList:[]},s={WITH_MOTION_TIME:50,DONT_MOTION_TIME:40};t.start=function(){window.page=new l,page.containerBox=null,setDefaultContainerBox(page),page.bodyElement.style.margin="0px",page.bodyElement.style.overflow="hidden",page.mainBox=createBox(0,0,page.width,page.height),page.mainBox.containerBox=null,that.element.style.position="fixed",that.color="transparent",page.onResize((function(){"function"==typeof page.refreshSize&&page.refreshSize()})),"function"==typeof start&&(start(),t.afterStart()),"function"==typeof loop&&(n||setLoopTimer(1e3))},t.afterStart=function(){},window.println=function(t,e="log"){console[e](t)},window.random=function(t,e){let n=0;return null!=e?e<t?println("basic.js: random(): The second parameter (number) must be greater than the first.","error"):n=t+Math.round(Math.random()*(e-t)):println("basic.js: random(): Two parameters (numbers) must be sent.","error"),n},window.num=function(t,e="float"){if("float"==e){const e=parseFloat(t);return Math.round(100*e)/100}if("integer"==e||"int"==e)return parseInt(t)},window.str=function(t){return String(t)},window.isMobile=function(){let t=0,e=navigator.userAgent||navigator.vendor||window.opera;return(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4)))&&(t=1),t},window.go=function(t,e="_self"){return window.open(t,e)},window.twoDigitFormat=function(t){return t<=9&&(t="0"+t),t},window.storage={save(t,e){window.localStorage.setItem(t,JSON.stringify(e))},load:t=>JSON.parse(window.localStorage.getItem(t)),remove(t){window.localStorage.removeItem(t)}},window.clock={get hour(){return(new Date).getHours()},get minute(){return(new Date).getMinutes()},get second(){return(new Date).getSeconds()},get milisecond(){return(new Date).getMilliseconds()}},window.date={get year(){return(new Date).getFullYear()},get monthNumber(){let t=(new Date).getMonth();return t++,t},get ayAdi(){return t.aylar[this.monthNumber-1]},get monthName(){return t.months[this.monthNumber-1]},get dayNumber(){return(new Date).getDay()},get gunAdi(){return t.gunler[this.dayNumber]},get dayName(){return t.days[this.dayNumber]},get today(){return(new Date).getDate()},get now(){return Date.now()}};class r{constructor(t){this._type=t,this._visible=1,this._displayType="block",this._opacity=1,this._rotate=0,this._padding=0,this._motionString="none",this._clickable=0,this._eventFuncList=[]}get parentBox(){return this._containerBox}set parentBox(t){this._containerBox=t}get containerBox(){return this._containerBox}set containerBox(t){this._containerBox=t}get left(){return"absolute"==this.position?parseFloat(this.contElement.style.left):this.contElement.offsetLeft}set left(t){this.contElement.style.right="",this.contElement.style.left=parseFloat(t)+"px"}get top(){return"absolute"==this.position?parseFloat(this.contElement.style.top):this.contElement.offsetTop}set top(t){this.contElement.style.bottom="",this.contElement.style.top=parseFloat(t)+"px"}get right(){return parseFloat(this.contElement.style.right)}set right(t){this.contElement.style.left="",this.contElement.style.right=parseFloat(t)+"px"}get bottom(){return parseFloat(this.contElement.style.bottom)}set bottom(t){this.contElement.style.top="",this.contElement.style.bottom=parseFloat(t)+"px"}get totalLeft(){return d(this.contElement,"Left")}get totalTop(){return d(this.contElement,"Top")}get width(){return"string"!=typeof this._width?this._width||0:this.contElement.offsetWidth}set width(t){this._width=t,this.contElement.style.width="string"!=typeof t?parseFloat(t)+"px":t}get height(){return"string"!=typeof this._height?this._height||0:this.contElement.offsetHeight}set height(t){this._height=t,this.contElement.style.height="string"!=typeof t?parseFloat(t)+"px":t}get rotate(){return this._rotate}set rotate(t){this._rotate=parseInt(t),this.contElement.style.transform="rotate("+t+"deg)"}get visible(){return this._visible}set visible(t){this._visible=t,this.contElement.style.display&&"none"!=this.contElement.style.display&&(this._displayType=this.contElement.style.display),this.contElement.style.display=1==t?this._displayType:"none"}get clickable(){return this._clickable}set clickable(t){this._clickable=t,this.contElement.style.pointerEvents=1==t?"auto":"none"}get opacity(){return this._opacity}set opacity(t){this._opacity=t,this.contElement.style.opacity=t}get color(){return this._backgroundColor}set color(t){this._backgroundColor=t,this.contElement.style.backgroundColor=t}get padding(){return this._padding||0}set padding(t){let e,n,i,o;if(this._padding=t,"number"==typeof t)e=n=i=o=t;else if(Array.isArray(t)){const s=t.length;1===s?e=n=i=o=t[0]:2===s||3===s?(e=n=t[0],i=o=t[1]):4===s&&(e=t[0],i=t[1],n=t[2],o=t[3])}this.contElement.style.paddingLeft=e+"px",this.contElement.style.paddingTop=i+"px",this.contElement.style.paddingRight=n+"px",this.contElement.style.paddingBottom=o+"px"}get border(){return this._border}set border(t){this._border=t,this.contElement.style.borderWidth=t+"px"}get borderColor(){return this._borderColor}set borderColor(t){this._borderColor=t,this.contElement.style.borderColor=t}get round(){return this._round}set round(t){this._round=t,this.contElement.style.borderRadius=t+"px"}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize=t,this.element.style.fontSize=t+"px"}get textSize(){return this._fontSize}set textSize(t){this._fontSize=t,this.element.style.fontSize=t+"px"}get textColor(){return this._textColor}set textColor(t){this._textColor=t,this.element.style.color=t}get textAlign(){return this._textAlign}set textAlign(t){this._textAlign=t,this.element.style.textAlign=t}get position(){return this.contElement.style.position?this.contElement.style.position:"absolute"}set position(t){this.contElement.style.position=t,"relative"==t&&(this.left=0,this.top=0)}center(t){g(this,t)}centerBy(t,e){b(this,t,e)}aline(t,e,n=0,i){f(this,t,e,n,i)}remove(){this.contElement.remove()}props(t,e,n){p(this,t,e,n)}_addEventListener(t,e,n){let i=this;const o=function(t){e(i,t)};n.addEventListener(t,o);const s={};s.eventName=t,s.originalFunc=e,s.func=o,s.element=n,this._eventFuncList.push(s)}_removeEventListener(t,e,n){let i=null;for(let t=0;t<this._eventFuncList.length;t++)if(this._eventFuncList[t].originalFunc==e){i=this._eventFuncList[t].func,this._eventFuncList.splice(t,1);break}i&&n.removeEventListener(t,i)}on(t,e,n=!1){const i="textbox"==this._type?this.inputElement:this.elem;return this.clickable=1,i.addEventListener(t,e,n),function(){i.removeEventListener(t,e)}}off(t,e){("textbox"==this._type?this.inputElement:this.elem).removeEventListener(t,e)}onResize(t){o.onResize(this,t)}remove_onResize(t){o.remove_onResize(this.element,t)}setMotion(t){const e=this;this._setMotionTimeout&&clearTimeout(this._setMotionTimeout),this._setMotionTimeout=setTimeout((function(){e.setMotionNow(t)}),s.DONT_MOTION_TIME)}getMotion(){return this._motionString}setMotionNow(t){this._motionString=t,this.contElement.style.transition=t}withMotion(t){const e=this;this._withMotionTimeout&&clearTimeout(this._withMotionTimeout),this._withMotionTimeout=setTimeout((function(){e.canMotionNow(),t(e)}),s.WITH_MOTION_TIME)}dontMotion(){this.contElement.style.transition="none";const t=this;this._dontMotionTimeout&&clearTimeout(this._dontMotionTimeout),this._dontMotionTimeout=setTimeout((function(){t.contElement.style.transition=t._motionString}),s.DONT_MOTION_TIME)}canMotionNow(){this.contElement.style.transition=this._motionString}}class l{constructor(){this._bodyElement=document.getElementsByTagName("BODY")[0],this._element=this._bodyElement,this._backgroundColor="white",this._zoom=1}get elem(){return this._element}get element(){return this._element}get contElement(){return this._element}get bodyElement(){return this._bodyElement}get mainBox(){return this._box}set mainBox(t){this._box=t,this._element=this._box.element}get width(){let t;return t=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,withPageZoom(t)}get height(){let t;return t=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,withPageZoom(t)}get html(){return this._box.element.innerHTML}set html(t){this._box.element.innerHTML=t}get zoom(){return this._zoom}set zoom(t){this._zoom=t,this.bodyElement.style.transformOrigin="top left",this.bodyElement.style.transform="scale("+t+")",page.refreshSize()}get color(){return this._backgroundColor}set color(t){this._backgroundColor=t,this.bodyElement.style.backgroundColor=t}fit(t=document.body.clientWidth,e){page.zoom=1;let n=page.width;e=e||t,page.zoom=n>e?e/t:n/t}autoFit(t,e){page.zoom=1;const n=t/e;let i=0;i=page.width/page.height<=n?page.width:page.height*n,page.fit(t,i)}refreshSize(){page.mainBox.width=page.width,page.mainBox.height=page.height}onClick(t){this._box._addEventListener("click",t,window)}remove_onClick(t){this._box._removeEventListener("click",t,window)}onResize(t){this._box._addEventListener("resize",t,window)}remove_onResize(t){this._box._removeEventListener("resize",t,window)}add(t){t.containerBox!=this&&(t.containerBox=this,this.element.appendChild(t.contElement))}}class a extends r{constructor(t=-1e3,e=-1e3,n=100,o=100){super("box"),this._backgroundColor="whitesmoke",this._border=0,this._borderColor="rgba(0, 0, 0, 0.6)",this._round=0,this._fontSize=16,this._textColor="rgba(0, 0, 0, 0.8)",this._textAlign="left",this._clipContent=1;const s=document.createElement("DIV");s.classList.add("basic_box"),s.style.left=t+"px",s.style.top=e+"px",this._element=s,this._containerBox=i,null!=i?i.element.appendChild(this._element):println("basic.js: The library is not yet ready for use. Put your code in window.onload","error"),this.width=n,this.height=o,"flex"==i.element.style.display&&(this.position="relative"),makeBasicObject(this)}get elem(){return this._element}get element(){return this._element}get contElement(){return this._element}get text(){return this.element.innerHTML}set text(t){this.element.innerHTML=t}get html(){return this.element.innerHTML}set html(t){this.element.innerHTML=t}get clipContent(){return this._clipContent}set clipContent(t){this._clipContent=t,t?(this.contElement.style.overflowX="hidden",this.contElement.style.overflowY="hidden"):(this.contElement.style.overflowX="visible",this.contElement.style.overflowY="visible")}get scrollX(){return"auto"==this.contElement.style.overflowX?1:0}get scrollY(){return"auto"==this.contElement.style.overflowY?1:0}set scrollX(t){this.contElement.style.overflowX="hidden",1==t&&(this.clickable=1,this.contElement.style.overflowX="auto")}set scrollY(t){this.contElement.style.overflowY="hidden",1==t&&(this.clickable=1,this.contElement.style.overflowY="auto")}onClick(t){this.clickable=1,this._addEventListener("click",t,this.contElement)}remove_onClick(t){this._removeEventListener("click",t,this.contElement)}add(t){t.containerBox=this,this.element.appendChild(t.contElement)}in(t){const e=getDefaultContainerBox();setDefaultContainerBox(this),t(this),setDefaultContainerBox(e)}}window.createBox=function(t,e,n,i){return new a(t,e,n,i)};class h extends r{constructor(e=-1e3,n=-1e3,o=t.BUTTON_WIDTH,s=t.BUTTON_HEIGHT){super("button"),this._backgroundColor=t.BUTTON_COLOR,this._border=1,this._borderColor="rgba(0, 0, 0, 0.40)",this._round=4,this._fontSize=20,this._textColor=t.BUTTON_TEXT_COLOR,this._textAlign="center",this._clickable=1;const r=document.createElement("BUTTON");r.innerHTML="Button",r.classList.add("basic_button"),r.setAttribute("type","button"),r.style.left=e+"px",r.style.top=n+"px",this._element=r,this._containerBox=i,i.element.appendChild(this._element),this.width=o,this.height=s,"flex"==i.element.style.display&&(this.position="relative"),makeBasicObject(this)}get elem(){return this._element}get element(){return this._element}get contElement(){return this._element}get buttonElement(){return this._element}get text(){return this.buttonElement.innerHTML}set text(t){this.buttonElement.innerHTML=t}get value(){return this.buttonElement.value}set value(t){this.buttonElement.value=t}get enabled(){return this.buttonElement.disabled?0:1}set enabled(t){this.buttonElement.disabled=t?0:1}get minimal(){return this.buttonElement.classList.contains("minimal")?1:0}set minimal(t){t?this.buttonElement.classList.add("minimal"):this.buttonElement.classList.remove("minimal")}get spaceX(){return parseInt(this.contElement.style.paddingLeft)||0}set spaceX(t){this.contElement.style.paddingLeft=t+"px",this.contElement.style.paddingRight=t+"px"}onClick(t){this.clickable=1,this._addEventListener("click",t,this.buttonElement)}remove_onClick(t){this._removeEventListener("click",t,this.buttonElement)}add(t){println("basic.js: add(): Insertion cannot be made inside the Button object.","error")}}window.createButton=function(t,e,n,i){return new h(t,e,n,i)};class c extends r{constructor(e=-1e3,n=-1e3,o=t.TEXTBOX_WIDTH,s=t.TEXTBOX_HEIGHT){super("textbox"),this._backgroundColor="white",this._border=1,this._borderColor="#4A4A4A",this._round=4,this._fontSize=20,this._textColor="#4A4A4A",this._textAlign="left",this._clickable=1;const r=document.createElement("DIV");r.classList.add("basic_textbox-main"),this._mainElement=r;const l=document.createElement("DIV");l.classList.add("basic_textbox-title"),l.innerHTML="",this._titleElement=l;const a=document.createElement("INPUT");a.value="",a.classList.add("basic_textbox"),a.setAttribute("type","text"),a.style.width="100%",a.style.height="100%",this._element=a,r.style.left=e+"px",r.style.top=n+"px",r.appendChild(this._titleElement),r.appendChild(this._element),this._containerBox=i,i.element.appendChild(this._mainElement),this.width=o,this.height=s,"flex"==i.element.style.display&&(this.position="relative"),makeBasicObject(this)}get elem(){return this._mainElement}get element(){return this._mainElement}get inputElement(){return this._element}get contElement(){return this._mainElement}get titleElement(){return this._titleElement}get text(){return this.inputElement.value}set text(t){this.inputElement.value=t.toString()}get color(){return super.color}set color(t){this._backgroundColor=t,this.inputElement.style.backgroundColor=t}get title(){return this.titleElement.innerHTML}set title(t){this.titleElement.innerHTML=t}get enabled(){return this.inputElement.disabled?0:1}set enabled(t){this.inputElement.disabled=t?0:1}set border(t){this._border=t,this.inputElement.style.borderWidth=t+"px"}get border(){return super.border}get borderColor(){return super.borderColor}set borderColor(t){this._borderColor=t,this.inputElement.style.borderColor=t}set round(t){this._round=t,this.inputElement.style.borderRadius=t+"px"}get round(){return super.round}get clickable(){return super.clickable}set clickable(t){this._clickable=t,this.inputElement.style.pointerEvents=1==t?"auto":"none"}get fontSize(){return super.fontSize}set fontSize(t){this._fontSize=t,this.inputElement.style.fontSize=t+"px"}get textSize(){return super.textSize}set textSize(t){this._fontSize=t,this.inputElement.style.fontSize=t+"px"}get textColor(){return super.textColor}set textColor(t){this._textColor=t,this.inputElement.style.color=t}get textAlign(){return super.textAlign}set textAlign(t){this._textAlign=t,this.inputElement.style.textAlign=t}get minimal(){return this.inputElement.classList.contains("minimal")?1:0}set minimal(t){t?this.inputElement.classList.add("minimal"):this.inputElement.classList.remove("minimal")}onChange(t){this._addEventListener("input",t,this.inputElement)}remove_onChange(t){this._removeEventListener("input",t,this.inputElement)}add(t){println("basic.js: add(): Insertion cannot be made inside the TextBox object.","error")}}window.createTextBox=function(t,e,n,i){return new c(t,e,n,i)},window.createInput=function(t,e,n,i){return new c(t,e,n,i)};class m extends r{constructor(t=-1e3,e=-1e3,n="auto",o="auto"){super("label"),this._backgroundColor="transparent",this._border=0,this._borderColor="rgba(0, 0, 0, 0.6)",this._round=0,this._fontSize=20,this._textColor="rgba(0, 0, 0, 0.8)",this._textAlign="left";const s=document.createElement("DIV");s.classList.add("basic_label"),s.style.left=t+"px",s.style.top=e+"px",this._element=s,this._containerBox=i,i.element.appendChild(this._element),this.width=n,this.height=o,"flex"==i.element.style.display&&(this.position="relative"),makeBasicObject(this)}get elem(){return this._element}get element(){return this._element}get contElement(){return this._element}get text(){return this.element.innerHTML}set text(t){this.element.innerHTML=t}get space(){return parseInt(this.contElement.style.padding)||0}set space(t){this.contElement.style.padding=t+"px"}get spaceX(){return parseInt(this.contElement.style.paddingLeft)||0}set spaceX(t){this.contElement.style.paddingLeft=t+"px",this.contElement.style.paddingRight=t+"px"}get spaceY(){return parseInt(this.contElement.style.paddingTop)||0}set spaceY(t){this.contElement.style.paddingTop=t+"px",this.contElement.style.paddingBottom=t+"px"}onClick(t){this.clickable=1,this._addEventListener("click",t,this.contElement)}remove_onClick(t){this._removeEventListener("click",t,this.contElement)}add(t){println("basic.js: add(): Insertion cannot be made inside the Label object.","error")}}window.createLabel=function(t,e,n,i){return new m(t,e,n,i)};class u extends r{constructor(t=-1e3,e=-1e3,n=0,o=0){super("image"),this._autoSize=1,this._space=0,this._backgroundColor="transparent",this._border=0,this._borderColor="rgba(0, 0, 0, 0.6)",this._round=0;const s=document.createElement("IMG");s.classList.add("basic_image"),s.style.left=t+"px",s.style.top=e+"px",this._element=s,this._containerBox=i,i.element.appendChild(this._element),super.width=n,super.height=o;const r=this;(n||o)&&(this.autoSize=0),s.addEventListener("load",(function(){if(r.autoSize>0){const t=r.autoSize;r.width=parseInt(r.naturalWidth/t)+"px",r.height=parseInt(r.naturalHeight/t)+"px"}})),"flex"==i.element.style.display&&(this.position="relative"),makeBasicObject(this)}get elem(){return this._element}get element(){return this._element}get imageElement(){return this._element}get contElement(){return this._element}get width(){return super.width}set width(t){this.autoSize=0,super.width=t}get height(){return super.height}set height(t){this.autoSize=0,super.height=t}get naturalWidth(){return this.imageElement.naturalWidth}get naturalHeight(){return this.imageElement.naturalHeight}get autoSize(){return this._autoSize}set autoSize(t){this._autoSize=t}get space(){return this._space}set space(t){t>50&&(t=50),t<0&&(t=0),this._space=t;const e=parseInt(this.width/100*t),n=parseInt(this.height/100*t);this.contElement.style.paddingLeft=e+"px",this.contElement.style.paddingRight=e+"px",this.contElement.style.paddingTop=n+"px",this.contElement.style.paddingBottom=n+"px"}onClick(t){this.clickable=1,this._addEventListener("click",t,this.contElement)}remove_onClick(t){this._removeEventListener("click",t,this.contElement)}onLoad(t){this._addEventListener("load",t,this.imageElement)}remove_onLoad(t){this._removeEventListener("load",t,this.imageElement)}load(t){this.imageElement.setAttribute("src",t),this.imageElement.setAttribute("alt",t)}add(t){println("basic.js: add(): Insertion cannot be made inside the Image object.","error")}}window.createImage=function(t,e,n,i){return new u(t,e,n,i)},window.createIcon=function(t,e,n,i){return new u(t,e,n,i)};const d=function(t,e){let n=0,i=t;for(;i.offsetParent;)n+=i["offset"+e],i=i.offsetParent;return n},p=function(t,e=[],n=[],i=[]){let o={};for(let t in e)o[t]=e[t];for(let t in n)o[t]=n[t];for(let t in i)o[t]=i[t];for(let e in o)t[e]=o[e]},g=function(t,e){if("left"==e||!e){const e=t.containerBox.width-2*(t.containerBox.border||0);t.left=parseInt((e-t.width)/2)}if("top"==e||!e){const e=t.containerBox.height-2*(t.containerBox.border||0);t.top=parseInt((e-t.height)/2)}},b=function(t,e,n){if("left"==n||!n){const i=e.width;t.left=parseInt((i-t.width)/2)+e.left,n&&(t.top=e.top)}if("top"==n||!n){const i=e.height;t.top=parseInt((i-t.height)/2)+e.top,n&&(t.left=e.left)}},f=function(t,e,n,i,o){if("left"==n?(isNaN(e.left)?isNaN(e.right)||(t.right=parseInt(e.right+e.width+i)):t.left=parseInt(e.left-t.width-i),isNaN(e.top)?t.bottom=parseInt(e.bottom):t.top=parseInt(e.top)):"top"==n?(isNaN(e.top)?isNaN(e.bottom)||(t.bottom=parseInt(e.bottom+e.height+i)):t.top=parseInt(e.top-t.height-i),isNaN(e.left)?t.right=parseInt(e.right):t.left=parseInt(e.left)):"right"==n?(isNaN(e.left)?isNaN(e.right)||(t.right=parseInt(e.right-t.width-i)):t.left=parseInt(e.left+e.width+i),isNaN(e.top)?t.bottom=parseInt(e.bottom):t.top=parseInt(e.top)):"bottom"==n?(isNaN(e.top)?isNaN(e.bottom)||(t.bottom=parseInt(e.bottom-t.height-i)):t.top=parseInt(e.top+e.height+i),isNaN(e.left)?t.right=parseInt(e.right):t.left=parseInt(e.left)):(isNaN(e.top)?isNaN(e.bottom)||(t.bottom=parseInt(e.bottom)):t.top=parseInt(e.top),isNaN(e.left)?isNaN(e.right)||(t.right=parseInt(e.right)):t.left=parseInt(e.left)),"left"==n||"right"==n){const n=e.height-t.height;switch(o){case"top":isNaN(e.top)&&(isNaN(e.bottom)||(t.bottom+=parseInt(n)));break;case"bottom":isNaN(e.top)?isNaN(e.bottom):t.top+=parseInt(n);break;case"center":isNaN(e.top)?isNaN(e.bottom)||(t.bottom+=parseInt(n/2)):t.top+=parseInt(n/2);break}}else if("top"==n||"bottom"==n){const n=e.width-t.width;switch(o){case"left":isNaN(e.left)&&(isNaN(e.right)||(t.right=parseInt(e.right+n)));break;case"right":isNaN(e.left)?isNaN(e.right):t.left+=parseInt(n);break;case"center":isNaN(e.left)?isNaN(e.right)||(t.right+=parseInt(n/2)):t.left+=parseInt(n/2);break}}};window.withPageZoom=function(t){return parseFloat(t*(1/page.zoom))},window.setLoopTimer=function(t){"function"==typeof loop&&(n&&(n=clearInterval(n)),0==t||(n=setInterval(loop,t)))},window.setDefaultContainerBox=function(t){e=i||page,i=t},window.restoreDefaultContainerBox=function(){i=e||page},window.getDefaultContainerBox=function(){return i},window.makeBasicObject=function(t){previousThat=that,prevThat=previousThat,that=t},o.onResize=function(t,e){const n={};n.obj=t,n.elem=t.element,n.func=e,o.objectAndFunctionList.push(n),o.whenDetected.observe(t.element)},o.remove_onResize=function(t,e){for(let n=o.objectAndFunctionList.length-1;n>=0;n--)o.objectAndFunctionList[n].elem==t&&o.objectAndFunctionList[n].func==e&&o.objectAndFunctionList.splice(n,1);o.whenDetected.unobserve(t)},o.whenDetected=new ResizeObserver((function(t){const e=o;for(let n=0;n<t.length;n++)for(let i=0;i<e.objectAndFunctionList.length;i++)t[n].target==e.objectAndFunctionList[i].elem&&e.objectAndFunctionList[i].func(e.objectAndFunctionList[i].obj)}));let _=[],w=null;const y=function(){w&&clearTimeout(w),w=setTimeout((function(){const t=_.length-1;t>0&&println("basic.js: Some started boxes were not ended. Count: "+t,"warn")}),100)};window.startFlexBox=function(t={},e,n,i,o){let s={},r=null;"object"==typeof t?(r=createBox(0,0,"100%","100%"),s=t):"object"==typeof e?(r=createBox(t,0,"100%","100%"),s=e):"object"==typeof n?(r=createBox(t,e,"100%","100%"),s=n):"object"==typeof i?(r=createBox(t,e,n,"100%"),s=i):"object"==typeof o?(r=createBox(t,e,n,i),s=o):r=createBox(t,e,n,i);const l={flexDirection:"row",flexWrap:"nowrap",alignContent:"center",justifyContent:"center",alignItems:"center",gap:"0px",flexBasis:"auto",flexGrow:0,flexShrink:0};s.align&&(s.flow||(s.flow="horizontal"));const a=function(t){let e=l.flexDirection;switch(t){case"horizontal":e="row";break;case"vertical":e="column";break}return e};s.flow&&(r._flow=s.flow,s.flexDirection=a(s.flow));const h=function(t="center"){let e="center",n="center",i="center";switch(t){case"top left":case"left top":e="center",n="flex-start",i="flex-start";break;case"top center":case"center top":e="center",n="center",i="flex-start";break;case"top right":case"right top":e="center",n="flex-end",i="flex-start";break;case"center left":case"left center":e="center",n="flex-start",i="center";break;case"center":case"center center":e="center",n="center",i="center";break;case"center right":case"right center":e="center",n="flex-end",i="center";break;case"bottom left":case"left bottom":e="center",n="flex-start",i="flex-end";break;case"bottom center":case"center bottom":e="center",n="center",i="flex-end";break;case"bottom right":case"right bottom":e="center",n="flex-end",i="flex-end";break}return[e,n,i]};if(s.align){r._align=s.align;const t=h(s.align);s.alignContent=t[0],"row"==s.flexDirection?(s.justifyContent=t[1],s.alignItems=t[2]):(s.justifyContent=t[2],s.alignItems=t[1])}const c=function(t){return Number.isInteger(t)?t+="px":t};Number.isInteger(s.gap)&&(s.gap=c(s.gap)),that.element.style.display="flex",r.props({color:"transparent"},l,s);for(let t in l)r.element.style[t]=r[t];return Object.defineProperty(r,"flow",{get:function(){return this._flow},set:function(t){this._flow=t,this.elem.style.flexDirection=a(t),this.align=this.align}}),Object.defineProperty(r,"align",{get:function(){return this._align},set:function(t){this._align=t;const e=h(t);this.elem.style.alignContent=e[0],"row"==r.elem.style.flexDirection?(this.elem.style.justifyContent=e[1],this.elem.style.alignItems=e[2]):(this.elem.style.justifyContent=e[2],this.elem.style.alignItems=e[1])}}),r.gap&&(r._gap=r.gap),Object.defineProperty(r,"gap",{get:function(){return this._gap},set:function(t){this._gap=c(t),this.elem.style.gap=this._gap}}),0==_.length&&_.push(getDefaultContainerBox()),setDefaultContainerBox(r),_.push(r),y(),r},window.AutoLayout=window.startFlexBox,window.startBox=function(...t){const e=Box(...t);return 0==_.length&&_.push(getDefaultContainerBox()),setDefaultContainerBox(e),_.push(e),y(),e},window.endBox=function(){_.length>1&&_.pop(),setDefaultContainerBox(_[_.length-1]),1==_.length&&(_=[])},window.endFlexBox=window.endBox,window.endAutoLayout=window.endBox;let x=null,E=null;window.saveCurrentThat=function(){x=that,E=previousThat},window.restoreThatFromSaved=function(){that=x,previousThat=E,prevThat=previousThat},window.Label=function(...t){let e={};t.length&&"object"==typeof t[t.length-1]&&(e=t.pop());const n=createLabel(...t);return n.props(e),n},window.Input=function(...t){let e={};t.length&&"object"==typeof t[t.length-1]&&(e=t.pop());const n=createTextBox(...t);return n.props(e),n},window.Icon=function(...t){let e={};t.length&&"object"==typeof t[t.length-1]&&(e=t.pop());const n=createImage(...t);return n.props(e),n},window.Box=function(...t){let e={};t.length&&"object"==typeof t[t.length-1]&&(e=t.pop());const n=createBox(...t);return n.props(e),n},window.Button=function(...t){let e={};t.length&&"object"==typeof t[t.length-1]&&(e=t.pop());const n=createButton(...t);return n.props(e),n},window.startObject=function(t){return t&&println("basic.js: startObject(): Use .props(defaults, props) for giving parameters.","warn"),saveCurrentThat(),startBox({color:"transparent"})},window.endObject=function(t){return endBox(),restoreThatFromSaved(),makeBasicObject(t),t},window.addEventListener("load",(function(){t.start()}))}();