Moved all legacy code to the TOF
This commit is contained in:
parent
cfc60ebd1d
commit
e28c88c233
129
libs/bluecore.js
129
libs/bluecore.js
@ -1,54 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
/////////////////////// BlueCore 1.8.3 \\\\\\\\\\\\\\\\\\\\\\\\\\
|
/////////////////////// 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
|
/// 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.
|
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;
|
ID = "string" == typeof ID ? ID.replace(/ /g,"_") : ID;
|
||||||
@ -82,24 +34,7 @@ function titledContainer (ParentID,ID,Class,Element,Position,Title) {
|
|||||||
outer.innerHTML = '<p class="title">'+Title+'</p>';
|
outer.innerHTML = '<p class="title">'+Title+'</p>';
|
||||||
return elementPlace("#outer_"+ID,ID,Class,Element);
|
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) {
|
function buttonAdd (ParentID,ID,Label,Action,Class,Element) {
|
||||||
if ( "undefined" == typeof Class ) { Class = ""; }
|
if ( "undefined" == typeof Class ) { Class = ""; }
|
||||||
if ( "undefined" == typeof Element) { Element = "div"; }
|
if ( "undefined" == typeof Element) { Element = "div"; }
|
||||||
@ -152,3 +87,67 @@ function popupDialog (ID, title, closeable, contentGen, genArgs, callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// end of legacy
|
/// 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];
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user