Skip to content
Snippets Groups Projects
Commit 021b119f authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Merge branch 'slyvote_configurator_and_small_refactor' into 'master'

SlyVote: New menu-driven configurator. Minor code refactor; no difference in functionality.

See merge request !373
parents 40a47c30 f9cbad25
No related branches found
No related tags found
1 merge request!373SlyVote: New menu-driven configurator. Minor code refactor; no difference in functionality.
SlyVote SlyVote
Version 1.14 Version 1.15
Release date: 2023-09-20 Release date: 2023-09-20
by by
...@@ -98,15 +98,13 @@ SlyVote is comprised of the following files: ...@@ -98,15 +98,13 @@ SlyVote is comprised of the following files:
2. slyvote.cfg The SlyVote configuration file 2. slyvote.cfg The SlyVote configuration file
3. dd_lightbar_menu.js A JavaScript lightbar menu class used by SlyVote. 3. slyv_cfg.js A menu-driven configuration program for SlyVote. As an
You do not need to edit or use this file directly. alternative to editing slyvote.cfg, this configurator
You can keep this file in the SlyVote directory or can be run at the command prompt in the SlyVote
copy it to your sbbs/exec/load directory if it's directory with the following command:
not already there. This file has been added to jsexec slyv_cfg
Synchronet's CVS source code repository in Alternately:
sbbs/exec/load, so it may already be part of your jsexec slyv_cfg.js
Synchronet setup if you have updated your JavaScript
files.
slyvote.cfg is a plain text file, so it can be edited using any text editor. slyvote.cfg is a plain text file, so it can be edited using any text editor.
......
This diff is collapsed.
...@@ -186,6 +186,12 @@ ...@@ -186,6 +186,12 @@
* different sub-board. Refactored ReadConfigFile(). * different sub-board. Refactored ReadConfigFile().
* 2023-09-20 Eric Oulashin Version 1.14 * 2023-09-20 Eric Oulashin Version 1.14
* Fixed poll voting for single-answer polls * Fixed poll voting for single-answer polls
* 2023-12-10 Eric Oulashin Version 1.15
* Code refactor; no difference in functionality.
* Now uses js.exec_dir instead of the hack to find out
* what directory the script is running in.
* Now uses user.is_sysop rather than storing a global
* variable with an ARS check for "SYSOP".
*/ */
// TODO: Have a messsage group selection so that it doesn't have to display all // TODO: Have a messsage group selection so that it doesn't have to display all
...@@ -257,16 +263,8 @@ else ...@@ -257,16 +263,8 @@ else
var gAvatar = load({}, "avatar_lib.js"); var gAvatar = load({}, "avatar_lib.js");
// Version information // Version information
var SLYVOTE_VERSION = "1.14"; var SLYVOTE_VERSION = "1.15";
var SLYVOTE_DATE = "2023-09-20"; var SLYVOTE_DATE = "2023-12-09";
// Determine the script's startup directory.
// This code is a trick that was created by Deuce, suggested by Rob Swindell
// as a way to detect which directory the script was executed in. I've
// shortened the code a little.
var gStartupPath = '.';
try { throw dig.dist(dist); } catch(e) { gStartupPath = e.fileName; }
gStartupPath = backslash(gStartupPath.replace(/[\/\\][^\/\\]*$/,''));
// Characters for display // Characters for display
// Box-drawing/border characters: Single-line // Box-drawing/border characters: Single-line
...@@ -361,8 +359,6 @@ var ERROR_PAUSE_WAIT_MS = 1500; ...@@ -361,8 +359,6 @@ var ERROR_PAUSE_WAIT_MS = 1500;
var gBottomBorderRow = 23; var gBottomBorderRow = 23;
var gMessageRow = 3; var gMessageRow = 3;
var gUserIsSysop = user.compare_ars("SYSOP");
// Keyboard key codes for displaying on the screen // Keyboard key codes for displaying on the screen
var UP_ARROW = ascii(24); var UP_ARROW = ascii(24);
var DOWN_ARROW = ascii(25); var DOWN_ARROW = ascii(25);
...@@ -388,10 +384,10 @@ var gReaderKeys = { ...@@ -388,10 +384,10 @@ var gReaderKeys = {
goToLast: "L", goToLast: "L",
vote: "V", vote: "V",
close: "C", close: "C",
validateMsg: "A", // Only for the sysop
quit: "Q" quit: "Q"
}; };
if (gUserIsSysop)
gReaderKeys.validateMsg = "A";
var gSlyVoteCfg = ReadConfigFile(); var gSlyVoteCfg = ReadConfigFile();
if (gSlyVoteCfg.cfgReadError.length > 0) if (gSlyVoteCfg.cfgReadError.length > 0)
...@@ -1223,7 +1219,7 @@ function ReadConfigFile() ...@@ -1223,7 +1219,7 @@ function ReadConfigFile()
if (!file_exists(cfgFilename)) if (!file_exists(cfgFilename))
cfgFilename = file_cfgname(system.ctrl_dir, filename); cfgFilename = file_cfgname(system.ctrl_dir, filename);
if (!file_exists(cfgFilename)) if (!file_exists(cfgFilename))
cfgFilename = file_cfgname(gStartupPath, filename); cfgFilename = file_cfgname(js.exec_dir, filename);
var cfgFile = new File(cfgFilename); var cfgFile = new File(cfgFilename);
if (cfgFile.open("r")) if (cfgFile.open("r"))
{ {
...@@ -1676,7 +1672,7 @@ function GetMsgBody(pMsgbase, pMsgHdr, pSubBoardCode, pUser) ...@@ -1676,7 +1672,7 @@ function GetMsgBody(pMsgbase, pMsgHdr, pSubBoardCode, pUser)
// sysop now know to validate it. // sysop now know to validate it.
if (pSubBoardCode != "mail") if (pSubBoardCode != "mail")
{ {
if (gUserIsSysop && msg_area.sub[pSubBoardCode].is_moderated && ((pMsgHdr.attr & MSG_VALIDATED) == 0)) if (user.is_sysop && msg_area.sub[pSubBoardCode].is_moderated && ((pMsgHdr.attr & MSG_VALIDATED) == 0))
{ {
var validateNotice = "\x01n\x01h\x01yThis is an unvalidated message in a moderated area. Press " var validateNotice = "\x01n\x01h\x01yThis is an unvalidated message in a moderated area. Press "
+ gReaderKeys.validateMsg + " to validate it.\r\n\x01g"; + gReaderKeys.validateMsg + " to validate it.\r\n\x01g";
...@@ -2610,7 +2606,7 @@ function ViewVoteResults(pSubBoardCode) ...@@ -2610,7 +2606,7 @@ function ViewVoteResults(pSubBoardCode)
} }
else if (scrollRetObj.lastKeypress == gReaderKeys.validateMsg) else if (scrollRetObj.lastKeypress == gReaderKeys.validateMsg)
{ {
if (gUserIsSysop && msg_area.sub[pSubBoardCode].is_moderated) if (user.is_sysop && msg_area.sub[pSubBoardCode].is_moderated)
{ {
var validated = ValidateMsg(msgbase, pSubBoardCode, pollMsgHdrs[currentMsgIdx].number); var validated = ValidateMsg(msgbase, pSubBoardCode, pollMsgHdrs[currentMsgIdx].number);
console.gotoxy(1, console.screen_rows-2); console.gotoxy(1, console.screen_rows-2);
...@@ -3583,7 +3579,7 @@ function IsReadableMsgHdr(pMsgHdr, pSubBoardCode) ...@@ -3583,7 +3579,7 @@ function IsReadableMsgHdr(pMsgHdr, pSubBoardCode)
return false; return false;
// Let the sysop see unvalidated messages and private messages but not other users. // Let the sysop see unvalidated messages and private messages but not other users.
if (!gUserIsSysop) if (!user.is_sysop)
{ {
if ((msg_area.sub[pSubBoardCode].is_moderated && ((pMsgHdr.attr & MSG_VALIDATED) == 0)) || if ((msg_area.sub[pSubBoardCode].is_moderated && ((pMsgHdr.attr & MSG_VALIDATED) == 0)) ||
(((pMsgHdr.attr & MSG_PRIVATE) == MSG_PRIVATE) && !userHandleAliasNameMatch(pMsgHdr.to))) (((pMsgHdr.attr & MSG_PRIVATE) == MSG_PRIVATE) && !userHandleAliasNameMatch(pMsgHdr.to)))
...@@ -3711,7 +3707,7 @@ function DrawVoteColumns(pTopRow, pBottomRow, pColumnX1, pColumnX2) ...@@ -3711,7 +3707,7 @@ function DrawVoteColumns(pTopRow, pBottomRow, pColumnX1, pColumnX2)
// REturen value: Boolean - Whether deleting a poll is allowed // REturen value: Boolean - Whether deleting a poll is allowed
function PollDeleteAllowed(pMsgbase, pSubBoardCode) function PollDeleteAllowed(pMsgbase, pSubBoardCode)
{ {
var canDelete = gUserIsSysop || (pSubBoardCode == "mail"); var canDelete = user.is_sysop || (pSubBoardCode == "mail");
if ((pMsgbase != null) && pMsgbase.is_open && (pMsgbase.cfg != null)) if ((pMsgbase != null) && pMsgbase.is_open && (pMsgbase.cfg != null))
canDelete = canDelete || ((pMsgbase.cfg.settings & SUB_DEL) == SUB_DEL); canDelete = canDelete || ((pMsgbase.cfg.settings & SUB_DEL) == SUB_DEL);
return canDelete; return canDelete;
...@@ -3743,7 +3739,7 @@ function DisplayViewingResultsHelpScr(pMsgbase, pSubBoardCode) ...@@ -3743,7 +3739,7 @@ function DisplayViewingResultsHelpScr(pMsgbase, pSubBoardCode)
"\x01h\x01cEND \x01g: \x01n\x01cGo to the bottom of the text", "\x01h\x01cEND \x01g: \x01n\x01cGo to the bottom of the text",
"\x01h\x01cF \x01g: \x01n\x01cGo to the first poll", "\x01h\x01cF \x01g: \x01n\x01cGo to the first poll",
"\x01h\x01cL \x01g: \x01n\x01cGo to the last poll"]; "\x01h\x01cL \x01g: \x01n\x01cGo to the last poll"];
if (gUserIsSysop) if (user.is_sysop)
keyHelpLines.push("\x01h\x01cDEL \x01g: \x01n\x01cDelete the current poll"); keyHelpLines.push("\x01h\x01cDEL \x01g: \x01n\x01cDelete the current poll");
else if (PollDeleteAllowed(pMsgbase, pSubBoardCode)) else if (PollDeleteAllowed(pMsgbase, pSubBoardCode))
keyHelpLines.push("\x01h\x01cDEL \x01g: \x01n\x01cDelete the current poll (if it's yours)"); keyHelpLines.push("\x01h\x01cDEL \x01g: \x01n\x01cDelete the current poll (if it's yours)");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment