// utils.js
// Create a global object to hold our utility functions
window.ChatbotUtils = {
convertMillisecToHrMinSec: function (milisectime) {
let date = new Date(milisectime);
let hr = date.getHours();
let min = date.getMinutes();
let sec = date.getSeconds();
hr = hr < 10 ? "0" + hr : hr;
min = min < 10 ? "0" + min : min;
sec = sec < 10 ? "0" + sec : sec;
return min + ":" + sec;
},
getCurrentTimestamp: function () {
const options = {
month: "short",
day: "numeric",
hour: "numeric",
minute: "numeric",
hour12: true,
};
return new Date().toLocaleString("en-US", options);
},
isHTML: function (str) {
var doc = new DOMParser().parseFromString(str, "text/html");
return Array.from(doc.body.childNodes).some((node) => node.nodeType === 1);
},
};