const saveBannerImg = function() {
let bannerImage = document.getElementById('bannerImg');
let imgData = getBase64Image(bannerImage);
localStorage.setItem("imgData", imgData);
}
const getBase64Image = function(img) {
let canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;
let ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0);
let dataURL = canvas.toDataURL("image/png");
return dataURL.replace(/^data:image\/(png|jpg);base64,/, "");
}
const loadBannerImg = function() {
let dataImage = localStorage.getItem('imgData');
let bannerImg = document.getElementById('tableBanner');
bannerImg.src = "data:image/png;base64," + dataImage;
}