Hello fellow bubblers
I added a run on page load workflow to run this JavaScript and added a a Javascript to bubble element, when i inspected the element for a value it shows empty! what am I doing wrong here.
// Dynamically load the buffer library
var script = document.createElement('script');
script.src = "https://cdnjs.cloudflare.com/ajax/libs/buffer/6.0.3/buffer.min.js";
// When the script is loaded, execute the following code
script.onload = function() {
// Ensure Buffer is defined from the loaded buffer library
var Buffer = buffer.Buffer;
// Function to get TLV for a given tag number and value
function getTLVForValue(tagNum, tagValue) {
var tagBuf = Buffer.from(tagNum, 'utf8'); // Create buffer for tag number
var tagValueLenBuf = Buffer.from([tagValue.length]); // Buffer for tag value length
var tagValueBuf = Buffer.from(tagValue, 'utf8'); // Buffer for tag value
var bufsArray = [tagBuf, tagValueLenBuf, tagValueBuf]; // Array of buffers
return Buffer.concat(bufsArray); // Concatenate all buffers into one
}
// Function to convert a UTF-8 string to Base64
function utf8ToBase64(str) {
return btoa(unescape(encodeURIComponent(str))); // Handle encoding for UTF-8 strings
}
// 1. Seller Name
var sellerNameBuf = getTLVForValue("1", "salah hospital");
// 2. VAT Registration
var vatRegistrationNameBuf = getTLVForValue("2", "31234567890123");
// Placeholder variables for other buffers
var timeStampBuf = Buffer.from("timestamp", 'utf8');
var taxTotalNameBuf = Buffer.from("taxTotal", 'utf8');
var vatTotalBuf = Buffer.from("vatTotal", 'utf8');
var hashedXmlBuf = Buffer.from("hashedXml", 'utf8');
var keyBuf = Buffer.from("key", 'utf8');
var signatureBuf = Buffer.from("signature", 'utf8');
// Combine all buffers
var tagsBufsArray = [
sellerNameBuf,
vatRegistrationNameBuf,
timeStampBuf,
taxTotalNameBuf,
vatTotalBuf,
hashedXmlBuf,
keyBuf,
signatureBuf
];
// Concatenate all buffers
var qrCodeBuf = Buffer.concat(tagsBufsArray);
// Convert to base64
var qrCodeB64 = utf8ToBase64(qrCodeBuf.toString('utf8'));
console.log(qrCodeB64);
// Sending to bubble_fn_1
bubble_fn_1(qrCodeB64);
};
Any help would be appreciated