2017-11-15 19:46:47 +01:00
|
|
|
"use strict";
|
2017-11-15 20:19:15 +01:00
|
|
|
|
2017-11-16 23:08:14 +01:00
|
|
|
/*
|
|
|
|
* This file contains the main control flow.
|
|
|
|
*/
|
|
|
|
|
2017-12-22 13:13:52 +01:00
|
|
|
var slyelement = {
|
|
|
|
obj: {},
|
2017-12-22 13:57:42 +01:00
|
|
|
curRaces: {},
|
2017-12-29 17:17:21 +01:00
|
|
|
curRaceId: 0,
|
2017-12-22 13:13:52 +01:00
|
|
|
el: '.frame',
|
|
|
|
options: {
|
|
|
|
horizontal: 1,
|
|
|
|
itemNav: 'basic',
|
|
|
|
smart: 1,
|
2017-12-29 17:11:02 +01:00
|
|
|
//activateOn: 'click',
|
|
|
|
//activatePageOn: 'click',
|
|
|
|
mouseDragging: 0,
|
2017-12-22 13:13:52 +01:00
|
|
|
touchDragging: 1,
|
2017-12-29 17:11:02 +01:00
|
|
|
releaseSwing: 0,
|
2017-12-22 13:13:52 +01:00
|
|
|
startAt: 3,
|
|
|
|
scrollBar: $('.strecken-selector').parent().find('.scrollbar'),
|
|
|
|
scrollBy: 1,
|
|
|
|
pagesBar: $('.strecken-selector').parent().find('.pages'),
|
|
|
|
speed: 300,
|
|
|
|
elasticBounds: 1,
|
|
|
|
dragHandle: 1,
|
|
|
|
dynamicHandle: 1,
|
|
|
|
clickBar: 1,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
preprocessor.load(function(data) {
|
|
|
|
slyelement.obj = new Sly($(slyelement.el), slyelement.options);
|
|
|
|
slyelement.obj.init();
|
|
|
|
|
2017-12-22 09:40:26 +01:00
|
|
|
|
2017-12-08 13:50:41 +01:00
|
|
|
// Some sample code for a year selector - TODO: Improve a lot and move somewhere else
|
|
|
|
var yearSelector = $("#seasonByYearSelector");
|
2017-12-22 13:13:52 +01:00
|
|
|
|
2017-12-17 10:38:48 +01:00
|
|
|
var seasons = processor.getSeasonsWithLapData();
|
2017-12-22 13:13:52 +01:00
|
|
|
|
2017-12-17 10:38:48 +01:00
|
|
|
for(var season in seasons){ yearSelector.append("<option>" + seasons[season].year + "</option>"); }
|
2017-12-22 13:13:52 +01:00
|
|
|
|
|
|
|
// Someone chose a year
|
|
|
|
yearSelector.change(function(event) {
|
|
|
|
var selectedYear = $(event.target).val();
|
2017-12-22 13:57:42 +01:00
|
|
|
slyelement.curRaces = processor.getRacesByYear(selectedYear);
|
2017-12-22 13:13:52 +01:00
|
|
|
$("#courseSelection").empty();
|
2017-12-22 13:57:42 +01:00
|
|
|
for(var race in slyelement.curRaces) {
|
|
|
|
var raceD = slyelement.curRaces[race];
|
2017-12-29 16:55:54 +01:00
|
|
|
|
|
|
|
var url = raceD.raceInfo.url;
|
|
|
|
var pathName = url.substring(url.lastIndexOf("/")+1);
|
|
|
|
getImageFromWikipedia(raceD,pathName,100,(raceD1,imageURL) => {
|
|
|
|
$("#courseSelection").append("<li data=\"" + raceD1.raceInfo.raceId + "\">" +
|
|
|
|
"<span class=\"coursename\">" + raceD1.raceInfo.name +"</span>"+
|
|
|
|
"<div class=courseimagecontainer>" +
|
|
|
|
"<img src=\"" + imageURL + "\"class=\"courseimage\"/> "
|
|
|
|
+ "</div>"
|
|
|
|
+ raceD1.raceInfo.date.toLocaleDateString("en-US") +
|
|
|
|
"</li>");
|
2017-12-29 17:11:02 +01:00
|
|
|
$("#courseSelection li").click(function(event) {
|
|
|
|
var raceI = event.currentTarget.attributes.data.value;
|
2017-12-29 17:17:21 +01:00
|
|
|
if(slyelement.curRaceId == raceI){ return; }
|
|
|
|
slyelement.curRaceId = raceI;
|
2017-12-29 17:11:02 +01:00
|
|
|
var rdata = slyelement.curRaces.filter(r => r.raceInfo.raceId == raceI)[0];
|
|
|
|
$("#lineGraphBox").empty();
|
|
|
|
createLineGraph("#lineGraphBox", rdata);
|
|
|
|
});
|
2017-12-29 16:55:54 +01:00
|
|
|
slyelement.obj.reload();
|
|
|
|
});
|
|
|
|
|
2017-12-22 13:13:52 +01:00
|
|
|
}
|
2017-12-29 17:11:02 +01:00
|
|
|
|
2017-12-29 16:55:54 +01:00
|
|
|
slyelement.obj.reload();
|
2017-12-22 13:13:52 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
$(window).resize(function(e) {
|
|
|
|
slyelement.obj.reload();
|
|
|
|
});
|
2017-11-16 23:57:21 +01:00
|
|
|
|
|
|
|
});
|