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”