1. /**
  2. * Inferno Shoutbox Javascript Engine
  3. * Created By Inferno Technologies
  4. * All Rights Reserved
  5. * * * * * * * * * * * * * * *
  6. */
  7. _ishout = function()
  8. {
  9. this.newestbottom = 0;
  10. this.script = '';
  11. this.editor = '';
  12. this.loader = '';
  13. this.notice = '';
  14. this.parsebreaker = '<<~~PARSE_^_BREAKER~~>>';
  15. this.activity = '';
  16. this.noticemessage = '';
  17. this.shoutframe = '';
  18. this.userframe = '';
  19. this.styleprops = '';
  20. this.styleprop = new Object;
  21. this.fetchshout = new Object;
  22. this.fetchusers = new Object;
  23. this.fetchrules = new Object;
  24. this.editshout = new Object;
  25. this.fetchsmilies = new Object;
  26. this.fetchashout = new Object;
  27. this.fetchaop = new Object;
  28. this.editshoutform = '';
  29. this.editshouteditor = '';
  30. this.smiliesbox = '';
  31. this.smiliesrow = '';
  32. this.shout = new Object;
  33. this.idle = false;
  34. this.idletimelimit = 0;
  35. this.loaded = false;
  36. this.idletime = 0;
  37. this.floodtime = 0;
  38. this.fetchingsmilies = false;
  39. this.showing = 'shoutbox';
  40. this.detached = false;
  41. this.aop = false;
  42. this.aoptime = -1;
  43. this.refreshspeed = 0;
  44. this.styleproperties = {
  45. 'fontWeight' : ['bold', false],
  46. 'textDecoration' : ['underline', false],
  47. 'fontStyle' : ['italic', false]
  48. };
  49. this.initiate = function(thisscript, idletime, dobold, doitalic, dounderline, newestbottom, floodtime, shoutheight, refreshspeed)
  50. {
  51. this.newestbottom = parseInt(newestbottom);
  52. this.editor = fetch_object('vbshout_pro_shoutbox_editor');
  53. this.notice = fetch_object('shoutbox_notice');
  54. this.noticemessage = fetch_object('shoutbox_notice_message');
  55. this.userframe = fetch_object('shoutbox_users_frame');
  56. this.editshouteditor = fetch_object('shoutbox_editshout');
  57. this.editshoutform = document.forms['editshoutform'];
  58. this.smiliesbox = fetch_object('shoutbox_smilies');
  59. this.smiliesrow = fetch_object('shoutbox_smilies_row');
  60. this.tabs = fetch_object('vbshout_pro_tabs');
  61. this.shoutwindow = fetch_object('shoutbox_window');
  62. this.tabhistory = new Array();
  63. this.shoutheight = shoutheight;
  64. this.refresh_speed = refreshspeed;
  65. this.append_tab('<a href="?" onclick="return InfernoShoutbox.show(\'shoutbox\');">Shoutbox</a>');
  66. this.append_tab('<a href="?" onclick="return InfernoShoutbox.show(\'activeusers\');">Active Users</a>: <span id="shoutbox_activity">0</span>');
  67. if (RULES.length > 0) {
  68. this.append_tab('<a href="?" onclick="return InfernoShoutbox.show(\'sb_rules\');">Shoutbox Rules</a>');
  69. }
  70. this.activity = fetch_object('shoutbox_activity');
  71. this.floodtime = floodtime;
  72. this.script = thisscript;
  73. this.load_editor_settings(parseInt(dobold), parseInt(doitalic), parseInt(dounderline));
  74. this.idletimelimit = idletime;
  75. this.idlecheck();
  76. this.set_shout_params('shoutbox_frame', '', '', '');
  77. this.fetch_shouts();
  78. if (this.aop)
  79. {
  80. this.get_shouts = setInterval("InfernoShoutbox.fetch_aop();", refreshspeed);
  81. }
  82. else
  83. {
  84. this.get_shouts = setInterval("InfernoShoutbox.fetch_shouts();", refreshspeed);
  85. }
  86. }
  87. this.load_editor_settings = function(dobold, doitalic, dounderline)
  88. {
  89. if (fetch_object('sb_color_mem'))
  90. {
  91. this.adjust_property_selection('color', fetch_object('sb_color_mem'), false);
  92. }
  93. if (fetch_object('sb_font_mem'))
  94. {
  95. this.adjust_property_selection('fontFamily', fetch_object('sb_font_mem'), false);
  96. }
  97. if (dobold && fetch_object('sb_mem_bold'))
  98. {
  99. this.adjust_property('fontWeight', this.styleproperties['fontWeight'][0], fetch_object('sb_mem_bold'), false);
  100. }
  101. if (doitalic && fetch_object('sb_mem_italic'))
  102. {
  103. this.adjust_property('fontStyle', this.styleproperties['fontStyle'][0], fetch_object('sb_mem_italic'), false);
  104. }
  105. if (dounderline && fetch_object('sb_mem_underline'))
  106. {
  107. this.adjust_property('textDecoration', this.styleproperties['textDecoration'][0], fetch_object('sb_mem_underline'), false);
  108. }
  109. }
  110. this.clear = function()
  111. {
  112. this.editor.value = '';
  113. }
  114. this.assign_styleprop = function(prop, sobj)
  115. {
  116. switch (prop)
  117. {
  118. case 'fontWeight':
  119. case 'textDecoration':
  120. case 'fontStyle':
  121. {
  122. this.adjust_property(prop, this.styleproperties[prop][0], sobj, true);
  123. return false;
  124. }
  125. case 'color':
  126. case 'fontFamily':
  127. {
  128. this.adjust_property_selection(prop, sobj, true);
  129. return false;
  130. }
  131. }
  132. }
  133. this.adjust_property_selection = function(property, sobj, update)
  134. {
  135. value = sobj.options[sobj.options.selectedIndex].value;
  136. if (!this.styleproperties[property])
  137. {
  138. this.styleproperties[property] = [];
  139. }
  140. this.styleproperties[property][1] = value;
  141. eval('this.editor.style.' + property + ' = "' + value + '";');
  142. if (update)
  143. {
  144. this.update_styleprops();
  145. }
  146. }
  147. this.adjust_property = function(property, value, sobj, update)
  148. {
  149. sobj.value = sobj.value + '*';
  150. if (this.styleproperties[property][1])
  151. {
  152. value = '';
  153. sobj.value = sobj.value.replace(/\*/g, '');
  154. }
  155. this.styleproperties[property][1] = !this.styleproperties[property][1];
  156. eval('this.editor.style.' + property + ' = "' + value + '";');
  157. if (update)
  158. {
  159. this.update_styleprops();
  160. }
  161. }
  162. this.set_shout_params = function(windowid, shoutprefix, shoutsuffix, fetchtype)
  163. {
  164. this.shout_params = new Object;
  165. this.shout_params.prefix = shoutprefix;
  166. this.shout_params.suffix = shoutsuffix;
  167. this.shout_params.fetchtype = fetchtype;
  168. this.shoutframe = fetch_object(windowid);
  169. }
  170. this.shout = function()
  171. {
  172. if (this.posting_shout)
  173. {
  174. this.show_notice('A previous message is still being submitted...please wait.');
  175. return false;
  176. }
  177. if (this.idle)
  178. {
  179. this.hide_notice();
  180. }
  181. this.idle = false;
  182. this.idletime = 0;
  183. message = PHP.trim(this.editor.value);
  184. if (message == '')
  185. {
  186. this.show_notice('Please enter a message first!');
  187. return false;
  188. }
  189. message = this.shout_params.prefix + message + this.shout_params.suffix;
  190. this.posting_shout = true;
  191. this.set_loader('');
  192. this.shout.ajax = new vB_AJAX_Handler(true);
  193. this.shout.ajax.onreadystatechange(InfernoShoutbox.shout_posted);
  194. this.shout.ajax.send('infernoshout.php', 'do=shout&message=' + PHP.urlencode(message));
  195. this.clear();
  196. return false;
  197. }
  198. this.unidle = function()
  199. {
  200. this.idletime = 0;
  201. this.idle = false;
  202. this.hide_notice();
  203. return false;
  204. }
  205. this.idlecheck = function()
  206. {
  207. if (this.idle || this.idletime > this.idletimelimit)
  208. {
  209. setTimeout("InfernoShoutbox.idlecheck()", 1000);
  210. return false;
  211. }
  212. this.idletime++;
  213. if (this.idletime > this.idletimelimit)
  214. {
  215. this.idle = true;
  216. }
  217. setTimeout("InfernoShoutbox.idlecheck()", 1000);
  218. }
  219. this.shout_posted = function()
  220. {
  221. ajax = InfernoShoutbox.shout.ajax;
  222. if (ajax.handler.readyState == 4 && ajax.handler.status == 200)
  223. {
  224. if (PHP.trim(ajax.handler.responseText) == 'completed')
  225. {
  226. InfernoShoutbox.force_fetch = true;
  227. InfernoShoutbox.fetch_shouts();
  228. }
  229. else if(PHP.trim(ajax.handler.responseText) == 'flood')
  230. {
  231. InfernoShoutbox.show_notice('You must wait ' + InfernoShoutbox.floodtime + ' second(s) between shouts.');
  232. InfernoShoutbox.posting_shout = false;
  233. }
  234. else
  235. {
  236. InfernoShoutbox.show_notice('Your shout failed to send.');
  237. InfernoShoutbox.posting_shout = false;
  238. }
  239. }
  240. }
  241. this.update_styleprops = function()
  242. {
  243. this.set_loader('');
  244. var bold = this.styleproperties['fontWeight'][1] ? 1 : 0;
  245. var italic = this.styleproperties['fontStyle'][1] ? 1 : 0;
  246. var underline = this.styleproperties['textDecoration'][1] ? 1 : 0;
  247. var colour = '';
  248. var fontfamily = '';
  249. if (this.styleproperties['color'])
  250. {
  251. colour = this.styleproperties['color'][1];
  252. }
  253. if (this.styleproperties['fontFamily'])
  254. {
  255. fontfamily = this.styleproperties['fontFamily'][1];
  256. }
  257. styleproperties = new Array(
  258. 'bold=' + bold,
  259. 'italic=' + italic,
  260. 'underline=' + underline,
  261. 'colour=' + colour,
  262. 'fontfamily=' + fontfamily
  263. );
  264. styleproperties = styleproperties.join('&');
  265. this.styleprop.ajax = new vB_AJAX_Handler(true);
  266. this.styleprop.ajax.onreadystatechange(InfernoShoutbox.styleprops_updated);
  267. this.styleprop.ajax.send('infernoshout.php', 'do=styleprops&' + styleproperties);
  268. }
  269. this.styleprops_updated = function()
  270. {
  271. ajax = InfernoShoutbox.styleprop.ajax;
  272. if (ajax.handler.readyState == 4 && ajax.handler.status == 200)
  273. {
  274. InfernoShoutbox.set_loader('none');
  275. InfernoShoutbox.show_notice('Your style properties have been updated.');
  276. }
  277. }
  278. this.fetch_aop = function()
  279. {
  280. if (this.fetching_aop)
  281. {
  282. if (this.failure_count('fetching_aop'))
  283. {
  284. this.fetching_aop = false;
  285. }
  286. return false;
  287. }
  288. if (InfernoShoutbox.new_aoptime)
  289. {
  290. this.fetch_shouts();
  291. return false;
  292. }
  293. this.fetching_aop = true;
  294. if (!this.fetchaop.ajax)
  295. {
  296. this.fetchaop.ajax = new vB_AJAX_Handler(true);
  297. this.fetchaop.ajax.onreadystatechange(InfernoShoutbox.fetch_aop_done);
  298. }
  299. this.fetchaop.ajax.send('infernoshout/aop/aop.php', '');
  300. }
  301. this.fetch_aop_done = function()
  302. {
  303. ajax = InfernoShoutbox.fetchaop.ajax;
  304. InfernoShoutbox.fetching_aop = false;
  305. if (ajax.handler.readyState == 4 && ajax.handler.status == 200)
  306. {
  307. new_aop_time = parseInt(ajax.handler.responseText);
  308. if (new_aop_time > InfernoShoutbox.aoptime)
  309. {
  310. InfernoShoutbox.new_aoptime = new_aop_time;
  311. InfernoShoutbox.fetch_shouts();
  312. }
  313. }
  314. }
  315. this.fetch_shouts = function()
  316. {
  317. if (this.posting_shout && !this.force_fetch)
  318. {
  319. if (this.failure_count('posting_shout'))
  320. {
  321. this.posting_shout = false;
  322. }
  323. return false;
  324. }
  325. if (this.fetching_shouts)
  326. {
  327. if (this.failure_count('fetching_shouts'))
  328. {
  329. this.fetching_shouts = false;
  330. }
  331. return false;
  332. }
  333. if (this.idle && this.loaded)
  334. {
  335. this.show_notice('You are currently idle in the shoutbox. Click <a href="?" onclick="return InfernoShoutbox.unidle();">HERE</a> to un-idle yourself.');
  336. clearTimeout(InfernoShoutbox.kill_notice); // Don't hide this notice
  337. return false;
  338. }
  339. this.fetching_shouts = true;
  340. this.force_fetch = false;
  341. this.loaded = true;
  342. this.set_loader('');
  343. this.fetchshout.ajax = new vB_AJAX_Handler(true);
  344. this.fetchshout.ajax.onreadystatechange(InfernoShoutbox.fetch_shouts_completed);
  345. this.fetchshout.ajax.send('infernoshout.php', 'do=messages' + ((this.detached) ? '&detach=true' : '') + '&fetchtype=' + this.shout_params.fetchtype);
  346. }
  347. this.fetch_shouts_completed = function()
  348. {
  349. ajax = InfernoShoutbox.fetchshout.ajax;
  350. if (ajax.handler.readyState == 4 && ajax.handler.status == 200)
  351. {
  352. data = ajax.handler.responseXML.documentElement;
  353. data = data.getElementsByTagName('data')[0].firstChild.data;
  354. data = data.split(InfernoShoutbox.parsebreaker);
  355. InfernoShoutbox.update_shouts(PHP.trim(data[0]));
  356. if (data[1])
  357. {
  358. InfernoShoutbox.activity.innerHTML = PHP.trim(data[1]);
  359. }
  360. // Posting a shout now finishes here, when shouts have been refetched
  361. if (InfernoShoutbox.posting_shout)
  362. {
  363. InfernoShoutbox.posting_shout = false;
  364. }
  365. InfernoShoutbox.set_loader('none');
  366. InfernoShoutbox.fetching_shouts = false;
  367. if (InfernoShoutbox.new_aoptime)
  368. {
  369. InfernoShoutbox.aoptime = InfernoShoutbox.new_aoptime;
  370. InfernoShoutbox.new_aoptime = false;
  371. }
  372. }
  373. }
  374. this.update_shouts = function(shouts)
  375. {
  376. this.shoutframe.innerHTML = '';
  377. this.shoutframe.innerHTML = shouts;
  378. if (this.newestbottom && this.shoutframe.scrollTop < this.shoutframe.scrollHeight)
  379. {
  380. this.shoutframe.scrollTop = this.shoutframe.scrollHeight;
  381. }
  382. }
  383. this.set_loader = function(set)
  384. {
  385. //this.loader.style.display = set;
  386. }
  387. this.show_notice = function(message)
  388. {
  389. clearTimeout(InfernoShoutbox.kill_notice);
  390. InfernoShoutbox.kill_notice = setTimeout("InfernoShoutbox.hide_notice()", 5000);
  391. this.noticemessage.innerHTML = message;
  392. this.notice.style.display = '';
  393. }
  394. this.hide_notice = function()
  395. {
  396. this.notice.style.display = 'none';
  397. }
  398. this.show = function(what)
  399. {
  400. if (what == this.showing)
  401. {
  402. return false;
  403. }
  404. if (what == 'shoutbox')
  405. {
  406. this.goto_pm_window('shoutbox_frame');
  407. //this.shoutframe.style.display = 'block';
  408. this.userframe.style.display = 'none';
  409. }
  410. else if (what == 'activeusers')
  411. {
  412. this.fetch_users();
  413. this.shoutframe.style.display = 'none';
  414. this.userframe.style.display = 'block';
  415. }
  416. else if (what == 'sb_rules')
  417. {
  418. this.fetch_rules();
  419. this.shoutframe.style.display = 'none';
  420. this.userframe.style.display = 'block';
  421. }
  422. else
  423. {
  424. this.fetch_users();
  425. this.shoutframe.style.display = 'none';
  426. this.userframe.style.display = 'block';
  427. }
  428. this.showing = what;
  429. return false;
  430. }
  431. this.fetch_rules = function()
  432. {
  433. this.set_loader('');
  434. this.fetchrules.ajax = new vB_AJAX_Handler(true);
  435. this.fetchrules.ajax.onreadystatechange(InfernoShoutbox.fetch_rules_completed);
  436. this.fetchrules.ajax.send('infernoshout.php', 'do=sb_rules');
  437. }
  438. this.fetch_rules_completed = function()
  439. {
  440. ajax = InfernoShoutbox.fetchrules.ajax;
  441. if (ajax.handler.readyState == 4 && ajax.handler.status == 200)
  442. {
  443. InfernoShoutbox.userframe.innerHTML = RULES.replace(/\n/g, '<br />');
  444. InfernoShoutbox.set_loader('none');
  445. }
  446. }
  447. this.fetch_users = function()
  448. {
  449. this.set_loader('');
  450. this.fetchusers.ajax = new vB_AJAX_Handler(true);
  451. this.fetchusers.ajax.onreadystatechange(InfernoShoutbox.fetch_users_completed);
  452. this.fetchusers.ajax.send('infernoshout.php', 'do=userlist');
  453. }
  454. this.fetch_users_completed = function()
  455. {
  456. ajax = InfernoShoutbox.fetchusers.ajax;
  457. if (ajax.handler.readyState == 4 && ajax.handler.status == 200)
  458. {
  459. InfernoShoutbox.userframe.innerHTML = ajax.handler.responseText;
  460. InfernoShoutbox.set_loader('none');
  461. }
  462. }
  463. this.pm_user = function(username)
  464. {
  465. this.editor.value = '/pm ' + username + '; Your message here';
  466. return false;
  467. }
  468. this.edit_shout = function(shoutid)
  469. {
  470. this.posting_shout = true;
  471. this.editshout.ajax = new vB_AJAX_Handler(true);
  472. this.editshout.ajax.onreadystatechange(InfernoShoutbox.edit_shout_fetched);
  473. this.editshout.ajax.send('infernoshout.php', 'do=editshout&shoutid=' + shoutid);
  474. this.set_loader('');
  475. return false;
  476. }
  477. this.edit_shout_fetched = function()
  478. {
  479. ajax = InfernoShoutbox.editshout.ajax;
  480. if (ajax.handler.readyState == 4 && ajax.handler.status == 200)
  481. {
  482. InfernoShoutbox.set_loader('none');
  483. data = ajax.handler.responseXML.documentElement;
  484. data = data.getElementsByTagName('data')[0].firstChild.data;
  485. if (data != 'deny')
  486. {
  487. InfernoShoutbox.show_edit_shout(data.split(InfernoShoutbox.parsebreaker));
  488. }
  489. else
  490. {
  491. InfernoShoutbox.posting_shout = false;
  492. }
  493. }
  494. }
  495. this.show_edit_shout = function(data)
  496. {
  497. theshout = PHP.trim(data[0]);
  498. shoutid = parseInt(data[1]);
  499. if (this.archive)
  500. {
  501. fetch_object('shout_' + shoutid).style.display = 'none';
  502. fetch_object('shout_edit_' + shoutid).style.display = '';
  503. fetch_tags(fetch_object('shout_edit_' + shoutid), 'input')[0].value = this.unescapeHTML(theshout);
  504. if (theshout.length < 60)
  505. {
  506. fetch_tags(fetch_object('shout_edit_' + shoutid), 'input')[0].size = (theshout.length + 1);
  507. }
  508. else
  509. {
  510. fetch_tags(fetch_object('shout_edit_' + shoutid), 'input')[0].size = 60;
  511. }
  512. }
  513. else
  514. {
  515. this.editshouteditor.style.display = '';
  516. this.editshoutform.shoutid.value = shoutid;
  517. this.editshoutform.editshout.value = this.unescapeHTML(theshout);
  518. }
  519. }
  520. this.cancel_edit_shout = function(shoutid)
  521. {
  522. if (this.archive)
  523. {
  524. fetch_object('shout_' + shoutid).style.display = '';
  525. fetch_object('shout_edit_' + shoutid).style.display = 'none';
  526. return false;
  527. }
  528. else
  529. {
  530. this.editshouteditor.style.display = 'none';
  531. this.posting_shout = false;
  532. }
  533. }
  534. this.archive_edit_shout = function(shoutid, dodelete)
  535. {
  536. if (typeof dodelete != 'undefined')
  537. {
  538. dodelete = 1;
  539. }
  540. else
  541. {
  542. dodelete = 0;
  543. }
  544. shout = PHP.urlencode(PHP.trim(fetch_tags(fetch_object('shout_edit_' + shoutid), 'input')[0].value));
  545. this.editshout.ajax = new vB_AJAX_Handler(true);
  546. this.editshout.ajax.shoutid = shoutid;
  547. this.editshout.ajax.dodelete = dodelete;
  548. this.editshout.ajax.onreadystatechange(InfernoShoutbox.edit_shout_done);
  549. this.editshout.ajax.send('infernoshout.php', 'do=doeditshout&shoutid=' + shoutid + '&shout=' + shout + '&delete=' + dodelete);
  550. return false;
  551. }
  552. this.do_edit_shout = function(dodelete)
  553. {
  554. if (typeof dodelete != 'undefined')
  555. {
  556. dodelete = 1;
  557. }
  558. else
  559. {
  560. dodelete = 0;
  561. }
  562. shout = PHP.urlencode(PHP.trim(this.editshoutform.editshout.value));
  563. shoutid = parseInt(this.editshoutform.shoutid.value);
  564. this.editshout.ajax = new vB_AJAX_Handler(true);
  565. this.editshout.ajax.shoutid = shoutid;
  566. this.editshout.ajax.onreadystatechange(InfernoShoutbox.edit_shout_done);
  567. this.editshout.ajax.send('infernoshout.php', 'do=doeditshout&shoutid=' + shoutid + '&shout=' + shout + '&delete=' + dodelete);
  568. this.editshouteditor.style.display = 'none';
  569. this.set_loader('');
  570. return false;
  571. }
  572. this.fetch_archive_shout = function(shoutid)
  573. {
  574. this.fetchashout.ajax = new vB_AJAX_Handler(true);
  575. this.fetchashout.ajax.shoutid = shoutid;
  576. this.fetchashout.ajax.onreadystatechange(InfernoShoutbox.fetch_archive_shout_done);
  577. this.fetchashout.ajax.send('infernoshout.php', 'do=getarchiveshout&shoutid=' + shoutid);
  578. }
  579. this.fetch_archive_shout_done = function()
  580. {
  581. ajax = InfernoShoutbox.fetchashout.ajax;
  582. if (ajax.handler.readyState == 4 && ajax.handler.status == 200)
  583. {
  584. data = ajax.handler.responseXML.documentElement;
  585. data = data.getElementsByTagName('data')[0].firstChild.data;
  586. fetch_object('shout_shell_' + ajax.shoutid).innerHTML = data;
  587. }
  588. }
  589. this.edit_shout_done = function()
  590. {
  591. ajax = InfernoShoutbox.editshout.ajax;
  592. if (ajax.handler.readyState == 4 && ajax.handler.status == 200)
  593. {
  594. if (InfernoShoutbox.archive)
  595. {
  596. if (!ajax.dodelete)
  597. {
  598. InfernoShoutbox.fetch_archive_shout(ajax.shoutid);
  599. }
  600. else
  601. {
  602. fetch_object('shout_row_' + ajax.shoutid).parentNode.removeChild(fetch_object('shout_row_' + ajax.shoutid));
  603. }
  604. }
  605. else
  606. {
  607. InfernoShoutbox.set_loader('none');
  608. InfernoShoutbox.posting_shout = false;
  609. InfernoShoutbox.fetch_shouts();
  610. }
  611. }
  612. }
  613. this.smilies = function()
  614. {
  615. if (this.fetchingsmilies)
  616. {
  617. return false;
  618. }
  619. if (this.smiliesbox.style.display == '')
  620. {
  621. this.smiliesbox.style.display = 'none';
  622. return false;
  623. }
  624. this.fetchingsmilies = true;
  625. this.fetchsmilies.ajax = new vB_AJAX_Handler(true);
  626. this.fetchsmilies.ajax.onreadystatechange(InfernoShoutbox.smilies_fetched);
  627. this.fetchsmilies.ajax.send('infernoshout.php', 'do=fetchsmilies');
  628. this.set_loader('');
  629. }
  630. this.smilies_fetched = function()
  631. {
  632. ajax = InfernoShoutbox.fetchsmilies.ajax;
  633. if (ajax.handler.readyState == 4 && ajax.handler.status == 200)
  634. {
  635. InfernoShoutbox.set_loader('none');
  636. InfernoShoutbox.fetchingsmilies = false;
  637. InfernoShoutbox.smiliesbox.style.display = '';
  638. InfernoShoutbox.smiliesrow.innerHTML = ajax.handler.responseText;
  639. }
  640. }
  641. this.append_smilie = function(code)
  642. {
  643. applyto = this.editshouteditor.style.display == '' ? this.editshoutform.editshout : this.editor;
  644. if (PHP.trim(applyto.value) == '')
  645. {
  646. applyto.value = code + ' ';
  647. }
  648. else
  649. {
  650. spacer = applyto.value.substring(applyto.value.length - 1) == ' ' ? '' : ' ';
  651. applyto.value += spacer + code + ' ';
  652. }
  653. try
  654. {
  655. applyto.focus();
  656. }
  657. catch(e)
  658. {
  659. }
  660. }
  661. this.make_curve = function(class_a, class_b)
  662. {
  663. curve = '<div class="alt2" style="border: 0px !important; margin: 0px; padding: 0px;">';
  664. curve += '<span style="float: right; border: 0px !important; margin: 0px; padding: 0px;">';
  665. curve += '<span class="alt1" style="display: block; border: 0px !important; margin: 0px; padding: 0px;">';
  666. curve += '<span class="alt2" style="width: 1px; height: 1px; display: block; overflow: hidden; border: 0px !important; margin: 0px; padding: 0px;"></span>';
  667. curve += '<span class="alt2" style="width: 2px; height: 1px; display: block; overflow: hidden; border: 0px !important; margin: 0px; padding: 0px;"></span>';
  668. curve += '<span class="alt2" style="width: 3px; height: 1px; display: block; overflow: hidden; border: 0px !important; margin: 0px; padding: 0px;"></span>';
  669. curve += '</span></span>';
  670. curve += '<span class="alt1" style="width: 3px; height: 1px; display: block; overflow: hidden; border: 0px !important; margin: 0px; padding: 0px;"></span>';
  671. curve += '<span class="alt1" style="width: 2px; height: 1px; display: block; overflow: hidden; border: 0px !important; margin: 0px; padding: 0px;"></span>';
  672. curve += '<span class="alt1" style="width: 1px; height: 1px; display: block; overflow: hidden; border: 0px !important; margin: 0px; padding: 0px;"></span>';
  673. curve += '</div>';
  674. curve += '';
  675. return curve;
  676. }
  677. this.append_tab = function(html, canclose)
  678. {
  679. if (canclose)
  680. {
  681. html += ' [<a href="#" onclick="return InfernoShoutbox.close_tab(this);">X</a>]';
  682. }
  683. html = this.make_curve('', '') + '<div class="smallfont" style="text-align: center; white-space: nowrap; padding: 5px; padding-top: 0px; padding-bottom: 4px; background: transparent; margin: 0px; border: 0px !important;">' + html + '</div>';
  684. cellposition = this.tabs.rows[0].cells.length - 1;
  685. newtab = this.tabs.rows[0].insertCell(cellposition);
  686. newtab.className = 'alt2';
  687. newtab.innerHTML = html;
  688. newtab.style.cssText = "border: 0px !important; margin: 0px; padding: 0px;";
  689. if (this.tabhistory[newtab.innerHTML])
  690. {
  691. newtab.parentNode.removeChild(newtab);
  692. return false;
  693. }
  694. this.tabhistory[newtab.innerHTML] = 1;
  695. cellposition = this.tabs.rows[0].cells.length - 1;
  696. newtab = this.tabs.rows[0].insertCell(cellposition);
  697. newtab.className = 'alt1';
  698. newtab.innerHTML = '&nbsp;';
  699. newtab.style.cssText = "border: 0px !important; margin: 0px; padding: 0px;";
  700. }
  701. this.close_tab = function(tabobj)
  702. {
  703. this.tabhistory[tabobj.parentNode.parentNode.innerHTML] = 0;
  704. tabobj.parentNode.parentNode.parentNode.removeChild(tabobj.parentNode.parentNode);
  705. this.clean_tab_spacing();
  706. if (this.showing != 'activeusers')
  707. {
  708. this.goto_pm_window('shoutbox_frame');
  709. }
  710. return false;
  711. }
  712. this.clean_tab_spacing = function()
  713. {
  714. for (var c = 0; c < this.tabs.rows[0].cells.length; c++)
  715. {
  716. if (this.tabs.rows[0].cells[c + 1])
  717. {
  718. if (this.tabs.rows[0].cells[c].innerHTML == this.tabs.rows[0].cells[c + 1].innerHTML && this.tabs.rows[0].cells[c].innerHTML == '&nbsp;')
  719. {
  720. this.tabs.rows[0].removeChild(this.tabs.rows[0].cells[c]);
  721. break;
  722. }
  723. }
  724. }
  725. }
  726. this.open_pm_tab = function(pmid, username)
  727. {
  728. if (!this.pm_tabs)
  729. {
  730. this.pm_tabs = {};
  731. }
  732. if (this.pm_tabs[pmid])
  733. {
  734. this.goto_pm_window(pmid);
  735. return false;
  736. }
  737. // Create the tab
  738. this.append_tab('<a href="#" onclick="return InfernoShoutbox.goto_pm_window(\'' + pmid + '\');">' + username + '</a>', 1);
  739. // Create the window
  740. this.append_shout_window(pmid, '/pm ' + username + '; ', '', 'pmonly&pmid=' + pmid.split('_')[1]);
  741. // Switch to the window
  742. this.goto_pm_window(pmid);
  743. return false;
  744. }
  745. this.set_default_window = function(windowid)
  746. {
  747. this.shout_windows[windowid] = new Object;
  748. this.shout_windows[windowid].suffix = '';
  749. this.shout_windows[windowid].prefix = '';
  750. this.shout_windows[windowid].fetchtype = '';
  751. }
  752. this.goto_pm_window = function(windowid)
  753. {
  754. if (!this.shout_windows)
  755. {
  756. this.shout_windows = {};
  757. this.set_default_window('shoutbox_frame');
  758. }
  759. if (!this.shout_windows[windowid])
  760. {
  761. return false;
  762. }
  763. this.userframe.style.display = 'none';
  764. this.shoutframe.style.display = 'none';
  765. this.set_shout_params(windowid, this.shout_windows[windowid].prefix, this.shout_windows[windowid].suffix, this.shout_windows[windowid].fetchtype);
  766. this.shoutframe.innerHTML = 'Loading...';
  767. this.shoutframe.style.display = 'block';
  768. this.showing = windowid;
  769. if (this.idle)
  770. {
  771. this.hide_notice();
  772. }
  773. this.idle = false;
  774. this.fetch_shouts();
  775. return false;
  776. }
  777. this.append_shout_window = function(windowid, shoutprefix, shoutsuffix, fetchtype)
  778. {
  779. if (!this.shout_windows)
  780. {
  781. this.shout_windows = {};
  782. this.set_default_window('shoutbox_frame');
  783. }
  784. if (this.shout_windows[windowid])
  785. {
  786. // This window has already been placed, don't remake it.
  787. return false;
  788. }
  789. this.shout_windows[windowid] = new Object;
  790. this.shout_windows[windowid].prefix = shoutprefix;
  791. this.shout_windows[windowid].suffix = shoutsuffix;
  792. this.shout_windows[windowid].fetchtype = fetchtype;
  793. swindow = document.createElement('span');
  794. swindow.style.display = 'none';
  795. swindow.style.padding = '3px';
  796. swindow.style.height = parseInt(this.shoutheight) + 'px';
  797. swindow.style.overflow = 'auto';
  798. swindow.style.width = '99%';
  799. swindow.innerHTML = 'Loading...';
  800. swindow.id = windowid;
  801. this.shoutwindow.appendChild(swindow);
  802. }
  803. this.goto_options = function()
  804. {
  805. window.location.href = 'infernoshout.php?' + SESSIONURL + 'do=options';
  806. }
  807. this.detach = function()
  808. {
  809. detachwin = window.open('infernoshout.php?' + SESSIONURL + 'do=detach', '_ishout_detach');
  810. try
  811. {
  812. detachwin.focus();
  813. }
  814. catch(e){}
  815. }
  816. // AJAX lock-ups... love 'em =D
  817. this.failure_count = function(failure_type)
  818. {
  819. if (!this.failure_log)
  820. {
  821. this.failure_log = new Array();
  822. }
  823. if (!this.failure_log[failure_type])
  824. {
  825. this.failure_log[failure_type] = 0;
  826. }
  827. this.failure_log[failure_type]++;
  828. if (this.failure_log[failure_type] > 2)
  829. {
  830. this.failure_log[failure_type] = 0;
  831. return true;
  832. }
  833. return false;
  834. }
  835. this.unescapeHTML = function(html)
  836. {
  837. tmpdiv = document.createElement('div');
  838. tmpdiv.innerHTML = html;
  839. return tmpdiv.childNodes[0] ? tmpdiv.childNodes[0].nodeValue : '';
  840. }
  841. }