if (!Array.isArray(elements)) {
elements = [elements];
}
+
+ const listener = event => {
+ if (event.key === 'Enter') {
+ callback(event);
+ }
+ }
+
+ elements.forEach(e => e.addEventListener('keypress', listener));
}
/**
}
}
return null;
+}
+
+/**
+ * Show a loading indicator in the given element.
+ * This will effectively clear the element.
+ * @param {Element} element
+ */
+export function showLoading(element) {
+ element.innerHTML = `<div class="loading-container"><div></div><div></div><div></div></div>`;
+}
+
+/**
+ * Remove any loading indicators within the given element.
+ * @param {Element} element
+ */
+export function removeLoading(element) {
+ const loadingEls = element.querySelectorAll('.loading-container');
+ for (const el of loadingEls) {
+ el.remove();
+ }
}
\ No newline at end of file