44 lines
1.0 KiB
JavaScript
44 lines
1.0 KiB
JavaScript
// JavaScript Document
|
|
|
|
function myFunction() {
|
|
let myVar = 'Hello, Wappler!';
|
|
return myVar;
|
|
}
|
|
|
|
function runMyFunction() {
|
|
// alert("function run")
|
|
let result = generateRandomIdentifier(9);
|
|
// Use Wappler dmx.set to bind result to a Wappler variable if needed
|
|
//<p>{{myResult}}</p>
|
|
console.log(result)
|
|
dmx.global.set('myResult', result);
|
|
|
|
}
|
|
async function toBase64(filePath) {
|
|
const img = await fetch(filePath).then(res => res.arrayBuffer())
|
|
console.log(img)
|
|
dmx.global.set('imgResult', img)
|
|
return img
|
|
}
|
|
|
|
|
|
|
|
|
|
const terminal = document.getElementById('terminal');
|
|
|
|
// Function to add a line to the terminal
|
|
function addLine(text) {
|
|
const line = document.createElement('p');
|
|
line.className = 'line';
|
|
line.textContent = text;
|
|
terminal.appendChild(line);
|
|
|
|
// Automatically scroll to the bottom
|
|
terminal.scrollTop = terminal.scrollHeight;
|
|
}
|
|
|
|
// Simulate adding lines
|
|
let lineCount = 0;
|
|
setInterval(() => {
|
|
addLine(`Line ${++lineCount}: This is a test log.`);
|
|
}, 500); // Add a new line every 500ms
|