<commit_before>;
define(['lib/simile', 'timemap/Environment', 'timemap/map/BranchPin', 'timemap/map/StoryPin', 'timemap', 'lib/jquery-ui'], function (Simile, Environment, BranchPin, StoryPin, Timemap) {

return (function () {

	var Timeline = function (viewport, map, startingDate, branchID, branchViewer) {
		var self = this;
		this.viewport = $(viewport);
		this.map = map;
		this.branchViewer = null;
		this.startingDate = startingDate;
		this.questTimeout = null;

		this.leftNumber = $('<div>').addClass('timelineBound').addClass('left');
		this.rightNumber = $('<div>').addClass('timelineBound').addClass('right');

		//When the document is ready, initialize the timeline's DOM element
		$(document).ready(function () {
			

			$.get('/preferences/', function(json) {
				self.initTimeline(json, branchID, branchViewer);
			});
		});

		$(window).bind('resize', function () {
			self.onResize();
		});

	};

	Timeline.prototype.getCurrentDate = function() {
		var self = this;
		return self.tl._bands[0].getCenterVisibleDate();
	}

	Timeline.prototype.processStories = function(json) {
		json = json.objects;
		var newJson = [];
		for (i in json) {
			newJson.push({
				title: json[i].title,
				description: json[i].description,
				content_type : json[i].content_type,
				start: json[i].year.toString(),
				end: json[i].year.toString(),
				id: json[i].id,
				instant : "true"
			});
		}

		if(json.length) {
			this.setTimelineStartDate(new Date(Date.UTC(json[0].year - 1, 0, 1)));
			this.setTimelineEndDate(new Date(Date.UTC(json[json.length - 1].year + 1, 0, 1)));
		}

		this.stories.byStart = newJson;
		this.stories.byEnd = newJson;

		this.hideShowOnScroll();
	};

	Timeline.prototype.processBranches = function(json) {
		var newJson = [];
		var currYear = new Date().getFullYear().toString();

		var btypeToIcon = {
			B: 'std',
			M: 'bookmobile-bus',
			S: 'bookmobile-trolley'
		}

		for (var i = 0; i < json.length; i++) {
			newJson.push({
				name: json[i].name,
				description: json[i].description,
				title: json[i].name,
				lat: json[i].latitude,
				lng: json[i].longitude,
				start: json[i].start_year.toString(),
				end: json[i].end_year ? json[i].end_year.toString() : currYear.toString(),
				id: json[i].id,
				type: btypeToIcon[json[i].btype]
			});
		}
		return newJson;
	};

	Timeline.prototype.processBranchesByStart = function(json) {
		this.branches.byStart = this.processBranches(json.objects);

		this.hideShowOnScroll();
	};

	Timeline.prototype.processBranchesByEnd = function(json) {
		json = json.objects;
		var endNotNulls = [];<commit_msg>stupid ie again<commit_after>;
define(['lib/simile', 'timemap/Environment', 'timemap/map/BranchPin', 'timemap/map/StoryPin', 'timemap', 'lib/jquery-ui'], function (Simile, Environment, BranchPin, StoryPin, Timemap) {

return (function () {

	var Timeline = function (viewport, map, startingDate, branchID, branchViewer) {
		var self = this;
		this.viewport = $(viewport);
		this.map = map;
		this.branchViewer = null;
		this.startingDate = startingDate;
		this.questTimeout = null;

		this.leftNumber = $('<div>').addClass('timelineBound').addClass('left');
		this.rightNumber = $('<div>').addClass('timelineBound').addClass('right');

		//When the document is ready, initialize the timeline's DOM element
		$(document).ready(function () {
			

			$.get('/preferences/', function(json) {
				self.initTimeline(json, branchID, branchViewer);
			});
		});

		$(window).bind('resize', function () {
			self.onResize();
		});

	};

	Timeline.prototype.getCurrentDate = function() {
		var self = this;
		return self.tl._bands[0].getCenterVisibleDate();
	}

	Timeline.prototype.processStories = function(json) {
		json = json.objects;
		var newJson = [];
		for (i in json) {
			newJson.push({
				title: json[i].title,
				description: json[i].description,
				content_type : json[i].content_type,
				start: json[i].year.toString(),
				end: json[i].year.toString(),
				id: json[i].id,
				instant : "true"
			});
		}

		if(json.length) {
			this.setTimelineStartDate(new Date(Date.UTC(json[0].year - 1, 0, 1)));
			this.setTimelineEndDate(new Date(Date.UTC(json[json.length - 1].year + 1, 0, 1)));
		}

		this.stories.byStart = newJson;
		this.stories.byEnd = newJson;

		this.hideShowOnScroll();
	};

	Timeline.prototype.processBranches = function(json) {
		var newJson = [];
		var currYear = new Date().getFullYear().toString();

		var btypeToIcon = {
			B: 'std',
			M: 'bookmobile-bus',
			S: 'bookmobile-trolley'
		}

		for (i in json) {
			if(!_.isFunction(json[i])) {
				newJson.push({
					name: json[i].name,
					description: json[i].description,
					title: json[i].name,
					lat: json[i].latitude,
					lng: json[i].longitude,
					start: json[i].start_year.toString(),
					end: json[i].end_year ? json[i].end_year.toString() : currYear.toString(),
					id: json[i].id,
					type: btypeToIcon[json[i].btype]
				});
			}
		}
		return newJson;
	};

	Timeline.prototype.processBranchesByStart = function(json) {
		this.branches.byStart = this.processBranches(json.objects);

		this.hideShowOnScroll();
	};

	Timeline.prototype.processBranchesByEnd = function(json) {
		json = json.objects;
		var endNotNulls = [];
{'fraction_non_alphanumeric': 0.17152165580682255, 'fraction_numerical': 0.003641241855116903, 'mean_word_length': 3.8324074074074073, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '641296', 'n_tokens_mistral': 2099, 'n_tokens_neox': 1808, 'n_words': 330}