updated to current version 1.8.2
This commit is contained in:
parent
0c32a0dcb1
commit
39592c856c
@ -1,5 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
/////////////////////// BlueCore 1.7.2 \\\\\\\\\\\\\\\\\\\\\\\\\\
|
/////////////////////// BlueCore 1.8.2 \\\\\\\\\\\\\\\\\\\\\\\\\\
|
||||||
|
|
||||||
function getData(url,dothis,tothis,type,body) {
|
function getData(url,dothis,tothis,type,body) {
|
||||||
var DataRequest = new XMLHttpRequest();
|
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.
|
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) {
|
return (function (myElement) {
|
||||||
if ("string" == typeof ID) { myElement.id = ID; }
|
if ("string" == typeof ID) { myElement.id = ID; }
|
||||||
if ("string" == typeof Class) { myElement.className = Class; }
|
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) {
|
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);
|
var newElement = elementMake(ID,Class,element);
|
||||||
if ( (typeof document.querySelector(parentID).append && typeof document.querySelector(parentID).prepend) !== "undefined") { // Are we compliant?
|
if ( (typeof document.querySelector(parentID).append && typeof document.querySelector(parentID).prepend) !== "undefined") { // Are we compliant?
|
||||||
if ("before" == position) {
|
if ("before" == position) {
|
||||||
@ -76,6 +79,23 @@ function elementPlace (parentID, ID, Class, element, position) {
|
|||||||
return newElement;
|
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) {
|
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"; }
|
||||||
@ -85,43 +105,39 @@ function buttonAdd (ParentID,ID,Label,Action,Class,Element) {
|
|||||||
})(elementPlace(ParentID,ID,"button "+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.
|
function inputDialog (dialogRoot,container,args,callback) {
|
||||||
if ( "sub_window" == type ) {
|
args = "object" == typeof args ? args : {"content":""};
|
||||||
var closeButton = elementPlace(parentDialog,"closeButton",null,"div"); //Also need to change this, to help standardize the look and feel of the UI
|
args.content = "string" == typeof args.content ? args.content : "";
|
||||||
closeButton.innerHTML = "X";
|
container.innerText += args.content;
|
||||||
closeButton.onclick = function () { document.getElementById("body").removeChild(DialogBack); }
|
var inputArea = elementPlace("#"+container.id,null,"formInput","input");
|
||||||
//More controls will go here probably as I flesh out the sub window design
|
if ("string" == typeof args.inputType) { inputArea.type = args.inputType; }
|
||||||
}
|
buttonAdd("#"+container.id,null,"Submit",function () {
|
||||||
if ( "input" == type ) {
|
callback(inputArea.value);
|
||||||
var inputArea = elementPlace(parentDialog,"listID","inputField","input",null);
|
dialogRoot.parentNode.removeChild(dialogRoot);
|
||||||
var submitButton = buttonAdd(parentDialog,"SubmitButton","Submit",function () {
|
},"dialog_submit");
|
||||||
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 dialogMessage (content,type,returnVar) {
|
function messageDialog (dialogRoot,container,args) {
|
||||||
var message = elementPlace("#body","app_message_back","app_Message_Back","div");
|
args = "object" == typeof args ? args : {"content":""};
|
||||||
var dialog = elementPlace("#app_message_back","app_message","app_Message","div");
|
args.content = "string" == typeof args.content ? args.content : "";
|
||||||
dialog.innerHTML = content;
|
container.innerText += args.content;
|
||||||
dialogControlsGen("#app_message",message, type, returnVar);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user