Skip to content

Commit 7cd7ff9

Browse files
committed
Optimized binary implementation.
1 parent ec4be00 commit 7cd7ff9

File tree

13 files changed

+54
-613
lines changed

13 files changed

+54
-613
lines changed

.codeclimate.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ exclude_paths:
4040
- doc/**/*
4141
- locales/**/*
4242
- src/blocks/**/*
43+
- static_files/**/*
4344
- third_party/**/*

app/chrome_app/js/background.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ chrome.app.runtime.onLaunched.addListener(
7070
);
7171
loaderWindow.drawAttention();
7272
} else {
73-
console.warn('Loaded inside sandboxed window!');
73+
console.warn('Loaded inside sand-boxed window!');
7474
}
7575
chrome.app.window.create('html/editor.html', editorConfig);
7676
});

app/chrome_app/js/editor.js

Lines changed: 37 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -23,73 +23,57 @@ let cwcChromeSupport = (
2323
typeof chrome !== 'undefined' &&
2424
typeof chrome.app !== 'undefined' &&
2525
typeof chrome.app.window !== 'undefined');
26+
let loader = cwcChromeSupport && chrome.app.window.get('loader');
2627

2728
let cwcBuildUi = function() {
28-
if (cwcChromeSupport) {
29-
let loader = chrome.app.window.get('loader');
30-
if (loader) {
31-
loader.contentWindow.postMessage({'command': 'progress',
32-
'text': 'Build the Coding with Chrome UI ...',
33-
'current': 1, 'total': 100}, '*');
34-
}
29+
if (loader) {
30+
loader.contentWindow.postMessage({'command': 'progress',
31+
'text': 'Build the Coding with Chrome UI ...',
32+
'current': 1, 'total': 100}, '*');
3533
if (typeof cwc == 'undefined') {
36-
if (loader) {
37-
loader.contentWindow.postMessage({'command': 'error',
38-
'msg': 'The cwc namespace is undefined!\n' +
39-
'Please make sure that the compiler runs without any errors!'},
40-
'*');
41-
}
42-
return null;
34+
loader.contentWindow.postMessage({'command': 'error',
35+
'msg': 'The cwc namespace is undefined!\n' +
36+
'Please make sure that the compiler runs without any errors!'},
37+
'*');
4338
} else if (typeof cwc.ui == 'undefined' ||
4439
typeof cwc.ui.Builder == 'undefined') {
45-
if (loader) {
46-
loader.contentWindow.postMessage({'command': 'error',
47-
'msg': 'cwc.ui.Builder is undefined!\n' +
48-
'Maybe an uncaught TypeError, SyntaxError, ... or missing files.'},
49-
'*');
50-
}
51-
return null;
40+
loader.contentWindow.postMessage({'command': 'error',
41+
'msg': 'cwc.ui.Builder is undefined!\n' +
42+
'Maybe an uncaught TypeError, SyntaxError, ... or missing files.'},
43+
'*');
5244
}
5345
}
54-
let uiBuilder = new cwc.ui.Builder();
55-
uiBuilder.decorate();
56-
return uiBuilder;
46+
return new cwc.ui.Builder().decorate();
5747
};
5848

59-
6049
let cwcLoadScripts = function() {
6150
let header = document.getElementsByTagName('head')[0];
62-
if (header) {
63-
let loader = cwcChromeSupport && chrome.app.window.get('loader');
64-
let message = 'Loading additional JavaScripts ...';
65-
if (loader) {
66-
loader.contentWindow.postMessage({'command': 'progress',
67-
'text': message,
68-
'current': 0, 'total': 100}, '*');
69-
}
70-
// Adding main ui script.
71-
let uiScript = document.createElement('script');
72-
uiScript.type = 'text/javascript';
73-
uiScript.src = '../js/cwc_ui.js';
74-
uiScript.onload = function() {
75-
// Adding debugging script.
76-
let debugScript = document.createElement('script');
77-
debugScript.type = 'text/javascript';
78-
debugScript.src = '../js/debug.js';
79-
header.appendChild(debugScript);
80-
};
81-
header.appendChild(uiScript);
82-
83-
if (loader) {
84-
loader.contentWindow.postMessage({'command': 'progress',
85-
'text': message,
86-
'current': 100, 'total': 100}, '*');
87-
}
88-
} else {
51+
if (!header) {
8952
console.error('Seems DOM content is not ready!');
53+
return;
9054
}
91-
};
55+
if (loader) {
56+
loader.contentWindow.postMessage({'command': 'progress',
57+
'text': 'Loading additional Scripts ...',
58+
'current': 0, 'total': 100}, '*');
59+
}
60+
let uiScript = document.createElement('script');
61+
uiScript.type = 'text/javascript';
62+
uiScript.src = '../js/cwc_ui.js';
63+
uiScript.onload = function() {
64+
let debugScript = document.createElement('script');
65+
debugScript.type = 'text/javascript';
66+
debugScript.src = '../js/debug.js';
67+
header.appendChild(debugScript);
68+
};
69+
header.appendChild(uiScript);
9270

71+
if (loader) {
72+
loader.contentWindow.postMessage({'command': 'progress',
73+
'text': 'Loaded additional Scripts',
74+
'current': 100, 'total': 100}, '*');
75+
}
76+
};
9377

9478
window.addEventListener('load', cwcBuildUi, false);
9579
document.addEventListener('DOMContentLoaded', cwcLoadScripts, false);

app/nw_app/html/editor.html

Lines changed: 0 additions & 64 deletions
This file was deleted.

app/nw_app/html/loader.html

Lines changed: 0 additions & 40 deletions
This file was deleted.

app/nw_app/js/background.js

Lines changed: 0 additions & 78 deletions
This file was deleted.

app/nw_app/js/debug.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)