30 lines
956 B
JavaScript

import { DateFormatter } from "arm-common";
export function scrollToId(id, yOffset) {
const element = document.querySelector("#" + id);
if (element) {
//const yOffset = -75;
const y = element.getBoundingClientRect().top + window.pageYOffset + yOffset;
window.scrollTo({ top: y, behavior: 'smooth' });
} else {
setTimeout(() => this.scrollToId(id, yOffset), 100);
}
}
export function objectIsEmpty(obj) {
for (let property in obj) return false;
return true;
}
export function addTsToFileName(fileName){
const dateString = DateFormatter.formatDate(new Date(), '_YYYYMMDD-HHmmss')
const ind = fileName.indexOf('.');
if (ind === -1) {
fileName = fileName + dateString;
} else {
const preName = fileName.substring(0, ind);
const postName = fileName.substring(ind, fileName.length);
fileName = preName + dateString + postName;
}
return fileName;
}