These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | /* |
||
2 | smf_AdminIndex(oOptions) |
||
3 | { |
||
4 | public init() |
||
5 | public loadAdminIndex() |
||
6 | public setAnnouncements() |
||
7 | public showCurrentVersion() |
||
8 | public checkUpdateAvailable() |
||
9 | } |
||
10 | |||
11 | smf_ViewVersions(oOptions) |
||
12 | { |
||
13 | public init() |
||
14 | public loadViewVersions |
||
15 | public swapOption(oSendingElement, sName) |
||
16 | public compareVersions(sCurrent, sTarget) |
||
17 | public determineVersions() |
||
18 | } |
||
19 | */ |
||
20 | |||
21 | |||
22 | |||
23 | // Handle the JavaScript surrounding the admin and moderation center. |
||
24 | function smf_AdminIndex(oOptions) |
||
25 | { |
||
26 | this.opt = oOptions; |
||
27 | this.init(); |
||
28 | } |
||
29 | |||
30 | smf_AdminIndex.prototype.init = function () |
||
31 | { |
||
32 | window.adminIndexInstanceRef = this; |
||
33 | var fHandlePageLoaded = function () { |
||
34 | window.adminIndexInstanceRef.loadAdminIndex(); |
||
35 | } |
||
36 | addLoadEvent(fHandlePageLoaded); |
||
37 | } |
||
38 | |||
39 | smf_AdminIndex.prototype.loadAdminIndex = function () |
||
40 | { |
||
41 | // Load the text box containing the latest news items. |
||
42 | if (this.opt.bLoadAnnouncements) |
||
43 | this.setAnnouncements(); |
||
44 | |||
45 | // Load the current SMF and your SMF version numbers. |
||
46 | if (this.opt.bLoadVersions) |
||
47 | this.showCurrentVersion(); |
||
48 | |||
49 | // Load the text box that sais there's a new version available. |
||
50 | if (this.opt.bLoadUpdateNotification) |
||
51 | this.checkUpdateAvailable(); |
||
52 | } |
||
53 | |||
54 | |||
55 | smf_AdminIndex.prototype.setAnnouncements = function () |
||
56 | { |
||
57 | if (!('smfAnnouncements' in window) || !('length' in window.smfAnnouncements)) |
||
58 | return; |
||
59 | |||
60 | var sMessages = ''; |
||
61 | for (var i = 0; i < window.smfAnnouncements.length; i++) |
||
62 | sMessages += this.opt.sAnnouncementMessageTemplate.replace('%href%', window.smfAnnouncements[i].href).replace('%subject%', window.smfAnnouncements[i].subject).replace('%time%', window.smfAnnouncements[i].time).replace('%message%', window.smfAnnouncements[i].message); |
||
63 | |||
64 | setInnerHTML(document.getElementById(this.opt.sAnnouncementContainerId), this.opt.sAnnouncementTemplate.replace('%content%', sMessages)); |
||
65 | } |
||
66 | |||
67 | smf_AdminIndex.prototype.showCurrentVersion = function () |
||
68 | { |
||
69 | if (!('smfVersion' in window)) |
||
70 | return; |
||
71 | |||
72 | var oSmfVersionContainer = document.getElementById(this.opt.sSmfVersionContainerId); |
||
73 | var oYourVersionContainer = document.getElementById(this.opt.sYourVersionContainerId); |
||
74 | |||
75 | setInnerHTML(oSmfVersionContainer, window.smfVersion); |
||
76 | |||
77 | var sCurrentVersion = getInnerHTML(oYourVersionContainer); |
||
78 | if (sCurrentVersion != window.smfVersion) |
||
79 | setInnerHTML(oYourVersionContainer, this.opt.sVersionOutdatedTemplate.replace('%currentVersion%', sCurrentVersion)); |
||
80 | } |
||
81 | |||
82 | smf_AdminIndex.prototype.checkUpdateAvailable = function () |
||
83 | { |
||
84 | if (!('smfUpdatePackage' in window)) |
||
85 | return; |
||
86 | |||
87 | var oContainer = document.getElementById(this.opt.sUpdateNotificationContainerId); |
||
88 | |||
89 | // Are we setting a custom title and message? |
||
90 | var sTitle = 'smfUpdateTitle' in window ? window.smfUpdateTitle : this.opt.sUpdateNotificationDefaultTitle; |
||
91 | var sMessage = 'smfUpdateNotice' in window ? window.smfUpdateNotice : this.opt.sUpdateNotificationDefaultMessage; |
||
92 | |||
93 | setInnerHTML(oContainer, this.opt.sUpdateNotificationTemplate.replace('%title%', sTitle).replace('%message%', sMessage)); |
||
94 | |||
95 | // Parse in the package download URL if it exists in the string. |
||
96 | document.getElementById('update-link').href = this.opt.sUpdateNotificationLink.replace('%package%', window.smfUpdatePackage); |
||
97 | |||
98 | oContainer.className = ('smfUpdateCritical' in window) ? 'errorbox' : 'noticebox'; |
||
99 | } |
||
100 | |||
101 | |||
102 | |||
103 | function smf_ViewVersions (oOptions) |
||
104 | { |
||
105 | this.opt = oOptions; |
||
106 | this.oSwaps = {}; |
||
107 | this.init(); |
||
108 | } |
||
109 | |||
110 | smf_ViewVersions.prototype.init = function () |
||
111 | { |
||
112 | // Load this on loading of the page. |
||
113 | window.viewVersionsInstanceRef = this; |
||
114 | var fHandlePageLoaded = function () { |
||
115 | window.viewVersionsInstanceRef.loadViewVersions(); |
||
116 | } |
||
117 | addLoadEvent(fHandlePageLoaded); |
||
118 | } |
||
119 | |||
120 | smf_ViewVersions.prototype.loadViewVersions = function () |
||
121 | { |
||
122 | this.determineVersions(); |
||
123 | } |
||
124 | |||
125 | smf_ViewVersions.prototype.swapOption = function (oSendingElement, sName) |
||
126 | { |
||
127 | // If it is undefined, or currently off, turn it on - otherwise off. |
||
128 | this.oSwaps[sName] = !(sName in this.oSwaps) || !this.oSwaps[sName]; |
||
129 | if (this.oSwaps[sName]) |
||
130 | $("#" + sName).show(300); |
||
131 | else |
||
132 | $("#" + sName).hide(300); |
||
133 | |||
134 | // Unselect the link and return false. |
||
135 | oSendingElement.blur(); |
||
136 | return false; |
||
137 | } |
||
138 | |||
139 | smf_ViewVersions.prototype.compareVersions = function (sCurrent, sTarget) |
||
140 | { |
||
141 | var aVersions = aParts = new Array(); |
||
142 | var aCompare = new Array(sCurrent, sTarget); |
||
143 | |||
144 | for (var i = 0; i < 2; i++) |
||
145 | { |
||
146 | // Clean the version and extract the version parts. |
||
147 | var sClean = aCompare[i].toLowerCase().replace(/ /g, '').replace(/2.0rc1-1/, '2.0rc1.1'); |
||
148 | aParts = sClean.match(/(\d+)(?:\.(\d+|))?(?:\.)?(\d+|)(?:(alpha|beta|rc)(\d+|)(?:\.)?(\d+|))?(?:(dev))?(\d+|)/); |
||
149 | |||
150 | // No matches? |
||
151 | if (aParts == null) |
||
152 | return false; |
||
153 | |||
154 | // Build an array of parts. |
||
155 | aVersions[i] = [ |
||
156 | aParts[1] > 0 ? parseInt(aParts[1]) : 0, |
||
157 | aParts[2] > 0 ? parseInt(aParts[2]) : 0, |
||
158 | aParts[3] > 0 ? parseInt(aParts[3]) : 0, |
||
159 | typeof(aParts[4]) == 'undefined' ? 'stable' : aParts[4], |
||
160 | aParts[5] > 0 ? parseInt(aParts[5]) : 0, |
||
161 | aParts[6] > 0 ? parseInt(aParts[6]) : 0, |
||
162 | typeof(aParts[7]) != 'undefined', |
||
163 | ]; |
||
164 | } |
||
165 | |||
166 | // Loop through each category. |
||
167 | for (i = 0; i < 7; i++) |
||
168 | { |
||
169 | // Is there something for us to calculate? |
||
170 | if (aVersions[0][i] != aVersions[1][i]) |
||
171 | { |
||
172 | // Dev builds are a problematic exception. |
||
173 | // (stable) dev < (stable) but (unstable) dev = (unstable) |
||
174 | if (i == 3) |
||
175 | return aVersions[0][i] < aVersions[1][i] ? !aVersions[1][6] : aVersions[0][6]; |
||
176 | else if (i == 6) |
||
177 | return aVersions[0][6] ? aVersions[1][3] == 'stable' : false; |
||
178 | // Otherwise a simple comparison. |
||
179 | else |
||
180 | return aVersions[0][i] < aVersions[1][i]; |
||
181 | } |
||
182 | } |
||
183 | |||
184 | // They are the same! |
||
185 | return false; |
||
186 | } |
||
187 | |||
188 | smf_ViewVersions.prototype.determineVersions = function () |
||
189 | { |
||
190 | var oHighYour = { |
||
191 | Sources: '??', |
||
192 | Default: '??', |
||
193 | Languages: '??', |
||
194 | Templates: '??', |
||
195 | Tasks: '??' |
||
196 | }; |
||
197 | var oHighCurrent = { |
||
198 | Sources: '??', |
||
199 | Default: '??', |
||
200 | Languages: '??', |
||
201 | Templates: '??', |
||
202 | Tasks: '??' |
||
203 | }; |
||
204 | var oLowVersion = { |
||
205 | Sources: false, |
||
206 | Default: false, |
||
207 | Languages: false, |
||
208 | Templates: false, |
||
209 | Tasks: false |
||
210 | }; |
||
211 | |||
212 | var sSections = [ |
||
213 | 'Sources', |
||
214 | 'Default', |
||
215 | 'Languages', |
||
216 | 'Templates', |
||
217 | 'Tasks' |
||
218 | ]; |
||
219 | |||
220 | for (var i = 0, n = sSections.length; i < n; i++) |
||
221 | { |
||
222 | // Collapse all sections. |
||
223 | var oSection = document.getElementById(sSections[i]); |
||
224 | if (typeof(oSection) == 'object' && oSection != null) |
||
225 | oSection.style.display = 'none'; |
||
226 | |||
227 | // Make all section links clickable. |
||
228 | var oSectionLink = document.getElementById(sSections[i] + '-link'); |
||
229 | if (typeof(oSectionLink) == 'object' && oSectionLink != null) |
||
230 | { |
||
231 | oSectionLink.instanceRef = this; |
||
232 | oSectionLink.sSection = sSections[i]; |
||
233 | oSectionLink.onclick = function () { |
||
234 | this.instanceRef.swapOption(this, this.sSection); |
||
235 | return false; |
||
236 | }; |
||
237 | } |
||
238 | } |
||
239 | |||
240 | if (!('smfVersions' in window)) |
||
241 | window.smfVersions = {}; |
||
242 | |||
243 | for (var sFilename in window.smfVersions) |
||
244 | { |
||
245 | if (!document.getElementById('current' + sFilename)) |
||
246 | continue; |
||
247 | |||
248 | var sYourVersion = getInnerHTML(document.getElementById('your' + sFilename)); |
||
249 | |||
250 | var sCurVersionType; |
||
251 | for (var sVersionType in oLowVersion) |
||
252 | if (sFilename.substr(0, sVersionType.length) == sVersionType) |
||
253 | { |
||
254 | sCurVersionType = sVersionType; |
||
255 | break; |
||
256 | } |
||
257 | |||
258 | if (typeof(sCurVersionType) != 'undefined') |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
259 | { |
||
260 | if ((this.compareVersions(oHighYour[sCurVersionType], sYourVersion) || oHighYour[sCurVersionType] == '??') && !oLowVersion[sCurVersionType]) |
||
261 | oHighYour[sCurVersionType] = sYourVersion; |
||
262 | if (this.compareVersions(oHighCurrent[sCurVersionType], smfVersions[sFilename]) || oHighCurrent[sCurVersionType] == '??') |
||
263 | oHighCurrent[sCurVersionType] = smfVersions[sFilename]; |
||
264 | |||
265 | if (this.compareVersions(sYourVersion, smfVersions[sFilename])) |
||
266 | { |
||
267 | oLowVersion[sCurVersionType] = sYourVersion; |
||
268 | document.getElementById('your' + sFilename).className = 'alert'; |
||
269 | } |
||
270 | } |
||
271 | else if (this.compareVersions(sYourVersion, smfVersions[sFilename])) |
||
272 | oLowVersion[sCurVersionType] = sYourVersion; |
||
273 | |||
274 | setInnerHTML(document.getElementById('current' + sFilename), smfVersions[sFilename]); |
||
275 | setInnerHTML(document.getElementById('your' + sFilename), sYourVersion); |
||
276 | } |
||
277 | |||
278 | if (!('smfLanguageVersions' in window)) |
||
279 | window.smfLanguageVersions = {}; |
||
280 | |||
281 | for (sFilename in window.smfLanguageVersions) |
||
282 | { |
||
283 | for (var i = 0; i < this.opt.aKnownLanguages.length; i++) |
||
284 | { |
||
285 | if (!document.getElementById('current' + sFilename + this.opt.aKnownLanguages[i])) |
||
286 | continue; |
||
287 | |||
288 | setInnerHTML(document.getElementById('current' + sFilename + this.opt.aKnownLanguages[i]), smfLanguageVersions[sFilename]); |
||
289 | |||
290 | sYourVersion = getInnerHTML(document.getElementById('your' + sFilename + this.opt.aKnownLanguages[i])); |
||
291 | setInnerHTML(document.getElementById('your' + sFilename + this.opt.aKnownLanguages[i]), sYourVersion); |
||
292 | |||
293 | if ((this.compareVersions(oHighYour.Languages, sYourVersion) || oHighYour.Languages == '??') && !oLowVersion.Languages) |
||
294 | oHighYour.Languages = sYourVersion; |
||
295 | if (this.compareVersions(oHighCurrent.Languages, smfLanguageVersions[sFilename]) || oHighCurrent.Languages == '??') |
||
296 | oHighCurrent.Languages = smfLanguageVersions[sFilename]; |
||
297 | |||
298 | if (this.compareVersions(sYourVersion, smfLanguageVersions[sFilename])) |
||
299 | { |
||
300 | oLowVersion.Languages = sYourVersion; |
||
301 | document.getElementById('your' + sFilename + this.opt.aKnownLanguages[i]).style.color = 'red'; |
||
302 | } |
||
303 | } |
||
304 | } |
||
305 | |||
306 | setInnerHTML(document.getElementById('yourSources'), oLowVersion.Sources ? oLowVersion.Sources : oHighYour.Sources); |
||
307 | setInnerHTML(document.getElementById('currentSources'), oHighCurrent.Sources); |
||
308 | if (oLowVersion.Sources) |
||
309 | document.getElementById('yourSources').className = 'alert'; |
||
310 | |||
311 | setInnerHTML(document.getElementById('yourDefault'), oLowVersion.Default ? oLowVersion.Default : oHighYour.Default); |
||
312 | setInnerHTML(document.getElementById('currentDefault'), oHighCurrent.Default); |
||
313 | if (oLowVersion.Default) |
||
314 | document.getElementById('yourDefault').className = 'alert'; |
||
315 | |||
316 | if (document.getElementById('Templates')) |
||
317 | { |
||
318 | setInnerHTML(document.getElementById('yourTemplates'), oLowVersion.Templates ? oLowVersion.Templates : oHighYour.Templates); |
||
319 | setInnerHTML(document.getElementById('currentTemplates'), oHighCurrent.Templates); |
||
320 | |||
321 | if (oLowVersion.Templates) |
||
322 | document.getElementById('yourTemplates').className = 'alert'; |
||
323 | } |
||
324 | |||
325 | setInnerHTML(document.getElementById('yourLanguages'), oLowVersion.Languages ? oLowVersion.Languages : oHighYour.Languages); |
||
326 | setInnerHTML(document.getElementById('currentLanguages'), oHighCurrent.Languages); |
||
327 | if (oLowVersion.Languages) |
||
328 | document.getElementById('yourLanguages').className = 'alert'; |
||
329 | |||
330 | setInnerHTML(document.getElementById('yourTasks'), oLowVersion.Tasks ? oLowVersion.Tasks : oHighYour.Tasks); |
||
331 | setInnerHTML(document.getElementById('currentTasks'), oHighCurrent.Tasks); |
||
332 | if (oLowVersion.Tasks) |
||
333 | document.getElementById('yourTasks').className = 'alert'; |
||
334 | } |
||
335 | |||
336 | function addNewWord() |
||
337 | { |
||
338 | setOuterHTML(document.getElementById('moreCensoredWords'), '<div style="margin-top: 1ex;"><input type="text" name="censor_vulgar[]" size="30"> => <input type="text" name="censor_proper[]" size="30"><' + '/div><div id="moreCensoredWords"><' + '/div>'); |
||
339 | } |
||
340 | |||
341 | function toggleBBCDisabled(section, disable) |
||
342 | { |
||
343 | elems = document.getElementById(section).getElementsByTagName('*'); |
||
344 | for (var i = 0; i < elems.length; i++) |
||
345 | { |
||
346 | if (typeof(elems[i].name) == "undefined" || (elems[i].name.substr((section.length + 1), (elems[i].name.length - 2 - (section.length + 1))) != "enabledTags") || (elems[i].name.indexOf(section) != 0)) |
||
347 | continue; |
||
348 | |||
349 | elems[i].disabled = disable; |
||
350 | } |
||
351 | document.getElementById("bbc_" + section + "_select_all").disabled = disable; |
||
352 | } |
||
353 | |||
354 | function updateInputBoxes() |
||
355 | { |
||
356 | curType = document.getElementById("field_type").value; |
||
357 | privStatus = document.getElementById("private").value; |
||
358 | document.getElementById("max_length_dt").style.display = curType == "text" || curType == "textarea" ? "" : "none"; |
||
359 | document.getElementById("max_length_dd").style.display = curType == "text" || curType == "textarea" ? "" : "none"; |
||
360 | document.getElementById("dimension_dt").style.display = curType == "textarea" ? "" : "none"; |
||
361 | document.getElementById("dimension_dd").style.display = curType == "textarea" ? "" : "none"; |
||
362 | document.getElementById("bbc_dt").style.display = curType == "text" || curType == "textarea" ? "" : "none"; |
||
363 | document.getElementById("bbc_dd").style.display = curType == "text" || curType == "textarea" ? "" : "none"; |
||
364 | document.getElementById("options_dt").style.display = curType == "select" || curType == "radio" ? "" : "none"; |
||
365 | document.getElementById("options_dd").style.display = curType == "select" || curType == "radio" ? "" : "none"; |
||
366 | document.getElementById("default_dt").style.display = curType == "check" ? "" : "none"; |
||
367 | document.getElementById("default_dd").style.display = curType == "check" ? "" : "none"; |
||
368 | document.getElementById("mask_dt").style.display = curType == "text" ? "" : "none"; |
||
369 | document.getElementById("mask").style.display = curType == "text" ? "" : "none"; |
||
370 | document.getElementById("can_search_dt").style.display = curType == "text" || curType == "textarea" || curType == "select" ? "" : "none"; |
||
371 | document.getElementById("can_search_dd").style.display = curType == "text" || curType == "textarea" || curType == "select" ? "" : "none"; |
||
372 | document.getElementById("regex_div").style.display = curType == "text" && document.getElementById("mask").value == "regex" ? "" : "none"; |
||
373 | document.getElementById("display").disabled = false; |
||
374 | // Cannot show this on the topic |
||
375 | if (curType == "textarea" || privStatus >= 2) |
||
376 | { |
||
377 | document.getElementById("display").checked = false; |
||
378 | document.getElementById("display").disabled = true; |
||
379 | } |
||
380 | } |
||
381 | |||
382 | function addOption() |
||
383 | { |
||
384 | setOuterHTML(document.getElementById("addopt"), '<br><input type="radio" name="default_select" value="' + startOptID + '" id="' + startOptID + '"><input type="text" name="select_option[' + startOptID + ']" value=""><span id="addopt"></span>'); |
||
385 | startOptID++; |
||
386 | } |
||
387 | |||
388 | |||
389 | //Create a named element dynamically - thanks to: https://www.thunderguy.com/semicolon/2005/05/23/setting-the-name-attribute-in-internet-explorer/ |
||
390 | function createNamedElement(type, name, customFields) |
||
391 | { |
||
392 | var element = null; |
||
393 | |||
394 | if (!customFields) |
||
395 | customFields = ""; |
||
396 | |||
397 | // Try the IE way; this fails on standards-compliant browsers |
||
398 | try |
||
399 | { |
||
400 | element = document.createElement("<" + type + ' name="' + name + '" ' + customFields + ">"); |
||
401 | } |
||
402 | catch (e) |
||
403 | { |
||
404 | } |
||
405 | if (!element || element.nodeName != type.toUpperCase()) |
||
406 | { |
||
407 | // Non-IE browser; use canonical method to create named element |
||
408 | element = document.createElement(type); |
||
409 | element.name = name; |
||
410 | } |
||
411 | |||
412 | return element; |
||
413 | } |
||
414 | |||
415 | function smfSetLatestThemes() |
||
416 | { |
||
417 | if (typeof(window.smfLatestThemes) != "undefined") |
||
418 | setInnerHTML(document.getElementById("themeLatest"), window.smfLatestThemes); |
||
419 | |||
420 | if (tempOldOnload) |
||
421 | tempOldOnload(); |
||
422 | } |
||
423 | |||
424 | function changeVariant(sVariant) |
||
425 | { |
||
426 | document.getElementById('variant_preview').src = oThumbnails[sVariant]; |
||
427 | } |
||
428 | |||
429 | // The idea here is simple: don't refresh the preview on every keypress, but do refresh after they type. |
||
430 | function setPreviewTimeout() |
||
431 | { |
||
432 | if (previewTimeout) |
||
433 | { |
||
434 | window.clearTimeout(previewTimeout); |
||
435 | previewTimeout = null; |
||
436 | } |
||
437 | |||
438 | previewTimeout = window.setTimeout("refreshPreview(true); previewTimeout = null;", 500); |
||
439 | } |
||
440 | |||
441 | function toggleDuration(toChange) |
||
442 | { |
||
443 | if (toChange == 'fixed') |
||
444 | { |
||
445 | document.getElementById("fixed_area").style.display = "inline"; |
||
446 | document.getElementById("flexible_area").style.display = "none"; |
||
447 | } |
||
448 | else |
||
449 | { |
||
450 | document.getElementById("fixed_area").style.display = "none"; |
||
451 | document.getElementById("flexible_area").style.display = "inline"; |
||
452 | } |
||
453 | } |
||
454 | |||
455 | function calculateNewValues() |
||
456 | { |
||
457 | var total = 0; |
||
458 | for (var i = 1; i <= 6; i++) |
||
459 | { |
||
460 | total += parseInt(document.getElementById('weight' + i + '_val').value); |
||
461 | } |
||
462 | setInnerHTML(document.getElementById('weighttotal'), total); |
||
463 | for (var i = 1; i <= 6; i++) |
||
464 | { |
||
465 | setInnerHTML(document.getElementById('weight' + i), (Math.round(1000 * parseInt(document.getElementById('weight' + i + '_val').value) / total) / 10) + '%'); |
||
466 | } |
||
467 | } |
||
468 | |||
469 | function switchType() |
||
470 | { |
||
471 | document.getElementById("ul_settings").style.display = document.getElementById("method-existing").checked ? "none" : ""; |
||
472 | document.getElementById("ex_settings").style.display = document.getElementById("method-upload").checked ? "none" : ""; |
||
473 | } |
||
474 | |||
475 | function swapUploads() |
||
476 | { |
||
477 | document.getElementById("uploadMore").style.display = document.getElementById("uploadSmiley").disabled ? "none" : ""; |
||
478 | document.getElementById("uploadSmiley").disabled = !document.getElementById("uploadSmiley").disabled; |
||
479 | } |
||
480 | |||
481 | function selectMethod(element) |
||
482 | { |
||
483 | document.getElementById("method-existing").checked = element != "upload"; |
||
484 | document.getElementById("method-upload").checked = element == "upload"; |
||
485 | } |
||
486 | |||
487 | function updatePreview() |
||
488 | { |
||
489 | var currentImage = document.getElementById("preview"); |
||
490 | currentImage.src = smf_smileys_url + "/" + document.forms.smileyForm.set.value + "/" + document.forms.smileyForm.smiley_filename.value; |
||
491 | } |
||
492 | |||
493 | function swap_database_changes() |
||
494 | { |
||
495 | db_vis = !db_vis; |
||
496 | database_changes_area.style.display = db_vis ? "" : "none"; |
||
497 | return false; |
||
498 | } |
||
499 | |||
500 | function testFTP() |
||
501 | { |
||
502 | ajax_indicator(true); |
||
503 | |||
504 | // What we need to post. |
||
505 | var oPostData = { |
||
506 | 0: "ftp_server", |
||
507 | 1: "ftp_port", |
||
508 | 2: "ftp_username", |
||
509 | 3: "ftp_password", |
||
510 | 4: "ftp_path" |
||
511 | } |
||
512 | |||
513 | var sPostData = ""; |
||
514 | for (i = 0; i < 5; i++) |
||
515 | sPostData = sPostData + (sPostData.length == 0 ? "" : "&") + oPostData[i] + "=" + escape(document.getElementById(oPostData[i]).value); |
||
516 | |||
517 | // Post the data out. |
||
518 | sendXMLDocument(smf_prepareScriptUrl(smf_scripturl) + 'action=admin;area=packages;sa=ftptest;xml;' + smf_session_var + '=' + smf_session_id, sPostData, testFTPResults); |
||
519 | } |
||
520 | |||
521 | function expandFolder(folderIdent, folderReal) |
||
522 | { |
||
523 | // See if it already exists. |
||
524 | var possibleTags = document.getElementsByTagName("tr"); |
||
525 | var foundOne = false; |
||
526 | |||
527 | for (var i = 0; i < possibleTags.length; i++) |
||
528 | { |
||
529 | if (possibleTags[i].id.indexOf("content_" + folderIdent + ":-:") == 0) |
||
530 | { |
||
531 | possibleTags[i].style.display = possibleTags[i].style.display == "none" ? "" : "none"; |
||
532 | foundOne = true; |
||
533 | } |
||
534 | } |
||
535 | |||
536 | // Got something then we're done. |
||
537 | if (foundOne) |
||
538 | { |
||
539 | return false; |
||
540 | } |
||
541 | // Otherwise we need to get the wicked thing. |
||
542 | else if (window.XMLHttpRequest) |
||
543 | { |
||
544 | ajax_indicator(true); |
||
545 | getXMLDocument(smf_prepareScriptUrl(smf_scripturl) + 'action=admin;area=packages;onlyfind=' + escape(folderReal) + ';sa=perms;xml;' + smf_session_var + '=' + smf_session_id, onNewFolderReceived); |
||
546 | } |
||
547 | // Otherwise reload. |
||
548 | else |
||
549 | return true; |
||
550 | |||
551 | return false; |
||
552 | } |
||
553 | |||
554 | function dynamicExpandFolder() |
||
555 | { |
||
556 | expandFolder(this.ident, this.path); |
||
557 | |||
558 | return false; |
||
559 | } |
||
560 | |||
561 | function repeatString(sString, iTime) |
||
562 | { |
||
563 | if (iTime < 1) |
||
564 | return ''; |
||
565 | else |
||
566 | return sString + repeatString(sString, iTime - 1); |
||
567 | } |
||
568 | |||
569 | function select_in_category(cat_id, elem, brd_list) |
||
570 | { |
||
571 | for (var brd in brd_list) |
||
572 | document.getElementById(elem.value + '_brd' + brd_list[brd]).checked = true; |
||
573 | |||
574 | elem.selectedIndex = 0; |
||
575 | } |
||
576 | |||
577 | /* |
||
578 | * Attachments Settings |
||
579 | */ |
||
580 | function toggleSubDir () |
||
581 | { |
||
582 | var auto_attach = document.getElementById('automanage_attachments'); |
||
583 | var use_sub_dir = document.getElementById('use_subdirectories_for_attachments'); |
||
584 | var dir_elem = document.getElementById('basedirectory_for_attachments'); |
||
585 | |||
586 | use_sub_dir.disabled = !Boolean(auto_attach.selectedIndex); |
||
587 | if (use_sub_dir.disabled) |
||
588 | { |
||
589 | use_sub_dir.style.display = "none"; |
||
590 | document.getElementById('setting_use_subdirectories_for_attachments').parentNode.style.display = "none"; |
||
591 | dir_elem.style.display = "none"; |
||
592 | document.getElementById('setting_basedirectory_for_attachments').parentNode.style.display = "none"; |
||
593 | } |
||
594 | else |
||
595 | { |
||
596 | use_sub_dir.style.display = ""; |
||
597 | document.getElementById('setting_use_subdirectories_for_attachments').parentNode.style.display = ""; |
||
598 | dir_elem.style.display = ""; |
||
599 | document.getElementById('setting_basedirectory_for_attachments').parentNode.style.display = ""; |
||
600 | } |
||
601 | toggleBaseDir(); |
||
602 | } |
||
603 | function toggleBaseDir () |
||
604 | { |
||
605 | var auto_attach = document.getElementById('automanage_attachments'); |
||
606 | var sub_dir = document.getElementById('use_subdirectories_for_attachments'); |
||
607 | var dir_elem = document.getElementById('basedirectory_for_attachments'); |
||
608 | |||
609 | if (auto_attach.selectedIndex == 0) |
||
610 | { |
||
611 | dir_elem.disabled = 1; |
||
612 | } |
||
613 | else |
||
614 | dir_elem.disabled = !sub_dir.checked; |
||
615 | } |