93 lines
2.4 KiB
JavaScript
93 lines
2.4 KiB
JavaScript
// JavaScript Document
|
|
|
|
|
|
|
|
|
|
console.log("LIBRARY: dummyFunctions.js")
|
|
function myFunction() {
|
|
let myVar = 'Hello, Wappler!';
|
|
return myVar;
|
|
}
|
|
|
|
/**
|
|
|
|
// Just simple PouchDB calls to db.info and db.get to test fetch of a document
|
|
|
|
function infoCouchDB() {
|
|
const db = new PouchDB('http://localhost:9913/db_training')
|
|
db.info().then(function (info) {
|
|
console.log(info)
|
|
})
|
|
|
|
db.get('da/1734165676725').then(function (doc) {
|
|
console.log(doc)
|
|
})
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
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
|
|
}
|
|
|
|
|
|
function saveSignatureTEST1() {
|
|
// Capture the Base64 image data from the canvas
|
|
const canvas = document.getElementById('signatureCanvas');
|
|
const imageData = canvas.toDataURL('image/png'); // Base64-encoded image
|
|
|
|
// Use Wappler's Server Connect to send a POST request
|
|
dmx.parse('serverconnect_sign.load({imageData: "' + imageData + '"})');
|
|
console.log("SSTEST: Finish Run, Anything happen?")
|
|
}
|
|
|
|
|
|
function saveSignatureTEST2() {
|
|
const canvas = document.getElementById('signatureCanvas');
|
|
const imageData = canvas.toDataURL('image/png'); // Convert the canvas to a Base64 image string
|
|
|
|
dmx.parse('serverconnect_sign.load({image: "' + imageData + '"})').then((response) => {
|
|
const uploadedSignature = document.getElementById('uploadedSignature');
|
|
uploadedSignature.src = response.fileUrl; // Set the uploaded file URL to the image element
|
|
}).catch((error) => {
|
|
console.error("Error uploading signature:", error);
|
|
});
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
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
|
|
|
|
*/ |