Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.01 KB | None | 0 0
  1. /***
  2. * Application: Staff's ChatBox.
  3. * Description: Exclusive chat room for your forum staff.
  4. * Version: 2.02112015-jq1.9.1 - (wizard) Nesu, neb Tot.
  5. * Made and Optimizations by JScript - 2015/02/11
  6. * Copyright (c) 2015 JScript <jscriptbrasil at live dot com>
  7. * This work is free. You can redistribute it and/or modify it
  8. * under the terms of the WTFPL, Version 2
  9. */
  10. (function() {
  11. (function($) {
  12. jQuery.assyncFor = function(arr, callback) {
  13. for (var i = 0, len = arr.length; i < len; ++i) {
  14. var boundCallback = callback.bind(null, i, arr[i]);
  15. setTimeout(boundCallback, i)
  16. }
  17. return this
  18. }
  19. }(jQuery));
  20. chatStaff = {
  21. autor: "JScript",
  22. version: "2.02112015-jq1.9.1",
  23. codename: "(wizard) Nesu, neb Tot.",
  24. readLoop: 0,
  25. readInterval: 6000,
  26. startingMsg: "Iniciando, aguarde...",
  27. restartMsg: "Mensagens reiniciadas",
  28. mentionMsg: "Inserir o nome no shout",
  29. editChatMsg: "Editar",
  30. delChatMsg: "Remover",
  31. sendError: "Atenção!\n\n Ocorreu um erro ao enviar a mensagem. Aguarde 10 segundos e tente de novo!",
  32. removeError: "Atenção!\n\n Ocorreu um erro ao removar a mensagem. Aguarde 10 Segundos e tente de novo!",
  33. uninstallMsg: "Staff's ChatBox - 2.02112015-jq1.9.1, by JScript!\n\nBem-vindo ao desinstalador de Chatbox da equipe, quer continuar com a desinstalação?",
  34. uninstallMsg: "Staff's ChatBox - 2.02112015-jq1.9.1, by JScript!\\n\\nWBem-vindo ao desinstalador de Chatbox da equipe, quer continuar com a desinstalação?",
  35. stopRead: 0,
  36. postSize: 0,
  37. founder: undefined,
  38.  
  39. oPost: {
  40. user: [],
  41. msgs: []
  42. },
  43.  
  44. oBBCode: {
  45. patt: [
  46. /\[b](.*?)\[\/b]/gi,
  47. /\[i](.*?)\[\/i]/gi,
  48. /\[u](.*?)\[\/u]/gi,
  49. /\[s](.*?)\[\/s]/gi,
  50. /\[center](.*?)\[\/center]/gi,
  51. /\[size=(.*?)](.*?)\[\/size]/gi,
  52. /\[url](.*?)\[\/url]/gi,
  53. /\[url=(.*?)](.*?)\[\/url]/gi,
  54. /\[color=(.*?)](.*?)\[\/color]/gi,
  55. /\[img](.*?)\[\/img]/gi,
  56. /\[spoiler](.*?)\[\/spoiler]/gi,
  57. /\[code](.*?)\[\/code]/gi,
  58. /\[quote](.*?)\[\/quote]/gi,
  59. /\[quote=(.*?)](.*?)\[\/quote]/gi
  60. ],
  61.  
  62. html: [
  63. "<strong>$1</strong>",
  64. "<i>$1</i>",
  65. "<span style='text-decoration:underline;'>$1</span>",
  66. "<span style='text-decoration:line-through'>$1</span>",
  67. "<div style='margin:auto;text-align:center;width:100%'>$1</div>",
  68. "<span style='font-size: $1;'>$2</span>",
  69. "<a rel='nofollow' target='_blank' href='$1'>$1</a>",
  70. "<a rel='nofollow' target='_blank' href='$1'>$2</a>",
  71. "<span style='color: $1'>$2</span>",
  72. "<img src='$1' style='max-width:120px;max-height:120px;'/>",
  73. "<dl class='codebox spoiler'><dt style='cursor: pointer;'>Spoiler:</dt><dd><div class='spoiler_content'>$1</div></dd></dl>",
  74. "<dl class='codebox spoiler'><dt style='cursor: pointer;'>$1</dt><dd><div class='spoiler_content'>$2</div></dd></dl>",
  75. "<dl class='codebox'><dt>Código:</dt><dd class='cont_code'><code>$1</code></dd></dl>",
  76. "<blockquote><div>$1</div></blockquote>",
  77. "<blockquote><div>$2</div></blockquote>"
  78. ]
  79. },
  80.  
  81. initialize: function() {
  82. jQuery(function() {
  83. if (_userdata.user_level > 0) {
  84. if (!String.prototype.repeat) {
  85. String.prototype.repeat = function(count) {
  86. return (count < 1) ? "" : Array(count + 1).join(this.valueOf())
  87. }
  88. };
  89. chatStaff.setupChatbox()
  90. }
  91. })
  92. },
  93.  
  94. setupChatbox: function() {
  95. jQuery("head").append(
  96. "<style type='text/css'>" +
  97. ".jschatbox_container.row1 {" +
  98. " border: 1px solid #dbe4ef;" +
  99. "}" +
  100. ".message.block_wrap {" +
  101. " background: none repeat scroll 0 0 #ebfcdf;" +
  102. " border: 1px solid #a4cfa4;" +
  103. " color: #0e440e;" +
  104. " font-size: 12px;" +
  105. " line-height: 1.6;" +
  106. " padding: 10px;" +
  107. "}" +
  108. ".jschatbox_container .content {" +
  109. " border-bottom: 1px solid #f3f3f3 !important;" +
  110. " overflow: visible !important;" +
  111. " padding: 4px;" +
  112. "}" +
  113. "#staff-chatbox-shouts {" +
  114. " border: 1px solid #d5dde5;" +
  115. "}" +
  116. "#staff-chatbox-shouts > div {" +
  117. " border-bottom: 1px solid #d5dde5;" +
  118. " padding: 4px;" +
  119. " font-size: 12px;" +
  120. " line-height: 135%;" +
  121. " min-height: 35px;" +
  122. " margin: 0;" +
  123. "}" +
  124. ".altrow_avatar {" +
  125. " float: left;" +
  126. " padding-right: 4px;" +
  127. "}" +
  128. ".jschat_avatar {" +
  129. " background: none repeat scroll 0 0 #fff;" +
  130. " border: 1px solid #d5d5d5 !important;" +
  131. " box-shadow: 0 2px 2px rgba(0, 0, 0, 0.1);" +
  132. " height: 30px;" +
  133. " padding: 1px;" +
  134. " vertical-align: middle;" +
  135. " width: 30px;" +
  136. "}" +
  137. ".right.desc {" +
  138. " color: #777;" +
  139. " float: right;" +
  140. " font-size: 12px;" +
  141. "}" +
  142. ".altrow_text .right.desc > img {" +
  143. " cursor: pointer;" +
  144. "}" +
  145. ".shout_text {" +
  146. " display: block;" +
  147. " padding-top: 3px;" +
  148. " word-wrap: break-word;" +
  149. "}" +
  150. ".shout_text > img {" +
  151. " margin-bottom: 0 !important;" +
  152. " vertical-align: middle;" +
  153. "}" +
  154. "#rt_input {" +
  155. " font-family: inherit;" +
  156. " font-size: inherit;" +
  157. " vertical-align: middle;" +
  158. "}" +
  159. "#staff-shouts-resizer {" +
  160. " background-color: #dbe2ec;" +
  161. " cursor: n-resize;" +
  162. " height: 6px;" +
  163. "}" +
  164. ".message.error.block_wrap {" +
  165. " background-color: #f3e3e6;" +
  166. " border-color: #e599aa;" +
  167. " color: #80001c;" +
  168. " font-size: 12px;" +
  169. " line-height: 1.6;" +
  170. " padding: 10px;" +
  171. "}" +
  172. ".jschatbox_container .input_text, .jschatbox_container .input_submit {" +
  173. " padding: 4px;" +
  174. " vertical-align: middle;" +
  175. "}" +
  176. ".jschatbox_container .button2 {" +
  177. " cursor: pointer;" +
  178. " margin-left: 4px;" +
  179. "}" +
  180. "#staff-smiles-show {" +
  181. " background: none no-repeat scroll center center rgb(255, 255, 255);" +
  182. " border: 2px solid #d2d2d2;" +
  183. " height: 250px;" +
  184. " overflow: auto;" +
  185. " padding-top: 6px;" +
  186. " position: absolute;" +
  187. " width: 225px;" +
  188. " z-index: 99999;" +
  189. "}" +
  190. "#staff-smiles-show > p {" +
  191. " margin: 0;" +
  192. "}" +
  193. "#staff-smiles-show p a {" +
  194. " margin-bottom: 14px;" +
  195. "}" +
  196. "#staff-smiles-show a {" +
  197. " display: inline-block;" +
  198. " font-size: 18px;" +
  199. " margin-bottom: 5px;" +
  200. " margin-left: 10px;" +
  201. " text-decoration: none;" +
  202. "}" +
  203. "</style>"
  204. );
  205. jQuery("a[href^='/f1-']")
  206. .closest(".topiclist.forums")
  207. .html(
  208. "<div class='jschatbox_container row1'>" +
  209. " <div class='content row2' id='staff-announcement-row' style='display: none;'>" +
  210. " <div class='message block_wrap' id='staff-announcement-text'></div>" +
  211. " </div>" +
  212. " <div class='content top row1'>" +
  213. " <div id='staff-chatbox-shouts' style='top: 0px; height: 225px; min-height: 155px; left: 0px; overflow: auto;'>" +
  214. " <div id='shout-row-0' class='row2' style='padding: 8px;'>" +
  215. " <span class='altrow_text'>" +
  216. " <span class='shout_text' style='font-size: 18px;'><strong>" + chatStaff.startingMsg + "</strong></span>" +
  217. " </span>" +
  218. " </div>" +
  219. " </div>" +
  220. " <div id='staff-shouts-resizer' title='Click to resize' oncontextmenu='localStorage.removeItem(&quot;shout_height&quot;);return false;' onmousedown='chatStaff.resize();'></div>" +
  221. " <div style='display: none;' class='message error block_wrap' id='staff-shoutbox-error'></div>" +
  222. " </div>" +
  223. " <div class='content bottom row1'>" +
  224. " <div valign='top' class='footer altrow' colspan='2'>" +
  225. " <input type='text' id='staff-shout-input' size='75' class='input_text'>" +
  226. " <input type='button' onclick='chatStaff.submitShout();' id='staff-submit-button' value='Enviar' class='button2 input_submit'>" +
  227. " <input type='button' onclick='document.getElementById(&quot;staff-shout-input&quot;).value = &quot;&quot;;' id='staff-clear-button' value='Limpar' class='button2 input_submit'>" +
  228. " <input type='button' onclick='chatStaff.refresh(true);' id='staff-refresh-button' value='Atualizar' class='button2 input_submit'>" +
  229. " <input type='button' onclick='chatStaff.showSmile(event);' id='staff-smiles-button' value='Emotions' class='button2 input_submit'>" +
  230. " <div id='staff-smiles-show' style='display: none;'></div>" +
  231. " </div>" +
  232. " </div>" +
  233. "</div>"
  234. )
  235. .closest(".forabg")
  236. .find(".topics, .posts, .lastpost")
  237. .remove();
  238.  
  239. if (localStorage.getItem("shout_height")) {
  240. jQuery("#staff-chatbox-shouts").css("height", localStorage.getItem("shout_height"))
  241. }
  242. jQuery("#staff-shout-input").keydown(function(e) {
  243. if (e.keyCode == 13 && jQuery("#staff-shout-input").val() !== "") {
  244. chatStaff.submitShout()
  245. }
  246. });
  247. chatStaff.refresh(true);
  248. chatStaff.readLoop = setInterval("chatStaff.refresh()", chatStaff.readInterval);
  249. chatStaff.loadSmile()
  250. },
  251.  
  252. dataRead: function(callback) {
  253. jQuery.ajax({
  254. url: '/t1-',
  255. cache: false,
  256. type: "get",
  257. dataType: "text",
  258. success: callback
  259. })
  260. },
  261.  
  262. dataSave: function(failMsg) {
  263. failMsg = failMsg || "";
  264. jQuery.post('/post?p=1&mode=editpost', {
  265. subject: "chat_staff_db",
  266. message: JSON.stringify(chatStaff.oPost),
  267. edit_reason: "",
  268. attach_sig: 0,
  269. notify: 0,
  270. post: 1
  271. }).done(function() {
  272. chatStaff.stopRead = 0
  273. }).fail(function() {
  274. if (failMsg.length) {
  275. alert(failMsg)
  276. }
  277. chatStaff.stopRead = 0
  278. })
  279. },
  280.  
  281. parseDB: function(response, refresh) {
  282. refresh = refresh || false;
  283. response = /{"user":.+}]}/i.exec(jQuery(response).text());
  284. if (response !== null) {
  285. response = response[0];
  286. if (refresh && chatStaff.postSize == response.length) {
  287. return false
  288. }
  289. chatStaff.postSize = response.length;
  290. chatStaff.oPost = JSON.parse(response);
  291. if (refresh) {
  292. chatStaff.getMsgs(function() {
  293. document.getElementById("staff-chatbox-shouts").scrollTop = 999999
  294. });
  295. }
  296. }
  297. return true
  298. },
  299.  
  300. refresh: function(force) {
  301. force = force || false;
  302. if (!force && chatStaff.stopRead) {
  303. return false
  304. }
  305. chatStaff.dataRead(function(response, status, xhr) {
  306. if (xhr.status == 200) {
  307. chatStaff.parseDB(response, true)
  308. }
  309. })
  310. },
  311.  
  312. resize: function() {
  313. var element = jQuery("#staff-chatbox-shouts");
  314. jQuery(document).mousemove(function(event) {
  315. element.css("height", event.pageY - element.offset().top);
  316. document.getElementById("staff-chatbox-shouts").scrollTop = 999999
  317. }).mouseup(function() {
  318. jQuery(document).unbind("mouseup").unbind("mousemove");
  319. localStorage.setItem("shout_height", element.css("height"))
  320. })
  321. },
  322.  
  323. getUser: function(id) {
  324. var user = chatStaff.oPost.user;
  325. for (var i = 0, len = user.length; i < len; i++) {
  326. if (user[i].id === id) {
  327. return user[i]
  328. }
  329. }
  330. return null
  331. },
  332.  
  333. addMsg: function(id, msg, idx) {
  334. idx = idx || chatStaff.oPost.msgs.length;
  335. if (!chatStaff.getUser(id)) {
  336. chatStaff.oPost.user.push({
  337. id: _userdata.user_id,
  338. name: _userdata.username,
  339. pname: encodeURIComponent(jQuery('a[href="/u' + _userdata.user_id + '"]').slice(-1)[0].innerHTML),
  340. avatar: jQuery(_userdata.avatar).attr("src")
  341. })
  342. }
  343. return (msg.length) ? chatStaff.oPost.msgs[idx] = {
  344. id: _userdata.user_id,
  345. msg: encodeURIComponent(msg).replace(/%20/g, " "),
  346. date: Math.round(new Date().getTime() / 1000)
  347. } : chatStaff.oPost.msgs[idx] = null
  348. },
  349.  
  350. delMsg: function(index) {
  351. return chatStaff.oPost.msgs.splice(index, 1)
  352. },
  353.  
  354. editMsg: function(index, value) {
  355. return chatStaff.oPost.msgs[index].msg = encodeURIComponent(value).replace(/%20/g, " ")
  356. },
  357.  
  358. getMsgs: function(callback) {
  359. var aMsgLen = chatStaff.oPost.msgs.length - 1,
  360. user = 0,
  361. epoch = "",
  362. posts = "";
  363. $.assyncFor(chatStaff.oPost.msgs, function(i, value) {
  364. user = chatStaff.getUser(value.id);
  365. epoch = new Date(value.date * 1000);
  366. posts +=
  367. '<div id="shout-row-' + i + '" class="row2">' +
  368. ' <span class="altrow_avatar">' +
  369. ' <img width="30" height="30" class="jschat_avatar" src="' + user.avatar + '" alt="avatar">' +
  370. ' </span>' +
  371. ' <span class="altrow_name">' +
  372. ' <a title="' + chatStaff.mentionMsg + '" data-store="' + user.name +
  373. ' " class="at_member" onclick="chatStaff.insertMember(this);return false;" href="#">@</a>&nbsp;' +
  374. ' <a title="" rel="nofollow" target="_blank" href="/u' + user.id + '" class="hover_url">' + user.pname + '</a>&nbsp;:' +
  375. ' </span>' +
  376. ' <span class="altrow_text">' +
  377. ' <span title="" class="right desc">(' + epoch.toLocaleString() + " )&nbsp;";
  378. if ((user.id == _userdata.user_id) && (i > 0)) {
  379. posts +=
  380. ' <img alt="' + chatStaff.editChatMsg + '" onclick="chatStaff.editShout(' + i + ', 0, this)" src="https://i.servimg.com/u/f59/18/17/62/92/commen10.png">&nbsp;' +
  381. ' <img alt="' + chatStaff.delChatMsg + '" onclick="chatStaff.editShout(' + i + ', 1, this)" src="https://i.servimg.com/u/f59/18/17/62/92/delete10.png">'
  382. }
  383. posts +=
  384. ' </span>' +
  385. ' <span class="shout_text">' + value.msg + '</span>' +
  386. ' </span>' +
  387. '</div>';
  388.  
  389. if (i == aMsgLen) {
  390. posts = posts.replace(/%0A|%5Cn/gi, "<br>");
  391. posts = decodeURIComponent(posts);
  392. /*
  393. if (/\[url]/gi.test(data)) {
  394. data = data.replace(/\[url]([\s\S]*?)\[\/url]/gi, "<a rel='nofollow' target='_blank' href='$1'>$1</a>");
  395. } else if (/\[url=/gi.test(data)) {
  396. data = data.replace(/\[url=([\s\S]*?)]([\s\S]*?)\[\/url]/gi, "<a rel='nofollow' target='_blank' href='$1'>$2</a>");
  397. } else {
  398. data = data.replace(/((?:https?|ftp)%3A%2F%2F[A-Z0-9+&@#\/%?=~_|$!:,.;-]*[A-Z0-9+&@#\/%=~_|$])/gi, "<a rel='nofollow' target='_blank' href='$1'>$1</a>");
  399. }
  400. */
  401. var pattLen = chatStaff.oBBCode.patt.length - 1,
  402. html = chatStaff.oBBCode.html;
  403. $.assyncFor(chatStaff.oBBCode.patt, function(i, value) {
  404. posts = posts.replace(value, html[i]);
  405.  
  406. if (i == pattLen) {
  407. jQuery("#staff-chatbox-shouts").html(posts);
  408. callback();
  409. }
  410. });
  411. }
  412. });
  413. },
  414.  
  415. submitShout: function() {
  416. var user_msg = jQuery("#staff-shout-input").val();
  417. if (user_msg == "") {
  418. return false
  419. }
  420. chatStaff.stopRead = 1;
  421. jQuery("#staff-shout-input").val("");
  422. switch (user_msg) {
  423. case "/cls":
  424. chatStaff.oPost.user = [];
  425. chatStaff.oPost.msgs = [];
  426. user_msg = chatStaff.restartMsg;
  427. jQuery("#staff-chatbox-shouts").html("");
  428. break;
  429. case "/stop":
  430. jQuery("#staff-chatbox-shouts").css({
  431. "opacity": "0.4",
  432. "-moz-opacity": "0.4",
  433. "filter": "alpha(opacity=40)"
  434. });
  435. return false;
  436. break;
  437. case "/start":
  438. chatStaff.stopRead = 0;
  439. jQuery("#staff-chatbox-shouts").css({
  440. "opacity": "1",
  441. "-moz-opacity": "1",
  442. "filter": "alpha(opacity=100)"
  443. });
  444. return false;
  445. break;
  446. case "/uninstall":
  447. if (chatStaff.confirm(chatStaff.uninstallMsg)) {
  448. jQuery("#staff-shoutbox-error").show();
  449. return chatStaff.uninstall()
  450. }
  451. return false;
  452. break
  453. }
  454. chatStaff.dataRead(function(response, status, xhr) {
  455. if (xhr.status == 200) {
  456. if (chatStaff.oPost.msgs.length) {
  457. chatStaff.parseDB(response)
  458. }
  459. if (chatStaff.postSize > 14000) {
  460. chatStaff.oPost.msgs.splice(0, 1);
  461. chatStaff.oPost.msgs.splice(1, 1)
  462. }
  463. chatStaff.addMsg(_userdata.user_id, user_msg);
  464. chatStaff.getMsgs(function() {
  465. document.getElementById("staff-chatbox-shouts").scrollTop = 999999;
  466. chatStaff.dataSave(chatStaff.sendError)
  467. });
  468. }
  469. })
  470. },
  471.  
  472. editShout: function(index, mode, vData) {
  473. chatStaff.stopRead = 1;
  474. if (mode == 0) {
  475. var td = jQuery(vData).closest(".altrow_text"),
  476. width = td.width() - td.find(".right.desc").width(),
  477. height = td.height(),
  478. sHtml =
  479. "<span class='shout_text' id='staff-shout-edit'>" +
  480. " <textarea id='rt_input' style='width: " + width + "px; height: " + height + "px;'>" + decodeURIComponent(chatStaff.oPost.msgs[index].msg) + "</textarea>" +
  481. " <input type='submit' id='rt_submit' class='button2' value='Save' onclick='chatStaff.editShout(" + index + ", 2, jQuery(\"#rt_input\").val());return false;' style='margin-right: 4px;'>" +
  482. " <a title='Cancel' href='javascript:void(0);' onclick='var oEdit = jQuery(\"#staff-shout-edit\");oEdit.next().show();oEdit.prev().show();oEdit.remove();chatStaff.stopRead = 0;return false;'>Cancel</a>" +
  483. "</span>";
  484. td.find(".right.desc").hide();
  485. td.find(".shout_text").hide().before(sHtml);
  486. return false
  487. }
  488. chatStaff.dataRead(function(response, status, xhr) {
  489. if (xhr.status == 200) {
  490. chatStaff.parseDB(response);
  491. (mode == 2) ? chatStaff.editMsg(index, vData): chatStaff.delMsg(index);
  492. chatStaff.getMsgs(function() {
  493. chatStaff.dataSave(chatStaff.removeError)
  494. });
  495. }
  496. })
  497. },
  498.  
  499. loadSmile: function() {
  500. jQuery.ajax({
  501. url: "/post?mode=smilies",
  502. cache: true,
  503. type: "get",
  504. dataType: "text",
  505. success: function(response, status, xhr) {
  506. if (xhr.status == 200) {
  507. var htmlSmile = jQuery("<div>" + response + "</div>");
  508. htmlSmile.find("#smilies_categ, p, span").remove();
  509. htmlSmile.html(htmlSmile.html().replace(/insert_chatboxsmilie/g, "chatStaff.insertSmile"));
  510.  
  511. var oTarget = htmlSmile.find("a"),
  512. alen = oTarget.length - 1,
  513. oThis, patt, regex,
  514. pHtml = chatStaff.oBBCode.patt,
  515. bHtml = chatStaff.oBBCode.html;
  516. $.assyncFor(oTarget, function(i, value) {
  517. oThis = jQuery(value);
  518. patt = /\('(.*?)'\)/i.exec(oThis.attr("href"))[1];
  519. regex = new RegExp("(?:^|\\s)" + patt.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\^\$\|]/g, "\\$&") + "(?:\\s|$)", "gi");
  520. pHtml.push(regex);
  521. bHtml.push(oThis.html());
  522.  
  523. if (i == alen) {
  524. var aSmiles = [
  525. "&phone;", "&starf;", "&hearts;", "&sung;", "&check;",
  526. "&boxbox;", "©", "&Jscr;&Sscr;", "&block;", "&blk34;",
  527. "&xcirc;", "&star;", "&clubs;", "&cross;", "&Fscr;&Mscr;"
  528. ],
  529. sSmiles = "<p>";
  530. for (var i = 0, len = aSmiles.length; i < len; i++) {
  531. sSmiles += "<a href='#' onclick='chatStaff.insertSmile(\"" + aSmiles[i] + "\");return false;'>" + aSmiles[i] + "</a>"
  532. }
  533. sSmiles += "</p>";
  534. jQuery("#staff-smiles-show").html(sSmiles + htmlSmile.find("#simple-wrap, tbody:last").html())
  535. }
  536. });
  537. }
  538. }
  539. })
  540. },
  541.  
  542. showSmile: function(event) {
  543. var elenPos = jQuery("#staff-smiles-button"),
  544. target = jQuery("#staff-smiles-show");
  545. target.css({
  546. "left": (elenPos.offset().left + elenPos.outerWidth()) - target.outerWidth(),
  547. "top": elenPos.offset().top - target.outerHeight()
  548. });
  549. return (target[0].style.display == "none") ? target.fadeIn("fast") : target.fadeOut("fast")
  550. },
  551.  
  552. insertSmile: function(smile) {
  553. var id = document.getElementById("rt_input") || document.getElementById("staff-shout-input");
  554. id.focus();
  555. id.value += " " + smile + " ";
  556. document.getElementById("staff-smiles-show").style.display = "none"
  557. },
  558.  
  559. insertMember: function(oThis) {
  560. var id = document.getElementById("staff-shout-input");
  561. id.focus();
  562. id.value += "@" + oThis.getAttribute("data-store") + " -> "
  563. },
  564.  
  565. confirm: function(text) {
  566. return (confirm(text) == true) ? true : false
  567. },
  568.  
  569. uninstall: function() {
  570. var TID = jQuery('a[href*="tid="]').attr("href").split("tid=")[1].split("&")[0],
  571. prgBar = parseInt((jQuery("#staff-shoutbox-error").width() / 4) / 9);
  572. document.getElementById("staff-shoutbox-error").innerHTML += "&blk34;".repeat(prgBar);
  573. jQuery.ajax({
  574. url: "/admin/index?part=general&sub=general&mode=edit&fid=f82&extended_admin=1&tid=" + TID,
  575. type: "post",
  576. data: {
  577. fid: "f1",
  578. mode: "delete",
  579. move: -2,
  580. selected_id: "Root",
  581. update: "Delete"
  582. },
  583. dataType: "html",
  584. success: function(response, status, xhr) {
  585. document.getElementById("staff-shoutbox-error").innerHTML += "&blk34;".repeat(prgBar);
  586. if (xhr.status == 200) {
  587. var response = jQuery(response);
  588. if (response.find(".successbox") !== null) {
  589. jQuery.ajax({
  590. url: "/admin/index?mode=js&part=modules&sub=html&tid=" + TID,
  591. type: "get",
  592. dataType: "html",
  593. success: function(response, status, xhr) {
  594. document.getElementById("staff-shoutbox-error").innerHTML += "&blk34;".repeat(prgBar);
  595. if (xhr.status == 200) {
  596. var response = jQuery(response);
  597. var JS = response.find("#listJs td:contains('Module: chat_staff_db')").closest("tr").find("td:last input").val();
  598. jQuery.ajax({
  599. url: "/admin/index?part=modules&sub=html&mode=js&extended_admin=1&tid=" + TID,
  600. type: "post",
  601. data: {
  602. conf: [JS],
  603. confirm: 1,
  604. mode: "js_delete"
  605. },
  606. dataType: "html",
  607. success: function(response, status, xhr) {
  608. document.getElementById("staff-shoutbox-error").innerHTML += "&blk34;".repeat(prgBar);
  609. if (xhr.status == 200) {
  610. alert("The staff's chat box has been uninstalled from your forum!");
  611. window.location.reload(true)
  612. }
  613. }
  614. })
  615. }
  616. }
  617. })
  618. }
  619. }
  620. }
  621. })
  622. }
  623. };
  624.  
  625. chatStaff.initialize()
  626. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement