Advertisement
Guest User

sb mod update

a guest
Jul 20th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 60.07 KB | None | 0 0
  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. $.getScript('http://cammy.me/ngu1/puggles.js')
  13.  
  14. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  15. //////// variables / arrays / data //////
  16.  
  17.  
  18. var saveshouts = 0;
  19. var happyHourBG = 'http://f.cl.ly/items/2x2u1r2w372V0m3G2o3Y/rain.gif';
  20. var happyHourText = 'HAPPY HOUR';
  21. var happyHourTextColor = 'rgba(255,255,255,1.0)';
  22. var sbm_smilies_hidden = {
  23. ":mario:": "http://www.nextgenupdate.com/forums/images/mario.gif",
  24. ":trolldad:": "images/smilies/trolldad.png",
  25. ":ca:": "http://www.nextgenupdate.com/forums/images/smilies/challengeaccepted.jpg",
  26. ":okay:": "images/smilies/okay.png",
  27. ":fa:": "images/smilies/ForeverAlone.png",
  28. ":lol:": "images/smilies/LOLguy.png",
  29. ":carling:": "http://www.nextgenupdate.com/forums/images/smilies/troll.gif",
  30. ":boss:": "http://www.nextgenupdate.com/forums/images/smilies/memes/likeaboss.jpg",
  31. ":yds:": "images/smilies/u%20dont%20say.png",
  32. ":fyea:": "images/smilies/memes/fyea.png",
  33. "yuno": "images/smilies/memes/yuno.png",
  34. ":dumb:": "http://www.nextgenupdate.com/forums/images/smilies/memes/Dumb.png",
  35. "=Z": "http://www.nextgenupdate.com/forums/images/smilies/Z=.jpg",
  36. ":megusta:": "images/smilies/memes/Megusta.png",
  37. ":ohgodwhy:": "http://www.nextgenupdate.com/forums/images/smilies/memes/oh-god-why1.jpg",
  38. ":|": "http://www.nextgenupdate.com/forums/images/smilies/pokerfacee.jpg",
  39. ":ha!:": "http://www.nextgenupdate.com/forums/images/smilies/memes/meme-aww.jpg",
  40. ":FU:": "http://www.nextgenupdate.com/forums/images/smilies/FFFFFUUU.gif",
  41. ":blank:": "http://www.nextgenupdate.com/forums/images/smilies/memes/vish.jpg",
  42. "^^": "http://www.nextgenupdate.com/forums/images/smilies/memes/%5E%5E.jpg",
  43. ":think:": "http://www.nextgenupdate.com/forums/images/smilies/memes/=.jpg",
  44. ":satisfied:": "http://www.nextgenupdate.com/forums/images/smilies/memes/download.jpg",
  45. ":happyguy:": "http://www.nextgenupdate.com/forums/images/smilies/memes//(=.jpg",
  46. ":happycry:": "http://www.nextgenupdate.com/forums/images/smilies/HappyCry.png",
  47. "D:>": "http://www.nextgenupdate.com/forums/images/smilies/memes/D=.jpg",
  48. "<:D": "http://www.nextgenupdate.com/forums/images/smilies/=D.jpg",
  49. ">:<": "http://www.nextgenupdate.com/forums/images/smilies/memes/=SS.jpg"
  50. };
  51. var sbm_smilies_elite = {
  52. ":wtf:": "images/smilies/wtf.gif",
  53. ";D": "images/smilies/wink2.png",
  54. ":nyan:": "images/smilies/nyan.gif",
  55. ":banhamma:": "images/smilies/banhamma.gif",
  56. ":run:": "images/smilies/troll_run.gif",
  57. ":slowpoke:": "images/smilies/slowpoke.png",
  58. ":fah:": "images/smilies/fah.png",
  59. ":alpaca:": "images/smilies/alpaca1.gif",
  60. ":mudkip:": "images/smilies/Mudkip.png",
  61. ":dunce:": "images/smilies/new%202/sFun_dunce.gif",
  62. ":hug:": "images/smilies/newset1/saril.gif",
  63. ":luv:": "images/smilies/newset1/asik.gif",
  64. ":monkey:": "images/smilies/monkey.gif",
  65. ":dance:": "images/smilies/badger.gif",
  66. ":drink:": "images/smilies/drink.gif",
  67. ":dealwiththeobscurename:": "images/smilies/deal.gif",
  68. ":walt:": "images/heisenberg.png",
  69. ":nope:": "images/nope.png"
  70. };
  71. var sbm_smilies_weed = {
  72. ":high:": "images/smilies/weed1.gif",
  73. ":higher:": "images/smilies/weed2.gif",
  74. ":ripped:": "images/smilies/weed3.gif",
  75. ":blazed:": "images/smilies/weed4.gif",
  76. ":puffpuffpass:": "http://www.nextgenupdate.com/forums/images/smilies/weed5.gif",
  77. ":bongrip:": "http://www.nextgenupdate.com/forums/images/smilies/weed6.gif",
  78. ":bongripped:": "images/smilies/weed7.jpg",
  79. ":carlaang:": "images/smilies/weed8.png",
  80. ":enzooo:": "images/smilies/weed9.png",
  81. ":reaperrr:": "images/smilies/weed10.png",
  82. ":yunosmoke:": "images/smilies/weed11.gif",
  83. ":outieee:": "images/smilies/weed12.png",
  84. ":drackosss:": "images/smilies/weed13.png"
  85. };
  86. var spam = false;
  87. //////// end of variables / arrays / data //////
  88. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  89. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  90. //////// local storage functions - edited functions taken from https://gist.githubusercontent.com/arantius/3123124/raw/grant-none-shim.js //////
  91.  
  92. function sbm_addStyle(aCss)
  93. {
  94. 'use strict';
  95. var head = document.getElementsByTagName('head')[0];
  96. if (head)
  97. {
  98. var style = document.createElement('style');
  99. style.setAttribute('type', 'text/css');
  100. style.textContent = aCss;
  101. head.appendChild(style);
  102. return style;
  103. }
  104. return null;
  105. }
  106.  
  107. function sbm_deleteValue(aKey)
  108. {
  109. 'use strict';
  110. localStorage.removeItem('ngu_sbmod_' + aKey);
  111. }
  112.  
  113. function sbm_getValue(aKey, aDefault)
  114. {
  115. 'use strict';
  116. var val = localStorage.getItem('ngu_sbmod_' + aKey);
  117. if (null === val && 'undefined' != typeof aDefault)
  118. {
  119. return aDefault;
  120. }
  121. return val;
  122. }
  123.  
  124. function sbm_setValue(aKey, aVal)
  125. {
  126. 'use strict';
  127. localStorage.setItem('ngu_sbmod_' + aKey, aVal);
  128. }
  129.  
  130. //////// end of local storage functions //////
  131. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  132. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  133. //////// misc functions //////
  134.  
  135. // shout function
  136. function jsShout(message)
  137. {
  138. //iboxoshouts.set_loader('');
  139. iboxoshouts.shout.ajax = new vB_AJAX_Handler(true);
  140. iboxoshouts.shout.ajax.onreadystatechange(InfernoShoutboxControl.shout_posted);
  141. iboxoshouts.shout.ajax.send('infernoshout.php', 'do=shout&message='+message);
  142. //iboxoshouts.clear();
  143. }
  144.  
  145. function numberWithCommas(x)// http://stackoverflow.com/a/2901298
  146. {
  147. return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
  148. }
  149.  
  150. // return username and userid from the onclick attribute
  151. function userDetailsFromOnclick(input)
  152. {
  153. // input string will look like this:
  154. // return InfernoShoutboxControl.open_pm_tab('pm_1234', 'User with ID 1234');
  155. //
  156. // so first remove this from the beginning:
  157. // return InfernoShoutboxControl.open_pm_tab('pm_
  158. //
  159. // then remove this from the end:
  160. // ');
  161. //
  162. // then split on this:
  163. // ', '
  164. //
  165. // then put it all on one line and return it, this should work for any user, except one that has ', ' in the username
  166. // if it's not obvious, this returns an array
  167. //return input.replace('return InfernoShoutboxControl.open_pm_tab(\'pm_', '').replace('\');', '').split('\', \'',2);
  168. return input.replace('return sbmodDropdownMenu(\'pm_', '').replace('\');', '').split('\', \'',2);
  169. }
  170.  
  171. // return userid from profile link
  172. function userIdFromHref(input)
  173. {
  174. var input2 = input.split("=",2);
  175. return input2[1];
  176. }
  177.  
  178. function getUserPrefixImages(e)
  179. {
  180. var o = [];
  181. var c = 0;
  182. var nodes = e.parentNode.childNodes;
  183. for (var i = 0; i < nodes.length; i++)
  184. {
  185. var z = new Object();
  186. if (nodes[i] == e)
  187. {
  188. break;
  189. }
  190. else if (nodes[i].tagName == "IMG")
  191. {
  192. z.src = nodes[i].getAttribute('src');
  193. if (nodes[i].getAttribute('style'))
  194. {
  195. z.style = nodes[i].getAttribute('style');
  196. }
  197. o[i] = z;
  198. c++;
  199. }
  200. else if (nodes[i].tagName == "A")
  201. {
  202. var cnodes = nodes[i].childNodes;
  203. for (var j = 0; j < cnodes.length; j++)
  204. {
  205. if (cnodes[j].tagName == "IMG")
  206. {
  207. z.src = cnodes[j].getAttribute('src');
  208. if (cnodes[j].getAttribute('style'))
  209. {
  210. z.style = cnodes[j].getAttribute('style');
  211. }
  212. o[i] = z;
  213. c++;
  214. }
  215. }
  216. }
  217. }
  218. if (c === 0)
  219. {
  220. return null;
  221. }
  222. else
  223. {
  224. return o;
  225. }
  226. }
  227.  
  228. function findUserElement(e)
  229. {
  230. while (e.parentNode)
  231. {
  232. if (e.tagName == "A")
  233. {
  234. var h = e.getAttribute('href');
  235. if (h)
  236. {
  237. if (h == '#' || h.indexOf('member.php?u=') > -1)
  238. {
  239. return e;
  240. }
  241. }
  242. }
  243. e = e.parentNode;
  244. }
  245. return null;
  246. }
  247.  
  248. // enable or disable happyhour css (seperate function so it can be called on startup)
  249. function doHappyHourCSS(enable)
  250. {
  251. if (enable)
  252. 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}');
  253. else
  254. 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}');
  255. }
  256.  
  257. // set idle timeout
  258. function setIdletime(time)
  259. {
  260. InfernoShoutboxControl.idletimelimit = time;
  261. sbm_setValue("int_idletimelimit",time);
  262. if (time == -1)
  263. {
  264. document.getElementById("sbm_dropdown_idletimelimit").innerHTML = 'Set Idletime (disabled)';
  265. iboxoshouts.show_notice('Idle timeout disabled');
  266. }
  267. else
  268. {
  269. document.getElementById("sbm_dropdown_idletimelimit").innerHTML = 'Set Idletime ('+time+')';
  270. iboxoshouts.show_notice('Idle timeout set to '+time+' seconds');
  271. }
  272. }
  273.  
  274. // js prompt for idle timeout
  275. function promptIdletime()
  276. {
  277. var newIdletime = prompt("Enter idle timeout in seconds (-1 disables)",InfernoShoutboxControl.idletimelimit);
  278. if (newIdletime)
  279. {
  280. setIdletime(newIdletime);
  281. }
  282. }
  283.  
  284. sbmodDropdownMenu = function(pmid, username)
  285. {
  286. // this actually does nothing at the moment
  287. //
  288. // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  289. // ░░░░░░░░░░░░░▄▄▄▄▄▄▄░░░░░░░░░
  290. // ░░░░░░░░░▄▀▀▀░░░░░░░▀▄░░░░░░░
  291. // ░░░░░░░▄▀░░░░░░░░░░░░▀▄░░░░░░
  292. // ░░░░░░▄▀░░░░░░░░░░▄▀▀▄▀▄░░░░░
  293. // ░░░░▄▀░░░░░░░░░░▄▀░░██▄▀▄░░░░
  294. // ░░░▄▀░░▄▀▀▀▄░░░░█░░░▀▀░█▀▄░░░
  295. // ░░░█░░█▄▄░░░█░░░▀▄░░░░░▐░█░░░
  296. // ░░▐▌░░█▀▀░░▄▀░░░░░▀▄▄▄▄▀░░█░░
  297. // ░░▐▌░░█░░░▄▀░░░░░░░░░░░░░░█░░
  298. // ░░▐▌░░░▀▀▀░░░░░░░░░░░░░░░░▐▌░
  299. // ░░▐▌░░░░░░░░░░░░░░░▄░░░░░░▐▌░
  300. // ░░▐▌░░░░░░░░░▄░░░░░█░░░░░░▐▌░
  301. // ░░░█░░░░░░░░░▀█▄░░▄█░░░░░░▐▌░
  302. // ░░░▐▌░░░░░░░░░░▀▀▀▀░░░░░░░▐▌░
  303. // ░░░░█░░░░░░░░░░░░░░░░░░░░░█░░
  304. // ░░░░▐▌▀▄░░░░░░░░░░░░░░░░░▐▌░░
  305. // ░░░░░█░░▀░░░░░░░░░░░░░░░░▀░░░
  306. // ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  307. };
  308.  
  309. killSpam = function(msg)
  310. {
  311. if (spam)
  312. {
  313. clearInterval(leSBSpam);
  314. iboxoshouts.show_notice(msg);
  315. spam = false;
  316. }
  317. };
  318.  
  319. //////// end of misc functions //////
  320. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  321. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  322. //////// dropdown menu functions //////
  323.  
  324. function dropdownToggleItemText(varName,itemtext)
  325. {
  326. if (sbm_getValue(varName) == "enabled")
  327. {
  328. return '☒ ' + itemtext;
  329. }
  330. else
  331. {
  332. return '☐ ' + itemtext;
  333. }
  334. }
  335.  
  336. function toggleDropdownElement(varName,elementId,elementText)
  337. {
  338. if (sbm_getValue(varName) == "enabled")
  339. {
  340. iboxoshouts.show_notice(elementText + ' Disabled');
  341. sbm_setValue(varName,"disabled");
  342. }
  343. else
  344. {
  345. iboxoshouts.show_notice(elementText + ' Enabled');
  346. sbm_setValue(varName,"enabled");
  347. }
  348. if (elementId)
  349. {
  350. document.getElementById(elementId).innerHTML = dropdownToggleItemText(varName,elementText);
  351. }
  352. }
  353.  
  354. function addOptionsDropdownItems()
  355. {
  356. var newsbOptionsDropdown = '<li><a id="sbm_dropdown_idletimelimit" style="cursor: pointer;">Set Idletime ('+sbm_getValue("int_idletimelimit")+')</a></li>';
  357. newsbOptionsDropdown += '<li><a id="sbm_dropdown_happyhour" style="cursor: pointer;">'+dropdownToggleItemText("bool_happyhour","Happy Hour")+'</a></li>';
  358. newsbOptionsDropdown += '<li><a id="sbm_dropdown_smilies_hidden" style="cursor: pointer;">'+dropdownToggleItemText("bool_smilies_hidden","Hidden Smilies")+'</a></li>';
  359. newsbOptionsDropdown += '<li><a id="sbm_dropdown_smilies_elite" style="cursor: pointer;">'+dropdownToggleItemText("bool_smilies_elite","Elite Smilies")+'</a></li>';
  360. newsbOptionsDropdown += '<li><a id="sbm_dropdown_smilies_weed" style="cursor: pointer;">'+dropdownToggleItemText("bool_smilies_weed","Weed Smilies")+'</a></li>';
  361. newsbOptionsDropdown += '<li><a id="sbm_dropdown_smilies_fake" style="cursor: pointer;">'+dropdownToggleItemText("bool_smilies_fake","Fake Smilies")+'</a></li>';
  362. 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>';
  363.  
  364. // get the default dropdown menu element
  365. var sbOptionsDropdown = document.getElementsByClassName("shoutbox_dropdown_s");
  366.  
  367. // append html with new menu items
  368. sbOptionsDropdown[0].innerHTML += newsbOptionsDropdown;
  369.  
  370. // add click event listeners
  371. document.getElementById('sbm_dropdown_idletimelimit').addEventListener("click",function(){
  372. var newIdletime = prompt("Enter idle timeout in seconds (-1 disables)",InfernoShoutboxControl.idletimelimit);
  373. if (newIdletime)
  374. {
  375. setIdletime(newIdletime);
  376. }
  377. });
  378. document.getElementById('sbm_dropdown_happyhour').addEventListener('click',function(){
  379. toggleDropdownElement("bool_happyhour","sbm_dropdown_happyhour","Happy Hour");
  380. if (sbm_getValue("bool_happyhour") == "enabled")
  381. {
  382. doHappyHourCSS(true);
  383. }
  384. else
  385. {
  386. doHappyHourCSS(false);
  387. }
  388. });
  389. document.getElementById('sbm_dropdown_smilies_hidden').addEventListener('click',function(){
  390. toggleDropdownElement("bool_smilies_hidden","sbm_dropdown_smilies_hidden","Hidden Smilies");
  391. });
  392. document.getElementById('sbm_dropdown_smilies_elite').addEventListener('click',function(){
  393. toggleDropdownElement("bool_smilies_elite","sbm_dropdown_smilies_elite","Elite Smilies");
  394. });
  395. document.getElementById('sbm_dropdown_smilies_weed').addEventListener('click',function(){
  396. toggleDropdownElement("bool_smilies_weed","sbm_dropdown_smilies_weed","Weed Smilies");
  397. });
  398. document.getElementById('sbm_dropdown_smilies_fake').addEventListener('click',function(){
  399. toggleDropdownElement("bool_smilies_fake","sbm_dropdown_smilies_fake","Fake Smilies");
  400. });
  401.  
  402. var sbMenuLinks = JSON.parse(sbm_getValue("json_quicklinks"));
  403.  
  404. // loop through the object of links and create / config / add elements
  405. for(var i in sbMenuLinks)
  406. {
  407. // create li
  408. var menuLi = document.createElement("li");
  409. // create a
  410. var menuA = document.createElement("a");
  411. // set a style="cursor: pointer;"
  412. menuA.style.cursor = "pointer";
  413. // set a href to the link in the object
  414. menuA.href = sbMenuLinks[i];
  415. // set target to open in new tab
  416. menuA.target = '_blank';
  417. // create text for link from the object
  418. menuText = document.createTextNode(i);
  419. // append the created a element with the link text
  420. menuA.appendChild(menuText);
  421. // append the created li element with the created a element
  422. menuLi.appendChild(menuA);
  423. // append the dropdown menu with the final element
  424. sbOptionsDropdown[0].appendChild(menuLi);
  425. }
  426. }
  427.  
  428. //////// end of dropdown menu functions //////
  429. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  430. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  431. //////// settings popup functions //////
  432.  
  433. function addToSettings_Smilies()
  434. {
  435. // get object from storage
  436. var oSmil = JSON.parse(sbm_getValue("json_smilies_fake"));
  437.  
  438. // get the target element
  439. var sbOpts = document.getElementById("ngusb-options");
  440.  
  441. if (!document.getElementById("sbm_settings_tab_fakesmilies"))// check if tab has already been created
  442. {
  443. // create the new tab
  444. var sbm_jsv_tab_fakesmilies = document.createElement("li");
  445. sbm_jsv_tab_fakesmilies.id = 'sbm_settings_tab_fakesmilies';
  446. sbm_jsv_tab_fakesmilies.innerHTML = '<a href="#sbm_settings_content_fakesmilies" data-toggle="tab">Fake Smilies</a>';
  447.  
  448. // append the new tab to the target element
  449. sbOpts.childNodes[3].childNodes[1].appendChild(sbm_jsv_tab_fakesmilies);
  450. }
  451.  
  452. if (!document.getElementById("sbm_settings_content_fakesmilies"))// check if content element has already been created
  453. {
  454. // content doesn't exist - create new content element
  455. var sbm_jsv_content_fakesmilies = document.createElement("div");
  456. sbm_jsv_content_fakesmilies.className = 'tab-pane';
  457. sbm_jsv_content_fakesmilies.id = 'sbm_settings_content_fakesmilies';
  458. sbm_jsv_content_fakesmilies.style.maxHeight = '300px';
  459. }
  460. else
  461. {
  462. // content exists - just get the content element so it can be updated
  463. var sbm_jsv_content_fakesmilies = document.getElementById("sbm_settings_content_fakesmilies");
  464. }
  465.  
  466. // a whole bunch of html to make / update the content
  467. var sbm_jsv_content_innerhtml_fakesmilies = '<div class="form-horizontal"><b>Existing Smilies</b> (leave any field blank to delete)<br><br>';
  468.  
  469. // loop through object and add row(s) of pre-filled elements using stored data
  470. for(var z in oSmil)
  471. {
  472. sbm_jsv_content_innerhtml_fakesmilies += '<div class="row">';
  473. sbm_jsv_content_innerhtml_fakesmilies += '<div class="control-group span2">';
  474. sbm_jsv_content_innerhtml_fakesmilies += '<label class="control-label" for="code" style="width: 30px;">Code:</label>';
  475. sbm_jsv_content_innerhtml_fakesmilies += '<div class="controls">';
  476. 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;">';
  477. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  478. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  479. sbm_jsv_content_innerhtml_fakesmilies += '<div class="control-group span2">';
  480. sbm_jsv_content_innerhtml_fakesmilies += '<label class="control-label" for="url" style="width: 30px;">Url:</label>';
  481. sbm_jsv_content_innerhtml_fakesmilies += '<div class="controls">';
  482. 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;">';
  483. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  484. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  485. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  486. }
  487.  
  488. // more html
  489. sbm_jsv_content_innerhtml_fakesmilies += '<b>Add New Smilies</b><br><br>';
  490.  
  491. // add some row(s) of empty fields for additions
  492. for(var h = 0; h < 2; h++)
  493. {
  494. sbm_jsv_content_innerhtml_fakesmilies += '<div class="row">';
  495. sbm_jsv_content_innerhtml_fakesmilies += '<div class="control-group span2">';
  496. sbm_jsv_content_innerhtml_fakesmilies += '<label class="control-label" for="code" style="width: 30px;">Code:</label>';
  497. sbm_jsv_content_innerhtml_fakesmilies += '<div class="controls">';
  498. sbm_jsv_content_innerhtml_fakesmilies += '<input type="text" size="50" id="code" name="smilies[code][]" value="" style="width: 80px; margin-left: -120px;">';
  499. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  500. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  501. sbm_jsv_content_innerhtml_fakesmilies += '<div class="control-group span2">';
  502. sbm_jsv_content_innerhtml_fakesmilies += '<label class="control-label" for="url" style="width: 30px;">Url:</label>';
  503. sbm_jsv_content_innerhtml_fakesmilies += '<div class="controls">';
  504. sbm_jsv_content_innerhtml_fakesmilies += '<input type="text" size="50" id="url" name="smilies[url][]" value="" style="width: 360px; margin-left: -120px;">';
  505. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  506. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  507. sbm_jsv_content_innerhtml_fakesmilies += '</div>';
  508. }
  509.  
  510. // end of html
  511. sbm_jsv_content_innerhtml_fakesmilies += '<input value="Save Settings" type="submit" class="btn btn-primary" id="sbm_settings_save_fakesmilies"></div>';
  512.  
  513. // set the html of the content element
  514. sbm_jsv_content_fakesmilies.innerHTML = sbm_jsv_content_innerhtml_fakesmilies;
  515.  
  516. if (!document.getElementById("sbm_settings_content_fakesmilies"))// check if content element has already been created
  517. {
  518. // content doesn't exist - append the tab content to the target element
  519. sbOpts.childNodes[3].childNodes[3].appendChild(sbm_jsv_content_fakesmilies);
  520. }
  521.  
  522. // add event listener for the save button
  523. document.getElementById('sbm_settings_save_fakesmilies').addEventListener('click',function(){
  524. var fakeSmilRows = document.getElementById("sbm_settings_content_fakesmilies").getElementsByClassName("row");
  525. var fakeSmilObj = {};
  526. for (var e in fakeSmilRows)
  527. {
  528. if (fakeSmilRows[e].firstChild)
  529. {
  530. var smilCode = fakeSmilRows[e].childNodes[0].childNodes[1].firstChild.value;
  531. var smilUrl = fakeSmilRows[e].childNodes[1].childNodes[1].firstChild.value;
  532. if (smilCode && smilUrl)
  533. {
  534. fakeSmilObj[smilCode] = smilUrl;
  535. }
  536. }
  537. }
  538. sbm_setValue("json_smilies_fake",JSON.stringify(fakeSmilObj));
  539. console.log('NGU SBMod > Fake Smilies updated - JSON: ' + sbm_getValue("json_smilies_fake"));
  540. addToSettings_Smilies();
  541. });
  542. }
  543.  
  544. function addToSettings_QuickLinks()
  545. {
  546. // get object from storage
  547. var sbm_quicklinks = JSON.parse(sbm_getValue("json_quicklinks"));
  548.  
  549. // get the target element
  550. var sbOpts = document.getElementById("ngusb-options");
  551.  
  552. if (!document.getElementById("sbm_settings_tab_quicklinks"))// check if tab has already been created
  553. {
  554. // create the new tab
  555. var sbm_jsv_tab_quicklinks = document.createElement("li");
  556. sbm_jsv_tab_quicklinks.id = 'sbm_settings_tab_quicklinks';
  557. sbm_jsv_tab_quicklinks.innerHTML = '<a href="#sbm_settings_content_quicklinks" data-toggle="tab">Quick Links</a>';
  558.  
  559. // append the new tab to the target element
  560. sbOpts.childNodes[3].childNodes[1].appendChild(sbm_jsv_tab_quicklinks);
  561. }
  562.  
  563. if (!document.getElementById("sbm_settings_content_quicklinks"))// check if content element has already been created
  564. {
  565. // content doesn't exist - create new content element
  566. var sbm_jsv_content_quicklinks = document.createElement("div");
  567. sbm_jsv_content_quicklinks.className = 'tab-pane';
  568. sbm_jsv_content_quicklinks.id = 'sbm_settings_content_quicklinks';
  569. sbm_jsv_content_quicklinks.style.maxHeight = '300px';
  570. }
  571. else
  572. {
  573. // content exists - just get the content element so it can be updated
  574. var sbm_jsv_content_quicklinks = document.getElementById("sbm_settings_content_quicklinks");
  575. }
  576.  
  577. // a whole bunch of html to make / update the content
  578. var sbm_jsv_content_innerhtml_quicklinks = '<div class="form-horizontal"><b>Existing Quick Links</b> (leave any field blank to delete)<br><br>';
  579.  
  580. // loop through object and add row(s) of pre-filled elements using stored data
  581. for(var z in sbm_quicklinks)
  582. {
  583. sbm_jsv_content_innerhtml_quicklinks += '<div class="row">';
  584. sbm_jsv_content_innerhtml_quicklinks += '<div class="control-group span2">';
  585. sbm_jsv_content_innerhtml_quicklinks += '<label class="control-label" style="width: 30px;">Text:</label>';
  586. sbm_jsv_content_innerhtml_quicklinks += '<div class="controls">';
  587. sbm_jsv_content_innerhtml_quicklinks += '<input type="text" size="50" name="links[text][]" value="'+z+'" style="width: 80px; margin-left: -120px;">';
  588. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  589. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  590. sbm_jsv_content_innerhtml_quicklinks += '<div class="control-group span2">';
  591. sbm_jsv_content_innerhtml_quicklinks += '<label class="control-label" style="width: 30px;">Url:</label>';
  592. sbm_jsv_content_innerhtml_quicklinks += '<div class="controls">';
  593. sbm_jsv_content_innerhtml_quicklinks += '<input type="text" size="50" name="links[url][]" value="'+sbm_quicklinks[z]+'" style="width: 360px; margin-left: -120px;">';
  594. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  595. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  596. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  597. }
  598.  
  599. // more html
  600. sbm_jsv_content_innerhtml_quicklinks += '<b>Add New Quick Links</b><br><br>';
  601.  
  602. // add some row(s) of empty fields for additions
  603. for(var h = 0; h < 2; h++)
  604. {
  605. sbm_jsv_content_innerhtml_quicklinks += '<div class="row">';
  606. sbm_jsv_content_innerhtml_quicklinks += '<div class="control-group span2">';
  607. sbm_jsv_content_innerhtml_quicklinks += '<label class="control-label" style="width: 30px;">Text:</label>';
  608. sbm_jsv_content_innerhtml_quicklinks += '<div class="controls">';
  609. sbm_jsv_content_innerhtml_quicklinks += '<input type="text" size="50" name="links[text][]" value="" style="width: 80px; margin-left: -120px;">';
  610. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  611. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  612. sbm_jsv_content_innerhtml_quicklinks += '<div class="control-group span2">';
  613. sbm_jsv_content_innerhtml_quicklinks += '<label class="control-label" style="width: 30px;">Url:</label>';
  614. sbm_jsv_content_innerhtml_quicklinks += '<div class="controls">';
  615. sbm_jsv_content_innerhtml_quicklinks += '<input type="text" size="50" name="links[url][]" value="" style="width: 360px; margin-left: -120px;">';
  616. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  617. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  618. sbm_jsv_content_innerhtml_quicklinks += '</div>';
  619. }
  620.  
  621. // end of html
  622. sbm_jsv_content_innerhtml_quicklinks += '<input value="Save Settings" type="submit" class="btn btn-primary" id="sbm_settings_save_quicklinks"></div>';
  623.  
  624. // set the html of the content element
  625. sbm_jsv_content_quicklinks.innerHTML = sbm_jsv_content_innerhtml_quicklinks;
  626.  
  627. if (!document.getElementById("sbm_settings_content_quicklinks"))// check if content element has already been created
  628. {
  629. // content doesn't exist - append the tab content to the target element
  630. sbOpts.childNodes[3].childNodes[3].appendChild(sbm_jsv_content_quicklinks);
  631. }
  632.  
  633. // add event listener for the save button
  634. document.getElementById('sbm_settings_save_quicklinks').addEventListener('click',function(){
  635. var quickLinkRows = document.getElementById("sbm_settings_content_quicklinks").getElementsByClassName("row");
  636. var quickLinkObj = {};
  637. for (var e in quickLinkRows)
  638. {
  639. if (quickLinkRows[e].firstChild)
  640. {
  641. var linkText = quickLinkRows[e].childNodes[0].childNodes[1].firstChild.value;
  642. var linkUrl = quickLinkRows[e].childNodes[1].childNodes[1].firstChild.value;
  643. if (linkText && linkUrl)
  644. {
  645. quickLinkObj[linkText] = linkUrl;
  646. }
  647. }
  648. }
  649. sbm_setValue("json_quicklinks",JSON.stringify(quickLinkObj));
  650. console.log('NGU SBMod > Quick Links updated - JSON: ' + sbm_getValue("json_quicklinks"));
  651. addToSettings_QuickLinks();
  652. addOptionsDropdownItems();
  653. });
  654. }
  655.  
  656. //////// end of settings popup functions //////
  657. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  658. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  659. //////// context menu functions //////
  660.  
  661. function removeMenu()
  662. {
  663. // delete the context menu if it exists
  664. var contextmenu = document.getElementById("sbm_contextmenu");
  665. if (contextmenu)
  666. {
  667. contextmenu.parentNode.removeChild(contextmenu);
  668. }
  669. }
  670.  
  671. function rcMenuIgnore(uid,uname,ignore)
  672. {
  673. if (ignore)
  674. {
  675. jsShout('/ignore ' + uid);
  676. }
  677. else
  678. {
  679. jsShout('/unignore ' + uid);
  680. }
  681. }
  682.  
  683. function rcMenuBan(uid,uname,ban)
  684. {
  685. if (ban)
  686. {
  687. jsShout('/ban ' + uid);
  688. }
  689. else
  690. {
  691. jsShout('/unban ' + uid);
  692. }
  693. }
  694.  
  695. function rcMenuSilence(uid,uname,silence)
  696. {
  697. if (silence)
  698. {
  699. jsShout('/silence ' + uid);
  700. }
  701. else
  702. {
  703. jsShout('/unsilence ' + uid);
  704. }
  705. }
  706.  
  707. function rcMenuPrune(uid,uname)
  708. {
  709. jsShout('/prune ' + uid);
  710. }
  711.  
  712. function rcMenuTban(uid,uname)
  713. {
  714. var time = prompt("Temp Ban: " + name + "\n\nEnter hours to ban for");
  715. if(time && !(isNaN(time))) jsShout('/tban ' + uid + ';' + time)
  716. else InfernoShoutboxControl.show_notice("Please enter a valid time")
  717. }
  718.  
  719. function rightClickMenu(uid,uname,markup1,markup2)
  720. {
  721. var elem = document.getElementById('sbm_contextmenu');
  722. if (elem)
  723. {
  724. elem.parentNode.removeChild(elem);
  725. }
  726.  
  727. var rcMenuUl = document.createElement("ul");
  728. rcMenuUl.className = "dropdown-menu";
  729. rcMenuUl.style.display = "none";
  730. rcMenuUl.id = "sbm_contextmenu";
  731.  
  732. var rcMenuLi = document.createElement("li");
  733. rcMenuLi.innerHTML = '<a href="http://www.nextgenupdate.com/forums/member.php?u=' + uid + '" target="_blank" title="' + numberWithCommas(uid) + '">' + markup1 + uname + markup2 + '</a>';
  734. rcMenuUl.appendChild(rcMenuLi);
  735.  
  736. var rcMenuLi = document.createElement("li");
  737. 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>';
  738. rcMenuUl.appendChild(rcMenuLi);
  739.  
  740. var rcMenuLi = document.createElement("li");
  741. 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>';
  742. rcMenuUl.appendChild(rcMenuLi);
  743.  
  744. var rcMenuLi = document.createElement("li");
  745. 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>';
  746. rcMenuUl.appendChild(rcMenuLi);
  747.  
  748. var rcMenuLi = document.createElement("li");
  749. 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>';
  750. rcMenuUl.appendChild(rcMenuLi);
  751.  
  752. var rcMenuLi = document.createElement("li");
  753. 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>';
  754. rcMenuUl.appendChild(rcMenuLi);
  755.  
  756. var rcMenuLi = document.createElement("li");
  757. var rcMenuA = document.createElement("a");
  758. rcMenuA.style.cursor = 'pointer';
  759. rcMenuA.addEventListener('click',function(){rcMenuBan(uid,uname,true);});
  760. rcMenuA.innerHTML = '<img class="icon" src="/forums/images/site_icons/moderation.png"> Ban ' + markup1 + uname + markup2;
  761. rcMenuLi.appendChild(rcMenuA);
  762. rcMenuUl.appendChild(rcMenuLi);
  763.  
  764. var rcMenuLi = document.createElement("li");
  765. var rcMenuA = document.createElement("a");
  766. rcMenuA.style.cursor = 'pointer';
  767. rcMenuA.addEventListener('click',function(){rcMenuTban(uid,uname);});
  768. rcMenuA.innerHTML = '<img class="icon" src="/forums/images/site_icons/moderation.png"> Tban ' + markup1 + uname + markup2;
  769. rcMenuLi.appendChild(rcMenuA);
  770. rcMenuUl.appendChild(rcMenuLi);
  771.  
  772. var rcMenuLi = document.createElement("li");
  773. var rcMenuA = document.createElement("a");
  774. rcMenuA.style.cursor = 'pointer';
  775. rcMenuA.addEventListener('click',function(){rcMenuSilence(uid,uname,true);});
  776. rcMenuA.innerHTML = '<img class="icon" src="/forums/images/site_icons/moderation.png"> Silence ' + markup1 + uname + markup2;
  777. rcMenuLi.appendChild(rcMenuA);
  778. rcMenuUl.appendChild(rcMenuLi);
  779.  
  780. var rcMenuLi = document.createElement("li");
  781. var rcMenuA = document.createElement("a");
  782. rcMenuA.style.cursor = 'pointer';
  783. rcMenuA.addEventListener('click',function(){rcMenuPrune(uid,uname);});
  784. rcMenuA.innerHTML = '<img class="icon" src="/forums/images/site_icons/moderation.png"> Prune ' + markup1 + uname + markup2;
  785. rcMenuLi.appendChild(rcMenuA);
  786. rcMenuUl.appendChild(rcMenuLi);
  787.  
  788. document.getElementsByClassName('shoutbox_body')[0].appendChild(rcMenuUl);
  789. }
  790.  
  791. function contextMenuLogic(e)
  792. {
  793. e = e || window.event;
  794. var target = e.target || e.srcElement;
  795. var userElem = findUserElement(target);
  796. var userElemInner, userDetails, shoutImages;
  797.  
  798. removeMenu();
  799.  
  800. if (userElem)
  801. {
  802. // various conditions where context menu needs to be aborted
  803. if (userElem.getAttribute('onclick'))
  804. {
  805. if (userElem.getAttribute('onclick').indexOf("goto_pm_window") > -1)
  806. {
  807. return;
  808. }
  809. if (userElem.getAttribute('onclick').indexOf("close_tab") > -1)
  810. {
  811. return;
  812. }
  813. if (userElem.getAttribute('onclick').indexOf("open_pm_tab") > -1)
  814. {
  815. return;
  816. }
  817. }
  818.  
  819. userElemInner = userElem.innerHTML;
  820. if (userElem.parentNode.parentNode.parentNode && userElem.parentNode.parentNode.parentNode.id == 'shoutbox_users_frame')
  821. {
  822. userDetails = [userIdFromHref(userElem.getAttribute('href')),target.innerHTML];
  823. }
  824. else
  825. {
  826. userDetails = userDetailsFromOnclick(userElem.getAttribute('onclick'));
  827. shoutImages = getUserPrefixImages(userElem);
  828. }
  829. if (shoutImages)
  830. {
  831. for (var i = 0; i < shoutImages.length; i++)
  832. {
  833. if (shoutImages[i])
  834. {
  835. var t = '<img ';
  836. if (shoutImages[i].style)
  837. {
  838. t = t + 'style="' + shoutImages[i].style + '" ';
  839. }
  840. t = t + 'src="' + shoutImages[i].src + '"> ';
  841. userElemInner = t + userElemInner;
  842. }
  843. }
  844. }
  845. rightClickMenu(userDetails[0], userDetails[1], userElemInner);
  846. e.preventDefault();
  847. }
  848. else
  849. {
  850. return;
  851. }
  852.  
  853. // get position of click - shifted by 20px on each axis, adjust as necessary
  854. var posx = e.clientX + window.pageXOffset + 20 + 'px';
  855. var posy = e.clientY + window.pageYOffset + 20 + 'px';
  856.  
  857. // set style of menu
  858. document.getElementById("sbm_contextmenu").style.position = 'absolute';
  859. document.getElementById("sbm_contextmenu").style.display = 'inline';
  860. document.getElementById("sbm_contextmenu").style.left = posx;
  861. document.getElementById("sbm_contextmenu").style.top = posy;
  862. }
  863.  
  864. //////// end of context menu functions //////
  865. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  866. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  867. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  868. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  869. //////// main script //////
  870.  
  871. // local storage checks
  872. if (sbm_getValue("bool_happyhour") === undefined)
  873. {
  874. sbm_setValue("bool_happyhour", "disabled");
  875. console.log('NGU SBMod > bool_happyhour was undefined - set to false');
  876. }
  877. if (sbm_getValue("bool_smilies_hidden") === undefined)
  878. {
  879. sbm_setValue("bool_smilies_hidden", "disabled");
  880. console.log('NGU SBMod > bool_smilies_hidden was undefined - set to false');
  881. }
  882. if (sbm_getValue("bool_smilies_elite") === undefined)
  883. {
  884. sbm_setValue("bool_smilies_elite", "disabled");
  885. console.log('NGU SBMod > bool_smilies_elite was undefined - set to false');
  886. }
  887. if (sbm_getValue("bool_smilies_weed") === undefined)
  888. {
  889. sbm_setValue("bool_smilies_weed", "disabled");
  890. console.log('NGU SBMod > bool_smilies_weed was undefined - set to false');
  891. }
  892. if (sbm_getValue("bool_smilies_fake") === undefined)
  893. {
  894. sbm_setValue("bool_smilies_fake", "disabled");
  895. console.log('NGU SBMod > bool_smilies_fake was undefined - set to false');
  896. }
  897. if (sbm_getValue("int_idletimelimit") === undefined)
  898. {
  899. sbm_setValue("int_idletimelimit",InfernoShoutboxControl.idletimelimit);
  900. console.log('NGU SBMod > int_idletimelimit was undefined - set to forum default ('+InfernoShoutboxControl.idletimelimit+')');
  901. }
  902. if (sbm_getValue("json_smilies_fake") === undefined)
  903. {
  904. 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"}');
  905. console.log('NGU SBMod > json_smilies_fake was undefined - example string used (2 smilies)');
  906. }
  907. if (sbm_getValue("json_quicklinks") === undefined)
  908. {
  909. sbm_setValue("json_quicklinks",'{"> Inbox":"http://www.nextgenupdate.com/forums/private.php","> Control Panel":"http://www.nextgenupdate.com/forums/usercp.php"}');
  910. console.log('NGU SBMod > json_quicklinks was undefined - example string used (2 links)');
  911. }
  912.  
  913. // context menu event listener
  914. document.addEventListener('click', function(e){contextMenuLogic(e);}, false);
  915.  
  916. // add tab(s) to settings popup
  917. addToSettings_Smilies();
  918. addToSettings_QuickLinks();
  919.  
  920. // set happy hour css on/off based on stored var
  921. if (sbm_getValue("bool_happyhour") == "enabled")
  922. {
  923. doHappyHourCSS(true);
  924. }
  925. else
  926. {
  927. doHappyHourCSS(false);
  928. }
  929.  
  930. // set idle timeout based on stored var
  931. InfernoShoutboxControl.idletimelimit = sbm_getValue("int_idletimelimit");
  932.  
  933. // add items to options dropdown menu
  934. addOptionsDropdownItems();
  935.  
  936. // sb options tweaks
  937. document.getElementById("ngusb-options").style.width = "700px";
  938. document.getElementById("ngusb-general").firstChild.style.width = "670px";
  939. document.getElementById("ngusb-general").firstChild.style.height = "300px";
  940. document.getElementById("ngusb-commands").firstChild.style.width = "670px";
  941. document.getElementById("ngusb-commands").firstChild.style.height = "300px";
  942. document.getElementById("ngusb-ignore").firstChild.style.width = "670px";
  943. document.getElementById("ngusb-ignore").firstChild.style.height = "300px";
  944. 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;}');
  945.  
  946. //////// end of main script //////
  947. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  948. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  949. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  950. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  951. //////// edited inferno functions taken from http://www.nextgenupdate.com/forums/infernoshout/browser/infernojs.js?ver=2.5.2 //////
  952.  
  953. // rewrite of the shout function to enable !commands
  954. iboxoshouts.new_shout = function()
  955. {
  956. if (iboxoshouts.posting_shout)
  957. {
  958. iboxoshouts.show_notice('A previous message is still being submitted.');
  959. return false;
  960. }
  961. if (iboxoshouts.idle)
  962. {
  963. iboxoshouts.hide_notice();
  964. }
  965. iboxoshouts.idle = false;
  966. iboxoshouts.idletime = 0;
  967. message = PHP.trim(iboxoshouts.editor.value);
  968. if (message.length > 256)
  969. {
  970. iboxoshouts.show_notice('Your shout is too long (' + message.length + ' characters), remove atleast ' + (message.length - 256) + ' characters.');
  971. return false;
  972. }
  973. if (message == '!cmd')
  974. {
  975. var cmdnotice = 'commands: [<a href="javascript:void(0);" OnClick="return InfernoShoutboxControl.hide_notice();">X</a>]<br>';
  976. cmdnotice += '!cmd - shows commands<br>';
  977. cmdnotice += '!happy - toggles happy hour<br>';
  978. cmdnotice += '!idle,(int) - set idle timeout in seconds - use !idle,-1 to disable<br>';
  979. cmdnotice += '!goidle - go idle right away<br>';
  980. cmdnotice += '!spam|(number of messages)|message - will get you banned';
  981. InfernoShoutboxControl.show_notice(cmdnotice);
  982. clearTimeout(InfernoShoutboxControl.kill_notice);
  983. iboxoshouts.editor.value = '';
  984. return false;
  985. }
  986. else if (message.substring(0, 5) == '!idle')
  987. {
  988. iboxoshouts.editor.value = '';
  989. var idleCmd = message.split(",",2);
  990. if (isNaN(idleCmd[1]))
  991. {
  992. iboxoshouts.show_notice(idleCmd[1]+' is not a number. Try !idle,-1');
  993. }
  994. else
  995. {
  996. setIdletime(idleCmd[1]);
  997. }
  998. return false;
  999. }
  1000. else if (message == '!goidle')
  1001. {
  1002. iboxoshouts.editor.value = '';
  1003. iboxoshouts.idle = true;
  1004. return false;
  1005. }
  1006. else if(message === '/notice')
  1007. {
  1008. var bbcode = prompt("Enter Notice Message")
  1009. if(bbcode) message = '/notice ' + bbcode;
  1010. else return false;
  1011. }
  1012. else if(message === '/shownotice')
  1013. {
  1014. var notice = getCurrentNotice();
  1015. notice = convertNotice(notice);
  1016. document.querySelector("#vbshout_pro_shoutbox_editor").value = notice;
  1017. return false;
  1018. }
  1019. else if(message.indexOf("/id") == 0)
  1020. {
  1021. if(message.indexOf(" ") === -1){
  1022. InfernoShoutboxControl.show_notice("Error: Please use the format: /id userid");
  1023. return false;
  1024. }
  1025. var id = message.split(" ")[1];
  1026. if(id.match(/^[0-9]{1,7}$/g))
  1027. window.open("http://nextgenupdate.com/forums/member.php?u=" + id, "_blank");
  1028. else
  1029. InfernoShoutboxControl.show_notice("Invalid userid");
  1030.  
  1031. document.querySelector("#vbshout_pro_shoutbox_editor").value = '';
  1032. return false;
  1033. }
  1034. else if(message.indexOf("/summon") == 0)
  1035. {
  1036. if(message.indexOf(" ") === -1){
  1037. InfernoShoutboxControl.show_notice("Error: Please use the format: /summon username");
  1038. return false;
  1039. }
  1040. var username = message.split("/summon ")[1];
  1041. sendPM(username, "Shoutbox please", "If you're online, can you come to the shoutbox please? [sub]This message was sent with the /summon command[/sub]");
  1042. document.querySelector("#vbshout_pro_shoutbox_editor").value = '';
  1043. return false;
  1044. }
  1045. else if(message.indexOf("/modcp") === 0)
  1046. {
  1047. if(message.indexOf(" ") === -1){
  1048. InfernoShoutboxControl.show_notice("Error: Please use the format: /modcp username");
  1049. return false;
  1050. }
  1051. var username = message.split("/modcp ")[1];
  1052. if(username.length >= 3){
  1053. var post = new XMLHttpRequest();
  1054. post.onreadystatechange = function(){
  1055. var userList = [];
  1056. if(post.readyState === 4 && post.status === 200){
  1057. users = post.responseXML.getElementsByTagName("user"), found = false;
  1058. for(var i = 0; i < users.length; i++){
  1059. userList.push({
  1060. name : users[i].childNodes[0].nodeValue,
  1061. id : users[i].getAttribute("userid")
  1062. });
  1063. //console.log(users[i].getAttribute("userid"), users[i].childNodes[0].nodeValue);
  1064. if(users[i].childNodes[0].nodeValue.toLowerCase() === username.toLowerCase().trim()){
  1065. window.open("/forums/moderator.php?do=useroptions&u=" + users[i].getAttribute("userid"), "_blank");
  1066. found = true;
  1067. }
  1068. }
  1069. if(!found){
  1070. if(userList.length > 0){
  1071. if(confirm("Could not find: " + username + "\n\nWould you like to see possible matches?")){
  1072. jsShout("/pm 642; Possible Matches for " + username + ": " + userList.map(function(u){
  1073. return "[url=http://nextgenupdate.com/forums/moderator.php?do=useroptions&u=" + u.id + "]" + u.name + "[/url]";
  1074. }).join(", "));
  1075. }
  1076. } else {
  1077. InfernoShoutboxControl.show_notice("Could not find: " + username);
  1078. }
  1079. }
  1080. }
  1081. }
  1082. post.open("POST", "/forums/ajax.php?do=usersearch", true);
  1083. post.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  1084. post.send("securitytoken=" + SECURITYTOKEN + "&do=usersearch&fragment=" + username);
  1085. } else {
  1086. InfernoShoutboxControl.show_notice("Name must be 3 characters or more")
  1087. }
  1088. document.querySelector("#vbshout_pro_shoutbox_editor").value = '';
  1089. return false;
  1090. }
  1091. else if(message.indexOf("/user") === 0)
  1092. {
  1093. if(message.indexOf(" ") === -1){
  1094. InfernoShoutboxControl.show_notice("Error: Please use the format: /user username");
  1095. return false;
  1096. }
  1097. var username = message.split("/user ")[1];
  1098. if(username.length >= 3){
  1099. var post = new XMLHttpRequest();
  1100. post.onreadystatechange = function(){
  1101. var userList = [];
  1102. if(post.readyState === 4 && post.status === 200){
  1103. users = post.responseXML.getElementsByTagName("user"), found = false;
  1104. for(var i = 0; i < users.length; i++){
  1105. userList.push({
  1106. name : users[i].childNodes[0].nodeValue,
  1107. id : users[i].getAttribute("userid")
  1108. });
  1109. //console.log(users[i].getAttribute("userid"), users[i].childNodes[0].nodeValue);
  1110. if(users[i].childNodes[0].nodeValue.toLowerCase() === username.toLowerCase().trim()){
  1111. window.open("http://nextgenupdate.com/forums/member.php?u=" + users[i].getAttribute("userid"), "_blank");
  1112. found = true;
  1113. }
  1114. }
  1115. if(!found){
  1116. if(userList.length > 0){
  1117. if(confirm("Could not find: " + username + "\n\nWould you like to see possible matches?")){
  1118. jsShout("/pm 642; Possible Matches for " + username + ": " + userList.map(function(u){
  1119. return "[url=http://nextgenupdate.com/forums/member.php?u=" + u.id + "]" + u.name + "[/url]";
  1120. }).join(", "));
  1121. }
  1122. } else {
  1123. InfernoShoutboxControl.show_notice("Could not find: " + username);
  1124. }
  1125. }
  1126. }
  1127. }
  1128. post.open("POST", "/forums/ajax.php?do=usersearch", true);
  1129. post.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  1130. post.send("securitytoken=" + SECURITYTOKEN + "&do=usersearch&fragment=" + username);
  1131. } else {
  1132. InfernoShoutboxControl.show_notice("Name must be 3 characters or more")
  1133. }
  1134. document.querySelector("#vbshout_pro_shoutbox_editor").value = '';
  1135. return false;
  1136. }
  1137. else if (message.substring(0, 5) == '!spam')
  1138. {
  1139. iboxoshouts.editor.value = '';
  1140. var spamCmd = message.split("|",3);
  1141. if (isNaN(spamCmd[1]))
  1142. {
  1143. iboxoshouts.show_notice(spamCmd[1]+' is not a number!');
  1144. }
  1145. else
  1146. {
  1147. var sbSpamTime = (iboxoshouts.floodtime * 1000) + 100;
  1148. var number2 = 0;
  1149. iboxoshouts.show_notice('Spamming "'+spamCmd[2]+'" <b class="highlight">'+spamCmd[1]+'</b> times, <a style="cursor: pointer;" id="killspam">click here</a> to cancel...');
  1150. leSBSpam = setInterval(function ()
  1151. {
  1152. number2++;
  1153. if (number2 > spamCmd[1])
  1154. {
  1155. return false;
  1156. }
  1157. jsShout(spamCmd[2]);
  1158. shoutsleft = spamCmd[1] - number2;
  1159. if (shoutsleft > 0)
  1160. {
  1161. iboxoshouts.show_notice('<b class="highlight">'+shoutsleft+'</b> shouts left to spam, <a style="cursor: pointer;" id="killspam">click here</a> to cancel...');
  1162. }
  1163. else
  1164. {
  1165. iboxoshouts.show_notice('Spam finished');
  1166. }
  1167. }, sbSpamTime);
  1168. }
  1169. return false;
  1170. }
  1171. else if (message == '!happy')
  1172. {
  1173. toggle_var_and_update_dropdown_element("bool_happyhour","sbm_dropdown_happyhour","Happy Hour");
  1174. if (sbm_getValue("bool_happyhour") == "enabled")
  1175. {
  1176. doHappyHourCSS(true);
  1177. }
  1178. else
  1179. {
  1180. doHappyHourCSS(false);
  1181. }
  1182. iboxoshouts.editor.value = '';
  1183. return false;
  1184. }
  1185. else
  1186. {
  1187. if (message == '')
  1188. {
  1189. iboxoshouts.show_notice('Please enter a message first.');
  1190. return false;
  1191. }
  1192. }
  1193.  
  1194. message = iboxoshouts.shout_params.prefix + message + iboxoshouts.shout_params.suffix;
  1195. iboxoshouts.posting_shout = true;
  1196. iboxoshouts.set_loader('');
  1197. iboxoshouts.shout.ajax = new vB_AJAX_Handler(true);
  1198. iboxoshouts.shout.ajax.onreadystatechange(InfernoShoutboxControl.shout_posted);
  1199. iboxoshouts.shout.ajax.send('infernoshout.php', 'do=shout&message=' + PHP.urlencode(message));
  1200. iboxoshouts.clear();
  1201. return false;
  1202. }
  1203. iboxoshouts.shout = iboxoshouts.new_shout;
  1204. // rewrite of update_shouts to add things
  1205. iboxoshouts.new_update_shouts = function(shouts)
  1206. {
  1207. iboxoshouts.shoutframe.innerHTML = '';
  1208.  
  1209. if (sbm_getValue("bool_smilies_fake") == "enabled")
  1210. {
  1211.  
  1212. var sSmil = JSON.parse(sbm_getValue("json_smilies_fake"));
  1213. for(var k in sSmil)
  1214. {
  1215. var re = new RegExp(k,"g");
  1216. shouts = shouts.replace(re, '<a href="'+sSmil[k]+'" target="_blank" title="'+[k]+'"><img src="'+sSmil[k]+'"></a>');
  1217. }
  1218. }
  1219.  
  1220. var sbpmInline = new RegExp("InfernoShoutboxControl.open_pm_tab","g");
  1221. shouts = shouts.replace(sbpmInline, "sbmodDropdownMenu");
  1222.  
  1223. iboxoshouts.shoutframe.innerHTML = shouts;
  1224.  
  1225. if (iboxoshouts.newestbottom && iboxoshouts.shoutframe.scrollTop < iboxoshouts.shoutframe.scrollHeight)
  1226. {
  1227. iboxoshouts.shoutframe.scrollTop = iboxoshouts.shoutframe.scrollHeight;
  1228. }
  1229.  
  1230. if (spam)
  1231. {
  1232. var trigger = '\u00D7';
  1233. if (shouts.indexOf(trigger) > -1)
  1234. {
  1235. killSpam('SHOOP DA WOOP');
  1236. }
  1237. }
  1238. };
  1239. iboxoshouts.update_shouts = iboxoshouts.new_update_shouts;
  1240.  
  1241. // rewrite of smilies_fetched to add smilies to the menu
  1242. iboxoshouts.new_smilies_fetched = function()
  1243. {
  1244. ajax = InfernoShoutboxControl.fetchsmilies.ajax;
  1245.  
  1246. if (ajax.handler.readyState == 4 && ajax.handler.status == 200)
  1247. {
  1248. InfernoShoutboxControl.set_loader('none');
  1249. InfernoShoutboxControl.fetchingsmilies = false;
  1250. InfernoShoutboxControl.smiliesbox.style.display = '';
  1251. InfernoShoutboxControl.smiliesrow.innerHTML = ajax.handler.responseText;
  1252.  
  1253. if (sbm_getValue("bool_smilies_hidden") == "enabled")
  1254. {
  1255. for(var k in sbm_smilies_hidden)
  1256. {
  1257. var HTML = '<span style="padding-right: 2px; padding-left: 2px">';
  1258. HTML += '<img ';
  1259. HTML += 'src="'+sbm_smilies_hidden[k]+'" ';
  1260. HTML += 'title="'+k+'" ';
  1261. HTML += 'onclick="InfernoShoutboxControl.append_smilie(\''+k+'\');" ';
  1262. HTML += 'onmouseover="this.style.cursor = \'pointer\';" ';
  1263. HTML += 'style="cursor: pointer; max-height: 40px">';
  1264. HTML += '</span>';
  1265. InfernoShoutboxControl.smiliesrow.innerHTML += HTML;
  1266. }
  1267. }
  1268.  
  1269. if (sbm_getValue("bool_smilies_elite") == "enabled")
  1270. {
  1271. for(var k in sbm_smilies_elite)
  1272. {
  1273. var HTML = '<span style="padding-right: 2px; padding-left: 2px">';
  1274. HTML += '<img ';
  1275. HTML += 'src="'+sbm_smilies_elite[k]+'" ';
  1276. HTML += 'title="'+k+'" ';
  1277. HTML += 'onclick="InfernoShoutboxControl.append_smilie(\''+k+'\');" ';
  1278. HTML += 'onmouseover="this.style.cursor = \'pointer\';" ';
  1279. HTML += 'style="cursor: pointer; max-height: 40px">';
  1280. HTML += '</span>';
  1281. InfernoShoutboxControl.smiliesrow.innerHTML += HTML;
  1282. }
  1283. }
  1284.  
  1285. if (sbm_getValue("bool_smilies_weed") == "enabled")
  1286. {
  1287. for(var k in sbm_smilies_weed)
  1288. {
  1289. var HTML = '<span style="padding-right: 2px; padding-left: 2px">';
  1290. HTML += '<img ';
  1291. HTML += 'src="'+sbm_smilies_weed[k]+'" ';
  1292. HTML += 'title="'+k+'" ';
  1293. HTML += 'onclick="InfernoShoutboxControl.append_smilie(\''+k+'\');" ';
  1294. HTML += 'onmouseover="this.style.cursor = \'pointer\';" ';
  1295. HTML += 'style="cursor: pointer; max-height: 40px">';
  1296. HTML += '</span>';
  1297. InfernoShoutboxControl.smiliesrow.innerHTML += HTML;
  1298. }
  1299. }
  1300.  
  1301. if (sbm_getValue("bool_smilies_fake") == "enabled")
  1302. {
  1303. var mSmil = JSON.parse(sbm_getValue("json_smilies_fake"));
  1304. for(var k in mSmil)
  1305. {
  1306. var fHTML = '<span style="padding-right: 2px; padding-left: 2px">';
  1307. fHTML += '<img ';
  1308. fHTML += 'src="'+mSmil[k]+'" ';
  1309. fHTML += 'title="'+k+'" ';
  1310. fHTML += 'onclick="InfernoShoutboxControl.append_smilie(\''+k+'\');" ';
  1311. fHTML += 'onmouseover="this.style.cursor = \'pointer\';" ';
  1312. fHTML += 'style="cursor: pointer; max-height: 40px">';
  1313. fHTML += '</span>';
  1314. InfernoShoutboxControl.smiliesrow.innerHTML += fHTML;
  1315. }
  1316. }
  1317. }
  1318. }
  1319.  
  1320. iboxoshouts.smilies_fetched = iboxoshouts.new_smilies_fetched;
  1321.  
  1322. //////// end of edited inferno functions //////
  1323. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1324. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1325. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1326. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  1327. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement