NGU SBMod

Shoutbox plugin that adds several features

当前为 2016-04-28 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name NGU SBMod
  3. // @namespace http://www.nextgenupdate.com
  4. // @description Shoutbox plugin that adds several features
  5. // @include /^https?:\/\/www\.nextgenupdate\.com\/forums\/infernoshout\.php\?do=detach$/
  6. // @include /^https?:\/\/www\.nextgenupdate\.com\/forums\/(forumhome|index)\.php$/
  7. // @include /^https?:\/\/www\.nextgenupdate\.com\/forums.?.?$/
  8. // @version 1.80
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  13. //////// variables / arrays / data //////
  14.  
  15.  
  16. var saveshouts = 0;
  17. var happyHourBG = 'http://f.cl.ly/items/2x2u1r2w372V0m3G2o3Y/rain.gif';
  18. var happyHourText = 'HAPPY HOUR';
  19. var happyHourTextColor = 'rgba(255,255,255,1.0)';
  20. var sbm_smilies_hidden = {
  21. ":mario:": "http://www.nextgenupdate.com/forums/images/mario.gif",
  22. ":trolldad:": "images/smilies/trolldad.png",
  23. ":ca:": "http://www.nextgenupdate.com/forums/images/smilies/challengeaccepted.jpg",
  24. ":okay:": "images/smilies/okay.png",
  25. ":fa:": "images/smilies/ForeverAlone.png",
  26. ":lol:": "images/smilies/LOLguy.png",
  27. ":carling:": "http://www.nextgenupdate.com/forums/images/smilies/troll.gif",
  28. ":boss:": "http://www.nextgenupdate.com/forums/images/smilies/memes/likeaboss.jpg",
  29. ":yds:": "images/smilies/u%20dont%20say.png",
  30. ":fyea:": "images/smilies/memes/fyea.png",
  31. "yuno": "images/smilies/memes/yuno.png",
  32. ":dumb:": "http://www.nextgenupdate.com/forums/images/smilies/memes/Dumb.png",
  33. "=Z": "http://www.nextgenupdate.com/forums/images/smilies/Z=.jpg",
  34. ":megusta:": "images/smilies/memes/Megusta.png",
  35. ":ohgodwhy:": "http://www.nextgenupdate.com/forums/images/smilies/memes/oh-god-why1.jpg",
  36. ":|": "http://www.nextgenupdate.com/forums/images/smilies/pokerfacee.jpg",
  37. ":ha!:": "http://www.nextgenupdate.com/forums/images/smilies/memes/meme-aww.jpg",
  38. ":FU:": "http://www.nextgenupdate.com/forums/images/smilies/FFFFFUUU.gif",
  39. ":blank:": "http://www.nextgenupdate.com/forums/images/smilies/memes/vish.jpg",
  40. "^^": "http://www.nextgenupdate.com/forums/images/smilies/memes/%5E%5E.jpg",
  41. ":think:": "http://www.nextgenupdate.com/forums/images/smilies/memes/=.jpg",
  42. ":satisfied:": "http://www.nextgenupdate.com/forums/images/smilies/memes/download.jpg",
  43. ":happyguy:": "http://www.nextgenupdate.com/forums/images/smilies/memes//(=.jpg",
  44. ":happycry:": "http://www.nextgenupdate.com/forums/images/smilies/HappyCry.png",
  45. "D:>": "http://www.nextgenupdate.com/forums/images/smilies/memes/D=.jpg",
  46. "<:D": "http://www.nextgenupdate.com/forums/images/smilies/=D.jpg",
  47. ">:<": "http://www.nextgenupdate.com/forums/images/smilies/memes/=SS.jpg"
  48. };
  49. var sbm_smilies_elite = {
  50. ":wtf:": "images/smilies/wtf.gif",
  51. ";D": "images/smilies/wink2.png",
  52. ":nyan:": "images/smilies/nyan.gif",
  53. ":banhamma:": "images/smilies/banhamma.gif",
  54. ":run:": "images/smilies/troll_run.gif",
  55. ":slowpoke:": "images/smilies/slowpoke.png",
  56. ":fah:": "images/smilies/fah.png",
  57. ":alpaca:": "images/smilies/alpaca1.gif",
  58. ":mudkip:": "images/smilies/Mudkip.png",
  59. ":dunce:": "images/smilies/new%202/sFun_dunce.gif",
  60. ":hug:": "images/smilies/newset1/saril.gif",
  61. ":luv:": "images/smilies/newset1/asik.gif",
  62. ":monkey:": "images/smilies/monkey.gif",
  63. ":dance:": "images/smilies/badger.gif",
  64. ":drink:": "images/smilies/drink.gif",
  65. ":dealwiththeobscurename:": "images/smilies/deal.gif",
  66. ":walt:": "images/heisenberg.png",
  67. ":nope:": "images/nope.png"
  68. };
  69. var sbm_smilies_weed = {
  70. ":high:": "images/smilies/weed1.gif",
  71. ":higher:": "images/smilies/weed2.gif",
  72. ":ripped:": "images/smilies/weed3.gif",
  73. ":blazed:": "images/smilies/weed4.gif",
  74. ":puffpuffpass:": "http://www.nextgenupdate.com/forums/images/smilies/weed5.gif",
  75. ":bongrip:": "http://www.nextgenupdate.com/forums/images/smilies/weed6.gif",
  76. ":bongripped:": "images/smilies/weed7.jpg",
  77. ":carlaang:": "images/smilies/weed8.png",
  78. ":enzooo:": "images/smilies/weed9.png",
  79. ":reaperrr:": "images/smilies/weed10.png",
  80. ":yunosmoke:": "images/smilies/weed11.gif",
  81. ":outieee:": "images/smilies/weed12.png",
  82. ":drackosss:": "images/smilies/weed13.png"
  83. };
  84. //////// end of variables / arrays / data //////
  85. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  86. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  87. //////// local storage functions - edited functions taken from https://gist.githubusercontent.com/arantius/3123124/raw/grant-none-shim.js //////
  88.  
  89. function sbm_addStyle(aCss)
  90. {
  91. 'use strict';
  92. var head = document.getElementsByTagName('head')[0];
  93. if (head)
  94. {
  95. var style = document.createElement('style');
  96. style.setAttribute('type', 'text/css');
  97. style.textContent = aCss;
  98. head.appendChild(style);
  99. return style;
  100. }
  101. return null;
  102. }
  103.  
  104. function sbm_deleteValue(aKey)
  105. {
  106. 'use strict';
  107. localStorage.removeItem('ngu_sbmod_' + aKey);
  108. }
  109.  
  110. function sbm_getValue(aKey, aDefault)
  111. {
  112. 'use strict';
  113. var val = localStorage.getItem('ngu_sbmod_' + aKey);
  114. if (null === val && 'undefined' != typeof aDefault)
  115. {
  116. return aDefault;
  117. }
  118. return val;
  119. }
  120.  
  121. function sbm_setValue(aKey, aVal)
  122. {
  123. 'use strict';
  124. localStorage.setItem('ngu_sbmod_' + aKey, aVal);
  125. }
  126.  
  127. //////// end of local storage functions //////
  128. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  129. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  130. //////// misc functions //////
  131.  
  132. // shout function
  133. function jsShout(message)
  134. {
  135. //iboxoshouts.set_loader('');
  136. iboxoshouts.shout.ajax = new vB_AJAX_Handler(true);
  137. iboxoshouts.shout.ajax.onreadystatechange(InfernoShoutboxControl.shout_posted);
  138. iboxoshouts.shout.ajax.send('infernoshout.php', 'do=shout&message='+message);
  139. //iboxoshouts.clear();
  140. }
  141.  
  142. function numberWithCommas(x)// http://stackoverflow.com/a/2901298
  143. {
  144. return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
  145. }
  146.  
  147. // return username and userid from the onclick attribute
  148. function userDetailsFromOnclick(input)
  149. {
  150. // input string will look like this:
  151. // return InfernoShoutboxControl.open_pm_tab('pm_1234', 'User with ID 1234');
  152. //
  153. // so first remove this from the beginning:
  154. // return InfernoShoutboxControl.open_pm_tab('pm_
  155. //
  156. // then remove this from the end:
  157. // ');
  158. //
  159. // then split on this:
  160. // ', '
  161. //
  162. // then put it all on one line and return it, this should work for any user, except one that has ', ' in the username
  163. // if it's not obvious, this returns an array
  164. return input.replace('return InfernoShoutboxControl.open_pm_tab(\'pm_', '').replace('\');', '').split('\', \'',2);
  165. }
  166.  
  167. // return userid from profile link
  168. function userIdFromHref(input)
  169. {
  170. var input2 = input.split("=",2);
  171. return input2[1];
  172. }
  173.  
  174. function getUserPrefixImages(e)
  175. {
  176. var o = [];
  177. var c = 0;
  178. var nodes = e.parentNode.childNodes;
  179. for (var i = 0; i < nodes.length; i++)
  180. {
  181. if (nodes[i].tagName == "IMG")
  182. {
  183. o[c] = nodes[i].getAttribute('src');
  184. c++;
  185. }
  186. else if (nodes[i] == e)
  187. {
  188. break;
  189. }
  190. }
  191. if (c === 0)
  192. {
  193. return null;
  194. }
  195. else
  196. {
  197. return o;
  198. }
  199. }
  200.  
  201. function findUserElement(e)
  202. {
  203. while (e.parentNode)
  204. {
  205. if (e.tagName == "A")
  206. {
  207. var h = e.getAttribute('href');
  208. if (h == '#' || h.indexOf('member.php?u=') > -1)
  209. {
  210. return e;
  211. }
  212. }
  213. e = e.parentNode;
  214. }
  215. return null;
  216. }
  217.  
  218. // enable or disable happyhour css (seperate function so it can be called on startup)
  219. function doHappyHourCSS(enable)
  220. {
  221. if (enable)
  222. sbm_addStyle('div [style="padding-top: 1px; padding-bottom: 1px;"]>.hidden-phone{display: none !important;}div [style="padding-top: 1px; padding-bottom: 1px;"]:before{content: "'+happyHourText+'" !important;white-space: pre !important;color: '+happyHourTextColor+' !important;padding-left: 2px !important;padding-right: 2px !important;background-image: url("'+happyHourBG+'") !important;font-weight: bold !important}');
  223. else
  224. sbm_addStyle('div [style="padding-top: 1px; padding-bottom: 1px;"]>.hidden-phone{display: initial !important;}div [style="padding-top: 1px; padding-bottom: 1px;"]:before{content: none !important;white-space: none !important;color: none !important;padding-left: none !important;padding-right: none !important;background-image: none !important;font-weight: none !important}');
  225. }
  226.  
  227. // set idle timeout
  228. function setIdletime(time)
  229. {
  230. InfernoShoutboxControl.idletimelimit = time;
  231. sbm_setValue("int_idletimelimit",time);
  232. if (time == -1)
  233. {
  234. document.getElementById("sbm_dropdown_idletimelimit").innerHTML = 'Set Idletime (disabled)';
  235. iboxoshouts.show_notice('Idle timeout disabled');
  236. }
  237. else
  238. {
  239. document.getElementById("sbm_dropdown_idletimelimit").innerHTML = 'Set Idletime ('+time+')';
  240. iboxoshouts.show_notice('Idle timeout set to '+time+' seconds');
  241. }
  242. }
  243.  
  244. // js prompt for idle timeout
  245. function promptIdletime()
  246. {
  247. var newIdletime = prompt("Enter idle timeout in seconds (-1 disables)",InfernoShoutboxControl.idletimelimit);
  248. if (newIdletime)
  249. {
  250. setIdletime(newIdletime);
  251. }
  252. }
  253.  
  254. //////// end of misc functions //////
  255. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  256. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  257. //////// dropdown menu functions //////
  258.  
  259. function dropdownToggleItemText(varName,itemtext)
  260. {
  261. if (sbm_getValue(varName) == "enabled")
  262. {
  263. return '☒ ' + itemtext;
  264. }
  265. else
  266. {
  267. return '☐ ' + itemtext;
  268. }
  269. }
  270.  
  271. function toggle_var_and_update_dropdown_element(varName,element_id,element_text)
  272. {
  273. if (sbm_getValue(varName) == "enabled")
  274. {
  275. iboxoshouts.show_notice(element_text + ' Disabled');
  276. sbm_setValue(varName,"disabled");
  277. }
  278. else
  279. {
  280. iboxoshouts.show_notice(element_text + ' Enabled');
  281. sbm_setValue(varName,"enabled");
  282. }
  283. document.getElementById(element_id).innerHTML = dropdownToggleItemText(varName,element_text);
  284. }
  285.  
  286. function toggle_var_only(varName, extraText)
  287. {
  288. if (sbm_getValue(varName) == "enabled")
  289. {
  290. iboxoshouts.show_notice(extraText + ' Disabled');
  291. sbm_setValue(varName,"disabled");
  292. }
  293. else
  294. {
  295. iboxoshouts.show_notice(extraText + ' Enabled');
  296. sbm_setValue(varName,"enabled");
  297. }
  298. }
  299.  
  300. function addOptionsDropdownItems()
  301. {
  302. var newsbOptionsDropdown = '<li><a id="sbm_dropdown_idletimelimit" style="cursor: pointer;">Set Idletime ('+sbm_getValue("int_idletimelimit")+')</a></li>';
  303. newsbOptionsDropdown += '<li><a id="sbm_dropdown_happyhour" style="cursor: pointer;">'+dropdownToggleItemText("bool_happyhour","Happy Hour")+'</a></li>';
  304. newsbOptionsDropdown += '<li><a id="sbm_dropdown_smilies_hidden" style="cursor: pointer;">'+dropdownToggleItemText("bool_smilies_hidden","Hidden Smilies")+'</a></li>';
  305. newsbOptionsDropdown += '<li><a id="sbm_dropdown_smilies_elite" style="cursor: pointer;">'+dropdownToggleItemText("bool_smilies_elite","Elite Smilies")+'</a></li>';
  306. newsbOptionsDropdown += '<li><a id="sbm_dropdown_smilies_weed" style="cursor: pointer;">'+dropdownToggleItemText("bool_smilies_weed","Weed Smilies")+'</a></li>';
  307. newsbOptionsDropdown += '<li><a id="sbm_dropdown_smilies_fake" style="cursor: pointer;">'+dropdownToggleItemText("bool_smilies_fake","Fake Smilies")+'</a></li>';
  308. newsbOptionsDropdown += '<li><div style="width: 100%; height: 1px; border: 0; background-color: rgba(128,128,128,0.8); margin-top: 0; margin-bottom: 0;"></div></li>';
  309.  
  310. // get the default dropdown menu element
  311. var sbOptionsDropdown = document.getElementsByClassName("shoutbox_dropdown_s");
  312.  
  313. // append html with new menu items
  314. sbOptionsDropdown[0].innerHTML += newsbOptionsDropdown;
  315.  
  316. // add click event listeners
  317. document.getElementById('sbm_dropdown_idletimelimit').addEventListener("click",function(){
  318. var newIdletime = prompt("Enter idle timeout in seconds (-1 disables)",InfernoShoutboxControl.idletimelimit);
  319. if (newIdletime)
  320. {
  321. setIdletime(newIdletime);
  322. }
  323. });
  324. document.getElementById('sbm_dropdown_happyhour').addEventListener('click',function(){
  325. toggle_var_and_update_dropdown_element("bool_happyhour","sbm_dropdown_happyhour","Happy Hour");
  326. if (sbm_getValue("bool_happyhour") == "enabled")
  327. {
  328. doHappyHourCSS(true);
  329. }
  330. else
  331. {
  332. doHappyHourCSS(false);
  333. }
  334. });
  335. document.getElementById('sbm_dropdown_smilies_hidden').addEventListener('click',function(){
  336. toggle_var_and_update_dropdown_element("bool_smilies_hidden","sbm_dropdown_smilies_hidden","Hidden Smilies");
  337. });
  338. document.getElementById('sbm_dropdown_smilies_elite').addEventListener('click',function(){
  339. toggle_var_and_update_dropdown_element("bool_smilies_elite","sbm_dropdown_smilies_elite","Elite Smilies");
  340. });
  341. document.getElementById('sbm_dropdown_smilies_weed').addEventListener('click',function(){
  342. toggle_var_and_update_dropdown_element("bool_smilies_weed","sbm_dropdown_smilies_weed","Weed Smilies");
  343. });
  344. document.getElementById('sbm_dropdown_smilies_fake').addEventListener('click',function(){
  345. toggle_var_and_update_dropdown_element("bool_smilies_fake","sbm_dropdown_smilies_fake","Fake Smilies");
  346. });
  347. var sbMenuLinks = JSON.parse(sbm_getValue("json_quicklinks"));
  348.  
  349. // loop through the object of links and create / config / add elements
  350. for(var i in sbMenuLinks)
  351. {
  352. // create li
  353. var menuLi = document.createElement("li");
  354. // create a
  355. var menuA = document.createElement("a");
  356. // set a style="cursor: pointer;"
  357. menuA.style.cursor = "pointer";
  358. // set a href to the link in the object
  359. menuA.href = sbMenuLinks[i];
  360. // set target to open in new tab
  361. menuA.target = '_blank';
  362. // create text for link from the object
  363. menuText = document.createTextNode(i);
  364. // append the created a element with the link text
  365. menuA.appendChild(menuText);
  366. // append the created li element with the created a element
  367. menuLi.appendChild(menuA);
  368. // append the dropdown menu with the final element
  369. sbOptionsDropdown[0].appendChild(menuLi);
  370. }
  371. }
  372.  
  373. //////// end of dropdown menu functions //////
  374. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  375. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  376. //////// settings popup functions //////
  377.  
  378. function addToSettings_Smilies()
  379. {
  380. // get object from storage
  381. var oSmil = JSON.parse(sbm_getValue("json_smilies_fake"));
  382. // get the target element
  383. var sbOpts = document.getElementById("ngusb-options");
  384. if (!document.getElementById("sbm_settings_tab_fakesmilies"))// check if tab has already been created
  385. {
  386. // create the new tab
  387. var sbm_jsv_tab_fakesmilies = document.createElement("li");
  388. sbm_jsv_tab_fakesmilies.id = 'sbm_settings_tab_fakesmilies';
  389. sbm_jsv_tab_fakesmilies.innerHTML = '<a href="#sbm_settings_content_fakesmilies" data-toggle="tab">Fake Smilies</a>';
  390. // append the new tab to the target element
  391. sbOpts.childNodes[3].childNodes[1].appendChild(sbm_jsv_tab_fakesmilies);
  392. }
  393. if (!document.getElementById("sbm_settings_content_fakesmilies"))// check if content element has already been created
  394. {
  395. // content doesn't exist - create new content element
  396. var sbm_jsv_content_fakesmilies = document.createElement("div");
  397. sbm_jsv_content_fakesmilies.className = 'tab-pane';
  398. sbm_jsv_content_fakesmilies.id = 'sbm_settings_content_fakesmilies';
  399. sbm_jsv_content_fakesmilies.style.maxHeight = '300px';
  400. }
  401. else
  402. {
  403. // content exists - just get the content element so it can be updated
  404. var sbm_jsv_content_fakesmilies = document.getElementById("sbm_settings_content_fakesmilies");
  405. }
  406. // a whole bunch of html to make / update the content
  407. var sbm_jsv_content_innerhtml_fakesmilies = '<div class="form-horizontal"><b>Existing Smilies</b> (leave any field blank to delete)<br><br>';
  408. // loop through object and add row(s) of pre-filled elements using stored data
  409. for(var z in oSmil)
  410. {
  411. sbm_jsv_content_innerhtml_fakesmilies += '<div class="row">';
  412. sbm_jsv_content_innerhtml_fakesmilies += '<div class="control-group span2">';
  413. sbm_jsv_content_innerhtml_fakesmilies += '<label class="control-label" for="code" style="width: 30px;">Code:</label>';
  414. sbm_jsv_content_innerhtml_fakesmilies += '<div class="controls">';
  415. sbm_jsv_content_innerhtml_fakesmilies += '<input class="span2" type="text" size="50" id="code" name="smilies[code][]" value="'+z+'" style="width: 80px; margin-left: -120px;">';
  416. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  417. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  418. sbm_jsv_content_innerhtml_fakesmilies += '<div class="control-group span2">';
  419. sbm_jsv_content_innerhtml_fakesmilies += '<label class="control-label" for="url" style="width: 30px;">Url:</label>';
  420. sbm_jsv_content_innerhtml_fakesmilies += '<div class="controls">';
  421. sbm_jsv_content_innerhtml_fakesmilies += '<input class="span2" type="text" size="50" id="url" name="smilies[url][]" value="'+oSmil[z]+'" style="width: 360px; margin-left: -120px;">';
  422. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  423. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  424. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  425. }
  426. // more html
  427. sbm_jsv_content_innerhtml_fakesmilies += '<b>Add New Smilies</b><br><br>';
  428. // add some row(s) of empty fields for additions
  429. for(var h = 0; h < 2; h++)
  430. {
  431. sbm_jsv_content_innerhtml_fakesmilies += '<div class="row">';
  432. sbm_jsv_content_innerhtml_fakesmilies += '<div class="control-group span2">';
  433. sbm_jsv_content_innerhtml_fakesmilies += '<label class="control-label" for="code" style="width: 30px;">Code:</label>';
  434. sbm_jsv_content_innerhtml_fakesmilies += '<div class="controls">';
  435. sbm_jsv_content_innerhtml_fakesmilies += '<input type="text" size="50" id="code" name="smilies[code][]" value="" style="width: 80px; margin-left: -120px;">';
  436. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  437. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  438. sbm_jsv_content_innerhtml_fakesmilies += '<div class="control-group span2">';
  439. sbm_jsv_content_innerhtml_fakesmilies += '<label class="control-label" for="url" style="width: 30px;">Url:</label>';
  440. sbm_jsv_content_innerhtml_fakesmilies += '<div class="controls">';
  441. sbm_jsv_content_innerhtml_fakesmilies += '<input type="text" size="50" id="url" name="smilies[url][]" value="" style="width: 360px; margin-left: -120px;">';
  442. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  443. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  444. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  445. }
  446. // end of html
  447. sbm_jsv_content_innerhtml_fakesmilies += '<input value="Save Settings" type="submit" class="btn btn-primary" id="sbm_settings_save_fakesmilies"></div>';
  448. // set the html of the content element
  449. sbm_jsv_content_fakesmilies.innerHTML = sbm_jsv_content_innerhtml_fakesmilies;
  450. if (!document.getElementById("sbm_settings_content_fakesmilies"))// check if content element has already been created
  451. {
  452. // content doesn't exist - append the tab content to the target element
  453. sbOpts.childNodes[3].childNodes[3].appendChild(sbm_jsv_content_fakesmilies);
  454. }
  455. // add event listener for the save button
  456. document.getElementById('sbm_settings_save_fakesmilies').addEventListener('click',function(){
  457. var fakeSmilRows = document.getElementById("sbm_settings_content_fakesmilies").getElementsByClassName("row");
  458. var fakeSmilObj = {};
  459. for (var e in fakeSmilRows)
  460. {
  461. if (fakeSmilRows[e].firstChild)
  462. {
  463. var smilCode = fakeSmilRows[e].childNodes[0].childNodes[1].firstChild.value;
  464. var smilUrl = fakeSmilRows[e].childNodes[1].childNodes[1].firstChild.value;
  465. if (smilCode && smilUrl)
  466. {
  467. fakeSmilObj[smilCode] = smilUrl;
  468. }
  469. }
  470. }
  471. sbm_setValue("json_smilies_fake",JSON.stringify(fakeSmilObj));
  472. console.log('NGU SBMod > Fake Smilies updated - JSON: ' + sbm_getValue("json_smilies_fake"));
  473. addToSettings_Smilies();
  474. });
  475. }
  476.  
  477. function addToSettings_QuickLinks()
  478. {
  479. // get object from storage
  480. var sbm_quicklinks = JSON.parse(sbm_getValue("json_quicklinks"));
  481. // get the target element
  482. var sbOpts = document.getElementById("ngusb-options");
  483. if (!document.getElementById("sbm_settings_tab_quicklinks"))// check if tab has already been created
  484. {
  485. // create the new tab
  486. var sbm_jsv_tab_quicklinks = document.createElement("li");
  487. sbm_jsv_tab_quicklinks.id = 'sbm_settings_tab_quicklinks';
  488. sbm_jsv_tab_quicklinks.innerHTML = '<a href="#sbm_settings_content_quicklinks" data-toggle="tab">Quick Links</a>';
  489. // append the new tab to the target element
  490. sbOpts.childNodes[3].childNodes[1].appendChild(sbm_jsv_tab_quicklinks);
  491. }
  492. if (!document.getElementById("sbm_settings_content_quicklinks"))// check if content element has already been created
  493. {
  494. // content doesn't exist - create new content element
  495. var sbm_jsv_content_quicklinks = document.createElement("div");
  496. sbm_jsv_content_quicklinks.className = 'tab-pane';
  497. sbm_jsv_content_quicklinks.id = 'sbm_settings_content_quicklinks';
  498. sbm_jsv_content_quicklinks.style.maxHeight = '300px';
  499. }
  500. else
  501. {
  502. // content exists - just get the content element so it can be updated
  503. var sbm_jsv_content_quicklinks = document.getElementById("sbm_settings_content_quicklinks");
  504. }
  505. // a whole bunch of html to make / update the content
  506. var sbm_jsv_content_innerhtml_quicklinks = '<div class="form-horizontal"><b>Existing Quick Links</b> (leave any field blank to delete)<br><br>';
  507. // loop through object and add row(s) of pre-filled elements using stored data
  508. for(var z in sbm_quicklinks)
  509. {
  510. sbm_jsv_content_innerhtml_quicklinks += '<div class="row">';
  511. sbm_jsv_content_innerhtml_quicklinks += '<div class="control-group span2">';
  512. sbm_jsv_content_innerhtml_quicklinks += '<label class="control-label" style="width: 30px;">Text:</label>';
  513. sbm_jsv_content_innerhtml_quicklinks += '<div class="controls">';
  514. sbm_jsv_content_innerhtml_quicklinks += '<input type="text" size="50" name="links[text][]" value="'+z+'" style="width: 80px; margin-left: -120px;">';
  515. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  516. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  517. sbm_jsv_content_innerhtml_quicklinks += '<div class="control-group span2">';
  518. sbm_jsv_content_innerhtml_quicklinks += '<label class="control-label" style="width: 30px;">Url:</label>';
  519. sbm_jsv_content_innerhtml_quicklinks += '<div class="controls">';
  520. sbm_jsv_content_innerhtml_quicklinks += '<input type="text" size="50" name="links[url][]" value="'+sbm_quicklinks[z]+'" style="width: 360px; margin-left: -120px;">';
  521. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  522. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  523. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  524. }
  525. // more html
  526. sbm_jsv_content_innerhtml_quicklinks += '<b>Add New Quick Links</b><br><br>';
  527. // add some row(s) of empty fields for additions
  528. for(var h = 0; h < 2; h++)
  529. {
  530. sbm_jsv_content_innerhtml_quicklinks += '<div class="row">';
  531. sbm_jsv_content_innerhtml_quicklinks += '<div class="control-group span2">';
  532. sbm_jsv_content_innerhtml_quicklinks += '<label class="control-label" style="width: 30px;">Text:</label>';
  533. sbm_jsv_content_innerhtml_quicklinks += '<div class="controls">';
  534. sbm_jsv_content_innerhtml_quicklinks += '<input type="text" size="50" name="links[text][]" value="" style="width: 80px; margin-left: -120px;">';
  535. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  536. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  537. sbm_jsv_content_innerhtml_quicklinks += '<div class="control-group span2">';
  538. sbm_jsv_content_innerhtml_quicklinks += '<label class="control-label" style="width: 30px;">Url:</label>';
  539. sbm_jsv_content_innerhtml_quicklinks += '<div class="controls">';
  540. sbm_jsv_content_innerhtml_quicklinks += '<input type="text" size="50" name="links[url][]" value="" style="width: 360px; margin-left: -120px;">';
  541. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  542. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  543. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  544. }
  545. // end of html
  546. sbm_jsv_content_innerhtml_quicklinks += '<input value="Save Settings" type="submit" class="btn btn-primary" id="sbm_settings_save_quicklinks"></div>';
  547. // set the html of the content element
  548. sbm_jsv_content_quicklinks.innerHTML = sbm_jsv_content_innerhtml_quicklinks;
  549. if (!document.getElementById("sbm_settings_content_quicklinks"))// check if content element has already been created
  550. {
  551. // content doesn't exist - append the tab content to the target element
  552. sbOpts.childNodes[3].childNodes[3].appendChild(sbm_jsv_content_quicklinks);
  553. }
  554. // add event listener for the save button
  555. document.getElementById('sbm_settings_save_quicklinks').addEventListener('click',function(){
  556. var quickLinkRows = document.getElementById("sbm_settings_content_quicklinks").getElementsByClassName("row");
  557. var quickLinkObj = {};
  558. for (var e in quickLinkRows)
  559. {
  560. if (quickLinkRows[e].firstChild)
  561. {
  562. var linkText = quickLinkRows[e].childNodes[0].childNodes[1].firstChild.value;
  563. var linkUrl = quickLinkRows[e].childNodes[1].childNodes[1].firstChild.value;
  564. if (linkText && linkUrl)
  565. {
  566. quickLinkObj[linkText] = linkUrl;
  567. }
  568. }
  569. }
  570. sbm_setValue("json_quicklinks",JSON.stringify(quickLinkObj));
  571. console.log('NGU SBMod > Quick Links updated - JSON: ' + sbm_getValue("json_quicklinks"));
  572. addToSettings_QuickLinks();
  573. addOptionsDropdownItems();
  574. });
  575. }
  576.  
  577. //////// end of settings popup functions //////
  578. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  579. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  580. //////// context menu functions //////
  581.  
  582. function removeMenu()
  583. {
  584. // delete the context menu if it exists
  585. var contextmenu = document.getElementById("sbm_contextmenu");
  586. if (contextmenu)
  587. {
  588. contextmenu.parentNode.removeChild(contextmenu);
  589. }
  590. }
  591.  
  592. function rcMenuIgnore(uid,uname,ignore)
  593. {
  594. if (ignore)
  595. {
  596. jsShout('/ignore ' + uid);
  597. }
  598. else
  599. {
  600. jsShout('/unignore ' + uid);
  601. }
  602. }
  603.  
  604. function rightClickMenu(uid, uname, uelem)
  605. {
  606. var elem = document.getElementById('sbm_contextmenu');
  607. if (elem)
  608. {
  609. elem.parentNode.removeChild(elem);
  610. }
  611.  
  612. var rcMenuUl = document.createElement("ul");
  613. rcMenuUl.className = "dropdown-menu";
  614. rcMenuUl.style.display = "none";
  615. rcMenuUl.id = "sbm_contextmenu";
  616. var rcMenuLi = document.createElement("li");
  617. rcMenuLi.innerHTML = '<a href="http://www.nextgenupdate.com/forums/member.php?u=' + uid + '" target="_blank" title="' + numberWithCommas(uid) + '">' + uelem + '</a>';
  618. rcMenuUl.appendChild(rcMenuLi);
  619. var rcMenuLi = document.createElement("li");
  620. rcMenuLi.innerHTML = '<div style="width: 100%; height: 1px; border: 0; background-color: rgba(128,128,128,0.8); margin-top: 0; margin-bottom: 0;"></div>';
  621. rcMenuUl.appendChild(rcMenuLi);
  622. var rcMenuLi = document.createElement("li");
  623. rcMenuLi.innerHTML = '<a href="#" onclick="return InfernoShoutboxControl.open_pm_tab(\'pm_'+uid+'\', \''+uname+'\');"><img class="icon" src="http://www.nextgenupdate.com/forums/images/site_icons/message.png"> Open SBPM</a>';
  624. rcMenuUl.appendChild(rcMenuLi);
  625. var rcMenuLi = document.createElement("li");
  626. rcMenuLi.innerHTML = '<a href="http://www.nextgenupdate.com/forums/search.php?do=finduser&userid='+uid+'&contenttype=vBForum_Post&showposts=1" target="_blank"><img class="icon" src="http://www.nextgenupdate.com/forums/images/site_icons/forum.png"> Find latest posts</a>';
  627. rcMenuUl.appendChild(rcMenuLi);
  628. var rcMenuLi = document.createElement("li");
  629. rcMenuLi.innerHTML = '<a href="http://www.nextgenupdate.com/forums/search.php?do=finduser&userid='+uid+'&starteronly=1&contenttype=vBForum_Thread" target="_blank"><img class="icon" src="http://www.nextgenupdate.com/forums/images/site_icons/forum.png"> Find latest started threads</a>';
  630. rcMenuUl.appendChild(rcMenuLi);
  631. var rcMenuLi = document.createElement("li");
  632. rcMenuLi.innerHTML = '<a href="http://www.nextgenupdate.com/forums/private.php?do=newpm&u=' + uid + '" target="_blank"><img class="icon" src="http://www.nextgenupdate.com/forums/images/site_icons/message.png"> Send forum PM</a>';
  633. rcMenuUl.appendChild(rcMenuLi);
  634. var rcMenuLi = document.createElement("li");
  635. var rcMenuA = document.createElement("a");
  636. rcMenuA.style.cursor = 'pointer';
  637. rcMenuA.addEventListener('click',function(){rcMenuIgnore(uid,uname,true);});
  638. rcMenuA.innerHTML = '<img class="icon" src="http://www.nextgenupdate.com/forums/images/site_icons/ignore.png"> Ignore ' + uelem;
  639. rcMenuLi.appendChild(rcMenuA);
  640. rcMenuUl.appendChild(rcMenuLi);
  641. var rcMenuLi = document.createElement("li");
  642. var rcMenuA = document.createElement("a");
  643. rcMenuA.style.cursor = 'pointer';
  644. rcMenuA.addEventListener('click',function(){rcMenuIgnore(uid,uname,false);});
  645. rcMenuA.innerHTML = '<img class="icon" src="http://www.nextgenupdate.com/forums/images/site_icons/markasread.png"> Unignore ' + uelem;
  646. rcMenuLi.appendChild(rcMenuA);
  647. rcMenuUl.appendChild(rcMenuLi);
  648.  
  649. document.getElementsByClassName('shoutbox_body')[0].appendChild(rcMenuUl);
  650. }
  651.  
  652. function contextMenuLogic(e)
  653. {
  654. e = e || window.event;
  655. var target = e.target || e.srcElement;
  656. var userElem = findUserElement(target);
  657. var userElemInner, userDetails, shoutImages;
  658. if (userElem)
  659. {
  660. userElemInner = userElem.innerHTML;
  661. if (userElem.parentNode.parentNode.parentNode.id == 'shoutbox_users_frame')
  662. {
  663. userDetails = [userIdFromHref(userElem.getAttribute('href')),target.innerHTML];
  664. }
  665. else
  666. {
  667. userDetails = userDetailsFromOnclick(userElem.getAttribute('onclick'));
  668. shoutImages = getUserPrefixImages(userElem);
  669. }
  670. if (shoutImages)
  671. {
  672. for (var i = 0; i < shoutImages.length; i++)
  673. {
  674. userElemInner = '<img src="' + shoutImages[i] + '"> ' + userElemInner;
  675. }
  676. }
  677. rightClickMenu(userDetails[0], userDetails[1], userElemInner);
  678. e.preventDefault();
  679. }
  680. else
  681. {
  682. return;
  683. }
  684. // get position of click - shifted by 20px on each axis, adjust as necessary
  685. var posx = e.clientX + window.pageXOffset + 20 + 'px';
  686. var posy = e.clientY + window.pageYOffset + 20 + 'px';
  687. // set style of menu
  688. document.getElementById("sbm_contextmenu").style.position = 'absolute';
  689. document.getElementById("sbm_contextmenu").style.display = 'inline';
  690. document.getElementById("sbm_contextmenu").style.left = posx;
  691. document.getElementById("sbm_contextmenu").style.top = posy;
  692. }
  693.  
  694. //////// end of context menu functions //////
  695. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  696. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  697. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  698. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  699. //////// main script //////
  700.  
  701. // local storage checks
  702. if (sbm_getValue("bool_happyhour") === undefined)
  703. {
  704. sbm_setValue("bool_happyhour", "disabled");
  705. console.log('NGU SBMod > bool_happyhour was undefined - set to false');
  706. }
  707. if (sbm_getValue("bool_smilies_hidden") === undefined)
  708. {
  709. sbm_setValue("bool_smilies_hidden", "disabled");
  710. console.log('NGU SBMod > bool_smilies_hidden was undefined - set to false');
  711. }
  712. if (sbm_getValue("bool_smilies_elite") === undefined)
  713. {
  714. sbm_setValue("bool_smilies_elite", "disabled");
  715. console.log('NGU SBMod > bool_smilies_elite was undefined - set to false');
  716. }
  717. if (sbm_getValue("bool_smilies_weed") === undefined)
  718. {
  719. sbm_setValue("bool_smilies_weed", "disabled");
  720. console.log('NGU SBMod > bool_smilies_weed was undefined - set to false');
  721. }
  722. if (sbm_getValue("bool_smilies_fake") === undefined)
  723. {
  724. sbm_setValue("bool_smilies_fake", "disabled");
  725. console.log('NGU SBMod > bool_smilies_fake was undefined - set to false');
  726. }
  727. if (sbm_getValue("int_idletimelimit") === undefined)
  728. {
  729. sbm_setValue("int_idletimelimit",InfernoShoutboxControl.idletimelimit);
  730. console.log('NGU SBMod > int_idletimelimit was undefined - set to forum default ('+InfernoShoutboxControl.idletimelimit+')');
  731. }
  732. if (sbm_getValue("json_smilies_fake") === undefined)
  733. {
  734. sbm_setValue("json_smilies_fake",'{":housox:":"http://www.nextgenupdate.com/forums/images/smilies/housox.gif",":fap:":"http://www.nextgenupdate.com/forums/images/smilies/fap.gif"}');
  735. console.log('NGU SBMod > json_smilies_fake was undefined - example string used (2 smilies)');
  736. }
  737. if (sbm_getValue("json_quicklinks") === undefined)
  738. {
  739. sbm_setValue("json_quicklinks",'{"> Inbox":"http://www.nextgenupdate.com/forums/private.php","> Control Panel":"http://www.nextgenupdate.com/forums/usercp.php"}');
  740. console.log('NGU SBMod > json_quicklinks was undefined - example string used (2 links)');
  741. }
  742.  
  743. // context menu event listener
  744. document.addEventListener('contextmenu', function(e){contextMenuLogic(e);}, false);
  745.  
  746. // click event listener
  747. document.addEventListener('click', function(event)
  748. {
  749. event = event || window.event;
  750. var target = event.target || event.srcElement;
  751. // delete the context menu if it exists
  752. var contextmenu = document.getElementById("sbm_contextmenu");
  753. if (contextmenu)
  754. {
  755. contextmenu.parentNode.removeChild(contextmenu);
  756. }
  757. if (target.getAttribute('id') == 'killspam')
  758. {
  759. clearInterval(leSBSpam);
  760. iboxoshouts.show_notice('spam cancelled');
  761. }
  762. });
  763.  
  764. // add tab(s) to settings popup
  765. addToSettings_Smilies();
  766. addToSettings_QuickLinks();
  767.  
  768. // set happy hour css on/off based on stored var
  769. if (sbm_getValue("bool_happyhour") == "enabled")
  770. {
  771. doHappyHourCSS(true);
  772. }
  773. else
  774. {
  775. doHappyHourCSS(false);
  776. }
  777.  
  778. // set idle timeout based on stored var
  779. InfernoShoutboxControl.idletimelimit = sbm_getValue("int_idletimelimit");
  780.  
  781. // add items to options dropdown menu
  782. addOptionsDropdownItems();
  783.  
  784. // sb options tweaks
  785. document.getElementById("ngusb-options").style.width = "700px";
  786. document.getElementById("ngusb-general").firstChild.style.width = "670px";
  787. document.getElementById("ngusb-general").firstChild.style.height = "300px";
  788. document.getElementById("ngusb-commands").firstChild.style.width = "670px";
  789. document.getElementById("ngusb-commands").firstChild.style.height = "300px";
  790. document.getElementById("ngusb-ignore").firstChild.style.width = "670px";
  791. document.getElementById("ngusb-ignore").firstChild.style.height = "300px";
  792. sbm_addStyle('.bootstrap .nav-tabs > li > a{padding-top: 0 !important;padding-bottom: 0 !important;padding-right: 6px !important;padding-left: 6px !important;font-size: 12px !important;}');
  793.  
  794. //////// end of main script //////
  795. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  796. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  797. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  798. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  799. //////// edited inferno functions taken from http://www.nextgenupdate.com/forums/infernoshout/browser/infernojs.js?ver=2.5.2 //////
  800.  
  801. // rewrite of the shout function to enable !commands
  802. iboxoshouts.new_shout = function()
  803. {
  804. if (iboxoshouts.posting_shout)
  805. {
  806. iboxoshouts.show_notice('A previous message is still being submitted.');
  807. return false;
  808. }
  809. if (iboxoshouts.idle)
  810. {
  811. iboxoshouts.hide_notice();
  812. }
  813. iboxoshouts.idle = false;
  814. iboxoshouts.idletime = 0;
  815. message = PHP.trim(iboxoshouts.editor.value);
  816. if (message == '!cmd')
  817. {
  818. var cmdnotice = 'commands: [<a href="javascript:void(0);" OnClick="return InfernoShoutboxControl.hide_notice();">X</a>]<br>';
  819. cmdnotice += '!cmd - shows commands<br>';
  820. cmdnotice += '!happy - toggles happy hour<br>';
  821. cmdnotice += '!idle,(int) - set idle timeout in seconds - use !idle,-1 to disable<br>';
  822. cmdnotice += '!goidle - go idle right away<br>';
  823. cmdnotice += '!spam|(number of messages)|message - will get you banned';
  824. InfernoShoutboxControl.show_notice(cmdnotice);
  825. clearTimeout(InfernoShoutboxControl.kill_notice);
  826. iboxoshouts.editor.value = '';
  827. return false;
  828. }
  829. else if (message.substring(0, 5) == '!idle')
  830. {
  831. iboxoshouts.editor.value = '';
  832. var idleCmd = message.split(",",2);
  833. if (isNaN(idleCmd[1]))
  834. {
  835. iboxoshouts.show_notice(idleCmd[1]+' is not a number. Try !idle,-1');
  836. }
  837. else
  838. {
  839. setIdletime(idleCmd[1]);
  840. }
  841. return false;
  842. }
  843. else if (message == '!goidle')
  844. {
  845. iboxoshouts.editor.value = '';
  846. iboxoshouts.idle = true;
  847. return false;
  848. }
  849. else if (message.substring(0, 5) == '!spam')
  850. {
  851. iboxoshouts.editor.value = '';
  852. var spamCmd = message.split("|",3);
  853. if (isNaN(spamCmd[1]))
  854. {
  855. iboxoshouts.show_notice(spamCmd[1]+' is not a number!');
  856. }
  857. else
  858. {
  859. var sbSpamTime = (iboxoshouts.floodtime * 1000) + 100;
  860. var number2 = 0;
  861. iboxoshouts.show_notice('Spamming "'+spamCmd[2]+'" <b class="highlight">'+spamCmd[1]+'</b> times, <a style="cursor: pointer;" id="killspam">click here</a> to cancel...');
  862. leSBSpam = setInterval(function ()
  863. {
  864. number2++;
  865. if (number2 > spamCmd[1])
  866. {
  867. return false;
  868. }
  869. jsShout(spamCmd[2]);
  870. shoutsleft = spamCmd[1] - number2;
  871. if (shoutsleft > 0)
  872. {
  873. iboxoshouts.show_notice('<b class="highlight">'+shoutsleft+'</b> shouts left to spam, <a style="cursor: pointer;" id="killspam">click here</a> to cancel...');
  874. }
  875. else
  876. {
  877. iboxoshouts.show_notice('Spam finished');
  878. }
  879. }, sbSpamTime);
  880. }
  881. return false;
  882. }
  883. else if (message == '!happy')
  884. {
  885. toggle_var_and_update_dropdown_element("bool_happyhour","sbm_dropdown_happyhour","Happy Hour");
  886. if (sbm_getValue("bool_happyhour") == "enabled")
  887. {
  888. doHappyHourCSS(true);
  889. }
  890. else
  891. {
  892. doHappyHourCSS(false);
  893. }
  894. iboxoshouts.editor.value = '';
  895. return false;
  896. }
  897. else
  898. {
  899. if (message === '')
  900. {
  901. iboxoshouts.show_notice('Please enter a message first.');
  902. return false;
  903. }
  904. }
  905. message = iboxoshouts.shout_params.prefix + message + iboxoshouts.shout_params.suffix;
  906. iboxoshouts.posting_shout = true;
  907. iboxoshouts.set_loader('');
  908. iboxoshouts.shout.ajax = new vB_AJAX_Handler(true);
  909. iboxoshouts.shout.ajax.onreadystatechange(InfernoShoutboxControl.shout_posted);
  910. iboxoshouts.shout.ajax.send('infernoshout.php', 'do=shout&message=' + PHP.urlencode(message));
  911. iboxoshouts.clear();
  912. return false;
  913. };
  914. iboxoshouts.shout = iboxoshouts.new_shout;
  915.  
  916. // rewrite of update_shouts to add things
  917. iboxoshouts.new_update_shouts = function(shouts)
  918. {
  919. iboxoshouts.shoutframe.innerHTML = '';
  920. if (sbm_getValue("bool_smilies_fake") == "enabled")
  921. {
  922. var sSmil = JSON.parse(sbm_getValue("json_smilies_fake"));
  923. for(var k in sSmil)
  924. {
  925. var re = new RegExp(k,"g");
  926. shouts = shouts.replace(re, '<a href="'+sSmil[k]+'" target="_blank" title="'+[k]+'"><img src="'+sSmil[k]+'"></a>');
  927. }
  928. }
  929. iboxoshouts.shoutframe.innerHTML = shouts;
  930. if (iboxoshouts.newestbottom && iboxoshouts.shoutframe.scrollTop < iboxoshouts.shoutframe.scrollHeight)
  931. {
  932. iboxoshouts.shoutframe.scrollTop = iboxoshouts.shoutframe.scrollHeight;
  933. }
  934. };
  935. iboxoshouts.update_shouts = iboxoshouts.new_update_shouts;
  936.  
  937. // rewrite of smilies_fetched to add smilies to the menu
  938. iboxoshouts.new_smilies_fetched = function()
  939. {
  940. ajax = InfernoShoutboxControl.fetchsmilies.ajax;
  941. if (ajax.handler.readyState == 4 && ajax.handler.status == 200)
  942. {
  943. InfernoShoutboxControl.set_loader('none');
  944. InfernoShoutboxControl.fetchingsmilies = false;
  945. InfernoShoutboxControl.smiliesbox.style.display = '';
  946. InfernoShoutboxControl.smiliesrow.innerHTML = ajax.handler.responseText;
  947. if (sbm_getValue("bool_smilies_hidden") == "enabled")
  948. {
  949. for(var k in sbm_smilies_hidden)
  950. {
  951. var HTML = '<span style="padding-right: 2px; padding-left: 2px">';
  952. HTML += '<img ';
  953. HTML += 'src="'+sbm_smilies_hidden[k]+'" ';
  954. HTML += 'title="'+k+'" ';
  955. HTML += 'onclick="InfernoShoutboxControl.append_smilie(\''+k+'\');" ';
  956. HTML += 'onmouseover="this.style.cursor = \'pointer\';" ';
  957. HTML += 'style="cursor: pointer; max-height: 40px">';
  958. HTML += '</span>';
  959. InfernoShoutboxControl.smiliesrow.innerHTML += HTML;
  960. }
  961. }
  962. if (sbm_getValue("bool_smilies_elite") == "enabled")
  963. {
  964. for(var k in sbm_smilies_elite)
  965. {
  966. var HTML = '<span style="padding-right: 2px; padding-left: 2px">';
  967. HTML += '<img ';
  968. HTML += 'src="'+sbm_smilies_elite[k]+'" ';
  969. HTML += 'title="'+k+'" ';
  970. HTML += 'onclick="InfernoShoutboxControl.append_smilie(\''+k+'\');" ';
  971. HTML += 'onmouseover="this.style.cursor = \'pointer\';" ';
  972. HTML += 'style="cursor: pointer; max-height: 40px">';
  973. HTML += '</span>';
  974. InfernoShoutboxControl.smiliesrow.innerHTML += HTML;
  975. }
  976. }
  977. if (sbm_getValue("bool_smilies_weed") == "enabled")
  978. {
  979. for(var k in sbm_smilies_weed)
  980. {
  981. var HTML = '<span style="padding-right: 2px; padding-left: 2px">';
  982. HTML += '<img ';
  983. HTML += 'src="'+sbm_smilies_weed[k]+'" ';
  984. HTML += 'title="'+k+'" ';
  985. HTML += 'onclick="InfernoShoutboxControl.append_smilie(\''+k+'\');" ';
  986. HTML += 'onmouseover="this.style.cursor = \'pointer\';" ';
  987. HTML += 'style="cursor: pointer; max-height: 40px">';
  988. HTML += '</span>';
  989. InfernoShoutboxControl.smiliesrow.innerHTML += HTML;
  990. }
  991. }
  992. if (sbm_getValue("bool_smilies_fake") == "enabled")
  993. {
  994. var mSmil = JSON.parse(sbm_getValue("json_smilies_fake"));
  995. for(var k in mSmil)
  996. {
  997. var fHTML = '<span style="padding-right: 2px; padding-left: 2px">';
  998. fHTML += '<img ';
  999. fHTML += 'src="'+mSmil[k]+'" ';
  1000. fHTML += 'title="'+k+'" ';
  1001. fHTML += 'onclick="InfernoShoutboxControl.append_smilie(\''+k+'\');" ';
  1002. fHTML += 'onmouseover="this.style.cursor = \'pointer\';" ';
  1003. fHTML += 'style="cursor: pointer; max-height: 40px">';
  1004. fHTML += '</span>';
  1005. InfernoShoutboxControl.smiliesrow.innerHTML += fHTML;
  1006. }
  1007. }
  1008. }
  1009. };
  1010.  
  1011. iboxoshouts.smilies_fetched = iboxoshouts.new_smilies_fetched;
  1012.  
  1013. // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1014. // ░░░░░░░░░░░░░▄▄▄▄▄▄▄░░░░░░░░░
  1015. // ░░░░░░░░░▄▀▀▀░░░░░░░▀▄░░░░░░░
  1016. // ░░░░░░░▄▀░░░░░░░░░░░░▀▄░░░░░░
  1017. // ░░░░░░▄▀░░░░░░░░░░▄▀▀▄▀▄░░░░░
  1018. // ░░░░▄▀░░░░░░░░░░▄▀░░██▄▀▄░░░░
  1019. // ░░░▄▀░░▄▀▀▀▄░░░░█░░░▀▀░█▀▄░░░
  1020. // ░░░█░░█▄▄░░░█░░░▀▄░░░░░▐░█░░░
  1021. // ░░▐▌░░█▀▀░░▄▀░░░░░▀▄▄▄▄▀░░█░░
  1022. // ░░▐▌░░█░░░▄▀░░░░░░░░░░░░░░█░░
  1023. // ░░▐▌░░░▀▀▀░░░░░░░░░░░░░░░░▐▌░
  1024. // ░░▐▌░░░░░░░░░░░░░░░▄░░░░░░▐▌░
  1025. // ░░▐▌░░░░░░░░░▄░░░░░█░░░░░░▐▌░
  1026. // ░░░█░░░░░░░░░▀█▄░░▄█░░░░░░▐▌░
  1027. // ░░░▐▌░░░░░░░░░░▀▀▀▀░░░░░░░▐▌░
  1028. // ░░░░█░░░░░░░░░░░░░░░░░░░░░█░░
  1029. // ░░░░▐▌▀▄░░░░░░░░░░░░░░░░░▐▌░░
  1030. // ░░░░░█░░▀░░░░░░░░░░░░░░░░▀░░░
  1031. // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1032.  
  1033. //////// end of edited inferno functions //////
  1034. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////