script.js 53 KB

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