App-Alice
view release on metacpan or search on metacpan
share/static/alice.js view on Meta::CPAN
clone: clone,
isElement: isElement,
isArray: isArray,
isHash: isHash,
isFunction: isFunction,
isString: isString,
isNumber: isNumber,
isUndefined: isUndefined
});
})();
Object.extend(Function.prototype, (function() {
var slice = Array.prototype.slice;
function update(array, args) {
var arrayLength = array.length, length = args.length;
while (length--) array[arrayLength + length] = args[length];
return array;
}
function merge(array, args) {
array = slice.call(array, 0);
return update(array, args);
}
function argumentNames() {
var names = this.toString().match(/^[\s\(]*function[^(]*\(([^)]*)\)/)[1]
.replace(/\/\/.*?[\r\n]|\/\*(?:.|[\r\n])*?\*\//g, '')
.replace(/\s+/g, '').split(',');
return names.length == 1 && !names[0] ? [] : names;
}
function bind(context) {
if (arguments.length < 2 && Object.isUndefined(arguments[0])) return this;
var __method = this, args = slice.call(arguments, 1);
return function() {
var a = merge(args, arguments);
return __method.apply(context, a);
}
}
function bindAsEventListener(context) {
var __method = this, args = slice.call(arguments, 1);
return function(event) {
var a = update([event || window.event], args);
return __method.apply(context, a);
}
}
function curry() {
if (!arguments.length) return this;
var __method = this, args = slice.call(arguments, 0);
return function() {
var a = merge(args, arguments);
return __method.apply(this, a);
}
}
function delay(timeout) {
var __method = this, args = slice.call(arguments, 1);
timeout = timeout * 1000;
return window.setTimeout(function() {
return __method.apply(__method, args);
}, timeout);
}
function defer() {
var args = update([0.01], arguments);
return this.delay.apply(this, args);
}
function wrap(wrapper) {
var __method = this;
return function() {
var a = update([__method.bind(this)], arguments);
return wrapper.apply(this, a);
}
}
function methodize() {
if (this._methodized) return this._methodized;
var __method = this;
return this._methodized = function() {
var a = update([this], arguments);
return __method.apply(null, a);
};
}
return {
argumentNames: argumentNames,
bind: bind,
bindAsEventListener: bindAsEventListener,
curry: curry,
delay: delay,
defer: defer,
wrap: wrap,
methodize: methodize
}
})());
(function(proto) {
function toISOString() {
return this.getUTCFullYear() + '-' +
(this.getUTCMonth() + 1).toPaddedString(2) + '-' +
this.getUTCDate().toPaddedString(2) + 'T' +
this.getUTCHours().toPaddedString(2) + ':' +
this.getUTCMinutes().toPaddedString(2) + ':' +
this.getUTCSeconds().toPaddedString(2) + 'Z';
}
function toJSON() {
return this.toISOString();
}
if (!proto.toISOString) proto.toISOString = toISOString;
if (!proto.toJSON) proto.toJSON = toJSON;
share/static/alice.js view on Meta::CPAN
});
Ajax.Updater = Class.create(Ajax.Request, {
initialize: function($super, container, url, options) {
this.container = {
success: (container.success || container),
failure: (container.failure || (container.success ? null : container))
};
options = Object.clone(options);
var onComplete = options.onComplete;
options.onComplete = (function(response, json) {
this.updateContent(response.responseText);
if (Object.isFunction(onComplete)) onComplete(response, json);
}).bind(this);
$super(url, options);
},
updateContent: function(responseText) {
var receiver = this.container[this.success() ? 'success' : 'failure'],
options = this.options;
if (!options.evalScripts) responseText = responseText.stripScripts();
if (receiver = $(receiver)) {
if (options.insertion) {
if (Object.isString(options.insertion)) {
var insertion = { }; insertion[options.insertion] = responseText;
receiver.insert(insertion);
}
else options.insertion(receiver, responseText);
}
else receiver.update(responseText);
}
}
});
Ajax.PeriodicalUpdater = Class.create(Ajax.Base, {
initialize: function($super, container, url, options) {
$super(options);
this.onComplete = this.options.onComplete;
this.frequency = (this.options.frequency || 2);
this.decay = (this.options.decay || 1);
this.updater = { };
this.container = container;
this.url = url;
this.start();
},
start: function() {
this.options.onComplete = this.updateComplete.bind(this);
this.onTimerEvent();
},
stop: function() {
this.updater.options.onComplete = undefined;
clearTimeout(this.timer);
(this.onComplete || Prototype.emptyFunction).apply(this, arguments);
},
updateComplete: function(response) {
if (this.options.decay) {
this.decay = (response.responseText == this.lastText ?
this.decay * this.options.decay : 1);
this.lastText = response.responseText;
}
this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency);
},
onTimerEvent: function() {
this.updater = new Ajax.Updater(this.container, this.url, this.options);
}
});
function $(element) {
if (arguments.length > 1) {
for (var i = 0, elements = [], length = arguments.length; i < length; i++)
elements.push($(arguments[i]));
return elements;
}
if (Object.isString(element))
element = document.getElementById(element);
return Element.extend(element);
}
if (Prototype.BrowserFeatures.XPath) {
document._getElementsByXPath = function(expression, parentElement) {
var results = [];
var query = document.evaluate(expression, $(parentElement) || document,
null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0, length = query.snapshotLength; i < length; i++)
results.push(Element.extend(query.snapshotItem(i)));
return results;
};
}
/*--------------------------------------------------------------------------*/
if (!Node) var Node = { };
if (!Node.ELEMENT_NODE) {
Object.extend(Node, {
ELEMENT_NODE: 1,
ATTRIBUTE_NODE: 2,
TEXT_NODE: 3,
CDATA_SECTION_NODE: 4,
ENTITY_REFERENCE_NODE: 5,
ENTITY_NODE: 6,
PROCESSING_INSTRUCTION_NODE: 7,
COMMENT_NODE: 8,
DOCUMENT_NODE: 9,
DOCUMENT_TYPE_NODE: 10,
DOCUMENT_FRAGMENT_NODE: 11,
NOTATION_NODE: 12
});
share/static/alice.js view on Meta::CPAN
handleEvent: function(event) {
var element = this.selector ? event.findElement(this.selector) :
this.element;
if (element) this.callback.call(element, event, element);
}
});
function on(element, eventName, selector, callback) {
element = $(element);
if (Object.isFunction(selector) && Object.isUndefined(callback)) {
callback = selector, selector = null;
}
return new Event.Handler(element, eventName, selector, callback).start();
}
Object.extend(Event, Event.Methods);
Object.extend(Event, {
fire: fire,
observe: observe,
stopObserving: stopObserving,
on: on
});
Element.addMethods({
fire: fire,
observe: observe,
stopObserving: stopObserving,
on: on
});
Object.extend(document, {
fire: fire.methodize(),
observe: observe.methodize(),
stopObserving: stopObserving.methodize(),
on: on.methodize(),
loaded: false
});
if (window.Event) Object.extend(window.Event, Event);
else window.Event = Event;
})();
(function() {
/* Support for the DOMContentLoaded event is based on work by Dan Webb,
Matthias Miller, Dean Edwards, John Resig, and Diego Perini. */
var timer;
function fireContentLoadedEvent() {
if (document.loaded) return;
if (timer) window.clearTimeout(timer);
document.loaded = true;
document.fire('dom:loaded');
}
function checkReadyState() {
if (document.readyState === 'complete') {
document.stopObserving('readystatechange', checkReadyState);
fireContentLoadedEvent();
}
}
function pollDoScroll() {
try { document.documentElement.doScroll('left'); }
catch(e) {
timer = pollDoScroll.defer();
return;
}
fireContentLoadedEvent();
}
if (document.addEventListener) {
document.addEventListener('DOMContentLoaded', fireContentLoadedEvent, false);
} else {
document.observe('readystatechange', checkReadyState);
if (window == top)
timer = pollDoScroll.defer();
}
Event.observe(window, 'load', fireContentLoadedEvent);
})();
Element.addMethods();
/*------------------------------- DEPRECATED -------------------------------*/
Hash.toQueryString = Object.toQueryString;
var Toggle = { display: Element.toggle };
Element.Methods.childOf = Element.Methods.descendantOf;
var Insertion = {
Before: function(element, content) {
return Element.insert(element, {before:content});
},
Top: function(element, content) {
return Element.insert(element, {top:content});
},
Bottom: function(element, content) {
return Element.insert(element, {bottom:content});
},
After: function(element, content) {
return Element.insert(element, {after:content});
}
};
var $continue = new Error('"throw $continue" is deprecated, use "return" instead');
share/static/alice.js view on Meta::CPAN
});
if(affected.length>0)
drop = Droppables.findDeepestChild(affected);
if(this.last_active && this.last_active != drop) this.deactivate(this.last_active);
if (drop) {
Position.within(drop.element, point[0], point[1]);
if(drop.onHover)
drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element));
if (drop != this.last_active) Droppables.activate(drop);
}
},
fire: function(event, element) {
if(!this.last_active) return;
Position.prepare();
if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active))
if (this.last_active.onDrop) {
this.last_active.onDrop(element, this.last_active.element, event);
return true;
}
},
reset: function() {
if(this.last_active)
this.deactivate(this.last_active);
}
};
var Draggables = {
drags: [],
observers: [],
register: function(draggable) {
if(this.drags.length == 0) {
this.eventMouseUp = this.endDrag.bindAsEventListener(this);
this.eventMouseMove = this.updateDrag.bindAsEventListener(this);
this.eventKeypress = this.keyPress.bindAsEventListener(this);
Event.observe(document, "mouseup", this.eventMouseUp);
Event.observe(document, "mousemove", this.eventMouseMove);
Event.observe(document, "keypress", this.eventKeypress);
}
this.drags.push(draggable);
},
unregister: function(draggable) {
this.drags = this.drags.reject(function(d) { return d==draggable });
if(this.drags.length == 0) {
Event.stopObserving(document, "mouseup", this.eventMouseUp);
Event.stopObserving(document, "mousemove", this.eventMouseMove);
Event.stopObserving(document, "keypress", this.eventKeypress);
}
},
activate: function(draggable) {
if(draggable.options.delay) {
this._timeout = setTimeout(function() {
Draggables._timeout = null;
window.focus();
Draggables.activeDraggable = draggable;
}.bind(this), draggable.options.delay);
} else {
window.focus(); // allows keypress events if window isn't currently focused, fails for Safari
this.activeDraggable = draggable;
}
},
deactivate: function() {
this.activeDraggable = null;
},
updateDrag: function(event) {
if(!this.activeDraggable) return;
var pointer = [Event.pointerX(event), Event.pointerY(event)];
if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return;
this._lastPointer = pointer;
this.activeDraggable.updateDrag(event, pointer);
},
endDrag: function(event) {
if(this._timeout) {
clearTimeout(this._timeout);
this._timeout = null;
}
if(!this.activeDraggable) return;
this._lastPointer = null;
this.activeDraggable.endDrag(event);
this.activeDraggable = null;
},
keyPress: function(event) {
if(this.activeDraggable)
this.activeDraggable.keyPress(event);
},
addObserver: function(observer) {
this.observers.push(observer);
this._cacheObserverCallbacks();
},
removeObserver: function(element) { // element instead of observer fixes mem leaks
this.observers = this.observers.reject( function(o) { return o.element==element });
this._cacheObserverCallbacks();
},
notify: function(eventName, draggable, event) { // 'onStart', 'onEnd', 'onDrag'
if(this[eventName+'Count'] > 0)
this.observers.each( function(o) {
if(o[eventName]) o[eventName](eventName, draggable, event);
});
if(draggable.options[eventName]) draggable.options[eventName](draggable, event);
},
_cacheObserverCallbacks: function() {
['onStart','onEnd','onDrag'].each( function(eventName) {
Draggables[eventName+'Count'] = Draggables.observers.select(
function(o) { return o[eventName]; }
).length;
});
}
};
/*--------------------------------------------------------------------------*/
var Draggable = Class.create({
initialize: function(element) {
var defaults = {
handle: false,
reverteffect: function(element, top_offset, left_offset) {
var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02;
new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur,
queue: {scope:'_draggable', position:'end'}
});
},
endeffect: function(element) {
var toOpacity = Object.isNumber(element._opacity) ? element._opacity : 1.0;
new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,
queue: {scope:'_draggable', position:'end'},
afterFinish: function(){
Draggable._dragging[element] = false
}
});
share/static/alice.js view on Meta::CPAN
{ label: "Italic" }
]);
var Alice = { };
Object.extend(Alice, {
uncacheGravatar: function(content) {
if (!this.timestamp) {
var date = new Date();
this.timestamp = date.getTime();
}
return content.replace(
/(src=".*?gravatar.com\/avatar\/[^?]*\?)/gi,
"$1time=" + this.timestamp + "&"
);
},
epochToLocal: function(epoch, format) {
var date = new Date(parseInt(epoch) * 1000);
if (!date) return epoch;
var hours = date.getHours();
if (format == "12") {
var ap;
if (hours > 12) {
hours -= 12;
ap = "p";
} else {
ap = "a"
}
return sprintf("%d:%02d%s", hours, date.getMinutes(), ap);
}
return sprintf("%02d:%02d", hours, date.getMinutes());
},
stripNick: function(html) {
return html.replace(/<div class="left">.*<\/div>/, '');
},
growlNotify: function(message) {
if (window.fluid) {
window.fluid.showGrowlNotification({
title: message.window.title + ": " + message.nick,
description: message.body.unescapeHTML(),
priority: 1,
sticky: false,
identifier: message.msgid
});
}
else if (window.webkitNotifications) {
if (window.webkitNotifications.checkPermission() == 0) {
var popup = window.webkitNotifications.createNotification(
"http://static.usealice.org/image/alice.png",
message.window.title + ": " + message.nick,
message.body.unescapeHTML()
);
popup.ondisplay = function() {
setTimeout(function () {popup.cancel();}, 3000);
};
popup.show();
}
}
},
isSpecialKey: function(keyCode) {
var special_keys = [
16,27,9,32,13,8,145,20,144,19,45,36,46,35,33,34,37,38,39,
40,17,18,91,112,113,114,115,116,117,118,119,120,121,122,123
];
return special_keys.indexOf(keyCode) > -1;
},
loadInlineImage: function(image) {
var maxWidth = arguments.callee.maxWidth || 300;
var maxHeight = arguments.callee.maxHeight || 300;
image.style.visibility = 'hidden';
if (image.height > image.width && image.height > maxHeight) {
image.style.width = 'auto';
image.style.height = maxHeight + 'px';
}
else if (image.width > maxWidth) {
image.style.height = 'auto';
image.style.width = maxWidth + 'px';
}
else {
image.style.height = 'auto';
}
image.style.display = 'block';
image.style.visibility = 'visible';
setTimeout(function () {
var messagelist = image.up(".message_wrap");
messagelist.scrollTop = messagelist.scrollHeight;
}, 50);
},
playAudio: function(image, audio) {
image.src = '/static/image/pause.png';
if (! audio) {
var url = image.nextSibling.href;
audio = new Audio(url);
audio.addEventListener('ended', function () {
image.src = '/static/image/play.png';
image.onclick = function () { Alice.playAudio(image, audio) };
});
}
audio.play();
image.onclick = function() {
audio.pause();
this.src = '/static/image/play.png';
this.onclick = function () { Alice.playAudio(this, audio) };
};
},
prefs: {
addHighlight: function (alias) {
var channel = prompt("Enter a word to highlight.");
if (channel)
$('highlights').insert("<option value=\""+channel+"\">"+channel+"</option>");
return false;
},
removeHighlights: function (alias) {
$A($('highlights').options).each(function (option) {
if (option.selected) option.remove()});
return false;
},
remove: function() {
alice.windows().each(function(win) {
win.input.disabled = false;
});
$('prefs').remove();
},
submit: function(form) {
var options = {highlights: []};
["images", "avatars", "alerts"].each(function (pref) {
options[pref] = $(pref).checked ? "show" : "hide";
});
$A($("highlights").options).each(function(option) {
options.highlights.push(option.value);
});
["style", "timeformat"].each(function(pref) {
options[pref] = $(pref).value;
});
alice.options = options;
share/static/alice.js view on Meta::CPAN
submit: function(form) {
$$('#servers .channelselect').each(function(select) {
$A(select.options).each(function(option) {
option.selected = true;
});
});
new Ajax.Request('/save', {
method: 'get',
parameters: form.serialize(),
onSuccess: function(){Alice.connections.remove()}
});
return false;
},
remove: function() {
alice.windows().each(function(win) {
win.input.disabled = false;
});
$('servers').remove();
},
serverConnection: function(alias, action) {
new Ajax.Request('/say', {
method: 'get',
parameters: {
msg: '/' + action + ' ' + alias,
source: alice.activeWindow().id
}
});
return false;
}
}
});
Element.addMethods({
redraw: function(element){
element = $(element);
var n = document.createTextNode(' ');
element.appendChild(n);
(function(){n.parentNode.removeChild(n)}).defer();
return element;
}
});
Alice.Application = Class.create({
initialize: function() {
this.isFocused = true;
this.window_map = new Hash();
this.previousFocus = 0;
this.connection = new Alice.Connection(this);
this.filters = [];
this.keyboard = new Alice.Keyboard(this);
this.isPhone = window.navigator.platform.match(/(android|iphone)/i) ? 1 : 0;
this.isMobile = this.isPhone || Prototype.Browser.MobileSafari;
window.onload = function () {
setTimeout(this.connection.connect.bind(this.connection), 1000);
}.bind(this);
this.makeSortable();
},
actionHandlers: {
join: function (action) {
var win = this.getWindow(action['window'].id);
if (!win) {
this.insertWindow(action['window'].id, action.html);
win = new Alice.Window(this, action['window'].id, action['window'].title, false, action['window'].hashtag);
this.addWindow(win);
} else {
win.enable();
}
win.nicks = action.nicks;
},
part: function (action) {
this.closeWindow(action['window'].id);
},
nicks: function (action) {
var win = this.getWindow(action['window'].id);
if (win) win.nicks = action.nicks;
},
alert: function (action) {
this.activeWindow().showAlert(action['body']);
},
clear: function (action) {
var win = this.getWindow(action['window'].id);
if (win) {
win.messages.down("ul").update("");
win.lastNick = "";
}
},
connect: function (action) {
action.windows.each(function (win_info) {
var win = this.getWindow(win_info.id);
if (win) {
win.enable();
}
}.bind(this));
if ($('servers')) {
Alice.connections.connectServer(action.session);
}
},
disconnect: function (action) {
action.windows.each(function (win_info) {
var win = this.getWindow(win_info.id);
if (win) {
win.disable();
}
}.bind(this));
if ($('servers')) {
Alice.connections.disconnectServer(action.session);
}
},
focus: function (action) {
if (!action.window_number) return;
if (action.window_number == "next") {
this.nextWindow();
share/static/alice.js view on Meta::CPAN
addMissed: function() {
if (!window.fluid) return;
window.fluid.dockBadge ? window.fluid.dockBadge++ :
window.fluid.dockBadge = 1;
},
clearMissed: function() {
if (!window.fluid) return;
window.fluid.dockBadge = "";
}
});
Alice.Connection = Class.create({
initialize: function(application) {
this.application = application;
this.len = 0;
this.aborting = false;
this.request = null;
this.seperator = "--xalicex\n";
this.msgid = 0;
this.reconnect_count = 0;
this.reconnecting = false;
},
closeConnection: function() {
this.aborting = true;
if (this.request && this.request.transport)
this.request.transport.abort();
this.aborting = false;
},
connect: function() {
if (this.reconnect_count > 3) {
this.aborting = true;
this.application.activeWindow().showAlert("Alice server is not responding (<a href='javascript:alice.connection.reconnect()'>reconnect</a>)");
return;
}
this.closeConnection();
this.len = 0;
this.reconnect_count++;
var now = new Date();
console.log("opening new connection starting at message " + this.msgid);
this.request = new Ajax.Request('/stream', {
method: 'get',
parameters: {msgid: this.msgid, t: now.getTime() / 1000},
onException: this.handleException.bind(this),
onInteractive: this.handleUpdate.bind(this),
onComplete: this.handleComplete.bind(this)
});
},
reconnect: function () {
this.reconnecting = true;
this.reconnect_count = 0;
this.connect();
},
handleException: function(request, exception) {
console.log("encountered an error with stream.");
if (!this.aborting)
setTimeout(this.connect.bind(this), 2000);
},
handleComplete: function(transport) {
console.log("connection was closed cleanly.");
if (!this.aborting)
setTimeout(this.connect.bind(this), 2000);
},
handleUpdate: function(transport) {
if (this.reconnecting) {
this.application.activeWindow().showHappyAlert("Reconnected to the Alice server");
this.reconnecting = false;
}
this.reconnect_count = 0;
var time = new Date();
var data = transport.responseText.slice(this.len);
var start, end;
start = data.indexOf(this.seperator);
if (start > -1) {
start += this.seperator.length;
end = data.indexOf(this.seperator, start);
if (end == -1) return;
}
else return;
this.len += (end + this.seperator.length) - start;
data = data.slice(start, end);
try {
data = data.evalJSON();
var queue = data.queue;
var length = queue.length;
for (var i=0; i<length; i++) {
if (queue[i].type == "action")
this.application.handleAction(queue[i]);
else if (queue[i].type == "message") {
if (queue[i].msgid) this.msgid = queue[i].msgid;
if (queue[i].timestamp)
queue[i].timestamp = Alice.epochToLocal(queue[i].timestamp);
this.application.displayMessage(queue[i]);
}
}
}
catch (e) {
console.log(e.toString());
}
var lag = time / 1000 - data.time;
if (lag > 5) {
console.log("lag is " + Math.round(lag) + "s, reconnecting.");
this.connect();
}
},
requestWindow: function(title, windowId, message) {
new Ajax.Request('/say', {
method: 'post',
parameters: {source: windowId, msg: "/create " + title},
onSuccess: function (transport) {
this.handleUpdate(transport);
if (message) {
setTimeout(function() {
this.application.displayMessage(message)
}.bind(this), 1000);
}
}.bind(this)
});
},
closeWindow: function(win) {
new Ajax.Request('/say', {
method: 'post',
parameters: {source: win.id, msg: "/close"}
});
},
getConfig: function(callback) {
new Ajax.Request('/config', {
method: 'get',
onSuccess: callback
});
},
getPrefs: function(callback) {
new Ajax.Request('/prefs', {
method: 'get',
onSuccess: callback
});
},
getLog: function(callback) {
new Ajax.Request('/logs', {
method: 'get',
onSuccess: callback
});
},
sendMessage: function(form) {
new Ajax.Request('/say', {
method: 'post',
parameters: form.serialize(),
onException: function (request, exception) {
alert("There was an error sending a message.");
}
});
},
sendTabOrder: function (windows) {
new Ajax.Request('/tabs', {
method: 'post',
parameters: {tabs: windows}
});
},
sendPing: function() {
new Ajax.Request('/ping');
}
});
Alice.Window = Class.create({
initialize: function(application, element, title, active, hashtag) {
this.application = application;
this.element = $(element);
this.title = title;
this.hashtag = hashtag;
this.id = this.element.identify();
this.active = active;
this.tab = $(this.id + "_tab");
this.input = new Alice.Input(this, this.id + "_msg");
this.tabButton = $(this.id + "_tab_button");
this.tabOverflowButton = $(this.id + "_tab_overflow_button");
this.form = $(this.id + "_form");
this.topic = $(this.id + "_topic");
if (this.topic) {
var orig_height = this.topic.getStyle("height");
this.topic.observe("click", function(e) {
if (this.topic.getStyle("height") == orig_height) {
this.topic.setStyle({height: "auto"});
} else {
this.topic.setStyle({height: orig_height});
}
}.bind(this));
}
this.messages = this.element.down('.message_wrap');
this.submit = $(this.id + "_submit");
this.nicksVisible = false;
this.visibleNick = "";
this.visibleNickTimeout = "";
this.nicks = [];
this.messageLimit = 250;
this.submit.observe("click", function (e) {this.input.send(); e.stop()}.bind(this));
this.tab.observe("mousedown", function(e) {
if (!this.active) {this.focus(); this.focusing = true}
}.bind(this));
this.tab.observe("click", function(e) {this.focusing = false}.bind(this));
this.tabButton.observe("click", function(e) {
if (this.active && !this.focusing) this.close()}.bind(this));
this.messages.observe("mouseover", this.showNick.bind(this));
if (Prototype.Browser.Gecko) {
this.resizeMessagearea();
this.scrollToBottom();
}
else if (this.application.isMobile) {
this.messageLimit = 50;
this.messages.select("li").reverse().slice(50).invoke("remove");
}
if (this.active) this.scrollToBottom(true);
this.makeTopicClickable();
setTimeout(function () {
this.messages.select('li.message div.msg').each(function (msg) {
msg.innerHTML = application.applyFilters(msg.innerHTML);
});
}.bind(this), 1000);
},
isTabWrapped: function() {
return this.tab.offsetTop > 0;
},
unFocus: function() {
this.active = false;
this.input.uncancelNextFocus();
this.element.removeClassName('active');
this.tab.removeClassName('active');
this.tabOverflowButton.selected = false;
},
showNick: function (e) {
var li = e.findElement("#" + this.id + " ul.messages li.message");
if (li) {
if (this.nicksVisible || li == this.visibleNick) return;
clearTimeout(this.visibleNickTimeout);
this.visibleNick = li;
var nick; var time;
if (li.hasClassName("consecutive")) {
var stem = li.previous("li:not(.consecutive)");
if (!stem) return;
nick = stem.down(".nickhint");
time = stem.down(".timehint");
} else {
nick = li.down(".nickhint");
time = li.down(".timehint");
}
if (nick || time) {
this.visibleNickTimeout = setTimeout(function(nick, time) {
if (nick) {
nick.style.opacity = 1;
nick.style.webkitTransition = "opacity 0.1s ease-in-out";
}
if (time) {
time.style.webkitTransition = "opacity 0.1s ease-in-out";
time.style.opacity = 1;
}
setTimeout(function(){
if (this.nicksVisible) return;
if (nick) {
nick.style.webkitTransition = "opacity 0.25s ease-in";
nick.style.opacity = 0;
}
if (time) {
time.style.webkitTransition = "opacity 0.25s ease-in";
time.style.opacity = 0;
}
}.bind(this, nick, time) , 1000);
}.bind(this, nick, time), 500);
}
}
else {
this.visibleNick = "";
clearTimeout(this.visibleNickTimeout);
}
},
toggleNicks: function () {
if (this.nicksVisible) {
this.messages.select("span.nickhint").each(function(span){
span.style.webkitTransition = "opacity 0.1s ease-in";
span.style.opacity = 0;
});
this.messages.select("div.timehint").each(function(span){
span.style.webkitTransition = "opacity 0.1s ease-in";
span.style.opacity = 0;
});
}
else {
this.messages.select("span.nickhint").each(function(span){
span.style.webkitTransition = "opacity 0.1s ease-in-out";
span.style.opacity = 1;
});
this.messages.select("div.timehint").each(function(span){
span.style.webkitTransition = "opacity 0.1s ease-in-out";
span.style.opacity = 1;
});
}
this.nicksVisible = !this.nicksVisible;
},
focus: function(event) {
document.title = this.title;
this.application.previousFocus = this.application.activeWindow();
this.application.windows().invoke("unFocus");
this.active = true;
this.tab.addClassName('active');
this.element.addClassName('active');
this.tabOverflowButton.selected = true;
this.markRead();
this.scrollToBottom(true);
if (!this.application.isMobile) this.input.focus();
if (Prototype.Browser.Gecko) {
this.resizeMessagearea();
this.scrollToBottom();
}
this.element.redraw();
window.location.hash = this.hashtag;
window.location = window.location.toString();
this.application.updateChannelSelect();
},
markRead: function () {
this.tab.removeClassName("unread");
this.tab.removeClassName("highlight");
this.tabOverflowButton.removeClassName("unread");
},
disable: function () {
this.markRead();
this.tab.addClassName('disabled');
},
( run in 2.734 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )