Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
	// Try and ensure switching language maintains address and tab
	function getTabNum() {
		try {
			var cookie = document.cookie.split('; ').filter(function (cookie) {return cookie.startsWith('atMyCouncil')})[0];
			if (cookie.indexOf('MyNearest') >= 0) {
				return 1;
			} else if (cookie.indexOf('AllMapsMyMaps') >= 0) {
				return 2;
			}
			return 0;
		} catch (e) {}
	}
	function getUid() {
		try {
			var cookie = document.cookie.split('; ').filter(function (cookie) {return cookie.startsWith('astun:currentLocation')})[0];
			return JSON.parse(cookie.split('=', 2)[1]).uid;
		} catch (e) {}
	}
	jQuery(function() {
		// Update the  language toggle link to include the tab and UPRN of the address
		jQuery('.toggle').attr('href', jQuery('.toggle').attr('href') + '?tab=' + getTabNum() + '&action=SetAddress&UniqueId=' + getUid());
	});

...