var $jscomp={scope:{},IteratorResult:function(){},Iterator:function(){},Iterable:function(){}};$jscomp.Iterable.prototype.$$iterator=function(){};$jscomp.makeIterator=function(a){if(a.$$iterator)return a.$$iterator();if(!(a instanceof Array)&&"string"!=typeof a)throw Error();var b=0;return{next:function(){return b==a.length?{done:!0}:{done:!1,value:a[b++]}}}};$jscomp.copyProperties=function(a,b){for(var d in b)a[d]=b[d]};
$jscomp.inherits=function(a,b){function d(){}d.prototype=b.prototype;a.superClass_=b.prototype;a.prototype=new d;a.prototype.constructor=a;a.base=function(a,d,g){var h=Array.prototype.slice.call(arguments,2);return b.prototype[d].apply(a,h)}};
var OLClass=function(a,b){this.ID=a.ID;this.ClassNameShort=a.ClassNameShort;this.ClassNameLong=a.ClassNameLong;this.NationalTeams=a.NationalTeams;this.Hidden="undefined"!==typeof a.Hidden?a.Hidden:!1;this.MaxPointsInRoundCompetition=10;this.FirstRace=99999;this.NumberOfRaces=this.LastRace=0;this.Event=b;this.SubClasses=a.SubClasses;this.InSubClasses=a.InSubClasses;this.isClassCombination=this.SubClasses&&0this.LastRace&&(this.LastRace=e.RaceNo)}};OLClass.prototype.getSmartFollowUrl=function(a){return"/"+WwwRoot+"/"+Language+"/"+EventID+"/"+this.ClassNameShort.toLowerCase()+"/"+Texts.url_smart+"/"+a+"/"};
OLClass.prototype.getSmartFollowLink=function(a,b){"undefined"===typeof b&&(b=Texts.SmartFollow);return"undefined"===typeof this.Races[a]?"":!0===this.Races[a].NoResults?"":this.Races[a].TimingPoints[0].hasCompetitors()?""+b+" ":b};
OLClass.prototype.getCupLink=function(a,b){var d=b.Title;""!=b.Cup&&(d=b.Title+" "+b.Season+" yhteispisteet");return this.hasSubClasses()||"undefined"===typeof b.CurrentRace&&a!=this.Event.Headers.CurrentRace||b.IsThisClassExluded(this.ClassNameShort)?"":this.Races[a].TimingPoints[0].hasCompetitors()?""+d+" ":d};
OLClass.prototype.getTimingPointTitle=function(a,b,d){"undefined"===typeof d&&(d=!1);var e="";0"+Texts.lopputulokset+""}return Texts.lopputulokset}var b="/"+WwwRoot+"/"+Language+"/"+EventID+"/"+this.ClassNameShort.toLowerCase()+"/"+Texts.url_tilanne+"/"+a+"/0/",d=this.getTimingPointTitle(a,0);return!0===this.Races[a].NoResults?"":
"Relay"==this.Event.Headers.EventType?this.Races[a].TimingPoints[0].hasResultsTotal()?""+d+" ":d:this.Races[a].TimingPoints[0].hasResultsRace()?""+d+" ":d};
OLClass.prototype.AreThereAnyResults=function(){if("Relay"==this.Event.Headers.EventType){if(!0!==this.Races[this.LastRace].NoResults&&this.Races[this.LastRace].TimingPoints[0].hasResultsTotal())return!0}else for(var a in this.Races)if(!0===this.Races[a].NoResults)break;else if(this.Races[a].TimingPoints[0].hasResultsRace())return!0;return!1};
OLClass.prototype.GetFirstIntermediatePointWithResults=function(a){if(!0===this.Races[a].NoResults)return null;for(var b in this.Races[a].TimingPoints)if(0!=b&&this.Races[a].TimingPoints[b].hasResultsRace())return this.Races[a].TimingPoints[b].PointNumber;return null};OLClass.prototype.GetLastIntermediatePointWithResults=function(a){var b=null,d;for(d in this.Races[a].TimingPoints)if(0!=d){if(!this.Races[a].TimingPoints[d].hasResultsRace())break;b=this.Races[a].TimingPoints[d].PointNumber}return b};
OLClass.prototype.getIntermediateResultsLinks=function(a,b,d,e){if(!0===this.Races[a].NoResults)return"";"undefined"===typeof b&&(b=" ");"undefined"===typeof d&&(d=!1);"undefined"===typeof e&&(e=!1);var f=!1;if(d&&this.Races[a].TimingPoints.length>this.MaxPointsInRoundCompetition)var g=this.GetLastIntermediatePointWithResults(a),f=!0;d=[];var h="",k="",h=null,n;for(n in this.Races[a].TimingPoints)if(h=this.Races[a].TimingPoints[n].PointNumber,0!=h){if(f)if(e)if(null==g&&h>this.MaxPointsInRoundCompetition)break;
else if(null!=g&&h>g&&h>this.MaxPointsInRoundCompetition)break;else{if(null!=g&&hg)break;h="/"+WwwRoot+"/"+Language+"/"+EventID+"/"+this.ClassNameShort.toLowerCase()+"/"+Texts.url_tilanne+"/"+a+"/"+n+"/";k=this.getDistanceInKM(a,n);""!=k&&(k=this.getDistanceInKM(a,n),"Relay"==this.Event.Headers.EventType?this.Races[a].TimingPoints[n].hasResultsTotal()?d.push(""+k+" "):d.push(k):this.Races[a].TimingPoints[n].hasResultsRace()?
d.push(""+k+" "):d.push(k))}return 0!=d.length?d.join(b)+b:""};OLClass.prototype.hasCompetitors=function(a){return this.Races&&this.Races[a]?this.Races[a].TimingPoints[0].hasCompetitors():!1};OLClass.prototype.getLeaderBoardLink=function(){return""+Texts.Leaderboard+" "};
OLClass.prototype.getStartListLink=function(a){return 0==a?(a="/"+WwwRoot+"/"+Language+"/"+EventID+"/"+this.ClassNameShort.toLowerCase()+"/"+Texts.url_kilpailijat+"/",""+Texts.StartingList+" "):this.Races[a].TimingPoints[0].hasCompetitors()?(a="/"+WwwRoot+"/"+Language+"/"+EventID+"/"+this.ClassNameShort.toLowerCase()+"/"+Texts.url_kilpailijat+"/p"+a+"/",""+Texts.StartingList+" "):Texts.StartingList};
OLClass.prototype.getSplitsLink=function(a){return!0===this.Races[a].NoResults?"":this.Races[a].TimingPoints[0].hasResultsRace()?""+Texts.Rastivaliajat+" ":Texts.Rastivaliajat};
OLClass.prototype.getTotalResultsLink=function(a){return!0===this.Races[a].NoResults?"":this.Races[a].TimingPoints[0].hasResultsTotal()?""+Texts.TotalTimes+" ":Texts.TotalTimes};
OLClass.prototype.getRaceResultsLink=function(a){if(!0===this.Races[a].NoResults)return"";if(this.Races[a].TimingPoints[0].hasResultsRace()){if("Relay"==this.Event.Headers.EventType)return a="/"+WwwRoot+"/"+Language+"/"+EventID+"/"+this.ClassNameShort.toLowerCase()+"/"+Texts.url_legtimes+"/"+a+"/",""+Texts.LegTimes+" ";a="/"+WwwRoot+"/"+Language+"/"+EventID+"/"+this.ClassNameShort.toLowerCase()+"/"+Texts.url_racetimes+"/"+a+"/";return""+Texts.RaceTimes+" "}return"Relay"==
this.Event.Headers.EventType?Texts.LegTimes:Texts.RaceTimes};OLClass.prototype.getLegResultsLink=function(a){var b="/"+WwwRoot+"/"+Language+"/"+EventID+"/"+this.ClassNameShort.toLowerCase()+"/"+Texts.url_legtimes+"/"+a+"/";return!0===this.Races[a].NoResults?"":this.Races[a].TimingPoints[0].hasResultsRace()?""+Texts.LegTimes+" ":Texts.LegTimes};
OLClass.prototype.setDistance=function(a,b,d,e){console.log("Updating "+this.ClassNameShort+"-"+a+"-"+b+" "+this.Races[a].TimingPoints[b].DistanceStr+" => "+e);this.Races[a].TimingPoints[b].DistanceStr=e;this.Races[a].TimingPoints[b].DistanceMeters=d};
OLClass.prototype.getDistanceInKM=function(a,b){var d=this.Races[a].TimingPoints[b].DistanceMeters;return 0===d?(d=this.Races[a].TimingPoints[b].DistanceStr,"0"===d?"":d):"Swimming"==this.Event.Headers.Discipline?d+" m":(d/1E3).toFixed(1).replace(".",",")+" km"};OLClass.prototype.hasSubClasses=function(){return null!=this.SubClasses&&0a&&(a="0"+a);var b=this.Races[1].MassStart.getMinutes();10>b&&(b="0"+b);var d=this.Races[1].MassStart.getSeconds();return 0d&&(d="0"+d),a+":"+b+":"+d):a+":"+b};var OLClassRace=function(a,b){this.RaceNo=a.RaceNo;b&&!0===b?this.MassStartStr=this.MassStart=null:null!==a.MassStartStr&&""!=a.MassStartStr?this.MassStart=new Date((new Date(a.MassStartStr)).getTime()+OLTime.TimeZoneDiffToLocalMS):0=this.Qualification[f].FirstRankToQualify&&d.push(g),e=null):a<=this.Qualification[f].LastRankToQualify&&b>=this.Qualification[f].FirstRankToQualify&&(null!==e&&this.Qualification[f].LastRankToQualify>e&&(e=this.Qualification[f].LastRankToQualify),
d.push(g))}null!==e&&b>e&&d.push("-")}return d.join("/")};
OLClassRace.prototype.GetQualificationExplanation=function(){var a="";if(null!==this.Qualification&&this.Qualification&&0"+(""+Texts.Qualification+": "),a=a+"",b;for(b in this.Qualification)a+="",a+=this.Qualification[b].Title+", "+Texts.Sijat+" "+this.Qualification[b].FirstRankToQualify+"-",null!==this.Qualification[b].LastRankToQualify&&(a+=this.Qualification[b].LastRankToQualify),a+=" ";a+=" ";a+="
"}return a};
OLClassRace.prototype.getNumberOfIntermediaries=function(){var a=0,b;for(b in this.TimingPoints)0!=this.TimingPoints[b].PointNumber&&this.TimingPoints[b].Public&&++a;return a};var OLClub=function(a,b,d){this.ID=a[d.ID];this.District=this.ClubNameShort=this.ClubNameLong=null;this.FileFormat=d;0",b=this.Event.Headers.AllowFollowAll?b+(""+Texts.Favourites+" "):b+Texts.Favourites,b=b+"",e;for(e in this.FavouritesByBaseBib)b+=""+this.FavouritesByBaseBib[e].getCompetitorLink(null,!0,a)+" ";b+=" "}return b};
OLCompetitors.prototype.GetClubByLongName=function(a){for(var b in this.Clubs)if(this.Clubs[b].ClubNameLong==a)return this.Clubs[b];return null};
OLCompetitors.prototype.SaveBigRelayTmpResult=function(a,b,d,e,f){console.log("OLCompetitors.SaveBigRelayTmpResult() Offset="+b);var g=!1,h={};-3==b?(h.Class=this.Event.ClassesByID[d],h.RaceNo=e,h.Point=f):(h.Class=this.Event.ClassesByID[a[this.Event.JsonFileFormats.OLBigRelayResult.Class+b]],h.RaceNo=a[this.Event.JsonFileFormats.OLBigRelayResult.RaceNo+b],h.Point=a[this.Event.JsonFileFormats.OLBigRelayResult.Point+b]);h.BaseBib=a[this.Event.JsonFileFormats.OLBigRelayResult.BaseBib+b];h.Name=a[this.Event.JsonFileFormats.OLBigRelayResult.Name+
b];h.Nationality=a[this.Event.JsonFileFormats.OLBigRelayResult.Nationality+b];h.Bib=a[this.Event.JsonFileFormats.OLBigRelayResult.Bib+b];h.TimeTotal=a[this.Event.JsonFileFormats.OLBigRelayResult.TimeTotalStr+b];h.TimeTotalSecs=a[this.Event.JsonFileFormats.OLBigRelayResult.TimeTotalSecs+b];h.RankTotal=a[this.Event.JsonFileFormats.OLBigRelayResult.RankTotal+b];h.DiffTotal=a[this.Event.JsonFileFormats.OLBigRelayResult.DiffTotal+b];h.TimeRace=a[this.Event.JsonFileFormats.OLBigRelayResult.TimeRaceStr+
b];h.TimeRaceSecs=a[this.Event.JsonFileFormats.OLBigRelayResult.TimeRaceSecs+b];h.RankRace=a[this.Event.JsonFileFormats.OLBigRelayResult.RankRace+b];h.DiffRace=a[this.Event.JsonFileFormats.OLBigRelayResult.DiffRace+b];h.Competitor=this.CompetitorsByBaseBib[h.BaseBib];this.TmpBigRelayResultsByBaseBib[h.BaseBib]?(d=this.TmpBigRelayResultsByBaseBib[h.BaseBib],d.Name!=h.Name&&(d.Name=h.Name,g=!0),d.Nationality!=h.Nationality&&(d.Nationality=h.Nationality,g=!0),d.Bib!=h.Bib&&(d.Bib=h.Bib,g=!0),d.TimeTotal!=
h.TimeTotal&&(d.TimeTotal=h.TimeTotal,g=!0),d.TimeTotalSecs!=h.TimeTotalSecs&&(d.TimeTotalSecs=h.TimeTotalSecs,g=!0),d.RankTotal!=h.RankTotal&&(d.RankTotal=h.RankTotal,g=!0),d.DiffTotal!=h.DiffTotal&&(d.DiffTotal=h.DiffTotal,g=!0),d.TimeRace!=h.TimeRace&&(d.TimeRace=h.TimeRace,g=!0),d.TimeRaceSecs!=h.TimeRaceSecs&&(d.TimeRaceSecs=h.TimeRaceSecs,g=!0),d.RankRace!=h.RankRace&&(d.RankRace=h.RankRace,g=!0),d.DiffRace!=h.DiffRace&&(d.DiffRace=h.DiffRace,g=!0)):(g=!0,this.TmpBigRelayResults.push(h),this.TmpBigRelayResultsByBaseBib[h.BaseBib]=
h);g&&-3!=b&&(a.ChangedClassIDs[h.Class.ID]=h.Class.ID,a.ChangedRaceNos[h.RaceNo]=h.RaceNo,a.ChangedTimingPoints[h.Point]=h.Point,a.ChangedCompetitorID=h.Competitor.ID,a.ChangedCompetitorBib=h.Bib)};var OLControl=function(a,b,d){this.SplitDistance=this.ControlCode=null;this.SplitTime=new OLTime;this.SplitDifference=new OLTime;this.SplitTotalResults=this.SplitRank=null;this.CumulativeTime=new OLTime;this.CumulativeDifference=new OLTime;this.RelayRank=this.CumulativeRank=null;this.FileFormat=d;this.UpdateData(a,b)};
OLControl.prototype.UpdateData=function(a,b){this.ControlCode=parseInt(a[this.FileFormat.ControlCode]);this.SplitDistance=parseInt(a[this.FileFormat.SplitDistance]);this.SplitRank=parseInt(a[this.FileFormat.SplitRank]);this.SplitTotalResults=parseInt(a[this.FileFormat.SplitTotalResults]);this.CumulativeRank=parseInt(a[this.FileFormat.CumulativeRank]);this.RelayRank=parseInt(a[this.FileFormat.RelayRank]);this.SplitTime.UpdateData(a[this.FileFormat.SplitTime],b,-3);this.SplitDifference.UpdateData(a[this.FileFormat.SplitDifference],
b,-3);this.CumulativeTime.UpdateData(a[this.FileFormat.CumulativeTime],b,-3);this.CumulativeDifference.UpdateData(a[this.FileFormat.CumulativeDifference],b,-3);return!0};function _instanceof(a,b){return null!=b&&"undefined"!==typeof Symbol&&b[Symbol.hasInstance]?b[Symbol.hasInstance](a):a instanceof b}function _classCallCheck(a,b){if(!_instanceof(a,b))throw new TypeError("Cannot call a class as a function");}function _defineProperties(a,b){for(var d=0;d"+this.Title+" "+this.Season+" "+Texts.UnofficialTotalPoints+" "};
OLCup.prototype.GetOnlineHtmlTitlePrefix=function(a){return this.Title+" "+this.Season+" "+Texts.UnofficialTotalPoints+" | "+a};OLCup.prototype.IsThisClassExluded=function(a){return"undefined"!==typeof this.ExcludeClasses[a]};var OLCupAktia=function(a){console.log("OLCupAktia-rakentaja");OLCupAktia.base(this,"constructor",a);this.OverrideResultTable=!0;this.RaceNo=this.CurrentClass=null;this.DataJsonURL="";this.ResultsBybaseBib={}};$jscomp.copyProperties(OLCupAktia,OLCup);$jscomp.inherits(OLCupAktia,OLCup);OLCupAktia.prototype.GetPoints=function(a){return 0this.RaceNo)break;
g=this.GetPoints(a[b]["RaceRank_"+g]);null!==g&&++d.NumberOfRaces;0=this.RaceNo||2<=d.NumberOfRaces)?(d.EnoughRaces=!0,e.sort(function(a,d){return d-a}),d.TotalPoints=0,null!==e[0]&&0this.LastReceivedPkgID[a])this.LastReceivedPkgID[a]=b;d&&0a&&(a=this.LastReceivedPkgID[e],this.SocketIOCOnnection&&(this.SocketIOCOnnection.io.opts.query.LastReceivedPkgID=this.LastReceivedPkgID[e]));this.updateOnlineStatusStr(a)};OLEvent.prototype.GetClassIDByName=function(a){return this.ClassesByName[a.toLowerCase()].ID};OLEvent.prototype.GetClassByName=function(a){return this.ClassesByName[a.toLowerCase()]};
OLEvent.prototype.SocketIOStopFollowing=function(){this.Headers.AllowFollowAll||(console.log("SocketIOStopFollowing"),this.SendToSocketIO("stop_following",JSON.stringify([])));this.FollowingTimingPoints=[];this.FollowingBaseBibs=[];this.StartedFollowing=[]};OLEvent.prototype.SocketIOStartFollowingFavourite=function(a){this.Headers.AllowFollowAll||(a={Type:"Favourite",BaseBib:a},console.log("SocketIOStartFollowingFavourite "+JSON.stringify(a)),this.SendToSocketIO("start_following",JSON.stringify(a)))};
OLEvent.prototype.SocketIOStopFollowingFavourite=function(a){this.Headers.AllowFollowAll||(a={BaseBib:a},console.log("SocketIOStopFollowingFavourite "+JSON.stringify(a)),this.SendToSocketIO("stop_following_favourite",JSON.stringify(a)))};
OLEvent.prototype.SocketIOStartFollowing=function(a){"Results"==a.Type&&null!==a.Point&&"undefined"!==typeof a.Point?a.LastReceivedPkgID=this.LastReceivedPkgID["results_"+a.ClassID+"_"+a.RaceNo+"_"+a.Point]:"Results"==a.Type?(console.log(this.LastReceivedPkgID["results_"+a.ClassID+"_"+a.RaceNo]),a.LastReceivedPkgID=this.LastReceivedPkgID["results_"+a.ClassID+"_"+a.RaceNo]):"Splits"==a.Type?a.LastReceivedPkgID=this.LastReceivedPkgID["splits_"+a.ClassID+"_"+a.RaceNo]:"TopResults"!=a.Type&&(a.LastReceivedPkgID=
-2);this.Headers.AllowFollowAll||this.SendToSocketIO("start_following",JSON.stringify(a));var b=a.ClassID+"-"+a.RaceNo+"-"+a.Point;this.FollowingTimingPoints[b]||(this.FollowingTimingPoints[b]=b);0 Reload"),$.event.trigger({type:"ResetTimeChanged",
old_r:b.ResetTime,new_r:a.ResetTime,time:new Date})):a.Headers.Online!=b.Headers.Online&&(console.log("Online-status has changed -> Reload"),$.event.trigger({type:"ResetTimeChanged",old_r:b.ResetTime,new_r:a.ResetTime,time:new Date}));var e=!1,f=!1,g=!1;b.HyperLinks=a.Headers.HyperLinks;for(var h in b.HyperLinks)b.HyperLinks[h].Updated&&null!==b.HyperLinks[h].Updated&&(b.HyperLinks[h].Updated=new Date(b.HyperLinks[h].Updated),f=!0);for(var k in a.Classes)for(var n in a.Classes[k].Races)for(var r in a.Classes[k].Races[n].TimingPoints){h=
a.Classes[k].ID;var u=a.Classes[k].Races[n].RaceNo,m=a.Classes[k].Races[n].TimingPoints[r].PointNumber,q=b.ClassesByID[h].Races[u].TimingPoints[m].DistanceStr,v=a.Classes[k].Races[n].TimingPoints[r].DistanceMeters,A=a.Classes[k].Races[n].TimingPoints[r].DistanceStr;if(b.ClassesByID[h].Races[u].TimingPoints[m].DistanceMeters!=v||q!=A)b.ClassesByID[h].setDistance(u,m,v,A),e=!0}a=!1;b.AreThereAnyResults&&(a=!0);b.UpdateAreThereAnyResults();b.AreThereAnyResults!=a&&(g=!0);(e||f||g)&&$.event.trigger({type:"ForceUpdateOnlineTable",
message:"OLEvent.UpdateEventStatus()",KmUpdated:e,HyperlinksUpdated:f,AreThereAnyResultsUpdated:g})},error:function(a){console.log("Error downloading event data for timing point kilometers (ju/ve)");console.log(a)}})};OLEvent.prototype.ConnectToServer=function(){this.updateOnlineStatusStr("Offline");OnlineConnection=!1;null!=this.TimeoutTimer&&(clearTimeout(this.TimeoutTimer),this.TimeoutTimer=null);this.DoNotDownloadChangesWhenConnecting&&(this.LastReceivedPkgID=-3);this.connectSocketIO()};
OLEvent.prototype.connectPolling=function(){console.log("Connecting to polling data source: "+this.EventID+" LastReceivedPkgID="+this.LastReceivedPkgID+" ResetTime="+this.ResetTime);this.PollForDataUpdates()};
OLEvent.prototype.PollForDataUpdates=function(){console.log("Polling for data updates: "+this.EventID+" LastReceivedPkgID="+this.LastReceivedPkgID+" ResetTime="+this.ResetTime);var a="http://"+window.location.host+"/"+WwwRoot+"/cgi/onlinedata.cgi?SSE=0&EventID="+this.EventID+"&LastReceivedPkgID="+this.LastReceivedPkgID+"&ResetTime="+this.ResetTime+"&a="+(new Date).getTime(),b=this;$.ajax({url:a,success:function(a){for(var e in a)console.log(JSON.stringify(a[e])),OnlineConnection=!0,$.event.trigger({type:"DataUpdateReceived",
message:a[e]});b.ConnectionActivity(!0);setTimeout(function(){b.PollForDataUpdates()},6E3+1E3*Math.random())},error:function(a){console.log(a);409==a.status&&$.event.trigger({type:"ResetTimeChanged",old_r:b.ResetTime,time:new Date});b.updateOnlineStatusStr("Offline");OnlineConnection=!1;setTimeout(function(){b.PollForDataUpdates()},1E4+1E3*Math.random())}})};
OLEvent.prototype.connectSSE=function(){console.log("Connecting to Server Sent Events source: "+this.EventID+" LastReceivedPkgID="+this.LastReceivedPkgID+" ResetTime="+this.ResetTime);if(window.EventSource){var a="http://"+window.location.host+"/"+WwwRoot+"/cgi/onlinedata.cgi?SSE=1&EventID="+this.EventID+"&LastReceivedPkgID="+this.LastReceivedPkgID+"&ResetTime="+this.ResetTime+"&a="+(new Date).getTime();this.SSEConnection=new EventSource(a);console.log(this.SSEConnection);var b=this;this.SSEConnection.addEventListener("message",
function(a){var e=$.parseJSON(a.data);console.log(a);OnlineConnection=!0;$.event.trigger({type:"DataUpdateReceived",message:e});b.ConnectionActivity(!0)},!1);this.SSEConnection.addEventListener("open",function(a){console.log("SSE OPENED");console.log(a);b.ConnectionActivity(!0)},!1);this.SSEConnection.addEventListener("ping",function(a){b.ConnectionActivity(!0)},!1);this.SSEConnection.addEventListener("ResetChanged",function(a){console.log(a);console.log("Reset Changed");$.event.trigger({type:"ResetTimeChanged",
old_r:b.ResetTime,time:new Date});b.ConnectionActivity(!0)},!1);this.SSEConnection.addEventListener("RequestError",function(a){console.log(a);console.log("RequestError");b.ReConnectToServer()},!1);this.SSEConnection.addEventListener("error",function(a){b.updateOnlineStatusStr("Offline");OnlineConnection=!1;console.log(a);console.log("SSE ERROR");a.readyState==EventSource.CLOSED?console.log("SSE Closed"):a.readyState==EventSource.CONNECTING&&console.log("SSE Reconnecting...")},!1)}else console.log("SSE NOT SUPPORTED")};
OLEvent.prototype.connectSocketIO=function(){var a=nodejs_base_url+"/"+this.EventID,b=-2,b=this.Headers.AllowFollowAll?this.LastReceivedPkgID.results:this.LastReceivedPkgID.Event>this.LastReceivedPkgID.Competitors?this.LastReceivedPkgID.Event:this.LastReceivedPkgID.Competitors;console.log("Connecting to Socket.IO source: "+a+" LastReceivedPkgID="+b+" ResetTime="+this.ResetTime);try{this.SocketIOCOnnection=io(a,{query:{LastReceivedPkgID:b,ResetTime:this.ResetTime}});var d=this;this.SocketIOCOnnection.on("o2",
function(a){console.log("'"+a+"'");a=$.parseJSON(a);OnlineConnection=!0;$.event.trigger({type:"DataUpdateReceived",message:a});d.ConnectionActivity(!0)});this.SocketIOCOnnection.on("ResetChanged",function(a){console.log(a);console.log("Reset Changed");$.event.trigger({type:"ResetTimeChanged",old_r:d.ResetTime,time:new Date});d.ConnectionActivity(!1)});this.SocketIOCOnnection.on("error",function(a){"Invalid namespace"==a?(console.log("SocketIO ERROR Attempted to connect to invalid namespace "),d.ConnectionActivity(!1),
d.ReconnectSocketIO()):(console.log("SocketIO ERROR Error on socket.io client ",a),d.ConnectionActivity(!1))});this.SocketIOCOnnection.on("connect",function(){console.log("SocketIO OPENED "+this.id+" "+this.io.engine.transports);d.UserSettings.NotificationsConnectionStatus&&$.notify(Texts.ConnectedToServer,"success");$.event.trigger({type:"SocketIOConnected",time:new Date});for(var a in d.SocketIOSendBuffer){var b=d.SocketIOSendBuffer[a];console.log("Sending from buffer to SocketIO: "+b.Event+" "+
b.Data);this.emit(b.Event,b.Data)}d.SocketIOSendBuffer=[];d.ConnectionActivity(!0);this.io.engine.on("upgrade",function(a){console.log("Socket.IO transport upgraded")})});this.SocketIOCOnnection.on("disconnect",function(){console.log("SocketIO DISCONNECTED "+this.id);console.log(d);console.log(this);d.UserSettings.NotificationsConnectionStatus&&$.notify(Texts.ServerDisconnected,"warn");OnlineConnection=!1;d.ConnectionActivity(!1);d.SendToSocketIO("stop_following",JSON.stringify([]));for(var a in d.StartedFollowing){var b=
JSON.parse(d.StartedFollowing[a]);b.LastReceivedPkgID=this.io.opts.query.LastReceivedPkgID;d.SendToSocketIO("start_following_after_reconnect",JSON.stringify(b))}for(a in d.StartedFollowing)b=JSON.parse(d.StartedFollowing[a]),b.LastReceivedPkgID=this.io.opts.query.LastReceivedPkgID,d.SendToSocketIO("start_following_after_reconnect",JSON.stringify(b));for(a in d.StartedFollowingFavourites)b=JSON.parse(d.StartedFollowingFavourites[a]),b.LastReceivedPkgID=this.io.opts.query.LastReceivedPkgID,d.SendToSocketIO("start_following_after_reconnect",
JSON.stringify(b));!1!==d.StartedFollowingNewLeader&&(b=JSON.parse(d.StartedFollowingNewLeader),b.LastReceivedPkgID=this.io.opts.query.LastReceivedPkgID,d.SendToSocketIO("start_following_after_reconnect",JSON.stringify(b)));for(a in d.TopicsSubscribed)d.SendToSocketIO("subscribe_to_topic_after_reconnect",d.TopicsSubscribed[a])});this.SocketIOCOnnection.on("connect_error",function(){console.log("SocketIO Connect error "+this.id);d.UserSettings.NotificationsConnectionStatus&&$.notify(Texts.ServerDisconnected,
"warn");OnlineConnection=!1;d.ConnectionActivity(!1)});this.SocketIOCOnnection.on("connect_timeout",function(){console.log("SocketIO Connection timeout "+this.id);d.UserSettings.NotificationsConnectionStatus&&$.notify(Texts.ServerDisconnected,"warn");OnlineConnection=!1;d.ConnectionActivity(!1)});this.SocketIOCOnnection.on("reconnect_attempt",function(){console.log("SocketIO Reconnect attempt "+this.id);OnlineConnection=!1;d.ConnectionActivity(!1)});this.SocketIOCOnnection.on("reconnecting",function(a){console.log("SocketIO Reconnecting... "+
a+" "+this.id);OnlineConnection=!1;d.ConnectionActivity(!1)});this.SocketIOCOnnection.on("reconnect_error",function(a){console.log("SocketIO Reconnect error "+this.id);d.UserSettings.NotificationsConnectionStatus&&$.notify(Texts.ReconnectFailed,"warn");console.log(a);OnlineConnection=!1;d.ConnectionActivity(!1)});this.SocketIOCOnnection.on("reconnect_failed",function(){console.log("SocketIO Reconnect failed "+this.id);d.UserSettings.NotificationsConnectionStatus&&$.notify(Texts.ReconnectFailed,"warn");
OnlineConnection=!1;d.ConnectionActivity(!1)});this.SocketIOCOnnection.on("pong",function(a){d.ConnectionActivity(!0)})}catch(e){console.log("ERROR: socket.io encountered a problem: "+e),this.ConnectionActivity(!1)}};
OLEvent.prototype.connectWebSocket=function(){console.log("Connecting websocket: "+this.EventID+" LastReceivedPkgID="+this.LastReceivedPkgID+" ResetTime="+this.ResetTime);var a="undefined"!==typeof hepjee?"ws://127.0.0.1:8081/ws2/"+WwwRoot+"/?EventID="+this.EventID+"&LastReceivedPkgID="+this.LastReceivedPkgID+"&ResetTime="+this.ResetTime:"ws://"+window.location.host+"/ws2/"+WwwRoot+"/?EventID="+this.EventID+"&LastReceivedPkgID="+this.LastReceivedPkgID+"&ResetTime="+this.ResetTime+"&a="+(new Date).getTime();
try{this.websocket=new WebSocket(a)}catch(b){console.log(b)}var d=this;this.websocket.onopen=function(a){console.log("Websocket connected!");d.updateOnlineStatusStr(d.LastReceivedPkgID);OnlineConnection=!0};this.websocket.onmessage=function(a){"ping"==a.data?d.websocket.send("pong"):(a=$.parseJSON(a.data),OnlineConnection=!0,$.event.trigger({type:"DataUpdateReceived",message:a}))};this.websocket.onerror=function(a){console.log("Websocket-error:");console.log(a);d.updateOnlineStatusStr("Offline");
OnlineConnection=!1};this.websocket.onclose=function(){d.updateOnlineStatusStr("Offline");OnlineConnection=!1;console.log("Websocket closed");setTimeout(function(){d.connectWebSocket()},5E3)}};
OLEvent.prototype.updateOnlineStatusStr=function(a){this.OnlineStatusStr=a;console.log("OLEvent.updateOnlineStatusStr() str="+a);"Offline"==this.OnlineStatusStr?$("#OnlineStatusIcon").hasClass("Offline")||$("#OnlineStatusIcon").addClass("Offline"):($("#OnlineStatusIcon").hasClass("Offline")&&($("#OnlineStatusIcon").removeClass("Offline"),this.updateOnlineStatus()),$("#OnlineStatusIcon").prop("title",a))};
OLEvent.prototype.updateOnlineStatus=function(){if("Offline"==this.OnlineStatusStr)$("#OnlineStatusClock").html(this.OnlineStatusStr);else{var a=this,b=this.GetNow(),d=1E3-b.getTime()%1E3,e=b.getHours();10>e&&(e="0"+e);var f=b.getMinutes();10>f&&(f="0"+f);b=b.getSeconds();10>b&&(b="0"+b);this.ClockStr=e+":"+f+":"+b;$("#OnlineStatusClock").html(this.ClockStr);this.StatusTimer=setTimeout(function(){a.updateOnlineStatus()},d)}};
OLEvent.prototype.GetNow=function(){return new Date(OLTime.GetDateNow().getTime()+OLTime.TimeZoneDiffToLocalMS)};
OLEvent.prototype.syncClock=function(){var a=(new Date).getTime(),b=this;$.ajax({url:"/"+WwwRoot+"/online/online_time.json?a="+a,success:function(d){var e=(new Date).getTime();d=d-e+parseInt((e-a)/2,0);OLTime.FakeNow?console.log("Not synchronizing because of fakenow, but diff is = "+d+" ms"):(OLTime.TimeCorrection=d,console.log("Synchronizing clock diff="+d+" ms"));$.event.trigger({type:"ClockSyncReceived",message:"hep",time:new Date});setTimeout(function(){b.syncClock()},6E5)},error:function(a){console.log(a.message)}})};
OLEvent.prototype.DownloadCompetitorData=function(a){var b="/"+WwwRoot+"/online/online_"+this.EventID+"_competitor.json?BaseBib="+a.Competitor.BaseBib+"&a="+(new Date).getTime();console.log("Downloading "+b);$.ajax({url:b,success:function(b){a.onCompetitorDataDownloaded(b)},error:function(b){a.onCompetitorDataDownloaded(b)}})};OLEvent.prototype.UpdateAreThereAnyResults=function(){for(var a in this.Classes)this.Classes[a].AreThereAnyResults()&&(this.AreThereAnyResults=!0)};
OLEvent.prototype.GetHyperLinks=function(){var a="";if(this.BigRelay)this.AreThereAnyResults&&(a+=""+Texts.lehdistotulokset+" ");else{if(this.Headers.Online||!this.AreThereAnyResults)a+=""+Texts.lahtolistakaikkisarjoittain+" ",a+=""+Texts.lahtolistaseuroittain+" ";this.AreThereAnyResults&&(a+=""+Texts.tuloksetkaikkisarjat+" ",a+=""+Texts.lehdistotulokset+" ")}if(this.HyperLinks)for(var b in this.HyperLinks)if("TextOnly"==this.HyperLinks[b].Type)a+=
""+this.HyperLinks[b].Title+" ";else if("PPResultsXML"==this.HyperLinks[b].Type&&this.AreThereAnyResults){var d=Texts.XmlTulokset;this.Headers.ControlSplits&&(d=Texts.XmlTuloksetRva);"MultiRace"==this.Headers.EventType&&(d+=" "+this.Races[this.HyperLinks[b].RaceNo].RaceTitle);a+=""+d+" ";this.Headers.Online&&(a+="("+Texts.paivitetty+" "+OLTime.PrintTime(this.HyperLinks[b].Updated)+") ");a+="(PP) "}else"IOFResultListXML"==
this.HyperLinks[b].Type&&this.AreThereAnyResults?(d=Texts.XmlTulokset,"MultiRace"==this.Headers.EventType&&(d+=" "+this.Races[this.HyperLinks[b].RaceNo].RaceTitle),a+=""+d+" ",this.Headers.Online&&(a+="("+Texts.paivitetty+" "+OLTime.PrintTime(this.HyperLinks[b].Updated)+") "),a+="(IOF) "):!this.Headers.Online&&this.AreThereAnyResults||"IOFStartListXML"!=this.HyperLinks[b].Type?"ExternalLink"==this.HyperLinks[b].Type&&
(a+=""+this.HyperLinks[b].Title+" "):(d=Texts.XmlLahtolistat,"MultiRace"==this.Headers.EventType&&(d+=" "+this.Races[this.HyperLinks[b].RaceNo].RaceTitle),a+=""+d+" ",this.Headers.Online&&(a+="("+Texts.paivitetty+" "+OLTime.PrintTime(this.HyperLinks[b].Updated)+") "),a+="(IOF) ");return a};
OLEvent.prototype.GetBadgeTypeTxt=function(){return Texts[this.Headers.BadgeType]?Texts[this.Headers.BadgeType]:this.Headers.BadgeType?this.Headers.BadgeType:Texts.Badge};OLEvent.prototype.GetRaceTitle=function(a){return this.Races[a].GetRaceTitle()};OLEvent.prototype.SetFollowNewLeader=function(a){a&&!1===this.StartedFollowingNewLeader?this.SendToSocketIO("start_following",JSON.stringify({Type:"NewLeader"})):a||!1===this.StartedFollowingNewLeader||this.SendToSocketIO("stop_following_newleader",JSON.stringify([]))};
OLEvent.prototype.setUserSettings=function(a){this.UserSettings=a};var OLEventRace=function(a){this.RaceTimeZoneMin=this.RaceTitle=this.RaceDate=this.RaceNo=this.PrecisionSplitsShow=this.PrecisionSplitsRank=this.PrecisionIntermediariesShow=this.PrecisionIntermediariesRank=this.PrecisionResultsShow=this.PrecisionResultsRank=null;this.UpdateData(a)};
OLEventRace.prototype.UpdateData=function(a){this.PrecisionResultsRank=a.PrecisionResultsRank;this.PrecisionResultsShow=a.PrecisionResultsShow;this.PrecisionIntermediariesRank=a.PrecisionIntermediariesRank;this.PrecisionIntermediariesShow=a.PrecisionIntermediariesShow;this.PrecisionSplitsRank=a.PrecisionSplitsRank;this.PrecisionSplitsShow=a.PrecisionSplitsShow;this.RaceDate=new Date(a.RaceDate);this.RaceTitle=a.RaceTitle;this.RaceTimeZoneMin=a.RaceTimeZoneMin;this.RaceNo=a.RaceNo;OLTime.PrecisionResultsRank[a.RaceNo]=
this.PrecisionResultsRank;OLTime.PrecisionResultsShow[a.RaceNo]=this.PrecisionResultsShow;OLTime.PrecisionIntermediariesRank[a.RaceNo]=this.PrecisionIntermediariesRank;OLTime.PrecisionIntermediariesShow[a.RaceNo]=this.PrecisionIntermediariesShow;OLTime.PrecisionSplitsRank[a.RaceNo]=this.PrecisionSplitsRank;OLTime.PrecisionSplitsShow[a.RaceNo]=this.PrecisionSplitsShow;OLTime.RaceDates[a.RaceNo]=this.RaceDate};
OLEventRace.prototype.GetRaceTitle=function(){return this.RaceTitle=="Race "+this.RaceNo?this.RaceNo+". "+Texts.day:""!=this.RaceTitle?this.RaceTitle:this.RaceNo+". "+Texts.day};var OLIndividualCompetitor=function(a,b,d,e){console.log(e);this.ID=a[e.JsonFileFormats.OLIndividualCompetitor.CompetitorID];this.NameFirst=this.NameLast=this.WRCode=this.LicenseNumber=this.Nationality=this.Club=this.BaseBib=null;this.FileFormats=e.JsonFileFormats;this.Races=[];this.isFavourite=!1;this.Event=e;this.UpdateData(a,b,d)};
OLIndividualCompetitor.prototype.UpdateData=function(a,b,d){this.BaseBib=null!=a[this.FileFormats.OLIndividualCompetitor.BaseBib]?a[this.FileFormats.OLIndividualCompetitor.BaseBib]:null;this.Club="object"==typeof b[a[this.FileFormats.OLIndividualCompetitor.ClubID]]?b[a[this.FileFormats.OLIndividualCompetitor.ClubID]]:d;this.Nationality=null!=a[this.FileFormats.OLIndividualCompetitor.Nationality]?a[this.FileFormats.OLIndividualCompetitor.Nationality]:"";this.LicenseNumber=null!=a[this.FileFormats.OLIndividualCompetitor.LicenseNumber]?
a[this.FileFormats.OLIndividualCompetitor.LicenseNumber]:0;this.WRCode=null!=a[this.FileFormats.OLIndividualCompetitor.WRCode]?a[this.FileFormats.OLIndividualCompetitor.WRCode]:"";this.NameLast=null!=a[this.FileFormats.OLIndividualCompetitor.NameLast]?a[this.FileFormats.OLIndividualCompetitor.NameLast]:"";this.NameFirst=null!=a[this.FileFormats.OLIndividualCompetitor.NameFirst]?a[this.FileFormats.OLIndividualCompetitor.NameFirst]:"";if(a.ChangedClassIDs){for(var e in this.Races)a.ChangedClassIDs[this.Races[e].Class.ID]=
this.Races[e].Class.ID,a.ChangedRaceNos[this.Races[e].RaceNo]=this.Races[e].RaceNo;a.ChangedTimingPointsAll=!0}};OLIndividualCompetitor.prototype.GetRacePoints=function(a){return this.Races[a]?this.Races[a].GetRacePoints():null};OLIndividualCompetitor.prototype.UpdateStartTimeReal=function(a){var b=a.shift();return 0==this.Races.length||null==this.Races[b]?!1:this.Races[b].UpdateStartTimeReal(a)};
OLIndividualCompetitor.prototype.UpdateRaceData=function(a,b,d,e){this.Races[b]?this.Races[b].UpdateData(a,d,e):this.Races[b]=new OLIndividualCompetitorRace(a,d,e,this.FileFormats);a.ChangedClassIDs&&(a.ChangedClassIDs[this.Races[b].Class.ID]=this.Races[b].Class.ID,a.ChangedRaceNos[b]=b,a.ChangedTimingPointsAll=!0)};
OLIndividualCompetitor.prototype.UpdateSplits=function(a,b,d,e){if(this.Races[b])this.Races[b].UpdateSplits(a);else return!1;a.ChangedClassIDs&&(a.ChangedClassIDs[this.Races[b].Class.ID]=this.Races[b].Class.ID,a.ChangedRaceNos[b]=b,a.ChangedTimingPointsAll=!0)};OLIndividualCompetitor.prototype.ClearRaces=function(){this.Races=[]};
OLIndividualCompetitor.prototype.UpdateBadges=function(a){if(0==this.Races.length)return!1;var b=a[this.FileFormats.OLUpdateBadge.RaceNo-1];a.ChangedClassIDs&&(a.ChangedClassIDs[this.Races[b].Class.ID]=this.Races[b].Class.ID,a.ChangedRaceNos[b]=b,a.ChangedTimingPoints[0]=0);return this.Races[b].UpdateBadges(a[this.FileFormats.OLUpdateBadge.Badge1-1],a[this.FileFormats.OLUpdateBadge.Badge2-1])};
OLIndividualCompetitor.prototype.UpdateResult=function(a){if(0==this.Races.length)return!1;var b=a.shift(),d=a[this.FileFormats.OLResult.Point-2];a.ChangedClassIDs&&(a.ChangedClassIDs[this.Races[b].Class.ID]=this.Races[b].Class.ID,a.ChangedRaceNos[b]=b,a.ChangedTimingPoints[d]=d);return this.Races[b].UpdateResult(a,d)};
OLIndividualCompetitor.prototype.getNatPrint=function(a){return a&&"OTH"!=this.Nationality?" ":this.Nationality};
OLIndividualCompetitor.prototype.getCompetitorLink=function(a,b,d){var e=[];e.push("Competitor");e.push(this.BaseBib);a&&e.push(a);d=this.GetNameStd(a,d);b&&a&&this.Races&&this.Races[a]&&(d+=" ("+this.Races[a].Bib+")");return''+d+" "};
OLIndividualCompetitor.prototype.getClubLink=function(a,b){if(null===this.Club||null===this.Club.ClubNameLong||""==this.Club.ClubNameLong)return"";var d=[];d.push("ClubResults");d.push(encodeURIComponent(this.Club.ClubNameLong));a&&d.push(a);d='';d=b?d+this.Club.ClubNameShort:d+this.Club.ClubNameLong;return d+" "};
OLIndividualCompetitor.prototype.getCertificateLink=function(a){return""+Texts.Certificate+" "};
OLIndividualCompetitor.prototype.GetFavouriteButton=function(a){return this?this.isFavourite?"'+Texts.RemoveFromFavourites+" ":"'+Texts.AddToFavourites+" ":"?"};
OLIndividualCompetitor.prototype.GetNameStd=function(a,b){if(b){var d=this.NameFirst.split("-");return 2==d.length?d[0].substr(0,1)+"-"+d[1].substr(0,1)+". "+this.NameLast:this.NameFirst.substr(0,1)+". "+this.NameLast}return this.NameFirst+" "+this.NameLast};var OLIndividualCompetitorRace=function(a,b,d,e){this.Competitor=d[a[e.OLIndividualCompetitorRace.CompetitorID]];this.Status=this.RaceNo=null;this.PenaltyTime=new OLTime;this.StartTimeTable=new OLTime;this.StartTimeReal=new OLTime;this.Class=this.Bib=this.Badge2=this.Badge1=null;this.Results=[];this.RacePoints=this.Splits=null;this.FileFormats=e;this.ShootingPenalties=this.RankTmp=this.WorstPossibleRankTmp=this.BestPossibleRankTmp=this.RunningTimeTmp=null;this.UpdateData(a,b)};
OLIndividualCompetitorRace.prototype.UpdateData=function(a,b){this.RaceNo=a[this.FileFormats.OLIndividualCompetitorRace.RaceNo];this.Status=a[this.FileFormats.OLIndividualCompetitorRace.Status];this.Badge1=a[this.FileFormats.OLIndividualCompetitorRace.Badge1];this.Badge2=a[this.FileFormats.OLIndividualCompetitorRace.Badge2];this.Bib=a[this.FileFormats.OLIndividualCompetitorRace.Bib];this.RacePoints=this.FileFormats.OLIndividualCompetitorRace.RacePoints&&a[this.FileFormats.OLIndividualCompetitorRace.RacePoints]?
a[this.FileFormats.OLIndividualCompetitorRace.RacePoints]:null;this.ShootingPenalties=this.FileFormats.OLIndividualCompetitorRace.ShootingPenalties&&a[this.FileFormats.OLIndividualCompetitorRace.ShootingPenalties]?a[this.FileFormats.OLIndividualCompetitorRace.ShootingPenalties]:null;null!=this.Class?this.Class.ID!=a[this.FileFormats.OLIndividualCompetitorRace.ClassID]&&(this.Class=b[a[this.FileFormats.OLIndividualCompetitorRace.ClassID]]):this.Class=b[a[this.FileFormats.OLIndividualCompetitorRace.ClassID]];
this.PenaltyTime.UpdateData(a[this.FileFormats.OLIndividualCompetitorRace.PenaltyTime],this.RaceNo,0);this.StartTimeTable.UpdateData(a[this.FileFormats.OLIndividualCompetitorRace.StartTimeTable],this.RaceNo,-2);this.StartTimeReal.UpdateData(a[this.FileFormats.OLIndividualCompetitorRace.StartTimeReal],this.RaceNo,-1);if(null!=a[this.FileFormats.OLIndividualCompetitorRace.Results])for(var d in a[this.FileFormats.OLIndividualCompetitorRace.Results])this.UpdateResult(a[this.FileFormats.OLIndividualCompetitorRace.Results][d],
a[this.FileFormats.OLIndividualCompetitorRace.Results][d][this.FileFormats.OLResult.Point-2])};OLIndividualCompetitorRace.prototype.UpdateStartTimeReal=function(a){a.ChangedClassIDs&&(a.ChangedClassIDs[this.Class.ID]=this.Class.ID,a.ChangedRaceNos[this.RaceNo]=this.RaceNo,a.ChangedTimingPointsAll=!0);this.StartTimeReal.UpdateData(a[this.FileFormats.OLStartTimeReal.StartTimeReal-2],this.RaceNo,-1)};
OLIndividualCompetitorRace.prototype.UpdateResult=function(a,b){if(this.Results[b])return this.Results[b].UpdateData(a,this.RaceNo);this.Results[b]=new OLResult(a,this.RaceNo,this.FileFormats.OLResult);return!0};OLIndividualCompetitorRace.prototype.UpdateBadges=function(a,b){this.Badge1=a;this.Badge2=b;return!0};
OLIndividualCompetitorRace.prototype.UpdateSplits=function(a){if(this.Splits)return this.Splits.UpdateData(a,this.RaceNo);this.Splits=new OLSplits(a,this.RaceNo,this.FileFormats.OLSplits,this.FileFormats.OLControl);return!0};OLIndividualCompetitorRace.prototype.GetNameStd=function(a){return this.Competitor.NameFirst+" "+this.Competitor.NameLast};
OLIndividualCompetitorRace.prototype.GetRaceTimeNow=function(){if("OP"==this.Status&&null===this.Results[0].TimeRace.Time){var a=this.Competitor.Event.GetNow(),b=(null===this.StartTimeReal.Time?this.StartTimeTable.Time:this.StartTimeReal.Time)+OLTime.RaceDates[this.RaceNo].getTime()+OLTime.TimeZoneDiffToLocalMS,a=a-b;null!=this.PenaltyTime.Time&&(a+=this.PenaltyTime.Time);0>a&&(a=0);this.RunningTimeTmp=new OLTime(a,this.RaceNo,-4);this.RunningTimeTmp.Time=a}else this.RunningTimeTmp=null;return this.RunningTimeTmp};
OLIndividualCompetitorRace.prototype.GetPossibleFinalClasses=function(){return null===this.BestPossibleRankTmp||null===this.WorstPossibleRankTmp?"":this.Class.GetPossibleFinalClasses(this.RaceNo,this.BestPossibleRankTmp,this.WorstPossibleRankTmp)};OLIndividualCompetitorRace.HowManyOpenAndFinished=function(a){var b=0,d;for(d in a)"OP"!=a[d].Status&&null===a[d].Results[0].TimeRace.Time||++b;return b};
OLIndividualCompetitorRace.prototype.HowManyFinishedBeforeMe=function(a){var b=0,d;for(d in a)null!==a[d].Results[0].TimeRace.Time&&null!==this.RunningTimeTmp&&a[d].Results[0].TimeRace.getValueRank()"+a[h]+"";e.appendChild(g);H.appendChild(e);H.appendChild(document.createElement("tbody"));H.appendChild(document.createElement("tfoot"));
$("#online_content").append(H);$("#online_content").append(B);$("#online_content").append(K);""!=b&&(B.innerHTML=b);""!=d&&(K.innerHTML=d);f();A()}function d(a){w.startDownloadCompetitorData();setInterval(function(){l.DownloadEventData()},18E4)}function e(){F.innerHTML=''+l.Headers.EventTitle+" ";z=C="";l.Headers.AllowFollowAll||(U=L=M=-1,l.SocketIOStopFollowing());t="Relay"==l.Headers.EventType?new OLShowEventIndexRelay(l,w):new OLShowEventIndexIndividual(l,w);
y(D,B,t,null,null);b(t.Columns)}function f(){$("#OnlineTable tbody").unbind("click");$("#OnlineTable tbody").on("click","a",function(a){a.preventDefault();$.event.trigger({type:"LinkClicked",url:this.href,title:"default",time:new Date})});$("#OnlineHeaderLower").unbind("click");$("#OnlineHeaderLower").on("click","a",function(a){$(this).hasClass("ExternalLink")||(a.preventDefault(),$.event.trigger({type:"LinkClicked",url:this.href,title:"default",time:new Date}))});$("#OnlineFooterLower").unbind("click");
$("#OnlineFooterLower").on("click","a",function(a){$(this).hasClass("ExternalLink")||(a.preventDefault(),$.event.trigger({type:"LinkClicked",url:this.href,title:"default",time:new Date}))})}function g(a){J.SetUserSettingsFromLocalStorage();l.Headers.AllowFollowAll?(w.DownloadAllResults(),G()):(G(),l.Headers.Online&&l.ConnectToServer(),$("#DownloadStatus").dialog("close"));if(!l.FollowingFavourites){for(var b in w.FavouritesByBaseBib)l.SocketIOSubscribe(b);l.FollowingFavourites=!0}}function h(a){console.log(a);
console.log("window.location.reload()");window.location.reload()}function k(a){G();l.Headers.Online&&l.ConnectToServer();$("#DownloadStatus").dialog("close");for(var b in R)Y(R[b]);R=[]}function n(a){console.log("onSocketIOStopFollowing");l.SocketIOStopFollowing()}function r(a){J.InitializeMessagingIfNecessary()}function u(a){a.message.DoNotStopFollowing||l.SocketIOStopFollowing();var b={};if(a.message.Type&&"TopResults"==a.message.Type)b.Type="TopResults",b.ClassID=a.message.ClassID,b.RaceNo=a.message.RaceNo,
b.Point=a.message.Point,l.SocketIOStartFollowing(b);else if(a.message.PostID)b.Type="ResultboardPost",b.ResultBoardPostNo=a.message.PostID,l.SocketIOStartFollowing(b);else if(null!==a.message.BaseBib&&0"+Texts.LegTimes+
" "+d+". "+Texts.leg+" "+f.getDistanceInKM(d,e)+"",z=Texts.LegTimes+" "+d+". "+Texts.leg+" "+f.getDistanceInKM(d,e)+" | "+f.ClassNameShort):0==e?l.Headers.IsRoundCompetition&&l.Headers.Online?(C=""+Texts.RoundsStatus+" ",z=Texts.RoundsStatus+" | "+f.ClassNameShort):(C=""+Texts.Maali+" "+f.getDistanceInKM(d,e)+" ",z=Texts.Maali+" "+f.getDistanceInKM(d,e)+" | "+f.ClassNameShort):(C=""+Texts.Valiaika+" "+f.getDistanceInKM(d,e)+" ",z=Texts.Valiaika+" "+f.getDistanceInKM(d,
e)+" | "+f.ClassNameShort);t=l.ClassesByID[a].Races[d].BigRelay?new OLShowStandingsRaceRelayBig(f,d,e,l,w.TmpBigRelayResults,w.TmpBigRelayResultsByBaseBib):new OLShowStandingsRace(d,e,w.CompetitorRaces[a][d],f,l);y(D,B,t,l.ClassesByID[a],d);b(t.Columns)}function v(a,d,e){console.log("ShowStandingsTotal("+a+","+d+","+e+")");F.innerHTML=l.Headers.EventTitle;var f=l.ClassesByID[a];"Relay"==l.Headers.EventType?0==e?d==f.LastRace?(C=""+Texts.Maali+" "+f.getDistanceInKM(d,e)+" ",z=Texts.Maali+" "+
f.getDistanceInKM(d,e)+" | "+f.ClassNameShort):(C=""+d+". "+Texts.Vaihto+" "+f.getDistanceInKM(d,e)+" ",z=d+". "+Texts.Vaihto+" "+f.getDistanceInKM(d,e)+" | "+f.ClassNameShort):(C=""+d+". "+Texts.leg+" "+Texts.Valiaika+" "+f.getDistanceInKM(d,e)+" ",z=d+". "+Texts.leg+" "+Texts.Valiaika+" "+f.getDistanceInKM(d,e)+" | "+f.ClassNameShort):"Pursuit"==f.Races[d].MultiRaceType?0==e?(C=""+Texts.Maali+" "+f.getDistanceInKM(d,e)+" ",z=Texts.Maali+" "+f.getDistanceInKM(d,e)+" | "+f.ClassNameShort):
(C=""+Texts.Valiaika+" "+f.getDistanceInKM(d,e)+" ",z=Texts.Valiaika+" "+f.getDistanceInKM(d,e)+" | "+f.ClassNameShort):(C=""+Texts.TotalTimes+" ",z=Texts.TotalTimes+" | "+f.ClassNameShort);t=l.ClassesByID[a].Races[d].BigRelay?new OLShowStandingsTotalRelayBig(f,d,e,l,w.TmpBigRelayResults,w.TmpBigRelayResultsByBaseBib):new OLShowStandingsTotal(d,e,w.CompetitorRaces[a][d],f,l);y(D,B,t,l.ClassesByID[a],d);b(t.Columns)}function A(a){if(null!=t){var b=!1,d=!1;J.NotificationsFavourites&&
a&&a.PkgClass&&a.PkgClass==l.PkgClasses.OLResult&&a.ChangedCompetitorID&&"undefined"!==typeof w.CompetitorsByID[a.ChangedCompetitorID]&&null!=w.FavouritesByBaseBib[w.CompetitorsByID[a.ChangedCompetitorID].BaseBib]&&DisplayResultNotification(w.CompetitorsByID[a.ChangedCompetitorID],a.RaceNo,a.Point);if(a&&a.PkgClass&&a.PkgClass==l.PkgClasses.OLTopResult){var e="notification-competitor-"+a.BaseBib+"-"+a.RaceNo+"-"+a.Point+"-"+a.Time;if(J.NotificationsNewLeader&&!J.isNotificationAlreadySent(e)&&1==a.Rank){var f=
l.ClassesByID[a.ClassID],e=f.getSmartFollowUrl(a.RaceNo),g=Texts.NewLeader+" "+f.ClassNameShort,g=g+(" "+f.getTimingPointTitle(a.RaceNo,a.Point,!1)),f=a.Time+" ";if("Relay"==l.Headers.EventType){if(f+=a.ClubName,""!=a.FirstName||""!=a.LastName)f+=" ("+a.FirstName+" "+a.LastName+")"}else f+=a.FirstName+" "+a.LastName,""!=a.ClubName&&(f+=" ("+a.ClubName+")");$.notify({title:g,content:f,url:e},{style:"OLResultNotification",autoHideDelay:1E4,clickToHide:!1})}}if(a&&a.PkgClass==l.PkgClasses.OLTopResult&&
"OLShowLeaderBoard"==t.Name)a.ClassID==t.ClassID&&(b=!0);else if("OLShowCompetitorIndividual"!=t.Name)if("OLShowResultBoard"==t.Name.substring(0,17))if(a&&a.PkgClass&&a.PkgClass==l.PkgClasses.OLResultBoardControlMessage)t.ShowCompetitorInteractive(a),b=!0;else if("FollowTimingPoints"==t.DisplayMode.Action&&a&&a.PkgClass&&a.PkgClass==l.PkgClasses.OLResult){for(var h in a.ChangedRaceNos){a.RaceNo=a.ChangedRaceNos[h];break}for(var k in a.ChangedTimingPoints){a.Point=a.ChangedTimingPoints[k];break}if(!l.Headers.AllowFollowAll||
l.AreWeFollowing(a.ChangedClassIDs,a.RaceNo,a.Point))"Relay"==l.Headers.EventType?(a.ClubName=w.CompetitorsByID[a.ChangedCompetitorID].Club.ClubNameShort,a.TeamNo=w.CompetitorsByID[a.ChangedCompetitorID].TeamNo):a.Name=w.CompetitorsByID[a.ChangedCompetitorID].GetNameStd(),a.BaseBib=w.CompetitorsByID[a.ChangedCompetitorID].BaseBib,t.AddCompetitorToFollow(a),b=!0}else{if("LatestBoard"==t.DisplayMode.Action&&a&&a.PkgClass&&a.PkgClass==l.PkgClasses.OLResult){for(h in a.ChangedRaceNos){a.RaceNo=a.ChangedRaceNos[h];
break}for(k in a.ChangedTimingPoints){a.Point=a.ChangedTimingPoints[k];break}if(!l.Headers.AllowFollowAll||l.AreWeFollowing(a.ChangedClassIDs,a.RaceNo,a.Point))"Relay"==l.Headers.EventType?(a.ClubName=w.CompetitorsByID[a.ChangedCompetitorID].Club.ClubNameLong,a.TeamNo=w.CompetitorsByID[a.ChangedCompetitorID].TeamNo):(a.ClubName=w.CompetitorsByID[a.ChangedCompetitorID].Club.ClubNameLong,a.Name=w.CompetitorsByID[a.ChangedCompetitorID].getCompetitorLink(a.RaceNo)),a.BaseBib=w.CompetitorsByID[a.ChangedCompetitorID].BaseBib,
t.AddCompetitorToFollow(a),b=!0}}else if(!t.TableInit)return;if(null!=a){null===E||"OLShowCompetitorIndividual"!=E.Name&&"OLShowCompetitorRelay"!=E.Name||"function"===typeof E.CheckIfIdListed&&a.ChangedCompetitorID&&E.CheckIfIdListed(a.ChangedCompetitorID)&&(d=!0);if(!0===a.DoNotUpdate)console.log("No update yet!"),b=!1,Z=a.PkgID,W||(W=!0,setTimeout(function(){ca(a)},2E3));else if("OLShowEventIndexIndividual"==t.Name)b=!0;else if("OLShowResultBoardInteractive"==t.Name)a.ChangedCompetitorID&&null!==
a.ChangedCompetitorID&&(b=t.CheckIfBaseBibListed(w.CompetitorsByID[a.ChangedCompetitorID].BaseBib));else if(a.PkgClass!=l.PkgClasses.OLClub)if("OLShowFavourites"==t.Name)for(var r in a.ChangedClassIDs){if(null!=t.ClassesToFollow[r]){Popup=!0;break}}else if("OLShowCup"==t.Name)for(r in a.ChangedClassIDs){if(null!=t.ClassesToFollow[r]){b=!0;break}}else if("OLShowEventIndexRelay"==t.Name)b=!0;else if(a.ChangedClassIDsAll)b=!0;else if(null!=a.ChangedClassIDs[t.ClassID]&&a.ChangedClassIDs[t.ClassID]==
t.ClassID&&(a.ChangedRaceNosAll?b=!0:null==t.RaceNo?(console.log("Update: class matches. RaceNo not defined in current_view."),b=!0):t.RaceNo&&a.ChangedRaceNos[t.RaceNo]==t.RaceNo&&(a.ChangedTimingPointsAll?b=!0:null==t.TimingPoint?b=!0:a.ChangedTimingPoints[t.TimingPoint]==t.TimingPoint&&(b=!0)),null!==E&&("OLShowClubResults"==E.Name||"OLShowCompetitorIndividual"==E.Name||"OLShowCompetitorRelay"==E.Name)))for(r in a.ChangedClassIDs)if(null!=E.ClassesToFollow[r]){d=!0;break}if(a.PkgClass==l.PkgClasses.OLEventStatus&&
0$("#OnlineTable_wrapper").width()&&($("#OnlineTable_wrapper").addClass("full-width-table"),$("#OnlineTable_fade").length||
$("#OnlineTable_wrapper").before('')),t.TableStyleClass&&""!=t.TableStyleClass&&$("#OnlineTable_wrapper").addClass(t.TableStyleClass),0==S.dataTableExt.afnFiltering.length&&S.dataTableExt.afnFiltering.push(function(a,b,d){return"true"===b[0]}),S.fnDraw(),null!=t&&null!=t.SomethingHighlighted&&t.SomethingHighlighted&&t.SetHighlightUpdateTimer())}function y(a,b,d,e,f){console.log("PrintHeadersAndFooters()");if(null==d||"OLShowResultBoardAuto"!=
d.Name||"StatusBoardInteractive"!=d.DisplayMode.Action)a.innerHTML="";if(null!==e&&e&&null!==f){a.innerHTML=1"+e.ClassNameLong+" "+f+". "+Texts.day+""):a.innerHTML+(""+e.ClassNameLong+" ");var g;g=""+("< "+Texts.sarjat+" - ");"Relay"==l.Headers.EventType?g=e.Races[f].BigRelay?g+(e.getStartListLink(f)+
" - "):g+(e.getSmartFollowLink(f)+" - "):(g+=e.getStartListLink(f)+" - ",g+=e.getSmartFollowLink(f)+" - ");g+=e.getIntermediateResultsLinks(f," - ",l.Headers.IsRoundCompetition);g+=e.getFinishResultsLink(f);f!=e.FirstRace&&"Continuation"==e.Races[f].MultiRaceType?g+=" - "+e.getTotalResultsLink(f):f!=e.FirstRace&&"Pursuit"==e.Races[f].MultiRaceType?g+=" - "+e.getRaceResultsLink(f):"Relay"==l.Headers.EventType&&1 ",C=""+Texts.AllFavourites+" ",z=Texts.AllFavourites,t=new OLShowFavourites(w.FavouritesByBaseBib,l.Headers.ShowFlags),y(D,B,t,null,null),b(t.Columns);else if(f[0]===Texts.url_resultboard||"tulostaulu"===f[0])console.log("tulostaulu"),l.DoNotDownloadChangesWhenConnecting=!0,V(g);else if(f[1]==Texts.url_tilanne||"tilanne"===f[1])g=l.GetClassIDByName(f[0]),h=parseInt(f[2]),
d=parseInt(f[3]),!l.Headers.AllowFollowAll&&l.ClassesByID[g].Races[h].BigRelay&&fa(g,h,d)?(M=f=g,L=h,U=d,w.changeClassAndRaceAndPoint(f,h,d)):!l.Headers.AllowFollowAll&&O(g,h)?P(g,h):"Relay"==l.Headers.EventType||"Pursuit"==l.ClassesByID[g].Races[h].MultiRaceType?v(g,h,d):q(g,h,d);else if(f[1]==Texts.url_lopputulokset||"lopputulokset"===f[1])g=l.GetClassIDByName(f[0]),da(g);else if(f[1]==Texts.url_leaderboard||"karki"===f[1])g=l.GetClassIDByName(f[0]),F.innerHTML=l.Headers.EventTitle,d=l.ClassesByID[g],
C=""+Texts.Leaderboard+" ",z=Texts.Leaderboard+" | ",z="VE"==d.ClassNameShort?z+Texts.VenlojenViesti:"JU"==d.ClassNameShort?z+Texts.JukolanViesti:z+d.ClassNameLong,t=new OLShowLeaderBoard(d,l,w.CompetitorsByBaseBib),y(D,B,t,d,null),b(t.Columns);else if(f[1]===Texts.url_totaltimes||"yhteisajat"===f[1])g=l.GetClassIDByName(f[0]),h=parseInt(f[2]),!l.Headers.AllowFollowAll&&O(g,h)?P(g,h):v(g,h,0);else if(f[1]===Texts.url_cup||"cup"===f[1])g=l.GetClassIDByName(f[0]),d=f[2],h=parseInt(f[3]),!l.Headers.AllowFollowAll&&
O(g,h)?P(g,h):(f=g,console.log("ShowCup("+f+","+d+","+h+")"),F.innerHTML=l.Headers.EventTitle,m=l.ClassesByID[f],"undefined"!==typeof l.Cups[d]&&(d=l.Cups[d],C=d.GetOnlineHeaderLowerStaticText(),z=d.GetOnlineHtmlTitlePrefix(m.ClassNameShort),t=new OLShowCup(h,m,w.CompetitorRaces[f][h],w.CompetitorsByBaseBib,l.Headers.ShowFlags,d),y(D,B,t,l.ClassesByID[f],h)),b(t.Columns));else if(f[1]===Texts.url_racetimes||f[1]===Texts.url_legtimes||"osuusajat"===f[1])g=l.GetClassIDByName(f[0]),h=parseInt(f[2]),
!l.Headers.AllowFollowAll&&l.ClassesByID[g].Races[h].BigRelay&&fa(g,h,0)?(d=g,f=h,M=d,L=f,U=0,w.changeClassAndRaceAndPoint(d,f,0)):!l.Headers.AllowFollowAll&&O(g,h)?P(g,h):q(g,h,0);else if(f[1]===Texts.url_smart||"smart"===f[1])g=l.GetClassIDByName(f[0]),h=parseInt(f[2]),!l.Headers.AllowFollowAll&&O(g,h)?P(g,h):(d=g,f=h,console.log("ShowSmartFollow("+d+","+f+")"),h=l.ClassesByID[d],F.innerHTML=l.Headers.EventTitle,1"+Texts.SmartFollow+"",
z=Texts.SmartFollow+" | "+h.ClassNameShort):"Relay"==l.Headers.EventType?(C=""+Texts.SmartFollow+" "+f+". "+Texts.osuus+" ",z=Texts.SmartFollow+" "+f+". "+Texts.osuus+" | "+h.ClassNameShort):(C=""+Texts.SmartFollow+" ",z=Texts.SmartFollow+" | "+h.ClassNameShort),t="Relay"==l.Headers.EventType||"Pursuit"==h.Races[f].MultiRaceType?new OLShowSmartFollowTotal(w.CompetitorRaces[d][f],h,f,l.Headers):new OLShowSmartFollowRace(w.CompetitorRaces[d][f],h,f,l.Headers),y(D,B,t,l.ClassesByID[d],
f),b(t.Columns));else if(f[1]===Texts.url_kilpailijat||"kilpailijat"===f[1])if(g=l.GetClassIDByName(f[0]),""!=f[2])if(h=f[2],"p"===h.substring(0,1))h=h.substring(1),h=h=parseInt(h),l.Headers.AllowFollowAll||l.ClassesByID[g].Races[h].BigRelay||!O(g,h)?ea(g,h):P(g,h);else{if(e(),console.log(m),!m||!m[0]||"Feedback"!=decodeURIComponent(m[0])){var m=[];m.push("Competitor");m.push(parseInt(f[2]));f[3]&&m.push(parseInt(f[3]));f=window.location.origin+"/"+WwwRoot+"/"+Language+"/"+EventID+"/"+ManipulateGet(m,
window.location.search);f={Url:f};console.log(f);history.pushState(f,f.Title,f.Url);G(d)}}else ea(g);else if(!(f[0]!==Texts.url_kilpailijat&&"kilpailijat"!==f[0]||f[1]!==Texts.url_sarjoittain&&"sarjoittain"!==f[1]))console.log("ShowStartListByClass()"),F.innerHTML=l.Headers.EventTitle,C=""+Texts.StartingList+" ",a(),d="",d="Relay"==l.Headers.EventType?"StartListByClassRelay":"StartListByClassIndividual",t=new OLShowListGeneric(d,l,w.CompetitorsByBaseBib,w.Clubs),y(D,B,t,null,null);else if(!(f[0]!==
Texts.url_kilpailijat&&"kilpailijat"!==f[0]||f[1]!==Texts.url_seuroittain&&"seuroittain"!==f[1]))console.log("ShowStartListByClub()"),F.innerHTML=l.Headers.EventTitle,C=""+Texts.StartingList+" ",z=Texts.StartingList,a(),d="",d="Relay"==l.Headers.EventType?"StartListByClubRelay":"StartListByClubIndividual",t=new OLShowListGeneric(d,l,w.CompetitorsByBaseBib,w.Clubs),y(D,B,t,null,null);else if(f[0]===Texts.url_lopputulokset||"lopputulokset"===f[0])da();else if(f[0]===Texts.url_selected||"valikoidut"===
f[0])console.log("ShowSelectedResults()"),F.innerHTML=l.Headers.EventTitle,C=""+Texts.aluejalehdistotulokset+" ",a(),t=new OLShowSelectedResults("SelectedResults",l,w.Clubs),y(D,B,t,null,null);else if(f[0]===Texts.url_kilpailijat||"kilpailijat"===f[0])e(),console.log(m),m&&m[0]&&"Feedback"==decodeURIComponent(m[0])||(m=[],m.push("Competitor"),m.push(parseInt(f[1])),f[2]&&m.push(parseInt(f[2])),f=window.location.origin+"/"+WwwRoot+"/"+Language+"/"+EventID+"/"+ManipulateGet(m,window.location.search),
f={Url:f},console.log(f),history.pushState(f,f.Title,f.Url),G(d));else if(f[1]===Texts.url_rva||"rva"===f[1])g=l.GetClassIDByName(f[0]),h=parseInt(f[2]),l.Headers.AllowFollowAll||l.ClassesByID[g].Races[h].BigRelay||!O(g,h)?(d=g,f=h,console.log("ShowSplits("+d+","+f+")"),h=l.ClassesByID[d],F.innerHTML=l.Headers.EventTitle,"Relay"==l.Headers.EventType?(C=""+Texts.Rastivaliajat+" "+f+". "+Texts.Leg+" ",z=Texts.Rastivaliajat+" "+f+". "+Texts.Leg+" | "+h.ClassNameShort):1"+
Texts.Rastivaliajat+" "+f+". "+Texts.Day+"",z=f+" "+Texts.Rastivaliajat+" | "+h.ClassNameShort):(C=""+Texts.Rastivaliajat+" ",z=Texts.Rastivaliajat+" | "+h.ClassNameShort),t="Relay"==l.Headers.EventType?h.Races[f].BigRelay?new OLShowSplitsRelayBig(f,w.RelayCompetitorsByClassID[d],h,l.Headers.ShowFlags):new OLShowSplitsRelay(f,w.CompetitorRaces[d][f],h,l.Headers.ShowFlags):new OLShowSplitsIndividual(f,w.CompetitorRaces[d][f],h,l.Headers.ShowFlags,l.Headers.FinishLineControlCode),y(D,B,
t,h,f),b(t.Columns)):P(g,h)}function fa(a,d,b){return a!=M?(console.log("Class changed! ClassID="+a+" current_ClassID="+M),!0):d!=L?(console.log("Race changed! RaceNo="+d+" current_RaceNo="+L),!0):b!=U?(console.log("PointNo changed! PointNo="+d+" current_PointNo="+U),!0):!1}function O(a,d){return a!=M?(console.log("Class changed! ClassID="+a+" current_ClassID="+M),!0):d!=L?(console.log("Race changed! RaceNo="+d+" current_RaceNo="+L),!0):!1}function ca(a){console.log("CheckBigRelayUpdate");W=!1;Z==
l.LastReceivedPkgID.OnlineData?(a.DoNotUpdate=!1,A(a)):(console.log(Z+" != "+l.LastReceivedPkgID.OnlineData),W=!0,setTimeout(function(){ca(a)},1E3))}function P(a,d){M=a;L=d;w.changeClassAndRace(a,d)}var t=null,J=new OLUserSettings;new OLCookieBar({agreeBtn:{background:"#188C44"}});(function(){var a=window.location.pathname.split("/");""==a[0]&&a.shift();WwwRoot="";Language=null;for(var d in a)if(null===Language)"fi"==a[d]||"sv"==a[d]||"en"==a[d]||"se"==a[d]?(Language=a[d],Texts=OLTexts.getLanguageArray(Language)):
""!=a[d]&&(""!=WwwRoot&&(WwwRoot+="/"),WwwRoot+=a[d]);else if(""!=a[d]){EventID=a[d];break}})();var W=!1,Z=null,F=document.createElement("h1");F.setAttribute("id","OnlineHeaderUpper");var D=document.createElement("div");D.setAttribute("id","OnlineHeaderLower");var C="",z="",aa=document.createElement("div");aa.setAttribute("id","OnlineLanguageSelection");var N=document.createElement("div");N.setAttribute("id","OnlineStatus");N.innerHTML="Offline Offline ";
N.hidden=!0;var B=document.createElement("div");B.setAttribute("id","OnlineFooterUpper");var K=document.createElement("div");K.setAttribute("id","OnlineFooterLower");var x;x='";var I=$("body");$("head").append(' ');"undefined"!=typeof IsJukola&&IsJukola&&I.addClass("style-jukola");"undefined"!=typeof IsEmbedded&&IsEmbedded&&I.addClass("embedded");I.append('
');$("#online_content").innerHTML=
"";$("#online_content").append(x);$("#online_content").append(N);$("#online_content").append(F);$("#online_content").append(D);$("#MainMenuPanel").append(aa);x="";null===EventID?(x+=" ",x+=" ",x+=" "):
(x+=" ",x+=" ",x+=" ");$("#OnlineLanguageSelection").html(x);OnlineConnection=
!1;x="";if(null!==Language){null!==EventID&&(x+=""+Texts.kisan_etusivu+" ");x+=""+Texts.tulosten_etusivu+" ";x+=""+Texts.palaute+" ";x+=''+Texts.haku_tuloksista+" ";var I=WwwRoot.substring(0,WwwRoot.length-4),X=Language;"sv"==X&&(X="se");x=null!==EventID?x+(""+Texts.BackToPreviousVersion+" "):x+(""+Texts.BackToPreviousVersion+" ");x+=""}K.innerHTML=x;$(document).on("LinkClicked",function(a){var d={};d.href=""+window.location.href;d.origin=""+window.location.origin;d.pathname=""+window.location.pathname;d.search=""+window.location.search;"default"===a.title&&(a.title=EventID);a={Url:a.url};history.pushState(a,a.Title,a.Url);G(d)});window.addEventListener("popstate",G,!1);x=document.createElement("div");
x.setAttribute("id","CompetitorPopup");$("#online_content").append(x);var ba=!1;$("#CompetitorPopup").dialog({autoOpen:!1,resizable:!1,modal:!0,draggable:!0,width:900,position:{my:"center",at:"top+10%",of:window},open:function(){$("body").addClass("noscroll popup-open");$(".ui-widget-overlay").bind("click",function(){$("#CompetitorPopup").dialog("close")})},close:function(a,d){ba=!0;console.log("Popup closed");$(".grecaptcha-badge").addClass("hidden");var b={};b.href=""+window.location.href;b.origin=
""+window.location.origin;b.pathname=""+window.location.pathname;b.search=""+window.location.search;var e={Url:b.origin+b.pathname+ManipulateGet(null,b.search)};history.pushState(e,e.Title,e.Url);G(b);ba=!1;$("body").removeClass("noscroll popup-open")},closeOnEscape:!0});$("#CompetitorPopup").html("");var l=null,E=null;if(!0===EventError)N.hidden=!0,OnlineHeaderMenu.hidden=!0,t=new OLNoEvent("EventError"),$("#online_content").append(B),$("#online_content").append(K),Q(),G();else if(null===Language)N.hidden=
!0,OnlineHeaderMenu.hidden=!0,t=new OLNoEvent("LanguageSelection"),$("#online_content").append(B),$("#online_content").append(K),f(),Q(),G();else if(null===EventID||"haku"===EventID||"palaute"===EventID)N.hidden=!0,t=new OLNoEvent("EventSelection"),$("#online_content").append(B),$("#online_content").append(K),f(),"haku"===EventID||"palaute"===EventID?(x={},x.href=""+window.location.href,x.origin=""+window.location.origin,x.pathname=""+window.location.pathname,x.search=""+window.location.search,I=
[],"palaute"===EventID?I.push("Feedback"):"haku"===EventID&&I.push("Search"),I={Url:window.location.origin+"/"+WwwRoot+"/"+Language+"/"+ManipulateGet(I)},console.log(I),history.pushState(I,I.Title,I.Url),G(x)):(G(),Q());else{$(document).on("EventDataLoaded",d);$(document).on("CompetitorDataLoaded",g);$(document).on("DataUpdateReceived",Y);$(document).on("AllResultsDownloaded",k);$(document).on("SingleResultsDownloaded",m);$(document).on("ResetTimeChanged",h);$(document).on("ForceResetOnlineTable",
ga);$(document).on("ForceUpdateOnlineTable",ha);$(document).on("SocketIOStartFollowing",u);$(document).on("SocketIOStopFollowing",n);$(document).on("SocketIOConnected",r);window.twttr=function(a,d,b){var e=a.getElementsByTagName(d)[0],f=window.twttr||{};if(a.getElementById(b))return f;a=a.createElement(d);a.id=b;a.src="https://platform.twitter.com/widgets.js";e.parentNode.insertBefore(a,e);f._e=[];f.ready=function(a){f._e.push(a)};return f}(document,"script","twitter-wjs");x=document.createElement("div");
x.setAttribute("id","DownloadStatus");$("#online_content").append(x);$("#DownloadStatus").dialog({autoOpen:!1,resizable:!1,modal:!0,dialogClass:"no-close",draggable:!1,width:900,closeOnEscape:!1});$("#DownloadStatus").html("
");var l=new OLEvent(EventID),w=new OLCompetitors(l);J.setCurrentEvent(l);J.setCurrentCompetitors(w);l.setUserSettings(J);var M=-1,L=-1,U=-1,T=null,H=null,S=null,R=[]}AddToFavourites=function(a){console.log("AddToFavourites() "+
a);J.AddToFavourites(a)&&A()};RemoveFromFavourites=function(a){console.log("onRemoveFromFavourites() "+a);J.RemoveFromFavourites(a)&&A()};toggleMenu=function(){var a=document.getElementById("MainMenuPanel"),d=document.getElementById("MainMenuPanelContent"),b=document.getElementById("OnlineFooterLower").innerHTML,b=b+J.getSettingSelectionHTML(),e;e='";
a.classList.toggle("active");$(d).html(e+b);J.setEventHandlers();$("#MainMenuPanelContent").unbind("click");$("#MainMenuPanelContent").on("click","a",function(a){$(this).hasClass("ExternalLink")||(a.preventDefault(),toggleMenu(),$.event.trigger({type:"LinkClicked",url:this.href,title:"default",time:new Date}))})};DisplayResultNotification=function(a,d,b){var e=window.location.protocol+"//"+window.location.host+"/"+WwwRoot+"/online/online_"+l.EventID+"_statuslist.json?a="+(new Date).getTime(),e=e+
("&Get="+JSON.stringify([[a.BaseBib,d,b]]));console.log(e);$.ajax({type:"GET",url:e,async:!1}).done(function(e){if("undefined"!==typeof e[0]&&(e=e[0],e.BaseBib==a.BaseBib&&null!==e.Result&&!J.isNotificationAlreadySent("notification-competitor-"+e.BaseBib+"-"+d+"-"+b+"-"+e.Result))){var f=ManipulateGet(["Competitor",a.BaseBib,d],window.location.search),g=a.GetNameStd(!1),h=e.Result+", "+Texts.Sijoitus+" "+e.Rank+".";null!=e.Diff&&(h+=" ("+e.Diff+")");"Relay"!=l.Headers.EventType&&(g+=" "+l.ClassesByID[e.ClassID].getTimingPointTitle(d,
b,!0));$.notify({title:g,content:h,url:f},{style:"OLResultNotification",autoHideDelay:1E4,clickToHide:!1})}})};$("#SearchButton").on("click",function(){localStorage.removeItem("SearchWords");var a={};a.href=""+window.location.href;a.origin=""+window.location.origin;a.pathname=""+window.location.pathname;a.search=""+window.location.search;var d=[];d.push("Search");d={Url:window.location.origin+window.location.pathname+ManipulateGet(d,window.location.search)};console.log(d);history.pushState(d,d.Title,
d.Url);G(a)})});function SplitGetToParams(a){var b={};if(a&&""!=a){a=a.substring(1).split("&");for(var d in a)null===b&&(b={}),temp=a[d].split("="),""!=temp[0]&&""!=temp[1]&&(b[temp[0]]=temp[1])}return b}
function ManipulateGet(a,b){var d="",e=!1;if(b&&""!=b){var f=b.substring(1).split("&"),g;for(g in f){var h=f[g].split("="),k=h[0],h=h[1];"Popup"==k?null!==a&&(d+="&Popup="+a.join(";"),e=!0):d+="&"+k+"="+h}}null===a||e||(d+="&Popup="+a.join(";"));""!=d&&"&"==d.substr(0,1)&&(d=d.substr(1));""!=d&&"?"!=d.substr(0,1)&&(d="?"+d);return d}function IsArrayEmpty(a){for(var b in a)return!1;return!0}function die(){throw Error("Die");};var OLNoEvent=function(a){this.Name="OLNoEvent";this.SubName=a;this.SelectionDiv=document.createElement("div");this.SelectionDiv.setAttribute("id","SelectionDiv");$("#online_content").append(this.SelectionDiv);a="";if("LanguageSelection"==this.SubName)a+="Valitse kieli / V\u00e4lj spr\u00e5k / Choose language ",this.SelectionDiv.innerHTML=
a;else if("EventError"!=this.SubName&&"EventSelection"==this.SubName){a+=""+Texts.valitse_kilpailu+" ";this.SelectionDiv.innerHTML=a;a=["",""];var b={processing:!0,ordering:!1,columns:[{data:function(a,d,b,e){return null!==a.EventID&&null!==a.EventTitle?""+a.EventTitle+" ":"?"}},{data:function(a,d,b,e){return!0===a.Online?"ONLINE ":""},sClass:"Nationality"}],info:!1,paging:!1,ajax:"/"+WwwRoot+"/online/online_events_dt.json"},
d=document.createElement("table");d.setAttribute("id","EventSelection");d.setAttribute("class","display nowrap compact");var e=document.createElement("thead"),f=document.createElement("tr"),g;for(g in a)f.innerHTML+=""+a[g]+" ";e.appendChild(f);d.appendChild(e);d.appendChild(document.createElement("tbody"));d.appendChild(document.createElement("tfoot"));this.SelectionDiv.appendChild(d);var h=$(d).DataTable(b);setInterval(function(){h.ajax.reload(null,!1)},9E4);d.className+=" EventSelection";
$("#EventSelection_wrapper").addClass("narrow-table")}};var OLRelayCompetitor=function(a,b,d,e,f){this.ID=a[f.JsonFileFormats.OLRelayCompetitor.CompetitorID];this.Bib=this.Class=this.Nationality=this.Club=this.BaseBib=null;this.TeamNo=0;this.FileFormats=f.JsonFileFormats;this.Event=f;this.Races=[];this.isFavourite=!1;this.UpdateData(a,b,d,e)};
OLRelayCompetitor.prototype.UpdateData=function(a,b,d,e){this.BaseBib=null!=a[this.FileFormats.OLRelayCompetitor.BaseBib]?a[this.FileFormats.OLRelayCompetitor.BaseBib]:null;this.Club="object"==typeof b[a[this.FileFormats.OLRelayCompetitor.ClubID]]?b[a[this.FileFormats.OLRelayCompetitor.ClubID]]:e;this.Nationality=null!=a[this.FileFormats.OLRelayCompetitor.Nationality]?a[this.FileFormats.OLRelayCompetitor.Nationality]:"";this.TeamNo=null!=a[this.FileFormats.OLRelayCompetitor.TeamNo]?a[this.FileFormats.OLRelayCompetitor.TeamNo]:
0;this.Bib=null!=a[this.FileFormats.OLRelayCompetitor.Bib]?a[this.FileFormats.OLRelayCompetitor.Bib]:null;null!=this.Class?this.Class.ID!=a[this.FileFormats.OLRelayCompetitor.ClassID]&&(this.Class=d[a[this.FileFormats.OLRelayCompetitor.ClassID]]):this.Class=d[a[this.FileFormats.OLRelayCompetitor.ClassID]];if(a.ChangedClassIDs){for(var f in this.Races)a.ChangedRaceNos[this.Races[f].RaceNo]=this.Races[f].RaceNo;a.ChangedClassIDs[this.Class.ID]=this.Class.ID;a.ChangedTimingPointsAll=!0}if(null!=a[this.FileFormats.OLRelayCompetitor.Races])for(var g in a[this.FileFormats.OLRelayCompetitor.Races])b=
a[this.FileFormats.OLRelayCompetitor.Races][g],d=b[this.FileFormats.OLRelayCompetitorRace.RaceNo],this.Races[d]&&(console.log("Updating RaceNo="+d),this.Races[d].UpdateData(b,this.Bib,this.Class))};
OLRelayCompetitor.prototype.UpdateRaceData=function(a,b,d,e){this.Races[b]?this.Races[b].UpdateData(a,this.Bib,this.Class):this.Races[b]=new OLRelayCompetitorRace(a,e,this.FileFormats,this.Bib,this.Class);a.ChangedClassIDs&&(a.ChangedClassIDs[this.Races[b].Class.ID]=this.Races[b].Class.ID,a.ChangedRaceNos[b]=b,a.ChangedTimingPointsAll=!0)};
OLRelayCompetitor.prototype.UpdateSplits=function(a,b,d,e){if(this.Races[b])this.Races[b].UpdateSplits(a);else return!1;a.ChangedClassIDs&&(a.ChangedClassIDs[this.Races[b].Class.ID]=this.Races[b].Class.ID,a.ChangedRaceNos[b]=b,a.ChangedTimingPointsAll=!0)};OLRelayCompetitor.prototype.ClearRaces=function(){this.Races=[]};
OLRelayCompetitor.prototype.UpdateStartTimeReal=function(a){var b=a.shift();a.ChangedClassIDs&&(a.ChangedClassIDs[this.Class.ID]=this.Class.ID,a.ChangedRaceNos[b]=b,a.ChangedTimingPointsAll=!0);return 0==this.Races.length||null==this.Races[b]?!1:this.Races[b].UpdateStartTimeReal(a)};
OLRelayCompetitor.prototype.UpdateResult=function(a){var b=a.shift(),d=a[this.FileFormats.OLResult.Point-2];a.ChangedClassIDs&&(a.ChangedClassIDs[this.Class.ID]=this.Class.ID,a.ChangedRaceNos[b]=b,a.ChangedTimingPoints[d]=d);return 0==this.Races.length||null==this.Races[b]?!1:this.Races[b].UpdateResult(a,d)};
OLRelayCompetitor.prototype.getNatPrint=function(a){return a&&"OTH"!=this.Nationality&&""!=this.Nationality?" ":this.Nationality};
OLRelayCompetitor.prototype.getCompetitorLink=function(a,b,d){var e=[];e.push("Competitor");e.push(this.BaseBib);a&&e.push(a);a=this.Club.ClubNameLong;1'+a+""};
OLRelayCompetitor.prototype.GetFavouriteButton=function(a){return this.isFavourite?""+Texts.RemoveFromFavourites+" ":""+Texts.AddToFavourites+" "};OLRelayCompetitor.prototype.GetRunnerLink=function(a,b){return this.Races[a].GetRunnerLink(b)};
OLRelayCompetitor.prototype.GetNameStd=function(a){if(null===this.Club||null===this.Club.ClubNameLong||""==this.Club.ClubNameLong)return"";var b=this.Club.ClubNameLong;1"+this.Club.ClubNameLong+""};
OLRelayCompetitor.prototype.UpdateBadges=function(a){if(0==this.Races.length)return!1;var b=a[this.FileFormats.OLUpdateBadge.RaceNo-1];a.ChangedClassIDs&&(a.ChangedClassIDs[this.Class.ID]=this.Class.ID,a.ChangedRaceNos[b]=b,a.ChangedTimingPointsAll=!0);return this.Races[b].UpdateBadges(a[this.FileFormats.OLUpdateBadge.Badge1-1],a[this.FileFormats.OLUpdateBadge.Badge2-1])};var OLRelayCompetitorRace=function(a,b,d,e,f){this.Competitor=b[a[d.OLRelayCompetitorRace.CompetitorID]];this.Status=this.RaceNo=null;this.PenaltyTime=new OLTime;this.StartTimeReal=new OLTime;this.NameFirst=this.NameLast=this.Class=this.Bib=this.Badge2=this.Badge1=null;this.Results=[];this.Splits=null;this.FileFormats=d;this.ShootingPenalties=this.RunningTimeTmp=null;this.UpdateData(a,e,f)};
OLRelayCompetitorRace.prototype.UpdateData=function(a,b,d){this.RaceNo=a[this.FileFormats.OLRelayCompetitorRace.RaceNo];this.Status=a[this.FileFormats.OLRelayCompetitorRace.Status];this.Badge1=a[this.FileFormats.OLRelayCompetitorRace.Badge1];this.Badge2=a[this.FileFormats.OLRelayCompetitorRace.Badge2];this.ShootingPenalties=this.FileFormats.OLRelayCompetitorRace.ShootingPenalties&&a[this.FileFormats.OLRelayCompetitorRace.ShootingPenalties]?a[this.FileFormats.OLRelayCompetitorRace.ShootingPenalties]:
null;this.Bib=b;this.Class=d;this.PenaltyTime.UpdateData(a[this.FileFormats.OLRelayCompetitorRace.PenaltyTime],this.RaceNo,0);this.NameLast=a[this.FileFormats.OLRelayCompetitorRace.NameLast];this.NameFirst=a[this.FileFormats.OLRelayCompetitorRace.NameFirst];this.StartTimeReal.UpdateData(a[this.FileFormats.OLRelayCompetitorRace.StartTimeReal],this.RaceNo,-1);if(null!=a[this.FileFormats.OLRelayCompetitorRace.Results])for(var e in a[this.FileFormats.OLRelayCompetitorRace.Results])this.UpdateResult(a[this.FileFormats.OLRelayCompetitorRace.Results][e],
a[this.FileFormats.OLRelayCompetitorRace.Results][e][this.FileFormats.OLResult.Point-2])};OLRelayCompetitorRace.prototype.UpdateStartTimeReal=function(a){this.StartTimeReal.UpdateData(a[this.FileFormats.OLStartTimeReal.StartTimeReal-2],this.RaceNo,-1)};OLRelayCompetitorRace.prototype.UpdateResult=function(a,b){if(this.Results[b])return this.Results[b].UpdateData(a,this.RaceNo);this.Results[b]=new OLResult(a,this.RaceNo,this.FileFormats.OLResult);return!0};
OLRelayCompetitorRace.prototype.UpdateSplits=function(a){if(this.Splits)return this.Splits.UpdateData(a,this.RaceNo);this.Splits=new OLSplits(a,this.RaceNo,this.FileFormats.OLSplits,this.FileFormats.OLControl);return!0};OLRelayCompetitorRace.prototype.GetNameStd=function(a){return a?(a=this.NameFirst.split("-"),2==a.length?a[0].substr(0,1)+"-"+a[1].substr(0,1)+". "+this.NameLast:this.NameFirst.substr(0,1)+". "+this.NameLast):this.NameFirst+" "+this.NameLast};
OLRelayCompetitorRace.prototype.GetRunnerLink=function(a){a=this.GetNameStd(a);var b=[];b.push("Competitor");b.push(this.Competitor.BaseBib);b.push(this.RaceNo);return''+a+" "};
OLRelayCompetitorRace.prototype.GetRaceTimeNow=function(){if("OP"==this.Status)if(this.StartTimeReal.Time){var a=this.Competitor.Event.GetNow(),b=this.StartTimeReal.Time+OLTime.RaceDates[this.RaceNo].getTime()+OLTime.TimeZoneDiffToLocalMS,a=a-b;0>a&&(a=0);this.RunningTimeTmp=new OLTime(a,this.RaceNo,-4);this.RunningTimeTmp.Time=a}else this.RunningTimeTmp=null;else this.RunningTimeTmp=null;return this.RunningTimeTmp};
OLRelayCompetitorRace.prototype.UpdateBadges=function(a,b){this.Badge1=a;this.Badge2=b;return!0};var OLResult=function(a,b,d){this.DiffTmp=this.RankTmp="";this.TimeTotal=new OLTime;this.TimeRace=new OLTime;this.ChangedTime=null;this.FileFormat={};a&&(this.FileFormat={},this.FileFormat.Point=d.Point+-2,this.FileFormat.TimeRace=d.TimeRace+-2,this.FileFormat.TimeTotal=d.TimeTotal+-2,this.UpdateData(a,b))};
OLResult.prototype.UpdateData=function(a,b){this.DiffTmp=this.RankTmp="";var d;d=0|this.TimeRace.UpdateData(a[this.FileFormat.TimeRace],b,a[this.FileFormat.Point]);a.length<=this.FileFormat.TimeTotal?this.TimeTotal.UpdateData(a[this.FileFormat.TimeRace],b,a[this.FileFormat.Point]):d|=this.TimeTotal.UpdateData(a[this.FileFormat.TimeTotal],b,a[this.FileFormat.Point]);d&&!ProcessingFile&&(this.ChangedTime=new Date);return d};
OLResult.getStatusText=function(a){a="Status_"+a;return null!=Texts[a]?Texts[a]:"?"};
OLResult.prototype.clone=function(){var a=new OLResult;a.TimeRace.Time=this.TimeRace.Time;a.TimeRace.PrecisionRank=this.TimeRace.PrecisionRank;a.TimeRace.PrecisionShow=this.TimeRace.PrecisionShow;a.TimeTotal.Time=this.TimeTotal.Time;a.TimeTotal.PrecisionRank=this.TimeTotal.PrecisionRank;a.TimeTotal.PrecisionShow=this.TimeTotal.PrecisionShow;null!==this.ChangedTime&&(a.ChangedTime=new Date(this.ChangedTime.getTime()));return a};var OLShowClubResults=function(a,b,d,e){this.Name="OLShowClubResults";this.RaceNo=b;this.Event=d;this.current_competitors=e;this.Club=this.current_competitors.GetClubByLongName(a);this.CompetitorsToFollow=[];this.ClassesToFollow=[];this.ResultsToBeDownloaded=[];this.PopupTable_1_DT=null;console.log("OLShowClubResults.OLShowClubResults()");$("#CompetitorPopup").html("");$("#CompetitorPopup").dialog("open");var f=e="";null===this.Club?(e=Texts.virhe+"!",f+=Texts.Seuraa+' "'+a+'" '+Texts.ei_loydy+". "):
(e=Texts.ClubResults+": "+this.Club.ClubNameLong,a=d.GetRaceTitle(b),a!=b+". "+Texts.day?e+=" "+a:1