From a0333f6677581a30ac69838aaabf0fee52f64769 Mon Sep 17 00:00:00 2001
From: "Rob Swindell (on Debian Linux)" <rob@synchro.net>
Date: Sat, 11 Mar 2023 23:58:32 -0800
Subject: [PATCH] New file transfer configuration sub menu script

To replace some copy/pasta in *.src (and later *.js shells)
---
 exec/default.src    | 50 ++-------------------------------------------
 exec/filescancfg.js | 47 ++++++++++++++++++++++++++++++++++++++++++
 exec/wwiv.src       | 28 ++-----------------------
 3 files changed, 51 insertions(+), 74 deletions(-)
 create mode 100755 exec/filescancfg.js

diff --git a/exec/default.src b/exec/default.src
index 0f4fbf16af..43399c6d4c 100644
--- a/exec/default.src
+++ b/exec/default.src
@@ -796,54 +796,8 @@ cmdkey /*
 	end_cmd
 
 cmdkey &
-	:xfercfg
-	compare_user_misc UM_expert
-	if_false
-		menu xfercfg
-		end_if
-	async
-	print "\r\n\1y\1hConfig: \1n"
-	getcmd ?QBEP\r
-	logkey
-
-	cmdkey ?
-		compare_user_misc UM_expert
-		if_true
-			menu xfercfg
-			end_if
-		goto xfercfg
-		end_cmd
-
-	cmdkey P
-		file_ptrs_cfg
-		end_cmd
-
-	cmdkey B
-                crlf
-		toggle_user_misc UM_BATCHFLAG
-                compare_user_misc UM_BATCHFLAG
-                print "Batch flagging in file listings is now: \1h"
-                if_true
-                    print "ON"
-                else
-                    print "OFF"
-                    end_if
-                crlf
-		end_cmd
-
-	cmdkey E
-                crlf
-		toggle_user_misc UM_EXTDESC
-                compare_user_misc UM_EXTDESC
-                print "Extended file description display is now: \1h"
-                if_true
-                    print "ON"
-                else
-                    print "OFF"
-                    end_if
-                crlf
-                end_cmd
-	end_cmd
+    exec_bin "filescancfg"
+    end_cmd
 
 cmdkey #
 	print "\r\n\1c\1hType the actual number, not the symbol.\r\n"
diff --git a/exec/filescancfg.js b/exec/filescancfg.js
new file mode 100755
index 0000000000..073ac85afa
--- /dev/null
+++ b/exec/filescancfg.js
@@ -0,0 +1,47 @@
+// File Scan Configuration menu
+
+require("sbbsdefs.js", "USER_EXPERT");
+
+"use strict";
+
+const menufile = "xfercfg";
+
+while(bbs.online && !js.terminated) {
+	if(!(user.settings & USER_EXPERT))
+		bbs.menu(menufile);
+	bbs.nodesync();
+	console.print("\r\n\x01y\x01hConfig: \x01n");
+	var key = console.getkeys("?QBEP\r");
+	bbs.log_key(key);
+
+	switch(key) {
+		case '?':
+			if(user.settings & USER_EXPERT)
+				bbs.menu(menufile);
+			continue;
+		case 'P':
+			var val = bbs.get_newscantime(bbs.new_file_time);
+			if(val !== null)
+				bbs.new_file_time = val;
+			break;
+		case 'B':
+			user.settings ^= USER_BATCHFLAG;
+			console.print("\r\nBatch flagging in file listings is now: \1h");
+			if(user.settings & USER_BATCHFLAG)
+				console.print("ON");
+			else
+				console.print("OFF");
+			console.crlf();
+			break;
+		case 'E':
+			user.settings ^= USER_EXTDESC;
+			console.print("\r\nExtended file description display is now: \1h");
+			if(user.settings & USER_EXTDESC)
+				console.print("ON");
+			else
+				console.print("OFF");
+			console.crlf();
+			break;
+	}
+	break;
+}
diff --git a/exec/wwiv.src b/exec/wwiv.src
index 22d1709286..82f350a191 100644
--- a/exec/wwiv.src
+++ b/exec/wwiv.src
@@ -610,32 +610,8 @@ cmdkey /*
 	end_cmd
 
 cmdkey T
-	:xfercfg
-	compare_ars expert
-	if_false
-		menu XFERCFG
-		end_if
-	async
-	print "\r\n\x01y\x01hConfig: \x01n"
-	getcmd ?QBP\r
-	logkey
-
-	cmdkey ?
-		compare_ars expert
-		if_true
-			menu XFERCFG
-			end_if
-		goto xfercfg
-		end_cmd
-
-	cmdkey P
-		file_ptrs_cfg
-		end_cmd
-
-	cmdkey B
-		toggle_user_misc UM_BATCHFLAG
-		end_cmd
-	end_cmd
+    exec_bin "filescancfg"
+    end_cmd
 
 cmdkey #
 	print "\r\n\x01c\x01hType the actual number, not the symbol.\r\n"
-- 
GitLab