Skip to content

Commit 40d6235

Browse files
committed
code optimization
1 parent d940e00 commit 40d6235

11 files changed

Lines changed: 71 additions & 107 deletions

File tree

.project

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@
1515
</dictionary>
1616
</arguments>
1717
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
20+
<triggers>full,incremental,</triggers>
21+
<arguments>
22+
<dictionary>
23+
<key>LaunchConfigHandle</key>
24+
<value>&lt;project&gt;/.externalToolBuilders/Compass-Katex.launch</value>
25+
</dictionary>
26+
</arguments>
27+
</buildCommand>
1828
</buildSpec>
1929
<natures>
2030
</natures>

src/assets/js/bootLoader.ts

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* it is possible to load EASYUI asynchronously.
44
* jquery node_module working with ProvidePlugin.
55
*/
6-
import MobileDetect from 'mobile-detect';
76
const CodeMirror = (await import('codemirror')).default;
87

98
import { Observable } from './patterns/observable';
@@ -72,7 +71,7 @@ export class BootLoader implements IBootLoader {
7271
}
7372
} catch(err) {
7473
console.error(`Error occurred: ${err} `);
75-
reject(Error(err));
74+
reject(new Error(err));
7675
}
7776
});
7877
}
@@ -97,20 +96,6 @@ export class BootLoader implements IBootLoader {
9796
return this.promisify(setTimeout, delay);
9897
}
9998

100-
/**
101-
* Checks if running device is mobile device.
102-
*
103-
* @returns - Flag indicating a Mobile device
104-
*/
105-
platformInfo() : any {
106-
// Not reliable -> overridden in app
107-
let md = new MobileDetect(navigator.userAgent);
108-
let mobile = md.mobile() != null;
109-
let osFamily = md.os() ?? 'desktop';
110-
111-
return { isMobile: mobile, osFamily: osFamily };
112-
}
113-
11499
/**
115100
* Initializes the app.
116101
*
@@ -121,7 +106,7 @@ export class BootLoader implements IBootLoader {
121106
async initApp() {
122107
try {
123108
this.vme = this.factory();
124-
window.vme = this.vme; // prevents garbage collection?
109+
globalThis.vme = this.vme; // prevents garbage collection?
125110
await this.vme.initialise();
126111
$('#myContainer').layout({fit: true}); // TODO: move to initialise, can be better controlled
127112
$('#innerLayout').layout({fit: true});
@@ -170,7 +155,7 @@ export class BootLoader implements IBootLoader {
170155
*/
171156
function checkTypeByName(type: any, name: string, readableName = name) {
172157
lastChecked = readableName;
173-
if (type === undefined || type === null || (typeof type) === 'undefined' || !type.prototype) {
158+
if (!type?.prototype) {
174159
console.warn(`Undefined type : ${readableName}`);
175160
return false;
176161
}
@@ -202,7 +187,7 @@ export class BootLoader implements IBootLoader {
202187
function mhchemCheck() {
203188
try {
204189
lastChecked = "Mhchem";
205-
this.katex.renderToString("\\ce{SO4^2- + Ba^2+ -> BaSO4 v} ", { throwOnError: true });
190+
this.katex.renderToString(String.raw`\ce{SO4^2- + Ba^2+ -> BaSO4 v} `, { throwOnError: true });
206191
return true;
207192
} catch(e) {
208193
console.warn(`Presence check failed : Mhchem`);
@@ -212,15 +197,9 @@ export class BootLoader implements IBootLoader {
212197

213198
let allLoaded = (
214199
checkOther(typeof $, 'function', 'jquery') &&
215-
//checkOther(typeof $.messager, 'object', 'easyui') &&
216-
//checkOther(typeof $.fn.datagrid, 'function', 'datagrid') &&
217-
//checkOther(typeof $.fn.datagrid.defaults, 'object', 'datagrid') &&
218-
//checkOther(typeof $.fn.datagrid.defaults.defaultFilterOptions, 'object', 'datagrid-filter') &&
219-
// Can we independantly check dnd and cellediting?
200+
220201
checkOther(typeof this.katex, 'object', 'Katex') &&
221202
checkOther(typeof this.katex.renderToString, 'function', 'Katex') &&
222-
// Can we do this check?
223-
//mhchemCheck() &&
224203

225204
checkTypeByName(CodeMirror, 'CodeMirror', 'CodeMirror') &&
226205

@@ -236,7 +215,7 @@ export class BootLoader implements IBootLoader {
236215
checkTypeByName(KatexInputHelper, 'KatexInputHelper'));
237216

238217
if (! allLoaded && cycle <= 0) {
239-
throw Error(`${lastChecked} not loaded`);
218+
throw new Error(`${lastChecked} not loaded`);
240219
}
241220

242221
return allLoaded;

src/assets/js/container.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ container
7272

7373

7474
const bootLoader: IBootLoader = container.get(bootLoaderId);
75-
container.bind(platformInfoId).toDynamicValue(bootLoader.platformInfo.bind(bootLoader));
7675

7776
try {
7877
await bootLoader.init1();

0 commit comments

Comments
 (0)