projects:vote

Vote

todo:

content:

vote.txt jun 2026

vote.txt

reverse engineering

html/svc.php -> php/svchub.php -> getprofile,putprofile

html/account/svc.php -> php/account/svchub.php -> register,verify,forgotpassword,etc.


model of singleton objects

user.js - voyc.User, represents logged-in user

view.js - voyc.View, subscribes to nav requests: home, about, account, profile

model.js - voyc.Model, meant to be main driver for app (start with model app, then rename)

account.js - voyc.Account, account svc driver.  submits svc requests and receives data back.

accountview.js - voyc.AccountView, account ui driver

vote.js - voyc.Vote, app driver



todo:
define html components: account, vote
get nav to work in view.js
resolve vote and model
resolve Observer vs Event

webdev svc castballot makes call to webprod, hardcoded in vote.js 
	model.js does it correctly

x shell script in ~/webdev/disable_dev.sh

castballot.php - 
	input: electionid (int), votes (string of ints)
	insert into vote.vote (userid, electionid, votes) ...;
	
	select id, name, party from vote.candidate where electionid = $1;
	shuffle

	select votes from vote.vote where electionid = $1;
	build array of votes
	count votes in rounds
	
	output: candidates, results 

validate.php - 
	function validateInteger()
	function validateArrayOfIntegers()

-------------------

vote.js
voyc.Vote()

this.comm = Comm() instantiate Comm object

getElection(electionid)
	svc castballot return candidates, results
	drawElection
		show heading "2016 USA Pres"
	drawBallot
		get candidates from svc, 
		those who are ranked: sort by rank, 
		draw in a loop
		those not yet ranked: sort by random
		draw in a loop
		enable the Cast Ballot button
	drawResults
		get results returned from svc
		display the winner
		display the rounds details in a table
		
	nav.replace('ballot')  nav.replace using webprod/vote/.../jslib/nav.js object

on load, new voyc.Vote()

--------------------

model.js
voyc.Model()

instantiate self and object model: View, User, Account, AccountView

instantiate Observer

instantiage BrowserHistory and pagedraw() function

instantiate Comm  

subscribe to events: set/getProfile requessted, submitted, posted, received

--------------------

index.html

header - leftnav, headeruser

section content-container
	section content-home
		section ballot
		section results
	section content-about
	section content-profile

3 modeless dialogs
	leftnav
	header user
	unused settings
modal container
9 modal dialogs - all used by account

footer - two logo links


--------------------

usage:
<insert from readme>
mv model.js to vote.js
substitute vote.Model to voyc.Vote


Event  pub/sub
Observer  pub/sub

terminology
Observer
Pub/Sub
Data Binding
Message Queue
Event-driven architecture
decoupled
Listener
dispatcher

Observer/Observeable
addEventListener/dispatchEvent
Publisher/Subscriber
Send/Receive


table

singleton object that runs it all
subscriber/listener/receiver
publisher/

verb, doer

dispatcher

manager      thingie         list         action               actor          action           actor
window       event           queue        addEventListener()   listener       dispatchEvent    dispatcher
Observer     note            stack        subscribe()          subscriber     publish()        publisher
Event        <parameters>    events       subscribe()          subscriber     publish()        publisher
             message         queue        send or xmit         sender         receive          receiver

two lists
1. list of subscribers or listeners
2. queue of published messages or events that can be processed asynchronously

-------------------------------

original version, plus:
	account management: login, register, etc
	one vote per user, can be changed
	multiple elections
	election results vs rounds detailed results

election menu
ballot
results
detailed results
about