PageSourceSearch

https://spectremedia.org/wp-content/themes/spectre-v2/js/utils.js?ver=v.1.0.0

js spectremedia.org collected 2026-10-02 05:25:44 UTC 4,848 bytes, 147 lines download raw bytes

1const WP_AJAX = {
2    post (action, data, onSuccess, onError) {
3
4        let formData = this.toFormData(data);
5        formData.append('action', action);
6
7        $.ajax({
8            url: ajaxurl,
9            method: 'POST',
10            processData: false,
11            contentType: false,
12            data: formData,
13            success: res => {
14                if (res.success) {
15                    if (typeof onSuccess == 'function') onSuccess(res.data);
16                }
17                else {
18                    if (typeof onError == 'function') onError(res);
19                }
20            },
21            error: res => {
22                if (typeof onError == 'function') onError(res);
23            }
24        })
25    },
26    toFormData (o) {
27        let formData = new FormData();
28
29        Object.keys(o).forEach(key => {
30            formData.append(key, o[key]);
31        })
32
33        return formData;
34    }
35};
36
37function parseURL (url) {
38    let o = {
39        url,
40        baseURL: null,
41        hasQueryString: false,
42        queryString: {},
43    };
44
45    let urlSplit = url.split('?');
46    o.baseURL = urlSplit[0];
47
48    if (urlSplit.length > 1) {
49        o.hasQueryString = true;
50        
51        urlSplit[1].split('&').forEach(qsPart => {
52            let qsPartSplit = qsPart.split('=');
53            o.queryString[qsPartSplit[0]] = qsPartSplit[1]
54        });
55    }
56
57    return o;
58}
59
60function buildURL (baseURL, qsObj) {
61    let url = baseURL;
62    let qsKeys = Object.keys(qsObj);
63
64    if (qsKeys.length > 0) {
65        url += "?";
66        url += qsKeys.map(key => key + '=' + qsObj[key]).join('&');
67    }
68
69    return url;
70}
71
72function waitFor (test, callback) {
73
74    if (test()) {
75        callback();
76        return;
77    }
78    
79    var waitToobarIntervalID = null;
80    var waitToolbar = () => {
81
82        if (test()) {
83
84            clearInterval(waitToobarIntervalID);
85            waitToobarIntervalID = null
86            callback();
87
88        }
89    }
90
91    waitToobarIntervalID = setInterval(waitToolbar, 10);
92}
93
94function validateEmail (email) {
95    const re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
96    return re.test(email);
97}
98
99function randomString(length, withNumeric=false) {
100    var text = "";
101    var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
102    if (withNumeric) possible += "0123456789"
103
104    for (var i = 0; i < length; i++)
105        text += possible.charAt(Math.floor(Math.random() * possible.length));
106
107    return text;
108}
109
110const __id = (slug, hashLength=5, withNumeric=true) => {
111    if (typeof slug == 'undefined' || slug == null) {
112        slug = randomString(5, true)
113    }
114    return slug + '_' + Date.now() + randomString(hashLength, withNumeric)
115}
116
117const ICONS = {
118    facebook: `
119        <svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
120            viewBox="0 0 100 100" style="enable-background:new 0 0 100 100;" xml:space="preserve">
121            <path d="M71.9,21.6h-8.1c-6.2,0-7.4,3-7.4,7.3v9.6h15v15.1h-15v38.8H41V53.7H28v-15h13V27.6c0-12.9,7.9-20.1,19.4-20.1h11.7
122            L71.9,21.6L71.9,21.6z"/>
123        </svg>
124    `,
125    copyLink: `
126        <svg version="1.1" id="Calque_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
127                viewBox="0 0 100 100" style="enable-background:new 0 0 100 100;" xml:space="preserve">
128            <style type="text/css">
129                .st0{fill:none;stroke:#000000;stroke-width:4.252;stroke-miterlimit:10;}
130                .st1{stroke:#000000;stroke-width:4.252;stroke-miterlimit:10;}
131            </style>
132            <path class="st0" d="M79.8,16H42.9c-2.3,0-4.2,1.9-4.2,4.2v36.9c0,2.3,1.9,4.2,4.2,4.2h36.9c2.3,0,4.2-1.9,4.2-4.2V20.2
133                C84,17.9,82.1,16,79.8,16z"/>
134            <path class="st1" d="M38.7,38.7H20.2c-2.3,0-4.2,1.9-4.2,4.2v36.9c0,2.3,1.9,4.2,4.2,4.2h36.9c2.3,0,4.2-1.9,4.2-4.2V61.3H38.7V38.7
135                z"/>
136        </svg>
137    `,
138    twitter: `
139        <svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
140            viewBox="0 0 100 100" style="enable-background:new 0 0 100 100;" xml:space="preserve">
141            <path d="M96.5,28.6c-3.1,1.4-6.5,2.3-10,2.7c3.6-2.2,6.4-5.6,7.7-9.6c-3.4,2-7.1,3.4-11.1,4.2c-3.2-3.4-7.7-5.5-12.7-5.5
142                c-11.3,0-19.5,10.5-17,21.4C38.9,41.1,26,34.2,17.4,23.7c-4.6,7.8-2.4,18.1,5.4,23.3c-2.9-0.1-5.5-0.9-7.9-2.2
143                c-0.2,8.1,5.6,15.6,14,17.3c-2.5,0.7-5.1,0.8-7.9,0.3c2.2,6.9,8.7,12,16.3,12.1c-7.3,5.7-16.6,8.3-25.8,7.2
144                c7.7,4.9,16.9,7.8,26.7,7.8c32.4,0,50.7-27.3,49.6-51.9C91.2,35.2,94.2,32.1,96.5,28.6z"/>
145        </svg>
146    `,
147};

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.