NGU SBMod

Shoutbox plugin that adds several features

当前为 2016-09-26 提交的版本,查看 最新版本

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