1 2var kwtRaceListCount = 10; 3 4function KWTRaceObject(id) { 5 this.ID = id; 6 this.Author = null; 7 this.Title = ""; 8 this.Description = ""; 9 this.StartTime = null; 10 this.EndTime = null; 11 this.MaxMembers = 0; 12 this.Password = ""; 13 this.TrackID = 0; 14 this.Track = null; 15 this.DeviceType = 0; 16 this.RealityFactor = 80; 17 this.GroupID = 0; 18 this.Group = null; 19 this.GearSet = 0; 20 this.Automatic = 0; 21 this.TargetPulse = 0; 22 this.MemberCount = 0; 23 this.Winner = null; 24 this.AnnouncementCount = 0; 25 this.IsAnnounced = false; 26 this.FixTargetPulse = false; 27 this.StartDistance = -1; 28 this.TargetDistance = -1; 29 this.WinnerList = null; 30 this.RaceType = 2; 31 this.StartIntervall = null; 32 this.MaxBotCount = null; 33 this.RouteStartPointID = 0; 34 this.RouteEndPointID = 0; 35 this.HeadwindDirection = 0.0; 36 this.HeadwindSpeed = 0.0; 37 this.DisableWindShadow = false; 38 this.EveryoneCanJoin = false; 39} 40 41function KWTRaceMemberObject(id) 42{ 43 this.ID = id; 44 this.RaceID = 0; 45 this.TimeDrivingID = 0; 46 this.Person = null; 47 this.TotalTime = 0; 48 this.AverageSpeed = 0; 49 this.AveragePower = 0; 50 this.AverageRPM = 0; 51 this.AveragePulse = 0; 52 this.TotalEnergy = 0; 53 this.Milage = 0; 54 this.Rank = 0; 55 this.RaceComplete = 0; 56 this.Weight = 0; 57 this.Height = 0; 58 this.GearSet = 0; 59 this.Automatic = 0; 60 this.AveragePulsePercent = 0; 61 this.DeviceID = 0; 62 this.Strokes = 0; 63 this.AverageBrakeLevel = 0; 64 this.AverageMaxPower = 0; 65 this.Disqualified = false; 66 this.TotalTimeMS = 0; 67 this.NormalizedPower = 0; 68 this.TimeDrives = []; 69} 70 71function KWTRaceEvaluationRangeObject() { 72 this.RangeType = 0; 73 this.Start = 0; 74 this.End = 0; 75 this.Members = new Array(); 76} 77 78function KWTRaceEvaluationRangeMemberObject() { 79 this.RaceMemberID = 0; 80 this.TimeDrivingID = 0; 81 this.Person = null; 82 this.Time = 0; 83 this.Distance = 0; 84 this.AvgPower = 0; 85 this.AvgSpeed = 0; 86 this.AvgPulse = 0; 87 this.AvgRPM = 0; 88 this.AvgMaxPower = 0; 89 this.TimeMS = 0; 90 this.TimeDrives = []; 91} 92 93function KWTRaceTimeDrivingObject() { 94 this.ID = 0; 95 this.StartTime = null; 96 this.EndTime = null; 97 this.Count = 0; 98} 99 100function KWTCupHighscoreMedalObject() { 101 this.Type = 0; 102 this.Name = ""; 103 this.StartTime = null; 104} 105 106function KWTCupHighscoreObject() { 107 this.Place = 0; 108 this.User = null; 109 this.Time = 0; 110 this.Distance = 0; 111 this.Points = 0; 112 this.Medals = new Array(); 113 this.Fortunes = 0; 114 this.TimeMS = 0; 115 this.InternPoints = 0; 116 this.Trikot = ""; 117} 118 119function KWTCupTeamHighscoreObject() { 120 this.Place = 0; 121 this.Name = ""; 122 this.ShortName = ""; 123 this.Members = new Array(); 124 this.Time = 0; 125 this.Distance = 0.0; 126 this.Points = 0; 127 this.TimeMS = 0; 128} 129 130function KWTCupTeamObject() { 131 this.ID = -1; 132 this.Name = ""; 133 this.ShortName = ""; 134 this.Member1 = -1; 135 this.Member2 = -1; 136 this.Member3 = -1; 137 this.Member4 = -1; 138 this.Member5 = -1; 139} 140KWTCupTeamObject.prototype.toJSON = function () { 141 var result = ""; 142 result += "ID: " + this.ID; 143 result += ", Name: \"" + this.Name + "\""; 144 result += ", ShortName: \"" + this.ShortName + "\""; 145 result += ", Member1: " + this.Member1; 146 result += ", Member2: " + this.Member2; 147 result += ", Member3: " + this.Member3; 148 result += ", Member4: " + this.Member4; 149 result += ", Member5: " + this.Member5; 150 return "{" + result + "}"; 151}; 152KWTCupTeamObject.prototype.fromJSON = function (jo) { 153 this.ID = jo.ID; 154 this.Name = jo.Name; 155 this.ShortName = jo.ShortName; 156 this.Member1 = jo.Member1; 157 this.Member2 = jo.Member2; 158 this.Member3 = jo.Member3; 159 this.Member4 = jo.Member4; 160 this.Member5 = jo.Member5; 161 return this; 162}; 163 164 165function KWTRacePortal() { 166 this._listeners = {}; 167 this.nextGroupRaces = new Array(); 168 this.nextGroupRacesLoading = false; 169 this.nextGroup = -1; 170 this.endedGroupRaces = new Array(); 171 this.endedGroupRacesLoading = false; 172 this.endedGroup = -1; 173 this.currentRace = null; 174 this.raceMembers = new Array(); 175 this.userRaces = new Array(); 176 this.userRacesLoading = false; 177 this.evaluationRanges = new Array(); 178 this.timeDrivings = new Array(); 179 this.cupHighscoreLoaded = false; 180 this.cupHighscoreLoading = false; 181 this.cupHighscore = new Array(); 182 this.oldCupHighscoreLoaded = false; 183 this.oldCupHighscoreLoading = false; 184 this.oldCupHighscore = new Array(); 185 this.cupTeamHighscoreLoaded = false; 186 this.cupTeamHighscoreLoading = false; 187 this.cupTeamHighscore = new Array(); 188 this.cupTeamHighscoreTrackTitle = ""; 189 this.cupTeamHighscoreTrackID = ""; 190 this.cupTeamHighscoreTrackCount = 0; 191 this.cupTeamHighscoreTrackNumber = -1; 192 this.cupSprintHighscoreLoaded = false; 193 this.cupSprintHighscoreLoading = false; 194 this.cupSprintHighscore = new Array(); 195 196 this.summerCupHighscoreLoaded = false; 197 this.summerCupHighscoreLoading = false; 198 this.summerCupHighscore = new Array(); 199 this.summerCupYears = new Array(); 200 this.summerCupMonths = new Array(); 201 this.summerCupDifficulties = new Array(); 202 this.summerCupDeviceTypes = new Array(); 203 204 this.nextRacePage = 0; 205 this.nextRacePageCount = 0; 206 this.nextRaceCount = 0; 207 this.endedRacePage = 0; 208 this.endedRacePageCount = 0; 209 this.endedRaceCount = 0; 210 this.userRacesPage = 0; 211 this.userRacesPageCount = 0; 212 213 this.createdRace = null; 214 this.CreateRaceTrackID = ""; 215 216 this.nextRaces = new Array(); 217 this.nextRacesPage = 0; 218 this.nextRacesPageCount = 0; 219 this.nextRacesLastLoad = null; 220 221 this.cupTeams = new Array(); 222 this.cupTeamsLoaded = false; 223 this.cupTeamsLoading = false; 224 this.settedCupTeam = null; 225 this.deletedTeamID = -1; 226} 227 228KWTRacePortal.prototype.addListener = function (type, listener) { 229 if (typeof this._listeners[type] == "undefined") { 230 this._listeners[type] = []; 231 } 232 233 this._listeners[type].push(listener); 234};
235 236KWTRacePortal.prototype.fire = function (event) { 237 if (typeof event == "string") { 238 event = { type: event }; 239 } 240 if (!event.target) { 241 event.target = this; 242 } 243 244 if (!event.type) { //falsy 245 throw new Error("Event object missing 'type' property."); 246 } 247 248 if (this._listeners[event.type] instanceof Array) { 249 var listeners = this._listeners[event.type]; 250 for (var i = 0, len = listeners.length; i < len; i++) { 251 listeners[i].call(this, event); 252 } 253 } 254}; 255 256KWTRacePortal.prototype.removeListener = function (type, listener) { 257 if (this._listeners[type] instanceof Array) { 258 var listeners = this._listeners[type]; 259 for (var i = 0, len = listeners.length; i < len; i++) { 260 if (listeners[i] === listener) { 261 listeners.splice(i, 1); 262 break; 263 } 264 } 265 } 266}; 267 268KWTRacePortal.prototype.getRaceImage = function (type) { 269 if (type == 1) 270 return '/typo3conf/ext/wwswtportal/Resources/Public/Images/laufband_small.jpg'; 271 else if (type == 2) 272 return '/typo3conf/ext/wwswtportal/Resources/Public/Images/crosstrainer_small.jpg'; 273 else if (type == 3) 274 return '/typo3conf/ext/wwswtportal/Resources/Public/Images/radergometer_small.jpg'; 275 else if (type == 4) 276 return '/typo3conf/ext/wwswtportal/Resources/Public/Images/rower_small.png'; 277 return ""; 278} 279KWTRacePortal.prototype.getDeviceIcon = function (type) { 280 if (type == 1) 281 return '/typo3conf/ext/wwswtportal/Resources/Public/Images/treadmill_a.gif'; 282 else if (type == 2) 283 return '/typo3conf/ext/wwswtportal/Resources/Public/Images/crossergo_a.gif'; 284 else if (type == 3) 285 return '/typo3conf/ext/wwswtportal/Resources/Public/Images/wheelergo_a.gif'; 286 else if (type == 4) 287 return '/typo3conf/ext/wwswtportal/Resources/Public/Images/rower_a.gif'; 288 return ""; 289} 290 291KWTRacePortal.prototype.getDeviceTypeName = function (type) { 292 if (type == 1) 293 return getLL("Treadmill"); 294 else if (type == 2) 295 return getLL("Crosstrainer"); 296 else if (type == 3) 297 return getLL("WheelErgometer"); 298 else if (type == 4) 299 return getLL("Rower"); 300 return ""; 301} 302 303KWTRacePortal.prototype.getGearSet = function (gs) { 304 if (gs == 0) 305 return getLL("noGearset"); 306 else if (gs == 1) 307 return getLL("RennradGearset"); 308 else if (gs == 2) 309 return getLL("TourenradGearset"); 310 else if (gs == 3) 311 return getLL("MTBGearset"); 312 else if (gs == 4) 313 return getLL("RacerGearset"); 314 return ""; 315} 316 317KWTRacePortal.prototype.getTargetPulse = function (targetPulse) { 318 if (targetPulse <= 0) 319 return getLL("TargetPulseOff"); 320 else { 321 return (targetPulse / 100 * 200) + " (" + targetPulse + " %)"; 322 } 323 return ""; 324} 325 326KWTRacePortal.prototype.loadRaceObjectXML = function (jo) { 327 var r = new KWTRaceObject(jo.childNodes[0].childNodes[0].data); 328 for (var i = 1; i < jo.childNodes.length; i++) { 329 var child = jo.childNodes[i]; 330 if (WWSname(child) == "Author") 331 r.Author = userPortal.loadUserObjectXML(child); 332 else if (WWSname(child) == "Title") 333 r.Title = WWSvalue(child); 334 else if (WWSname(child) == "Description") 335 r.Description = WWSvalue(child); 336 else if (WWSname(child) == "StartTime") 337 r.StartTime = new Date(WWSvalue(child) + "Z"); 338 else if (WWSname(child) == "EndTime" && WWSvalue(child) != null) 339 r.EndTime = new Date(WWSvalue(child) + "Z"); 340 else if (WWSname(child) == "MaxMembers") 341 r.MaxMembers = WWSvalue(child); 342 else if (WWSname(child) == "Password") 343 r.Password = WWSvalue(child); 344 else if (WWSname(child) == "TrackID") 345 r.TrackID = WWSvalue(child); 346 else if (WWSname(child) == "Track") 347 r.Track = trackPortal.loadTrackObjectXml(child); 348 else if (WWSname(child) == "DeviceType") 349 r.DeviceType = WWSvalue(child); 350 else if (WWSname(child) == "RealityFactor") 351 r.RealityFactor = WWSvalue(child); 352 else if (WWSname(child) == "GroupID") 353 r.GroupID = WWSvalue(child); 354 else if (WWSname(child) == "Group") 355 r.Group = groupPortal.loadGroupObjectXML(child); 356 else if (WWSname(child) == "GearSet") 357 r.GearSet = WWSvalue(child); 358 else if (WWSname(child) == "Automatic") 359 r.Automatic = WWSvalue(child); 360 else if (WWSname(child) == "TargetPulse") 361 r.TargetPulse = WWSvalue(child); 362 else if (WWSname(child) == "MemberCount") 363 r.MemberCount = WWSvalue(child); 364 else if (WWSname(child) == "Winner") 365 r.Winner = userPortal.loadUserObjectXML(child); 366 else if (WWSname(child) == "AnnouncementCount") 367 r.AnnouncementCount = WWSvalue(child); 368 else if (WWSname(child) == "IsAnnounced") 369 r.IsAnnounced = WWSvalue(child); 370 else if (WWSname(child) == "FixTargetPulse") 371 r.FixTargetPulse = WWSvalue(child) == "true" ? true : false; 372 else if (WWSname(child) == "StartDistance") 373 r.StartDistance = WWSvalue(child); 374 else if (WWSname(child) == "TargetDistance") 375 r.TargetDistance = WWSvalue(child); 376 else if (WWSname(child) == "WinnerList") { 377 r.WinnerList = new Array(); 378 for (var j = 0; j < child.childNodes.length; j++) { 379 var child2 = child.childNodes[j]; 380 r.WinnerList.push(userPortal.loadUserObjectXML(child2)); 381 } 382 } 383 else if (WWSname(child) == "RaceType") { 384 r.RaceType = WWSvalue(child); 385 } 386 else if (WWSname(child) == "StartIntervall") r.StartIntervall = WWSvalue(child); 387 else if (WWSname(child) == "MaxBotCount") r.MaxBotCount = WWSvalue(child); 388 else if (WWSname(child) == "RouteStartPointID") r.RouteStartPointID = WWSvalue(child); 389 else if (WWSname(child) == "RouteEndPointID") r.RouteEndPointID = WWSvalue(child); 390 else if (WWSname(child) == "HeadwindDirection") r.HeadwindDirection = WWSvalue(child); 391 else if (WWSname(child) == "HeadwindSpeed") r.HeadwindSpeed = WWSvalue(child); 392 else if (WWSname(child) == "DisableWindShadow") r.DisableWindShadow = WWSvalue(child) == "true" ? true : false; 393 else if (WWSname(child) == "EveryoneCanJoin") r.EveryoneCanJoin = WWSvalue(child) == "true" ? true : false; 394 } 395 return r; 396} 397 398KWTRacePortal.prototype.loadRaceObject = function (jo) { 399 if (jo == null) return null; 400 var r = new KWTRaceObject(jo.ID); 401 r.Author = userPortal.loadUserObject(jo.Author); 402 r.Title = jo.Title; 403 r.Description = jo.Description; 404 r.StartTime = jsonDateTimeToDate(jo.StartTime); 405 if (jo.EndTime != null) 406 r.EndTime = jsonDateTimeToDate(jo.EndTime); 407 r.MaxMembers = jo.MaxMembers; 408 r.Password = jo.Password; 409 r.TrackID = jo.TrackID; 410 r.Track = trackPortal.loadTrackObject(jo.Track); 411 r.DeviceType = jo.DeviceType;
412 r.RealityFactor = jo.RealityFactor; 413 r.GroupID = jo.GroupID; 414 r.Group = groupPortal.loadGroupObject(jo.Group); 415 r.GearSet = jo.GearSet; 416 r.Automatic = jo.Automatic; 417 r.TargetPulse = jo.TargetPulse; 418 r.MemberCount = jo.MemberCount; 419 r.Winner = userPortal.loadUserObject(jo.Winner); 420 r.AnnouncementCount = jo.AnnouncementCount; 421 r.IsAnnounced = jo.IsAnnounced; 422 r.FixTargetPulse = jo.FixTargetPulse; 423 r.StartDistance = jo.StartDistance; 424 r.TargetDistance = jo.TargetDistance; 425 r.WinnerList = new Array(); 426 for (var i = 0; i < jo.WinnerList.length; i++) { 427 r.WinnerList.push(userPortal.loadUserObject(jo.WinnerList[i])); 428 } 429 r.RaceType = jo.RaceType; 430 r.StartIntervall = jo.StartIntervall; 431 r.MaxBotCount = jo.MaxBotCount; 432 r.RouteStartPointID = jo.RouteStartPointID; 433 r.RouteEndPointID = jo.RouteEndPointID; 434 r.HeadwindDirection = jo.HeadwindDirection; 435 r.HeadwindSpeed = jo.HeadwindSpeed; 436 r.DisableWindShadow = jo.DisableWindShadow; 437 r.EveryoneCanJoin = jo.EveryoneCanJoin; 438 return r; 439} 440 441KWTRacePortal.prototype.loadGroupRaces = function (groupID, limit, page) { 442 racePortal.endedGroupRacesLoading = true; 443 racePortal.endedGroup = groupID; 444 //var postData = "{req: {API_KEY: \"" + api_key + "\", SessionID: \"" + kwt_ajaxportal_sessionID + "\", GroupID: " + groupID + "}}"; 445 var postData = '<?xml version="1.0" encoding="utf-8"?>'; 446 postData += '<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">'; 447 postData += '<soap12:Body>'; 448 postData += '<GetGroupRaces xmlns="http://www.kettlerworldtours.net/RacePortal/">'; 449 postData += ' <req>'; 450 postData += ' <API_KEY>' + api_key + '</API_KEY>'; 451 postData += ' <SessionID>' + kwt_ajaxportal_sessionID + '</SessionID>'; 452 postData += ' <GroupID>' + groupID + '</GroupID>'; 453 postData += ' <Limit>' + limit + '</Limit>'; 454 postData += ' <Page>' + page + '</Page>'; 455 postData += ' <RaceKind>1</RaceKind>'; 456 postData += ' </req>'; 457 postData += '</GetGroupRaces>'; 458 postData += '</soap12:Body>'; 459 postData += '</soap12:Envelope>'; 460 $.ajax( 461 { 462 type: "POST", 463 //url: "/KWTPortal2/RacePortal.asmx/GetGroupRaces", 464 url: "/KWTPortal2/RacePortal.asmx", 465 //dataType: "json", 466 //contentType: "application/json; charset=utf-8", 467 dataType: "xml", 468 contentType: "text/xml", 469 success: this.OnKWTGroupRacesLoaded, 470 error: this.OnKWTGroupRacesError, 471 data: postData 472 } 473 ); 474} 475 476KWTRacePortal.prototype.loadNextGroupRaces = function (groupID, limit, page) { 477 racePortal.nextGroupRacesLoading = true; 478 racePortal.nextGroup = groupID; 479 //var postData = "{req: {API_KEY: \"" + api_key + "\", SessionID: \"" + kwt_ajaxportal_sessionID + "\", GroupID: " + groupID + "}}"; 480 var postData = '<?xml version="1.0" encoding="utf-8"?>'; 481 postData += '<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">'; 482 postData += '<soap12:Body>'; 483 postData += '<GetGroupRaces xmlns="http://www.kettlerworldtours.net/RacePortal/">'; 484 postData += ' <req>'; 485 postData += ' <API_KEY>' + api_key + '</API_KEY>'; 486 postData += ' <SessionID>' + kwt_ajaxportal_sessionID + '</SessionID>'; 487 postData += ' <GroupID>' + groupID + '</GroupID>'; 488 postData += ' <Limit>' + limit + '</Limit>'; 489 postData += ' <Page>' + page + '</Page>'; 490 postData += ' <RaceKind>2</RaceKind>'; 491 postData += ' </req>'; 492 postData += '</GetGroupRaces>'; 493 postData += '</soap12:Body>'; 494 postData += '</soap12:Envelope>'; 495 $.ajax( 496 { 497 type: "POST", 498 //url: "/KWTPortal2/RacePortal.asmx/GetGroupRaces", 499 url: "/KWTPortal2/RacePortal.asmx", 500 //dataType: "json", 501 //contentType: "application/json; charset=utf-8", 502 dataType: "xml", 503 contentType: "text/xml", 504 success: this.OnKWTNextGroupRacesLoaded, 505 error: this.OnKWTNextGroupRacesError, 506 data: postData 507 } 508); 509} 510 511KWTRacePortal.prototype.OnKWTGroupRacesLoaded = function (msg, textStatus, jqXHR) { 512 racePortal.endedGroupRacesLoading = false; 513 racePortal.endedGroupRaces = []; 514 var races = msg.documentElement.childNodes[0].childNodes[0].childNodes[0].childNodes[1]; 515 var raceCount = msg.documentElement.childNodes[0].childNodes[0].childNodes[0].childNodes[2].childNodes[0].data; 516 for (var i = 0; i < races.childNodes.length; i++) { 517 var jg = races.childNodes[i];
518 var r = racePortal.loadRaceObjectXML(jg); 519 racePortal.endedGroupRaces.push(r); 520 } 521 racePortal.endedRacePageCount = Math.round((raceCount / kwtRaceListCount) + 0.499); 522 racePortal.endedRaceCount = raceCount; 523 racePortal.fire({ type: "OnGroupRacesLoaded", Kind: 1, Result: 1 }); 524} 525 526KWTRacePortal.prototype.OnKWTGroupRacesError = function (jqXHR, textStatus, errorThrown) { 527 racePortal.endedGroupRacesLoading = false; 528 racePortal.fire({ type: "OnGroupRacesLoaded", Kind: 1, Result: -100 }); 529} 530 531KWTRacePortal.prototype.OnKWTNextGroupRacesLoaded = function (msg, textStatus, jqXHR) { 532 racePortal.nextGroupRacesLoading = false; 533 racePortal.nextGroupRaces = []; 534 var races = msg.documentElement.childNodes[0].childNodes[0].childNodes[0].childNodes[1]; 535 var raceCount = msg.documentElement.childNodes[0].childNodes[0].childNodes[0].childNodes[2].childNodes[0].data; 536 for (var i = 0; i < races.childNodes.length; i++) { 537 var jg = races.childNodes[i]; 538 var r = racePortal.loadRaceObjectXML(jg); 539 racePortal.nextGroupRaces.push(r); 540 } 541 racePortal.nextRacePageCount = Math.round((raceCount / kwtRaceListCount) + 0.499); 542 racePortal.nextRaceCount = raceCount; 543 racePortal.fire({ type: "OnGroupRacesLoaded", Kind: 2 }); 544} 545 546KWTRacePortal.prototype.OnKWTNextGroupRacesError = function (jqXHR, textStatus, errorThrown) { 547 racePortal.nextGroupRacesLoading = false; 548 racePortal.fire({ type: "OnGroupRacesLoaded", Kind: 2, Result: -100 }); 549} 550 551KWTRacePortal.prototype.getNextRaces = function () { 552 return racePortal.nextGroupRaces; 553} 554 555KWTRacePortal.prototype.getEndedRaces = function () { 556 return racePortal.endedGroupRaces; 557} 558 559KWTRacePortal.prototype.getRace = function (raceID) { 560 if (racePortal.currentRace != null && racePortal.currentRace.ID == raceID) 561 return racePortal.currentRace; 562 for (var i = 0; i < racePortal.nextGroupRaces.length; i++) { 563 if (racePortal.nextGroupRaces[i].ID == raceID) 564 return racePortal.nextGroupRaces[i]; 565 } 566 for (var i = 0; i < racePortal.endedGroupRaces.length; i++) { 567 if (racePortal.endedGroupRaces[i].ID == raceID) 568 return racePortal.endedGroupRaces[i]; 569 } 570 racePortal.loadRace(raceID); 571 return null; 572} 573 574 575KWTRacePortal.prototype.loadRace = function (raceID) { 576 var postData = "{req: {API_KEY: \"" + api_key + "\", SessionID: \"" + kwt_ajaxportal_sessionID + "\", RaceID: " + raceID + "}}"; 577 $.ajax( 578 { 579 type: "POST", 580 url: "/KWTPortal2/RacePortal.asmx/GetRace", 581 dataType: "json", 582 contentType: "application/json; charset=utf-8", 583 success: this.OnKWTGetRaceLoaded, 584 error: this.OnKWTGetRaceError, 585 data: postData 586 } 587); 588} 589KWTRacePortal.prototype.OnKWTGetRaceLoaded = function (msg, textStatus, jqXHR) { 590 if (msg.d.ResultCode == 1) { 591 racePortal.currentRace = racePortal.loadRaceObject(msg.d.Race); 592 racePortal.fire({ type: "OnRaceLoaded", Result: 1 }); 593 } 594 else 595 racePortal.fire({ type: "OnRaceLoaded", Result: -1 }); 596} 597 598KWTRacePortal.prototype.OnKWTGetRaceError = function (jqXHR, textStatus, errorThrown) { 599 racePortal.fire({ type: "OnRaceLoaded", Result: -100 }); 600} 601 602 603KWTRacePortal.prototype.loadRaceMembers = function (raceID) { 604 var postData = "{req: {API_KEY: \"" + api_key + "\", SessionID: \"" + kwt_ajaxportal_sessionID + "\", RaceID: " + raceID + "}}"; 605 $.ajax( 606 { 607 type: "POST", 608 url: "/KWTPortal2/RacePortal.asmx/GetRaceMembers", 609 dataType: "json", 610 contentType: "application/json; charset=utf-8", 611 success: this.OnKWTRaceMembersLoaded, 612 error: this.OnKWTRaceMembersError, 613 data: postData 614 } 615); 616} 617 618 619 620KWTRacePortal.prototype.OnKWTRaceMembersLoaded = function (msg, textStatus, jqXHR) { 621 racePortal.raceMembers = []; 622 racePortal.evaluationRanges = []; 623 racePortal.timeDrivings = []; 624 if (msg.d.ResultCode == 1) { 625 for (var i = 0; i < msg.d.RaceMembers.length; i++) { 626 var jo = msg.d.RaceMembers[i]; 627 var rm = new KWTRaceMemberObject(jo.ID); 628 rm.TimeDrives = []; 629 rm.RaceID = jo.RaceID; 630 rm.TimeDrivingID = jo.TimeDrivingID; 631 rm.Person = userPortal.loadUserObject(jo.Person);
632 rm.TotalTime = jo.TotalTime; 633 rm.AverageSpeed = jo.AverageSpeed; 634 rm.AveragePower = jo.AveragePower; 635 rm.AverageRPM = jo.AverageRPM; 636 rm.AveragePulse = jo.AveragePulse; 637 rm.TotalEnergy = jo.TotalEnergy; 638 rm.Milage = jo.Milage; 639 rm.Rank = jo.Rank; 640 rm.RaceComplete = jo.RaceComplete; 641 rm.Weight = jo.Weight; 642 rm.Height = jo.Height; 643 rm.GearSet = jo.GearSet; 644 rm.Automatic = jo.Automatic; 645 rm.AveragePulsePercent = jo.AveragePulsePercent; 646 rm.DeviceID = jo.DeviceID; 647 rm.Strokes = jo.Strokes; 648 rm.AverageBrakeLevel = jo.AverageBrakeLevel; 649 rm.AverageMaxPower = jo.AverageMaxPower; 650 rm.TotalTimeMS = jo.TotalTimeMS; 651 rm.NormalizedPower = jo.NormalizedPower; 652 for (var j = 0; j < jo.TimeDrives.length; j++) { 653 var jo2 = jo.TimeDrives[j]; 654 var rm2 = new KWTRaceMemberObject(jo2.ID); 655 rm2.RaceID = jo2.RaceID; 656 rm2.TimeDrivingID = jo2.TimeDrivingID; 657 rm2.Person = userPortal.loadUserObject(jo2.Person); 658 rm2.TotalTime = jo2.TotalTime; 659 rm2.AverageSpeed = jo2.AverageSpeed; 660 rm2.AveragePower = jo2.AveragePower; 661 rm2.AverageRPM = jo2.AverageRPM; 662 rm2.AveragePulse = jo2.AveragePulse; 663 rm2.TotalEnergy = jo2.TotalEnergy; 664 rm2.Milage = jo2.Milage; 665 rm2.Rank = jo2.Rank; 666 rm2.RaceComplete = jo2.RaceComplete; 667 rm2.Weight = jo2.Weight; 668 rm2.Height = jo2.Height; 669 rm2.GearSet = jo2.GearSet; 670 rm2.Automatic = jo2.Automatic; 671 rm2.AveragePulsePercent = jo2.AveragePulsePercent; 672 rm2.DeviceID = jo2.DeviceID; 673 rm2.Strokes = jo2.Strokes; 674 rm2.AverageBrakeLevel = jo2.AverageBrakeLevel; 675 rm2.AverageMaxPower = jo2.AverageMaxPower; 676 rm2.TotalTimeMS = jo2.TotalTimeMS; 677 rm2.NormalizedPower = jo2.NormalizedPower; 678 rm.TimeDrives.push(rm2); 679 } 680 racePortal.raceMembers.push(rm); 681 } 682 for (var i = 0; i < msg.d.EvaluationRanges.length; i++) { 683 var jo = msg.d.EvaluationRanges[i]; 684 var range = new KWTRaceEvaluationRangeObject(); 685 range.RangeType = jo.RangeType; 686 range.Start = jo.Start; 687 range.End = jo.End; 688 for (var j = 0; j < jo.Members.length; j++) { 689 var mj = jo.Members[j]; 690 var rmm = new KWTRaceEvaluationRangeMemberObject(); 691 rmm.RaceMemberID = mj.RaceMemberID; 692 rmm.TimeDrivingID = mj.TimeDrivingID; 693 rmm.Person = userPortal.loadUserObject(mj.Person); 694 rmm.Time = mj.Time; 695 rmm.TimeMS = mj.TimeMS; 696 rmm.Distance = mj.Distance; 697 rmm.AvgPower = mj.AvgPower; 698 rmm.AvgSpeed = mj.AvgSpeed; 699 rmm.AvgPulse = mj.AvgPulse; 700 rmm.AvgRPM = mj.AvgRPM; 701 rmm.AvgMaxPower = mj.AvgMaxPower; 702 for (var k = 0; k < mj.TimeDrives.length; k++) { 703 var mj2 = mj.TimeDrives[k]; 704 var rmm2 = new KWTRaceEvaluationRangeMemberObject(); 705 rmm2.RaceMemberID = mj2.RaceMemberID; 706 rmm2.TimeDrivingID = mj2.TimeDrivingID; 707 rmm2.Person = userPortal.loadUserObject(mj2.Person); 708 rmm2.Time = mj2.Time; 709 rmm2.TimeMS = mj2.TimeMS; 710 rmm2.Distance = mj2.Distance; 711 rmm2.AvgPower = mj2.AvgPower; 712 rmm2.AvgSpeed = mj2.AvgSpeed; 713 rmm2.AvgPulse = mj2.AvgPulse; 714 rmm2.AvgRPM = mj2.AvgRPM; 715 rmm2.AvgMaxPower = mj2.AvgMaxPower; 716 rmm.TimeDrives.push(rmm2); 717 } 718 range.Members.push(rmm); 719 } 720 racePortal.evaluationRanges.push(range); 721 } 722 for (var i = 0; i < msg.d.TimeDrivings.length; i++) { 723 var jo = msg.d.TimeDrivings[i]; 724 var td = new KWTRaceTimeDrivingObject(); 725 td.ID = jo.ID; 726 td.StartTime = jsonDateTimeToDate(jo.StartTime); 727 td.EndTime = jsonDateTimeToDate(jo.EndTime); 728 td.Count = jo.Count; 729 racePortal.timeDrivings.push(td); 730 } 731 } 732 racePortal.fire({ type: "OnRaceMembersLoaded", Result: msg.d.ResultCode }); 733} 734 735KWTRacePortal.prototype.OnKWTRaceMembersError = function (jqXHR, textStatus, errorThrown) { 736 racePortal.fire({ type: "OnRaceMembersLoaded", Result: -100 }); 737} 738 739 740KWTRacePortal.prototype.createRace = function (race) { 741 racePortal.createdRace = race; 742 var postData = "{req: {API_KEY: \"" + api_key + "\", SessionID: \"" + kwt_ajaxportal_sessionID + "\", Race: {"; 743 postData += "Author: {ID: "+kwt_userid+"}," 744 postData += "Title: \""+race.Title+"\","; 745 postData += "Description: \""+race.Description+"\","; 746 postData += "StartTime: \"" + race.StartTime.toJSON().substr(0, race.StartTime.toJSON().length - 1) + "\","; 747 postData += "MaxMembers: 99,"; 748 postData += "Password: \""+race.Password+"\","; 749 postData += "TrackID: \""+race.TrackID+"\","; 750 postData += "DeviceType: "+race.DeviceType+","; 751 postData += "RealityFactor: "+race.RealityFactor+","; 752 postData += "GroupID: "+race.GroupID+","; 753 postData += "GearSet: "+race.GearSet+","; 754 postData += "Automatic: "+race.Automatic+","; 755 postData += "TargetPulse: "+race.TargetPulse+","; 756 postData += "FixTargetPulse: " + (race.FixTargetPulse == 1 ? "true" : "false") + ","; 757 postData += "StartDistance: " + race.StartDistance + ","; 758 postData += "TargetDistance: " + race.TargetDistance +","; 759 postData += "EveryoneCanJoin: " + (race.EveryoneCanJoin == 1 ? "true" : "false"); 760 postData += "}}}"; 761 $.ajax( 762 { 763 type: "POST", 764 url: "/KWTPortal2/RacePortal.asmx/CreateRace", 765 dataType: "json", 766 contentType: "application/json; charset=utf-8", 767 success: this.OnKWTCreateRaceSuccess, 768 error: this.OnKWTCreateRaceError, 769 data: postData 770 } 771 ); 772} 773 774KWTRacePortal.prototype.OnKWTCreateRaceSuccess = function (msg, textStatus, jqXHR) { 775 var resultCode = msg.d.ResultCode; 776 if (resultCode == 1) { 777 racePortal.fire({ type: "OnCreateRace", Result: 1 }); 778 } 779 else 780 racePortal.fire({ type: "OnCreateRace", Result: -1, Response: msg.d }); 781} 782 783KWTRacePortal.prototype.OnKWTCreateRaceError = function (jqXHR, textStatus, errorThrown) { 784 racePortal.fire({ type: "OnCreateRace", Result: -100 }); 785} 786 787 788 789KWTRacePortal.prototype.loadNextRaces = function () { 790 var postData = "{req: {API_KEY: \"" + api_key + "\", SessionID: \"" + kwt_ajaxportal_sessionID + "\", LimitDays: 365}}"; 791 $.ajax( 792 { 793 type: "POST", 794 url: "/KWTPortal2/RacePortal.asmx/GetNextRaces", 795 dataType: "json", 796 contentType: "application/json; charset=utf-8", 797 success: this.OnKWTGetNextRacesLoaded, 798 error: this.OnKWTGetNextRacesError, 799 data: postData 800 } 801); 802} 803KWTRacePortal.prototype.OnKWTGetNextRacesLoaded = function (msg, textStatus, jqXHR) { 804 if (msg.d.ResultCode == 1) { 805 racePortal.nextRaces = []; 806 for (var i = 0; i < msg.d.Races.length; i++) { 807 racePortal.nextRaces.push(racePortal.loadRaceObject(msg.d.Races[i])); 808 } 809 racePortal.nextRacesPageCount = Math.round((racePortal.nextRaces.length / kwtRaceListCount) + 0.499); 810 racePortal.nextRacesLastLoad = new Date(); 811 racePortal.fire({ type: "OnNextRacesLoaded", Result: 1 }); 812 } 813 else 814 racePortal.fire({ type: "OnNextRacesLoaded", Result: -1 }); 815} 816 817KWTRacePortal.prototype.OnKWTGetNextRacesError = function (jqXHR, textStatus, errorThrown) { 818 racePortal.fire({ type: "OnNextRacesLoaded", Result: -100 }); 819} 820 821KWTRacePortal.prototype.AddAnnouncement = function (raceID) { 822 var postData = "{req: {API_KEY: \"" + api_key + "\", SessionID: \"" + kwt_ajaxportal_sessionID + "\", RaceID: "+raceID+"}}"; 823 $.ajax( 824 { 825 type: "POST", 826 url: "/KWTPortal2/RacePortal.asmx/AddAnnouncement", 827 dataType: "json", 828 contentType: "application/json; charset=utf-8", 829 success: this.OnKWTAddAnnouncementLoaded, 830 error: this.OnKWTAddAnnouncementError, 831 data: postData 832 } 833); 834} 835KWTRacePortal.prototype.OnKWTAddAnnouncementLoaded = function (msg, textStatus, jqXHR) { 836 if (msg.d.ResultCode == 1) { 837 racePortal.fire({ type: "OnAddAnnouncement", Result: 1 }); 838 } 839 else 840 racePortal.fire({ type: "OnAddAnnouncement", Result: -1 }); 841} 842 843KWTRacePortal.prototype.OnKWTAddAnnouncementError = function (jqXHR, textStatus, errorThrown) { 844 racePortal.fire({ type: "OnAddAnnouncement", Result: -100 }); 845} 846 847KWTRacePortal.prototype.RemoveAnnouncement = function (raceID) { 848 var postData = "{req: {API_KEY: \"" + api_key + "\", SessionID: \"" + kwt_ajaxportal_sessionID + "\", RaceID: " + raceID + "}}"; 849 $.ajax( 850 { 851 type: "POST", 852 url: "/KWTPortal2/RacePortal.asmx/RemoveAnnouncement", 853 dataType: "json", 854 contentType: "application/json; charset=utf-8", 855 success: this.OnKWTRemoveAnnouncementLoaded, 856 error: this.OnKWTRemoveAnnouncementError, 857 data: postData 858 } 859); 860} 861KWTRacePortal.prototype.OnKWTRemoveAnnouncementLoaded = function (msg, textStatus, jqXHR) { 862 if (msg.d.ResultCode == 1) { 863 racePortal.fire({ type: "OnRemoveAnnouncement", Result: 1 }); 864 } 865 else 866 racePortal.fire({ type: "OnRemoveAnnouncement", Result: -1 }); 867} 868 869KWTRacePortal.prototype.OnKWTRemoveAnnouncementError = function (jqXHR, textStatus, errorThrown) { 870 racePortal.fire({ type: "OnRemoveAnnouncement", Result: -100 }); 871} 872 873KWTRacePortal.prototype.deleteRace = function (raceID) { 874 var postData = "{req: {API_KEY: \"" + api_key + "\", SessionID: \"" + kwt_ajaxportal_sessionID + "\", RaceID: " + raceID + "}}"; 875 $.ajax( 876 { 877 type: "POST", 878 url: "/KWTPortal2/RacePortal.asmx/DeleteRace", 879 dataType: "json", 880 contentType: "application/json; charset=utf-8", 881 success: this.OnKWTDeleteRaceLoaded, 882 error: this.OnKWTDeleteRaceError, 883 data: postData 884 } 885); 886} 887KWTRacePortal.prototype.OnKWTDeleteRaceLoaded = function (msg, textStatus, jqXHR) { 888 racePortal.fire({ type: "OnDeleteRace", Result: msg.d.ResultCode }); 889} 890 891KWTRacePortal.prototype.OnKWTDeleteRaceError = function (jqXHR, textStatus, errorThrown) { 892 racePortal.fire({ type: "OnDeleteRace", Result: -100 }); 893} 894 895KWTRacePortal.prototype.loadUserRaces = function (userID, limit, page) { 896 var postData = "{req: {API_KEY: \"" + api_key + "\", SessionID: \"" + kwt_ajaxportal_sessionID + "\", UserID: " + userID + ", Limit: " + limit + ", Page: " + page + "}}"; 897 racePortal.userRacesLoading = true; 898 $.ajax( 899 { 900 type: "POST", 901 url: "/KWTPortal2/RacePortal.asmx/GetUserRaces", 902 dataType: "json", 903 contentType: "application/json; charset=utf-8", 904 success: this.OnKWTGetUserRacesLoaded, 905 error: this.OnKWTGetUserRacesError, 906 data: postData 907 } 908); 909} 910KWTRacePortal.prototype.OnKWTGetUserRacesLoaded = function (msg, textStatus, jqXHR) { 911 racePortal.userRacesLoading = false; 912 if (msg.d.ResultCode == 1) { 913 racePortal.userRaces = []; 914 var raceCount = msg.d.RaceCount; 915 for (var i = 0; i < msg.d.Races.length; i++) { 916 racePortal.userRaces.push(racePortal.loadRaceObject(msg.d.Races[i])); 917 } 918 racePortal.userRacesPageCount = Math.round((raceCount / kwtRaceListCount) + 0.499); 919 racePortal.fire({ type: "OnUserRacesLoaded", Result: 1 }); 920 } 921 else 922 racePortal.fire({ type: "OnUserRacesLoaded", Result: -1 }); 923} 924 925KWTRacePortal.prototype.OnKWTGetUserRacesError = function (jqXHR, textStatus, errorThrown) { 926 racePortal.userRacesLoading = false; 927 racePortal.fire({ type: "OnUserRacesLoaded", Result: -100 }); 928} 929 930KWTRacePortal.prototype.loadCupHighscore = function (groupID, type, season) { 931 var postData = "{req: {API_KEY: \"" + api_key + "\", SessionID: \"" + kwt_ajaxportal_sessionID + "\", GroupID: " + groupID + ", Type: " + type + ", Season: "+season+"}}"; 932 racePortal.cupHighscoreLoading = true; 933 $.ajax( 934 { 935 type: "POST", 936 url: "/KWTPortal2/RacePortal.asmx/GetCupHighscore", 937 dataType: "json", 938 contentType: "application/json; charset=utf-8", 939 success: this.OnKWTGetCupHighscoreLoaded, 940 error: this.OnKWTGetCupHighscoreError, 941 data: postData 942 } 943); 944} 945KWTRacePortal.prototype.OnKWTGetCupHighscoreLoaded = function (msg, textStatus, jqXHR) { 946 racePortal.cupHighscoreLoading = false; 947 racePortal.cupHighscore = []; 948 if (msg.d.ResultCode == 1) { 949 for (var i = 0; i < msg.d.Highscore.length; i++) { 950 var jo = msg.d.Highscore[i]; 951 var c = new KWTCupHighscoreObject(); 952 c.Place = jo.Place; 953 c.User = userPortal.loadUserObject(jo.User);
954 c.Time = jo.Time; 955 c.TimeMS = jo.TimeMS; 956 c.Distance = jo.Distance; 957 c.Points = jo.Points; 958 c.Fortunes = jo.Fortunes; 959 for (var j = 0; j < jo.Medals.length; j++) { 960 var medal = jo.Medals[j]; 961 var m = new KWTCupHighscoreMedalObject(); 962 m.Type = medal.Type; 963 m.Name = medal.Name; 964 m.StartTime = jsonDateTimeToDate(medal.StartTime); 965 c.Medals.push(m); 966 } 967 racePortal.cupHighscore.push(c); 968 } 969 racePortal.fire({ type: "OnCupHighscoreLoaded", Result: 1 }); 970 } 971 else 972 racePortal.fire({ type: "OnCupHighscoreLoaded", Result: -1 }); 973} 974 975KWTRacePortal.prototype.OnKWTGetCupHighscoreError = function (jqXHR, textStatus, errorThrown) { 976 racePortal.cupHighscoreLoading = false; 977 racePortal.fire({ type: "OnCupHighscoreLoaded", Result: -100 }); 978} 979 980 981KWTRacePortal.prototype.loadOldCupHighscore = function (groupID, type) { 982 var postData = "{req: {API_KEY: \"" + api_key + "\", SessionID: \"" + kwt_ajaxportal_sessionID + "\", GroupID: " + groupID + ", Type: " + type + "}}"; 983 racePortal.oldCupHighscoreLoading = true; 984 $.ajax( 985 { 986 type: "POST", 987 url: "/KWTPortal2/RacePortal.asmx/GetOldCupHighscore", 988 dataType: "json", 989 contentType: "application/json; charset=utf-8", 990 success: this.OnKWTGetOldCupHighscoreLoaded, 991 error: this.OnKWTGetOldCupHighscoreError, 992 data: postData 993 } 994 ); 995} 996KWTRacePortal.prototype.OnKWTGetOldCupHighscoreLoaded = function (msg, textStatus, jqXHR) { 997 racePortal.oldCupHighscoreLoading = false; 998 racePortal.oldCupHighscore = []; 999 if (msg.d.ResultCode == 1) { 1000 for (var i = 0; i < msg.d.Highscore.length; i++) { 1001 var jo = msg.d.Highscore[i]; 1002 var c = new KWTCupHighscoreObject(); 1003 c.Place = jo.Place; 1004 c.User = userPortal.loadUserObject(jo.User); 1005 c.Time = jo.Time; 1006 c.TimeMS = jo.TimeMS; 1007 c.Distance = jo.Distance; 1008 c.Points = jo.Points; 1009 c.Fortunes = jo.Fortunes; 1010 for (var j = 0; j < jo.Medals.length; j++) { 1011 var medal = jo.Medals[j]; 1012 var m = new KWTCupHighscoreMedalObject(); 1013 m.Type = medal.Type; 1014 m.Name = medal.Name; 1015 m.StartTime = jsonDateTimeToDate(medal.StartTime); 1016 c.Medals.push(m); 1017 } 1018 c.InternPoints = jo.InternPoints; 1019 c.Trikot = jo.Trikot; 1020 racePortal.oldCupHighscore.push(c); 1021 } 1022 racePortal.fire({ type: "OnOldCupHighscoreLoaded", Result: 1 }); 1023 } 1024 else 1025 racePortal.fire({ type: "OnOldCupHighscoreLoaded", Result: -1 }); 1026} 1027 1028KWTRacePortal.prototype.OnKWTGetOldCupHighscoreError = function (jqXHR, textStatus, errorThrown) { 1029 racePortal.oldCupHighscoreLoading = false; 1030 racePortal.fire({ type: "OnOldCupHighscoreLoaded", Result: -100 }); 1031} 1032 1033KWTRacePortal.prototype.loadSummerCupHighscore = function (groupID, type, year, month, difficulty, devicetype) { 1034 var postData = "{req: {API_KEY: \"" + api_key + "\", SessionID: \"" + kwt_ajaxportal_sessionID + "\", GroupID: " + groupID + ", Type: " + type + ", Year: "+year+", Month: " + month + ", Difficulty: "+difficulty+", DeviceType: "+devicetype+"}}"; 1035 racePortal.summerCupHighscoreLoading = true; 1036 $.ajax( 1037 { 1038 type: "POST", 1039 url: "/KWTPortal2/RacePortal.asmx/GetSummerCupHighscore", 1040 dataType: "json", 1041 contentType: "application/json; charset=utf-8", 1042 success: this.OnKWTGetSummerCupHighscoreLoaded, 1043 error: this.OnKWTGetSummerCupHighscoreError, 1044 data: postData 1045 } 1046); 1047} 1048KWTRacePortal.prototype.OnKWTGetSummerCupHighscoreLoaded = function (msg, textStatus, jqXHR) { 1049 racePortal.summerCupHighscoreLoading = false; 1050 racePortal.summerCupHighscore = []; 1051 if (msg.d.ResultCode == 1) { 1052 for (var i = 0; i < msg.d.Highscore.length; i++) { 1053 var jo = msg.d.Highscore[i]; 1054 var c = new KWTCupHighscoreObject(); 1055 c.Place = jo.Place; 1056 c.User = userPortal.loadUserObject(jo.User);
1057 c.Time = jo.Time; 1058 c.TimeMS = jo.TimeMS; 1059 c.Distance = jo.Distance; 1060 c.Points = jo.Points; 1061 c.Fortunes = jo.Fortunes; 1062 for (var j = 0; j < jo.Medals.length; j++) { 1063 var medal = jo.Medals[j]; 1064 var m = new KWTCupHighscoreMedalObject(); 1065 m.Type = medal.Type; 1066 m.Name = medal.Name; 1067 m.StartTime = jsonDateTimeToDate(medal.StartTime); 1068 c.Medals.push(m); 1069 } 1070 racePortal.summerCupHighscore.push(c); 1071 } 1072 racePortal.fire({ type: "OnSummerCupHighscoreLoaded", Result: 1 }); 1073 } 1074 else 1075 racePortal.fire({ type: "OnSummerCupHighscoreLoaded", Result: -1 }); 1076} 1077 1078KWTRacePortal.prototype.OnKWTGetSummerCupHighscoreError = function (jqXHR, textStatus, errorThrown) { 1079 racePortal.summerCupHighscoreLoading = false; 1080 racePortal.fire({ type: "OnSummerCupHighscoreLoaded", Result: -100 }); 1081} 1082 1083KWTRacePortal.prototype.loadSummerCupHighscoreAvailable = function (groupID, type, year, month, difficulty, devicetype) { 1084 var postData = "{req: {API_KEY: \"" + api_key + "\", SessionID: \"" + kwt_ajaxportal_sessionID + "\", GroupID: " + groupID + ", Type: " + type + ", Year: " + year + ", Month: " + month + ", Difficulty: " + difficulty + ", DeviceType: " + devicetype + "}}"; 1085 racePortal.summerCupHighscoreLoading = true; 1086 $.ajax( 1087 { 1088 type: "POST", 1089 url: "/KWTPortal2/RacePortal.asmx/GetSummerCupHighscoreAvailable", 1090 dataType: "json", 1091 contentType: "application/json; charset=utf-8", 1092 success: this.OnKWTGetSummerCupHighscoreAvailableLoaded, 1093 error: this.OnKWTGetSummerCupHighscoreAvailableError, 1094 data: postData 1095 } 1096); 1097} 1098KWTRacePortal.prototype.OnKWTGetSummerCupHighscoreAvailableLoaded = function (msg, textStatus, jqXHR) { 1099 racePortal.summerCupHighscoreLoading = false; 1100 racePortal.summerCupHighscore = []; 1101 if (msg.d.ResultCode == 1) { 1102 racePortal.summerCupYears = msg.d.Years; 1103 racePortal.summerCupMonths = msg.d.Months; 1104 racePortal.summerCupDifficulties = msg.d.Difficulties; 1105 racePortal.summerCupDeviceTypes = msg.d.DeviceTypes; 1106 racePortal.fire({ type: "OnSummerCupHighscoreAvailableLoaded", Result: 1 }); 1107 } 1108 else 1109 racePortal.fire({ type: "OnSummerCupHighscoreAvailableLoaded", Result: -1 }); 1110} 1111 1112KWTRacePortal.prototype.OnKWTGetSummerCupHighscoreAvailableError = function (jqXHR, textStatus, errorThrown) { 1113 racePortal.summerCupHighscoreLoading = false; 1114 racePortal.fire({ type: "OnSummerCupHighscoreAvailableLoaded", Result: -100 }); 1115} 1116 1117 1118KWTRacePortal.prototype.loadCupTeamHighscore = function (groupID, type) { 1119 var postData = "{req: {API_KEY: \"" + api_key + "\", SessionID: \"" + kwt_ajaxportal_sessionID + "\", GroupID: " + groupID + ", Type: " + type + "}}"; 1120 racePortal.cupTeamHighscoreLoading = true; 1121 $.ajax( 1122 { 1123 type: "POST", 1124 url: "/KWTPortal2/RacePortal.asmx/GetCupTeamHighscore", 1125 dataType: "json", 1126 contentType: "application/json; charset=utf-8", 1127 success: this.OnKWTGetCupTeamHighscoreLoaded, 1128 error: this.OnKWTGetCupTeamHighscoreError, 1129 data: postData 1130 } 1131); 1132} 1133 1134KWTRacePortal.prototype.loadCupTeamHighscoreByTrackNumber = function (groupID, type, trackNumber) { 1135 var postData = "{req: {API_KEY: \"" + api_key + "\", SessionID: \"" + kwt_ajaxportal_sessionID + "\", GroupID: " + groupID + ", Type: " + type + ", TrackNumber: "+trackNumber+"}}"; 1136 racePortal.cupTeamHighscoreLoading = true; 1137 $.ajax( 1138 { 1139 type: "POST", 1140 url: "/KWTPortal2/RacePortal.asmx/GetCupTeamHighscoreByTrackNumber", 1141 dataType: "json", 1142 contentType: "application/json; charset=utf-8", 1143 success: this.OnKWTGetCupTeamHighscoreLoaded, 1144 error: this.OnKWTGetCupTeamHighscoreError, 1145 data: postData 1146 } 1147); 1148} 1149 1150KWTRacePortal.prototype.loadTotalCupTeamHighscore = function (groupIDs, type) { 1151 var postData = "{req: {API_KEY: \"" + api_key + "\", SessionID: \"" + kwt_ajaxportal_sessionID + "\", GroupIDs: \"" + groupIDs + "\", Type: " + type + "}}"; 1152 racePortal.cupTeamHighscoreLoading = true; 1153 $.ajax( 1154 { 1155 type: "POST", 1156 url: "/KWTPortal2/RacePortal.asmx/GetTotalCupTeamHighscore", 1157 dataType: "json", 1158 contentType: "application/json; charset=utf-8", 1159 success: this.OnKWTGetCupTeamHighscoreLoaded, 1160 error: this.OnKWTGetCupTeamHighscoreError, 1161 data: postData 1162 } 1163); 1164} 1165 1166KWTRacePortal.prototype.OnKWTGetCupTeamHighscoreLoaded = function (msg, textStatus, jqXHR) { 1167 racePortal.cupTeamHighscoreLoading = false; 1168 racePortal.cupTeamHighscore = []; 1169 if (msg.d.ResultCode == 1) { 1170 racePortal.cupTeamHighscoreTrackTitle = ""; 1171 racePortal.cupTeamHighscoreTrackID = ""; 1172 if (typeof (msg.d.TrackID) != "undefined") { 1173 racePortal.cupTeamHighscoreTrackID = msg.d.TrackID; 1174 racePortal.cupTeamHighscoreTrackTitle = msg.d.TrackTitle; 1175 } 1176 racePortal.cupTeamHighscoreTrackCount = 0; 1177 if (typeof (msg.d.TrackCount) != "undefined") { 1178 racePortal.cupTeamHighscoreTrackCount = msg.d.TrackCount; 1179 } 1180 for (var i = 0; i < msg.d.Highscore.length; i++) { 1181 var jo = msg.d.Highscore[i]; 1182 var t = new KWTCupTeamHighscoreObject(); 1183 t.Place = jo.Place; 1184 t.Name = jo.Name;
1185 t.ShortName = jo.ShortName; 1186 t.Time = jo.Time; 1187 t.TimeMS = jo.TimeMS; 1188 t.Distance = jo.Distance; 1189 t.Points = jo.Points; 1190 for (var k = 0; k < jo.Members.length; k++) { 1191 var jo2 = jo.Members[k]; 1192 var c = new KWTCupHighscoreObject(); 1193 c.Place = jo2.Place; 1194 c.User = userPortal.loadUserObject(jo2.User); 1195 c.Time = jo2.Time; 1196 c.TimeMS = jo2.TimeMS; 1197 c.Distance = jo2.Distance; 1198 c.Points = jo2.Points; 1199 c.Fortunes = jo2.Fortunes; 1200 for (var j = 0; j < jo2.Medals.length; j++) { 1201 var medal = jo2.Medals[j]; 1202 var m = new KWTCupHighscoreMedalObject(); 1203 m.Type = medal.Type; 1204 m.Name = medal.Name; 1205 m.StartTime = jsonDateTimeToDate(medal.StartTime); 1206 c.Medals.push(m); 1207 } 1208 t.Members.push(c); 1209 } 1210 racePortal.cupTeamHighscore.push(t); 1211 } 1212 racePortal.fire({ type: "OnCupTeamHighscoreLoaded", Result: 1 }); 1213 } 1214 else 1215 racePortal.fire({ type: "OnCupTeamHighscoreLoaded", Result: -1 }); 1216} 1217 1218KWTRacePortal.prototype.OnKWTGetCupTeamHighscoreError = function (jqXHR, textStatus, errorThrown) { 1219 racePortal.cupTeamHighscoreLoading = false; 1220 racePortal.fire({ type: "OnCupTeamHighscoreLoaded", Result: -100 }); 1221} 1222 1223 1224KWTRacePortal.prototype.loadCupSprintHighscore = function (groupID, type, season) { 1225 var postData = "{req: {API_KEY: \"" + api_key + "\", SessionID: \"" + kwt_ajaxportal_sessionID + "\", GroupID: " + groupID + ", Type: " + type + ", Season: "+season+"}}"; 1226 racePortal.cupSprintHighscoreLoading = true; 1227 $.ajax( 1228 { 1229 type: "POST", 1230 url: "/KWTPortal2/RacePortal.asmx/GetCupSprintHighscore", 1231 dataType: "json", 1232 contentType: "application/json; charset=utf-8", 1233 success: this.OnKWTGetCupSprintHighscoreLoaded, 1234 error: this.OnKWTGetCupSprintHighscoreError, 1235 data: postData 1236 } 1237); 1238} 1239 1240 1241KWTRacePortal.prototype.loadTotalCupSprintHighscore = function (groupIDs, type) { 1242 var postData = "{req: {API_KEY: \"" + api_key + "\", SessionID: \"" + kwt_ajaxportal_sessionID + "\", GroupIDs: \"" + groupIDs + "\", Type: " + type + "}}"; 1243 racePortal.cupSprintHighscoreLoading = true; 1244 $.ajax( 1245 { 1246 type: "POST", 1247 url: "/KWTPortal2/RacePortal.asmx/GetTotalCupSprintHighscore", 1248 dataType: "json", 1249 contentType: "application/json; charset=utf-8", 1250 success: this.OnKWTGetCupSprintHighscoreLoaded, 1251 error: this.OnKWTGetCupSprintHighscoreError, 1252 data: postData 1253 } 1254); 1255} 1256 1257KWTRacePortal.prototype.OnKWTGetCupSprintHighscoreLoaded = function (msg, textStatus, jqXHR) { 1258 racePortal.cupSprintHighscoreLoading = false; 1259 racePortal.cupSprintHighscore = []; 1260 if (msg.d.ResultCode == 1) { 1261 for (var i = 0; i < msg.d.Highscore.length; i++) { 1262 var jo = msg.d.Highscore[i]; 1263 var c = new KWTCupHighscoreObject(); 1264 c.Place = jo.Place; 1265 c.User = userPortal.loadUserObject(jo.User); 1266 c.Time = jo.Time; 1267 c.TimeMS = jo.TimeMS; 1268 c.Distance = jo.Distance; 1269 c.Points = jo.Points; 1270 c.Fortunes = jo.Fortunes; 1271 for (var j = 0; j < jo.Medals.length; j++) { 1272 var medal = jo.Medals[j]; 1273 var m = new KWTCupHighscoreMedalObject(); 1274 m.Type = medal.Type; 1275 m.Name = medal.Name; 1276 m.StartTime = jsonDateTimeToDate(medal.StartTime); 1277 c.Medals.push(m); 1278 } 1279 racePortal.cupSprintHighscore.push(c); 1280 } 1281 racePortal.fire({ type: "OnCupSprintHighscoreLoaded", Result: 1 }); 1282 } 1283 else 1284 racePortal.fire({ type: "OnCupSprintHighscoreLoaded", Result: -1 }); 1285} 1286 1287KWTRacePortal.prototype.OnKWTGetCupSprintHighscoreError = function (jqXHR, textStatus, errorThrown) { 1288 racePortal.cupSprintHighscoreLoading = false; 1289 racePortal.fire({ type: "OnCupSprintHighscoreLoaded", Result: -100 }); 1290} 1291 1292 1293 1294KWTRacePortal.prototype.loadCupTeams = function (groupID) { 1295 var postData = "{req: {API_KEY: \"" + api_key + "\", SessionID: \"" + kwt_ajaxportal_sessionID + "\", GroupID: " + groupID + "}}";
1296 racePortal.cupTeamsLoading = true; 1297 $.ajax( 1298 { 1299 type: "POST", 1300 url: "/KWTPortal2/RacePortal.asmx/GetCupTeams", 1301 dataType: "json", 1302 contentType: "application/json; charset=utf-8", 1303 success: this.OnKWTGetCupTeamsLoaded, 1304 error: this.OnKWTGetCupTeamsError, 1305 data: postData 1306 } 1307); 1308} 1309KWTRacePortal.prototype.OnKWTGetCupTeamsLoaded = function (msg, textStatus, jqXHR) { 1310 racePortal.cupTeamsLoading = false; 1311 racePortal.cupTeams = []; 1312 if (msg.d.ResultCode == 1) { 1313 for (var i = 0; i < msg.d.Teams.length; i++) { 1314 var jo = msg.d.Teams[i]; 1315 var t = new KWTCupTeamObject(); 1316 t.fromJSON(jo); 1317 racePortal.cupTeams.push(t); 1318 } 1319 racePortal.cupTeamsLoaded = true; 1320 racePortal.fire({ type: "OnCupTeamsLoaded", Result: 1 }); 1321 } 1322 else 1323 racePortal.fire({ type: "OnCupTeamsLoaded", Result: -1 }); 1324} 1325 1326KWTRacePortal.prototype.OnKWTGetCupTeamsError = function (jqXHR, textStatus, errorThrown) { 1327 racePortal.cupTeamsLoading = false; 1328 racePortal.fire({ type: "OnCupTeamsLoaded", Result: -100 }); 1329} 1330 1331 1332KWTRacePortal.prototype.SetCupTeam = function (groupID, team) { 1333 var postData = "{req: {API_KEY: \"" + api_key + "\", SessionID: \"" + kwt_ajaxportal_sessionID + "\", GroupID: " + groupID + ", Team: " + team.toJSON() + "}}"; 1334 if (team.ID <= 0) 1335 racePortal.settedCupTeam = team; 1336 $.ajax( 1337 { 1338 type: "POST", 1339 url: "/KWTPortal2/RacePortal.asmx/SetCupTeam", 1340 dataType: "json", 1341 contentType: "application/json; charset=utf-8", 1342 success: this.OnKWTSetCupTeamLoaded, 1343 error: this.OnKWTSetCupTeamError, 1344 data: postData 1345 } 1346); 1347} 1348KWTRacePortal.prototype.OnKWTSetCupTeamLoaded = function (msg, textStatus, jqXHR) { 1349 if (msg.d.ResultCode == 1) { 1350 if (racePortal.settedCupTeam != null) { 1351 if (racePortal.settedCupTeam.ID < 0) 1352 racePortal.cupTeams.push(racePortal.settedCupTeam); 1353 racePortal.settedCupTeam.ID = msg.d.TeamID; 1354 } 1355 racePortal.fire({ type: "OnSetCupTeamLoaded", Result: 1 }); 1356 } 1357 else 1358 racePortal.fire({ type: "OnSetCupTeamLoaded", Result: -1 }); 1359 racePortal.settedCupTeam = null; 1360} 1361 1362KWTRacePortal.prototype.OnKWTSetCupTeamError = function (jqXHR, textStatus, errorThrown) { 1363 racePortal.fire({ type: "OnSetCupTeamLoaded", Result: -100 }); 1364 racePortal.settedCupTeam = null; 1365} 1366 1367KWTRacePortal.prototype.DeleteCupTeam = function (teamID) { 1368 var postData = "{req: {API_KEY: \"" + api_key + "\", SessionID: \"" + kwt_ajaxportal_sessionID + "\", TeamID: " + teamID + "}}"; 1369 racePortal.deletedTeamID = teamID; 1370 $.ajax( 1371 { 1372 type: "POST", 1373 url: "/KWTPortal2/RacePortal.asmx/DeleteCupTeam", 1374 dataType: "json", 1375 contentType: "application/json; charset=utf-8", 1376 success: this.OnKWTDeleteCupTeamLoaded, 1377 error: this.OnKWTDeleteCupTeamError, 1378 data: postData 1379 } 1380); 1381} 1382KWTRacePortal.prototype.OnKWTDeleteCupTeamLoaded = function (msg, textStatus, jqXHR) { 1383 if (msg.d.ResultCode == 1) { 1384 if (racePortal.deletedTeamID > 0) { 1385 for (var i = 0; i < racePortal.cupTeams.length; i++) { 1386 if (racePortal.cupTeams[i].ID == racePortal.deletedTeamID) { 1387 racePortal.cupTeams.splice(i, 1); 1388 break; 1389 } 1390 } 1391 } 1392 racePortal.fire({ type: "OnDeleteCupTeamLoaded", Result: 1 }); 1393 } 1394 else 1395 racePortal.fire({ type: "OnDeleteCupTeamLoaded", Result: -1 }); 1396 racePortal.deletedTeamID = -1; 1397} 1398 1399KWTRacePortal.prototype.OnKWTDeleteCupTeamError = function (jqXHR, textStatus, errorThrown) { 1400 racePortal.fire({ type: "OnDeleteCupTeamLoaded", Result: -100 }); 1401 racePortal.deletedTeamID = -1; 1402} 1403 1404 1405KWTRacePortal.prototype.SendTeamCreationMessage = function (groupID,teamName,creator,member2,member3,member4,member5) { 1406 var postData = "{req: {API_KEY: \"" + api_key + "\", SessionID: \"" + kwt_ajaxportal_sessionID + "\", GroupID: " + groupID + ", TeamName: \"" + teamName + "\", Creator: \"" + creator + "\", Member2: \"" + member2 + "\", Member3: \"" + member3 + "\", Member4: \"" + member4 + "\", Member5: \"" + member5 + "\"}}"; 1407 $.ajax( 1408 { 1409 type: "POST",
1410 url: "/KWTPortal2/RacePortal.asmx/SendTeamCreationMessage", 1411 dataType: "json", 1412 contentType: "application/json; charset=utf-8", 1413 success: this.OnKWTSendTeamCreationMessageLoaded, 1414 error: this.OnKWTSendTeamCreationMessageError, 1415 data: postData 1416 } 1417); 1418} 1419KWTRacePortal.prototype.OnKWTSendTeamCreationMessageLoaded = function (msg, textStatus, jqXHR) { 1420 if (msg.d.ResultCode == 1) { 1421 racePortal.fire({ type: "OnSendTeamCreationMessageLoaded", Result: 1 }); 1422 } 1423 else 1424 racePortal.fire({ type: "OnSendTeamCreationMessageLoaded", Result: -1 }); 1425} 1426 1427KWTRacePortal.prototype.OnKWTSendTeamCreationMessageError = function (jqXHR, textStatus, errorThrown) { 1428 racePortal.fire({ type: "OnSendTeamCreationMessageLoaded", Result: -100 }); 1429}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.