PageSourceSearch

https://xoops.org/include/xoops.js

js xoops.org collected 2026-10-01 09:15:30 UTC 7,774 bytes, 250 lines download raw bytes

1function xoops$() {
2    var elements = new Array();
3
4    for (var i = 0; i < arguments.length; i++) {
5        var element = arguments[i];
6        if (typeof element == 'string') {
7            element = document.getElementById(element);
8        }
9
10        if (arguments.length == 1) {
11            return element;
12        }
13
14        elements.push(element);
15    }
16
17    return elements;
18}
19
20
21function xoopsGetElementById(id) {
22    return xoops$(id);
23}
24
25function xoopsSetElementProp(name, prop, val) {
26    var elt = xoopsGetElementById(name);
27    if (elt) {
28        elt[prop] = val;
29    }
30}
31
32function xoopsSetElementStyle(name, prop, val) {
33    var elt = xoopsGetElementById(name);
34    if (elt && elt.style) {
35        elt.style[prop] = val;
36    }
37}
38
39function xoopsGetFormElement(fname, ctlname) {
40    var frm = document.forms[fname];
41    return frm ? frm.elements[ctlname] : null;
42}
43
44function justReturn() {
45    //return;
46}
47
48function openWithSelfMain(url, name, width, height, returnwindow) {
49    const left = Math.max(0, Math.round((screen.width - width) / 2));
50    const top = Math.max(0, Math.round((screen.height - height) / 2));
51    const options = "width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + ",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no";
52
53    const new_window = window.open(url, name, options);
54    if (new_window) {
55        window.self.name = "main";
56        new_window.focus();
57    }
58    return (returnwindow != null ? new_window : void(0));
59}
60
61function setElementColor(id, color) {
62    xoopsGetElementById(id).style.color = "#" + color;
63}
64
65function setElementFont(id, font) {
66    xoopsGetElementById(id).style.fontFamily = font;
67}
68
69function setElementSize(id, size) {
70    xoopsGetElementById(id).style.fontSize = size;
71}
72
73function changeDisplay(id) {
74    var elestyle = xoopsGetElementById(id).style;
75    if (elestyle.display == "") {
76        elestyle.display = "none";
77    } else {
78        elestyle.display = "block";
79    }
80}
81
82function setVisible(id) {
83    xoopsGetElementById(id).style.visibility = "visible";
84}
85
86function setHidden(id) {
87    xoopsGetElementById(id).style.visibility = "hidden";
88}
89
90function appendSelectOption(selectMenuId, optionName, optionValue) {
91    var selectMenu = xoopsGetElementById(selectMenuId);
92    var newoption = new Option(optionName, optionValue);
93    newoption.selected = true;
94    selectMenu.options[selectMenu.options.length] = newoption;
95}
96
97function disableElement(target) {
98    var targetDom = xoopsGetElementById(target);
99    targetDom.disabled = targetDom.disabled != true;
100}
101
102function xoopsCheckAll(form, switchId) {
103    var eltForm = xoops$(form);
104    var eltSwitch = xoops$(switchId);
105    // You MUST NOT specify names, it's just kept for BC with the old lame crappy code
106    if (!eltForm && document.forms[form]) {
107        eltForm = document.forms[form];
108    }
109    if (!eltSwitch && eltForm.elements[switchId]) {
110        eltSwitch = eltForm.elements[switchId];
111    }
112
113    var i;
114    for (i = 0; i != eltForm.elements.length; i++) {
115        if (eltForm.elements[i] != eltSwitch && eltForm.elements[i].type == 'checkbox') {
116            eltForm.elements[i].checked = eltSwitch.checked;
117        }
118    }
119}
120
121
122function xoopsCheckGroup(form, switchId, groupName) {
123    var eltForm = xoops$(form);
124    var eltSwitch = xoops$(switchId);
125    // You MUST NOT specify names, it's just kept for BC with the old lame crappy code
126    if (!eltForm && document.forms[form]) {
127        eltForm = document.forms[form];
128    }
129    if (!eltSwitch && eltForm.elements[switchId]) {
130        eltSwitch = eltForm.elements[switchId];
131    }
132
133    var i;
134    for (i = 0; i != eltForm.elements.length; i++) {
135        var e = eltForm.elements[i];
136        if ((e.type == 'checkbox') && ( e.name == groupName )) {
137            e.checked = eltSwitch.checked;
138            e.click();
139            e.click();  // Click to activate subgroups twice so we don't reverse effect
140        }
141    }
142}
143
144function xoopsCheckAllElements(elementIds, switchId) {
145    var switch_cbox = xoopsGetElementById(switchId);
146    for (var i = 0; i < elementIds.length; i++) {
147        var e = xoopsGetElementById(elementIds[i]);
148        if ((e.name != switch_cbox.name) && (e.type == 'checkbox')) {
149            e.checked = switch_cbox.checked;
150        }
151    }
152}
153
154function xoopsSavePosition(id) {
155    var textareaDom = xoopsGetElementById(id);
156    if (textareaDom.createTextRange) {
157        textareaDom.caretPos = document.selection.createRange().duplicate();
158    }
159}
160function xoopsInsertText(domobj, text) {
161    if (domobj.selectionEnd) {
162        //firefox
163        var start = domobj.selectionStart;
164        var end = domobj.selectionEnd;
165        domobj.value = domobj.value.substr(0, start) + text + domobj.value.substr(end, domobj.value.length);
166        domobj.focus();
167        var pos = start + text.length;
168        domobj.setSelectionRange(pos, pos);
169        domobj.blur();
170    } else if (domobj.createTextRange && domobj.caretPos) {
171        //IE
172        var caretPos = domobj.caretPos;
173        caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
174    } else if (domobj.getSelection && domobj.caretPos) {
175        var caretPos = domobj.caretPos;
176        caretPos.text = caretPos.text.charat(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
177    } else {
178        domobj.value = domobj.value + text;
179    }
180}
181
182function xoopsCodeSmilie(id, smilieCode) {
183    var revisedMessage;
184    var textareaDom = xoopsGetElementById(id);
185    xoopsInsertText(textareaDom, smilieCode);
186    textareaDom.focus();
187    //return;
188}
189function showImgSelected(imgId, selectId, imgDir, extra, xoopsUrl) {
190    if (xoopsUrl == null) {
191        xoopsUrl = "./";
192    }
193    imgDom = xoopsGetElementById(imgId);
194    selectDom = xoopsGetElementById(selectId);
195    if (selectDom.options[selectDom.selectedIndex].value != "") {
196        // encodeURIComponent on the selected value: the theme-switch
197        // selector now allows spaces and non-ASCII directory names, and
198        // avatar / rank / smiley selectors can also legitimately contain
199        // characters that need URL-encoding. encodeURIComponent is a
200        // no-op for [A-Za-z0-9_.-~] (RFC 3986 unreserved), so it does
201        // not change the URL for callers using ASCII-only filenames.
202        imgDom.src = xoopsUrl + "/" + imgDir + "/" + encodeURIComponent(selectDom.options[selectDom.selectedIndex].value) + extra;
203    } else {
204        imgDom.src = xoopsUrl + "/images/blank.gif";
205    }
206}
207
208function xoopsExternalLinks() {
209    if (!document.getElementsByTagName) {
210        return;
211    }
212    var anchors = document.getElementsByTagName("a");
213    for (var i = 0; i < anchors.length; i++) {
214        var anchor = anchors[i];
215        if (anchor.getAttribute("href")) {
216            // Check rel value with extra rels, like "external noflow". No test for performance yet
217            var $pattern = new RegExp("external", "i");
218            if ($pattern.test(anchor.getAttribute("rel"))) {
219                /*anchor.onclick = function() {
220                 window.open(this.href);
221                 return false;
222                 }*/
223                anchor.target = "_blank";
224            }
225        }
226    }
227}
228
229function xoopsOnloadEvent(func) {
230    if (window.onload) {
231        xoopsAddEvent(window, 'load', window.onload);
232    }
233    xoopsAddEvent(window, 'load', func);
234}
235
236function xoopsAddEvent(obj, evType, fn) {
237    if (obj.addEventListener) {
238        obj.addEventListener(evType, fn, true);
239        return true;
240    } else {
241        if (obj.attachEvent) {
242            var r = obj.attachEvent("on" + evType, fn);
243            return r;
244        } else {
245            return false;
246        }
247    }
248}
249
250xoopsOnloadEvent(xoopsExternalLinks);

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.