====== SlyVote ======
[[https://gitlab.synchro.net/main/sbbs/-/tree/master/xtrn/slyvote|SlyVote]] is a voting booth door for Synchronet (written in JavaScript) for viewing and voting on polls, as well as creating polls.  SlyVote makes use of the voting feature added in Synchronet 3.17 and also supports displaying of avatars for the people who post polls (avatars were also added in Synchronet 3.17).

===== Getting SlyVote =====
SlyVote is in the ''[[dev:Git]]'' and can be downloaded from the SlyVote directory within ''[[dir:xtrn]]'' ([[https://gitlab.synchro.net/main/sbbs/-/tree/master/xtrn/slyvote?ref_type=heads|Git repository link]])

===== Minimum Synchronet version and .js scripts =====
SlyVote requires Synchronet 3.17 or newer and makes use of the following JavaScript scripts (in the ''[[dir:exec]]''/load directory) :\\
  * sbbsdefs.js
  * text.js
  * frame.js
  * scrollbar.js
  * dd_lightbar_menu.js (''[[custom:javascript:lib:ddlightbarmenu.js]]'')
  * smbdefs.js
  * avatar_lib.js

In addition, SlyVote has an option to post a poll, which executes postpoll.js (in the ''[[dir:exec]]'' directory).

SlyVote requires an ANSI terminal, since SlyVote makes use of lightbar menus which do cursor movement, as well as a scrolling frame to display poll results.
===== Installation =====
First, ensure that you have an up-to-date Synchronet system running Synchronet 3.17 or higher, and ensure that your Synchronet JavaScript files in sbbs/''[[dir:exec]]''/load are up to date (it wouldn't hurt to also ensure your .js files in your ''[[dir:exec]]'' directory are also up to date).  The easiest way to update your JavaScript files would probably be to download [[ftp://vert.synchro.net/Synchronet/sbbs_run.zip|sbbs_run.zip from Vertrauen]], extract that somewhere, and then copy the .js files from ''[[dir:exec]]'' and ''[[dir:exec]]''/load to your sbbs/exec and sbbs/exec/load directories.

Synchronet 3.17 can be downloaded from [[http://vert.synchro.net|Vertrauen]] (the home BBS of Synchronet).  The fresh install of Synchronet 3.17 is [[ftp://ftp.synchro.net/sbbs317b.zip]], and the upgrade package is [[ftp://ftp.synchro.net/sbup317b.zip]].  After installing Synchronet 3.17, if you want to use the latest daily-built (beta) Synchronet binaries, you can download [[ftp://vert.synchro.net/Synchronet/sbbs_dev.zip|sbbs_dev.zip]] for Windows or [[ftp://vert.synchro.net/Synchronet/sbbs_dev.tgz|sbbs_dev.tgz]] for Linux.  If you want to build it yourself on Linux, see ''[[install:nix]]'' for instructions.  See ''[[install:dev]]'' for more information on updating to the latest development build of Synchronet.

SlyVote should run faster if you use a Synchronet build from April 6, 2019 or newer.  That beta build added a new JavaScript function (MsgBase.get_index()) which SlyVote makes use of if available when checking messages in the sub-boards to see if they are poll votes.

SlyVote is comprised of the following files:
  * slyvote.js: The SlyVote script
  * slyvote.cfg: The SlyVote configuration file
  * slyv_cfg.js: A menu-driven configuration program for SlyVote. As an alternative to editing slyvote.cfg, this configurator provides a text-mode menu interface to configure SlyVote.
The menu-driven configurator can be run at the command prompt in the SlyVote directory with the following command:
    jsexec slyv_cfg
Alternately:
    jsexec slyv_cfg.js

slyvote.cfg is a plain text file, so it can be edited using any text editor.

You can copy slyvote.js and slyvote.cfg to a directory of your choice.  slyvote.cfg, if it exists in these directories, will be read from these directories in order:
sbbs/mods
sbbs/ctrl
Same directory as slyvote.js

Also, SlyVote also depends on dd_lightbar_menu.js, which should exist in your sbbs/''[[dir:exec]]''/load directory.
===== Configuration with Synchronet =====
Run SCFG (Synchronet configuration) and add the following configuration to [[util:SCFG]]->External Programs->Online Programs (Doors) in the section of your choice.  Note that this assumes SlyVote is installed in sbbs/xtrn/slyvote.
  Name                            SlyVote Voting Booth
  Internal Code                   SLYVOTE
  Start-up Directory              ../xtrn/slyvote
  Command Line                    ?slyvote.js
  Clean-up Command Line           
  Execution Cost                  None
  Access Requirements             ANSI
  Execution Requirements          
  Multiple Concurrent Users       Yes
  Intercept I/O                   No                                
  Native Executable               No                                
  Use Shell to Execute            No                                
  Modify User Data                No
  Execute on Event                No
  Pause After Execution           No
  BBS Drop File Type              None
  Place Drop File In              Node Directory

===== Configuration file =====
SlyVote can be configured to use a single sub-board or multiple sub-boards, allowing the user to choose a sub-board and vote on polls and view poll results in the various sub-boards configured with SlyVote.
SlyVote's configuration file has the following options:
^ Setting                         ^ Description^
| showAvatars                     | Whether or not to show avatars of the people who post polls in the results. Valid values are true and false. Defaults to true. |
| useAllAvailableSubBoards        | Whether or not to use all available sub-boards where voting is enabled. Valid values are true and false.  This defaults to true.  If this is set to true, then any subBoardsCodes values in the configuration file (described below) will be ignored. |
| subBoardCodes                   | A comma-separated list of internal sub-board codes specifying which sub-board or sub-boards to use for polls.  A single sub-board code can be specified if you only want to use one sub-board with SlyVote.  Also, subBoardCodes can appear multiple times in slyvote.cfg, and all specified sub-boards will be used.  If any of the specified sub-board codes don't exist or refer to sub-boards that don't allow voting, then they will not be used. |
| startupSubBoardCode             | Optional: An internal sub-board code for a sub-board to automatically start in if there are multiple sub-boards configured.  If this is set, SlyVote will not prompt the user for a sub-board on startup and will start in the sub-board specified by this setting. |

===== Additional notes for sysops =====
For sysops, polls can be deleted when viewing results from SlyVote.\\
\\
SlyVote uses the following lines from Synchronet's text.dat file (located in the sbbs/ctrl directory):
  * 120 (CantPostOnSub)
  * 503 (SelectItemWhich)
  * 759 (CantReadSub)
  * 779 (VotingNotAllowed)
  * 780 (VotedAlready)
  * 781 (R_Voting)
  * 787 (PollVoteNotice)
  * 791 (BallotHdr)

===== See Also =====
  * [[:howto:door:|howto:door index]]

{{tag>}}
