script.js 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677
  1. var smf_formSubmitted = false;
  2. var lastKeepAliveCheck = new Date().getTime();
  3. var smf_editorArray = new Array();
  4. // Some very basic browser detection - from Mozilla's sniffer page.
  5. var ua = navigator.userAgent.toLowerCase();
  6. var is_opera = ua.indexOf('opera') != -1;
  7. var is_opera5 = ua.indexOf('opera/5') != -1 || ua.indexOf('opera 5') != -1;
  8. var is_opera6 = ua.indexOf('opera/6') != -1 || ua.indexOf('opera 6') != -1;
  9. var is_opera7 = ua.indexOf('opera/7') != -1 || ua.indexOf('opera 7') != -1;
  10. var is_opera8 = ua.indexOf('opera/8') != -1 || ua.indexOf('opera 8') != -1;
  11. var is_opera9 = ua.indexOf('opera/9') != -1 || ua.indexOf('opera 9') != -1;
  12. var is_opera95 = ua.indexOf('opera/9.5') != -1 || ua.indexOf('opera 9.5') != -1;
  13. var is_opera96 = ua.indexOf('opera/9.6') != -1 || ua.indexOf('opera 9.6') != -1;
  14. var is_opera10 = (ua.indexOf('opera/9.8') != -1 || ua.indexOf('opera 9.8') != -1 || ua.indexOf('opera/10.') != -1 || ua.indexOf('opera 10.') != -1) || ua.indexOf('version/10.') != -1;
  15. var is_opera95up = is_opera95 || is_opera96 || is_opera10;
  16. var is_ff = (ua.indexOf('firefox') != -1 || ua.indexOf('iceweasel') != -1 || ua.indexOf('icecat') != -1 || ua.indexOf('shiretoko') != -1 || ua.indexOf('minefield') != -1) && !is_opera;
  17. var is_gecko = ua.indexOf('gecko') != -1 && !is_opera;
  18. var is_chrome = ua.indexOf('chrome') != -1;
  19. var is_safari = ua.indexOf('applewebkit') != -1 && !is_chrome;
  20. var is_webkit = ua.indexOf('applewebkit') != -1;
  21. var is_ie = ua.indexOf('msie') != -1 && !is_opera;
  22. var is_ie4 = is_ie && ua.indexOf('msie 4') != -1;
  23. var is_ie5 = is_ie && ua.indexOf('msie 5') != -1;
  24. var is_ie50 = is_ie && ua.indexOf('msie 5.0') != -1;
  25. var is_ie55 = is_ie && ua.indexOf('msie 5.5') != -1;
  26. var is_ie5up = is_ie && !is_ie4;
  27. var is_ie6 = is_ie && ua.indexOf('msie 6') != -1;
  28. var is_ie6up = is_ie5up && !is_ie55 && !is_ie5;
  29. var is_ie6down = is_ie6 || is_ie5 || is_ie4;
  30. var is_ie7 = is_ie && ua.indexOf('msie 7') != -1;
  31. var is_ie7up = is_ie6up && !is_ie6;
  32. var is_ie7down = is_ie7 || is_ie6 || is_ie5 || is_ie4;
  33. var is_ie8 = is_ie && ua.indexOf('msie 8') != -1;
  34. var is_ie8up = is_ie8 && !is_ie7down;
  35. var is_iphone = ua.indexOf('iphone') != -1 || ua.indexOf('ipod') != -1;
  36. var is_android = ua.indexOf('android') != -1;
  37. var ajax_indicator_ele = null;
  38. // Define document.getElementById for Internet Explorer 4.
  39. if (!('getElementById' in document) && 'all' in document)
  40. document.getElementById = function (sId) {
  41. return document.all[sId];
  42. }
  43. // Define XMLHttpRequest for IE 5 and above. (don't bother for IE 4 :/.... works in Opera 7.6 and Safari 1.2!)
  44. else if (!('XMLHttpRequest' in window) && 'ActiveXObject' in window)
  45. window.XMLHttpRequest = function () {
  46. return new ActiveXObject(is_ie5 ? 'Microsoft.XMLHTTP' : 'MSXML2.XMLHTTP');
  47. };
  48. // Ensure the getElementsByTagName exists.
  49. if (!'getElementsByTagName' in document && 'all' in document)
  50. document.getElementsByTagName = function (sName) {
  51. return document.all.tags[sName];
  52. }
  53. // Some older versions of Mozilla don't have this, for some reason.
  54. if (!('forms' in document))
  55. document.forms = document.getElementsByTagName('form');
  56. // Load an XML document using XMLHttpRequest.
  57. function getXMLDocument(sUrl, funcCallback)
  58. {
  59. if (!window.XMLHttpRequest)
  60. return null;
  61. var oMyDoc = new XMLHttpRequest();
  62. var bAsync = typeof(funcCallback) != 'undefined';
  63. var oCaller = this;
  64. if (bAsync)
  65. {
  66. oMyDoc.onreadystatechange = function () {
  67. if (oMyDoc.readyState != 4)
  68. return;
  69. if (oMyDoc.responseXML != null && oMyDoc.status == 200)
  70. {
  71. if (funcCallback.call)
  72. {
  73. funcCallback.call(oCaller, oMyDoc.responseXML);
  74. }
  75. // A primitive substitute for the call method to support IE 5.0.
  76. else
  77. {
  78. oCaller.tmpMethod = funcCallback;
  79. oCaller.tmpMethod(oMyDoc.responseXML);
  80. delete oCaller.tmpMethod;
  81. }
  82. }
  83. };
  84. }
  85. oMyDoc.open('GET', sUrl, bAsync);
  86. oMyDoc.send(null);
  87. return oMyDoc;
  88. }
  89. // Send a post form to the server using XMLHttpRequest.
  90. function sendXMLDocument(sUrl, sContent, funcCallback)
  91. {
  92. if (!window.XMLHttpRequest)
  93. return false;
  94. var oSendDoc = new window.XMLHttpRequest();
  95. var oCaller = this;
  96. if (typeof(funcCallback) != 'undefined')
  97. {
  98. oSendDoc.onreadystatechange = function () {
  99. if (oSendDoc.readyState != 4)
  100. return;
  101. if (oSendDoc.responseXML != null && oSendDoc.status == 200)
  102. funcCallback.call(oCaller, oSendDoc.responseXML);
  103. else
  104. funcCallback.call(oCaller, false);
  105. };
  106. }
  107. oSendDoc.open('POST', sUrl, true);
  108. if ('setRequestHeader' in oSendDoc)
  109. oSendDoc.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  110. oSendDoc.send(sContent);
  111. return true;
  112. }
  113. // A property we'll be needing for php_to8bit.
  114. String.prototype.oCharsetConversion = {
  115. from: '',
  116. to: ''
  117. };
  118. // Convert a string to an 8 bit representation (like in PHP).
  119. String.prototype.php_to8bit = function ()
  120. {
  121. if (smf_charset == 'UTF-8')
  122. {
  123. var n, sReturn = '';
  124. for (var i = 0, iTextLen = this.length; i < iTextLen; i++)
  125. {
  126. n = this.charCodeAt(i);
  127. if (n < 128)
  128. sReturn += String.fromCharCode(n)
  129. else if (n < 2048)
  130. sReturn += String.fromCharCode(192 | n >> 6) + String.fromCharCode(128 | n & 63);
  131. else if (n < 65536)
  132. sReturn += String.fromCharCode(224 | n >> 12) + String.fromCharCode(128 | n >> 6 & 63) + String.fromCharCode(128 | n & 63);
  133. else
  134. sReturn += String.fromCharCode(240 | n >> 18) + String.fromCharCode(128 | n >> 12 & 63) + String.fromCharCode(128 | n >> 6 & 63) + String.fromCharCode(128 | n & 63);
  135. }
  136. return sReturn;
  137. }
  138. else if (this.oCharsetConversion.from.length == 0)
  139. {
  140. switch (smf_charset)
  141. {
  142. case 'ISO-8859-1':
  143. this.oCharsetConversion = {
  144. from: '\xa0-\xff',
  145. to: '\xa0-\xff'
  146. };
  147. break;
  148. case 'ISO-8859-2':
  149. this.oCharsetConversion = {
  150. from: '\xa0\u0104\u02d8\u0141\xa4\u013d\u015a\xa7\xa8\u0160\u015e\u0164\u0179\xad\u017d\u017b\xb0\u0105\u02db\u0142\xb4\u013e\u015b\u02c7\xb8\u0161\u015f\u0165\u017a\u02dd\u017e\u017c\u0154\xc1\xc2\u0102\xc4\u0139\u0106\xc7\u010c\xc9\u0118\xcb\u011a\xcd\xce\u010e\u0110\u0143\u0147\xd3\xd4\u0150\xd6\xd7\u0158\u016e\xda\u0170\xdc\xdd\u0162\xdf\u0155\xe1\xe2\u0103\xe4\u013a\u0107\xe7\u010d\xe9\u0119\xeb\u011b\xed\xee\u010f\u0111\u0144\u0148\xf3\xf4\u0151\xf6\xf7\u0159\u016f\xfa\u0171\xfc\xfd\u0163\u02d9',
  151. to: '\xa0-\xff'
  152. };
  153. break;
  154. case 'ISO-8859-5':
  155. this.oCharsetConversion = {
  156. from: '\xa0\u0401-\u040c\xad\u040e-\u044f\u2116\u0451-\u045c\xa7\u045e\u045f',
  157. to: '\xa0-\xff'
  158. };
  159. break;
  160. case 'ISO-8859-9':
  161. this.oCharsetConversion = {
  162. from: '\xa0-\xcf\u011e\xd1-\xdc\u0130\u015e\xdf-\xef\u011f\xf1-\xfc\u0131\u015f\xff',
  163. to: '\xa0-\xff'
  164. };
  165. break;
  166. case 'ISO-8859-15':
  167. this.oCharsetConversion = {
  168. from: '\xa0-\xa3\u20ac\xa5\u0160\xa7\u0161\xa9-\xb3\u017d\xb5-\xb7\u017e\xb9-\xbb\u0152\u0153\u0178\xbf-\xff',
  169. to: '\xa0-\xff'
  170. };
  171. break;
  172. case 'tis-620':
  173. this.oCharsetConversion = {
  174. from: '\u20ac\u2026\u2018\u2019\u201c\u201d\u2022\u2013\u2014\xa0\u0e01-\u0e3a\u0e3f-\u0e5b',
  175. to: '\x80\x85\x91-\x97\xa0-\xda\xdf-\xfb'
  176. };
  177. break;
  178. case 'windows-1251':
  179. this.oCharsetConversion = {
  180. from: '\u0402\u0403\u201a\u0453\u201e\u2026\u2020\u2021\u20ac\u2030\u0409\u2039\u040a\u040c\u040b\u040f\u0452\u2018\u2019\u201c\u201d\u2022\u2013\u2014\u2122\u0459\u203a\u045a\u045c\u045b\u045f\xa0\u040e\u045e\u0408\xa4\u0490\xa6\xa7\u0401\xa9\u0404\xab-\xae\u0407\xb0\xb1\u0406\u0456\u0491\xb5-\xb7\u0451\u2116\u0454\xbb\u0458\u0405\u0455\u0457\u0410-\u044f',
  181. to: '\x80-\x97\x99-\xff'
  182. };
  183. break;
  184. case 'windows-1253':
  185. this.oCharsetConversion = {
  186. from: '\u20ac\u201a\u0192\u201e\u2026\u2020\u2021\u2030\u2039\u2018\u2019\u201c\u201d\u2022\u2013\u2014\u2122\u203a\xa0\u0385\u0386\xa3-\xa9\xab-\xae\u2015\xb0-\xb3\u0384\xb5-\xb7\u0388-\u038a\xbb\u038c\xbd\u038e-\u03a1\u03a3-\u03ce',
  187. to: '\x80\x82-\x87\x89\x8b\x91-\x97\x99\x9b\xa0-\xa9\xab-\xd1\xd3-\xfe'
  188. };
  189. break;
  190. case 'windows-1255':
  191. this.oCharsetConversion = {
  192. from: '\u20ac\u201a\u0192\u201e\u2026\u2020\u2021\u02c6\u2030\u2039\u2018\u2019\u201c\u201d\u2022\u2013\u2014\u02dc\u2122\u203a\xa0-\xa3\u20aa\xa5-\xa9\xd7\xab-\xb9\xf7\xbb-\xbf\u05b0-\u05b9\u05bb-\u05c3\u05f0-\u05f4\u05d0-\u05ea\u200e\u200f',
  193. to: '\x80\x82-\x89\x8b\x91-\x99\x9b\xa0-\xc9\xcb-\xd8\xe0-\xfa\xfd\xfe'
  194. };
  195. break;
  196. case 'windows-1256':
  197. this.oCharsetConversion = {
  198. from: '\u20ac\u067e\u201a\u0192\u201e\u2026\u2020\u2021\u02c6\u2030\u0679\u2039\u0152\u0686\u0698\u0688\u06af\u2018\u2019\u201c\u201d\u2022\u2013\u2014\u06a9\u2122\u0691\u203a\u0153\u200c\u200d\u06ba\xa0\u060c\xa2-\xa9\u06be\xab-\xb9\u061b\xbb-\xbe\u061f\u06c1\u0621-\u0636\xd7\u0637-\u063a\u0640-\u0643\xe0\u0644\xe2\u0645-\u0648\xe7-\xeb\u0649\u064a\xee\xef\u064b-\u064e\xf4\u064f\u0650\xf7\u0651\xf9\u0652\xfb\xfc\u200e\u200f\u06d2',
  199. to: '\x80-\xff'
  200. };
  201. break;
  202. default:
  203. this.oCharsetConversion = {
  204. from: '',
  205. to: ''
  206. };
  207. break;
  208. }
  209. var funcExpandString = function (sSearch) {
  210. var sInsert = '';
  211. for (var i = sSearch.charCodeAt(0), n = sSearch.charCodeAt(2); i <= n; i++)
  212. sInsert += String.fromCharCode(i);
  213. return sInsert;
  214. };
  215. this.oCharsetConversion.from = this.oCharsetConversion.from.replace(/.\-./g, funcExpandString);
  216. this.oCharsetConversion.to = this.oCharsetConversion.to.replace(/.\-./g, funcExpandString);
  217. }
  218. var sReturn = '', iOffsetFrom = 0;
  219. for (var i = 0, n = this.length; i < n; i++)
  220. {
  221. iOffsetFrom = this.oCharsetConversion.from.indexOf(this.charAt(i));
  222. sReturn += iOffsetFrom > -1 ? this.oCharsetConversion.to.charAt(iOffsetFrom) : (this.charCodeAt(i) > 127 ? '&#' + this.charCodeAt(i) + ';' : this.charAt(i));
  223. }
  224. return sReturn
  225. }
  226. // Character-level replacement function.
  227. String.prototype.php_strtr = function (sFrom, sTo)
  228. {
  229. return this.replace(new RegExp('[' + sFrom + ']', 'g'), function (sMatch) {
  230. return sTo.charAt(sFrom.indexOf(sMatch));
  231. });
  232. }
  233. // Simulate PHP's strtolower (in SOME cases PHP uses ISO-8859-1 case folding).
  234. String.prototype.php_strtolower = function ()
  235. {
  236. return typeof(smf_iso_case_folding) == 'boolean' && smf_iso_case_folding == true ? this.php_strtr(
  237. 'ABCDEFGHIJKLMNOPQRSTUVWXYZ\x8a\x8c\x8e\x9f\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde',
  238. 'abcdefghijklmnopqrstuvwxyz\x9a\x9c\x9e\xff\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe'
  239. ) : this.php_strtr('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
  240. }
  241. String.prototype.php_urlencode = function()
  242. {
  243. return escape(this).replace(/\+/g, '%2b').replace('*', '%2a').replace('/', '%2f').replace('@', '%40');
  244. }
  245. String.prototype.php_htmlspecialchars = function()
  246. {
  247. return this.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
  248. }
  249. String.prototype.php_unhtmlspecialchars = function()
  250. {
  251. return this.replace(/&quot;/g, '"').replace(/&gt;/g, '>').replace(/&lt;/g, '<').replace(/&amp;/g, '&');
  252. }
  253. String.prototype.php_addslashes = function()
  254. {
  255. return this.replace(/\\/g, '\\\\').replace(/'/g, '\\\'');
  256. }
  257. String.prototype._replaceEntities = function(sInput, sDummy, sNum)
  258. {
  259. return String.fromCharCode(parseInt(sNum));
  260. }
  261. String.prototype.removeEntities = function()
  262. {
  263. return this.replace(/&(amp;)?#(\d+);/g, this._replaceEntities);
  264. }
  265. String.prototype.easyReplace = function (oReplacements)
  266. {
  267. var sResult = this;
  268. for (var sSearch in oReplacements)
  269. sResult = sResult.replace(new RegExp('%' + sSearch + '%', 'g'), oReplacements[sSearch]);
  270. return sResult;
  271. }
  272. // Open a new window
  273. function reqWin(desktopURL, alternateWidth, alternateHeight, noScrollbars)
  274. {
  275. if ((alternateWidth && self.screen.availWidth * 0.8 < alternateWidth) || (alternateHeight && self.screen.availHeight * 0.8 < alternateHeight))
  276. {
  277. noScrollbars = false;
  278. alternateWidth = Math.min(alternateWidth, self.screen.availWidth * 0.8);
  279. alternateHeight = Math.min(alternateHeight, self.screen.availHeight * 0.8);
  280. }
  281. else
  282. noScrollbars = typeof(noScrollbars) == 'boolean' && noScrollbars == true;
  283. window.open(desktopURL, 'requested_popup', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=' + (noScrollbars ? 'no' : 'yes') + ',width=' + (alternateWidth ? alternateWidth : 480) + ',height=' + (alternateHeight ? alternateHeight : 220) + ',resizable=no');
  284. // Return false so the click won't follow the link ;).
  285. return false;
  286. }
  287. // Open a overlay div
  288. function reqOverlayDiv(desktopURL, sHeader, sIcon)
  289. {
  290. // Set up our div details
  291. var sAjax_indicator = '<div class="centertext"><img src="' + smf_images_url + '/loading.gif" ></div>';
  292. var sIcon = smf_images_url + '/' + typeof(sIcon) == 'string' ? sIcon : 'helptopics.png';
  293. var sHeader = typeof(sHeader) == 'string' ? sHeader : help_popup_heading_text;
  294. // Create the div that we are going to load
  295. var oContainer = new smc_Popup({heading: sHeader, content: sAjax_indicator, icon: sIcon});
  296. var oPopup_body = $('#' + oContainer.popup_id).find('.popup_content');
  297. // Load the help page content (we just want the text to show)
  298. $.ajax({
  299. url: desktopURL,
  300. type: "GET",
  301. dataType: "html",
  302. beforeSend: function () {
  303. },
  304. success: function (data, textStatus, xhr) {
  305. var help_content = $('<div id="temp_help">').html(data).find('a[href$="self.close();"]').hide().prev('br').hide().parent().html();
  306. oPopup_body.html(help_content);
  307. },
  308. error: function (xhr, textStatus, errorThrown) {
  309. oPopup_body.html(textStatus);
  310. }
  311. });
  312. return false;
  313. }
  314. // *** smc_Popup class.
  315. function smc_Popup(oOptions)
  316. {
  317. this.opt = oOptions;
  318. this.popup_id = this.opt.custom_id ? this.opt.custom_id : 'smf_popup';
  319. this.show();
  320. }
  321. smc_Popup.prototype.show = function ()
  322. {
  323. popup_class = 'popup_window ' + (this.opt.custom_class ? this.opt.custom_class : 'description');
  324. icon = this.opt.icon ? '<img src="' + this.opt.icon + '" class="icon" alt="" /> ' : '';
  325. // Create the div that will be shown
  326. $('body').append('<div id="' + this.popup_id + '" class="popup_container"><div class="' + popup_class + '"><div class="catbg popup_heading"><a href="javascript:void(0);" class="hide_popup"></a>' + icon + this.opt.heading + '</div><div class="popup_content">' + this.opt.content + '</div></div></div>');
  327. // Show it
  328. this.popup_body = $('#' + this.popup_id).children('.popup_window');
  329. this.popup_body.css({top: '25%', left: '50%', margin: '-' + ($(this.popup_body).height() / 2) + 'px 0 0 -' + ($(this.popup_body).width() / 2) + 'px'}).parent().fadeIn(300);
  330. // Trigger hide on escape or mouse click
  331. var popup_instance = this;
  332. $(document).mouseup(function (e) {
  333. if ($('#' + popup_instance.popup_id).has(e.target).length === 0)
  334. popup_instance.hide();
  335. }).keyup(function(e){
  336. if(e.keyCode == 27)
  337. popup_instance.hide();
  338. });
  339. $('#' + this.popup_id).find('.hide_popup').click(function (){ return popup_instance.hide(); });
  340. return false;
  341. }
  342. smc_Popup.prototype.hide = function ()
  343. {
  344. $('#' + this.popup_id).fadeOut(300, function(){ $(this).remove(); });
  345. return false;
  346. }
  347. // Remember the current position.
  348. function storeCaret(oTextHandle)
  349. {
  350. // Only bother if it will be useful.
  351. if ('createTextRange' in oTextHandle)
  352. oTextHandle.caretPos = document.selection.createRange().duplicate();
  353. }
  354. // Replaces the currently selected text with the passed text.
  355. function replaceText(text, oTextHandle)
  356. {
  357. // Attempt to create a text range (IE).
  358. if ('caretPos' in oTextHandle && 'createTextRange' in oTextHandle)
  359. {
  360. var caretPos = oTextHandle.caretPos;
  361. caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
  362. caretPos.select();
  363. }
  364. // Mozilla text range replace.
  365. else if ('selectionStart' in oTextHandle)
  366. {
  367. var begin = oTextHandle.value.substr(0, oTextHandle.selectionStart);
  368. var end = oTextHandle.value.substr(oTextHandle.selectionEnd);
  369. var scrollPos = oTextHandle.scrollTop;
  370. oTextHandle.value = begin + text + end;
  371. if (oTextHandle.setSelectionRange)
  372. {
  373. oTextHandle.focus();
  374. var goForward = is_opera ? text.match(/\n/g).length : 0;
  375. oTextHandle.setSelectionRange(begin.length + text.length + goForward, begin.length + text.length + goForward);
  376. }
  377. oTextHandle.scrollTop = scrollPos;
  378. }
  379. // Just put it on the end.
  380. else
  381. {
  382. oTextHandle.value += text;
  383. oTextHandle.focus(oTextHandle.value.length - 1);
  384. }
  385. }
  386. // Surrounds the selected text with text1 and text2.
  387. function surroundText(text1, text2, oTextHandle)
  388. {
  389. // Can a text range be created?
  390. if ('caretPos' in oTextHandle && 'createTextRange' in oTextHandle)
  391. {
  392. var caretPos = oTextHandle.caretPos, temp_length = caretPos.text.length;
  393. caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text1 + caretPos.text + text2 + ' ' : text1 + caretPos.text + text2;
  394. if (temp_length == 0)
  395. {
  396. caretPos.moveStart('character', -text2.length);
  397. caretPos.moveEnd('character', -text2.length);
  398. caretPos.select();
  399. }
  400. else
  401. oTextHandle.focus(caretPos);
  402. }
  403. // Mozilla text range wrap.
  404. else if ('selectionStart' in oTextHandle)
  405. {
  406. var begin = oTextHandle.value.substr(0, oTextHandle.selectionStart);
  407. var selection = oTextHandle.value.substr(oTextHandle.selectionStart, oTextHandle.selectionEnd - oTextHandle.selectionStart);
  408. var end = oTextHandle.value.substr(oTextHandle.selectionEnd);
  409. var newCursorPos = oTextHandle.selectionStart;
  410. var scrollPos = oTextHandle.scrollTop;
  411. oTextHandle.value = begin + text1 + selection + text2 + end;
  412. if (oTextHandle.setSelectionRange)
  413. {
  414. var goForward = is_opera ? text1.match(/\n/g).length : 0, goForwardAll = is_opera ? (text1 + text2).match(/\n/g).length : 0;
  415. if (selection.length == 0)
  416. oTextHandle.setSelectionRange(newCursorPos + text1.length + goForward, newCursorPos + text1.length + goForward);
  417. else
  418. oTextHandle.setSelectionRange(newCursorPos, newCursorPos + text1.length + selection.length + text2.length + goForwardAll);
  419. oTextHandle.focus();
  420. }
  421. oTextHandle.scrollTop = scrollPos;
  422. }
  423. // Just put them on the end, then.
  424. else
  425. {
  426. oTextHandle.value += text1 + text2;
  427. oTextHandle.focus(oTextHandle.value.length - 1);
  428. }
  429. }
  430. // Checks if the passed input's value is nothing.
  431. function isEmptyText(theField)
  432. {
  433. // Copy the value so changes can be made..
  434. var theValue = theField.value;
  435. // Strip whitespace off the left side.
  436. while (theValue.length > 0 && (theValue.charAt(0) == ' ' || theValue.charAt(0) == '\t'))
  437. theValue = theValue.substring(1, theValue.length);
  438. // Strip whitespace off the right side.
  439. while (theValue.length > 0 && (theValue.charAt(theValue.length - 1) == ' ' || theValue.charAt(theValue.length - 1) == '\t'))
  440. theValue = theValue.substring(0, theValue.length - 1);
  441. if (theValue == '')
  442. return true;
  443. else
  444. return false;
  445. }
  446. // Only allow form submission ONCE.
  447. function submitonce(theform)
  448. {
  449. smf_formSubmitted = true;
  450. // If there are any editors warn them submit is coming!
  451. for (var i = 0; i < smf_editorArray.length; i++)
  452. smf_editorArray[i].doSubmit();
  453. }
  454. function submitThisOnce(oControl)
  455. {
  456. // Hateful, hateful fix for Safari 1.3 beta.
  457. if (is_safari)
  458. return !smf_formSubmitted;
  459. // oControl might also be a form.
  460. var oForm = 'form' in oControl ? oControl.form : oControl;
  461. var aTextareas = oForm.getElementsByTagName('textarea');
  462. for (var i = 0, n = aTextareas.length; i < n; i++)
  463. aTextareas[i].readOnly = true;
  464. return !smf_formSubmitted;
  465. }
  466. // Deprecated, as innerHTML is supported everywhere.
  467. function setInnerHTML(oElement, sToValue)
  468. {
  469. oElement.innerHTML = sToValue;
  470. }
  471. function getInnerHTML(oElement)
  472. {
  473. return oElement.innerHTML;
  474. }
  475. // Set the "outer" HTML of an element.
  476. function setOuterHTML(oElement, sToValue)
  477. {
  478. if ('outerHTML' in oElement)
  479. oElement.outerHTML = sToValue;
  480. else
  481. {
  482. var range = document.createRange();
  483. range.setStartBefore(oElement);
  484. oElement.parentNode.replaceChild(range.createContextualFragment(sToValue), oElement);
  485. }
  486. }
  487. // Checks for variable in theArray.
  488. function in_array(variable, theArray)
  489. {
  490. for (var i in theArray)
  491. if (theArray[i] == variable)
  492. return true;
  493. return false;
  494. }
  495. // Checks for variable in theArray.
  496. function array_search(variable, theArray)
  497. {
  498. for (var i in theArray)
  499. if (theArray[i] == variable)
  500. return i;
  501. return null;
  502. }
  503. // Find a specific radio button in its group and select it.
  504. function selectRadioByName(oRadioGroup, sName)
  505. {
  506. if (!('length' in oRadioGroup))
  507. return oRadioGroup.checked = true;
  508. for (var i = 0, n = oRadioGroup.length; i < n; i++)
  509. if (oRadioGroup[i].value == sName)
  510. return oRadioGroup[i].checked = true;
  511. return false;
  512. }
  513. function selectAllRadio(oInvertCheckbox, oForm, sMask, sValue)
  514. {
  515. for (var i = 0; i < oForm.length; i++)
  516. if (oForm[i].name != undefined && oForm[i].name.substr(0, sMask.length) == sMask && oForm[i].value == sValue)
  517. oForm[i].checked = true;
  518. }
  519. // Invert all checkboxes at once by clicking a single checkbox.
  520. function invertAll(oInvertCheckbox, oForm, sMask, bIgnoreDisabled)
  521. {
  522. for (var i = 0; i < oForm.length; i++)
  523. {
  524. if (!('name' in oForm[i]) || (typeof(sMask) == 'string' && oForm[i].name.substr(0, sMask.length) != sMask && oForm[i].id.substr(0, sMask.length) != sMask))
  525. continue;
  526. if (!oForm[i].disabled || (typeof(bIgnoreDisabled) == 'boolean' && bIgnoreDisabled))
  527. oForm[i].checked = oInvertCheckbox.checked;
  528. }
  529. }
  530. // Keep the session alive - always!
  531. var lastKeepAliveCheck = new Date().getTime();
  532. function smf_sessionKeepAlive()
  533. {
  534. var curTime = new Date().getTime();
  535. // Prevent a Firefox bug from hammering the server.
  536. if (smf_scripturl && curTime - lastKeepAliveCheck > 900000)
  537. {
  538. var tempImage = new Image();
  539. tempImage.src = smf_prepareScriptUrl(smf_scripturl) + 'action=keepalive;time=' + curTime;
  540. lastKeepAliveCheck = curTime;
  541. }
  542. window.setTimeout('smf_sessionKeepAlive();', 1200000);
  543. }
  544. window.setTimeout('smf_sessionKeepAlive();', 1200000);
  545. // Set a theme option through javascript.
  546. function smf_setThemeOption(option, value, theme, cur_session_id, cur_session_var, additional_vars)
  547. {
  548. // Compatibility.
  549. if (cur_session_id == null)
  550. cur_session_id = smf_session_id;
  551. if (typeof(cur_session_var) == 'undefined')
  552. cur_session_var = 'sesc';
  553. if (additional_vars == null)
  554. additional_vars = '';
  555. var tempImage = new Image();
  556. tempImage.src = smf_prepareScriptUrl(smf_scripturl) + 'action=jsoption;var=' + option + ';val=' + value + ';' + cur_session_var + '=' + cur_session_id + additional_vars + (theme == null ? '' : '&th=' + theme) + ';time=' + (new Date().getTime());
  557. }
  558. function smf_avatarResize()
  559. {
  560. var possibleAvatars = document.getElementsByTagName('img');
  561. for (var i = 0; i < possibleAvatars.length; i++)
  562. {
  563. var tempAvatars = []; j = 0;
  564. if (possibleAvatars[i].className != 'avatar')
  565. continue;
  566. // Image.prototype.avatar = possibleAvatars[i];
  567. tempAvatars[j] = new Image();
  568. tempAvatars[j].avatar = possibleAvatars[i];
  569. tempAvatars[j].onload = function()
  570. {
  571. this.avatar.width = this.width;
  572. this.avatar.height = this.height;
  573. if (smf_avatarMaxWidth != 0 && this.width > smf_avatarMaxWidth)
  574. {
  575. this.avatar.height = (smf_avatarMaxWidth * this.height) / this.width;
  576. this.avatar.width = smf_avatarMaxWidth;
  577. }
  578. if (smf_avatarMaxHeight != 0 && this.avatar.height > smf_avatarMaxHeight)
  579. {
  580. this.avatar.width = (smf_avatarMaxHeight * this.avatar.width) / this.avatar.height;
  581. this.avatar.height = smf_avatarMaxHeight;
  582. }
  583. }
  584. tempAvatars[j].src = possibleAvatars[i].src;
  585. j++;
  586. }
  587. if (typeof(window_oldAvatarOnload) != 'undefined' && window_oldAvatarOnload)
  588. {
  589. window_oldAvatarOnload();
  590. window_oldAvatarOnload = null;
  591. }
  592. }
  593. function hashLoginPassword(doForm, cur_session_id, token)
  594. {
  595. // Compatibility.
  596. if (cur_session_id == null)
  597. cur_session_id = smf_session_id;
  598. if (typeof(hex_sha1) == 'undefined')
  599. return;
  600. // Are they using an email address?
  601. if (doForm.user.value.indexOf('@') != -1)
  602. return;
  603. // Unless the browser is Opera, the password will not save properly.
  604. if (!('opera' in window))
  605. doForm.passwrd.autocomplete = 'off';
  606. doForm.hash_passwrd.value = hex_sha1(hex_sha1(doForm.user.value.php_to8bit().php_strtolower() + doForm.passwrd.value.php_to8bit()) + cur_session_id + token);
  607. // It looks nicer to fill it with asterisks, but Firefox will try to save that.
  608. if (is_ff != -1)
  609. doForm.passwrd.value = '';
  610. else
  611. doForm.passwrd.value = doForm.passwrd.value.replace(/./g, '*');
  612. }
  613. function hashAdminPassword(doForm, username, cur_session_id, token)
  614. {
  615. // Compatibility.
  616. if (cur_session_id == null)
  617. cur_session_id = smf_session_id;
  618. if (typeof(hex_sha1) == 'undefined')
  619. return;
  620. doForm.admin_hash_pass.value = hex_sha1(hex_sha1(username.php_to8bit().php_strtolower() + doForm.admin_pass.value.php_to8bit()) + cur_session_id + token);
  621. doForm.admin_pass.value = doForm.admin_pass.value.replace(/./g, '*');
  622. }
  623. function hashModeratePassword(doForm, username, cur_session_id, token)
  624. {
  625. if (typeof(hex_sha1) == 'undefined')
  626. return;
  627. doForm.moderate_hash_pass.value = hex_sha1(hex_sha1(username.php_to8bit().php_strtolower() + doForm.moderate_pass.value.php_to8bit()) + cur_session_id + token);
  628. doForm.moderate_pass.value = doForm.moderate_pass.value.replace(/./g, '*');
  629. }
  630. // Shows the page numbers by clicking the dots (in compact view).
  631. function expandPages(spanNode, baseURL, firstPage, lastPage, perPage)
  632. {
  633. var replacement = '', i, oldLastPage = 0;
  634. var perPageLimit = 50;
  635. // The dots were bold, the page numbers are not (in most cases).
  636. spanNode.style.fontWeight = 'normal';
  637. spanNode.onclick = '';
  638. // Prevent too many pages to be loaded at once.
  639. if ((lastPage - firstPage) / perPage > perPageLimit)
  640. {
  641. oldLastPage = lastPage;
  642. lastPage = firstPage + perPageLimit * perPage;
  643. }
  644. // Calculate the new pages.
  645. for (i = firstPage; i < lastPage; i += perPage)
  646. replacement += '<a class="navPages" href="' + baseURL.replace(/%1\$d/, i).replace(/%%/g, '%') + '">' + (1 + i / perPage) + '</a> ';
  647. if (oldLastPage > 0)
  648. replacement += '<span style="font-weight: bold; cursor: ' + (is_ie && !is_ie6up ? 'hand' : 'pointer') + ';" onclick="expandPages(this, \'' + baseURL + '\', ' + lastPage + ', ' + oldLastPage + ', ' + perPage + ');"> ... </span> ';
  649. // Replace the dots by the new page links.
  650. setInnerHTML(spanNode, replacement);
  651. }
  652. function smc_preCacheImage(sSrc)
  653. {
  654. if (!('smc_aCachedImages' in window))
  655. window.smc_aCachedImages = [];
  656. if (!in_array(sSrc, window.smc_aCachedImages))
  657. {
  658. var oImage = new Image();
  659. oImage.src = sSrc;
  660. }
  661. }
  662. // *** smc_Cookie class.
  663. function smc_Cookie(oOptions)
  664. {
  665. this.opt = oOptions;
  666. this.oCookies = {};
  667. this.init();
  668. }
  669. smc_Cookie.prototype.init = function()
  670. {
  671. if ('cookie' in document && document.cookie != '')
  672. {
  673. var aCookieList = document.cookie.split(';');
  674. for (var i = 0, n = aCookieList.length; i < n; i++)
  675. {
  676. var aNameValuePair = aCookieList[i].split('=');
  677. this.oCookies[aNameValuePair[0].replace(/^\s+|\s+$/g, '')] = decodeURIComponent(aNameValuePair[1]);
  678. }
  679. }
  680. }
  681. smc_Cookie.prototype.get = function(sKey)
  682. {
  683. return sKey in this.oCookies ? this.oCookies[sKey] : null;
  684. }
  685. smc_Cookie.prototype.set = function(sKey, sValue)
  686. {
  687. document.cookie = sKey + '=' + encodeURIComponent(sValue);
  688. }
  689. // *** smc_Toggle class.
  690. function smc_Toggle(oOptions)
  691. {
  692. this.opt = oOptions;
  693. this.bCollapsed = false;
  694. this.oCookie = null;
  695. this.init();
  696. }
  697. smc_Toggle.prototype.init = function ()
  698. {
  699. // The master switch can disable this toggle fully.
  700. if ('bToggleEnabled' in this.opt && !this.opt.bToggleEnabled)
  701. return;
  702. // If cookies are enabled and they were set, override the initial state.
  703. if ('oCookieOptions' in this.opt && this.opt.oCookieOptions.bUseCookie)
  704. {
  705. // Initialize the cookie handler.
  706. this.oCookie = new smc_Cookie({});
  707. // Check if the cookie is set.
  708. var cookieValue = this.oCookie.get(this.opt.oCookieOptions.sCookieName)
  709. if (cookieValue != null)
  710. this.opt.bCurrentlyCollapsed = cookieValue == '1';
  711. }
  712. // If the init state is set to be collapsed, collapse it.
  713. if (this.opt.bCurrentlyCollapsed)
  714. this.changeState(true, true);
  715. // Initialize the images to be clickable.
  716. if ('aSwapImages' in this.opt)
  717. {
  718. for (var i = 0, n = this.opt.aSwapImages.length; i < n; i++)
  719. {
  720. var oImage = document.getElementById(this.opt.aSwapImages[i].sId);
  721. if (typeof(oImage) == 'object' && oImage != null)
  722. {
  723. // Display the image in case it was hidden.
  724. if (oImage.style.display == 'none')
  725. oImage.style.display = '';
  726. oImage.instanceRef = this;
  727. oImage.onclick = function () {
  728. this.instanceRef.toggle();
  729. this.blur();
  730. }
  731. oImage.style.cursor = 'pointer';
  732. // Preload the collapsed image.
  733. smc_preCacheImage(this.opt.aSwapImages[i].srcCollapsed);
  734. }
  735. }
  736. }
  737. // Initialize links.
  738. if ('aSwapLinks' in this.opt)
  739. {
  740. for (var i = 0, n = this.opt.aSwapLinks.length; i < n; i++)
  741. {
  742. var oLink = document.getElementById(this.opt.aSwapLinks[i].sId);
  743. if (typeof(oLink) == 'object' && oLink != null)
  744. {
  745. // Display the link in case it was hidden.
  746. if (oLink.style.display == 'none')
  747. oLink.style.display = '';
  748. oLink.instanceRef = this;
  749. oLink.onclick = function () {
  750. this.instanceRef.toggle();
  751. this.blur();
  752. return false;
  753. }
  754. }
  755. }
  756. }
  757. }
  758. // Collapse or expand the section.
  759. smc_Toggle.prototype.changeState = function(bCollapse, bInit)
  760. {
  761. // Default bInit to false.
  762. bInit = typeof(bInit) == 'undefined' ? false : true;
  763. // Handle custom function hook before collapse.
  764. if (!bInit && bCollapse && 'funcOnBeforeCollapse' in this.opt)
  765. {
  766. this.tmpMethod = this.opt.funcOnBeforeCollapse;
  767. this.tmpMethod();
  768. delete this.tmpMethod;
  769. }
  770. // Handle custom function hook before expand.
  771. else if (!bInit && !bCollapse && 'funcOnBeforeExpand' in this.opt)
  772. {
  773. this.tmpMethod = this.opt.funcOnBeforeExpand;
  774. this.tmpMethod();
  775. delete this.tmpMethod;
  776. }
  777. // Loop through all the images that need to be toggled.
  778. if ('aSwapImages' in this.opt)
  779. {
  780. for (var i = 0, n = this.opt.aSwapImages.length; i < n; i++)
  781. {
  782. var oImage = document.getElementById(this.opt.aSwapImages[i].sId);
  783. if (typeof(oImage) == 'object' && oImage != null)
  784. {
  785. // Only (re)load the image if it's changed.
  786. var sTargetSource = bCollapse ? this.opt.aSwapImages[i].srcCollapsed : this.opt.aSwapImages[i].srcExpanded;
  787. if (oImage.src != sTargetSource)
  788. oImage.src = sTargetSource;
  789. oImage.alt = oImage.title = bCollapse ? this.opt.aSwapImages[i].altCollapsed : this.opt.aSwapImages[i].altExpanded;
  790. }
  791. }
  792. }
  793. // Loop through all the links that need to be toggled.
  794. if ('aSwapLinks' in this.opt)
  795. {
  796. for (var i = 0, n = this.opt.aSwapLinks.length; i < n; i++)
  797. {
  798. var oLink = document.getElementById(this.opt.aSwapLinks[i].sId);
  799. if (typeof(oLink) == 'object' && oLink != null)
  800. setInnerHTML(oLink, bCollapse ? this.opt.aSwapLinks[i].msgCollapsed : this.opt.aSwapLinks[i].msgExpanded);
  801. }
  802. }
  803. // Now go through all the sections to be collapsed.
  804. for (var i = 0, n = this.opt.aSwappableContainers.length; i < n; i++)
  805. {
  806. if (this.opt.aSwappableContainers[i] == null)
  807. continue;
  808. var oContainer = document.getElementById(this.opt.aSwappableContainers[i]);
  809. if (typeof(oContainer) == 'object' && oContainer != null)
  810. oContainer.style.display = bCollapse ? 'none' : '';
  811. }
  812. // Update the new state.
  813. this.bCollapsed = bCollapse;
  814. // Update the cookie, if desired.
  815. if ('oCookieOptions' in this.opt && this.opt.oCookieOptions.bUseCookie)
  816. this.oCookie.set(this.opt.oCookieOptions.sCookieName, this.bCollapsed ? '1' : '0');
  817. if (!bInit && 'oThemeOptions' in this.opt && this.opt.oThemeOptions.bUseThemeSettings)
  818. smf_setThemeOption(this.opt.oThemeOptions.sOptionName, this.bCollapsed ? '1' : '0', 'sThemeId' in this.opt.oThemeOptions ? this.opt.oThemeOptions.sThemeId : null, smf_session_id, smf_session_var, 'sAdditionalVars' in this.opt.oThemeOptions ? this.opt.oThemeOptions.sAdditionalVars : null);
  819. }
  820. smc_Toggle.prototype.toggle = function()
  821. {
  822. // Change the state by reversing the current state.
  823. this.changeState(!this.bCollapsed);
  824. }
  825. function ajax_indicator(turn_on)
  826. {
  827. if (ajax_indicator_ele == null)
  828. {
  829. ajax_indicator_ele = document.getElementById('ajax_in_progress');
  830. if (ajax_indicator_ele == null && typeof(ajax_notification_text) != null)
  831. {
  832. create_ajax_indicator_ele();
  833. }
  834. }
  835. if (ajax_indicator_ele != null)
  836. {
  837. if (navigator.appName == 'Microsoft Internet Explorer' && !is_ie7up)
  838. {
  839. ajax_indicator_ele.style.position = 'absolute';
  840. ajax_indicator_ele.style.top = document.documentElement.scrollTop;
  841. }
  842. ajax_indicator_ele.style.display = turn_on ? 'block' : 'none';
  843. }
  844. }
  845. function create_ajax_indicator_ele()
  846. {
  847. // Create the div for the indicator.
  848. ajax_indicator_ele = document.createElement('div');
  849. // Set the id so it'll load the style properly.
  850. ajax_indicator_ele.id = 'ajax_in_progress';
  851. // Add the image in and link to turn it off.
  852. var cancel_link = document.createElement('a');
  853. cancel_link.href = 'javascript:ajax_indicator(false)';
  854. var cancel_img = document.createElement('img');
  855. cancel_img.src = smf_images_url + '/icons/quick_remove.png';
  856. if (typeof(ajax_notification_cancel_text) != 'undefined')
  857. {
  858. cancel_img.alt = ajax_notification_cancel_text;
  859. cancel_img.title = ajax_notification_cancel_text;
  860. }
  861. // Add the cancel link and image to the indicator.
  862. cancel_link.appendChild(cancel_img);
  863. ajax_indicator_ele.appendChild(cancel_link);
  864. // Set the text. (Note: You MUST append here and not overwrite.)
  865. ajax_indicator_ele.innerHTML += ajax_notification_text;
  866. // Finally attach the element to the body.
  867. document.body.appendChild(ajax_indicator_ele);
  868. }
  869. function createEventListener(oTarget)
  870. {
  871. if (!('addEventListener' in oTarget))
  872. {
  873. if (oTarget.attachEvent)
  874. {
  875. oTarget.addEventListener = function (sEvent, funcHandler, bCapture) {
  876. oTarget.attachEvent('on' + sEvent, funcHandler);
  877. }
  878. oTarget.removeEventListener = function (sEvent, funcHandler, bCapture) {
  879. oTarget.detachEvent('on' + sEvent, funcHandler);
  880. }
  881. }
  882. else
  883. {
  884. oTarget.addEventListener = function (sEvent, funcHandler, bCapture) {
  885. oTarget['on' + sEvent] = funcHandler;
  886. }
  887. oTarget.removeEventListener = function (sEvent, funcHandler, bCapture) {
  888. oTarget['on' + sEvent] = null;
  889. }
  890. }
  891. }
  892. }
  893. // This function will retrieve the contents needed for the jump to boxes.
  894. function grabJumpToContent()
  895. {
  896. var oXMLDoc = getXMLDocument(smf_prepareScriptUrl(smf_scripturl) + 'action=xmlhttp;sa=jumpto;xml');
  897. var aBoardsAndCategories = new Array();
  898. ajax_indicator(true);
  899. if (oXMLDoc.responseXML)
  900. {
  901. var items = oXMLDoc.responseXML.getElementsByTagName('smf')[0].getElementsByTagName('item');
  902. for (var i = 0, n = items.length; i < n; i++)
  903. {
  904. aBoardsAndCategories[aBoardsAndCategories.length] = {
  905. id: parseInt(items[i].getAttribute('id')),
  906. isCategory: items[i].getAttribute('type') == 'category',
  907. name: items[i].firstChild.nodeValue.removeEntities(),
  908. is_current: false,
  909. childLevel: parseInt(items[i].getAttribute('childlevel'))
  910. }
  911. }
  912. }
  913. ajax_indicator(false);
  914. for (var i = 0, n = aJumpTo.length; i < n; i++)
  915. aJumpTo[i].fillSelect(aBoardsAndCategories);
  916. }
  917. // This'll contain all JumpTo objects on the page.
  918. var aJumpTo = new Array();
  919. // *** JumpTo class.
  920. function JumpTo(oJumpToOptions)
  921. {
  922. this.opt = oJumpToOptions;
  923. this.dropdownList = null;
  924. this.showSelect();
  925. }
  926. // Show the initial select box (onload). Method of the JumpTo class.
  927. JumpTo.prototype.showSelect = function ()
  928. {
  929. var sChildLevelPrefix = '';
  930. for (var i = this.opt.iCurBoardChildLevel; i > 0; i--)
  931. sChildLevelPrefix += this.opt.sBoardChildLevelIndicator;
  932. setInnerHTML(document.getElementById(this.opt.sContainerId), this.opt.sJumpToTemplate.replace(/%select_id%/, this.opt.sContainerId + '_select').replace(/%dropdown_list%/, '<select name="' + this.opt.sContainerId + '_select" id="' + this.opt.sContainerId + '_select" ' + ('implementation' in document ? '' : 'onmouseover="grabJumpToContent();" ') + ('onbeforeactivate' in document ? 'onbeforeactivate' : 'onfocus') + '="grabJumpToContent();"><option value="?board=' + this.opt.iCurBoardId + '.0">' + sChildLevelPrefix + this.opt.sBoardPrefix + this.opt.sCurBoardName.removeEntities() + '</option></select>&nbsp;<input type="button" class="button_submit" value="' + this.opt.sGoButtonLabel + '" onclick="window.location.href = \'' + smf_prepareScriptUrl(smf_scripturl) + 'board=' + this.opt.iCurBoardId + '.0\';" />'));
  933. this.dropdownList = document.getElementById(this.opt.sContainerId + '_select');
  934. }
  935. // Fill the jump to box with entries. Method of the JumpTo class.
  936. JumpTo.prototype.fillSelect = function (aBoardsAndCategories)
  937. {
  938. var bIE5x = !('implementation' in document);
  939. var iIndexPointer = 0;
  940. // Create an option that'll be above and below the category.
  941. var oDashOption = document.createElement('option');
  942. oDashOption.appendChild(document.createTextNode(this.opt.sCatSeparator));
  943. oDashOption.disabled = 'disabled';
  944. oDashOption.value = '';
  945. // Reset the events and clear the list (IE5.x only).
  946. if (bIE5x)
  947. {
  948. this.dropdownList.onmouseover = null;
  949. this.dropdownList.remove(0);
  950. }
  951. if ('onbeforeactivate' in document)
  952. this.dropdownList.onbeforeactivate = null;
  953. else
  954. this.dropdownList.onfocus = null;
  955. // Create a document fragment that'll allowing inserting big parts at once.
  956. var oListFragment = bIE5x ? this.dropdownList : document.createDocumentFragment();
  957. // Loop through all items to be added.
  958. for (var i = 0, n = aBoardsAndCategories.length; i < n; i++)
  959. {
  960. var j, sChildLevelPrefix, oOption;
  961. // If we've reached the currently selected board add all items so far.
  962. if (!aBoardsAndCategories[i].isCategory && aBoardsAndCategories[i].id == this.opt.iCurBoardId)
  963. {
  964. if (bIE5x)
  965. iIndexPointer = this.dropdownList.options.length;
  966. else
  967. {
  968. this.dropdownList.insertBefore(oListFragment, this.dropdownList.options[0]);
  969. oListFragment = document.createDocumentFragment();
  970. continue;
  971. }
  972. }
  973. if (aBoardsAndCategories[i].isCategory)
  974. oListFragment.appendChild(oDashOption.cloneNode(true));
  975. else
  976. for (j = aBoardsAndCategories[i].childLevel, sChildLevelPrefix = ''; j > 0; j--)
  977. sChildLevelPrefix += this.opt.sBoardChildLevelIndicator;
  978. oOption = document.createElement('option');
  979. oOption.appendChild(document.createTextNode((aBoardsAndCategories[i].isCategory ? this.opt.sCatPrefix : sChildLevelPrefix + this.opt.sBoardPrefix) + aBoardsAndCategories[i].name));
  980. oOption.value = aBoardsAndCategories[i].isCategory ? '#c' + aBoardsAndCategories[i].id : '?board=' + aBoardsAndCategories[i].id + '.0';
  981. oListFragment.appendChild(oOption);
  982. if (aBoardsAndCategories[i].isCategory)
  983. oListFragment.appendChild(oDashOption.cloneNode(true));
  984. }
  985. // Add the remaining items after the currently selected item.
  986. this.dropdownList.appendChild(oListFragment);
  987. if (bIE5x)
  988. this.dropdownList.options[iIndexPointer].selected = true;
  989. // Internet Explorer needs this to keep the box dropped down.
  990. this.dropdownList.style.width = 'auto';
  991. this.dropdownList.focus();
  992. // Add an onchange action
  993. this.dropdownList.onchange = function() {
  994. if (this.selectedIndex > 0 && this.options[this.selectedIndex].value)
  995. window.location.href = smf_scripturl + this.options[this.selectedIndex].value.substr(smf_scripturl.indexOf('?') == -1 || this.options[this.selectedIndex].value.substr(0, 1) != '?' ? 0 : 1);
  996. }
  997. }
  998. // A global array containing all IconList objects.
  999. var aIconLists = new Array();
  1000. // *** IconList object.
  1001. function IconList(oOptions)
  1002. {
  1003. if (!window.XMLHttpRequest)
  1004. return;
  1005. this.opt = oOptions;
  1006. this.bListLoaded = false;
  1007. this.oContainerDiv = null;
  1008. this.funcMousedownHandler = null;
  1009. this.funcParent = this;
  1010. this.iCurMessageId = 0;
  1011. this.iCurTimeout = 0;
  1012. // Add backwards compatibility with old themes.
  1013. if (!('sSessionVar' in this.opt))
  1014. this.opt.sSessionVar = 'sesc';
  1015. this.initIcons();
  1016. }
  1017. // Replace all message icons by icons with hoverable and clickable div's.
  1018. IconList.prototype.initIcons = function ()
  1019. {
  1020. for (var i = document.images.length - 1, iPrefixLength = this.opt.sIconIdPrefix.length; i >= 0; i--)
  1021. if (document.images[i].id.substr(0, iPrefixLength) == this.opt.sIconIdPrefix)
  1022. setOuterHTML(document.images[i], '<div title="' + this.opt.sLabelIconList + '" onclick="' + this.opt.sBackReference + '.openPopup(this, ' + document.images[i].id.substr(iPrefixLength) + ')" onmouseover="' + this.opt.sBackReference + '.onBoxHover(this, true)" onmouseout="' + this.opt.sBackReference + '.onBoxHover(this, false)" style="background: ' + this.opt.sBoxBackground + '; cursor: ' + (is_ie && !is_ie6up ? 'hand' : 'pointer') + '; padding: 3px; text-align: center;"><img src="' + document.images[i].src + '" alt="' + document.images[i].alt + '" id="' + document.images[i].id + '" style="margin: 0px; padding: ' + (is_ie ? '3px' : '3px 0px 3px 0px') + ';" /></div>');
  1023. }
  1024. // Event for the mouse hovering over the original icon.
  1025. IconList.prototype.onBoxHover = function (oDiv, bMouseOver)
  1026. {
  1027. oDiv.style.border = bMouseOver ? this.opt.iBoxBorderWidthHover + 'px solid ' + this.opt.sBoxBorderColorHover : '';
  1028. oDiv.style.background = bMouseOver ? this.opt.sBoxBackgroundHover : this.opt.sBoxBackground;
  1029. oDiv.style.padding = bMouseOver ? (3 - this.opt.iBoxBorderWidthHover) + 'px' : '3px'
  1030. }
  1031. // Show the list of icons after the user clicked the original icon.
  1032. IconList.prototype.openPopup = function (oDiv, iMessageId)
  1033. {
  1034. this.iCurMessageId = iMessageId;
  1035. if (!this.bListLoaded && this.oContainerDiv == null)
  1036. {
  1037. // Create a container div.
  1038. this.oContainerDiv = document.createElement('div');
  1039. this.oContainerDiv.id = 'iconList';
  1040. this.oContainerDiv.style.display = 'none';
  1041. this.oContainerDiv.style.cursor = is_ie && !is_ie6up ? 'hand' : 'pointer';
  1042. this.oContainerDiv.style.position = 'absolute';
  1043. this.oContainerDiv.style.width = oDiv.offsetWidth + 'px';
  1044. this.oContainerDiv.style.background = this.opt.sContainerBackground;
  1045. this.oContainerDiv.style.border = this.opt.sContainerBorder;
  1046. this.oContainerDiv.style.padding = '1px';
  1047. this.oContainerDiv.style.textAlign = 'center';
  1048. document.body.appendChild(this.oContainerDiv);
  1049. // Start to fetch its contents.
  1050. ajax_indicator(true);
  1051. this.tmpMethod = getXMLDocument;
  1052. this.tmpMethod(smf_prepareScriptUrl(this.opt.sScriptUrl) + 'action=xmlhttp;sa=messageicons;board=' + this.opt.iBoardId + ';xml', this.onIconsReceived);
  1053. delete this.tmpMethod;
  1054. createEventListener(document.body);
  1055. }
  1056. // Set the position of the container.
  1057. var aPos = smf_itemPos(oDiv);
  1058. if (is_ie50)
  1059. aPos[1] += 4;
  1060. this.oContainerDiv.style.top = (aPos[1] + oDiv.offsetHeight) + 'px';
  1061. this.oContainerDiv.style.left = (aPos[0] - 1) + 'px';
  1062. this.oClickedIcon = oDiv;
  1063. if (this.bListLoaded)
  1064. this.oContainerDiv.style.display = 'block';
  1065. document.body.addEventListener('mousedown', this.onWindowMouseDown, false);
  1066. }
  1067. // Setup the list of icons once it is received through xmlHTTP.
  1068. IconList.prototype.onIconsReceived = function (oXMLDoc)
  1069. {
  1070. var icons = oXMLDoc.getElementsByTagName('smf')[0].getElementsByTagName('icon');
  1071. var sItems = '';
  1072. for (var i = 0, n = icons.length; i < n; i++)
  1073. sItems += '<div onmouseover="' + this.opt.sBackReference + '.onItemHover(this, true)" onmouseout="' + this.opt.sBackReference + '.onItemHover(this, false);" onmousedown="' + this.opt.sBackReference + '.onItemMouseDown(this, \'' + icons[i].getAttribute('value') + '\');" style="padding: 3px 0px 3px 0px; margin-left: auto; margin-right: auto; border: ' + this.opt.sItemBorder + '; background: ' + this.opt.sItemBackground + '"><img src="' + icons[i].getAttribute('url') + '" alt="' + icons[i].getAttribute('name') + '" title="' + icons[i].firstChild.nodeValue + '" /></div>';
  1074. setInnerHTML(this.oContainerDiv, sItems);
  1075. this.oContainerDiv.style.display = 'block';
  1076. this.bListLoaded = true;
  1077. if (is_ie)
  1078. this.oContainerDiv.style.width = this.oContainerDiv.clientWidth + 'px';
  1079. ajax_indicator(false);
  1080. }
  1081. // Event handler for hovering over the icons.
  1082. IconList.prototype.onItemHover = function (oDiv, bMouseOver)
  1083. {
  1084. oDiv.style.background = bMouseOver ? this.opt.sItemBackgroundHover : this.opt.sItemBackground;
  1085. oDiv.style.border = bMouseOver ? this.opt.sItemBorderHover : this.opt.sItemBorder;
  1086. if (this.iCurTimeout != 0)
  1087. window.clearTimeout(this.iCurTimeout);
  1088. if (bMouseOver)
  1089. this.onBoxHover(this.oClickedIcon, true);
  1090. else
  1091. this.iCurTimeout = window.setTimeout(this.opt.sBackReference + '.collapseList();', 500);
  1092. }
  1093. // Event handler for clicking on one of the icons.
  1094. IconList.prototype.onItemMouseDown = function (oDiv, sNewIcon)
  1095. {
  1096. if (this.iCurMessageId != 0)
  1097. {
  1098. ajax_indicator(true);
  1099. this.tmpMethod = getXMLDocument;
  1100. var oXMLDoc = this.tmpMethod(smf_prepareScriptUrl(this.opt.sScriptUrl) + 'action=jsmodify;topic=' + this.opt.iTopicId + ';msg=' + this.iCurMessageId + ';' + smf_session_var + '=' + smf_session_id + ';icon=' + sNewIcon + ';xml');
  1101. delete this.tmpMethod;
  1102. ajax_indicator(false);
  1103. var oMessage = oXMLDoc.responseXML.getElementsByTagName('smf')[0].getElementsByTagName('message')[0];
  1104. if (oMessage.getElementsByTagName('error').length == 0)
  1105. {
  1106. if (this.opt.bShowModify && oMessage.getElementsByTagName('modified').length != 0)
  1107. setInnerHTML(document.getElementById('modified_' + this.iCurMessageId), oMessage.getElementsByTagName('modified')[0].childNodes[0].nodeValue);
  1108. this.oClickedIcon.getElementsByTagName('img')[0].src = oDiv.getElementsByTagName('img')[0].src;
  1109. }
  1110. }
  1111. }
  1112. // Event handler for clicking outside the list (will make the list disappear).
  1113. IconList.prototype.onWindowMouseDown = function ()
  1114. {
  1115. for (var i = aIconLists.length - 1; i >= 0; i--)
  1116. {
  1117. aIconLists[i].funcParent.tmpMethod = aIconLists[i].collapseList;
  1118. aIconLists[i].funcParent.tmpMethod();
  1119. delete aIconLists[i].funcParent.tmpMethod;
  1120. }
  1121. }
  1122. // Collapse the list of icons.
  1123. IconList.prototype.collapseList = function()
  1124. {
  1125. this.onBoxHover(this.oClickedIcon, false);
  1126. this.oContainerDiv.style.display = 'none';
  1127. this.iCurMessageId = 0;
  1128. document.body.removeEventListener('mousedown', this.onWindowMouseDown, false);
  1129. }
  1130. // Handy shortcuts for getting the mouse position on the screen - only used for IE at the moment.
  1131. function smf_mousePose(oEvent)
  1132. {
  1133. var x = 0;
  1134. var y = 0;
  1135. if (oEvent.pageX)
  1136. {
  1137. y = oEvent.pageY;
  1138. x = oEvent.pageX;
  1139. }
  1140. else if (oEvent.clientX)
  1141. {
  1142. x = oEvent.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
  1143. y = oEvent.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
  1144. }
  1145. return [x, y];
  1146. }
  1147. // Short function for finding the actual position of an item.
  1148. function smf_itemPos(itemHandle)
  1149. {
  1150. var itemX = 0;
  1151. var itemY = 0;
  1152. if ('offsetParent' in itemHandle)
  1153. {
  1154. itemX = itemHandle.offsetLeft;
  1155. itemY = itemHandle.offsetTop;
  1156. while (itemHandle.offsetParent && typeof(itemHandle.offsetParent) == 'object')
  1157. {
  1158. itemHandle = itemHandle.offsetParent;
  1159. itemX += itemHandle.offsetLeft;
  1160. itemY += itemHandle.offsetTop;
  1161. }
  1162. }
  1163. else if ('x' in itemHandle)
  1164. {
  1165. itemX = itemHandle.x;
  1166. itemY = itemHandle.y;
  1167. }
  1168. return [itemX, itemY];
  1169. }
  1170. // This function takes the script URL and prepares it to allow the query string to be appended to it.
  1171. function smf_prepareScriptUrl(sUrl)
  1172. {
  1173. return sUrl.indexOf('?') == -1 ? sUrl + '?' : sUrl + (sUrl.charAt(sUrl.length - 1) == '?' || sUrl.charAt(sUrl.length - 1) == '&' || sUrl.charAt(sUrl.length - 1) == ';' ? '' : ';');
  1174. }
  1175. var aOnloadEvents = new Array();
  1176. function addLoadEvent(fNewOnload)
  1177. {
  1178. // If there's no event set, just set this one
  1179. if (typeof(fNewOnload) == 'function' && (!('onload' in window) || typeof(window.onload) != 'function'))
  1180. window.onload = fNewOnload;
  1181. // If there's just one event, setup the array.
  1182. else if (aOnloadEvents.length == 0)
  1183. {
  1184. aOnloadEvents[0] = window.onload;
  1185. aOnloadEvents[1] = fNewOnload;
  1186. window.onload = function() {
  1187. for (var i = 0, n = aOnloadEvents.length; i < n; i++)
  1188. {
  1189. if (typeof(aOnloadEvents[i]) == 'function')
  1190. aOnloadEvents[i]();
  1191. else if (typeof(aOnloadEvents[i]) == 'string')
  1192. eval(aOnloadEvents[i]);
  1193. }
  1194. }
  1195. }
  1196. // This isn't the first event function, add it to the list.
  1197. else
  1198. aOnloadEvents[aOnloadEvents.length] = fNewOnload;
  1199. }
  1200. function smfFooterHighlight(element, value)
  1201. {
  1202. element.src = smf_images_url + '/' + (value ? 'h_' : '') + element.id + '.png';
  1203. }
  1204. // Get the text in a code tag.
  1205. function smfSelectText(oCurElement, bActOnElement)
  1206. {
  1207. // The place we're looking for is one div up, and next door - if it's auto detect.
  1208. if (typeof(bActOnElement) == 'boolean' && bActOnElement)
  1209. var oCodeArea = document.getElementById(oCurElement);
  1210. else
  1211. var oCodeArea = oCurElement.parentNode.nextSibling;
  1212. if (typeof(oCodeArea) != 'object' || oCodeArea == null)
  1213. return false;
  1214. // Start off with my favourite, internet explorer.
  1215. if ('createTextRange' in document.body)
  1216. {
  1217. var oCurRange = document.body.createTextRange();
  1218. oCurRange.moveToElementText(oCodeArea);
  1219. oCurRange.select();
  1220. }
  1221. // Firefox at el.
  1222. else if (window.getSelection)
  1223. {
  1224. var oCurSelection = window.getSelection();
  1225. // Safari is special!
  1226. if (oCurSelection.setBaseAndExtent)
  1227. {
  1228. var oLastChild = oCodeArea.lastChild;
  1229. oCurSelection.setBaseAndExtent(oCodeArea, 0, oLastChild, 'innerText' in oLastChild ? oLastChild.innerText.length : oLastChild.textContent.length);
  1230. }
  1231. else
  1232. {
  1233. var curRange = document.createRange();
  1234. curRange.selectNodeContents(oCodeArea);
  1235. oCurSelection.removeAllRanges();
  1236. oCurSelection.addRange(curRange);
  1237. }
  1238. }
  1239. return false;
  1240. }
  1241. // A function needed to discern HTML entities from non-western characters.
  1242. function smc_saveEntities(sFormName, aElementNames, sMask)
  1243. {
  1244. if (typeof(sMask) == 'string')
  1245. {
  1246. for (var i = 0, n = document.forms[sFormName].elements.length; i < n; i++)
  1247. if (document.forms[sFormName].elements[i].id.substr(0, sMask.length) == sMask)
  1248. aElementNames[aElementNames.length] = document.forms[sFormName].elements[i].name;
  1249. }
  1250. for (var i = 0, n = aElementNames.length; i < n; i++)
  1251. {
  1252. if (aElementNames[i] in document.forms[sFormName])
  1253. document.forms[sFormName][aElementNames[i]].value = document.forms[sFormName][aElementNames[i]].value.replace(/&#/g, '&#38;#');
  1254. }
  1255. }
  1256. // A function used to clean the attachments on post page
  1257. function cleanFileInput(idElement)
  1258. {
  1259. // Simpler solutions work in Opera, IE, Safari and Chrome.
  1260. if (is_opera || is_ie || is_safari || is_chrome)
  1261. {
  1262. document.getElementById(idElement).outerHTML = document.getElementById(idElement).outerHTML;
  1263. }
  1264. // What else can we do? By the way, this doesn't work in Chrome and Mac's Safari.
  1265. else
  1266. {
  1267. document.getElementById(idElement).type = 'input';
  1268. document.getElementById(idElement).type = 'file';
  1269. }
  1270. }
  1271. function applyWindowClasses(oList)
  1272. {
  1273. var bAlternate = false;
  1274. oListItems = oList.getElementsByTagName("LI");
  1275. for (i = 0; i < oListItems.length; i++)
  1276. {
  1277. // Skip dummies.
  1278. if (oListItems[i].id == "")
  1279. continue;
  1280. oListItems[i].className = "windowbg" + (bAlternate ? "2" : "");
  1281. bAlternate = !bAlternate;
  1282. }
  1283. }
  1284. function reActivate()
  1285. {
  1286. document.forms.postmodify.message.readOnly = false;
  1287. }
  1288. // The actual message icon selector.
  1289. function showimage()
  1290. {
  1291. document.images.icons.src = icon_urls[document.forms.postmodify.icon.options[document.forms.postmodify.icon.selectedIndex].value];
  1292. }
  1293. function pollOptions()
  1294. {
  1295. var expire_time = document.getElementById('poll_expire');
  1296. if (isEmptyText(expire_time) || expire_time.value == 0)
  1297. {
  1298. document.forms.postmodify.poll_hide[2].disabled = true;
  1299. if (document.forms.postmodify.poll_hide[2].checked)
  1300. document.forms.postmodify.poll_hide[1].checked = true;
  1301. }
  1302. else
  1303. document.forms.postmodify.poll_hide[2].disabled = false;
  1304. }
  1305. function generateDays(offset)
  1306. {
  1307. // Work around JavaScript's lack of support for default values...
  1308. offset = typeof(offset) != 'undefined' ? offset : 0;
  1309. var days = 0, selected = 0;
  1310. var dayElement = document.getElementById("day" + offset), yearElement = document.getElementById("year" + offset), monthElement = document.getElementById("month" + offset);
  1311. monthLength[1] = 28;
  1312. if (yearElement.options[yearElement.selectedIndex].value % 4 == 0)
  1313. monthLength[1] = 29;
  1314. selected = dayElement.selectedIndex;
  1315. while (dayElement.options.length)
  1316. dayElement.options[0] = null;
  1317. days = monthLength[monthElement.value - 1];
  1318. for (i = 1; i <= days; i++)
  1319. dayElement.options[dayElement.length] = new Option(i, i);
  1320. if (selected < days)
  1321. dayElement.selectedIndex = selected;
  1322. }
  1323. function toggleLinked(form)
  1324. {
  1325. form.board.disabled = !form.link_to_board.checked;
  1326. }
  1327. function initSearch()
  1328. {
  1329. if (document.forms.searchform.search.value.indexOf("%u") != -1)
  1330. document.forms.searchform.search.value = unescape(document.forms.searchform.search.value);
  1331. }
  1332. function selectBoards(ids, aFormID)
  1333. {
  1334. var toggle = true;
  1335. var aForm = document.getElementById(aFormID);
  1336. for (i = 0; i < ids.length; i++)
  1337. toggle = toggle & aForm["brd" + ids[i]].checked;
  1338. for (i = 0; i < ids.length; i++)
  1339. aForm["brd" + ids[i]].checked = !toggle;
  1340. }
  1341. function expandCollapseBoards()
  1342. {
  1343. var current = document.getElementById("searchBoardsExpand").style.display != "none";
  1344. document.getElementById("searchBoardsExpand").style.display = current ? "none" : "";
  1345. document.getElementById("expandBoardsIcon").src = smf_images_url + (current ? "/expand.png" : "/collapse.png");
  1346. }
  1347. function expandCollapseLabels()
  1348. {
  1349. var current = document.getElementById("searchLabelsExpand").style.display != "none";
  1350. document.getElementById("searchLabelsExpand").style.display = current ? "none" : "";
  1351. document.getElementById("expandLabelsIcon").src = smf_images_url + (current ? "/expand.png" : "/collapse.png");
  1352. }
  1353. function updateRuleDef(optNum)
  1354. {
  1355. if (document.getElementById("ruletype" + optNum).value == "gid")
  1356. {
  1357. document.getElementById("defdiv" + optNum).style.display = "none";
  1358. document.getElementById("defseldiv" + optNum).style.display = "";
  1359. }
  1360. else if (document.getElementById("ruletype" + optNum).value == "bud" || document.getElementById("ruletype" + optNum).value == "")
  1361. {
  1362. document.getElementById("defdiv" + optNum).style.display = "none";
  1363. document.getElementById("defseldiv" + optNum).style.display = "none";
  1364. }
  1365. else
  1366. {
  1367. document.getElementById("defdiv" + optNum).style.display = "";
  1368. document.getElementById("defseldiv" + optNum).style.display = "none";
  1369. }
  1370. }
  1371. function updateActionDef(optNum)
  1372. {
  1373. if (document.getElementById("acttype" + optNum).value == "lab")
  1374. {
  1375. document.getElementById("labdiv" + optNum).style.display = "";
  1376. }
  1377. else
  1378. {
  1379. document.getElementById("labdiv" + optNum).style.display = "none";
  1380. }
  1381. }
  1382. function smfSetLatestPackages()
  1383. {
  1384. if (typeof(window.smfLatestPackages) != "undefined")
  1385. setInnerHTML(document.getElementById("packagesLatest"), window.smfLatestPackages);
  1386. if (tempOldOnload)
  1387. tempOldOnload();
  1388. }
  1389. function updateAuthMethod()
  1390. {
  1391. // What authentication method is being used?
  1392. if (!document.getElementById("auth_openid") || !document.getElementById("auth_openid").checked)
  1393. currentAuthMethod = "passwd";
  1394. else
  1395. currentAuthMethod = "openid";
  1396. // No openID?
  1397. if (!document.getElementById("auth_openid"))
  1398. return true;
  1399. document.forms.creator.openid_url.disabled = currentAuthMethod == "openid" ? false : true;
  1400. document.forms.creator.smf_autov_pwmain.disabled = currentAuthMethod == "passwd" ? false : true;
  1401. document.forms.creator.smf_autov_pwverify.disabled = currentAuthMethod == "passwd" ? false : true;
  1402. document.getElementById("smf_autov_pwmain_div").style.display = currentAuthMethod == "passwd" ? "" : "none";
  1403. document.getElementById("smf_autov_pwverify_div").style.display = currentAuthMethod == "passwd" ? "" : "none";
  1404. if (currentAuthMethod == "passwd")
  1405. {
  1406. verificationHandle.refreshMainPassword();
  1407. verificationHandle.refreshVerifyPassword();
  1408. document.forms.creator.openid_url.style.backgroundColor = "";
  1409. document.getElementById("auth_openid_div").style.display = "none";
  1410. document.getElementById("auth_pass_div").style.display = "";
  1411. }
  1412. else
  1413. {
  1414. document.forms.creator.smf_autov_pwmain.style.backgroundColor ="";
  1415. document.forms.creator.smf_autov_pwverify.style.backgroundColor = "";
  1416. document.forms.creator.openid_url.style.backgroundColor = "#FCE184";
  1417. document.getElementById("auth_openid_div").style.display = "";
  1418. document.getElementById("auth_pass_div").style.display = "none";
  1419. }
  1420. }