<commit_before>GCMRC.Page = {
	createMiniMap: function(config) {
		if (!config)
			config = {};

		var upstreamStationName = config['upstreamStationName'];
		var downstreamStationName = config['downstreamStationName'];
		var divId = config['divId'] || 'openlayers-map';

		var options = {};
		GCMRC.Mapping.maps[divId] = new OpenLayers.Map(divId, options);

		var layersToAdd = [];
		layersToAdd.push(GCMRC.Mapping.layers.esri.esriTopo);
		layersToAdd.push(GCMRC.Mapping.layers.flowlines["zone" + GCMRC.Page.reach.displayOrder]);
		layersToAdd.push(GCMRC.Mapping.layers.markers);

		GCMRC.Mapping.maps[divId].addLayers(layersToAdd);
		var makeIcon = function() {
			var size = new OpenLayers.Size(21, 25);
			var offset = new OpenLayers.Pixel(-(size.w / 2), -size.h);
			var icon = new OpenLayers.Icon(CONFIG.relativePath + 'app/marker.png', size, offset);

			return icon;
		};

		if (GCMRC.Stations[upstreamStationName]) {
			GCMRC.Mapping.layers.markers.addMarker(
					new OpenLayers.Marker(new OpenLayers.LonLat(GCMRC.Stations[upstreamStationName].lon, GCMRC.Stations[upstreamStationName].lat).transform(
					new OpenLayers.Projection("EPSG:4326"),
					GCMRC.Mapping.maps[divId].getProjectionObject()
					), makeIcon()));
		}

		if (GCMRC.Stations[downstreamStationName]) {
			GCMRC.Mapping.layers.markers.addMarker(new OpenLayers.Marker(
					new OpenLayers.LonLat(GCMRC.Stations[downstreamStationName].lon, GCMRC.Stations[downstreamStationName].lat).transform(
					new OpenLayers.Projection("EPSG:4326"),
					GCMRC.Mapping.maps[divId].getProjectionObject()
					), makeIcon()));
		}

		GCMRC.Mapping.maps[divId].zoomToExtent(GCMRC.Mapping.layers.markers.getDataExtent());
	},
	buildPORView : function(div, earliest, latest) {
		var result = [
			'<div>',
			'Records exist from ',
			'<a href="#" class="fromdate">',
			earliest.split("T")[0],
			'</a>',
			' through ',
			'<a href="#" class="todate">',
			latest.split("T")[0],
			'</a>',
			'</div>'
		];
		div.append(result.join(''));
	},
	buildSliderInfo : function(div, dateStr, multiplier) {
		div.append('<div>Uncertainty for Major Tributary Sand Loads <span class="c_qual' + multiplier + '"></span>% after ' + dateStr + '</div>');
	},
	buildGraphClicked: function() {
		var begin = $("input[name='beginPosition']").val();
		var end = $("input[name='endPosition']").val();
		
		var endStaticRecMillis = new Date(GCMRC.Page.reach.endStaticRec).getTime() + (CONFIG.networkHoursOffset * 60 * 60 * 1000);
		var newestSuspSedMillis = new Date(GCMRC.Page.reach.newestSuspSed).getTime() + (CONFIG.networkHoursOffset * 60 * 60 * 1000);
		
		var beginMillis = Date.create(begin).getUTCTime() + (CONFIG.networkHoursOffset * 60 * 60 * 1000);
		var endMillis = Date.create(end).getUTCTime() + (CONFIG.networkHoursOffset * 60 * 60 * 1000);
		if (endMillis >= beginMillis) {
			var expectedGraphColumns = GCMRC.Page.getExpectedGraphColumns();
			var chosenParameters = [];
			expectedGraphColumns.forEach(function(el) {
				[].push.apply(this, el.columns.map(function(col) {
					return col.split("-")[0];
				}).unique());
			}, chosenParameters);

			var expectedStations = [];
			if (CONFIG.upstreamStationName) {
				expectedStations.push(CONFIG.upstreamStationName);
			}
			if (CONFIG.downstreamStationName) {
				expectedStations.push(CONFIG.downstreamStationName);
			}
			if (GCMRC.Page.reach.majorTrib) {
				expectedStations.push(GCMRC.Page.reach.majorTrib);
			}
			if (GCMRC.Page.reach.minorTrib) {
				expectedStations.push(GCMRC.Page.reach.minorTrib);
			}
			if (GCMRC.Page.reach.downstreamDischargeStation) {
				expectedStations.push(GCMRC.Page.reach.downstreamDischargeStation);
			}

			var serviceOptions = {
				station: expectedStations,
				beginPosition: begin,
				endPosition: end,
				column: chosenParameters,
				tz: '-' + CONFIG.networkHoursOffset,
				cutoffBefore: GCMRC.Page.earliestPositionISO,
				cutoffAfter: GCMRC.Page.latestPositionISO,
				timeFormat: 'UTCMillis',
				every: 'P1D',
				noDataFilter: 'true',
				useLagged: 'true'
			};

			var aggTime = GCMRC.Page.checkIfAgg(serviceOptions);

			if (aggTime) {
				serviceOptions['downscale'] = aggTime;
			}
			
			var thingthing = $('div.c_qual');
			thingthing.empty();
			if ((endStaticRecMillis && endStaticRecMillis < endMillis) && 
					(!newestSuspSedMillis || (endStaticRecMillis < newestSuspSedMillis && newestSuspSedMillis > beginMillis))) {
				GCMRC.Page.buildSliderInfo(thingthing, GCMRC.Page.reach.endStaticRec.split("T")[0], 2);
				$('.c_qual2').html(parseFloat($('span[name=c_val]').html()) * 2);
			}
			if (newestSuspSedMillis && newestSuspSedMillis < endMillis) {
				GCMRC.Page.buildSliderInfo(thingthing, GCMRC.Page.reach.newestSuspSed.split("T")[0], 4);
				$('.c_qual4').html(parseFloat($('span[name=c_val]').html()) * 4);
			}
			
			GCMRC.Graphing.createDataGraph(
					'agg',
					{
						divId: 'data-dygraph',
						labelDivId: 'legend-dygraph',
						graphsToMake: expectedGraphColumns,
						endStaticRec : endStaticRecMillis,
						newestSuspSed : newestSuspSedMillis,
						dateWindow : [beginMillis, endMillis]
					},
			serviceOptions);
		} else {
			GCMRC.Graphing.clearErrorMsg();
			GCMRC.Graphing.showErrorMsg("Please choose an End that is after Start");
		}
	},
	downloadDataClicked : function() {
		if (GCMRC.Graphing.graphs['data-dygraph']) {
			var form = $('#exportPost');
			var tabbedData = "Time\tLow\tMid\tHigh\n";
			GCMRC.Graphing.graphs['data-dygraph']["sandbudget"].file_.forEach(function(el) {
				tabbedData += el[0] + '\t' + el[1][0] + '\t' + el[1][1] + '\t' + el[1][2] + '\n';
			});

			form.find('[name=data]').val(tabbedData)
			form.submit();
		} else {
			LOG.debug("We don't have data to pull from!");
		}
	},
	fromDateClicked: function() {
		$('#beginDatePicker').val($(this).html());
	},
	toDateClicked: function() {
		var date = $(this).html();
		if ("Now" === date) {
			date = new Date();
<commit_msg>capital Time<commit_after>GCMRC.Page = {
	createMiniMap: function(config) {
		if (!config)
			config = {};

		var upstreamStationName = config['upstreamStationName'];
		var downstreamStationName = config['downstreamStationName'];
		var divId = config['divId'] || 'openlayers-map';

		var options = {};
		GCMRC.Mapping.maps[divId] = new OpenLayers.Map(divId, options);

		var layersToAdd = [];
		layersToAdd.push(GCMRC.Mapping.layers.esri.esriTopo);
		layersToAdd.push(GCMRC.Mapping.layers.flowlines["zone" + GCMRC.Page.reach.displayOrder]);
		layersToAdd.push(GCMRC.Mapping.layers.markers);

		GCMRC.Mapping.maps[divId].addLayers(layersToAdd);
		var makeIcon = function() {
			var size = new OpenLayers.Size(21, 25);
			var offset = new OpenLayers.Pixel(-(size.w / 2), -size.h);
			var icon = new OpenLayers.Icon(CONFIG.relativePath + 'app/marker.png', size, offset);

			return icon;
		};

		if (GCMRC.Stations[upstreamStationName]) {
			GCMRC.Mapping.layers.markers.addMarker(
					new OpenLayers.Marker(new OpenLayers.LonLat(GCMRC.Stations[upstreamStationName].lon, GCMRC.Stations[upstreamStationName].lat).transform(
					new OpenLayers.Projection("EPSG:4326"),
					GCMRC.Mapping.maps[divId].getProjectionObject()
					), makeIcon()));
		}

		if (GCMRC.Stations[downstreamStationName]) {
			GCMRC.Mapping.layers.markers.addMarker(new OpenLayers.Marker(
					new OpenLayers.LonLat(GCMRC.Stations[downstreamStationName].lon, GCMRC.Stations[downstreamStationName].lat).transform(
					new OpenLayers.Projection("EPSG:4326"),
					GCMRC.Mapping.maps[divId].getProjectionObject()
					), makeIcon()));
		}

		GCMRC.Mapping.maps[divId].zoomToExtent(GCMRC.Mapping.layers.markers.getDataExtent());
	},
	buildPORView : function(div, earliest, latest) {
		var result = [
			'<div>',
			'Records exist from ',
			'<a href="#" class="fromdate">',
			earliest.split("T")[0],
			'</a>',
			' through ',
			'<a href="#" class="todate">',
			latest.split("T")[0],
			'</a>',
			'</div>'
		];
		div.append(result.join(''));
	},
	buildSliderInfo : function(div, dateStr, multiplier) {
		div.append('<div>Uncertainty for Major Tributary Sand Loads <span class="c_qual' + multiplier + '"></span>% after ' + dateStr + '</div>');
	},
	buildGraphClicked: function() {
		var begin = $("input[name='beginPosition']").val();
		var end = $("input[name='endPosition']").val();
		
		var endStaticRecMillis = new Date(GCMRC.Page.reach.endStaticRec).getTime() + (CONFIG.networkHoursOffset * 60 * 60 * 1000);
		var newestSuspSedMillis = new Date(GCMRC.Page.reach.newestSuspSed).getTime() + (CONFIG.networkHoursOffset * 60 * 60 * 1000);
		
		var beginMillis = Date.create(begin).getUTCTime() + (CONFIG.networkHoursOffset * 60 * 60 * 1000);
		var endMillis = Date.create(end).getUTCTime() + (CONFIG.networkHoursOffset * 60 * 60 * 1000);
		if (endMillis >= beginMillis) {
			var expectedGraphColumns = GCMRC.Page.getExpectedGraphColumns();
			var chosenParameters = [];
			expectedGraphColumns.forEach(function(el) {
				[].push.apply(this, el.columns.map(function(col) {
					return col.split("-")[0];
				}).unique());
			}, chosenParameters);

			var expectedStations = [];
			if (CONFIG.upstreamStationName) {
				expectedStations.push(CONFIG.upstreamStationName);
			}
			if (CONFIG.downstreamStationName) {
				expectedStations.push(CONFIG.downstreamStationName);
			}
			if (GCMRC.Page.reach.majorTrib) {
				expectedStations.push(GCMRC.Page.reach.majorTrib);
			}
			if (GCMRC.Page.reach.minorTrib) {
				expectedStations.push(GCMRC.Page.reach.minorTrib);
			}
			if (GCMRC.Page.reach.downstreamDischargeStation) {
				expectedStations.push(GCMRC.Page.reach.downstreamDischargeStation);
			}

			var serviceOptions = {
				station: expectedStations,
				beginPosition: begin,
				endPosition: end,
				column: chosenParameters,
				tz: '-' + CONFIG.networkHoursOffset,
				cutoffBefore: GCMRC.Page.earliestPositionISO,
				cutoffAfter: GCMRC.Page.latestPositionISO,
				timeFormat: 'UTCMillis',
				every: 'P1D',
				noDataFilter: 'true',
				useLagged: 'true'
			};

			var aggTime = GCMRC.Page.checkIfAgg(serviceOptions);

			if (aggTime) {
				serviceOptions['downscale'] = aggTime;
			}
			
			var thingthing = $('div.c_qual');
			thingthing.empty();
			if ((endStaticRecMillis && endStaticRecMillis < endMillis) && 
					(!newestSuspSedMillis || (endStaticRecMillis < newestSuspSedMillis && newestSuspSedMillis > beginMillis))) {
				GCMRC.Page.buildSliderInfo(thingthing, GCMRC.Page.reach.endStaticRec.split("T")[0], 2);
				$('.c_qual2').html(parseFloat($('span[name=c_val]').html()) * 2);
			}
			if (newestSuspSedMillis && newestSuspSedMillis < endMillis) {
				GCMRC.Page.buildSliderInfo(thingthing, GCMRC.Page.reach.newestSuspSed.split("T")[0], 4);
				$('.c_qual4').html(parseFloat($('span[name=c_val]').html()) * 4);
			}
			
			GCMRC.Graphing.createDataGraph(
					'agg',
					{
						divId: 'data-dygraph',
						labelDivId: 'legend-dygraph',
						graphsToMake: expectedGraphColumns,
						endStaticRec : endStaticRecMillis,
						newestSuspSed : newestSuspSedMillis,
						dateWindow : [beginMillis, endMillis]
					},
			serviceOptions);
		} else {
			GCMRC.Graphing.clearErrorMsg();
			GCMRC.Graphing.showErrorMsg("Please choose an End that is after Start");
		}
	},
	downloadDataClicked : function() {
		if (GCMRC.Graphing.graphs['data-dygraph']) {
			var form = $('#exportPost');
			var tabbedData = "Time\tLower Uncertainty Bound\tZero Bias Value\tUpper Uncertainty Bound\n";
			GCMRC.Graphing.graphs['data-dygraph']["sandbudget"].file_.forEach(function(el) {
				tabbedData += el[0] + '\t' + el[1][0] + '\t' + el[1][1] + '\t' + el[1][2] + '\n';
			});

			form.find('[name=data]').val(tabbedData)
			form.submit();
		} else {
			LOG.debug("We don't have data to pull from!");
		}
	},
	fromDateClicked: function() {
		$('#beginDatePicker').val($(this).html());
	},
	toDateClicked: function() {
		var date = $(this).html();
		if ("Now" === date) {
			date = new Date();

{'fraction_non_alphanumeric': 0.16470390309555855, 'fraction_numerical': 0.010767160161507403, 'mean_word_length': 4.205341506129598, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2972815', 'n_tokens_mistral': 4969, 'n_tokens_neox': 4204, 'n_words': 633}