Difference between revisions of "The DRAFT1846Start Page"

From BOARD18 Project WIKI
Jump to navigation Jump to search
(added index)
(→‎function newDraftOK(response): reflect adition of new function)
Line 57: Line 57:
== function newDraftOK(response) ==
== function newDraftOK(response) ==
Function newDraftOK is the success callback function for  
Function newDraftOK is the success callback function for  
the ajax php/makeDraft.php call.  
the ajax makeDraft.php call. It checks for a failure
and then reports the new draft ID to the start page.
Finally it adds a psudorandom url key to the array for
each player and calls the updatedraft.php function.
 
The php/makeDraft.php call returns the numeric draft_id of  
The php/makeDraft.php call returns the numeric draft_id of  
the new table row or the integer 0 if a failure occurred.
the new table row or the intiger 0 if a failure occured.
The newDraftOK function checks for a failure (0)
 
and then reports the new draft ID to the start page.
== function updtDraftResult(result) ==
Finally it calls the emailConfirmation.php function.
Function updtDraftResult is the success callback function 
for the ajax updtDraft.php call made by the newDraftOK()
function. It checks for a failure or a collision
and then it calls the emailConfirmation.php function.
 
Output from updateDraft is an echo return status of
"success", "collision" or "fail".


== function startupEmailsResult(response) ==
== function startupEmailsResult(response) ==

Revision as of 11:21, 24 May 2020

DRAFT1846 Design edit


Control is transferred to the draft1846Start page from the index page. The index page also supplies the number of players the draft1846Start page as a URL parameter.
The draft1846Start page displays a form in to which the names and email addresses of the players should be entered. For less than 5 players, it also displays a selection box which should be used to select the unused privates.

function SetupDraft()

The SetupDraft function uses the functions below to setup a new draft by creating a new row in the draft_table and then sending a confirmation email to each player in the draft.

function makeDeck()

The makeDeck function sets up a D1846.deck array with all private companies present in the array. It then removes the privates that will not be used in the game. Then it adds the required number of blank cards to the array. And finally it shuffles the array.

function shuffle(array)

Function shuffle is used to shuffle a javascript array. I found various forms of this function on many web pages. This particular one is a modified version of the function shown on the javascript.info page at https://javascript.info/task/shuffle

The shuffle function accepts an array as input and shuffles the array in place.

function purgeitem(array, item)

Function purgeitem is used to remove an item from a javascript array.

The purgeitem function accepts two parameters:

  1. The first is the array that will be modified.
  2. The second is the item that will be removed.

The function modifies the array in place.

function makePinfo()

The makePinfo function sets up the D1846.nlist array and the D1846.elist array by accessing the player name and email addresse fields from the setup form on the draft1846Start page. It also checks for duplicate names.

function makeDraftRow()

Function makeDraftRow creates "D1846.draft", and then uses JSON.stringify to convert it to the JSON component of the new draft_table row for this usage of DRAFT1846. It then does an ajax call to makeDraft.php.

function newDraftOK(response)

Function newDraftOK is the success callback function for the ajax makeDraft.php call. It checks for a failure and then reports the new draft ID to the start page. Finally it adds a psudorandom url key to the array for each player and calls the updatedraft.php function.

The php/makeDraft.php call returns the numeric draft_id of the new table row or the intiger 0 if a failure occured.

function updtDraftResult(result)

Function updtDraftResult is the success callback function for the ajax updtDraft.php call made by the newDraftOK() function. It checks for a failure or a collision and then it calls the emailConfirmation.php function.

Output from updateDraft is an echo return status of "success", "collision" or "fail".

function startupEmailsResult(response)

Function startupEmailsResult is the call back function for the ajax calls to emailConfirmation.php. It will have to process returns from multiple emails for the same call. It only needs to check for errors and it only needs to report the first error.