script.js 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607
  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. // Remember the current position.
  288. function storeCaret(oTextHandle)
  289. {
  290. // Only bother if it will be useful.
  291. if ('createTextRange' in oTextHandle)
  292. oTextHandle.caretPos = document.selection.createRange().duplicate();
  293. }
  294. // Replaces the currently selected text with the passed text.
  295. function replaceText(text, oTextHandle)
  296. {
  297. // Attempt to create a text range (IE).
  298. if ('caretPos' in oTextHandle && 'createTextRange' in oTextHandle)
  299. {
  300. var caretPos = oTextHandle.caretPos;
  301. caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
  302. caretPos.select();
  303. }
  304. // Mozilla text range replace.
  305. else if ('selectionStart' in oTextHandle)
  306. {
  307. var begin = oTextHandle.value.substr(0, oTextHandle.selectionStart);
  308. var end = oTextHandle.value.substr(oTextHandle.selectionEnd);
  309. var scrollPos = oTextHandle.scrollTop;
  310. oTextHandle.value = begin + text + end;
  311. if (oTextHandle.setSelectionRange)
  312. {
  313. oTextHandle.focus();
  314. var goForward = is_opera ? text.match(/\n/g).length : 0;
  315. oTextHandle.setSelectionRange(begin.length + text.length + goForward, begin.length + text.length + goForward);
  316. }
  317. oTextHandle.scrollTop = scrollPos;
  318. }
  319. // Just put it on the end.
  320. else
  321. {
  322. oTextHandle.value += text;
  323. oTextHandle.focus(oTextHandle.value.length - 1);
  324. }
  325. }
  326. // Surrounds the selected text with text1 and text2.
  327. function surroundText(text1, text2, oTextHandle)
  328. {
  329. // Can a text range be created?
  330. if ('caretPos' in oTextHandle && 'createTextRange' in oTextHandle)
  331. {
  332. var caretPos = oTextHandle.caretPos, temp_length = caretPos.text.length;
  333. caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text1 + caretPos.text + text2 + ' ' : text1 + caretPos.text + text2;
  334. if (temp_length == 0)
  335. {
  336. caretPos.moveStart('character', -text2.length);
  337. caretPos.moveEnd('character', -text2.length);
  338. caretPos.select();
  339. }
  340. else
  341. oTextHandle.focus(caretPos);
  342. }
  343. // Mozilla text range wrap.
  344. else if ('selectionStart' in oTextHandle)
  345. {
  346. var begin = oTextHandle.value.substr(0, oTextHandle.selectionStart);
  347. var selection = oTextHandle.value.substr(oTextHandle.selectionStart, oTextHandle.selectionEnd - oTextHandle.selectionStart);
  348. var end = oTextHandle.value.substr(oTextHandle.selectionEnd);
  349. var newCursorPos = oTextHandle.selectionStart;
  350. var scrollPos = oTextHandle.scrollTop;
  351. oTextHandle.value = begin + text1 + selection + text2 + end;
  352. if (oTextHandle.setSelectionRange)
  353. {
  354. var goForward = is_opera ? text1.match(/\n/g).length : 0, goForwardAll = is_opera ? (text1 + text2).match(/\n/g).length : 0;
  355. if (selection.length == 0)
  356. oTextHandle.setSelectionRange(newCursorPos + text1.length + goForward, newCursorPos + text1.length + goForward);
  357. else
  358. oTextHandle.setSelectionRange(newCursorPos, newCursorPos + text1.length + selection.length + text2.length + goForwardAll);
  359. oTextHandle.focus();
  360. }
  361. oTextHandle.scrollTop = scrollPos;
  362. }
  363. // Just put them on the end, then.
  364. else
  365. {
  366. oTextHandle.value += text1 + text2;
  367. oTextHandle.focus(oTextHandle.value.length - 1);
  368. }
  369. }
  370. // Checks if the passed input's value is nothing.
  371. function isEmptyText(theField)
  372. {
  373. // Copy the value so changes can be made..
  374. var theValue = theField.value;
  375. // Strip whitespace off the left side.
  376. while (theValue.length > 0 && (theValue.charAt(0) == ' ' || theValue.charAt(0) == '\t'))
  377. theValue = theValue.substring(1, theValue.length);
  378. // Strip whitespace off the right side.
  379. while (theValue.length > 0 && (theValue.charAt(theValue.length - 1) == ' ' || theValue.charAt(theValue.length - 1) == '\t'))
  380. theValue = theValue.substring(0, theValue.length - 1);
  381. if (theValue == '')
  382. return true;
  383. else
  384. return false;
  385. }
  386. // Only allow form submission ONCE.
  387. function submitonce(theform)
  388. {
  389. smf_formSubmitted = true;
  390. // If there are any editors warn them submit is coming!
  391. for (var i = 0; i < smf_editorArray.length; i++)
  392. smf_editorArray[i].doSubmit();
  393. }
  394. function submitThisOnce(oControl)
  395. {
  396. // Hateful, hateful fix for Safari 1.3 beta.
  397. if (is_safari)
  398. return !smf_formSubmitted;
  399. // oControl might also be a form.
  400. var oForm = 'form' in oControl ? oControl.form : oControl;
  401. var aTextareas = oForm.getElementsByTagName('textarea');
  402. for (var i = 0, n = aTextareas.length; i < n; i++)
  403. aTextareas[i].readOnly = true;
  404. return !smf_formSubmitted;
  405. }
  406. // Deprecated, as innerHTML is supported everywhere.
  407. function setInnerHTML(oElement, sToValue)
  408. {
  409. oElement.innerHTML = sToValue;
  410. }
  411. function getInnerHTML(oElement)
  412. {
  413. return oElement.innerHTML;
  414. }
  415. // Set the "outer" HTML of an element.
  416. function setOuterHTML(oElement, sToValue)
  417. {
  418. if ('outerHTML' in oElement)
  419. oElement.outerHTML = sToValue;
  420. else
  421. {
  422. var range = document.createRange();
  423. range.setStartBefore(oElement);
  424. oElement.parentNode.replaceChild(range.createContextualFragment(sToValue), oElement);
  425. }
  426. }
  427. // Checks for variable in theArray.
  428. function in_array(variable, theArray)
  429. {
  430. for (var i in theArray)
  431. if (theArray[i] == variable)
  432. return true;
  433. return false;
  434. }
  435. // Checks for variable in theArray.
  436. function array_search(variable, theArray)
  437. {
  438. for (var i in theArray)
  439. if (theArray[i] == variable)
  440. return i;
  441. return null;
  442. }
  443. // Find a specific radio button in its group and select it.
  444. function selectRadioByName(oRadioGroup, sName)
  445. {
  446. if (!('length' in oRadioGroup))
  447. return oRadioGroup.checked = true;
  448. for (var i = 0, n = oRadioGroup.length; i < n; i++)
  449. if (oRadioGroup[i].value == sName)
  450. return oRadioGroup[i].checked = true;
  451. return false;
  452. }
  453. function selectAllRadio(oInvertCheckbox, oForm, sMask, sValue)
  454. {
  455. for (var i = 0; i < oForm.length; i++)
  456. if (oForm[i].name != undefined && oForm[i].name.substr(0, sMask.length) == sMask && oForm[i].value == sValue)
  457. oForm[i].checked = true;
  458. }
  459. // Invert all checkboxes at once by clicking a single checkbox.
  460. function invertAll(oInvertCheckbox, oForm, sMask, bIgnoreDisabled)
  461. {
  462. for (var i = 0; i < oForm.length; i++)
  463. {
  464. if (!('name' in oForm[i]) || (typeof(sMask) == 'string' && oForm[i].name.substr(0, sMask.length) != sMask && oForm[i].id.substr(0, sMask.length) != sMask))
  465. continue;
  466. if (!oForm[i].disabled || (typeof(bIgnoreDisabled) == 'boolean' && bIgnoreDisabled))
  467. oForm[i].checked = oInvertCheckbox.checked;
  468. }
  469. }
  470. // Keep the session alive - always!
  471. var lastKeepAliveCheck = new Date().getTime();
  472. function smf_sessionKeepAlive()
  473. {
  474. var curTime = new Date().getTime();
  475. // Prevent a Firefox bug from hammering the server.
  476. if (smf_scripturl && curTime - lastKeepAliveCheck > 900000)
  477. {
  478. var tempImage = new Image();
  479. tempImage.src = smf_prepareScriptUrl(smf_scripturl) + 'action=keepalive;time=' + curTime;
  480. lastKeepAliveCheck = curTime;
  481. }
  482. window.setTimeout('smf_sessionKeepAlive();', 1200000);
  483. }
  484. window.setTimeout('smf_sessionKeepAlive();', 1200000);
  485. // Set a theme option through javascript.
  486. function smf_setThemeOption(option, value, theme, cur_session_id, cur_session_var, additional_vars)
  487. {
  488. // Compatibility.
  489. if (cur_session_id == null)
  490. cur_session_id = smf_session_id;
  491. if (typeof(cur_session_var) == 'undefined')
  492. cur_session_var = 'sesc';
  493. if (additional_vars == null)
  494. additional_vars = '';
  495. var tempImage = new Image();
  496. 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());
  497. }
  498. function smf_avatarResize()
  499. {
  500. var possibleAvatars = document.getElementsByTagName('img');
  501. for (var i = 0; i < possibleAvatars.length; i++)
  502. {
  503. var tempAvatars = []; j = 0;
  504. if (possibleAvatars[i].className != 'avatar')
  505. continue;
  506. // Image.prototype.avatar = possibleAvatars[i];
  507. tempAvatars[j] = new Image();
  508. tempAvatars[j].avatar = possibleAvatars[i];
  509. tempAvatars[j].onload = function()
  510. {
  511. this.avatar.width = this.width;
  512. this.avatar.height = this.height;
  513. if (smf_avatarMaxWidth != 0 && this.width > smf_avatarMaxWidth)
  514. {
  515. this.avatar.height = (smf_avatarMaxWidth * this.height) / this.width;
  516. this.avatar.width = smf_avatarMaxWidth;
  517. }
  518. if (smf_avatarMaxHeight != 0 && this.avatar.height > smf_avatarMaxHeight)
  519. {
  520. this.avatar.width = (smf_avatarMaxHeight * this.avatar.width) / this.avatar.height;
  521. this.avatar.height = smf_avatarMaxHeight;
  522. }
  523. }
  524. tempAvatars[j].src = possibleAvatars[i].src;
  525. j++;
  526. }
  527. if (typeof(window_oldAvatarOnload) != 'undefined' && window_oldAvatarOnload)
  528. {
  529. window_oldAvatarOnload();
  530. window_oldAvatarOnload = null;
  531. }
  532. }
  533. function hashLoginPassword(doForm, cur_session_id)
  534. {
  535. // Compatibility.
  536. if (cur_session_id == null)
  537. cur_session_id = smf_session_id;
  538. if (typeof(hex_sha1) == 'undefined')
  539. return;
  540. // Are they using an email address?
  541. if (doForm.user.value.indexOf('@') != -1)
  542. return;
  543. // Unless the browser is Opera, the password will not save properly.
  544. if (!('opera' in window))
  545. doForm.passwrd.autocomplete = 'off';
  546. doForm.hash_passwrd.value = hex_sha1(hex_sha1(doForm.user.value.php_to8bit().php_strtolower() + doForm.passwrd.value.php_to8bit()) + cur_session_id);
  547. // It looks nicer to fill it with asterisks, but Firefox will try to save that.
  548. if (is_ff != -1)
  549. doForm.passwrd.value = '';
  550. else
  551. doForm.passwrd.value = doForm.passwrd.value.replace(/./g, '*');
  552. }
  553. function hashAdminPassword(doForm, username, cur_session_id)
  554. {
  555. // Compatibility.
  556. if (cur_session_id == null)
  557. cur_session_id = smf_session_id;
  558. if (typeof(hex_sha1) == 'undefined')
  559. return;
  560. doForm.admin_hash_pass.value = hex_sha1(hex_sha1(username.php_to8bit().php_strtolower() + doForm.admin_pass.value.php_to8bit()) + cur_session_id);
  561. doForm.admin_pass.value = doForm.admin_pass.value.replace(/./g, '*');
  562. }
  563. function hashModeratePassword(doForm, username, cur_session_id)
  564. {
  565. if (typeof(hex_sha1) == 'undefined')
  566. return;
  567. doForm.moderate_hash_pass.value = hex_sha1(hex_sha1(username.php_to8bit().php_strtolower() + doForm.moderate_pass.value.php_to8bit()) + cur_session_id);
  568. doForm.moderate_pass.value = doForm.moderate_pass.value.replace(/./g, '*');
  569. }
  570. // Shows the page numbers by clicking the dots (in compact view).
  571. function expandPages(spanNode, baseURL, firstPage, lastPage, perPage)
  572. {
  573. var replacement = '', i, oldLastPage = 0;
  574. var perPageLimit = 50;
  575. // The dots were bold, the page numbers are not (in most cases).
  576. spanNode.style.fontWeight = 'normal';
  577. spanNode.onclick = '';
  578. // Prevent too many pages to be loaded at once.
  579. if ((lastPage - firstPage) / perPage > perPageLimit)
  580. {
  581. oldLastPage = lastPage;
  582. lastPage = firstPage + perPageLimit * perPage;
  583. }
  584. // Calculate the new pages.
  585. for (i = firstPage; i < lastPage; i += perPage)
  586. replacement += '<a class="navPages" href="' + baseURL.replace(/%1\$d/, i).replace(/%%/g, '%') + '">' + (1 + i / perPage) + '</a> ';
  587. if (oldLastPage > 0)
  588. replacement += '<span style="font-weight: bold; cursor: ' + (is_ie && !is_ie6up ? 'hand' : 'pointer') + ';" onclick="expandPages(this, \'' + baseURL + '\', ' + lastPage + ', ' + oldLastPage + ', ' + perPage + ');"> ... </span> ';
  589. // Replace the dots by the new page links.
  590. setInnerHTML(spanNode, replacement);
  591. }
  592. function smc_preCacheImage(sSrc)
  593. {
  594. if (!('smc_aCachedImages' in window))
  595. window.smc_aCachedImages = [];
  596. if (!in_array(sSrc, window.smc_aCachedImages))
  597. {
  598. var oImage = new Image();
  599. oImage.src = sSrc;
  600. }
  601. }
  602. // *** smc_Cookie class.
  603. function smc_Cookie(oOptions)
  604. {
  605. this.opt = oOptions;
  606. this.oCookies = {};
  607. this.init();
  608. }
  609. smc_Cookie.prototype.init = function()
  610. {
  611. if ('cookie' in document && document.cookie != '')
  612. {
  613. var aCookieList = document.cookie.split(';');
  614. for (var i = 0, n = aCookieList.length; i < n; i++)
  615. {
  616. var aNameValuePair = aCookieList[i].split('=');
  617. this.oCookies[aNameValuePair[0].replace(/^\s+|\s+$/g, '')] = decodeURIComponent(aNameValuePair[1]);
  618. }
  619. }
  620. }
  621. smc_Cookie.prototype.get = function(sKey)
  622. {
  623. return sKey in this.oCookies ? this.oCookies[sKey] : null;
  624. }
  625. smc_Cookie.prototype.set = function(sKey, sValue)
  626. {
  627. document.cookie = sKey + '=' + encodeURIComponent(sValue);
  628. }
  629. // *** smc_Toggle class.
  630. function smc_Toggle(oOptions)
  631. {
  632. this.opt = oOptions;
  633. this.bCollapsed = false;
  634. this.oCookie = null;
  635. this.init();
  636. }
  637. smc_Toggle.prototype.init = function ()
  638. {
  639. // The master switch can disable this toggle fully.
  640. if ('bToggleEnabled' in this.opt && !this.opt.bToggleEnabled)
  641. return;
  642. // If cookies are enabled and they were set, override the initial state.
  643. if ('oCookieOptions' in this.opt && this.opt.oCookieOptions.bUseCookie)
  644. {
  645. // Initialize the cookie handler.
  646. this.oCookie = new smc_Cookie({});
  647. // Check if the cookie is set.
  648. var cookieValue = this.oCookie.get(this.opt.oCookieOptions.sCookieName)
  649. if (cookieValue != null)
  650. this.opt.bCurrentlyCollapsed = cookieValue == '1';
  651. }
  652. // If the init state is set to be collapsed, collapse it.
  653. if (this.opt.bCurrentlyCollapsed)
  654. this.changeState(true, true);
  655. // Initialize the images to be clickable.
  656. if ('aSwapImages' in this.opt)
  657. {
  658. for (var i = 0, n = this.opt.aSwapImages.length; i < n; i++)
  659. {
  660. var oImage = document.getElementById(this.opt.aSwapImages[i].sId);
  661. if (typeof(oImage) == 'object' && oImage != null)
  662. {
  663. // Display the image in case it was hidden.
  664. if (oImage.style.display == 'none')
  665. oImage.style.display = '';
  666. oImage.instanceRef = this;
  667. oImage.onclick = function () {
  668. this.instanceRef.toggle();
  669. this.blur();
  670. }
  671. oImage.style.cursor = 'pointer';
  672. // Preload the collapsed image.
  673. smc_preCacheImage(this.opt.aSwapImages[i].srcCollapsed);
  674. }
  675. }
  676. }
  677. // Initialize links.
  678. if ('aSwapLinks' in this.opt)
  679. {
  680. for (var i = 0, n = this.opt.aSwapLinks.length; i < n; i++)
  681. {
  682. var oLink = document.getElementById(this.opt.aSwapLinks[i].sId);
  683. if (typeof(oLink) == 'object' && oLink != null)
  684. {
  685. // Display the link in case it was hidden.
  686. if (oLink.style.display == 'none')
  687. oLink.style.display = '';
  688. oLink.instanceRef = this;
  689. oLink.onclick = function () {
  690. this.instanceRef.toggle();
  691. this.blur();
  692. return false;
  693. }
  694. }
  695. }
  696. }
  697. }
  698. // Collapse or expand the section.
  699. smc_Toggle.prototype.changeState = function(bCollapse, bInit)
  700. {
  701. // Default bInit to false.
  702. bInit = typeof(bInit) == 'undefined' ? false : true;
  703. // Handle custom function hook before collapse.
  704. if (!bInit && bCollapse && 'funcOnBeforeCollapse' in this.opt)
  705. {
  706. this.tmpMethod = this.opt.funcOnBeforeCollapse;
  707. this.tmpMethod();
  708. delete this.tmpMethod;
  709. }
  710. // Handle custom function hook before expand.
  711. else if (!bInit && !bCollapse && 'funcOnBeforeExpand' in this.opt)
  712. {
  713. this.tmpMethod = this.opt.funcOnBeforeExpand;
  714. this.tmpMethod();
  715. delete this.tmpMethod;
  716. }
  717. // Loop through all the images that need to be toggled.
  718. if ('aSwapImages' in this.opt)
  719. {
  720. for (var i = 0, n = this.opt.aSwapImages.length; i < n; i++)
  721. {
  722. var oImage = document.getElementById(this.opt.aSwapImages[i].sId);
  723. if (typeof(oImage) == 'object' && oImage != null)
  724. {
  725. // Only (re)load the image if it's changed.
  726. var sTargetSource = bCollapse ? this.opt.aSwapImages[i].srcCollapsed : this.opt.aSwapImages[i].srcExpanded;
  727. if (oImage.src != sTargetSource)
  728. oImage.src = sTargetSource;
  729. oImage.alt = oImage.title = bCollapse ? this.opt.aSwapImages[i].altCollapsed : this.opt.aSwapImages[i].altExpanded;
  730. }
  731. }
  732. }
  733. // Loop through all the links that need to be toggled.
  734. if ('aSwapLinks' in this.opt)
  735. {
  736. for (var i = 0, n = this.opt.aSwapLinks.length; i < n; i++)
  737. {
  738. var oLink = document.getElementById(this.opt.aSwapLinks[i].sId);
  739. if (typeof(oLink) == 'object' && oLink != null)
  740. setInnerHTML(oLink, bCollapse ? this.opt.aSwapLinks[i].msgCollapsed : this.opt.aSwapLinks[i].msgExpanded);
  741. }
  742. }
  743. // Now go through all the sections to be collapsed.
  744. for (var i = 0, n = this.opt.aSwappableContainers.length; i < n; i++)
  745. {
  746. if (this.opt.aSwappableContainers[i] == null)
  747. continue;
  748. var oContainer = document.getElementById(this.opt.aSwappableContainers[i]);
  749. if (typeof(oContainer) == 'object' && oContainer != null)
  750. oContainer.style.display = bCollapse ? 'none' : '';
  751. }
  752. // Update the new state.
  753. this.bCollapsed = bCollapse;
  754. // Update the cookie, if desired.
  755. if ('oCookieOptions' in this.opt && this.opt.oCookieOptions.bUseCookie)
  756. this.oCookie.set(this.opt.oCookieOptions.sCookieName, this.bCollapsed ? '1' : '0');
  757. if (!bInit && 'oThemeOptions' in this.opt && this.opt.oThemeOptions.bUseThemeSettings)
  758. 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);
  759. }
  760. smc_Toggle.prototype.toggle = function()
  761. {
  762. // Change the state by reversing the current state.
  763. this.changeState(!this.bCollapsed);
  764. }
  765. function ajax_indicator(turn_on)
  766. {
  767. if (ajax_indicator_ele == null)
  768. {
  769. ajax_indicator_ele = document.getElementById('ajax_in_progress');
  770. if (ajax_indicator_ele == null && typeof(ajax_notification_text) != null)
  771. {
  772. create_ajax_indicator_ele();
  773. }
  774. }
  775. if (ajax_indicator_ele != null)
  776. {
  777. if (navigator.appName == 'Microsoft Internet Explorer' && !is_ie7up)
  778. {
  779. ajax_indicator_ele.style.position = 'absolute';
  780. ajax_indicator_ele.style.top = document.documentElement.scrollTop;
  781. }
  782. ajax_indicator_ele.style.display = turn_on ? 'block' : 'none';
  783. }
  784. }
  785. function create_ajax_indicator_ele()
  786. {
  787. // Create the div for the indicator.
  788. ajax_indicator_ele = document.createElement('div');
  789. // Set the id so it'll load the style properly.
  790. ajax_indicator_ele.id = 'ajax_in_progress';
  791. // Add the image in and link to turn it off.
  792. var cancel_link = document.createElement('a');
  793. cancel_link.href = 'javascript:ajax_indicator(false)';
  794. var cancel_img = document.createElement('img');
  795. cancel_img.src = smf_images_url + '/icons/quick_remove.png';
  796. if (typeof(ajax_notification_cancel_text) != 'undefined')
  797. {
  798. cancel_img.alt = ajax_notification_cancel_text;
  799. cancel_img.title = ajax_notification_cancel_text;
  800. }
  801. // Add the cancel link and image to the indicator.
  802. cancel_link.appendChild(cancel_img);
  803. ajax_indicator_ele.appendChild(cancel_link);
  804. // Set the text. (Note: You MUST append here and not overwrite.)
  805. ajax_indicator_ele.innerHTML += ajax_notification_text;
  806. // Finally attach the element to the body.
  807. document.body.appendChild(ajax_indicator_ele);
  808. }
  809. function createEventListener(oTarget)
  810. {
  811. if (!('addEventListener' in oTarget))
  812. {
  813. if (oTarget.attachEvent)
  814. {
  815. oTarget.addEventListener = function (sEvent, funcHandler, bCapture) {
  816. oTarget.attachEvent('on' + sEvent, funcHandler);
  817. }
  818. oTarget.removeEventListener = function (sEvent, funcHandler, bCapture) {
  819. oTarget.detachEvent('on' + sEvent, funcHandler);
  820. }
  821. }
  822. else
  823. {
  824. oTarget.addEventListener = function (sEvent, funcHandler, bCapture) {
  825. oTarget['on' + sEvent] = funcHandler;
  826. }
  827. oTarget.removeEventListener = function (sEvent, funcHandler, bCapture) {
  828. oTarget['on' + sEvent] = null;
  829. }
  830. }
  831. }
  832. }
  833. // This function will retrieve the contents needed for the jump to boxes.
  834. function grabJumpToContent()
  835. {
  836. var oXMLDoc = getXMLDocument(smf_prepareScriptUrl(smf_scripturl) + 'action=xmlhttp;sa=jumpto;xml');
  837. var aBoardsAndCategories = new Array();
  838. ajax_indicator(true);
  839. if (oXMLDoc.responseXML)
  840. {
  841. var items = oXMLDoc.responseXML.getElementsByTagName('smf')[0].getElementsByTagName('item');
  842. for (var i = 0, n = items.length; i < n; i++)
  843. {
  844. aBoardsAndCategories[aBoardsAndCategories.length] = {
  845. id: parseInt(items[i].getAttribute('id')),
  846. isCategory: items[i].getAttribute('type') == 'category',
  847. name: items[i].firstChild.nodeValue.removeEntities(),
  848. is_current: false,
  849. childLevel: parseInt(items[i].getAttribute('childlevel'))
  850. }
  851. }
  852. }
  853. ajax_indicator(false);
  854. for (var i = 0, n = aJumpTo.length; i < n; i++)
  855. aJumpTo[i].fillSelect(aBoardsAndCategories);
  856. }
  857. // This'll contain all JumpTo objects on the page.
  858. var aJumpTo = new Array();
  859. // *** JumpTo class.
  860. function JumpTo(oJumpToOptions)
  861. {
  862. this.opt = oJumpToOptions;
  863. this.dropdownList = null;
  864. this.showSelect();
  865. }
  866. // Show the initial select box (onload). Method of the JumpTo class.
  867. JumpTo.prototype.showSelect = function ()
  868. {
  869. var sChildLevelPrefix = '';
  870. for (var i = this.opt.iCurBoardChildLevel; i > 0; i--)
  871. sChildLevelPrefix += this.opt.sBoardChildLevelIndicator;
  872. 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\';" />'));
  873. this.dropdownList = document.getElementById(this.opt.sContainerId + '_select');
  874. }
  875. // Fill the jump to box with entries. Method of the JumpTo class.
  876. JumpTo.prototype.fillSelect = function (aBoardsAndCategories)
  877. {
  878. var bIE5x = !('implementation' in document);
  879. var iIndexPointer = 0;
  880. // Create an option that'll be above and below the category.
  881. var oDashOption = document.createElement('option');
  882. oDashOption.appendChild(document.createTextNode(this.opt.sCatSeparator));
  883. oDashOption.disabled = 'disabled';
  884. oDashOption.value = '';
  885. // Reset the events and clear the list (IE5.x only).
  886. if (bIE5x)
  887. {
  888. this.dropdownList.onmouseover = null;
  889. this.dropdownList.remove(0);
  890. }
  891. if ('onbeforeactivate' in document)
  892. this.dropdownList.onbeforeactivate = null;
  893. else
  894. this.dropdownList.onfocus = null;
  895. // Create a document fragment that'll allowing inserting big parts at once.
  896. var oListFragment = bIE5x ? this.dropdownList : document.createDocumentFragment();
  897. // Loop through all items to be added.
  898. for (var i = 0, n = aBoardsAndCategories.length; i < n; i++)
  899. {
  900. var j, sChildLevelPrefix, oOption;
  901. // If we've reached the currently selected board add all items so far.
  902. if (!aBoardsAndCategories[i].isCategory && aBoardsAndCategories[i].id == this.opt.iCurBoardId)
  903. {
  904. if (bIE5x)
  905. iIndexPointer = this.dropdownList.options.length;
  906. else
  907. {
  908. this.dropdownList.insertBefore(oListFragment, this.dropdownList.options[0]);
  909. oListFragment = document.createDocumentFragment();
  910. continue;
  911. }
  912. }
  913. if (aBoardsAndCategories[i].isCategory)
  914. oListFragment.appendChild(oDashOption.cloneNode(true));
  915. else
  916. for (j = aBoardsAndCategories[i].childLevel, sChildLevelPrefix = ''; j > 0; j--)
  917. sChildLevelPrefix += this.opt.sBoardChildLevelIndicator;
  918. oOption = document.createElement('option');
  919. oOption.appendChild(document.createTextNode((aBoardsAndCategories[i].isCategory ? this.opt.sCatPrefix : sChildLevelPrefix + this.opt.sBoardPrefix) + aBoardsAndCategories[i].name));
  920. oOption.value = aBoardsAndCategories[i].isCategory ? '#c' + aBoardsAndCategories[i].id : '?board=' + aBoardsAndCategories[i].id + '.0';
  921. oListFragment.appendChild(oOption);
  922. if (aBoardsAndCategories[i].isCategory)
  923. oListFragment.appendChild(oDashOption.cloneNode(true));
  924. }
  925. // Add the remaining items after the currently selected item.
  926. this.dropdownList.appendChild(oListFragment);
  927. if (bIE5x)
  928. this.dropdownList.options[iIndexPointer].selected = true;
  929. // Internet Explorer needs this to keep the box dropped down.
  930. this.dropdownList.style.width = 'auto';
  931. this.dropdownList.focus();
  932. // Add an onchange action
  933. this.dropdownList.onchange = function() {
  934. if (this.selectedIndex > 0 && this.options[this.selectedIndex].value)
  935. 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);
  936. }
  937. }
  938. // A global array containing all IconList objects.
  939. var aIconLists = new Array();
  940. // *** IconList object.
  941. function IconList(oOptions)
  942. {
  943. if (!window.XMLHttpRequest)
  944. return;
  945. this.opt = oOptions;
  946. this.bListLoaded = false;
  947. this.oContainerDiv = null;
  948. this.funcMousedownHandler = null;
  949. this.funcParent = this;
  950. this.iCurMessageId = 0;
  951. this.iCurTimeout = 0;
  952. // Add backwards compatibility with old themes.
  953. if (!('sSessionVar' in this.opt))
  954. this.opt.sSessionVar = 'sesc';
  955. this.initIcons();
  956. }
  957. // Replace all message icons by icons with hoverable and clickable div's.
  958. IconList.prototype.initIcons = function ()
  959. {
  960. for (var i = document.images.length - 1, iPrefixLength = this.opt.sIconIdPrefix.length; i >= 0; i--)
  961. if (document.images[i].id.substr(0, iPrefixLength) == this.opt.sIconIdPrefix)
  962. 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>');
  963. }
  964. // Event for the mouse hovering over the original icon.
  965. IconList.prototype.onBoxHover = function (oDiv, bMouseOver)
  966. {
  967. oDiv.style.border = bMouseOver ? this.opt.iBoxBorderWidthHover + 'px solid ' + this.opt.sBoxBorderColorHover : '';
  968. oDiv.style.background = bMouseOver ? this.opt.sBoxBackgroundHover : this.opt.sBoxBackground;
  969. oDiv.style.padding = bMouseOver ? (3 - this.opt.iBoxBorderWidthHover) + 'px' : '3px'
  970. }
  971. // Show the list of icons after the user clicked the original icon.
  972. IconList.prototype.openPopup = function (oDiv, iMessageId)
  973. {
  974. this.iCurMessageId = iMessageId;
  975. if (!this.bListLoaded && this.oContainerDiv == null)
  976. {
  977. // Create a container div.
  978. this.oContainerDiv = document.createElement('div');
  979. this.oContainerDiv.id = 'iconList';
  980. this.oContainerDiv.style.display = 'none';
  981. this.oContainerDiv.style.cursor = is_ie && !is_ie6up ? 'hand' : 'pointer';
  982. this.oContainerDiv.style.position = 'absolute';
  983. this.oContainerDiv.style.width = oDiv.offsetWidth + 'px';
  984. this.oContainerDiv.style.background = this.opt.sContainerBackground;
  985. this.oContainerDiv.style.border = this.opt.sContainerBorder;
  986. this.oContainerDiv.style.padding = '1px';
  987. this.oContainerDiv.style.textAlign = 'center';
  988. document.body.appendChild(this.oContainerDiv);
  989. // Start to fetch its contents.
  990. ajax_indicator(true);
  991. this.tmpMethod = getXMLDocument;
  992. this.tmpMethod(smf_prepareScriptUrl(this.opt.sScriptUrl) + 'action=xmlhttp;sa=messageicons;board=' + this.opt.iBoardId + ';xml', this.onIconsReceived);
  993. delete this.tmpMethod;
  994. createEventListener(document.body);
  995. }
  996. // Set the position of the container.
  997. var aPos = smf_itemPos(oDiv);
  998. if (is_ie50)
  999. aPos[1] += 4;
  1000. this.oContainerDiv.style.top = (aPos[1] + oDiv.offsetHeight) + 'px';
  1001. this.oContainerDiv.style.left = (aPos[0] - 1) + 'px';
  1002. this.oClickedIcon = oDiv;
  1003. if (this.bListLoaded)
  1004. this.oContainerDiv.style.display = 'block';
  1005. document.body.addEventListener('mousedown', this.onWindowMouseDown, false);
  1006. }
  1007. // Setup the list of icons once it is received through xmlHTTP.
  1008. IconList.prototype.onIconsReceived = function (oXMLDoc)
  1009. {
  1010. var icons = oXMLDoc.getElementsByTagName('smf')[0].getElementsByTagName('icon');
  1011. var sItems = '';
  1012. for (var i = 0, n = icons.length; i < n; i++)
  1013. 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>';
  1014. setInnerHTML(this.oContainerDiv, sItems);
  1015. this.oContainerDiv.style.display = 'block';
  1016. this.bListLoaded = true;
  1017. if (is_ie)
  1018. this.oContainerDiv.style.width = this.oContainerDiv.clientWidth + 'px';
  1019. ajax_indicator(false);
  1020. }
  1021. // Event handler for hovering over the icons.
  1022. IconList.prototype.onItemHover = function (oDiv, bMouseOver)
  1023. {
  1024. oDiv.style.background = bMouseOver ? this.opt.sItemBackgroundHover : this.opt.sItemBackground;
  1025. oDiv.style.border = bMouseOver ? this.opt.sItemBorderHover : this.opt.sItemBorder;
  1026. if (this.iCurTimeout != 0)
  1027. window.clearTimeout(this.iCurTimeout);
  1028. if (bMouseOver)
  1029. this.onBoxHover(this.oClickedIcon, true);
  1030. else
  1031. this.iCurTimeout = window.setTimeout(this.opt.sBackReference + '.collapseList();', 500);
  1032. }
  1033. // Event handler for clicking on one of the icons.
  1034. IconList.prototype.onItemMouseDown = function (oDiv, sNewIcon)
  1035. {
  1036. if (this.iCurMessageId != 0)
  1037. {
  1038. ajax_indicator(true);
  1039. this.tmpMethod = getXMLDocument;
  1040. 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');
  1041. delete this.tmpMethod;
  1042. ajax_indicator(false);
  1043. var oMessage = oXMLDoc.responseXML.getElementsByTagName('smf')[0].getElementsByTagName('message')[0];
  1044. if (oMessage.getElementsByTagName('error').length == 0)
  1045. {
  1046. if (this.opt.bShowModify && oMessage.getElementsByTagName('modified').length != 0)
  1047. setInnerHTML(document.getElementById('modified_' + this.iCurMessageId), oMessage.getElementsByTagName('modified')[0].childNodes[0].nodeValue);
  1048. this.oClickedIcon.getElementsByTagName('img')[0].src = oDiv.getElementsByTagName('img')[0].src;
  1049. }
  1050. }
  1051. }
  1052. // Event handler for clicking outside the list (will make the list disappear).
  1053. IconList.prototype.onWindowMouseDown = function ()
  1054. {
  1055. for (var i = aIconLists.length - 1; i >= 0; i--)
  1056. {
  1057. aIconLists[i].funcParent.tmpMethod = aIconLists[i].collapseList;
  1058. aIconLists[i].funcParent.tmpMethod();
  1059. delete aIconLists[i].funcParent.tmpMethod;
  1060. }
  1061. }
  1062. // Collapse the list of icons.
  1063. IconList.prototype.collapseList = function()
  1064. {
  1065. this.onBoxHover(this.oClickedIcon, false);
  1066. this.oContainerDiv.style.display = 'none';
  1067. this.iCurMessageId = 0;
  1068. document.body.removeEventListener('mousedown', this.onWindowMouseDown, false);
  1069. }
  1070. // Handy shortcuts for getting the mouse position on the screen - only used for IE at the moment.
  1071. function smf_mousePose(oEvent)
  1072. {
  1073. var x = 0;
  1074. var y = 0;
  1075. if (oEvent.pageX)
  1076. {
  1077. y = oEvent.pageY;
  1078. x = oEvent.pageX;
  1079. }
  1080. else if (oEvent.clientX)
  1081. {
  1082. x = oEvent.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
  1083. y = oEvent.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
  1084. }
  1085. return [x, y];
  1086. }
  1087. // Short function for finding the actual position of an item.
  1088. function smf_itemPos(itemHandle)
  1089. {
  1090. var itemX = 0;
  1091. var itemY = 0;
  1092. if ('offsetParent' in itemHandle)
  1093. {
  1094. itemX = itemHandle.offsetLeft;
  1095. itemY = itemHandle.offsetTop;
  1096. while (itemHandle.offsetParent && typeof(itemHandle.offsetParent) == 'object')
  1097. {
  1098. itemHandle = itemHandle.offsetParent;
  1099. itemX += itemHandle.offsetLeft;
  1100. itemY += itemHandle.offsetTop;
  1101. }
  1102. }
  1103. else if ('x' in itemHandle)
  1104. {
  1105. itemX = itemHandle.x;
  1106. itemY = itemHandle.y;
  1107. }
  1108. return [itemX, itemY];
  1109. }
  1110. // This function takes the script URL and prepares it to allow the query string to be appended to it.
  1111. function smf_prepareScriptUrl(sUrl)
  1112. {
  1113. return sUrl.indexOf('?') == -1 ? sUrl + '?' : sUrl + (sUrl.charAt(sUrl.length - 1) == '?' || sUrl.charAt(sUrl.length - 1) == '&' || sUrl.charAt(sUrl.length - 1) == ';' ? '' : ';');
  1114. }
  1115. var aOnloadEvents = new Array();
  1116. function addLoadEvent(fNewOnload)
  1117. {
  1118. // If there's no event set, just set this one
  1119. if (typeof(fNewOnload) == 'function' && (!('onload' in window) || typeof(window.onload) != 'function'))
  1120. window.onload = fNewOnload;
  1121. // If there's just one event, setup the array.
  1122. else if (aOnloadEvents.length == 0)
  1123. {
  1124. aOnloadEvents[0] = window.onload;
  1125. aOnloadEvents[1] = fNewOnload;
  1126. window.onload = function() {
  1127. for (var i = 0, n = aOnloadEvents.length; i < n; i++)
  1128. {
  1129. if (typeof(aOnloadEvents[i]) == 'function')
  1130. aOnloadEvents[i]();
  1131. else if (typeof(aOnloadEvents[i]) == 'string')
  1132. eval(aOnloadEvents[i]);
  1133. }
  1134. }
  1135. }
  1136. // This isn't the first event function, add it to the list.
  1137. else
  1138. aOnloadEvents[aOnloadEvents.length] = fNewOnload;
  1139. }
  1140. function smfFooterHighlight(element, value)
  1141. {
  1142. element.src = smf_images_url + '/' + (value ? 'h_' : '') + element.id + '.png';
  1143. }
  1144. // Get the text in a code tag.
  1145. function smfSelectText(oCurElement, bActOnElement)
  1146. {
  1147. // The place we're looking for is one div up, and next door - if it's auto detect.
  1148. if (typeof(bActOnElement) == 'boolean' && bActOnElement)
  1149. var oCodeArea = document.getElementById(oCurElement);
  1150. else
  1151. var oCodeArea = oCurElement.parentNode.nextSibling;
  1152. if (typeof(oCodeArea) != 'object' || oCodeArea == null)
  1153. return false;
  1154. // Start off with my favourite, internet explorer.
  1155. if ('createTextRange' in document.body)
  1156. {
  1157. var oCurRange = document.body.createTextRange();
  1158. oCurRange.moveToElementText(oCodeArea);
  1159. oCurRange.select();
  1160. }
  1161. // Firefox at el.
  1162. else if (window.getSelection)
  1163. {
  1164. var oCurSelection = window.getSelection();
  1165. // Safari is special!
  1166. if (oCurSelection.setBaseAndExtent)
  1167. {
  1168. var oLastChild = oCodeArea.lastChild;
  1169. oCurSelection.setBaseAndExtent(oCodeArea, 0, oLastChild, 'innerText' in oLastChild ? oLastChild.innerText.length : oLastChild.textContent.length);
  1170. }
  1171. else
  1172. {
  1173. var curRange = document.createRange();
  1174. curRange.selectNodeContents(oCodeArea);
  1175. oCurSelection.removeAllRanges();
  1176. oCurSelection.addRange(curRange);
  1177. }
  1178. }
  1179. return false;
  1180. }
  1181. // A function needed to discern HTML entities from non-western characters.
  1182. function smc_saveEntities(sFormName, aElementNames, sMask)
  1183. {
  1184. if (typeof(sMask) == 'string')
  1185. {
  1186. for (var i = 0, n = document.forms[sFormName].elements.length; i < n; i++)
  1187. if (document.forms[sFormName].elements[i].id.substr(0, sMask.length) == sMask)
  1188. aElementNames[aElementNames.length] = document.forms[sFormName].elements[i].name;
  1189. }
  1190. for (var i = 0, n = aElementNames.length; i < n; i++)
  1191. {
  1192. if (aElementNames[i] in document.forms[sFormName])
  1193. document.forms[sFormName][aElementNames[i]].value = document.forms[sFormName][aElementNames[i]].value.replace(/&#/g, '&#38;#');
  1194. }
  1195. }
  1196. // A function used to clean the attachments on post page
  1197. function cleanFileInput(idElement)
  1198. {
  1199. // Simpler solutions work in Opera, IE, Safari and Chrome.
  1200. if (is_opera || is_ie || is_safari || is_chrome)
  1201. {
  1202. document.getElementById(idElement).outerHTML = document.getElementById(idElement).outerHTML;
  1203. }
  1204. // What else can we do? By the way, this doesn't work in Chrome and Mac's Safari.
  1205. else
  1206. {
  1207. document.getElementById(idElement).type = 'input';
  1208. document.getElementById(idElement).type = 'file';
  1209. }
  1210. }
  1211. function applyWindowClasses(oList)
  1212. {
  1213. var bAlternate = false;
  1214. oListItems = oList.getElementsByTagName("LI");
  1215. for (i = 0; i < oListItems.length; i++)
  1216. {
  1217. // Skip dummies.
  1218. if (oListItems[i].id == "")
  1219. continue;
  1220. oListItems[i].className = "windowbg" + (bAlternate ? "2" : "");
  1221. bAlternate = !bAlternate;
  1222. }
  1223. }
  1224. function reActivate()
  1225. {
  1226. document.forms.postmodify.message.readOnly = false;
  1227. }
  1228. // The actual message icon selector.
  1229. function showimage()
  1230. {
  1231. document.images.icons.src = icon_urls[document.forms.postmodify.icon.options[document.forms.postmodify.icon.selectedIndex].value];
  1232. }
  1233. function pollOptions()
  1234. {
  1235. var expire_time = document.getElementById('poll_expire');
  1236. if (isEmptyText(expire_time) || expire_time.value == 0)
  1237. {
  1238. document.forms.postmodify.poll_hide[2].disabled = true;
  1239. if (document.forms.postmodify.poll_hide[2].checked)
  1240. document.forms.postmodify.poll_hide[1].checked = true;
  1241. }
  1242. else
  1243. document.forms.postmodify.poll_hide[2].disabled = false;
  1244. }
  1245. function generateDays(offset)
  1246. {
  1247. // Work around JavaScript's lack of support for default values...
  1248. offset = typeof(offset) != 'undefined' ? offset : 0;
  1249. var days = 0, selected = 0;
  1250. var dayElement = document.getElementById("day" + offset), yearElement = document.getElementById("year" + offset), monthElement = document.getElementById("month" + offset);
  1251. monthLength[1] = 28;
  1252. if (yearElement.options[yearElement.selectedIndex].value % 4 == 0)
  1253. monthLength[1] = 29;
  1254. selected = dayElement.selectedIndex;
  1255. while (dayElement.options.length)
  1256. dayElement.options[0] = null;
  1257. days = monthLength[monthElement.value - 1];
  1258. for (i = 1; i <= days; i++)
  1259. dayElement.options[dayElement.length] = new Option(i, i);
  1260. if (selected < days)
  1261. dayElement.selectedIndex = selected;
  1262. }
  1263. function toggleLinked(form)
  1264. {
  1265. form.board.disabled = !form.link_to_board.checked;
  1266. }
  1267. function initSearch()
  1268. {
  1269. if (document.forms.searchform.search.value.indexOf("%u") != -1)
  1270. document.forms.searchform.search.value = unescape(document.forms.searchform.search.value);
  1271. }
  1272. function selectBoards(ids, aFormID)
  1273. {
  1274. var toggle = true;
  1275. var aForm = document.getElementById(aFormID);
  1276. for (i = 0; i < ids.length; i++)
  1277. toggle = toggle & aForm["brd" + ids[i]].checked;
  1278. for (i = 0; i < ids.length; i++)
  1279. aForm["brd" + ids[i]].checked = !toggle;
  1280. }
  1281. function expandCollapseBoards()
  1282. {
  1283. var current = document.getElementById("searchBoardsExpand").style.display != "none";
  1284. document.getElementById("searchBoardsExpand").style.display = current ? "none" : "";
  1285. document.getElementById("expandBoardsIcon").src = smf_images_url + (current ? "/expand.png" : "/collapse.png");
  1286. }
  1287. function expandCollapseLabels()
  1288. {
  1289. var current = document.getElementById("searchLabelsExpand").style.display != "none";
  1290. document.getElementById("searchLabelsExpand").style.display = current ? "none" : "";
  1291. document.getElementById("expandLabelsIcon").src = smf_images_url + (current ? "/expand.png" : "/collapse.png");
  1292. }
  1293. function updateRuleDef(optNum)
  1294. {
  1295. if (document.getElementById("ruletype" + optNum).value == "gid")
  1296. {
  1297. document.getElementById("defdiv" + optNum).style.display = "none";
  1298. document.getElementById("defseldiv" + optNum).style.display = "";
  1299. }
  1300. else if (document.getElementById("ruletype" + optNum).value == "bud" || document.getElementById("ruletype" + optNum).value == "")
  1301. {
  1302. document.getElementById("defdiv" + optNum).style.display = "none";
  1303. document.getElementById("defseldiv" + optNum).style.display = "none";
  1304. }
  1305. else
  1306. {
  1307. document.getElementById("defdiv" + optNum).style.display = "";
  1308. document.getElementById("defseldiv" + optNum).style.display = "none";
  1309. }
  1310. }
  1311. function updateActionDef(optNum)
  1312. {
  1313. if (document.getElementById("acttype" + optNum).value == "lab")
  1314. {
  1315. document.getElementById("labdiv" + optNum).style.display = "";
  1316. }
  1317. else
  1318. {
  1319. document.getElementById("labdiv" + optNum).style.display = "none";
  1320. }
  1321. }
  1322. function smfSetLatestPackages()
  1323. {
  1324. if (typeof(window.smfLatestPackages) != "undefined")
  1325. setInnerHTML(document.getElementById("packagesLatest"), window.smfLatestPackages);
  1326. if (tempOldOnload)
  1327. tempOldOnload();
  1328. }
  1329. function updateAuthMethod()
  1330. {
  1331. // What authentication method is being used?
  1332. if (!document.getElementById("auth_openid") || !document.getElementById("auth_openid").checked)
  1333. currentAuthMethod = "passwd";
  1334. else
  1335. currentAuthMethod = "openid";
  1336. // No openID?
  1337. if (!document.getElementById("auth_openid"))
  1338. return true;
  1339. document.forms.creator.openid_url.disabled = currentAuthMethod == "openid" ? false : true;
  1340. document.forms.creator.smf_autov_pwmain.disabled = currentAuthMethod == "passwd" ? false : true;
  1341. document.forms.creator.smf_autov_pwverify.disabled = currentAuthMethod == "passwd" ? false : true;
  1342. document.getElementById("smf_autov_pwmain_div").style.display = currentAuthMethod == "passwd" ? "" : "none";
  1343. document.getElementById("smf_autov_pwverify_div").style.display = currentAuthMethod == "passwd" ? "" : "none";
  1344. if (currentAuthMethod == "passwd")
  1345. {
  1346. verificationHandle.refreshMainPassword();
  1347. verificationHandle.refreshVerifyPassword();
  1348. document.forms.creator.openid_url.style.backgroundColor = "";
  1349. document.getElementById("auth_openid_div").style.display = "none";
  1350. document.getElementById("auth_pass_div").style.display = "";
  1351. }
  1352. else
  1353. {
  1354. document.forms.creator.smf_autov_pwmain.style.backgroundColor ="";
  1355. document.forms.creator.smf_autov_pwverify.style.backgroundColor = "";
  1356. document.forms.creator.openid_url.style.backgroundColor = "#FCE184";
  1357. document.getElementById("auth_openid_div").style.display = "";
  1358. document.getElementById("auth_pass_div").style.display = "none";
  1359. }
  1360. }