admin.js 22 KB

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