updated to current version 1.8.2

This commit is contained in:
bluesaxman 2019-04-20 10:30:10 -06:00
parent 0c32a0dcb1
commit 39592c856c

View File

@ -1,5 +1,5 @@
"use strict";
/////////////////////// BlueCore 1.7.2 \\\\\\\\\\\\\\\\\\\\\\\\\\
/////////////////////// BlueCore 1.8.2 \\\\\\\\\\\\\\\\\\\\\\\\\\
function getData(url,dothis,tothis,type,body) {
var DataRequest = new XMLHttpRequest();
@ -50,6 +50,7 @@ function getHTMLfrag(url,targetNode) {
}
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;
return (function (myElement) {
if ("string" == typeof ID) { myElement.id = ID; }
if ("string" == typeof Class) { myElement.className = Class; }
@ -58,6 +59,8 @@ function elementMake (ID,Class,element) { //new and improved, I can use more tha
}
function elementPlace (parentID, ID, Class, element, position) {
parentID = "string" == typeof parentID ? parentID.replace(/ /g,"_") : parentID;
ID = "string" == typeof ID ? ID.replace(/ /g,"_") : ID;
var newElement = elementMake(ID,Class,element);
if ( (typeof document.querySelector(parentID).append && typeof document.querySelector(parentID).prepend) !== "undefined") { // Are we compliant?
if ("before" == position) {
@ -76,6 +79,23 @@ function elementPlace (parentID, ID, Class, element, position) {
return newElement;
}
function titledContainer (ParentID,ID,Class,Element,Position,Title) {
var outer = elementPlace(ParentID,"outer_"+ID,"outer "+Class,"div",Position);
outer.innerHTML = '<p class="title">'+Title+'</p>';
return elementPlace("#outer_"+ID,ID,Class,Element);
}
function numberShorten (Value) {
var level = 0;
var number = Value;
var unit = ["","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"];
while (999<number) {
level++;
number = Math.round(number)/1000;
}
return number+unit[level];
}
function buttonAdd (ParentID,ID,Label,Action,Class,Element) {
if ( "undefined" == typeof Class ) { Class = ""; }
if ( "undefined" == typeof Element) { Element = "div"; }
@ -85,43 +105,39 @@ function buttonAdd (ParentID,ID,Label,Action,Class,Element) {
})(elementPlace(ParentID,ID,"button "+Class,Element));
}
function dialogControlsGen(parentDialog,DialogBack,type,returnVar) { //I need to refactor this, these if statments are too similar.
if ( "sub_window" == type ) {
var closeButton = elementPlace(parentDialog,"closeButton",null,"div"); //Also need to change this, to help standardize the look and feel of the UI
closeButton.innerHTML = "X";
closeButton.onclick = function () { document.getElementById("body").removeChild(DialogBack); }
//More controls will go here probably as I flesh out the sub window design
}
if ( "input" == type ) {
var inputArea = elementPlace(parentDialog,"listID","inputField","input",null);
var submitButton = buttonAdd(parentDialog,"SubmitButton","Submit",function () {
returnVar.value = inputArea.value;
document.getElementById("body").removeChild(DialogBack);
},"UI UIbutton");
}
if ( "input_password" == type ) {
var inputArea = elementPlace(parentDialog,"listID","inputField","input",null);
inputArea.type = "password";
var submitButton = buttonAdd(parentDialog,"SubmitButton","Submit",function () {
returnVar.value = inputArea.value;
document.getElementById("body").removeChild(DialogBack);
},"UI UIbutton");
}
if ( "info" == type ) {
var closeButton = elementPlace(parentDialog,"closeButton",null,"div");
closeButton.innerHTML = "Close";
closeButton.onclick = function () { document.getElementById("body").removeChild(DialogBack); }
}
if ( "end" == type ) {
var closeButton = elementPlace(parentDialog,"closeButton",null,"div");
closeButton.innerHTML = "Play Again";
closeButton.onclick = function () { document.getElementById("body").removeChild(DialogBack); gameInit(); }
}
function inputDialog (dialogRoot,container,args,callback) {
args = "object" == typeof args ? args : {"content":""};
args.content = "string" == typeof args.content ? args.content : "";
container.innerText += args.content;
var inputArea = elementPlace("#"+container.id,null,"formInput","input");
if ("string" == typeof args.inputType) { inputArea.type = args.inputType; }
buttonAdd("#"+container.id,null,"Submit",function () {
callback(inputArea.value);
dialogRoot.parentNode.removeChild(dialogRoot);
},"dialog_submit");
}
function dialogMessage (content,type,returnVar) {
var message = elementPlace("#body","app_message_back","app_Message_Back","div");
var dialog = elementPlace("#app_message_back","app_message","app_Message","div");
dialog.innerHTML = content;
dialogControlsGen("#app_message",message, type, returnVar);
function messageDialog (dialogRoot,container,args) {
args = "object" == typeof args ? args : {"content":""};
args.content = "string" == typeof args.content ? args.content : "";
container.innerText += args.content;
buttonAdd("#"+container.id,null,"Ok",function () {
dialogRoot.parentNode.removeChild(dialogRoot);
},"dialog_submit");
}
function popupDialog (ID, title, closeable, contentGen, genArgs, callback) {
if ("function" != typeof callback) { callback = function () { return 0; }; }
var dialogBack = elementPlace("body",ID+"_back","dialog_back","div");
var dialogWindow = elementPlace("#"+ID+"_back",ID,"dialog_window","div");
var dialogTitle = elementPlace("#"+ID,ID+"_title","dialog_title","div");
if ("string" == typeof title) { dialogTitle.innerText = title; }
if (true == closeable) {buttonAdd("#"+ID+"_title",null,"X",function () {dialogBack.parentNode.removeChild(dialogBack);},"dialog_close");}
var dialogContent = elementPlace("#"+ID,ID+"_content","dialog_content","div");
if ("function" == typeof contentGen) {
contentGen(dialogBack,dialogContent,genArgs,callback);
} else {
dialogContent.innerText = "string" == typeof contentGen ? contentGen : "Empty Dialog";
buttonAdd("#"+ID+"_content",null,"Close",callback);
}
}