Sunday, 15 October 2017

How to copy from the Firefox Web console

In Firefox
Enter about:config in the address bar

scroll down to devtools.selfxss.count
Default value is 0

Double-click onvalue, and a dialog pops up
Change value to e.g. 1000


XMLHttpRequest : callbacks, status and ready codes

readystate  - is an event code
State  Description
0      The request is not initialized
1      The request has been set up
2      The request has been sent
3      The request is in process
4      The request is complete
status - is the HTML code returned from the server
200: "OK" 
403: "Forbidden"
404: "Page not found"
etc
( For a complete list : the Http Messages Reference at W3Schools
statusText - returns the text of the status code (e.g. "OK" or "Not Found")

In an XMLHttpRequest, the callback function is defined

e.g.
function getCompetition(aFileName) {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {   
       // callback function 
       // called when the XML request status changes
    if (this.readyState == 4 && this.status == 200) {   
       // only interested in the status change of the
       // request is both "request complete" and HTML "OK"
       competitionDoc = getDoc(this);
       console.log("competitionDoc: ", competitionDoc);
//       return anXHdoc;
    }
  };
  console.log("About to open the file");
  var d = new Date(); var t = d.getTime();
  xhttp.open("GET", aFileName + "?" + t , true);
  xhttp.send();
}

The callback function section of the function definition of the function containing the XMLHttpRequest (XHR for short from now on) is deferred until the callback is fired by the relevant event


onreadystatechange a property of the XHR.  Defines a function to be called when the readyState property changes aka the event-handler  to be used when the event occurs
readystatechange an event of XHR  Occurs when the readystate attribute changes
readystate an attribute of XHR

Acc, to W3Schools, if you have more than one AJAX task in a website, you should create one function for executing the XMLHttpRequest object, and one callback function for each AJAX task.

This sounds a bit like the refactoring of the requests I was planning on, but I'm not quite sure exactly what they mean.

Tuesday, 10 October 2017

Consequences of the BP Poule set up

We need to track the competitionUid for the fencers

We need to track the poolUid for the fencers

We need to retain the BP boutlist order

We need to return the bout scores using the fencers' competitionUids

Within Referee's <pool>.js
Store the BP pool IDs
Store the BP boutlist order
Store the fencers' competition Uids
Add a line of Final result with BP data -in <pool>-status.js
it requires:

BP fencers' competitionUid
Win or lose status
Score
BP bout number ( Match ID="n" )

So, do we convert in Referee or in Directoire?
Do we store the alt fencerIDs and the alt matchIDs in Referee, or do all the conversion in Directoire

There is no surety that BP uses the same boutlist order every time for a pool of a given size - in fact it is unlikely.

We therefore need to read the actual boutlist order provided by BP.


Current Referee <pool>-status.js info
///////////////////////////////////////////////////
// Bout 1 over 
///////////////////////////////////////////////////
currBout=1; boutStartTimes[1] = '2017-10-10T23:39:37.333Z';
currFencer1 = 1;  currFencer2 = 2;
boutScores[1][2] = 5;  boutScores[2][1] = 3;
boutVictors[1][2] = 'V';   boutVictors[2][1] = 'L';
boutStarted[1][2] = true ; boutStarted[2][1] = true ;
boutStartTimes[1] = '2017-10-10T23:39:37.333Z';
boutFinishTimes[1] = '2017-10-10T23:39:55.550Z';
///////////       ///////////////       ///////////


Current BP data for the same Bout
<Poule ID="1">
    <Tireur REF="1" NoDansLaPoule="1" NbVictoires="1" NbMatches="4" TD="5" TR="3" RangPoule="1"/>
    <Tireur REF="4" NoDansLaPoule="2" NbVictoires="0" NbMatches="4" TD="3" TR="5" RangPoule="5"/>
...
    <Match ID="7">
       <Tireur REF="4" Score="3" Statut="D"/>
       <Tireur REF="1" Score="5" Statut="V"/>
    </Match>
...
</Poule>



Store

JavaScript Testing resources


An Overview of JavaScript Testing in 2017
https://medium.com/powtoon-engineering/a-complete-guide-to-testing-javascript-in-2017-a217b4cd5a2a

JSUnit
http://www.jsunit.net/
a Unit Testing framework for client-side (in-browser) JavaScript.


Jasmine (JavaScript testing framework)
https://en.wikipedia.org/wiki/Jasmine_(JavaScript_testing_framework)
Jasmine is an open source testing framework for JavaScript.[4] It aims to run on any JavaScript-enabled platform, to not intrude on the application nor the IDE, and to have easy-to-read syntax. 

Jasmine
https://github.com/jasmine/jasmine/releases

DalekJS
http://dalekjs.com/index.html
http://dalekjs.com/pages/getStarted.html#install
Automated cross browser testing with JavaScript!



TrueSkill resources

The original MS posts
https://www.microsoft.com/en-us/research/project/trueskill-ranking-system/
https://www.microsoft.com/en-us/research/project/trueskill-ranking-system/?from=http%3A%2F%2Fresearch.microsoft.com%2Fmlp%2Ftrueskill%2Frankcalculator.aspx

Moserware resources - the most important
http://www.moserware.com/2010/03/computing-your-skill.html

A detailed implementation of the TrueSkill algorithm to go along with my "Computing Your Skill" blog post
https://github.com/moserware/Skills

The key codefile: 1 player versus 1 player
https://github.com/moserware/Skills/blob/master/Skills/TrueSkill/TwoPlayerTrueSkillCalculator.cs


http://www.moserware.com/assets/computing-your-skill/The%20Math%20Behind%20TrueSkill.pdf


An implementation in the F language
https://blogs.technet.microsoft.com/apg/2008/06/16/trueskill-in-f/


Glicko paper
http://www.glicko.net/glicko/glicko.pdf

Glicko2 paper
http://www.glicko.net/glicko/glicko2.pdf

Glicko 2 in Javascript for Node.js
https://www.npmjs.com/package/glicko2

Lots of good commenting in the code
Glicko2 in a node-InTheBrowser demo
https://npm.runkit.com/glicko2

How the .cotcot changes as the competition progresses

Initially:

Root node
CompetitionIndividuelle
  Tireurs
     Tireur <1>  there is no UID for each fencer
     etc - e.g.   <Tireur Nom="Appleton" Prenom="Anna" DateNaissance="01.03.2010" Sexe="F" Club="FiF North Merchiston" Licence="" Categorie="" Ranking="0" Rating="" Exporte="0" Statut="F"/>
 <Equipes/>
 <Arbitres/>
 <Phases PhaseEnCours="0">
  <ClassementGeneral PhaseID="1" ID=""/>
 </Phases>

Define formula of 1 round of pools - Phases is updated with a TourDePoules.  Phase IDs are re-shuffled

<Phases PhaseEnCours="0">
  <TourDePoules PhaseID="2" ID="Round 1" ScoreMax="5" RepartitionEquilibre="1" PhaseSuivanteDesQualifies="3"/>
  <ClassementGeneral PhaseID="3" ID=""/>
</Phases>

After Check-in is done, each fencer changes Statut attrib, from F to Q
<Tireur Nom="Appleton" Prenom="Anna" DateNaissance="01.03.2010" Sexe="F" Club="FiF North Merchiston" Licence="" Categorie="" Ranking="0" Rating="" Exporte="0" Statut="Q"/>

Move to Next Round (Round 1 pools).
Fencers get a UID attribute, ID="n"
  <Tireur ID="1" Nom="Appleton" Prenom="Anna" DateNaissance="01.03.2010" Sexe="F" Club="FiF North Merchiston" Licence="" Categorie="" Ranking="0" Rating="" Exporte="0" Statut="Q"/>

Within TourDePoules, there are a set of Tireur tags, one per fencer, using only a REF="n" attrib and a RangInitial="n" attribute
Then a Poule is added, with UID attribute ID="n"
within the pool, each fencer gets Pool results attributes
    <Tireur REF="1" NoDansLaPoule="3" NbVictoires="0" NbMatches="4" RangPoule="0"/>
They are listed in pool appearance order
The REF attribute is based on initial appearance in the /cotcot file

TourDePoules PhaseId="2" becomes
 <TourDePoules PhaseID="2" ID="Round 1" ScoreMax="5" RepartitionEquilibre="1" NbDePoules="1" PhaseSuivanteDesQualifies="3">
   <Tireur REF="4" RangInitial="1"/>
   <Tireur REF="2" RangInitial="2"/>
   <Tireur REF="1" RangInitial="3"/>
   <Tireur REF="5" RangInitial="4"/>
   <Tireur REF="3" RangInitial="5"/>
   <Poule ID="1">
    <Tireur REF="4" NoDansLaPoule="1" NbVictoires="0" NbMatches="4" RangPoule="0"/>
    <Tireur REF="2" NoDansLaPoule="2" NbVictoires="0" NbMatches="4" RangPoule="0"/>
    <Tireur REF="1" NoDansLaPoule="3" NbVictoires="0" NbMatches="4" RangPoule="0"/>
    <Tireur REF="5" NoDansLaPoule="4" NbVictoires="0" NbMatches="4" RangPoule="0"/>
    <Tireur REF="3" NoDansLaPoule="5" NbVictoires="0" NbMatches="4" RangPoule="0"/>
   </Poule>
  </TourDePoules>

Changing the avoid conflicts flag to "Club" changes the TourDePoules Attributes
Decalage="/club/"
  <TourDePoules PhaseID="2" ID="Round 1" ScoreMax="5" RepartitionEquilibre="1" Decalage="/club/" NbDePoules="1" PhaseSuivanteDesQualifies="3">

Belle Poule will either display by pools, or a list of fencers, in pool-fencer order, with the pool number displayed

Marking up one bout (bout 7) results in
Pool's Fencers are updated, if they were involved in a bout
NoDansLaPoule is their Pool idNum  REF is their competitionUid num
e.g.
<Tireur REF="1" NoDansLaPoule="1" NbVictoires="1" NbMatches="4" TD="5" TR="3" RangPoule="1"/>
The bouts are all added
Unscored bouts are added, with the two fencers identified by their competitionUid
e.g.
     <Match ID="1">
     <Tireur REF="1"/>
     <Tireur REF="2"/>
    </Match>
The two fencers involved in the bout have their results updated
e.g.
The two fencers are identified by their competition UID, NOT their number in the Pool
For the scored bout, scores and result are added as attributes.   Only the scored bout receives scores
e.g. 
    <Match ID="7">
     <Tireur REF="4" Score="3" Statut="D"/>
     <Tireur REF="1" Score="5" Statut="V"/>
    </Match>

One match is added for every one on the boutlist, in BP boutlist order


If you load in renamed versions of the earier status of the Competition .cotcot file, it happily accepts it.












NodeLists and HTMLCollections

If you use a selector, e.g. getElementsByTagName

it returns a HTMLCollection

This is (more or less) an array of items matching the selector.

What it makes really hard to do is access the children of the elements returned in the collection



e.g.

Tireurs
     Tireur tId="1"
     Tireur tId="2"
     etc


Actually, If they are all child nodes of a single element of an HTMLcollection, then simply 

TireursInASingleNode = xmlDoc.getElementsByTagName("Tireurs");

listOfFencers = TireursInASingleNode[0].getElementsByTagName("Tireur")
// get all the child elements of the 0th node in Tireurs







Monday, 9 October 2017

Details of the Belle Poule .cotcot file

It appears to be an FIE-standard XML file

Root tag CompetitionIndividuelle

Tag
CompetitionIndividuelle
Attrs
Couleur="#hhhhhh" Hex RGB code
ID="59d6f347"  <8 hexigits, as a string>
Annee="yyyy"
Arme="F" [or S or E, I'm guessing]
Sexe="FM" [I'm guessing the other options are "F" or "M"]
Categorie="M13" [for Moins de 13? - Under 13]
Niveau="X" [???]
Date="dd.mm.yyyy"
Appel="11:00"
Scratch="11:20"
Debut="11:30"
TitreLong="PaFF Trial 3"
URLorganisateur="http://paff.uk.to"
ScoreAleatoire="0"
TailleMinimaleEquipe="3"
ClassementDefautEquipe="9999"
ClassementManuel="0"
Lieu="Edinburgh"


FENCERS

Fencers ("Tireurs")
Statut
= Status

"F"
Entered, not checked-in
"Q"
Checked-in

Sexe
= Gender   "M" or "F"

Nom
= Surname (last name in the import file)

Prenom
=First Name

Equipe
= Team within a Club

DateNaissance
DoB, in the date format of BP's host

Nation
Ligue
Club
Categorie
Ranking  All set to "0"
Rating
Exporte  All set to "0"

Equipes

i.e. Teams - within clubs

Arbitres

Referees

Phases 

Attributes
PhaseEnCours="0"

Tags Within Phases

TourDePoules (Pools round)

PhaseID="2"
ID="Round #1" /* user input in Preferences */
ScoreMax="5"
RepartitionEquilibre="1"
PhaseSuivanteDesQualifies="3"

PhaseDeTableaux (DE)

PhaseId="3"
ID=""
ScoreMax="10"
PlaceTirees="0"

Classement General  (Final results?)

PhaseId="4"
ID="4"

</Phases>

So within phases, each round is set up (whether pools or DE) , and then the Final the Pools or DE is set up, then the final results

Questions: What happens when you change the Max Score for a round of Pools, after it has been previously set up?


Originally, test data was
Pools - 1 round
DE

And there was Pools PhaseId 2
DE Phase ID 3
Classification PhaseId 4

On deleting the DE table in BP, it was removed from the Phases, and the follwing Phases had their PhaseID decreased by 1

Adding a second round of pools to the formula forces teh pools for the first round of pools to be defined.

Getting the info by name from the whole document means that that I pick up the Tireur tags in TourDePoules and Poule as  well as in Tireur






Saturday, 7 October 2017

TrueSkill Calculator

Here is an implementation of TrueSkill in C#

This is the simplest implentation - 1 player versus one player

https://github.com/moserware/Skills/blob/master/Skills/TrueSkill/TwoPlayerTrueSkillCalculator.cs

Loading XML data into the browser

Implicit rules for XML


It requires an encoding defintition in the <xml> statement
To be loaded as a unity, it requires a top-level node - e.g. "catalog" in "books.xml"

The file suffix must be .xml
Re-naming a valid .xml file with a different suffix causes a null object to be returned.



That node

The XML file needs to be suffixed as .xml

The load process for a Belle Poule .cotcot file is currently

Save the .cotcot file into the appropriate /org/<org>/<competition>/[<event>/] folder in CK

How do you do that, when BP is storing locally, and CK is remote?


Copy the .cotcot file, changing its suffix to .xml

Load the .xml into the browser




On save, save as .xml

Copy the .xml file, and rename to <prevFileName>suffix.cotcot

Load into BP




Thursday, 21 September 2017

Bringing the Test and Dev repositories back into line with the long-term stable Production

The Production repository of April 2016 has been live and stable for 17 months now, and I'd forgotten what I'd been up to in Dev.

So I wanted to overwrite the Dev and Test with Production, but without losing the changesets graph and numbering.

However, there was a problem. The Production repository decided it was no longer matched to the Dev and Test ones.

So...
I copied the Production directory, to get a complete back-up, including pools data.

I over-wrote the files in Dev directory with the files from Production (excepting the .hg files).
I checked everything that had changed, keeping notes in Notepad of the interesting stuff.
I committed the changes in Dev, then pull/update-d them into Test.
I cloned Test to create a new Production.

This in effect took Dev and Test back to Commit 511.

This will require re-writing the Dev changes in Commits 512 to 519.






Wednesday, 20 September 2017

Eliminated the "Loading" text

What I did

I've commented out both of them from  templates/gawainRefHead-L3.phtml file in Test

Result

This eliminates the "loading" text.
and eliminates the vertical scrolling on the screen
The screen was sized to the viewport. "loading" appeared below the viewport, which made the webpage larger than 1 screen.

Resolves Issues  

101,116, (get rid of 'loading' and a duplicate), and
222,223,225, hunting for and eliminating the .map files I thought were the cause.

Tests

Tested for existing pools - 
PaFF/PaFF_20/Rd P4
Test/20170920/of_4
Created a new pool
Test/20170920/of_7

Test results : only observed difference was a lack of the "loading" text.

Test Conclusion

Only jQuery has been used to date, jQuery Mobile has been loaded, but not been used.

Why it worked 

ClubKnight currently loads  jQuery Mobile 1.3.1
jQuery Mobile is supposed to automagically load its .css files.  (For styling and for structure)
It was not loading any .css files in ClubKnight.

jQuery Mobile includes a "Loading" screen while the web page is loading, containing <H1>loading</H1>

jQuery Mobile's Css files include a version which only contains the structure, but not any of the themes, to allow you to hand-roll styling for the UI elements, while accessing the structural widgets.

The version for ClubKnight is
http://code.jquery.com/mobile/1.3.1/jquery.mobile.structure-1.3.1.css

I can't find where the .css  gets specified, so I don't know how to
a) load the .css from the local server
b) specify that particular version

I looked through the jQuery Mobile.js - did not see any loading instructions.

Alternatives tried

I tried manually loading the relevant .css file.  This overwrote the button styling I had created.

Sunday, 10 September 2017

Minifying my own .js files.

functions.js

is now stored as two versions:  functions.max.js (the version that I am creating) and functions.min.js (the minified version)

Depending on the stage I'm in, I copy the appropriate one into functions.js

Functions.js gets loaded by the poolsheets.

According to minifierUsed.txt in GawainDocumentation:
Minifier used.
http://refresh-sf.com/

Thursday, 7 September 2017

ClubKnight servers and Mercurial Repositories - which is which

The repositories at present 2017-09-07

Production server
To start: desktop shortcut "Mongoose 5.5. on D"

Files stored in
web url:
   http://clubknight.uk/
file location
   D:\Mongoose\webroot\
Mercurial repository named:
   web_root

web url:
    http://clubknight.uk/trial
file location
    D:\Mongoose\webroot\trial
Mercurial repository named:
    trialOnD

To back up production system data, copy:
   D:\Mongoose\webroot\ 
      to 
   M:\D-Mongoose Backup

Development server
To start: ???
web url:
   ???
file location:
   either
Mercurial repository:  gawainDev-Dev
 
Test Server
To start: desktop shortcut "Mongoose 5.5. on M"
http://clubknight.uk:8080/trial
M:\webroot\trial
Mercurial:  trialOnM