Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- JSChat v1.0
- Por edi472
- 05/07/2012
- (c) 2012
- */
- start = function (_chat) {
- var att = null;
- var exit = null;
- var lastmsg = null;
- var delay = 800;
- $(function () {
- $(window).bind("error", function (a) {
- chat.dialog("Erro", a.originalEvent["message"])
- });
- function sprintf(a,b){if(a.match(/%s/gi)){return a.replace(/%s/gi,b)}}
- chat = {
- startonwindow: function (a, b) {
- if (a == true && this.loggedin) {
- $('[name=chat-actions]').hide();
- $("[name=chat-tools],[name=chat-box]").show();
- $("[name=chat]").fadeIn(2100)
- }
- else {
- $('[name=chat-welcome-msg]').html("Crie sua conta já e participe também do meu chat! Espero que goste!");
- $("[name=chat]").fadeIn(2100);
- }
- b.setInterval(function () {
- $("button").button();
- $("input:text").addClass("input");
- $("input:password").addClass("input")
- }, 1);
- return this
- },
- check_nick: function (a) {
- $.ajax({
- url: "headers/check_nick.php?n=" + a.value,
- success: function (a) {
- if (a == 1) {
- chat.dialog("Opa", 'Parece que alguém já está usando o nick "<b>' + $("[name=chat-nick]").val() + '</b>"');
- $("[name=chat-nick]").val("").focus()
- }
- }
- })
- },
- dialog: function (a, b) {
- $('<div id="' + a + '" title="' + a + '" id="chat-' + Math.floor(Math.random() * Date.now()) + '">' + b + "</div>").dialog({
- close: function () {
- $("#id=" + a + "").dialog("destroy").remove()
- },
- width: "auto",
- modal: true
- })
- },
- auto_complete: function () {
- if (typeof array_users == "undefined") {
- $.getScript("headers/auto_complete.php", function () {
- $("[name=chat-nick-login]").autocomplete({
- source: array_users
- });
- return array_users
- })
- }
- else {
- $("[name=chat-nick-login]").autocomplete({
- source: array_users
- });
- return array_users
- }
- },
- logout: function () {
- $("#1").slideUp(500);
- $.get("headers/bye.php", {}, function (a) {
- if (a.match(/NO_/gi)) {
- location.reload()
- }
- else {
- location.reload();
- setTimeout(function () {
- location.reload();
- }, 2500)
- }
- })
- },
- see_error: function (a) {
- $("[name=chat-msg]").effect("highlight", 1100).val("").attr("placeholder", a).blur();
- return setTimeout(function () {
- $("[name=chat-msg]").removeAttr("placeholder").focus()
- }, delay)
- },
- reg: function () {
- $.post("headers/member.php?do=register", {
- psecretp: $("[name=chat-secret-question]").val(),
- RES: $("[name=chat-secret-aswner]").val(),
- packer: "++[md5]",
- captcha: $("[name=chat-captcha]").val(),
- login: $("[name=chat-nick]").val(),
- senha: $("[name=chat-pass]").val(),
- email: $("[name=chat-email]").val()
- }, function (p) {
- eval(p)
- })
- },
- login: function () {
- $.post("headers/member.php?do=login", {
- lembrar: $("input:checkbox").val(),
- login: $("[name=chat-nick-login]").val(),
- senha: $("[name=chat-pass-login]").val()
- }, function (p) {
- eval(p)
- })
- },
- update: function () {
- if (c === true) {
- $.ajax({
- url: "headers/member.php?do=see",
- cache: false,
- error: function () {
- chat.update()
- },
- success: function (a) {
- $("[name=chat-box]").html('<p align="left">' + a + "</p>").scrollTop($("[name=chat-box]")[0].scrollHeight)
- }
- })
- }
- }
- };
- $("[name=chat-send]").click(function () {
- msg = $("[name=chat-msg]").val();
- /*if (lastmsg === msg) {
- chat.see_error("Mensagem simultânea.");
- return false
- }*/
- if (msg.length > 50) {
- chat.see_error("Mensagem muito grande.");
- return false
- }
- else if (msg.length < 1) {
- chat.see_error("Mensagem muito pequena.");
- return false
- }
- if (msg.match(/\/last/gi)) {
- var a = msg.match(/\[(.*)\]/gi).toString().split("[")[1].split("]")[0];
- $.get("headers/last_entry.php?date=" + Date.now(), {
- nick: a
- }, function (b) {
- if (b !== "NO_EXISTS") {
- chat.dialog("Aviso", "A última visita do usuário <b>" + a + "</b> foi à " + b);
- $("[name=chat-msg").val("");
- return false
- }
- chat.dialog("Erro", "O usuário de nome <b>" + a + "</b> não existe.<br>Tente novamente.");
- $("[name=chat-msg").val("");
- return false
- })
- } else if(msg.match(/\/bye/gi)||msg.match(/\/logout/gi)) {
- } else if(msg.match(/\/commands/gi)) {
- if (!admin) chat.dialog("Comandos", "<b>/commands</b> - ver lista de comandos disponíveis<br><b>/pm [nick] [msg]</b> - mandar mensagem privada<br><b>/last [nick]</b> - ver última visita de um usuário");
- else chat.dialog("Comandos", "<b>/commands</b> - ver lista de comandos disponíveis<br><b>/pm [nick] [msg]</b> - mandar mensagem privada<br><b>/last [nick]</b> - ver última visita de um usuário<br><b>/ban [nick] [motivo]</b> - banir usuário</b><br><b>/superban [nick] [motivo]</b> - banir usuário deletando todos seus registros<br><b>/rank [nick] [rank]</b> - trocar rank do usuário (3-ADM, 2-MOD, 1-MEMBRO, 0-CONVIDADO)</b><br><b>/clear</b> - limpar mensagens da BOX<br><b>/nick [nick] [novo_nick]</b> - mudar nick de um usuário<br><b>/pm [nick] [msg]</b> - mandar mensagem privada<br><b>/alert [msg]</b> - mandar mensagem para todos]")
- } else if(msg.match(/\/online/gi)) {
- $.ajax({
- url: "headers/online.php?token=" + user_hash,
- error: function () {
- chat.dialog("Erro", "Tente novamente mais tarde.");
- },
- success: function (a) {
- $('<div name="wio" title="Usuários Online">' + a + "</div>").dialog({
- modal: true,
- resizable: false,
- close: function () {
- $("[name=wio]").dialog("destroy").remove()
- }
- })
- }
- })
- }
- $.post("headers/member.php?do=save", {
- m: msg
- }, function (a) {
- $("[name=chat-msg]").val("");
- chat.update()
- });
- return lastmsg = msg
- });
- $("[name=chat-logout]").click(function () {
- clearInterval(qaz);
- chat.logout()
- });
- $("[name=chat-msg]").keydown(function (a) {
- if (a.keyCode == 13) {
- $("[name=chat-send]").click()
- }
- });
- qaz = _chat.setInterval("chat.update()", 5000);
- return this
- })
- }(window)
Advertisement
Add Comment
Please, Sign In to add comment