Highlight Wins Tied first place.

Hi Colin,

I have been using the Highlight wins effect and this weekend we had a tie in a race for first so scored 1.5. and was not highlighted.

I managed to amend (bodge) the effect below, is it possible to do a better job with a wild card eg 1.*, I tried but my java skills are nonexistent.

var winsText = ‘1.5’;

var winsText2 = ‘1.0’;

var winsColour = ‘#ffd700’;

var winsSelector = ‘.summarytable td’;

$(function () {

$(winsSelector).filter(function() {

return $(this).text() === winsText ;

}).css(“background”, winsColour);

});

$(function () {

$(winsSelector).filter(function() {

return $(this).text() === winsText2 ;

}).css(“background”, winsColour);

});

Cheers

Keith

In a way the effect itself is already a bodge because it assumes so much but $(this).text() == could be replaced with something like:-

($(this).text().split(’.’))[0] ==

to grab the 1 from 1.*

···

On Mon, Jun 27, 2016 at 10:58 AM, keithsykes69@yahoo.com [sailwave] sailwave@yahoogroups.com wrote:

Hi Colin,

I have been using the Highlight wins effect and this weekend we had a tie in a race for first so scored 1.5. and was not highlighted.

I managed to amend (bodge) the effect below, is it possible to do a better job with a wild card eg 1.*, I tried but my java skills are nonexistent.

var winsText = ‘1.5’;

var winsText2 = ‘1.0’;

var winsColour = ‘#ffd700’;

var winsSelector = ‘.summarytable td’;

$(function () {

$(winsSelector).filter(function() {

return $(this).text() === winsText ;

}).css(“background”, winsColour);

});

$(function () {

$(winsSelector).filter(function() {

return $(this).text() === winsText2 ;

}).css(“background”, winsColour);

});

Cheers

Keith

Cheers,

Colin J

http://op12no2.me

or use

parseInt($(this).text()) < 2.0

instead

CJ

···

On Mon, Jun 27, 2016 at 10:58 AM, keithsykes69@yahoo.com [sailwave] sailwave@yahoogroups.com wrote:

Hi Colin,

I have been using the Highlight wins effect and this weekend we had a tie in a race for first so scored 1.5. and was not highlighted.

I managed to amend (bodge) the effect below, is it possible to do a better job with a wild card eg 1.*, I tried but my java skills are nonexistent.

var winsText = ‘1.5’;

var winsText2 = ‘1.0’;

var winsColour = ‘#ffd700’;

var winsSelector = ‘.summarytable td’;

$(function () {

$(winsSelector).filter(function() {

return $(this).text() === winsText ;

}).css(“background”, winsColour);

});

$(function () {

$(winsSelector).filter(function() {

return $(this).text() === winsText2 ;

}).css(“background”, winsColour);

});

Cheers

Keith

Cheers,

Colin J

http://op12no2.me

Hi Keith,

Colin has replied - In reality it is complicated in that it applies to 1.5 2.5 and 3.5 and if it was more than 2 boats drawing then there are others as well

As a quick hack you could have something like this which handles 2.5 as well

//

// name=HighlightWins3

// dependencies=jQuery

// description=Highlight winning scores in summary tables.

// author=Jon Eskdale based on an idea by Colin Jenkins

// date=2015-08-30 2016-06-27

// version=1.7

// url=http://sailwave.com

// email=jon@sailwave.com

// twitter=eskdale

// comments=Edit colours to colours of your choice

//

$(document).ready(function() {

var winsSelector = ‘.summaryrace’;

var winsText = /\b1.0/;

var oneHalfText = /\b1.5/;

var twoText = /\b2.0/;

var twoHalfText = /\b2.5/;

var threeText = /\b3.0/;

// Edit these colours to change the highlight colours for 1st, 2nd and 3rd

var winsColour = ‘#ffd700’;

var twoColour = ‘#6a91c5’;

var threeColour = ‘#da6841’;

//var twoColour = ‘#ffe768’;

//var threeColour = ‘#fff0a1’;

// create array of race column numbers for first table (summarytable)

var ths = document.getElementsByTagName(‘col’);

var column =[];

for (var i=0; i<ths.length; i++) {

if (ths[i].classList[0] === "race") {

	column.push(i);

} else {

	if (column.length !=0) {

		break;

	}

}

}

//console.log(column);

// Set a class of summaryrace for all race cells in summary table body

//

for (var i=0; i<column.length; i++) {

$(".summarytable tbody tr td:nth-child(" + (column[i]+1) +")").addClass("summaryrace");

}

// Change the background color for cells with class of summaryrace and that match regular expression text

$(function () {

$(winsSelector).filter(function() {

return winsText.test($(this).text());

}).css(“background”, winsColour);

$(winsSelector).filter(function() {

return twoText.test($(this).text());

}).css(“background”, twoColour);

$(winsSelector).filter(function() {

return threeText.test($(this).text());

}).css(“background”, threeColour);

$(winsSelector).filter(function() {

return oneHalfText.test($(this).text());

}).css(“background”, winsColour);

$(winsSelector).filter(function() {

return twoHalfText.test($(this).text());

}).css(“background”, twoColour);

});

});

In the longer term I think the solution is to use version 2.22.1 of Sailwave available here in Beta https://dl.dropboxusercontent.com/u/220425/sailwave.exe - I haven’t released it officially yet as I wanted to do some testing and its not just a case of changing the .exe

In this version Sailwave can automatically adds a class to the table boxes for first second and third to do this you need to update the template.

For example

Results.htm in the Templates directory would end like this:-

string.set("race.start.windstrength", "Wind strength: ")

string.set("race.start.windspeed", "Ave wind: ")

string.set("[summary.col.race.rank1.td](http://summary.col.race.rank1.td)", "rank1")

string.set("[summary.col.race.rank2.td](http://summary.col.race.rank2.td)", "rank2")

string.set("[summary.col.race.rank3.td](http://summary.col.race.rank3.td)", "rank3")

html.include('header.txt')

html.resultswiz()

html.include('footer.txt')

There are three additional lines. You can see that rank1, rank2, rank3 are being added as classes.

The javascript will then only have to check for these classes and colour them appropriately, so it should handle all automatically and possibly even allow it to be coloured using css or a much simpler javascript (The existing javascript won’t work)

If anyone feels like experimenting please do and let me have any feedback before I make the release official.

Jon

···

On 27 June 2016 at 10:58, keithsykes69@yahoo.com [sailwave] sailwave@yahoogroups.com wrote:

Hi Colin,

I have been using the Highlight wins effect and this weekend we had a tie in a race for first so scored 1.5. and was not highlighted.

I managed to amend (bodge) the effect below, is it possible to do a better job with a wild card eg 1.*, I tried but my java skills are nonexistent.

var winsText = ‘1.5’;

var winsText2 = ‘1.0’;

var winsColour = ‘#ffd700’;

var winsSelector = ‘.summarytable td’;

$(function () {

$(winsSelector).filter(function() {

return $(this).text() === winsText ;

}).css(“background”, winsColour);

});

$(function () {

$(winsSelector).filter(function() {

return $(this).text() === winsText2 ;

}).css(“background”, winsColour);

});

Cheers

Keith

Jon Eskdale
07530 112233

Skype “eskdale”

OK - this morning I got around to writing the javascript to go with this:-

You can download the beta script from here:- https://dl.dropboxusercontent.com/u/220425/HighlightWins3v3.js

This one I hope should keep everyone happy as it will work with different number of races per fleet and any number of draws.

Basically it is working on Rank but with the option to not highlight if any of a range of codes are used. So that, if you have only 2 finishers in a race the rest of the competitors will be ranked third but as DNC and DNF etc are specified as not to highlight in the script, then they won’t be highlighted. Of course if you think that you want to highlight them because they were strictly third then you can by editing just the single line. One code you might want to add or maybe not is OOD if you add it then only competitors that raced will be highlighted - you decide.

So to test this out use Sailwave 2.22 https://dl.dropboxusercontent.com/u/220425/sailwave.exe and overwrite the one in the Program Files (x86)\Sailwave.

also make sure you have the extra lines in the Results.htm file which is stored in the template directory you can download this file from https://dl.dropboxusercontent.com/u/220425/Results.htm to save you editing it.

The script goes in the Javascript directory. Then select it as an effect when you publish

Let me know what you think and if you are happy I’ll generate a full installer for everyone.

//

// name=HighlightWins3v3

// dependencies=jQuery

// description=Highlight winning scores in summary tables.

// author=Jon Eskdale based on an idea by Colin Jenkins

// date=2016-07-04

// version=3.0 For use with Sailwave from V2.22.x

// Requires the following lines in the Results.htm file (Results.htm is in the Templates directory)

// string.set(“summary.col.race.rank1.td”, “rank1”)

// string.set(“summary.col.race.rank2.td”, “rank2”)

// string.set(“summary.col.race.rank3.td”, “rank3”)

// url=http://sailwave.com

// email=jon@sailwave.com

// twitter=eskdale

// comments=Edit colours to colours of your choice

//

$(document).ready(function() {

var selectorRank1 = ‘.rank1’;

var selectorRank2 = ‘.rank2’;

var selectorRank3 = ‘.rank3’;

// Results with these codes will not get highlighted add or remove codes to your choice

var ignoreText = /^(?!.\b(DNC|DNF|DNS|OCS|BFD|UFD|RET|DSQ|DGM|DNE)\b)./i

// Edit these colours to change the highlight colours for 1st, 2nd and 3rd

var winsColour = ‘#ffd700’;

var twoColour = ‘#6a91c5’;

var threeColour = ‘#da6841’;

// Change the background color for cells with class of rank1-3 and don’t have a code specified

$(function () {

$(selectorRank1).filter(function() {

return ignoreText.test($(this).text());

}).css(“background”, winsColour);

$(selectorRank2).filter(function() {

return ignoreText.test($(this).text());

}).css(“background”, twoColour);

$(selectorRank3).filter(function() {

return ignoreText.test($(this).text());

}).css(“background”, threeColour);

});

});

···

On 27 June 2016 at 15:37, Jon Eskdale jon@eskdale.org wrote:

Hi Keith,

Colin has replied - In reality it is complicated in that it applies to 1.5 2.5 and 3.5 and if it was more than 2 boats drawing then there are others as well

As a quick hack you could have something like this which handles 2.5 as well

//

// name=HighlightWins3

// dependencies=jQuery

// description=Highlight winning scores in summary tables.

// author=Jon Eskdale based on an idea by Colin Jenkins

// date=2015-08-30 2016-06-27

// version=1.7

// url=http://sailwave.com

// email=jon@sailwave.com

// twitter=eskdale

// comments=Edit colours to colours of your choice

//

$(document).ready(function() {

var winsSelector = ‘.summaryrace’;

var winsText = /\b1.0/;

var oneHalfText = /\b1.5/;

var twoText = /\b2.0/;

var twoHalfText = /\b2.5/;

var threeText = /\b3.0/;

// Edit these colours to change the highlight colours for 1st, 2nd and 3rd

var winsColour = ‘#ffd700’;

var twoColour = ‘#6a91c5’;

var threeColour = ‘#da6841’;

//var twoColour = ‘#ffe768’;

//var threeColour = ‘#fff0a1’;

// create array of race column numbers for first table (summarytable)

var ths = document.getElementsByTagName(‘col’);

var column =[];

for (var i=0; i<ths.length; i++) {

if (ths[i].classList[0] === “race”) {

  column.push(i);

} else {

  if (column.length !=0) {
  	break;
  }

}

}

//console.log(column);

// Set a class of summaryrace for all race cells in summary table body

//

for (var i=0; i<column.length; i++) {

$(".summarytable tbody tr td:nth-child(" + (column[i]+1) +")").addClass(“summaryrace”);

}

// Change the background color for cells with class of summaryrace and that match regular expression text

$(function () {

$(winsSelector).filter(function() {

return winsText.test($(this).text());

}).css(“background”, winsColour);

$(winsSelector).filter(function() {

return twoText.test($(this).text());

}).css(“background”, twoColour);

$(winsSelector).filter(function() {

return threeText.test($(this).text());

}).css(“background”, threeColour);

$(winsSelector).filter(function() {

return oneHalfText.test($(this).text());

}).css(“background”, winsColour);

$(winsSelector).filter(function() {

return twoHalfText.test($(this).text());

}).css(“background”, twoColour);

});

});

In the longer term I think the solution is to use version 2.22.1 of Sailwave available here in Beta https://dl.dropboxusercontent.com/u/220425/sailwave.exe - I haven’t released it officially yet as I wanted to do some testing and its not just a case of changing the .exe

In this version Sailwave can automatically adds a class to the table boxes for first second and third to do this you need to update the template.

For example

Results.htm in the Templates directory would end like this:-

string.set("race.start.windstrength", "Wind strength: ")

string.set("race.start.windspeed", "Ave wind: ")

string.set("[summary.col.race.rank1.td](http://summary.col.race.rank1.td)", "rank1")

string.set("[summary.col.race.rank2.td](http://summary.col.race.rank2.td)", "rank2")

string.set("[summary.col.race.rank3.td](http://summary.col.race.rank3.td)", "rank3")

html.include('header.txt')

html.resultswiz()

html.include('footer.txt')

There are three additional lines. You can see that rank1, rank2, rank3 are being added as classes.

The javascript will then only have to check for these classes and colour them appropriately, so it should handle all automatically and possibly even allow it to be coloured using css or a much simpler javascript (The existing javascript won’t work)

If anyone feels like experimenting please do and let me have any feedback before I make the release official.

Jon

Jon Eskdale

03333 443377

07530 112233

Jon Eskdale
07530 112233

Skype “eskdale”

On 27 June 2016 at 10:58, keithsykes69@yahoo.com [sailwave] sailwave@yahoogroups.com wrote:

Hi Colin,

I have been using the Highlight wins effect and this weekend we had a tie in a race for first so scored 1.5. and was not highlighted.

I managed to amend (bodge) the effect below, is it possible to do a better job with a wild card eg 1.*, I tried but my java skills are nonexistent.

var winsText = ‘1.5’;

var winsText2 = ‘1.0’;

var winsColour = ‘#ffd700’;

var winsSelector = ‘.summarytable td’;

$(function () {

$(winsSelector).filter(function() {

return $(this).text() === winsText ;

}).css(“background”, winsColour);

});

$(function () {

$(winsSelector).filter(function() {

return $(this).text() === winsText2 ;

}).css(“background”, winsColour);

});

Cheers

Keith

Hi Jon,

Many thanks for this.

I got around to having a look at this today, looks good to me.

I did notice the Publish menu showed top item as

“amp;Results… CTL /P”

Cheers

Keith

Hi Keith - Thanks

The Publish menu is fine on my system

Inline images 1

The Publish menu is populated by what is in your templates folder - so would presume you have added or edited one of the templates possibly.

Jon

···

On 7 July 2016 at 12:38, keithsykes69@yahoo.com [sailwave] sailwave@yahoogroups.com wrote:

Hi Jon,

Many thanks for this.

I got around to having a look at this today, looks good to me.

I did notice the Publish menu showed top item as

“amp;Results… CTL /P”

Cheers

Keith

Jon Eskdale
07530 112233

Skype “eskdale”

Thanks Jon, all sorted these was a & in the dropbox results.htm, template.setmenurank(100) template.setmenutext('&Results...') or at least there was by the time id down loaded it

Thanks again

Keith