fix: allow constructor with 1 arguement

This commit is contained in:
Ward Truyen
2025-10-19 00:37:11 +02:00
parent 0badda6799
commit 62ebabdc9d
2 changed files with 9 additions and 9 deletions

View File

@@ -39,14 +39,14 @@
&lt;script src="js/wterminal.js"&gt;&lt;/script&gt;</code>
</p>
<p>Then add a script ellement with:<br>
<code>WTerminal.instalDropdownTerminal();</code>
Or
<code>new WTerminal("dropdown", null, null);</code>
<code>WTerminal.instalDropdownTerminal();</code><br>
Or<br>
<code>new WTerminal("dropdown");</code><br>
</p>
<script>
WTerminal.instalDropdownTerminal();
// WTerminal.instalDropdownTerminal();
// Or
//new WTerminal("dropdown", null, null);
new WTerminal("dropdown");
</script>
</main>

View File

@@ -5,7 +5,7 @@
*/
class WTerminal {
//TERMINAL const
static get VERSION() { return "1.3.2"; }; // terminal version, duh.
static get VERSION() { return "1.3.3"; }; // terminal version, duh.
//css & html element relations:
static get BACKGROUND_CLASS() { return "wterminal-background"; }; // blurred background div class, contains it all, hides it all.
static get CONTAINER_CLASS() { return "wterminal-container"; }; // container div class for all the terminal elements.
@@ -198,7 +198,7 @@ class WTerminal {
constructor(name, locationId, options) {
this.name = name;
this.locationId = location;
this.locationId = locationId;
// use name in static storage of terminals
WTerminal.terminals[name] = this;
// Todo: use options variable ...
@@ -276,7 +276,7 @@ class WTerminal {
controls.appendChild(btnScrollBottom);
container.appendChild(output);
container.appendChild(inputForm);
if (locationId === null) { // use location to insert terminal in a div(string id) or dropdown (null)
if (locationId === null || typeof locationId === 'undefined') { // use location to insert terminal in a div(string id) or dropdown (null)
const background = WTerminal.createElement('div', { class: WTerminal.BACKGROUND_CLASS, title: "Close terminal" });
this.backgroundEl = background;
@@ -1297,7 +1297,7 @@ class WTerminal {
if (document.body) {
new WTerminal('dropdown', null, null);
} else {
window.addEventListener("load", () => new WTerminal('dropdown', null, null));
window.addEventListener("load", () => new WTerminal('dropdown'));
}
}