Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function decodeHtml(html) {
- var txt = document.createElement("textarea");
- txt.innerHTML = html;
- return txt.value;
- }
- function encodeHtml(str) {
- var div = document.createElement('div');
- div.appendChild(document.createTextNode(str));
- return div.innerHTML;
- }
- function usergroup_id_to_class_name(group_id) {
- if (parseInt(group_id) == 99) {
- return 'chatBot';
- }
- return 'usergroup-' + group_id;
- }
- (function(window, document, options, undefined) {
- var lang = {
- 'en': {
- 'logged_in': 'You are now logged in as [username]',
- 'conn_closed_label': 'Your connection is <strong>closed</strong>, please <strong>refresh</strong>',
- 'rate_limiting_error': 'Error:\nWe have received too many messages from your IP and we\'ve banned it for the next [seconds] seconds\nYour last message has NOT been sent.',
- 'rate_limiting_warning': 'Warning:\nWe have received too many messages from your IP and we will ban it for the next [seconds] seconds.\nPlease, write fewer messages to avoid bothering our other users.'
- },
- 'de': {
- /* TODO */
- }
- }[options.lang_code];
- var shout = document.getElementById(options.shout_id),
- chats = shout.children[0],
- form = shout.children[1];
- chats.removeChild(chats.children[0]);
- if (window.WebSocket === undefined) {
- return;
- }
- chats.removeChild(chats.children[0]);
- var Set = function() {};
- Set.prototype.add = function(o) { this[o] = true; };
- Set.prototype.remove = function(o) { delete this[o]; };
- var mouseover_timeout = 0,
- appendMessage = function(epoch, user_id, username, group_id, raw_content, autoscroll) {
- var must_scroll = autoscroll && chats.scrollTop == (chats.scrollHeight - chats.offsetHeight);
- var local_date = new Date(0);
- local_date.setUTCSeconds(epoch);
- var count = chats.childElementCount,
- p = document.createElement('p'),
- a = document.createElement('a'),
- name = document.createTextNode(username),
- d = document.createElement('span');
- // Format the username
- a.setAttribute('href', 'profile.php?id=' + parseInt(user_id));
- a.setAttribute('target', '_blank');
- a.className = usergroup_id_to_class_name(group_id);
- a.appendChild(name);
- // Format date
- d.textContent = '[' + local_date.toLocaleTimeString() + '] ';
- d.className = 'dateTime';
- // Format the message
- p.textContent = ': ' + decodeHtml(raw_content);
- // Create links
- p.innerHTML = anchorme(p.innerHTML, {
- attributes:[
- {
- name: "target",
- value: "_blank"
- }
- ]});
- p.insertBefore(a, p.firstChild);
- p.insertBefore(d, p.firstChild);
- if ((count % 2) == 0) {
- p.className = 'rowEven';
- } else {
- p.className = 'rowOdd';
- }
- chats.appendChild(p);
- if(must_scroll) {
- chats.scrollTop = chats.scrollHeight;
- }
- };
- var chat_input = document.getElementById('shouttext');
- var conn_closed_label = document.createElement('label');
- conn_closed_label.appendChild(document.createElement('span'));
- conn_closed_label.children[0].innerHTML = lang['conn_closed_label'];
- chat_input.onkeydown = checkEnter;
- chat_input.onchange = fixMessage;
- chat_input.style.visibility = 'visible';
- chat_input.disabled = false;
- // Show emoji selector
- var emoji_selector = document.getElementById("emojiselector");
- var emoji_count = emoji.length;
- function addEmoji(code) {
- var option = document.createElement('option');
- option.innerHTML = code;
- emoji_selector.appendChild(option);
- }
- for (var index = 0; index < emoji_count; index++) {
- addEmoji(emoji[index]);
- }
- var addEmojiToInput = function () {
- chat_input.value += emoji_selector.value;
- chat_input.focus();
- };
- emoji_selector.onchange = addEmojiToInput;
- return false;
- }
- )(
- this,
- this.document,
- {
- lang_code: 'en',
- shout_id: 'shout',
- websocket_url: 'wss://gamesense.pub/forums/shoutbox/'
- }
- );
- var seconds = Math.round((new Date()).getTime() / 1000);
- appendMessage(seconds, 2, 'admin', 1, encodeHtml('apolo gay'), true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement