Initial commit
This commit is contained in:
commit
43ad32700c
7085 changed files with 447606 additions and 0 deletions
73
modules/chat/js/tab.src
Normal file
73
modules/chat/js/tab.src
Normal file
|
@ -0,0 +1,73 @@
|
|||
var TabCompleter = function(element) {
|
||||
this.input = element;
|
||||
};
|
||||
|
||||
TabCompleter.prototype = {
|
||||
input : null,
|
||||
tabInProgress : false,
|
||||
tabBase : null,
|
||||
lastHitIdx : -1,
|
||||
lastSpace : -1,
|
||||
matches: null,
|
||||
reset : function () {
|
||||
this.tabInProgress = false;
|
||||
this.tabBase = null;
|
||||
this.matches = null;
|
||||
this.lastHitIdx = -1;
|
||||
this.lastSpace = -1;
|
||||
}
|
||||
};
|
||||
|
||||
TabCompleter.prototype.complete = function complete()
|
||||
{
|
||||
var text = this.input.value;
|
||||
if (!(this.tabInProgress))
|
||||
{
|
||||
var lastWord;
|
||||
this.lastSpace = text.lastIndexOf(" ");
|
||||
|
||||
if (text.length < 1) {
|
||||
return;
|
||||
}
|
||||
else if (this.lastSpace < 0) {
|
||||
lastWord = text;
|
||||
}
|
||||
else if (++(this.lastSpace) >= text.length) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
lastWord = text.substring(this.lastSpace);
|
||||
}
|
||||
if(lastWord.substr(0,1)=="/"){
|
||||
lastWord=lastWord.substr(1);
|
||||
}
|
||||
this.tabBase = lastWord.toLowerCase();
|
||||
this.tabInProgress = true;
|
||||
}
|
||||
|
||||
var users = $("a.notice",window.parent.document);
|
||||
|
||||
if (this.lastHitIdx >= users.length) {
|
||||
this.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
for (var n = 0; n < users.length; n++)
|
||||
{
|
||||
i = (n + this.lastHitIdx + 1) % users.length;
|
||||
|
||||
if (users.eq(i).attr('id').toLowerCase().indexOf(this.tabBase) == 0)
|
||||
{
|
||||
if (this.lastSpace >= 1) {
|
||||
this.input.value = text.substring(0, this.lastSpace) + users.eq(i).attr('id');
|
||||
}
|
||||
else {
|
||||
this.input.value = users.eq(i).attr('id');
|
||||
}
|
||||
|
||||
this.lastHitIdx = i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue