From eb20fbe9eb207d3b4d0d36c5b4b2d657cee571f8 Mon Sep 17 00:00:00 2001
From: Arkerthan <arkerthan@gmail.com>
Date: Tue, 11 Feb 2020 10:39:52 +0100
Subject: [PATCH] convert useGuard to DOM

---
 src/interaction/main/useGuard.js |  9 ++---
 src/js/main.js                   | 57 ++++++++++++++++++++++++++++++++
 src/js/slaveListing.js           |  2 +-
 src/uncategorized/main.tw        | 36 +++++---------------
 4 files changed, 71 insertions(+), 33 deletions(-)

diff --git a/src/interaction/main/useGuard.js b/src/interaction/main/useGuard.js
index 50bbf2e4ab4..79977929ba8 100644
--- a/src/interaction/main/useGuard.js
+++ b/src/interaction/main/useGuard.js
@@ -1,6 +1,8 @@
-
-/* OPEN USEGUARD */
-App.Interact.UseGuard = function(slave) {
+/**
+ * @param slave
+ * @return {string}
+ */
+App.Interact.guardPose = function(slave) {
 	"use strict";
 	let r = ``;
 	/* eslint-disable no-unused-vars*/
@@ -279,4 +281,3 @@ App.Interact.UseGuard = function(slave) {
 	}
 	return r;
 };
-/* CLOSE USEGUARD */
diff --git a/src/js/main.js b/src/js/main.js
index f52619035ba..c817c75707e 100644
--- a/src/js/main.js
+++ b/src/js/main.js
@@ -1,3 +1,6 @@
+/**
+ * @return {Text}
+ */
 App.MainView.fcnn = function() {
 	let text;
 
@@ -9,3 +12,57 @@ App.MainView.fcnn = function() {
 
 	return document.createTextNode(`${text} `);
 };
+
+/**
+ * @return {HTMLDivElement}
+ */
+App.MainView.useGuard = function() {
+	const guard = V.slaves[V.slaveIndices[V.Bodyguard.ID]];
+
+	const outerDiv = document.createElement("div");
+
+	if (guard === undefined || guard.assignment !== "guard you" || V.useSlaveSummaryOverviewTab === 1) {
+		return outerDiv;
+	}
+
+	outerDiv.append(App.UI.DOM.makeSpan(App.Interact.guardPose(guard), "scene-intro"));
+
+	function setEnvironment() {
+		V.activeSlave = guard;
+		V.nextButton = "Back";
+		V.nextLink = "AS Dump";
+		V.returnTo = passage();
+	}
+
+	const {him, his} = getPronouns(guard);
+	const optionDiv = document.createElement("div");
+	optionDiv.classList.add("indent");
+
+	optionDiv.append(
+		App.UI.DOM.passageLink(`Use ${his} mouth`, "FLips", setEnvironment),
+		" | ",
+		App.UI.DOM.passageLink(`Play with ${his} tits`, "FBoobs", setEnvironment)
+	);
+
+	if (canDoVaginal(guard)) {
+		optionDiv.append(" | ", App.UI.DOM.passageLink(`Fuck ${him}`, "FVagina", setEnvironment));
+		if (canDoAnal(guard)) {
+			optionDiv.append(" | ", App.UI.DOM.passageLink(`Use ${his} holes`, "FButt", setEnvironment));
+		}
+		if (guard.belly >= 300000) {
+			optionDiv.append(" | ", App.UI.DOM.passageLink(`Fuck ${him} over ${his} belly`, "FBellyFuck", setEnvironment));
+		}
+	}
+
+	if (canPenetrate(guard)) {
+		optionDiv.append(" | ", App.UI.DOM.passageLink(`Ride ${him}`, "FDick", setEnvironment));
+	}
+	if (canDoAnal(guard)) {
+		optionDiv.append(" | ", App.UI.DOM.passageLink(`Fuck ${his} ass`, "FAnus", setEnvironment));
+	}
+	optionDiv.append(" | ", App.UI.DOM.passageLink(`Abuse ${him}`, "Gameover", () => { V.gameover = "idiot ball"; }));
+
+	outerDiv.append(optionDiv);
+
+	return outerDiv;
+};
diff --git a/src/js/slaveListing.js b/src/js/slaveListing.js
index f6902d60843..4c9bd8e53b6 100644
--- a/src/js/slaveListing.js
+++ b/src/js/slaveListing.js
@@ -845,7 +845,7 @@ App.UI.SlaveList.penthousePage = function() {
 				const p = getPronouns(BG);
 				V.i = App.Utils.slaveIndexForId(BG.ID);
 				const interactLinkSetters = `$activeSlave = $slaves[${V.i}], $nextButton = "Back", $nextLink = "AS Dump", $returnTo = "Main"`;
-				r += `<br><span class='scene-intro'>${App.Interact.UseGuard(BG)}</span>`;
+				r += `<br><span class='scene-intro'>${App.Interact.guardPose(BG)}</span>`;
 				let useHimLinks = [];
 				useHimLinks.push(App.UI.passageLink(`Use ${p.his} mouth`, "FLips", interactLinkSetters));
 				useHimLinks.push(App.UI.passageLink(`Play with ${p.his} tits`, "FBoobs", interactLinkSetters));
diff --git a/src/uncategorized/main.tw b/src/uncategorized/main.tw
index 8f05fc2c90c..de9fd7e0af9 100644
--- a/src/uncategorized/main.tw
+++ b/src/uncategorized/main.tw
@@ -154,34 +154,14 @@ __''MAIN MENU''__&nbsp;&nbsp;&nbsp;&nbsp;//[[Summary Options]]//
 <</for>>
 <</if>>
 
-<<if (def _BG) && ($slaves[_BG].assignment == "guard you") && ($useSlaveSummaryOverviewTab != 1)>>
-	<<set $i = _BG>>
-	<<set _j = "Back", _k = "AS Dump", _l = "Main">>
-	<<setLocalPronouns $slaves[$i]>>
-	<<set _GO = "idiot ball">>
-	<br>
-	//<<= App.Interact.UseGuard($slaves[$i])>>//
-	<br>&nbsp;&nbsp;&nbsp;&nbsp;[["Use "+$his+" mouth"|FLips][$activeSlave = $slaves[_BG], $nextButton = _j, $nextLink = _k, $returnTo = _l]]
-	| [["Play with "+$his+" tits"|FBoobs][$activeSlave = $slaves[_BG], $nextButton = _j, $nextLink = _k, $returnTo = _l]]
-	<<if canDoVaginal($slaves[_BG])>>
-		| [["Fuck "+$him|FVagina][$activeSlave = $slaves[_BG], $nextButton = _j, $nextLink = _k, $returnTo = _l]]
-		<<if canDoAnal($slaves[_BG])>>
-			| [["Use "+$his+" holes"|FButt][$activeSlave = $slaves[_BG],$nextButton = _j, $nextLink = _k, $returnTo = _l]]
-		<</if>>
-		<<if $slaves[_BG].belly >= 300000>>
-			| [["Fuck "+$him+" over "+$his+" belly"|FBellyFuck][$activeSlave = $slaves[_BG], $nextButton = _j, $nextLink = _k, $returnTo = _l]]
-		<</if>>
-	<</if>>
-	/*check*/
-	<<if canPenetrate($slaves[_BG])>>
-		| [["Ride "+$him|FDick][$activeSlave = $slaves[_BG], $nextButton = _j, $nextLink = _k, $returnTo = _l]]
-	<</if>>
-	<<if canDoAnal($slaves[_BG])>>
-		| [["Fuck "+$his+" ass"|FAnus][$activeSlave = $slaves[_BG], $nextButton = _j, $nextLink = _k, $returnTo = _l]]
-	<</if>>
-	| [["Abuse "+$him|Gameover][$gameover = _GO]]
-<</if>>
-
+<span id="BG"></span>
+<<script>>
+	$(document).one(':passageend', () => {
+		$('#BG').append(
+			App.MainView.useGuard(),
+		);
+	});
+<</script>>
 
 <<set $activeSlave = $slaves.random()>>
 <<if $activeSlave && ($activeSlave.assignment != "please you") && ($activeSlave.assignment != "guard you")>>
-- 
GitLab