";
- this.config.custom_placement || (this.get_template_item("usercount").innerHTML = c);
- this.get_template_item("userlist").innerHTML = 0 < c ? d : '
' + this.t("No users online") + "
"
- },
- update_messages: function (a) {
- var b = this,
- c = {},
- d = f(document.createElement("div")),
- e = "",
- t = function (a, b) {
- if (b) return c[a] = 0;
- a in c ? c[a]++ : c[a] = 1
- };
- this.array_walk("a", a, function (a, c) {
- var h = f('
[' + a.datetime + "]
");
- if ("msg" !== a.action) switch (a.action) {
- case "connect":
- return e += "[" + a.datetime + "] " + a.msg + "\n", h.append(' ' + a.msg + ""), d[b.settings.on("newest first") ? "prepend" : "append"](h)
- } else if (!b.settings.value("ignored")["u" + a.userId]) {
- var g = f('' + a.msg + ""),
- k = g[0].getElementsByTagName("table")[0],
- q = "public",
- l = "' + (a.user.admin ? b.t("@") : "") + " " + a.username + ": ";
- a.user.avatar && (l = '' + l);
- if (k && k.className && /^a_chat_(pm|cmd|tab)$/.test(k.className)) {
- var q = k.className.replace("a_chat_", ""),
- p = k.getElementsByTagName("td")[0].innerHTML,
- m = k.getElementsByTagName("td")[1].innerHTML;
- f(k).replaceWith('')
- }
- a.userId = parseInt(a.userId);
- switch (q) {
- case "pm":
- if (!b.config.allow_private_messaging) return console.log("AWCError 202: Private messaging is turned off and therefore can not be displayed.");
- q = b.tabs.safe_name(p).split("]-[~~SPLITTER~~]-[");
- k = b.tabs.create["private"](q);
- if (b.tabs.can_view(k) && b.tabs.can_view(k, a.userId) && (b.tabs.get(k.id) || b.tabs.add(k), t(k.id), b.tabs.in_tab() && b.tabs.current === k.id)) {
- h.addClass("chat_private_message");
- window.LGBB && (m = LGBB.parse(m));
- f("#AWCMESSAGESWITCH", g).replaceWith(b.filter(m)).prepend('' + b.t("Private message") + ": ");
- break
- }
- return;
- case "cmd":
- if ("pub" === m && (q = "public"), "me" === p) {
- var r = k.getElementsByTagName("td")[2].innerHTML,
- k = b.tabs.get(m),
- l = !1;
- if (k) {
- if (p = k.name, m = "* " + a.username + " " + r + "", "public" === q) {
- if (b.tabs.in_tab()) return;
- g.html(m);
- break
- }
- } else return
- } else {
- if ("cleartab" === p) {
- if (b.get_user(a.userId).staff && (t(m, !0), b.tabs.current === m)) {
- d.empty();
- f("#AWCMESSAGESWITCH", g).replaceWith("* " + b.t("Tab cleared by") + " " + a.username + "");
- l = !1;
- break
- }
- return
- }
- if ("nudge" !== p && "global" === p) {
- t(m);
- r = k.getElementsByTagName("td")[2].innerHTML;
- f("#AWCMESSAGESWITCH", g).replaceWith(b.t("Global") + ": " + b.filter(r));
- break
- }
- }
- case "tab":
- r = b.tabs.create_id(p);
- k = b.tabs.get(r);
- if (!k)
- if (b.get_user(a.userId).staff && !avacweb_chat_config.tabs[p]) k = b.tabs.create.user(p, a.username), b.tabs.add(k);
- else return;
- if (b.tabs.can_view(k)) {
- t(r);
- if (b.tabs.current !== r) return;
- "tab" === q ? (window.LGBB && (m = LGBB.parse(m)), f("#AWCMESSAGESWITCH", g).replaceWith(b.filter(m))) : g.html(b.filter(m));
- break
- }
- return;
- case "public":
- t("pub");
- if (b.tabs.in_tab()) return;
- m = g.html();
- window.LGBB && (m = LGBB.parse(m));
- g.html(b.filter(m))
- }
- l && (h.append(l), a.userId === b.user("id") && h.addClass("my_message"));
- e += "[" + a.datetime + "] " + a.username + ": " + g.text() + "\n";
- h.append(g);
- d[b.settings.on("newest first") ? "prepend" : "append"](h)
- }
- });
- this.plain_text = e;
- this.get_template_item("messages").innerHTML = this.settings.on("plain text") ? e.replace(/[\r\n]+/g, " ") : d.html();
- d.empty();
- delete d;
- this.check_tab_counts(c);
- this.tabs.save()
- },
- check_tab_counts: function (a) {
- var b = !1,
- c = 0,
- d;
- for (d in a) {
- var e = this.tabs.get(d);
- e && this.tabs.can_view(e) && (0 !== e.count && a[d] !== e.count && ((b = document.getElementById("achat_tab_" + d)) && !f(b).hasClass("selected") && f(b).addClass("new"), b = !0), c += a[d] - e.count, this.tabs.data[d].count = a[d])
- }
- b && this.alert_new_messages(c)
- },
- alert_new_messages: function (a) {
- this.event.fire("onnew", a) && !this.settings.on("reading") && (this.settings.on("open") || this.config.custom_placement || f("#avacweb_chat_button").addClass("newmsg"))
- },
- get_user: function (a) {
- var b = {
- id: 0,
- username: "Guest",
- staff: !1,
- color: "none",
- online: !1
- };
- return "string" === typeof a ? this.user_data[a] ? this.user_data[a] : b : this.user_data["u" + a] ? this.user_data["u" + a] : b
- },
- user: function (a) {
- return this.get_user(this._user.user_id)[a]
- },
- array_walk: function (a, b, c) {
- "string" !== typeof a && (c = b, b = a, a = "a");
- var d = {
- f: "filter",
- m: "map",
- a: "forEach"
- }[a],
- e = 0,
- f = [],
- g = b.length;
- if (d && b[d]) return b[d](c);
- for (; e < g; e++) {
- var d = b[e],
- h = c.call(b, d, e, b);
- switch (a) {
- case "f":
- h && f.push(d);
- break;
- case "m":
- f.push(h)
- }
- }
- return f
- },
- in_array: function (a, b) {
- return a.indexOf ? -1 !== a.indexOf(b) : 0 < this.array_walk("f", a, function (a) {
- return a === b
- }).length
- },
- cookie: function (a, b, c) {
- a = "achat_" + a;
- if (1 === arguments.length) return a in sessionStorage ? sessionStorage.getItem(a) : localStorage.getItem(a);
- (c ? localStorage : sessionStorage).setItem(a, b)
- },
- t: function (a) {
- return window.avacweb_chat_translation ? avacweb_chat_translation[a.toLowerCase()] || a : a
- },
- get_template_item: function (a) {
- var b = document.getElementById(this.config.template.ids[a]);
- if (b) return b;
- console.log('AWCError 201: No id or element found for template item "' + a + '"');
- return document.createElement("div")
- },
- loading: function () {
- this.get_template_item("messages").innerHTML = ''
- },
- get_refresh_rate: function () {
- var a = ++this.inactive_refreshes,
- b = "normal";
- switch (!0) {
- case 40 < a:
- b = "in40";
- break;
- case 30 < a:
- b = "in30";
- break;
- case 20 < a:
- b = "in20";
- break;
- case 10 < a:
- b = "in10"
- }
- this.logged_in || (b = "in20");
- this.settings.on("disable timeout") && (b = "in10");
- return this.refresh_rates[b]
- },
- ignore: function (a, b) {
- var c = this.settings.value("ignored");
- a = this.get_user(a);
- if (!a.id) return this.popup(ac.t("User not found"));
- if (a.staff) return this.popup(ac.t("Staff can not be ignored"));
- b ? delete c["u" + a.id] : c["u" + a.id] = 1;
- this.settings.value("ignored", c);
- this.update_messages(this.last_data.messages)
- },
- popup: function (a, b) {
- if ("update" === a) {
- var c = window.AWC_update;
- this.cookie("update", c.id, 1);
- a = c.text
- }
- c = document.getElementById("achat_popup");
- c.className = b && a ? "error" : "";
- c.lastChild.innerHTML = a || "";
- this.showhide("achat_popup")
- },
- showhide: function (a) {
- var b = document.getElementById(a);
- this.current_popup && a !== this.current_popup && (document.getElementById(this.current_popup).style.display = "none");
- if ("" === b.innerHTML && "achat_smilies" === a) {
- var c = function () {
- b.innerHTML = b.innerHTML.replace(/href="javascript:insert_chatboxsmilie/g, 'onclick="return avacweb_chat.insert_text');
- f("form select", b).removeAttr("onchange").change(function (a) {
- d("/smilies.forum?categ=" + this.value + "&mode=smilies_frame")
- })
- },
- d = function (a) {
- b.innerHTML = '';
- f(b).load(a + " #simple-wrap", c)
- };
- d("/smilies.forum?mode=smilies_frame")
- }
- if ("" === b.innerHTML && "achat_colors" === a) {
- for (var e = "0369BDF".split(""), g = '
',
- h = e.length, l = 0; l < h; l++) {
- for (var g = g + "
", n = 0; n < h; n++)
- for (var u = 0; u < h; u++) var k = "#" + e[l] + e[l] + e[n] + e[n] + e[u] + e[u],
- g = g + ('
");
- g += "
"
- }
- b.innerHTML = g + "
"
- }
- "none" === b.style.display ? (b.style.display = "", this.current_popup = a) : (b.style.display = "none", this.current_popup = null)
- },
- insert_text: function (a) {
- var b = this.get_template_item("messagebox");
- b.value += a;
- b.focus();
- return !1
- },
- insert_pm: function (a) {
- var b = this.get_template_item("messagebox"),
- c = b.value;
- 0 === c.indexOf("/pm(") ? b.value = "/pm(" + a + "," + c.substr(4) : b.value = "/pm(" + a + ") " + c;
- b.focus();
- return !1
- },
- capitalize: function (a) {
- return a.charAt(0).toUpperCase() + a.substr(1)
- },
- filter: function (a) {
- for (var b in this.config.filters) a = a.replace(RegExp(b, "gi"), this.config.filters[b]);
- return a
- },
- resize: {
- dimensions: {},
- init: function (a, b) {
- var c = avacweb_chat.resize,
- d = document.getElementById("avacweb_chat");
- c.startX = a.pageX;
- c.startY = a.pageY;
- c.startW = d.offsetWidth;
- c.startH = d.offsetHeight;
- c.windowW = f(window).width();
- c.windowH = f(window).height();
- c.startB = c.windowH - (d.offsetTop + c.startH);
- f("body, html").mousemove(c[b]).mouseup(function () {
- f("body, html").off("mousemove").off("mouseup");
- avacweb_chat.cookie("dimensions", JSON.stringify(avacweb_chat.resize.dimensions))
- })
- },
- drag: function (a) {
- var b = document.getElementById("avacweb_chat"),
- c = avacweb_chat.resize;
- c.dimensions.width = b.style.width = c.startW + (c.startX - a.pageX) + "px";
- c.dimensions.height = b.style.height = c.startH + (c.startY - a.pageY) + "px"
- },
- move: function (a) {
- var b = document.getElementById("avacweb_chat"),
- c = avacweb_chat.resize;
- c.dimensions.right = b.style.right = c.windowW - a.pageX - c.startW + "px";
- c.dimensions.bottom = b.style.bottom = c.startB - (a.pageY - c.startY) + "px"
- }
- },
- settings: {
- initiated: !1,
- data: {},
- add: function (a, b, c) {
- if ("object" === typeof a) {
- for (var d in a) this.add(d, a[d], b);
- return this
- }
- this.data[a] ? (this.data[a].save = c ? !0 : !1, this.data[a].value = b) : (b = "boolean" === typeof b ? b ? 1 : 0 : b, this.data[a] = {
- value: b,
- special: "number" !== typeof b ? !0 : !1,
- save: c ? !0 : !1,
- UI_added: !1
- });
- return this
- },
- add_ui: function (a) {
- this.initiated || this.init();
- if (1 < arguments.length) return avacweb_chat.array_walk(arguments, function (a) {
- avacweb_chat.settings.add_ui(a)
- });
- if (this.data[a] && (!this.data[a] || !this.data[a].special && !this.data[a].UI_added)) {
- var b = avacweb_chat,
- b = '
' + b.t(b.capitalize(a)) + "",
- b = b + ('
");
- f(document.getElementById("achat_user_prefs")).append(b);
- this.data[a].UI_added = !0
- }
- },
- remove: function (a) {
- if (this.data[a]) {
- if (this.data[a].UI_added) {
- var b = document.getElementById("ac_" + a.replace(/\s/g, "_") + "_checkbox");
- b && b.parentNode.parentNode.removeChild(b.parentNode)
- }
- delete this.data[a];
- this.save()
- }
- },
- value: function (a, b) {
- 2 === arguments.length && this.data[a] && (this.data[a].value = b, this.data[a].UI_added && (document.getElementById("ac_" + a.replace(" ", "_") + "_checkbox").checked = !!b), avacweb_chat.event.fire("onsettingchange", a), this.save());
- return this.data[a] ? this.data[a].value : null
- },
- on: function (a) {
- return !(!this.data[a] || !this.data[a].value)
- },
- toggle: function (a) {
- return this.value(a, this.on(a) ? 0 : 1)
- },
- save: function () {
- var a = {},
- b, c;
- for (b in this.data) c = this.data[b], c.save && (a[b] = c.value);
- avacweb_chat.cookie("user_prefs", JSON.stringify(a), 1)
- },
- init: function () {
- if (!this.initiated) {
- var a = avacweb_chat,
- b = a.cookie("user_prefs");
- b && !a.mobile && this.add(JSON.parse(b), !0);
- this.initiated = !0
- }
- }
- }
- };
- l = function () {
- return !0
- };
- g.commands = {
- away: !1,
- abs: !1,
- exit: !1,
- banlist: {
- description: "/banlist - View a list of banned users. Chatbox moderators only.",
- staff: !0,
- run: function () {
- return !1
- }
- },
- cls: {
- description: "/cls - clear the chatbox. Chatbox moderators only.",
- run: l,
- staff: !0
- },
- clear: {
- description: "/clear - clear the chatbox. Chatbox moderators only.",
- run: l,
- staff: !0
- },
- ban: {
- description: "/ban username - Ban a user in the chatbox. Chatbox moderators only.",
- run: l,
- staff: !0
- },
- unban: {
- description: "/unban username - Unban a user in the chatbox. Chatbox moderators only.",
- run: l,
- staff: !0
- },
- mod: {
- description: "/mod username - Give a user moderator privileges in the chatbox. Admin only",
- run: l,
- staff: !0
- },
- unmod: {
- description: "/unmod username - Remove a users moderator privileges in the chatbox. Admin only",
- run: l,
- staff: !0
- },
- kick: {
- description: "/kick username - Disconnect a member from the Chatbox. Moderators only.",
- run: l,
- staff: !0
- },
- logs: {
- description: "/logs - Open up the log management page for your chat to manage your saved chat logs.",
- staff: !0,
- run: function () {
- window.open("", "awc-logs").document.write('