<commit_before>/* App.Views.ChartURL.js                                                             
 * ================                                                             
 *
 * This view is responsible for handling data binding between the
 * the chart and url parameters, to enable nice linking support
 * for specific countries and years.
 *
 * @project Our World In Data
 * @author  <NAME>                                                     
 * @created 2016-03-31
 */ 

;(function() {
	"use strict";
	owid.namespace("App.Views.ChartURL");

	App.Views.ChartURL = Backbone.View.extend({
		initialize: function(options) {
			if (App.isEditor) return false; // No URL stuff while editing charts

			if (window.location.pathname.match(/.export$/)) {
				$("body").attr("id", "chart-export");
				$(window).on("chart-loaded", function() {
					if (window.callPhantom) window.callPhantom();
					else console.log("Chart loaded!");
				});
			}

			// Keep the query params separate between map and the other tabs
			this.lastTabName = null;
			this.mapQueryStr = "?";
			this.chartQueryStr = "?";

			$(window).on("query-change", this.onQueryChange.bind(this));
			options.dispatcher.on("tab-change", this.onTabChange, this);
			App.ChartModel.on("change:selected-countries", this.updateCountryParam, this);			
			App.ChartModel.on("change-map-year", this.updateYearParam, this);
			App.ChartModel.on("change-map", this.updateMapParams, this);
		},

		/**
		 * Apply any url query parameters on chart startup
		 */
		populateFromURL: function() {
			var params = owid.getQueryParams();

			// Set tab if specified
			var tab = params.tab;
			if (tab) {
				if (!_.contains(App.ChartModel.get("tabs"), tab))
					console.error("Unexpected tab: " + tab);
				else
					App.ChartModel.set("default-tab", tab, { silent: true });
			}

			var year = params.year;
			if (year !== undefined) {
				App.ChartModel.updateMapConfig("defaultYear", year);
			}

			var region = params.region;<commit_msg>Fix URL population<commit_after>/* App.Views.ChartURL.js                                                             
 * ================                                                             
 *
 * This view is responsible for handling data binding between the
 * the chart and url parameters, to enable nice linking support
 * for specific countries and years.
 *
 * @project Our World In Data
 * @author  <NAME>                                                     
 * @created 2016-03-31
 */ 

;(function() {
	"use strict";
	owid.namespace("App.Views.ChartURL");

	App.Views.ChartURL = Backbone.View.extend({
		initialize: function(options) {
			if (App.isEditor) return false; // No URL stuff while editing charts

			if (window.location.pathname.match(/.export$/)) {
				$("body").attr("id", "chart-export");
				$(window).on("chart-loaded", function() {
					if (window.callPhantom) window.callPhantom();
					else console.log("Chart loaded!");
				});
			}

			// Keep the query params separate between map and the other tabs
			this.lastTabName = null;
			this.mapQueryStr = "?";
			this.chartQueryStr = "?";

			$(window).on("query-change", this.onQueryChange.bind(this));
			options.dispatcher.on("tab-change", this.onTabChange, this);
			App.ChartModel.on("change:selected-countries", this.updateCountryParam, this);			
			App.ChartModel.on("change-map-year", this.updateYearParam, this);
			App.ChartModel.on("change-map", this.updateMapParams, this);
			this.populateFromURL();
		},

		/**
		 * Apply any url query parameters on chart startup
		 */
		populateFromURL: function() {
			var params = owid.getQueryParams();

			// Set tab if specified
			var tab = params.tab;
			if (tab) {
				if (!_.contains(App.ChartModel.get("tabs"), tab))
					console.error("Unexpected tab: " + tab);
				else
					App.ChartModel.set("default-tab", tab, { silent: true });
			}

			var year = params.year;
			if (year !== undefined) {
				App.ChartModel.updateMapConfig("defaultYear", year);
			}

			var region = params.region;
{'fraction_non_alphanumeric': 0.14625681705503224, 'fraction_numerical': 0.0039662865642042635, 'mean_word_length': 2.460548885077187, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4220563', 'n_tokens_mistral': 1350, 'n_tokens_neox': 1126, 'n_words': 280}