5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 19:31:20 +08:00
wails/runtime/js/core/utils.js
Lea Anthony 5b33ed28fd
Initial support for firebug (#543)
* Initial support for firebug

* Remove windows message
2020-10-28 21:20:47 +11:00

47 lines
1.3 KiB
JavaScript

/*
_ __ _ __
| | / /___ _(_) /____
| | /| / / __ `/ / / ___/
| |/ |/ / /_/ / / (__ )
|__/|__/\__,_/_/_/____/
The lightweight framework for web-like apps
(c) Lea Anthony 2019-present
*/
/* jshint esversion: 6 */
import { Emit } from './events';
export function AddScript(js, callbackID) {
var script = document.createElement('script');
script.text = js;
document.body.appendChild(script);
if (callbackID) {
Emit(callbackID);
}
}
export function InjectFirebug() {
// set the debug attribute on HTML
var html = document.getElementsByTagName('html')[0];
html.setAttribute('debug', 'true');
var firebugURL = 'https://wails.app/assets/js/firebug-lite.js#startOpened=true,disableWhenFirebugActive=false';
var script = document.createElement('script');
script.src = firebugURL;
script.type = 'application/javascript';
document.head.appendChild(script);
window.wails.Log.Info('Injected firebug');
}
// Adapted from webview - thanks zserge!
export function InjectCSS(css) {
var elem = document.createElement('style');
elem.setAttribute('type', 'text/css');
if (elem.styleSheet) {
elem.styleSheet.cssText = css;
} else {
elem.appendChild(document.createTextNode(css));
}
var head = document.head || document.getElementsByTagName('head')[0];
head.appendChild(elem);
}