admin.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  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. oContainer.className = ('smfUpdateCritical' in window) ? 'errorbox' : 'noticebox';
  77. }
  78. function smf_ViewVersions (oOptions)
  79. {
  80. this.opt = oOptions;
  81. this.oSwaps = {};
  82. this.init();
  83. }
  84. smf_ViewVersions.prototype.init = function ()
  85. {
  86. // Load this on loading of the page.
  87. window.viewVersionsInstanceRef = this;
  88. var fHandlePageLoaded = function () {
  89. window.viewVersionsInstanceRef.loadViewVersions();
  90. }
  91. addLoadEvent(fHandlePageLoaded);
  92. }
  93. smf_ViewVersions.prototype.loadViewVersions = function ()
  94. {
  95. this.determineVersions();
  96. }
  97. smf_ViewVersions.prototype.swapOption = function (oSendingElement, sName)
  98. {
  99. // If it is undefined, or currently off, turn it on - otherwise off.
  100. this.oSwaps[sName] = !(sName in this.oSwaps) || !this.oSwaps[sName];
  101. if (this.oSwaps[sName])
  102. $("#" + sName).show(300);
  103. else
  104. $("#" + sName).hide(300);
  105. // Unselect the link and return false.
  106. oSendingElement.blur();
  107. return false;
  108. }
  109. smf_ViewVersions.prototype.compareVersions = function (sCurrent, sTarget)
  110. {
  111. var aVersions = aParts = new Array();
  112. var aCompare = new Array(sCurrent, sTarget);
  113. for (var i = 0; i < 2; i++)
  114. {
  115. // Clean the version and extract the version parts.
  116. var sClean = aCompare[i].toLowerCase().replace(/ /g, '').replace(/2.0rc1-1/, '2.0rc1.1');
  117. aParts = sClean.match(/(\d+)(?:\.(\d+|))?(?:\.)?(\d+|)(?:(alpha|beta|rc)(\d+|)(?:\.)?(\d+|))?(?:(dev))?(\d+|)/);
  118. // No matches?
  119. if (aParts == null)
  120. return false;
  121. // Build an array of parts.
  122. aVersions[i] = [
  123. aParts[1] > 0 ? parseInt(aParts[1]) : 0,
  124. aParts[2] > 0 ? parseInt(aParts[2]) : 0,
  125. aParts[3] > 0 ? parseInt(aParts[3]) : 0,
  126. typeof(aParts[4]) == 'undefined' ? 'stable' : aParts[4],
  127. aParts[5] > 0 ? parseInt(aParts[5]) : 0,
  128. aParts[6] > 0 ? parseInt(aParts[6]) : 0,
  129. typeof(aParts[7]) != 'undefined',
  130. ];
  131. }
  132. // Loop through each category.
  133. for (i = 0; i < 7; i++)
  134. {
  135. // Is there something for us to calculate?
  136. if (aVersions[0][i] != aVersions[1][i])
  137. {
  138. // Dev builds are a problematic exception.
  139. // (stable) dev < (stable) but (unstable) dev = (unstable)
  140. if (i == 3)
  141. return aVersions[0][i] < aVersions[1][i] ? !aVersions[1][6] : aVersions[0][6];
  142. else if (i == 6)
  143. return aVersions[0][6] ? aVersions[1][3] == 'stable' : false;
  144. // Otherwise a simple comparison.
  145. else
  146. return aVersions[0][i] < aVersions[1][i];
  147. }
  148. }
  149. // They are the same!
  150. return false;
  151. }
  152. smf_ViewVersions.prototype.determineVersions = function ()
  153. {
  154. var oHighYour = {
  155. Sources: '??',
  156. Default: '??',
  157. Languages: '??',
  158. Templates: '??'
  159. };
  160. var oHighCurrent = {
  161. Sources: '??',
  162. Default: '??',
  163. Languages: '??',
  164. Templates: '??'
  165. };
  166. var oLowVersion = {
  167. Sources: false,
  168. Default: false,
  169. Languages: false,
  170. Templates: false
  171. };
  172. var sSections = [
  173. 'Sources',
  174. 'Default',
  175. 'Languages',
  176. 'Templates'
  177. ];
  178. for (var i = 0, n = sSections.length; i < n; i++)
  179. {
  180. // Collapse all sections.
  181. var oSection = document.getElementById(sSections[i]);
  182. if (typeof(oSection) == 'object' && oSection != null)
  183. oSection.style.display = 'none';
  184. // Make all section links clickable.
  185. var oSectionLink = document.getElementById(sSections[i] + '-link');
  186. if (typeof(oSectionLink) == 'object' && oSectionLink != null)
  187. {
  188. oSectionLink.instanceRef = this;
  189. oSectionLink.sSection = sSections[i];
  190. oSectionLink.onclick = function () {
  191. this.instanceRef.swapOption(this, this.sSection);
  192. return false;
  193. };
  194. }
  195. }
  196. if (!('smfVersions' in window))
  197. window.smfVersions = {};
  198. for (var sFilename in window.smfVersions)
  199. {
  200. if (!document.getElementById('current' + sFilename))
  201. continue;
  202. var sYourVersion = getInnerHTML(document.getElementById('your' + sFilename));
  203. var sCurVersionType;
  204. for (var sVersionType in oLowVersion)
  205. if (sFilename.substr(0, sVersionType.length) == sVersionType)
  206. {
  207. sCurVersionType = sVersionType;
  208. break;
  209. }
  210. if (typeof(sCurVersionType) != 'undefined')
  211. {
  212. if ((this.compareVersions(oHighYour[sCurVersionType], sYourVersion) || oHighYour[sCurVersionType] == '??') && !oLowVersion[sCurVersionType])
  213. oHighYour[sCurVersionType] = sYourVersion;
  214. if (this.compareVersions(oHighCurrent[sCurVersionType], smfVersions[sFilename]) || oHighCurrent[sCurVersionType] == '??')
  215. oHighCurrent[sCurVersionType] = smfVersions[sFilename];
  216. if (this.compareVersions(sYourVersion, smfVersions[sFilename]))
  217. {
  218. oLowVersion[sCurVersionType] = sYourVersion;
  219. document.getElementById('your' + sFilename).style.color = 'red';
  220. }
  221. }
  222. else if (this.compareVersions(sYourVersion, smfVersions[sFilename]))
  223. oLowVersion[sCurVersionType] = sYourVersion;
  224. setInnerHTML(document.getElementById('current' + sFilename), smfVersions[sFilename]);
  225. setInnerHTML(document.getElementById('your' + sFilename), sYourVersion);
  226. }
  227. if (!('smfLanguageVersions' in window))
  228. window.smfLanguageVersions = {};
  229. for (sFilename in window.smfLanguageVersions)
  230. {
  231. for (var i = 0; i < this.opt.aKnownLanguages.length; i++)
  232. {
  233. if (!document.getElementById('current' + sFilename + this.opt.aKnownLanguages[i]))
  234. continue;
  235. setInnerHTML(document.getElementById('current' + sFilename + this.opt.aKnownLanguages[i]), smfLanguageVersions[sFilename]);
  236. sYourVersion = getInnerHTML(document.getElementById('your' + sFilename + this.opt.aKnownLanguages[i]));
  237. setInnerHTML(document.getElementById('your' + sFilename + this.opt.aKnownLanguages[i]), sYourVersion);
  238. if ((this.compareVersions(oHighYour.Languages, sYourVersion) || oHighYour.Languages == '??') && !oLowVersion.Languages)
  239. oHighYour.Languages = sYourVersion;
  240. if (this.compareVersions(oHighCurrent.Languages, smfLanguageVersions[sFilename]) || oHighCurrent.Languages == '??')
  241. oHighCurrent.Languages = smfLanguageVersions[sFilename];
  242. if (this.compareVersions(sYourVersion, smfLanguageVersions[sFilename]))
  243. {
  244. oLowVersion.Languages = sYourVersion;
  245. document.getElementById('your' + sFilename + this.opt.aKnownLanguages[i]).style.color = 'red';
  246. }
  247. }
  248. }
  249. setInnerHTML(document.getElementById('yourSources'), oLowVersion.Sources ? oLowVersion.Sources : oHighYour.Sources);
  250. setInnerHTML(document.getElementById('currentSources'), oHighCurrent.Sources);
  251. if (oLowVersion.Sources)
  252. document.getElementById('yourSources').style.color = 'red';
  253. setInnerHTML(document.getElementById('yourDefault'), oLowVersion.Default ? oLowVersion.Default : oHighYour.Default);
  254. setInnerHTML(document.getElementById('currentDefault'), oHighCurrent.Default);
  255. if (oLowVersion.Default)
  256. document.getElementById('yourDefault').style.color = 'red';
  257. if (document.getElementById('Templates'))
  258. {
  259. setInnerHTML(document.getElementById('yourTemplates'), oLowVersion.Templates ? oLowVersion.Templates : oHighYour.Templates);
  260. setInnerHTML(document.getElementById('currentTemplates'), oHighCurrent.Templates);
  261. if (oLowVersion.Templates)
  262. document.getElementById('yourTemplates').style.color = 'red';
  263. }
  264. setInnerHTML(document.getElementById('yourLanguages'), oLowVersion.Languages ? oLowVersion.Languages : oHighYour.Languages);
  265. setInnerHTML(document.getElementById('currentLanguages'), oHighCurrent.Languages);
  266. if (oLowVersion.Languages)
  267. document.getElementById('yourLanguages').style.color = 'red';
  268. }
  269. function addNewWord()
  270. {
  271. 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>');
  272. }
  273. function toggleBBCDisabled(section, disable)
  274. {
  275. elems = document.getElementById(section).getElementsByTagName('*');
  276. for (var i = 0; i < elems.length; i++)
  277. {
  278. 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))
  279. continue;
  280. elems[i].disabled = disable;
  281. }
  282. document.getElementById("bbc_" + section + "_select_all").disabled = disable;
  283. }
  284. function updateInputBoxes()
  285. {
  286. curType = document.getElementById("field_type").value;
  287. privStatus = document.getElementById("private").value;
  288. document.getElementById("max_length_dt").style.display = curType == "text" || curType == "textarea" ? "" : "none";
  289. document.getElementById("max_length_dd").style.display = curType == "text" || curType == "textarea" ? "" : "none";
  290. document.getElementById("dimension_dt").style.display = curType == "textarea" ? "" : "none";
  291. document.getElementById("dimension_dd").style.display = curType == "textarea" ? "" : "none";
  292. document.getElementById("bbc_dt").style.display = curType == "text" || curType == "textarea" ? "" : "none";
  293. document.getElementById("bbc_dd").style.display = curType == "text" || curType == "textarea" ? "" : "none";
  294. document.getElementById("options_dt").style.display = curType == "select" || curType == "radio" ? "" : "none";
  295. document.getElementById("options_dd").style.display = curType == "select" || curType == "radio" ? "" : "none";
  296. document.getElementById("default_dt").style.display = curType == "check" ? "" : "none";
  297. document.getElementById("default_dd").style.display = curType == "check" ? "" : "none";
  298. document.getElementById("mask_dt").style.display = curType == "text" ? "" : "none";
  299. document.getElementById("mask").style.display = curType == "text" ? "" : "none";
  300. document.getElementById("can_search_dt").style.display = curType == "text" || curType == "textarea" ? "" : "none";
  301. document.getElementById("can_search_dd").style.display = curType == "text" || curType == "textarea" ? "" : "none";
  302. document.getElementById("regex_div").style.display = curType == "text" && document.getElementById("mask").value == "regex" ? "" : "none";
  303. document.getElementById("display").disabled = false;
  304. // Cannot show this on the topic
  305. if (curType == "textarea" || privStatus >= 2)
  306. {
  307. document.getElementById("display").checked = false;
  308. document.getElementById("display").disabled = true;
  309. }
  310. }
  311. function addOption()
  312. {
  313. 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>');
  314. startOptID++;
  315. }
  316. //Create a named element dynamically - thanks to: http://www.thunderguy.com/semicolon/2005/05/23/setting-the-name-attribute-in-internet-explorer/
  317. function createNamedElement(type, name, customFields)
  318. {
  319. var element = null;
  320. if (!customFields)
  321. customFields = "";
  322. // Try the IE way; this fails on standards-compliant browsers
  323. try
  324. {
  325. element = document.createElement("<" + type + ' name="' + name + '" ' + customFields + ">");
  326. }
  327. catch (e)
  328. {
  329. }
  330. if (!element || element.nodeName != type.toUpperCase())
  331. {
  332. // Non-IE browser; use canonical method to create named element
  333. element = document.createElement(type);
  334. element.name = name;
  335. }
  336. return element;
  337. }
  338. function smfSetLatestThemes()
  339. {
  340. if (typeof(window.smfLatestThemes) != "undefined")
  341. setInnerHTML(document.getElementById("themeLatest"), window.smfLatestThemes);
  342. if (tempOldOnload)
  343. tempOldOnload();
  344. }
  345. function changeVariant(sVariant)
  346. {
  347. document.getElementById('variant_preview').src = oThumbnails[sVariant];
  348. }
  349. // The idea here is simple: don't refresh the preview on every keypress, but do refresh after they type.
  350. function setPreviewTimeout()
  351. {
  352. if (previewTimeout)
  353. {
  354. window.clearTimeout(previewTimeout);
  355. previewTimeout = null;
  356. }
  357. previewTimeout = window.setTimeout("refreshPreview(true); previewTimeout = null;", 500);
  358. }
  359. function toggleDuration(toChange)
  360. {
  361. if (toChange == 'fixed')
  362. {
  363. document.getElementById("fixed_area").style.display = "inline";
  364. document.getElementById("flexible_area").style.display = "none";
  365. }
  366. else
  367. {
  368. document.getElementById("fixed_area").style.display = "none";
  369. document.getElementById("flexible_area").style.display = "inline";
  370. }
  371. }
  372. function calculateNewValues()
  373. {
  374. var total = 0;
  375. for (var i = 1; i <= 6; i++)
  376. {
  377. total += parseInt(document.getElementById('weight' + i + '_val').value);
  378. }
  379. setInnerHTML(document.getElementById('weighttotal'), total);
  380. for (var i = 1; i <= 6; i++)
  381. {
  382. setInnerHTML(document.getElementById('weight' + i), (Math.round(1000 * parseInt(document.getElementById('weight' + i + '_val').value) / total) / 10) + '%');
  383. }
  384. }
  385. function switchType()
  386. {
  387. document.getElementById("ul_settings").style.display = document.getElementById("method-existing").checked ? "none" : "";
  388. document.getElementById("ex_settings").style.display = document.getElementById("method-upload").checked ? "none" : "";
  389. }
  390. function swapUploads()
  391. {
  392. document.getElementById("uploadMore").style.display = document.getElementById("uploadSmiley").disabled ? "none" : "";
  393. document.getElementById("uploadSmiley").disabled = !document.getElementById("uploadSmiley").disabled;
  394. }
  395. function selectMethod(element)
  396. {
  397. document.getElementById("method-existing").checked = element != "upload";
  398. document.getElementById("method-upload").checked = element == "upload";
  399. }
  400. function updatePreview()
  401. {
  402. var currentImage = document.getElementById("preview");
  403. currentImage.src = smf_images_url + "/" + document.forms.smileyForm.set.value + "/" + document.forms.smileyForm.smiley_filename.value;
  404. }
  405. function swap_database_changes()
  406. {
  407. db_vis = !db_vis;
  408. database_changes_area.style.display = db_vis ? "" : "none";
  409. return false;
  410. }
  411. function testFTP()
  412. {
  413. ajax_indicator(true);
  414. // What we need to post.
  415. var oPostData = {
  416. 0: "ftp_server",
  417. 1: "ftp_port",
  418. 2: "ftp_username",
  419. 3: "ftp_password",
  420. 4: "ftp_path"
  421. }
  422. var sPostData = "";
  423. for (i = 0; i < 5; i++)
  424. sPostData = sPostData + (sPostData.length == 0 ? "" : "&") + oPostData[i] + "=" + escape(document.getElementById(oPostData[i]).value);
  425. // Post the data out.
  426. sendXMLDocument(smf_prepareScriptUrl(smf_scripturl) + 'action=admin;area=packages;sa=ftptest;xml;' + smf_session_var + '=' + smf_session_id, sPostData, testFTPResults);
  427. }
  428. function expandFolder(folderIdent, folderReal)
  429. {
  430. // See if it already exists.
  431. var possibleTags = document.getElementsByTagName("tr");
  432. var foundOne = false;
  433. for (var i = 0; i < possibleTags.length; i++)
  434. {
  435. if (possibleTags[i].id.indexOf("content_" + folderIdent + ":-:") == 0)
  436. {
  437. possibleTags[i].style.display = possibleTags[i].style.display == "none" ? "" : "none";
  438. foundOne = true;
  439. }
  440. }
  441. // Got something then we're done.
  442. if (foundOne)
  443. {
  444. return false;
  445. }
  446. // Otherwise we need to get the wicked thing.
  447. else if (window.XMLHttpRequest)
  448. {
  449. ajax_indicator(true);
  450. getXMLDocument(smf_prepareScriptUrl(smf_scripturl) + 'action=admin;area=packages;onlyfind=' + escape(folderReal) + ';sa=perms;xml;' + smf_session_var + '=' + smf_session_id, onNewFolderReceived);
  451. }
  452. // Otherwise reload.
  453. else
  454. return true;
  455. return false;
  456. }
  457. function dynamicExpandFolder()
  458. {
  459. expandFolder(this.ident, this.path);
  460. return false;
  461. }
  462. function repeatString(sString, iTime)
  463. {
  464. if (iTime < 1)
  465. return '';
  466. else
  467. return sString + repeatString(sString, iTime - 1);
  468. }
  469. function select_in_category(cat_id, elem, brd_list)
  470. {
  471. for (var brd in brd_list)
  472. document.getElementById(elem.value + '_brd' + brd_list[brd]).checked = true;
  473. elem.selectedIndex = 0;
  474. }
  475. /*
  476. * Server Settings > Caching
  477. */
  478. function toggleCache ()
  479. {
  480. var memcache = document.getElementById('cache_memcached');
  481. var cachedir = document.getElementById('cachedir');
  482. memcache.disabled = cache_type.value != "memcached";
  483. cachedir.disabled = cache_type.value != "smf";
  484. }
  485. /*
  486. * Attachments Settings
  487. */
  488. function toggleSubDir ()
  489. {
  490. var auto_attach = document.getElementById('automanage_attachments');
  491. var use_sub_dir = document.getElementById('use_subdirectories_for_attachments');
  492. var dir_elem = document.getElementById('basedirectory_for_attachments');
  493. use_sub_dir.disabled = !Boolean(auto_attach.selectedIndex);
  494. if (use_sub_dir.disabled)
  495. {
  496. use_sub_dir.style.display = "none";
  497. document.getElementById('setting_use_subdirectories_for_attachments').parentNode.style.display = "none";
  498. dir_elem.style.display = "none";
  499. document.getElementById('setting_basedirectory_for_attachments').parentNode.style.display = "none";
  500. }
  501. else
  502. {
  503. use_sub_dir.style.display = "";
  504. document.getElementById('setting_use_subdirectories_for_attachments').parentNode.style.display = "";
  505. dir_elem.style.display = "";
  506. document.getElementById('setting_basedirectory_for_attachments').parentNode.style.display = "";
  507. }
  508. toggleBaseDir();
  509. }
  510. function toggleBaseDir ()
  511. {
  512. var auto_attach = document.getElementById('automanage_attachments');
  513. var sub_dir = document.getElementById('use_subdirectories_for_attachments');
  514. var dir_elem = document.getElementById('basedirectory_for_attachments');
  515. if (auto_attach.selectedIndex == 0)
  516. {
  517. dir_elem.disabled = 1;
  518. }
  519. else
  520. dir_elem.disabled = !sub_dir.checked;
  521. }