1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-29 01:30:16 +02:00

code mode functionality added

This commit is contained in:
Kushagra Gour
2018-06-03 17:22:43 +05:30
parent a5ca35ac90
commit d407304ebf
7 changed files with 258 additions and 40 deletions

View File

@@ -1,6 +1,10 @@
import {
trackEvent
} from './analytics';
import {
deferred
} from './deferred';
window.DEBUG = document.cookie.indexOf('wmdebug') > -1;
window.$ = document.querySelector.bind(document);
@@ -80,7 +84,7 @@
export function log() {
if (window.DEBUG) {
console.log(...arguments);
console.log(Date.now(), ...arguments);
}
}
@@ -273,6 +277,19 @@
);
}
export function loadJS(src) {
var d = deferred();
var ref = window.document.getElementsByTagName('script')[0];
var script = window.document.createElement('script');
script.src = src;
script.async = true;
ref.parentNode.insertBefore(script, ref);
script.onload = function () {
d.resolve();
};
return d.promise;
};
window.chrome = window.chrome || {};
window.chrome.i18n = {
getMessage: () => {}