PageSourceSearch

https://floordimensions.com/wp-content/themes/roomvo-elite-site-theme/stimr-handler.js?ver=1.0.2

js floordimensions.com collected 2026-09-29 17:02:21 UTC 4,010 bytes, 134 lines download raw bytes

1(function () {
2  /**
3   * Parses a Roomvo CSS class and returns its components.
4   */
5  function parseRoomvoClass(vizClass, subtypeMap) {
6    let productType = "floor"; // Default
7    let productSku = "";
8    let filters = null;
9    let special = false;
10
11    if (vizClass === "inspire-stimr") {
12      special = true;
13      return { productType: null, productSku: null, filters: null, special };
14    }
15
16    // Handle simple/legacy buttons
17    if (vizClass === "stimr" || vizClass === "visualizer-button") {
18      return { productType, productSku, filters, special };
19    }
20
21    // Parse dynamic class
22    if (vizClass && vizClass.startsWith("stimr")) {
23      let remainder = vizClass.substring("stimr".length);
24
25      if (remainder.length > 0) {
26        const mainParts = remainder.split("--");
27        const typePart = mainParts[0].replace(/^-+/, "");
28        productType = typePart;
29
30        if (mainParts.length > 1) {
31          const dataPart = mainParts[1];
32
33          if (dataPart.startsWith("params")) {
34            // Handle Prefilters
35            filters = {};
36            filters.productSubtypes = [];
37
38            const paramString = dataPart
39              .substring("params".length)
40              .replace(/^[_-]+/, "");
41            const params = paramString.split("__");
42
43            params.forEach(function (part) {
44              const components = part.split("-");
45              const key = components.shift();
46              const values = components;
47              const isSubtypeKey = subtypeMap.hasOwnProperty(key);
48
49              if (isSubtypeKey) {
50                filters.productSubtypes.push(subtypeMap[key]);
51                values.forEach(function (v) {
52                  if (subtypeMap.hasOwnProperty(v)) {
53                    filters.productSubtypes.push(subtypeMap[v]);
54                  }
55                });
56              } else if (values.length > 0) {
57                filters[key] = values;
58              }
59            });
60
61            if (filters.productSubtypes.length === 0) {
62              delete filters.productSubtypes;
63            }
64          } else {
65            productSku = dataPart;
66          }
67        }
68      }
69    }
70    return { productType, productSku, filters, special };
71  }
72
73  // Event Listener
74  document.addEventListener("DOMContentLoaded", function () {
75    if (
76      typeof roomvoData === "undefined" ||
77      typeof roomvoData.subtypeMap === "undefined"
78    ) {
79      console.error("Roomvo data (subtypeMap) was not localized by PHP.");
80      return;
81    }
82
83    const localSubtypeMap = roomvoData.subtypeMap;
84
85    const myVizButtons = document.querySelectorAll(
86      '.stimr, .visualizer-button, [class*="stimr-"], .inspire-stimr'
87    );
88
89    myVizButtons.forEach(function (button) {
90      button.addEventListener("click", function (event) {
91        let vizClass = null;
92        for (let className of this.classList) {
93          if (
94            className === "stimr" ||
95            className === "visualizer-button" ||
96            className.startsWith("stimr-") ||
97            className === "inspire-stimr"
98          ) {
99            vizClass = className;
100            break;
101          }
102        }
103
104        if (!vizClass) return;
105
106        const { productType, productSku, filters, special } = parseRoomvoClass(
107          vizClass,
108          localSubtypeMap
109        );
110
111        if (typeof roomvo !== "undefined") {
112          if (special) {
113            roomvo.startStandaloneVisualizer({
114              extraParams: "&has_room_style_transfer_list=1",
115            });
116          } else if (filters) {
117            const prefilterObj = { prefilter: JSON.stringify(filters) };
118            roomvo.startStandaloneVisualizer(
119              productType,
120              "",
121              "",
122              "",
123              prefilterObj
124            );
125          } else {
126            roomvo.startStandaloneVisualizer(productType, productSku);
127          }
128        } else {
129          console.error("Roomvo script is not loaded.");
130        }
131      });
132    });
133  });
134})();

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.