1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/dashboard-ui/scripts/extensions.js

42 lines
1.1 KiB
JavaScript
Raw Normal View History

2015-12-14 10:43:03 -05:00
function getWindowLocationSearch(win) {
2014-04-08 22:12:17 -04: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 22:27:30 -04:00
2014-04-08 22:12:17 -04:00
return search || '';
}
2013-05-26 00:52:14 -04:00
function getParameterByName(name, url) {
2013-02-20 20:33:05 -05:00
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
2013-05-31 21:48:41 -04:00
var regex = new RegExp(regexS, "i");
2014-04-08 22:12:17 -04:00
var results = regex.exec(url || getWindowLocationSearch());
2013-02-20 20:33:05 -05:00
if (results == null)
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
2014-05-01 22:54:33 -04: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 14:45:42 -04:00
else if (value) {
2014-07-02 14:34:08 -04:00
2014-05-01 22:54:33 -04:00
if (url.indexOf('?') == -1) {
return url + '?' + param + "=" + value;
}
return url + '&' + param + "=" + value;
}
2015-06-29 14:45:42 -04:00
return url;
2015-12-14 10:43:03 -05:00
}