diff --git a/libs/bluecore.js b/libs/bluecore.js index 3eb1f1d..a372293 100644 --- a/libs/bluecore.js +++ b/libs/bluecore.js @@ -1,54 +1,6 @@ "use strict"; /////////////////////// BlueCore 1.8.3 \\\\\\\\\\\\\\\\\\\\\\\\\\ -function getData(url,dothis,tothis,type,body) { - var DataRequest = new XMLHttpRequest(); - if (undefined == type) { type = "GET"; } - if (undefined == body) { body = ""; } - DataRequest.open(type, url, true); - DataRequest.onreadystatechange = function () { - if ( (DataRequest.readyState === XMLHttpRequest.DONE) && (DataRequest.status === 200) ) { - dothis(DataRequest.responseText,tothis); - } - }; - DataRequest.send(body); -} - -function isEmpty(object) { -console.log(object); -console.log(typeof object); - if ( "object" == typeof object ) { - for ( var propery in object ) { - return false; - } - return true; - } else { - return false; - } -} - -function addJavascript(string,action) { - try { - window.eval(string); - if ("function" == typeof action) { action(); } - } - catch (e) { console.log("Error with external script: "+e); } -} - -function getJavascript(url,action) { - getData(url,addJavascript,action); -} - -function addHTMLfrag(string,target) { - target.innerHTML = string; -} - -function getHTMLfrag(url,targetNode) { - var target = document.querySelector(targetNode); - target.innerHTML = "Loading..."; - getData(url,addHTMLfrag,target); -} - /// Legacy functions for backwards compatibility, no reason for this abstraction function elementMake (ID,Class,element) { //new and improved, I can use more than just divs for things now. ID = "string" == typeof ID ? ID.replace(/ /g,"_") : ID; @@ -82,24 +34,7 @@ function titledContainer (ParentID,ID,Class,Element,Position,Title) { outer.innerHTML = '

'+Title+'

'; return elementPlace("#outer_"+ID,ID,Class,Element); } -/// end of legacy -function numberShorten (value=0, accuricy=3, factor=1000, notationArray=["","k","M","B","T","q","Q","s","S","O","N","d","Ud","Dd","Td","qd","Qd","sd","Sd","Od","Nd","v","Uv","Dv","Tv","qv","Qv","sv","Sv","Ov","Nv","t","Ut","Dt","Tt","qt","Qt","st","St","Ot","Nv","c","uc","dc","Tc","Dc","Uc","vc","Sc","Oc","Nc","STOP"]) { - value = !isNaN(value) ? value : 0; - factor = !isNaN(factor) ? factor : 1000; - accuricy = !isNaN(accuricy) ? accuricy : 3; - if (value < factor) { return value.toPrecision(acc); } - var mag = 0; - while (value > factor) { - value /= factor; - mag++; - } - notationArray = Array.isArray(notationArray) ? notationArray : [""]; - if (mag > notationArray.length) { return (Math.pow(factor,mag)*value).toExponential(accuricy); } - return value.toPrecision(accuricy)+notationArray[mag]; -} - -/// more legacy functions that are being kept purely for backwards compatability function buttonAdd (ParentID,ID,Label,Action,Class,Element) { if ( "undefined" == typeof Class ) { Class = ""; } if ( "undefined" == typeof Element) { Element = "div"; } @@ -152,3 +87,67 @@ function popupDialog (ID, title, closeable, contentGen, genArgs, callback) { } } /// end of legacy + +function getData(url,dothis,tothis,type,body) { + var DataRequest = new XMLHttpRequest(); + if (undefined == type) { type = "GET"; } + if (undefined == body) { body = ""; } + DataRequest.open(type, url, true); + DataRequest.onreadystatechange = function () { + if ( (DataRequest.readyState === XMLHttpRequest.DONE) && (DataRequest.status === 200) ) { + dothis(DataRequest.responseText,tothis); + } + }; + DataRequest.send(body); +} + +function isEmpty(object) { +console.log(object); +console.log(typeof object); + if ( "object" == typeof object ) { + for ( var propery in object ) { + return false; + } + return true; + } else { + return false; + } +} + +function addJavascript(string,action) { + try { + window.eval(string); + if ("function" == typeof action) { action(); } + } + catch (e) { console.log("Error with external script: "+e); } +} + +function getJavascript(url,action) { + getData(url,addJavascript,action); +} + +function addHTMLfrag(string,target) { + target.innerHTML = string; +} + +function getHTMLfrag(url,targetNode) { + var target = document.querySelector(targetNode); + target.innerHTML = "Loading..."; + getData(url,addHTMLfrag,target); +} + +function numberShorten (value=0, accuricy=3, factor=1000, notationArray=["","k","M","B","T","q","Q","s","S","O","N","d","Ud","Dd","Td","qd","Qd","sd","Sd","Od","Nd","v","Uv","Dv","Tv","qv","Qv","sv","Sv","Ov","Nv","t","Ut","Dt","Tt","qt","Qt","st","St","Ot","Nv","c","uc","dc","Tc","Dc","Uc","vc","Sc","Oc","Nc","STOP"]) { + value = !isNaN(value) ? value : 0; + factor = !isNaN(factor) ? factor : 1000; + accuricy = !isNaN(accuricy) ? accuricy : 3; + if (value < factor) { return value.toPrecision(acc); } + var mag = 0; + while (value > factor) { + value /= factor; + mag++; + } + notationArray = Array.isArray(notationArray) ? notationArray : [""]; + if (mag > notationArray.length) { return (Math.pow(factor,mag)*value).toExponential(accuricy); } + return value.toPrecision(accuricy)+notationArray[mag]; +} +