From 8579da72394cb25e581469d5a1e8f19fe4cfa51b Mon Sep 17 00:00:00 2001
From: lowercasedonkey <lowercasedonkey@gmail.com>
Date: Thu, 27 Aug 2020 01:02:47 -0400
Subject: [PATCH] create in DOM

---
 src/gui/userButton.js | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 src/gui/userButton.js

diff --git a/src/gui/userButton.js b/src/gui/userButton.js
new file mode 100644
index 00000000000..df909282460
--- /dev/null
+++ b/src/gui/userButton.js
@@ -0,0 +1,42 @@
+globalThis.userButton = function() {
+	const el = new DocumentFragment();
+	const _Pass = passage();
+	let div = document.createElement("div");
+	div.style.fontWeight = "bold";
+	// We must always have a named element so we have something to refresh even if the button is hidden for a scene
+	if (_Pass !== "End Week") {
+		if (_Pass === "Main") {
+			div.id = "endWeekButton";
+			div.append(
+				App.UI.DOM.link(
+					"END WEEK",
+					() => endWeek()
+				)
+			);
+			div.append(" ");
+			App.UI.DOM.appendNewElement("span", div, App.UI.Hotkeys.hotkeys("endWeek"), "hotkey");
+			el.append(div);
+			if (V.rulesAssistantAuto === 1 && DefaultRulesError()) {
+				App.UI.DOM.appendNewElement("div", el, `WARNING: Rules Assistant has rules with errors!`, "yellow");
+			}
+		} else {
+			div.id = "nextButton";
+			if (V.nextButton !== " ") {
+				div.append(
+					App.UI.DOM.passageLink(
+						V.nextButton,
+						V.nextLink
+					)
+				);
+				div.append(" ");
+				App.UI.DOM.appendNewElement("span", div, App.UI.Hotkeys.hotkeys("nextLink"), "hotkey");
+			}
+			el.append(div);
+		}
+	}
+	return el;
+};
+
+globalThis.updateUserButton = function() {
+	return jQuery("#nextButton").empty().append(userButton());
+};
-- 
GitLab