This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Explicitly save/update a url parameter using HTML5's replaceState(). | |
function updateQueryStringParam(key, value) { | |
const baseUrl = [location.protocol, '//', location.host, location.pathname].join(''); | |
const urlQueryString = document.location.search; | |
let newParam = key + '=' + value; | |
let params = '?' + newParam; | |
// If the "search" string exists, then build params from it | |
if (urlQueryString) { | |
const keyRegex = new RegExp('([\?&])' + key + '[^&]*'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Changes XML to JSON | |
// Modified version from here: http://davidwalsh.name/convert-xml-json | |
xmlToJson(xml) { | |
// Create the return object | |
let obj = {}; | |
if (xml.nodeType === 1) { // element | |
// do attributes | |
if (xml.attributes.length > 0) { | |
obj['@attributes'] = {}; |