File "utils.js"
Full path: /home/fsibplc/public_html/bot/bot-js/utils.js
File
size: 884 B (884 B bytes)
MIME-type: text/plain
Charset: utf-8
Download Open Edit Advanced Editor Back
// 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);
},
};