Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***
- * Application: Staff\'s ChatBox - Installer module.
- * Description: Install an exclusive chat room for your forum staff.
- * Version: 2.02112015-jq1.9.1 - (wizard) Nesu, neb Tot.
- * Made and Optimizations by JScript - 2014/12/06, 2015/02/11
- * Copyright (c) 2015 JScript <jscriptbrasil at live dot com>
- * This work is free. You can redistribute it and/or modify it
- * under the terms of the WTFPL, Version 2
- */
- var install = {
- version: "2.02112015-jq1.9.1",
- codeName: "(wizard) Nesu, neb Tot.",
- author: "JScript",
- contact: "jscriptbrasil at live dot com",
- installMsg: "Bine ai venit in panoul de instalare Staff Chatbox!\n\nDoriti sa-l instalati?",
- uninstallMsg: "Bine ai venit in panoul de dezinstalare Staff Chatbox! Doriti sa-l dezinstalati?",
- instMsg1: "Creez suportul pentru structura bazei de date, asteptati...",
- instMsg2: "Actualizez permisiunile petru administratori si moderatori, asteptati...",
- instMsg3: "Creez baza de date locala, asteptati...",
- instMsg4: "Copiez codul interfetei chatbox, asteptati...",
- instMsg5: "Instalare finalizata!\n\nReinprospatati pagina pentru a vedea chatbox-ul!",
- dinstMsg1: "Elimin suportul pentru structura bazei de date, asteptati...",
- dinstMsg2: "Elimin codul interfetei chatbox...",
- dinstMsg3: "Modulul Staff Chatbox a fost eliminat cu succes de pe forumul dumneavoastra.",
- create: {
- auth_copy: 0,
- desc: "Staff Chatbox va fi vizibil doar administratorilor si moderator! Puteti schimba permisiunile din <i>Panou => General => Forum => Categorii si forumuri => <span style='color:red;'><b>Staff Chatbox</b></span></i> pentru a adauga alte grupuri.<br />" +
- "<br/><br/>Comenzi disponibile:<br /><b>/dezinstalare</b> - Pentru a dezinstala acest chat (doar fondatorul este autorizat)<br /><b>/curata</b> - Pentru a sterge toate mesajele din chat, inclusiv acest mesaj <br /><b>/stop</b> - Opreste chat-ul<br /> <b>/start</b> - Porneste chat-ul",
- fid: "",
- image: "",
- main: -1,
- mode: "create",
- name: "Staff Chatox",
- order_posts: 1,
- order_topics: 1,
- position: "f0",
- preset_choice: 0,
- prune_days: 90,
- prune_enable: 0,
- prune_freq: 7,
- rule_display: {
- 0: "on"
- },
- rule_img_url: "",
- rule_msg: "",
- selected_id: "Root",
- status: 0,
- type: "f",
- update: 1
- },
- permissions: {
- fid: 0,
- forum_preset_read: "",
- forum_preset_view_images: 0,
- forum_preset_view_links: 0,
- forum_preset_write: "",
- group: {
- mod: {
- 2: "on"
- },
- view: {
- 2: "on"
- },
- write: {
- 2: "on"
- }
- },
- mode: "auth",
- preset_choice: 0,
- selected_id: "Root",
- simple_auth: 1,
- update: 1
- },
- topicDB: {
- subject: "baza_de_date_chatbox",
- message: "",
- topictype: 0,
- mode: 'newtopic',
- f: 0,
- post: 1
- },
- DB_edit: "",
- DB_url: "",
- TID: 0,
- founder: undefined,
- updateProgressBar: function(value) {
- var width = Math.round((value * 100) / 100);
- document.getElementById("shout-installer-prg").style.width = width + '%';
- }
- };
- jQuery(window).load(function() {
- if (_userdata.user_level !== 1) {
- return false;
- }
- install.TID = jQuery('a[href*="tid="]').attr('href').split('tid=')[1].split('&')[0]; //Get the var {TID}
- /*
- $.ajax({
- url: "/admin/index.forum?part=themes&tid=" + install.TID,
- type: 'get',
- async: false,
- dataType: 'html',
- success: function(response, status, xhr) {
- if (xhr.status == 200) {
- install.founder = $(response).find('a[href^="/admin/index.forum?mode=main&part=themes&sub=templates"]').attr('href');
- }
- }
- });
- if (install.founder == undefined) {
- return false;
- }
- */
- if (!__iConfirm(install.create.name + " - " + install.version + ", creat de " + install.author + "!\n\n" + install.installMsg)) {
- return false;
- }
- $('body').prepend('<div id="document_modal" class="modal" style="z-index: 10000; left: 0px; opacity: 0.4; position: fixed; top: 0px; height: 100%; width: 100%; background-color: rgb(62, 62, 62);"></div>');
- if ($('table.bodylinewidth').length) {
- //phpBB2
- $('body').prepend(
- '<table cellspacing="1" cellpadding="0" border="0" class="forumline" style="position: fixed; top: 20%; left: 30%; right: 30%; min-width: 400px; z-index: 10001;">' +
- ' <tbody>' +
- ' <tr>' +
- ' <td height="25" class="catLeft">' +
- ' <span class="genmed module-title">Staff Chatbox - Instalare modul</span>' +
- ' </td>' +
- ' </tr>' +
- ' <tr>' +
- ' <td align="left" class="row1">' +
- ' <div style="border: 1px solid rgb(210, 210, 210); box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.07); padding: 5px;">' +
- ' <div id="shout-installer-msg" style="font-size: 14px; font-weight: bold; padding: 5px; margin-top: 15px; word-wrap: break-word;"></div>' +
- ' <div style="border: 1px solid rgb(210, 210, 210); margin-top: 20px; padding: 4px 2px 5px; margin-bottom: 10px; font-size: 16px;">' +
- ' <div style="height: 20px; padding: 0px; background-color: rgb(205, 205, 205);" id="shout-installer-prg"></div>' +
- ' </div>' +
- ' </div>' +
- ' </td>' +
- ' </tr>' +
- ' </tbody>' +
- '</table>'
- );
- } else {
- //phpBB3, PunBB, Invision
- $('body').prepend(
- '<div class="module main borderwrap" style="position: fixed; top: 20%; left: 30%; right: 30%; min-width: 400px; z-index: 10001;">' +
- ' <span class="corners-top"><span></span></span>' +
- ' <div class="main-head inner">' +
- ' <div class="maintitle genmed module-title">' +
- ' <h3>Staff Chatbox - Instalare modul</h3>' +
- ' </div>' +
- ' </div>' +
- ' <div class="main-content clearfix box-content" style="background-color: rgb(251, 251, 251); border: 1px solid rgb(221, 221, 221);">' +
- ' <div style="border: 1px solid rgb(210, 210, 210); box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.07); padding: 5px;">' +
- ' <div id="shout-installer-msg" style="font-size: 14px; font-weight: bold; padding: 5px; margin-top: 15px; word-wrap: break-word;"></div>' +
- ' <div style="border: 1px solid rgb(210, 210, 210); margin-top: 20px; padding: 4px 2px 5px; margin-bottom: 10px; font-size: 16px;">' +
- ' <div style="height: 20px; padding: 0px; background-color: rgb(205, 205, 205);" id="shout-installer-prg" class="maintitle genmed module-title"></div>' +
- ' </div>' +
- ' </div>' +
- ' </div>' +
- ' <span class="corners-bottom"><span></span></span>' +
- '</div>'
- );
- }
- var msgElem = document.getElementById("shout-installer-msg");
- msgElem.innerHTML = install.instMsg1;
- install.updateProgressBar(5);
- $.ajax({
- url: "/admin/index.forum?part=general&sub=general&mode=create&fid=&extended_admin=1&tid=" + install.TID,
- type: 'post',
- data: install.create,
- dataType: 'html',
- success: function(response, status, xhr) {
- if (xhr.status == 200) {
- var response = $(response);
- if (response.find('.successbox') !== null) {
- var FID = response.find('input[name="fid"]').val();
- install.permissions.fid = FID;
- msgElem.innerHTML = install.instMsg2;
- install.updateProgressBar(15);
- $.ajax({
- url: "/admin/index.forum?part=general&sub=general&mode=auth&fid=" + FID + "&extended_admin=1&tid=" + install.TID,
- type: 'post',
- data: install.permissions,
- dataType: 'html',
- success: function(response, status, xhr) {
- if (xhr.status == 200) {
- var firstPost = {
- user: [{
- id: _userdata.user_id,
- name: _userdata.username,
- pname: encodeURIComponent($('a[href="/u' + _userdata.user_id + '"]')[0].innerHTML),
- avatar: $(_userdata.avatar).attr("src")
- }],
- msgs: [{
- id: _userdata.user_id,
- msg: encodeURIComponent(install.create.desc).replace(/%20/g, " "),
- date: Math.round(new Date().getTime() / 1000)
- //date: (new Date().toLocaleTimeString().substr(0, 5)) + " - " + (new Date().toLocaleDateString()) //IE fail...
- //date: (new Date().toLocaleTimeString().split(':').slice(0, 2).join(':')) + " - " + (new Date().toLocaleDateString())
- }]
- };
- install.topicDB.message = JSON.stringify(firstPost);
- install.topicDB.f = FID.substr(1);
- msgElem.innerHTML = install.instMsg3;
- install.updateProgressBar(25);
- $.ajax({
- url: "/post",
- type: 'post',
- data: install.topicDB,
- dataType: 'html',
- success: function(response, status, xhr) {
- if (xhr.status == 200) {
- var parse = /url=.*t=([0-9]+).*#([0-9]+)/ig.exec(response);
- if (parse !== null) {
- install.DB_url = "/t" + parse[1] + "-" + install.topicDB.subject;
- install.DB_edit = "/post?p=" + parse[2] + "&mode=editpost";
- __install_ChatBox(msgElem);
- }
- }
- }
- });
- }
- }
- });
- }
- }
- }
- });
- function __iConfirm(text) {
- return (confirm(text) == true) ? true : false;
- };
- });
- function __install_ChatBox(msgElem) {
- var chatbox_script = function() {
- // "For" asynchronous loop, faster and does not lock the browser interface when you have many messages!
- (function($) {
- jQuery.assyncFor = function(arr, callback) {
- for (var i = 0, len = arr.length; i < len; ++i) {
- var boundCallback = callback.bind(null, i, arr[i]);
- setTimeout(boundCallback, i);
- }
- return this;
- };
- }(jQuery));
- chatStaff = {
- autor: "JScript",
- version: "$install.version$",
- codename: "$install.codeName$",
- readLoop: 0,
- readInterval: 6000 /*Below this is danger!*/ ,
- startingMsg: "Va rugam asteptati...",
- restartMsg: "<span style='color: green;font-style: italic;'>Baza de date a fost reinitializata cu succes!</span>",
- mentionMsg: "Insert name into Shout",
- editChatMsg: "Editeaza",
- delChatMsg: "Sterge",
- sendError: "Atentie!\n\n A aparut o problema in momentul trimiterii mesajului, va rugam asteptati 10 secunde.",
- removeError: "Atentie!\n\n A aparut o problema in momentul editarii mesajului, va rugam asteptati 10 secunde!",
- uninstallMsg: "Staff ChatBox - $install.version$, creat de JScript!\n\nSunteti pe cale sa dezinstalati Staff Chatbox, doriti sa continuati?",
- uninstallMsg: "$install.create.name$ - $install.version$, creat de $install.author$!\n\n$install.uninstallMsg$",
- stopRead: 0,
- postSize: 0,
- founder: undefined,
- oPost: {
- user: [],
- msgs: []
- },
- oBBCode: {
- patt: [
- /\[b](.*?)\[\/b]/gi,
- /\[i](.*?)\[\/i]/gi,
- /\[u](.*?)\[\/u]/gi,
- /\[s](.*?)\[\/s]/gi,
- /\[center](.*?)\[\/center]/gi,
- /\[size=(.*?)](.*?)\[\/size]/gi,
- /\[url](.*?)\[\/url]/gi,
- /\[url=(.*?)](.*?)\[\/url]/gi,
- /\[color=(.*?)](.*?)\[\/color]/gi,
- /\[img](.*?)\[\/img]/gi,
- /\[spoiler](.*?)\[\/spoiler]/gi,
- /\[spoiler](.*?)\[\/spoiler]/gi,
- /\[code](.*?)\[\/code]/gi,
- /\[quote](.*?)\[\/quote]/gi,
- /\[quote=(.*?)](.*?)\[\/quote]/gi
- ],
- html: [
- "<strong>$1</strong>",
- "<i>$1</i>",
- "<span style='text-decoration:underline;'>$1</span>",
- "<span style='text-decoration:line-through'>$1</span>",
- "<div style='margin:auto;text-align:center;width:100%'>$1</div>",
- "<span style='font-size: $1;'>$2</span>",
- "<a rel='nofollow' target='_blank' href='$1'>$1</a>",
- "<a rel='nofollow' target='_blank' href='$1'>$2</a>",
- "<span style='color: $1'>$2</span>",
- "<img src='$1' style='max-width:120px;max-height:120px;'/>",
- "<dl class='codebox spoiler'><dt style='cursor: pointer;'>Spoiler:</dt><dd><div class='spoiler_content'>$1</div></dd></dl>",
- "<dl class='codebox spoiler'><dt style='cursor: pointer;'>$1</dt><dd><div class='spoiler_content'>$2</div></dd></dl>",
- "<dl class='codebox'><dt>CΓ³digo:</dt><dd class='cont_code'><code>$1</code></dd></dl>",
- "<blockquote><div>$1</div></blockquote>",
- "<blockquote><div>$2</div></blockquote>"
- ]
- },
- initialize: function() {
- jQuery(function() {
- if (_userdata.user_level > 0) {
- if (!String.prototype.repeat) { /* String repeat - By JScript */
- String.prototype.repeat = function(count) {
- return (count < 1) ? "" : Array(count + 1).join(this.valueOf())
- };
- };
- chatStaff.setupChatbox();
- }
- });
- },
- setupChatbox: function() {
- jQuery("head").append(
- "<style type='text/css'>" +
- ".jschatbox_container.row1 {" +
- " border: 1px solid #dbe4ef;" +
- "}" +
- ".message.block_wrap {" +
- " background: none repeat scroll 0 0 #ebfcdf;" +
- " border: 1px solid #a4cfa4;" +
- " color: #0e440e;" +
- " font-size: 12px;" +
- " line-height: 1.6;" +
- " padding: 10px;" +
- "}" +
- ".jschatbox_container .content {" +
- " border-bottom: 1px solid #f3f3f3 !important;" +
- " overflow: visible !important;" +
- " padding: 4px;" +
- "}" +
- "#staff-chatbox-shouts {" +
- " border: 1px solid #d5dde5;" +
- "}" +
- "#staff-chatbox-shouts > div {" +
- " border-bottom: 1px solid #d5dde5;" +
- " padding: 4px;" +
- " font-size: 12px;" +
- " line-height: 135%;" +
- " min-height: 35px;" +
- " margin: 0;" +
- "}" +
- ".altrow_avatar {" +
- " float: left;" +
- " padding-right: 4px;" +
- "}" +
- ".jschat_avatar {" +
- " background: none repeat scroll 0 0 #fff;" +
- " border: 1px solid #d5d5d5 !important;" +
- " box-shadow: 0 2px 2px rgba(0, 0, 0, 0.1);" +
- " height: 30px;" +
- " padding: 1px;" +
- " vertical-align: middle;" +
- " width: 30px;" +
- "}" +
- ".right.desc {" +
- " color: #777;" +
- " float: right;" +
- " font-size: 12px;" +
- "}" +
- ".altrow_text .right.desc > img {" +
- " cursor: pointer;" +
- "}" +
- ".shout_text {" +
- " display: block;" +
- " padding-top: 3px;" +
- " word-wrap: break-word;" +
- "}" +
- ".shout_text > img {" +
- " margin-bottom: 0 !important;" +
- " vertical-align: middle;" +
- "}" +
- "#rt_input {" +
- " font-family: inherit;" +
- " font-size: inherit;" +
- " vertical-align: middle;" +
- "}" +
- "#staff-shouts-resizer {" +
- " background-color: #dbe2ec;" +
- " cursor: n-resize;" +
- " height: 6px;" +
- "}" +
- ".message.error.block_wrap {" +
- " background-color: #f3e3e6;" +
- " border-color: #e599aa;" +
- " color: #80001c;" +
- " font-size: 12px;" +
- " line-height: 1.6;" +
- " padding: 10px;" +
- "}" +
- ".jschatbox_container .input_text, .jschatbox_container .input_submit {" +
- " padding: 4px;" +
- " vertical-align: middle;" +
- "}" +
- ".jschatbox_container .button2 {" +
- " cursor: pointer;" +
- " margin-left: 4px;" +
- "}" +
- "#staff-smiles-show {" +
- " background: none no-repeat scroll center center rgb(255, 255, 255);" +
- " border: 2px solid #d2d2d2;" +
- " height: 250px;" +
- " overflow: auto;" +
- " padding-top: 6px;" +
- " position: absolute;" +
- " width: 225px;" +
- " z-index: 99999;" +
- "}" +
- "#staff-smiles-show > p {" +
- " margin: 0;" +
- "}" +
- "#staff-smiles-show p a {" +
- " margin-bottom: 14px;" +
- "}" +
- "#staff-smiles-show a {" +
- " display: inline-block;" +
- " font-size: 18px;" +
- " margin-bottom: 5px;" +
- " margin-left: 10px;" +
- " text-decoration: none;" +
- "}" +
- "</style>"
- );
- jQuery("#$install.permissions.fid$, a[href^='/$install.permissions.fid$']")
- .closest("#$install.permissions.fid$, .main-content, .topiclist.forums, .forumline tr")
- .html(
- "<div class='jschatbox_container row1'>" +
- " <div class='content row2' id='staff-announcement-row' style='display: none;'>" +
- " <div class='message block_wrap' id='staff-announcement-text'></div>" +
- " </div>" +
- " <div class='content top row1'>" +
- " <div id='staff-chatbox-shouts' style='top: 0px; height: 225px; min-height: 155px; left: 0px; overflow: auto;'>" +
- " <p id='shout-row-0' class='row2' style='padding: 8px;'>" +
- " <span class='altrow_text'>" +
- " <span class='shout_text' style='font-size: 18px;'><strong>" + chatStaff.startingMsg + "</strong></span>" +
- " </span>" +
- " </p>" +
- " </div>" +
- " <div id='staff-shouts-resizer' title='Click to resize' oncontextmenu='localStorage.removeItem("shout_height");return false;' onmousedown='chatStaff.resize();'></div>" +
- " <div style='display: none;' class='message error block_wrap' id='staff-shoutbox-error'></div>" +
- " </div>" +
- " <div class='content bottom row1'>" +
- " <div valign='top' class='footer altrow' colspan='2'>" +
- " <input type='text' id='staff-shout-input' size='75' class='input_text'>" +
- " <input type='button' onclick='chatStaff.submitShout();' id='staff-submit-button' value='Trimite' class='button2 input_submit'>" +
- " <input type='button' onclick='document.getElementById("staff-shout-input").value = "";' id='staff-clear-button' value='Curatare' class='button2 input_submit'>" +
- " <input type='button' onclick='chatStaff.refresh(true);' id='staff-refresh-button' value='Reinprospatare' class='button2 input_submit'>" +
- " <input type='button' onclick='chatStaff.showSmile(event);' id='staff-smiles-button' value='Smile-uri' class='button2 input_submit'>" +
- /*" <input type='button' class='button2 input_submit' value='BBCode' id='staff-bbcode-button'>" +*/
- " <div id='staff-smiles-show' style='display: none;'></div>" +
- " </div>" +
- " </div>" +
- "</div>"
- )
- .closest(".forabg, .table, tbody")
- .find(".topics, .posts, .lastpost, th:not(:first)")
- .remove();
- if (localStorage.getItem("shout_height")) {
- jQuery("#staff-chatbox-shouts").css("height", localStorage.getItem("shout_height"));
- }
- jQuery("#staff-shout-input").keydown(function(e) {
- if (e.keyCode == 13 && jQuery("#staff-shout-input").val() !== "") {
- chatStaff.submitShout();
- }
- });
- chatStaff.refresh(true);
- chatStaff.readLoop = setInterval("chatStaff.refresh()", chatStaff.readInterval);
- chatStaff.loadSmile();
- },
- dataRead: function(callback) {
- jQuery.ajax({
- url: '$install.DB_url$',
- cache: false,
- type: "get",
- dataType: "text",
- success: callback
- });
- },
- dataSave: function(failMsg) {
- failMsg = failMsg || "";
- jQuery.post('$install.DB_edit$', {
- subject: "$install.topicDB.subject$",
- message: JSON.stringify(chatStaff.oPost),
- edit_reason: "",
- attach_sig: 0,
- notify: 0,
- post: 1
- }).done(function() {
- /*
- chatStaff.getMsgs(function() {
- document.getElementById("staff-chatbox-shouts").scrollTop = 999999;
- });
- */
- chatStaff.stopRead = 0;
- }).fail(function() {
- if (failMsg.length) {
- alert(failMsg);
- }
- chatStaff.stopRead = 0;
- });
- },
- parseDB: function(response, refresh) {
- refresh = refresh || false;
- response = /{"user":.+}]}/i.exec(jQuery(response).text());
- /*response = jQuery("td > .postbody div, div.postbody > .content div, div.entry-content > div > div, div.post-entry div", response).first().text();*/
- if (response !== null) {
- response = response[0];
- if (refresh && chatStaff.postSize == response.length) {
- return false;
- }
- chatStaff.postSize = response.length;
- chatStaff.oPost = JSON.parse(response);
- if (refresh) {
- chatStaff.getMsgs(function() {
- document.getElementById("staff-chatbox-shouts").scrollTop = 999999
- });
- }
- }
- return true
- },
- refresh: function(force) {
- force = force || false;
- if (!force && chatStaff.stopRead) {
- return false;
- }
- chatStaff.dataRead(function(response, status, xhr) {
- if (xhr.status == 200) {
- chatStaff.parseDB(response, true);
- }
- });
- },
- resize: function() {
- var element = jQuery("#staff-chatbox-shouts");
- jQuery(document).mousemove(function(event) {
- element.css("height", event.pageY - element.offset().top);
- document.getElementById("staff-chatbox-shouts").scrollTop = 999999;
- }).mouseup(function() {
- jQuery(document).unbind("mouseup").unbind("mousemove");
- localStorage.setItem("shout_height", element.css("height"));
- });
- },
- getUser: function(id) {
- var user = chatStaff.oPost.user;
- for (var i = 0, len = user.length; i < len; i++) {
- if (user[i].id === id) {
- return user[i];
- }
- }
- return null;
- },
- addMsg: function(id, msg, idx) {
- idx = idx || chatStaff.oPost.msgs.length;
- if (!chatStaff.getUser(id)) {
- chatStaff.oPost.user.push({
- id: _userdata.user_id,
- name: _userdata.username,
- pname: encodeURIComponent(jQuery('a[href="/u' + _userdata.user_id + '"]').slice(-1)[0].innerHTML),
- avatar: jQuery(_userdata.avatar).attr("src")
- });
- }
- return (msg.length) ?
- chatStaff.oPost.msgs[idx] = {
- id: _userdata.user_id,
- msg: encodeURIComponent(msg).replace(/%20/g, " "),
- date: Math.round(new Date().getTime() / 1000)
- //date: (new Date().toLocaleTimeString().substr(0, 5)) + " - " + (new Date().toLocaleDateString()) //IE fail...
- //date: (new Date().toLocaleTimeString().split(":").slice(0, 2).join(":")) + " - " + (new Date().toLocaleDateString())
- } :
- chatStaff.oPost.msgs[idx] = null;
- },
- delMsg: function(index) {
- return chatStaff.oPost.msgs.splice(index, 1);
- },
- editMsg: function(index, value) {
- return chatStaff.oPost.msgs[index].msg = encodeURIComponent(value).replace(/%20/g, " ");
- },
- getMsgs: function(callback) {
- var aMsgLen = chatStaff.oPost.msgs.length - 1,
- user = 0,
- epoch = "",
- posts = "";
- $.assyncFor(chatStaff.oPost.msgs, function(i, value) {
- user = chatStaff.getUser(value.id);
- epoch = new Date(value.date * 1000);
- posts +=
- '<div id="shout-row-' + i + '" class="row2">' +
- ' <span class="altrow_avatar">' +
- ' <img width="30" height="30" class="jschat_avatar" src="' + user.avatar + '" alt="avatar">' +
- ' </span>' +
- ' <span class="altrow_name">' +
- ' <a title="' + chatStaff.mentionMsg + '" data-store="' + user.name +
- ' " class="at_member" onclick="chatStaff.insertMember(this);return false;" href="#">@</a> ' +
- ' <a title="" rel="nofollow" target="_blank" href="/u' + user.id + '" class="hover_url">' + user.pname + '</a> :' +
- ' </span>' +
- ' <span class="altrow_text">' +
- ' <span title="" class="right desc">(' + epoch.toLocaleString() + " ) ";
- if ((user.id == _userdata.user_id) && (i > 0)) {
- posts +=
- ' <img alt="' + chatStaff.editChatMsg + '" onclick="chatStaff.editShout(' + i + ', 0, this)" src="http://i59.servimg.com/u/f59/18/17/62/92/commen10.png"> ' +
- ' <img alt="' + chatStaff.delChatMsg + '" onclick="chatStaff.editShout(' + i + ', 1, this)" src="http://i59.servimg.com/u/f59/18/17/62/92/delete10.png">'
- }
- posts +=
- ' </span>' +
- ' <span class="shout_text">' + value.msg + '</span>' +
- ' </span>' +
- '</div>';
- if (i == aMsgLen) {
- posts = posts.replace(/%0A|%5Cn/gi, "<br>");
- posts = decodeURIComponent(posts);
- /*
- if (/\[url]/gi.test(data)) {
- data = data.replace(/\[url]([\s\S]*?)\[\/url]/gi, "<a rel='nofollow' target='_blank' href='$1'>$1</a>");
- } else if (/\[url=/gi.test(data)) {
- data = data.replace(/\[url=([\s\S]*?)]([\s\S]*?)\[\/url]/gi, "<a rel='nofollow' target='_blank' href='$1'>$2</a>");
- } else {
- data = data.replace(/((?:https?|ftp)%3A%2F%2F[A-Z0-9+&@#\/%?=~_|$!:,.;-]*[A-Z0-9+&@#\/%=~_|$])/gi, "<a rel='nofollow' target='_blank' href='$1'>$1</a>");
- }
- */
- var pattLen = chatStaff.oBBCode.patt.length - 1,
- html = chatStaff.oBBCode.html;
- $.assyncFor(chatStaff.oBBCode.patt, function(i, value) {
- posts = posts.replace(value, html[i]);
- if (i == pattLen) {
- jQuery("#staff-chatbox-shouts").html(posts);
- callback();
- }
- });
- }
- });
- },
- submitShout: function() {
- var user_msg = jQuery("#staff-shout-input").val();
- if (user_msg == "") {
- return false;
- }
- chatStaff.stopRead = 1;
- jQuery("#staff-shout-input").val("");
- switch (user_msg) {
- case "/curata":
- chatStaff.oPost.user = [];
- chatStaff.oPost.msgs = [];
- user_msg = chatStaff.restartMsg;
- jQuery("#staff-chatbox-shouts").html("");
- break;
- case "/stop":
- jQuery("#staff-chatbox-shouts").css({
- "opacity": "0.4",
- "-moz-opacity": "0.4",
- "filter": "alpha(opacity=40)"
- });
- return false;
- break;
- case "/start":
- chatStaff.stopRead = 0;
- jQuery("#staff-chatbox-shouts").css({
- "opacity": "1",
- "-moz-opacity": "1",
- "filter": "alpha(opacity=100)"
- });
- return false;
- break;
- case '/info':
- return alert(
- chatStaff.info.Title +
- '\n\nVersiune: ' + chatStaff.info.Version +
- '\nData lansarii: ' + chatStaff.info.Release +
- '\nTip Cod:: ' + chatStaff.info.codeName +
- '\nAutor: ' + chatStaff.info.Author +
- '\nCopyright: ' + chatStaff.info.copyRight
- );
- break;
- case "/dezinstalare":
- if (chatStaff.confirm(chatStaff.uninstallMsg)) {
- jQuery("#staff-shoutbox-error").show();
- return chatStaff.uninstall();
- }
- return false;
- break;
- }
- chatStaff.dataRead(function(response, status, xhr) {
- if (xhr.status == 200) {
- if (chatStaff.oPost.msgs.length) {
- chatStaff.parseDB(response);
- }
- if (chatStaff.postSize > 14000) {
- chatStaff.oPost.msgs.splice(0, 1);
- chatStaff.oPost.msgs.splice(1, 1);
- }
- chatStaff.addMsg(_userdata.user_id, user_msg);
- chatStaff.getMsgs(function() {
- document.getElementById("staff-chatbox-shouts").scrollTop = 999999;
- chatStaff.dataSave(chatStaff.sendError)
- });
- }
- });
- },
- editShout: function(index, mode, vData) {
- chatStaff.stopRead = 1;
- if (mode == 0) {
- var td = jQuery(vData).closest(".altrow_text"),
- width = td.width() - td.find(".right.desc").width(),
- height = td.height(),
- sHtml =
- "<span class='shout_text' id='staff-shout-edit'>" +
- /*" <input type='text' maxlength='1024' size='50' class='input_text' value='" + decodeURIComponent(chatStaff.oPost.msgs[index].msg) + "' id='rt_input' style='width: 56%; margin-right: 4px;'>" +*/
- " <textarea id='rt_input' style='width: " + width + "px; height: " + height + "px;'>" + decodeURIComponent(chatStaff.oPost.msgs[index].msg) + "</textarea>" +
- " <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;'>" +
- " <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>" +
- "</span>";
- td.find(".right.desc").hide();
- td.find(".shout_text").hide().before(sHtml);
- return false;
- }
- chatStaff.dataRead(function(response, status, xhr) {
- if (xhr.status == 200) {
- chatStaff.parseDB(response);
- (mode == 2) ? chatStaff.editMsg(index, vData): chatStaff.delMsg(index);
- chatStaff.getMsgs(function() {
- chatStaff.dataSave(chatStaff.removeError)
- });
- }
- });
- },
- loadSmile: function() {
- jQuery.ajax({
- url: "/post?mode=smilies",
- cache: true,
- type: "get",
- dataType: "text",
- success: function(response, status, xhr) {
- if (xhr.status == 200) {
- var htmlSmile = jQuery("<div>" + response + "</div>");
- htmlSmile.find("#smilies_categ, p, span").remove();
- htmlSmile.html(htmlSmile.html().replace(/insert_chatboxsmilie/g, "chatStaff.insertSmile"));
- var oTarget = htmlSmile.find("a"),
- alen = oTarget.length - 1,
- oThis, patt, regex,
- pHtml = chatStaff.oBBCode.patt,
- bHtml = chatStaff.oBBCode.html;
- $.assyncFor(oTarget, function(i, value) {
- oThis = jQuery(value);
- patt = /\('(.*?)'\)/i.exec(oThis.attr("href"))[1];
- regex = new RegExp("(?:^|\\s)" + patt.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\^\$\|]/g, "\\$&") + "(?:\\s|$)", "gi");
- pHtml.push(regex);
- bHtml.push(oThis.html());
- if (i == alen) {
- var aSmiles = [
- "☎", "★", "♥", "♪", "✓",
- "⧉", "©", "𝒥𝒮", "█", "▓",
- "◯", "☆", "♣", "✗", "ℱℳ"
- ],
- sSmiles = "<p>";
- for (var i = 0, len = aSmiles.length; i < len; i++) {
- sSmiles += "<a href='#' onclick='chatStaff.insertSmile(\"" + aSmiles[i] + "\");return false;'>" + aSmiles[i] + "</a>"
- }
- sSmiles += "</p>";
- jQuery("#staff-smiles-show").html(sSmiles + htmlSmile.find("#simple-wrap, tbody:last").html())
- }
- });
- }
- }
- })
- },
- showSmile: function(event) {
- var elenPos = jQuery("#staff-smiles-button"),
- target = jQuery("#staff-smiles-show");
- target.css({
- "left": (elenPos.offset().left + elenPos.outerWidth()) - target.outerWidth(),
- "top": elenPos.offset().top - target.outerHeight()
- });
- return (target[0].style.display == "none") ? target.fadeIn("fast") : target.fadeOut("fast");
- },
- insertSmile: function(smile) {
- var id = document.getElementById("rt_input") || document.getElementById("staff-shout-input");
- id.focus();
- id.value += " " + smile + " ";
- document.getElementById("staff-smiles-show").style.display = "none";
- },
- insertMember: function(oThis) {
- var id = document.getElementById("staff-shout-input");
- id.focus();
- id.value += "@" + oThis.getAttribute("data-store") + " -> ";
- },
- confirm: function(text) {
- return (confirm(text) == true) ? true : false;
- },
- // Basic info...
- info: {
- Title: "Staff Chatbox",
- Version: "$install.version$",
- Release: "31.05.2015",
- codeName: "sosrio",
- Author: "JScript - 11.02.2015",
- copyRight: "(c) 2015 JScript <jscriptbrasil la live punct com>\nContributia mea a fost gratuita. Redistribuirea sau modificarea trebuie sa se faca conform termenilor WTFPL, Versiunea 2"
- },
- uninstall: function() {
- var TID = jQuery('a[href*="tid="]').attr("href").split("tid=")[1].split("&")[0],
- prgBar = parseInt((jQuery("#staff-shoutbox-error").width() / 4) / 9);
- document.getElementById("staff-shoutbox-error").innerHTML += "▓".repeat(prgBar);
- jQuery.ajax({
- url: "/admin/index.forum?part=general&sub=general&mode=edit&fid=$install.permissions.fid$&extended_admin=1&tid=" + TID,
- type: "post",
- data: {
- fid: "$install.permissions.fid$",
- mode: "delete",
- move: -2,
- selected_id: "Root",
- update: "Delete"
- },
- dataType: "html",
- success: function(response, status, xhr) {
- document.getElementById("staff-shoutbox-error").innerHTML += "▓".repeat(prgBar);
- if (xhr.status == 200) {
- var response = jQuery(response);
- if (response.find(".successbox") !== null) {
- jQuery.ajax({
- url: "/admin/index.forum?mode=js&part=modules&sub=html&tid=" + TID,
- type: "get",
- dataType: "html",
- success: function(response, status, xhr) {
- document.getElementById("staff-shoutbox-error").innerHTML += "▓".repeat(prgBar);
- if (xhr.status == 200) {
- var response = jQuery(response);
- var JS = response.find("#listJs td:contains('Modul: $install.topicDB.subject$')").closest("tr").find("td:last input").val();
- jQuery.ajax({
- url: "/admin/index.forum?part=modules&sub=html&mode=js&extended_admin=1&tid=" + TID,
- type: "post",
- data: {
- conf: [JS],
- confirm: 1,
- mode: "js_delete"
- },
- dataType: "html",
- success: function(response, status, xhr) {
- document.getElementById("staff-shoutbox-error").innerHTML += "▓".repeat(prgBar);
- if (xhr.status == 200) {
- alert("$install.dinstMsg3$");
- window.location.reload(true);
- }
- }
- });
- }
- }
- });
- }
- }
- }
- });
- }
- };
- chatStaff.initialize();
- };
- chatbox_script =
- '/***\n' +
- ' * Application: Staff\'s ChatBox.\n' +
- ' * Description: Exclusive chat room for your forum staff.\n' +
- ' * Version: ' + install.version + ' - ' + install.codeName + '\n' +
- ' * Made and Optimizations by JScript - 2015/02/11\n' +
- ' * Copyright (c) 2015 JScript <jscriptbrasil at live dot com>\n' +
- ' * This work is free. You can redistribute it and/or modify it\n' +
- ' * under the terms of the WTFPL, Version 2\n' +
- ' */\n\n' +
- "(" +
- chatbox_script.toString()
- .replace(/\$install.version\$/g, install.version)
- .replace(/\$install.codeName\$/g, install.codeName)
- .replace(/\$install.create.name\$/g, install.create.name)
- .replace(/\$install.author\$/g, install.author)
- .replace(/\$install.uninstallMsg\$/g, install.uninstallMsg)
- .replace(/\$install.permissions.fid\$/g, install.permissions.fid)
- .replace(/\$install.DB_url\$/g, install.DB_url)
- .replace(/\$install.DB_edit\$/g, install.DB_edit)
- .replace(/\$install.topicDB.subject\$/g, install.topicDB.subject)
- .replace(/\$install.dinstMsg1\$/g, install.dinstMsg1)
- .replace(/\$install.dinstMsg2\$/g, install.dinstMsg2)
- .replace(/\$install.dinstMsg3\$/g, install.dinstMsg3) +
- ")();"
- ;
- msgElem.innerHTML = install.instMsg4;
- install.updateProgressBar(45);
- jQuery.post('/admin/index.forum?part=modules&sub=html&mode=js_edit&extended_admin=1&tid=' + install.TID, { /* <- Parameters! */
- /* Post action */
- title: 'Modul: ' + install.topicDB.subject,
- js_placement: ['index'],
- type: 0,
- content: chatbox_script,
- mode: 'save',
- submit: 1
- }).done(function() {
- install.updateProgressBar(65);
- jQuery.ajax({
- url: "/admin/index.forum?mode=js&part=modules&sub=html&tid=" + install.TID,
- type: "get",
- dataType: "html",
- success: function(response, status, xhr) {
- if (xhr.status == 200) {
- var response = jQuery(response);
- var JS = response.find("#listJs td:contains(\'@instalare_chat\')").closest("tr").find("td:last input").val();
- install.updateProgressBar(85);
- jQuery.ajax({
- url: "/admin/index.forum?part=modules&sub=html&mode=js&extended_admin=1&tid=" + install.TID,
- type: "post",
- data: {
- conf: [JS],
- confirm: 1,
- mode: "js_delete"
- },
- dataType: "html",
- success: function(response, status, xhr) {
- if (xhr.status == 200) {
- install.updateProgressBar(100);
- alert(install.instMsg5);
- window.location.reload(true);
- }
- }
- });
- }
- }
- });
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement