NGU SBMod

Shoutbox plugin that adds several features

当前为 2015-06-03 提交的版本,查看 最新版本

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