1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2025-01-09 00:20:08 +00:00

Merge branch 'master' into commands

Conflicts:
	file/js/TimWolla.WCF.Chat.coffee
	file/lib/system/chat/commands/ChatCommandHandler.class.php
This commit is contained in:
Tim Düsterhus 2012-01-30 17:46:54 +01:00
commit b15391f421
22 changed files with 169 additions and 71 deletions

View File

@ -2,19 +2,35 @@
# TimWolla.WCF.Chat # TimWolla.WCF.Chat
# #
# @author Tim Düsterhus # @author Tim Düsterhus
# @copyright 2010-2011 Tim Düsterhus # @copyright 2010-2012 Tim Düsterhus
# @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode> # @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
# @package timwolla.wcf.chat # @package timwolla.wcf.chat
### ###
TimWolla ?= {} TimWolla ?= {}
TimWolla.WCF ?= {} TimWolla.WCF ?= {}
consoleMock ?=
log: () ->,
warn: () ->
(($, window) -> (($, window, console) ->
TimWolla.WCF.Chat = TimWolla.WCF.Chat =
# Templates
titleTemplate: null titleTemplate: null
messageTemplate: null messageTemplate: null
# Notifications
newMessageCount: null newMessageCount: null
isActive: true
# Autocompleter
autocompleteOffset: 0
autocompleteValue: null
# Autoscroll
oldScrollTop: null
# Events
events: events:
newMessage: $.Callbacks() newMessage: $.Callbacks()
userMenu: $.Callbacks() userMenu: $.Callbacks()
@ -24,16 +40,30 @@ TimWolla.WCF ?= {}
@events.newMessage.add $.proxy @notify, @ @events.newMessage.add $.proxy @notify, @
new WCF.PeriodicalExecuter $.proxy(@refreshRoomList, @), 60e3 new WCF.PeriodicalExecuter $.proxy(@refreshRoomList, @), 60e3
new WCF.PeriodicalExecuter $.proxy(@getMessages, @), @config.reloadTime * 1000 new WCF.PeriodicalExecuter $.proxy(@getMessages, @), @config.reloadTime * 1e3
@refreshRoomList() @refreshRoomList()
@getMessages() @getMessages()
console.log '[TimWolla.WCF.Chat] Finished initializing' console.log '[TimWolla.WCF.Chat] Finished initializing'
### ###
# Autocompletes a username
###
autocomplete: (firstChars, offset = @autocompleteOffset) ->
users = []
# Search all matching users
for user in $ '.chatUser'
username = $(user).data('username');
if username.indexOf(firstChars) is 0
users.push username
# None found -> return firstChars
# otherwise return the user at the current offset
return if users.length is 0 then firstChars else users[offset % users.length]
###
# Binds all the events needed for Tims Chat. # Binds all the events needed for Tims Chat.
### ###
bindEvents: () -> bindEvents: () ->
@isActive = true
$(window).focus $.proxy () -> $(window).focus $.proxy () ->
document.title = @titleTemplate.fetch document.title = @titleTemplate.fetch
title: $('#chatRoomList .activeMenuItem a').text() title: $('#chatRoomList .activeMenuItem a').text()
@ -45,25 +75,56 @@ TimWolla.WCF ?= {}
@isActive = false @isActive = false
, @ , @
# Insert a smiley
$('.smiley').click $.proxy (event) -> $('.smiley').click $.proxy (event) ->
@insertText ' ' + $(event.target).attr('alt') + ' ' @insertText ' ' + $(event.target).attr('alt') + ' '
, @ , @
# Switch sidebar tab
$('.chatSidebarTabs li').click $.proxy (event) -> $('.chatSidebarTabs li').click $.proxy (event) ->
event.preventDefault() event.preventDefault()
@toggleSidebarContents $ event.target @toggleSidebarContents $ event.target
, @ , @
# Submit Handler
$('#chatForm').submit $.proxy (event) -> $('#chatForm').submit $.proxy (event) ->
event.preventDefault() event.preventDefault()
@submit $ event.target @submit $ event.target
, @ , @
# Autocompleter
$('#chatInput').keydown $.proxy (event) ->
# tab key
if event.keyCode is 9
event.preventDefault()
if @autocompleteValue is null
@autocompleteValue = $('#chatInput').val()
firstChars = @autocompleteValue.substring(@autocompleteValue.lastIndexOf(' ')+1)
console.log '[TimWolla.WCF.Chat] Autocompleting "' + firstChars + '"'
return if firstChars.length is 0
# Insert name and increment offset
$('#chatInput').val(@autocompleteValue.substring(0, @autocompleteValue.lastIndexOf(' ') + 1) + @autocomplete(firstChars) + ', ')
@autocompleteOffset++
else
@autocompleteOffset = 0
@autocompleteValue = null
, @
# Refreshes the roomlist
$('#chatRoomList button').click $.proxy(@refreshRoomList, @)
# Clears the stream
$('#chatClear').click (event) -> $('#chatClear').click (event) ->
event.preventDefault() event.preventDefault()
$('.chatMessage').remove() $('.chatMessage').remove()
@oldScrollTop = $('.chatMessageContainer').scrollTop()
$('.chatMessageContainer').scrollTop $('.chatMessageContainer ul').height()
$('#chatInput').focus() $('#chatInput').focus()
# Toggle Buttons
$('.chatToggle').click (event) -> $('.chatToggle').click (event) ->
element = $ @ element = $ @
icon = element.find 'img' icon = element.find 'img'
@ -75,9 +136,18 @@ TimWolla.WCF ?= {}
element.data 'status', 1 element.data 'status', 1
icon.attr 'src', icon.attr('src').replace /disabled(\d?).([a-z]{3})$/, 'enabled$1.$2' icon.attr 'src', icon.attr('src').replace /disabled(\d?).([a-z]{3})$/, 'enabled$1.$2'
element.attr 'title', element.data 'disableMessage' element.attr 'title', element.data 'disableMessage'
if typeof window.webkitNotifications isnt 'undefined'
# Immediatly scroll down when activating autoscroll
$('#chatAutoscroll').click (event) ->
$(this).removeClass('hot')
if $(this).data 'status'
$('.chatMessageContainer').scrollTop $('.chatMessageContainer ul').height()
@oldScrollTop = $('.chatMessageContainer').scrollTop()
# Desktop Notifications
unless typeof window.webkitNotifications is 'undefined'
$('#chatNotify').click (event) -> $('#chatNotify').click (event) ->
window.webkitNotifications.requestPermission() window.webkitNotifications.requestPermission() if $(this).data 'status'
### ###
# Changes the chat-room. # Changes the chat-room.
@ -96,11 +166,11 @@ TimWolla.WCF ?= {}
@loading = false @loading = false
target.parent().removeClass 'ajaxLoad' target.parent().removeClass 'ajaxLoad'
# mark as active # Mark as active
$('.activeMenuItem .chatRoom').parent().removeClass 'activeMenuItem' $('.activeMenuItem .chatRoom').parent().removeClass 'activeMenuItem'
target.parent().addClass 'activeMenuItem' target.parent().addClass 'activeMenuItem'
# set new topic # Set new topic
if data.topic is '' if data.topic is ''
return if $('#topic').text().trim() is '' return if $('#topic').text().trim() is ''
@ -110,11 +180,11 @@ TimWolla.WCF ?= {}
$('#topic').text data.topic $('#topic').text data.topic
$('#topic').wcfBlindIn() if $('#topic').text().trim() isnt '' and $('#topic').is(':hidden') $('#topic').wcfBlindIn() if $('#topic').text().trim() isnt '' and $('#topic').is(':hidden')
$('title').text @titleTemplate.fetch data @handleMessages data.messages
@getMessages() document.title = @titleTemplate.fetch data
, @) , @)
error: () -> error: () ->
# reload page to change the room the old fashion-way # Reload the page to change the room the old fashion-way
# inclusive the error-message :) # inclusive the error-message :)
window.location.reload true window.location.reload true
beforeSend: $.proxy(() -> beforeSend: $.proxy(() ->
@ -129,7 +199,7 @@ TimWolla.WCF ?= {}
freeTheFish: () -> freeTheFish: () ->
return if $.wcfIsset('fish') return if $.wcfIsset('fish')
console.warn '[TimWolla.WCF.Chat] Freeing the fish' console.warn '[TimWolla.WCF.Chat] Freeing the fish'
fish = $ '<div id="fish">' + WCF.String.escapeHTML('><((((°>') + '</div>' fish = $ '<div id="fish">' + WCF.String.escapeHTML('><((((\u00B0>') + '</div>'
fish.css fish.css
position: 'absolute' position: 'absolute'
top: '150px' top: '150px'
@ -140,20 +210,20 @@ TimWolla.WCF ?= {}
fish.appendTo $ 'body' fish.appendTo $ 'body'
new WCF.PeriodicalExecuter(() -> new WCF.PeriodicalExecuter(() ->
left = (Math.random() * 100 - 50) left = Math.random() * 100 - 50
top = (Math.random() * 100 - 50) top = Math.random() * 100 - 50
fish = $('#fish') fish = $('#fish')
left *= -1 if((fish.position().left + left) < (0 + fish.width()) or (fish.position().left + left) > ($(document).width() - fish.width())) left *= -1 unless fish.width() < (fish.position().left + left) < ($(document).width() - fish.width())
top *= -1 if((fish.position().top + top) < (0 + fish.height()) or (fish.position().top + top) > ($(document).height() - fish.height())) top *= -1 unless fish.height() < (fish.position().top + top) < ($(document).height() - fish.height())
fish.text('><((((°>') if (left > 0) fish.text('><((((\u00B0>') if left > 0
fish.text('<°))))><') if (left < 0) fish.text('<\u00B0))))><') if left < 0
fish.animate fish.animate
top: '+=' + top top: '+=' + top
left: '+=' + left left: '+=' + left
, 1000 , 1e3
, 1.5e3); , 1.5e3);
### ###
# Loads new messages. # Loads new messages.
@ -172,6 +242,14 @@ TimWolla.WCF ?= {}
# @param array<object> messages # @param array<object> messages
### ###
handleMessages: (messages) -> handleMessages: (messages) ->
# Disable scrolling automagically when user manually scrolled
unless @oldScrollTop is null
if $('.chatMessageContainer').scrollTop() < @oldScrollTop
if $('#chatAutoscroll').data('status') is 1
$('#chatAutoscroll').click()
$('#chatAutoscroll').addClass('hot').fadeOut('slow').fadeIn('slow')
# Insert the messages
for message in messages for message in messages
@events.newMessage.fire message @events.newMessage.fire message
@ -182,23 +260,34 @@ TimWolla.WCF ?= {}
li.append output li.append output
li.appendTo $ '.chatMessageContainer ul' li.appendTo $ '.chatMessageContainer ul'
$('.chatMessageContainer').animate
scrollTop: $('.chatMessageContainer ul').height() # Autoscroll down
, 1000 if $('#chatAutoscroll').data('status') is 1
$('.chatMessageContainer').scrollTop $('.chatMessageContainer ul').height()
@oldScrollTop = $('.chatMessageContainer').scrollTop()
###
# Builds the userlist.
#
# @param array<object> users
###
handleUsers: (users) -> handleUsers: (users) ->
foundUsers = {} foundUsers = { }
for user in users for user in users
id = 'chatUser-'+user.userID id = 'chatUser-'+user.userID
element = $('#'+id) element = $('#'+id)
# Move the user to the correct position
if element[0] if element[0]
console.log '[TimWolla.WCF.Chat] Shifting user ' + user.userID console.log '[TimWolla.WCF.Chat] Moving User: "' + user.username + '"'
element = element.detach() element = element.detach()
$('#chatUserList').append element $('#chatUserList').append element
# Insert the user
else else
console.log '[TimWolla.WCF.Chat] Inserting user ' + user.userID console.log '[TimWolla.WCF.Chat] Inserting User: "' + user.username + '"'
li = $ '<li></li>' li = $ '<li></li>'
li.attr 'id', id li.attr 'id', id
li.addClass 'chatUser' li.addClass 'chatUser'
li.data 'username', user.username
a = $ '<a href="javascript:;">'+user.username+'</a>' a = $ '<a href="javascript:;">'+user.username+'</a>'
a.click $.proxy (event) -> a.click $.proxy (event) ->
event.preventDefault() event.preventDefault()
@ -217,9 +306,12 @@ TimWolla.WCF ?= {}
foundUsers[id] = true foundUsers[id] = true
# Remove users that were not found
$('.chatUser').each () -> $('.chatUser').each () ->
if typeof foundUsers[$(@).attr('id')] is 'undefined' if typeof foundUsers[$(@).attr('id')] is 'undefined'
$(@).remove() console.log '[TimWolla.WCF.Chat] Removing User: "' + $(@).data('username') + '"'
$(@).remove();
$('#toggleUsers .badge').text(users.length); $('#toggleUsers .badge').text(users.length);
### ###
@ -248,12 +340,13 @@ TimWolla.WCF ?= {}
# @param object message # @param object message
### ###
notify: (message) -> notify: (message) ->
return if (@isActive or $('#chatNotify').data('status') is 0) return if @isActive or $('#chatNotify').data('status') is 0
@newMessageCount++ @newMessageCount++
document.title = '(' + @newMessageCount + ') ' + @titleTemplate.fetch document.title = '(' + @newMessageCount + ') ' + @titleTemplate.fetch
title: $('#chatRoomList .activeMenuItem a').text() title: $('#chatRoomList .activeMenuItem a').text()
# Desktop Notifications
if typeof window.webkitNotifications isnt 'undefined' if typeof window.webkitNotifications isnt 'undefined'
if window.webkitNotifications.checkPermission() is 0 if window.webkitNotifications.checkPermission() is 0
title = WCF.Language.get('wcf.chat.newMessages') title = WCF.Language.get('wcf.chat.newMessages')
@ -263,12 +356,12 @@ TimWolla.WCF ?= {}
notification.show() notification.show()
setTimeout(() -> setTimeout(() ->
notification.cancel() notification.cancel()
, 5000) , 5e3)
### ###
# Refreshes the room-list. # Refreshes the room-list.
### ###
refreshRoomList: () -> refreshRoomList: () ->
console.log '[TimWolla.WCF.Chat] Refreshing the room-list' console.log '[TimWolla.WCF.Chat] Refreshing the roomlist'
$('#toggleRooms a').addClass 'ajaxLoad' $('#toggleRooms a').addClass 'ajaxLoad'
$.ajax $('#toggleRooms a').data('refreshUrl'), $.ajax $('#toggleRooms a').data('refreshUrl'),
@ -299,9 +392,10 @@ TimWolla.WCF ?= {}
# @param jQuery-object target # @param jQuery-object target
### ###
submit: (target) -> submit: (target) ->
# break if input contains only whitespace # Break if input contains only whitespace
return false if $('#chatInput').val().trim().length is 0 return false if $('#chatInput').val().trim().length is 0
# Finally free the fish
@freeTheFish() if $('#chatInput').val().trim().toLowerCase() is '/free the fish' @freeTheFish() if $('#chatInput').val().trim().toLowerCase() is '/free the fish'
$.ajax $('#chatForm').attr('action'), $.ajax $('#chatForm').attr('action'),
@ -352,4 +446,4 @@ TimWolla.WCF ?= {}
else else
li.addClass 'activeMenuItem' li.addClass 'activeMenuItem'
li.find('.chatUserMenu').wcfBlindIn 'vertical' li.find('.chatUserMenu').wcfBlindIn 'vertical'
)(jQuery, @) )(jQuery, @, consoleMock)

View File

@ -6,7 +6,7 @@
* Represents a chat message. * Represents a chat message.
* *
* @author Tim Düsterhus * @author Tim Düsterhus
* @copyright 2010-2011 Tim Düsterhus * @copyright 2010-2012 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode> * @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package timwolla.wcf.chat * @package timwolla.wcf.chat
* @subpackage data.chat.message * @subpackage data.chat.message

View File

@ -5,7 +5,7 @@
* Executes message related actions. * Executes message related actions.
* *
* @author Tim Düsterhus * @author Tim Düsterhus
* @copyright 2010-2011 Tim Düsterhus * @copyright 2010-2012 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode> * @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package timwolla.wcf.chat * @package timwolla.wcf.chat
* @subpackage data.chat.message * @subpackage data.chat.message

View File

@ -5,7 +5,7 @@
* Provides functions to edit chat messages. * Provides functions to edit chat messages.
* *
* @author Tim Düsterhus * @author Tim Düsterhus
* @copyright 2010-2011 Tim Düsterhus * @copyright 2010-2012 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode> * @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package timwolla.wcf.chat * @package timwolla.wcf.chat
* @subpackage data.chat.message * @subpackage data.chat.message

View File

@ -5,7 +5,7 @@
* Represents a list of chat messages. * Represents a list of chat messages.
* *
* @author Tim Düsterhus * @author Tim Düsterhus
* @copyright 2010-2011 Tim Düsterhus * @copyright 2010-2012 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode> * @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package timwolla.wcf.chat * @package timwolla.wcf.chat
* @subpackage data.chat.room * @subpackage data.chat.room

View File

@ -6,7 +6,7 @@
* Represents a chat room. * Represents a chat room.
* *
* @author Tim Düsterhus * @author Tim Düsterhus
* @copyright 2010-2011 Tim Düsterhus * @copyright 2010-2012 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode> * @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package timwolla.wcf.chat * @package timwolla.wcf.chat
* @subpackage data.chat.room * @subpackage data.chat.room

View File

@ -5,7 +5,7 @@
* Provides functions to edit chat rooms. * Provides functions to edit chat rooms.
* *
* @author Tim Düsterhus * @author Tim Düsterhus
* @copyright 2010-2011 Tim Düsterhus * @copyright 2010-2012 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode> * @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package timwolla.wcf.chat * @package timwolla.wcf.chat
* @subpackage data.chat.room * @subpackage data.chat.room

View File

@ -5,7 +5,7 @@
* Represents a list of chat rooms. * Represents a list of chat rooms.
* *
* @author Tim Düsterhus * @author Tim Düsterhus
* @copyright 2010-2011 Tim Düsterhus * @copyright 2010-2012 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode> * @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package timwolla.wcf.chat * @package timwolla.wcf.chat
* @subpackage data.chat.room * @subpackage data.chat.room

View File

@ -10,7 +10,7 @@
* Inserts a message * Inserts a message
* *
* @author Tim Düsterhus * @author Tim Düsterhus
* @copyright 2010-2011 Tim Düsterhus * @copyright 2010-2012 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode> * @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package timwolla.wcf.chat * @package timwolla.wcf.chat
* @subpackage form * @subpackage form

View File

@ -6,7 +6,7 @@
* Shows information about Tims chat. * Shows information about Tims chat.
* *
* @author Tim Düsterhus * @author Tim Düsterhus
* @copyright 2010-2011 Tim Düsterhus * @copyright 2010-2012 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode> * @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package timwolla.wcf.chat * @package timwolla.wcf.chat
* @subpackage page * @subpackage page

View File

@ -7,7 +7,7 @@
* Loads new messages. * Loads new messages.
* *
* @author Tim Düsterhus * @author Tim Düsterhus
* @copyright 2010-2011 Tim Düsterhus * @copyright 2010-2012 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode> * @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package timwolla.wcf.chat * @package timwolla.wcf.chat
* @subpackage page * @subpackage page

View File

@ -8,7 +8,7 @@
* Shows the chat-interface * Shows the chat-interface
* *
* @author Tim Düsterhus * @author Tim Düsterhus
* @copyright 2010-2011 Tim Düsterhus * @copyright 2010-2012 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode> * @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package timwolla.wcf.chat * @package timwolla.wcf.chat
* @subpackage page * @subpackage page
@ -66,8 +66,6 @@ public function readData() {
$this->readRoom(); $this->readRoom();
$this->userData['color'] = \wcf\util\ChatUtil::readUserData('color'); $this->userData['color'] = \wcf\util\ChatUtil::readUserData('color');
\wcf\util\ChatUtil::writeUserData(array('roomID' => $this->room->roomID)); \wcf\util\ChatUtil::writeUserData(array('roomID' => $this->room->roomID));
$this->newestMessages = chat\message\ChatMessageList::getNewestMessages($this->room, CHAT_LASTMESSAGES);
\wcf\util\ChatUtil::writeUserData(array('lastSeen' => count($this->newestMessages) ? end($this->newestMessages)->messageID : 0));
if (CHAT_DISPLAY_JOIN_LEAVE) { if (CHAT_DISPLAY_JOIN_LEAVE) {
$messageAction = new chat\message\ChatMessageAction(array(), 'create', array( $messageAction = new chat\message\ChatMessageAction(array(), 'create', array(
@ -86,6 +84,9 @@ public function readData() {
$return = $messageAction->getReturnValues(); $return = $messageAction->getReturnValues();
} }
$this->newestMessages = chat\message\ChatMessageList::getNewestMessages($this->room, CHAT_LASTMESSAGES);
\wcf\util\ChatUtil::writeUserData(array('lastSeen' => end($this->newestMessages)->messageID));
$this->readDefaultSmileys(); $this->readDefaultSmileys();
$this->readChatVersion(); $this->readChatVersion();
} }
@ -173,9 +174,12 @@ public function show() {
if ($this->useTemplate) exit; if ($this->useTemplate) exit;
@header('Content-type: application/json'); @header('Content-type: application/json');
$messages = array();
foreach ($this->newestMessages as $message) $messages[] = $message->jsonify(true);
echo \wcf\util\JSON::encode(array( echo \wcf\util\JSON::encode(array(
'title' => $this->room->getTitle(), 'title' => $this->room->getTitle(),
'topic' => WCF::getLanguage()->get($this->room->topic) 'topic' => WCF::getLanguage()->get($this->room->topic),
'messages' => $messages
)); ));
exit; exit;
} }

View File

@ -8,7 +8,7 @@
* Shows the chat-interface * Shows the chat-interface
* *
* @author Tim Düsterhus * @author Tim Düsterhus
* @copyright 2010-2011 Tim Düsterhus * @copyright 2010-2012 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode> * @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package timwolla.wcf.chat * @package timwolla.wcf.chat
* @subpackage page * @subpackage page

View File

@ -5,7 +5,7 @@
* Caches all chat rooms. * Caches all chat rooms.
* *
* @author Tim Düsterhus * @author Tim Düsterhus
* @copyright 2010-2011 Tim Düsterhus * @copyright 2010-2012 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode> * @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package timwolla.wcf.chat * @package timwolla.wcf.chat
* @subpackage system.cache.builder * @subpackage system.cache.builder

View File

@ -7,8 +7,8 @@
/** /**
* Handles chat-permissions. * Handles chat-permissions.
* *
* @author Tim Düsterhus, Marcel Werk * @author Tim Düsterhus, Marcel Werk
* @copyright 2010-2011 WoltLab GmbH * @copyright 2010-2012 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package timwolla.wcf.chat * @package timwolla.wcf.chat
* @subpackage system.chat.permissions * @subpackage system.chat.permissions

View File

@ -5,7 +5,7 @@
* Adds a new route to RouteHandler * Adds a new route to RouteHandler
* *
* @author Maximilian Mader * @author Maximilian Mader
* @copyright 2010-2011 Tim Düsterhus * @copyright 2010-2012 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode> * @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package timwolla.wcf.chat * @package timwolla.wcf.chat
* @subpackage system.event.listener * @subpackage system.event.listener

View File

@ -6,7 +6,7 @@
* PageMenuItemProvider for chat. * PageMenuItemProvider for chat.
* *
* @author Tim Düsterhus * @author Tim Düsterhus
* @copyright 2010-2011 Tim Düsterhus * @copyright 2010-2012 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode> * @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package timwolla.wcf.chat * @package timwolla.wcf.chat
* @subpackage system.menu.page * @subpackage system.menu.page

View File

@ -5,7 +5,7 @@
* TimeIntervalOptionType is an implementation of IOptionType for time intervals. * TimeIntervalOptionType is an implementation of IOptionType for time intervals.
* *
* @author Tim Düsterhus * @author Tim Düsterhus
* @copyright 2010-2011 Tim Düsterhus * @copyright 2010-2012 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode> * @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package timwolla.wcf.chat * @package timwolla.wcf.chat
* @subpackage system.option * @subpackage system.option

View File

@ -8,7 +8,7 @@
* Chat utilities * Chat utilities
* *
* @author Tim Düsterhus * @author Tim Düsterhus
* @copyright 2010-2011 Tim Düsterhus * @copyright 2010-2012 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode> * @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package timwolla.wcf.chat * @package timwolla.wcf.chat
* @subpackage util * @subpackage util

View File

@ -2,7 +2,7 @@
* Chat-Styles * Chat-Styles
* *
* @author Tim Düsterhus, Maximilian Mader * @author Tim Düsterhus, Maximilian Mader
* @copyright 2010-2011 Tim Düsterhus * @copyright 2010-2012 Tim Düsterhus
* @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode> * @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
* @package timwolla.wcf.chat * @package timwolla.wcf.chat
*/ */

View File

@ -5,7 +5,7 @@
<packagedescription><![CDATA[Chat for WoltLab Community Framework™]]></packagedescription> <packagedescription><![CDATA[Chat for WoltLab Community Framework™]]></packagedescription>
<standalone>0</standalone> <standalone>0</standalone>
<isunique>1</isunique> <isunique>1</isunique>
<version>3.0.0 Alpha 2</version> <version>3.0.0 Alpha 3</version>
<date>2011-11-26</date> <date>2011-11-26</date>
<plugin>com.woltlab.wcf.bbcode</plugin> <!-- TODO: Correct me --> <plugin>com.woltlab.wcf.bbcode</plugin> <!-- TODO: Correct me -->
</packageinformation> </packageinformation>
@ -45,4 +45,4 @@
<instruction type="templateListener">templatelistener.xml</instruction> <instruction type="templateListener">templatelistener.xml</instruction>
<instruction type="aclOption">acloptions.xml</instruction> <instruction type="aclOption">acloptions.xml</instruction>
</instructions> </instructions>
</package> </package>

View File

@ -119,6 +119,7 @@
{/if} {/if}
{/foreach} {/foreach}
</ul> </ul>
<div style="text-align: center;"><button type="button">Force Refresh</button></div>
</div> </div>
</nav> </nav>
</div> </div>
@ -153,27 +154,27 @@
<ul> <ul>
<li> <li>
<a id="chatAutoscroll" href="javascript:;" class="chatToggle balloonTooltip" title="{lang}wcf.global.button.disable{/lang}" data-disable-message="{lang}wcf.global.button.disable{/lang}" data-enable-message="{lang}wcf.global.button.enable{/lang}" data-status="1"> <a id="chatAutoscroll" href="javascript:;" class="chatToggle balloonTooltip" title="{lang}wcf.global.button.disable{/lang}" data-disable-message="{lang}wcf.global.button.disable{/lang}" data-enable-message="{lang}wcf.global.button.enable{/lang}" data-status="1">
<img alt="" src="{icon}enabled1{/icon}" /> <span>{lang}wcf.chat.scroll{/lang}</span> <img alt="" src="{icon size='S'}enabled1{/icon}" /> <span>{lang}wcf.chat.scroll{/lang}</span>
</a> </a>
</li> </li>
<li> <li>
<a id="chatNotify" href="javascript:;" class="chatToggle balloonTooltip" title="{lang}wcf.global.button.enable{/lang}" data-disable-message="{lang}wcf.global.button.disable{/lang}" data-enable-message="{lang}wcf.global.button.enable{/lang}" data-status="0"> <a id="chatNotify" href="javascript:;" class="chatToggle balloonTooltip" title="{lang}wcf.global.button.enable{/lang}" data-disable-message="{lang}wcf.global.button.disable{/lang}" data-enable-message="{lang}wcf.global.button.enable{/lang}" data-status="0">
<img alt="" src="{icon}disabled1{/icon}" /> <span>{lang}wcf.chat.notify{/lang}</span> <img alt="" src="{icon size='S'}disabled1{/icon}" /> <span>{lang}wcf.chat.notify{/lang}</span>
</a> </a>
</li> </li>
<li> <li>
<a id="chatSmilies" href="javascript:;" class="chatToggle balloonTooltip" title="{lang}wcf.global.button.disable{/lang}" data-disable-message="{lang}wcf.global.button.disable{/lang}" data-enable-message="{lang}wcf.global.button.enable{/lang}" data-status="1"> <a id="chatSmilies" href="javascript:;" class="chatToggle balloonTooltip" title="{lang}wcf.global.button.disable{/lang}" data-disable-message="{lang}wcf.global.button.disable{/lang}" data-enable-message="{lang}wcf.global.button.enable{/lang}" data-status="1">
<img alt="" src="{icon}enabled1{/icon}" /> <span>{lang}wcf.chat.smilies{/lang}</span> <img alt="" src="{icon size='S'}enabled1{/icon}" /> <span>{lang}wcf.chat.smilies{/lang}</span>
</a> </a>
</li> </li>
<li> <li>
<a id="chatClear" href="javascript:;" class="balloonTooltip" title="Clear the chat"> <a id="chatClear" href="javascript:;" class="balloonTooltip" title="{lang}wcf.chat.clear.description{/lang}">
<img alt="" src="{icon}delete1{/icon}" /> <span>{lang}wcf.chat.clear{/lang}</span> <img alt="" src="{icon size='S'}delete1{/icon}" /> <span>{lang}wcf.chat.clear{/lang}</span>
</a> </a>
</li> </li>
<li> <li>
<a id="chatMark" href="javascript:;" class="balloonTooltip" title="Show checkboxes"> <a id="chatMark" href="javascript:;" class="balloonTooltip" title="{lang}wcf.chat.mark.description{/lang}">
<img alt="" src="{icon}check1{/icon}" /> <span>{lang}wcf.chat.mark{/lang}</span> <img alt="" src="{icon size='S'}check1{/icon}" /> <span>{lang}wcf.chat.mark{/lang}</span>
</a> </a>
</li> </li>
</ul> </ul>
@ -182,21 +183,20 @@
{include file='chatCopyright'} {include file='chatCopyright'}
</div> </div>
</div> </div>
{include file='chatJavascriptInclude'} {include file='chatJavascriptInclude'}
<script type="text/javascript"> <script type="text/javascript">
//<![CDATA[ //<![CDATA[
(function ($, window) { (function ($, window) {
// populate templates // populate templates
TimWolla.WCF.Chat.titleTemplate = new WCF.Template('{ldelim}$title} - {'wcf.chat.title'|language|encodeJS} - {PAGE_TITLE|language|encodeJS}'); TimWolla.WCF.Chat.titleTemplate = (new WCF.Template('{ldelim}$title} - {'wcf.chat.title'|language|encodeJS} - {PAGE_TITLE|language|encodeJS}')).compile();
{capture assign='chatMessageTemplate'}{include file='chatMessage'}{/capture} {capture assign='chatMessageTemplate'}{include file='chatMessage'}{/capture}
TimWolla.WCF.Chat.messageTemplate = new WCF.Template('{@$chatMessageTemplate|encodeJS}'); TimWolla.WCF.Chat.messageTemplate = (new WCF.Template('{@$chatMessageTemplate|encodeJS}')).compile();
// populate config // populate config
TimWolla.WCF.Chat.config = { TimWolla.WCF.Chat.config = {
reloadTime: {CHAT_RELOADTIME}, reloadTime: {@CHAT_RELOADTIME},
animations: {CHAT_ANIMATIONS}, animations: {@CHAT_ANIMATIONS},
maxTextLength: {CHAT_LENGTH} maxTextLength: {@CHAT_LENGTH}
} }
WCF.Language.addObject({ WCF.Language.addObject({
'wcf.chat.query': '{lang}wcf.chat.query{/lang}', 'wcf.chat.query': '{lang}wcf.chat.query{/lang}',
@ -237,4 +237,4 @@
{include file='footer' sandbox=false} {include file='footer' sandbox=false}
</body> </body>
</html> </html>