showing results for - "jquery deparam"
Simona
10 Nov 2020
1/**
2 * jQuery.deparam - The oposite of jQuery param. Creates an object of query string parameters.
3 * 
4 * Credits for the idea and Regex:
5 * http://stevenbenner.com/2010/03/javascript-regex-trick-parse-a-query-string-into-an-object/
6*/
7(function($){
8  $.deparam = $.deparam || function(uri){
9    if(uri === undefined){
10      uri = window.location.search;
11    }
12    var queryString = {};
13    uri.replace(
14      new RegExp(
15        "([^?=&]+)(=([^&#]*))?", "g"),
16        function($0, $1, $2, $3) { queryString[$1] = $3; }
17      );
18      return queryString;
19    };
20})(jQuery);
Luna
16 Jan 2018
1(function ($) {
2  $.deparam =
3    $.deparam ||
4    function (uri) {
5      if (uri === undefined) {
6        uri = window.location.pathname;
7      }
8      const url = window.location.pathname;
9      const results = url.split("/");
10      const result = results.pop();
11      return result;
12    };
13})(Jquery);
14