PageSourceSearch

https://yildiz.edu.tr/core/modules/views/js/base.js?v=10.6.17

js yildiz.edu.tr collected 2026-09-24 09:07:42 UTC 3,135 bytes, 114 lines download raw bytes

1/**
2 * @file
3 * Some basic behaviors and utility functions for Views.
4 */
5
6(function ($, Drupal, drupalSettings) {
7  /**
8   * @namespace
9   */
10  Drupal.Views = {};
11
12  /**
13   * Helper function to parse a querystring.
14   *
15   * @param {string} query
16   *   The querystring to parse.
17   *
18   * @return {object}
19   *   A map of query parameters.
20   */
21  Drupal.Views.parseQueryString = function (query) {
22    const args = {};
23    if (query.includes('?')) {
24      query = query.substring(query.indexOf('?') + 1);
25    }
26    let pair;
27    const pairs = query.split('&');
28    for (let i = 0; i < pairs.length; i++) {
29      pair = pairs[i].split('=');
30      // Ignore the 'q' path argument, if present.
31      if (pair[0] !== 'q') {
32        if (pair[1]) {
33          args[decodeURIComponent(pair[0].replace(/\+/g, ' '))] =
34            decodeURIComponent(pair[1].replace(/\+/g, ' '));
35        } else {
36          args[decodeURIComponent(pair[0].replace(/\+/g, ' '))] = '';
37        }
38      }
39    }
40    return args;
41  };
42
43  /**
44   * Helper function to return a view's arguments based on a path.
45   *
46   * @param {string} href
47   *   The href to check.
48   * @param {string} viewPath
49   *   The views path to check.
50   *
51   * @return {object}
52   *   An object containing `view_args` and `view_path`.
53   */
54  Drupal.Views.parseViewArgs = function (href, viewPath) {
55    const returnObj = {};
56    const path = Drupal.Views.getPath(href);
57    // Get viewPath URL without baseUrl portion.
58    const viewHref = Drupal.url(viewPath).substring(
59      drupalSettings.path.baseUrl.length,
60    );
61    // Ensure we have a correct path.
62    if (viewHref && path.startsWith(`${viewHref}/`)) {
63      returnObj.view_args = decodeURIComponent(
64        path.substring(viewHref.length + 1, path.length),
65      );
66      returnObj.view_path = path;
67    }
68    return returnObj;
69  };
70
71  /**
72   * Strip off the protocol plus domain from an href.
73   *
74   * @param {string} href
75   *   The href to strip.
76   *
77   * @return {string}
78   *   The href without the protocol and domain.
79   */
80  Drupal.Views.pathPortion = function (href) {
81    // Remove e.g. http://example.com if present.
82    const protocol = window.location.protocol;
83    if (href.startsWith(protocol)) {
84      // 2 is the length of the '//' that normally follows the protocol.
85      href = href.substring(href.indexOf('/', protocol.length + 2));
86    }
87    return href;
88  };
89
90  /**
91   * Return the Drupal path portion of an href.
92   *
93   * @param {string} href
94   *   The href to check.
95   *
96   * @return {string}
97   *   An internal path.
98   */
99  Drupal.Views.getPath = function (href) {
100    href = Drupal.Views.pathPortion(href);
101    href = href.substring(drupalSettings.path.baseUrl.length, href.length);
102    if (href.startsWith('?q=')) {
103      // 3 is the length of the '?q=' added to the URL without clean URLs.
104      href = href.substring(3, href.length);
105    }
106    const chars = ['#', '?', '&'];
107    for (let i = 0; i < chars.length; i++) {
108      if (href.includes(chars[i])) {
109        href = href.substring(0, href.indexOf(chars[i]));
110      }
111    }
112    return href;
113  };
114})(jQuery, Drupal, drupalSettings);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.