2015-12-14 08:43:03 -07:00
|
|
|
|
function getWindowLocationSearch(win) {
|
2014-04-08 19:12:17 -07:00
|
|
|
|
|
|
|
|
|
var search = (win || window).location.search;
|
|
|
|
|
|
|
|
|
|
if (!search) {
|
|
|
|
|
|
|
|
|
|
var index = window.location.href.indexOf('?');
|
|
|
|
|
if (index != -1) {
|
|
|
|
|
search = window.location.href.substring(index);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-04-08 19:27:30 -07:00
|
|
|
|
|
2014-04-08 19:12:17 -07:00
|
|
|
|
return search || '';
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-25 21:52:14 -07:00
|
|
|
|
function getParameterByName(name, url) {
|
2013-02-20 18:33:05 -07:00
|
|
|
|
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
|
|
|
|
|
var regexS = "[\\?&]" + name + "=([^&#]*)";
|
2013-05-31 18:48:41 -07:00
|
|
|
|
var regex = new RegExp(regexS, "i");
|
2014-04-08 19:12:17 -07:00
|
|
|
|
|
|
|
|
|
var results = regex.exec(url || getWindowLocationSearch());
|
2013-02-20 18:33:05 -07:00
|
|
|
|
if (results == null)
|
|
|
|
|
return "";
|
|
|
|
|
else
|
|
|
|
|
return decodeURIComponent(results[1].replace(/\+/g, " "));
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-01 19:54:33 -07:00
|
|
|
|
function replaceQueryString(url, param, value) {
|
|
|
|
|
var re = new RegExp("([?|&])" + param + "=.*?(&|$)", "i");
|
|
|
|
|
if (url.match(re))
|
|
|
|
|
return url.replace(re, '$1' + param + "=" + value + '$2');
|
2015-06-29 11:45:42 -07:00
|
|
|
|
else if (value) {
|
2014-07-02 11:34:08 -07:00
|
|
|
|
|
2014-05-01 19:54:33 -07:00
|
|
|
|
if (url.indexOf('?') == -1) {
|
|
|
|
|
return url + '?' + param + "=" + value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return url + '&' + param + "=" + value;
|
|
|
|
|
}
|
2015-06-29 11:45:42 -07:00
|
|
|
|
|
|
|
|
|
return url;
|
2015-12-14 08:43:03 -07:00
|
|
|
|
}
|