| 123456789101112131415161718192021222324252627 |
- const push = (name, action) => {
- if (typeof(action) !== "function") {
- throw new TypeError("Action must be an function.");
- }
- if (typeof(name) !== "string") {
- throw new TypeError("Name of the push must be string.");
- }
- const target = document.createElement("input");
-
- target.type = "button";
- target.name = name;
- target.id = "push-" + name;
-
- target.value = name
- .toUpperCase()
- .replaceAll("-", " ")
- .replaceAll("_", " ");
- target.classList.add("push");
- target.addEventListener("click", action);
- return target;
- };
- export { push };
|