|
@@ -1,15 +1,15 @@
|
|
|
module INSPECTOR {
|
|
|
export class Helpers {
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* Returns the type of the given object. First
|
|
|
* uses getClassName. If nothing is returned, used the type of the constructor
|
|
|
*/
|
|
|
- public static GET_TYPE(obj:any) : string{
|
|
|
+ public static GET_TYPE(obj: any): string {
|
|
|
if (obj != null && obj != undefined) {
|
|
|
let classname = BABYLON.Tools.getClassName(obj);
|
|
|
- if (!classname || classname === 'object'){
|
|
|
+ if (!classname || classname === 'object') {
|
|
|
classname = obj.constructor.name;
|
|
|
// classname is undefined in IE11
|
|
|
if (!classname) {
|
|
@@ -25,22 +25,22 @@ module INSPECTOR {
|
|
|
return 'type_not_defined';
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Check if some properties are defined for the given type.
|
|
|
*/
|
|
|
- private static _CheckIfTypeExists(type:string) {
|
|
|
+ private static _CheckIfTypeExists(type: string) {
|
|
|
let properties = PROPERTIES[type];
|
|
|
if (properties) {
|
|
|
return true;
|
|
|
- }
|
|
|
+ }
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Returns true if the user browser is edge.
|
|
|
*/
|
|
|
- public static IsBrowserEdge() : boolean {
|
|
|
+ public static IsBrowserEdge(): boolean {
|
|
|
//Detect if we are running on a faulty buggy OS.
|
|
|
var regexp = /Edge/
|
|
|
return regexp.test(navigator.userAgent);
|
|
@@ -51,7 +51,7 @@ module INSPECTOR {
|
|
|
* is in PROPERTIES constant.
|
|
|
* Returns 'Undefined' if no type exists for this object
|
|
|
*/
|
|
|
- private static _GetTypeFor(obj:any) {
|
|
|
+ private static _GetTypeFor(obj: any) {
|
|
|
for (let type in PROPERTIES) {
|
|
|
let typeBlock = PROPERTIES[type];
|
|
|
if (typeBlock.type) {
|
|
@@ -70,9 +70,9 @@ module INSPECTOR {
|
|
|
var s = f && ((fn.name && ['', fn.name]) || fn.toString().match(/function ([^\(]+)/));
|
|
|
return (!f && 'not a function') || (s && s[1] || 'anonymous');
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/** Send the event which name is given in parameter to the window */
|
|
|
- public static SEND_EVENT(eventName:string){
|
|
|
+ public static SEND_EVENT(eventName: string) {
|
|
|
let event;
|
|
|
if (Inspector.DOCUMENT.createEvent) {
|
|
|
event = Inspector.DOCUMENT.createEvent('HTMLEvents');
|
|
@@ -82,25 +82,25 @@ module INSPECTOR {
|
|
|
}
|
|
|
window.dispatchEvent(event);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/** Returns the given number with 2 decimal number max if a decimal part exists */
|
|
|
- public static Trunc(nb) :number {
|
|
|
- if(Math.round(nb) !== nb) {
|
|
|
+ public static Trunc(nb): number {
|
|
|
+ if (Math.round(nb) !== nb) {
|
|
|
return nb.toFixed(2);
|
|
|
}
|
|
|
return nb;
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Useful function used to create a div
|
|
|
*/
|
|
|
- public static CreateDiv(className?:string, parent?: HTMLElement) : HTMLElement{
|
|
|
+ public static CreateDiv(className?: string, parent?: HTMLElement): HTMLElement {
|
|
|
return Helpers.CreateElement('div', className, parent);
|
|
|
}
|
|
|
-
|
|
|
- public static CreateElement(element:string, className?:string, parent?: HTMLElement) : HTMLElement{
|
|
|
+
|
|
|
+ public static CreateElement(element: string, className?: string, parent?: HTMLElement): HTMLElement {
|
|
|
let elem = Inspector.DOCUMENT.createElement(element);
|
|
|
-
|
|
|
+
|
|
|
if (className) {
|
|
|
elem.className = className;
|
|
|
}
|
|
@@ -109,12 +109,12 @@ module INSPECTOR {
|
|
|
}
|
|
|
return elem;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Removes all children of the given div.
|
|
|
*/
|
|
|
- public static CleanDiv(div:HTMLElement) {
|
|
|
- while ( div.firstChild ) {
|
|
|
+ public static CleanDiv(div: HTMLElement) {
|
|
|
+ while (div.firstChild) {
|
|
|
div.removeChild(div.firstChild);
|
|
|
}
|
|
|
}
|
|
@@ -122,7 +122,7 @@ module INSPECTOR {
|
|
|
/**
|
|
|
* Returns the true value of the given CSS Attribute from the given element (in percentage or in pixel, as it was specified in the css)
|
|
|
*/
|
|
|
- public static Css(elem:HTMLElement, cssAttribute:string) : string{
|
|
|
+ public static Css(elem: HTMLElement, cssAttribute: string): string {
|
|
|
let clone = elem.cloneNode(true) as HTMLElement;
|
|
|
let div = Helpers.CreateDiv('', Inspector.DOCUMENT.body);
|
|
|
div.style.display = 'none';
|
|
@@ -131,17 +131,17 @@ module INSPECTOR {
|
|
|
div.parentNode.removeChild(div);
|
|
|
return value;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public static LoadScript() {
|
|
|
BABYLON.Tools.LoadFile("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/highlight.min.js", (elem) => {
|
|
|
let script = Helpers.CreateElement('script', '', Inspector.DOCUMENT.body);
|
|
|
- script.textContent = elem;
|
|
|
-
|
|
|
+ script.textContent = elem;
|
|
|
+
|
|
|
// Load glsl detection
|
|
|
BABYLON.Tools.LoadFile("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/languages/glsl.min.js", (elem) => {
|
|
|
let script = Helpers.CreateElement('script', '', Inspector.DOCUMENT.body);
|
|
|
- script.textContent = elem;
|
|
|
-
|
|
|
+ script.textContent = elem;
|
|
|
+
|
|
|
// Load css style
|
|
|
BABYLON.Tools.LoadFile("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.7.0/styles/zenburn.min.css", (elem) => {
|
|
|
let style = Helpers.CreateElement('style', '', Inspector.DOCUMENT.body);
|
|
@@ -149,19 +149,19 @@ module INSPECTOR {
|
|
|
});
|
|
|
}, null, null, null, () => {
|
|
|
console.log("erreur");
|
|
|
- });
|
|
|
-
|
|
|
+ });
|
|
|
+
|
|
|
}, null, null, null, () => {
|
|
|
console.log("erreur");
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public static IsSystemName(name: string): boolean {
|
|
|
- if (name==null) {
|
|
|
+ if (name == null) {
|
|
|
return false;
|
|
|
}
|
|
|
- return name.indexOf("###")===0 && name.lastIndexOf("###")===(name.length-3);
|
|
|
+ return name.indexOf("###") === 0 && name.lastIndexOf("###") === (name.length - 3);
|
|
|
}
|
|
|
}
|
|
|
}
|