js: rename $ -> el for jQuery compat
This commit is contained in:
parent
377131e43d
commit
b8791f6aa2
@ -7,7 +7,7 @@ var SENTINEL_PASSWORD = "************";
|
||||
var CHAT_SCROLLBACK_LIMIT = 50; // Once over 2x $limit, the first $limit will be trimmed off the list
|
||||
var EXTERN_ROOT = window.location.protocol + "//" + window.location.host + "/";
|
||||
|
||||
var $ = function(s) {
|
||||
var el = function(s) {
|
||||
// There used to be a querySelectorAll implementation, but, better that we don't have
|
||||
// potentially-incompatible implementations if this one does actually work.
|
||||
// i'm not writing a selector engine...
|
||||
@ -179,7 +179,7 @@ var notify = function(title, body, tab) {
|
||||
/* Tab writers */
|
||||
|
||||
var write = function(tab) {
|
||||
var $tab = $('#inner-'+tab);
|
||||
var $tab = el('#inner-'+tab);
|
||||
return {
|
||||
'cls': function() {
|
||||
$tab.innerHTML = '';
|
||||
@ -255,7 +255,7 @@ var userlist = {
|
||||
'add': function(u) {
|
||||
if (this.has(u)) return;
|
||||
|
||||
var userlists = $(".userlist");
|
||||
var userlists = el(".userlist");
|
||||
for (var l = 0, e = userlists.length; l !== e; ++l) {
|
||||
var userlist = userlists[l];
|
||||
|
||||
@ -284,7 +284,7 @@ var userlist = {
|
||||
return this;
|
||||
},
|
||||
'del': function(u) {
|
||||
var userlists = $(".userlist");
|
||||
var userlists = el(".userlist");
|
||||
for (var l = 0, e = userlists.length; l !== e; ++l) {
|
||||
if (! userlists[l].children) continue;
|
||||
var userlist = userlists[l];
|
||||
@ -301,7 +301,7 @@ var userlist = {
|
||||
return this;
|
||||
},
|
||||
'clear': function() {
|
||||
var userlists = $(".userlist");
|
||||
var userlists = el(".userlist");
|
||||
for (var i in userlists) {
|
||||
if (! userlists[i].children) continue;
|
||||
var userlist = userlists[i];
|
||||
@ -314,7 +314,7 @@ var userlist = {
|
||||
return this;
|
||||
},
|
||||
'names': function() {
|
||||
var userlist = $(".userlist")[0].children;
|
||||
var userlist = el(".userlist")[0].children;
|
||||
var ret = [];
|
||||
for (var i = 0, e = userlist.length; i < e; ++i) {
|
||||
ret.push( textContent(userlist[i]) );
|
||||
@ -322,14 +322,14 @@ var userlist = {
|
||||
return ret;
|
||||
},
|
||||
'has': function(u) {
|
||||
return $(".user-" + b64(u)).length !== 0; /* there are two - large and non-large */
|
||||
return el(".user-" + b64(u)).length !== 0; /* there are two - large and non-large */
|
||||
},
|
||||
'count': function() {
|
||||
return $(".userlist")[0].children.length;
|
||||
return el(".userlist")[0].children.length;
|
||||
},
|
||||
'setInfo': function(nick, props) {
|
||||
var baseClass = "user-" + b64(nick);
|
||||
var $el = $("." + baseClass);
|
||||
var $el = el("." + baseClass);
|
||||
var prop_str = [];
|
||||
if (props.Description.length > 0) {
|
||||
prop_str.push(props.Description);
|
||||
@ -358,7 +358,7 @@ var userlist = {
|
||||
};
|
||||
|
||||
var submit = function() {
|
||||
var str = $("#chatbox").value;
|
||||
var str = el("#chatbox").value;
|
||||
if (! str.length) return;
|
||||
|
||||
if (hub_state === STATE_READY_FOR_LOGIN) {
|
||||
@ -401,7 +401,7 @@ var submit = function() {
|
||||
write("tab-main").system("Invalid internal state.");
|
||||
}
|
||||
|
||||
$("#chatbox").value = '';
|
||||
el("#chatbox").value = '';
|
||||
};
|
||||
|
||||
/* page visibility */
|
||||
@ -448,13 +448,13 @@ var pagevis_setup = function(fnActive, fnInactive) {
|
||||
*/
|
||||
var tab_set = function(tab) {
|
||||
|
||||
var tabs = $(".tabpane");
|
||||
var tabs = el(".tabpane");
|
||||
for (var i in tabs) {
|
||||
try {
|
||||
tabs[i].style.display = (tabs[i].id === tab ? 'block' : 'none');
|
||||
} catch (e) {};
|
||||
}
|
||||
var tabitems = $(".tabitem");
|
||||
var tabitems = el(".tabitem");
|
||||
for (var i in tabitems) {
|
||||
try {
|
||||
// Update UNREAD/SELECTED flags for the target
|
||||
@ -482,13 +482,13 @@ var tab_set = function(tab) {
|
||||
updateTitle();
|
||||
|
||||
write(tab).scroll();
|
||||
$("#chatbox").focus();
|
||||
el("#chatbox").focus();
|
||||
last_tab = tab;
|
||||
|
||||
};
|
||||
|
||||
var tab_new = function(id, name) {
|
||||
appendInnerHTML($("#bar"),
|
||||
appendInnerHTML(el("#bar"),
|
||||
' <div class="tabitem" data-tab="tab-ext-'+id+'" id="tabitem-tab-ext-'+id+'">'+
|
||||
'<span class="tab-label">'+
|
||||
hesc(name)+
|
||||
@ -496,7 +496,7 @@ var tab_new = function(id, name) {
|
||||
'<a class="tab-closer" data-tab="tab-ext-'+id+'">×</a>'+
|
||||
'</div> '
|
||||
);
|
||||
appendInnerHTML($("#extratabs"),
|
||||
appendInnerHTML(el("#extratabs"),
|
||||
' <div class="tabpane content placement-mid" id="tab-ext-'+id+'" style="display:none;">'+
|
||||
'<div class="content-inner" id="inner-tab-ext-'+id+'"></div>'+
|
||||
'</div>'
|
||||
@ -509,10 +509,10 @@ var tab_free = function(id) {
|
||||
if (id === "tab-main") return;
|
||||
|
||||
// remove tab item and body
|
||||
var el = $("#tabitem-"+id);
|
||||
var el = el("#tabitem-"+id);
|
||||
el.parentNode.removeChild(el);
|
||||
|
||||
var el = $("#"+id);
|
||||
var el = el("#"+id);
|
||||
el.parentNode.removeChild(el);
|
||||
|
||||
// clear from PM tabs
|
||||
@ -547,7 +547,7 @@ var noprop = function(ev) {
|
||||
}
|
||||
|
||||
var tab_addHandlers = function() {
|
||||
var tabitems = $(".tabitem");
|
||||
var tabitems = el(".tabitem");
|
||||
for (var i = 0; i < tabitems.length; i++) {
|
||||
if (! tabitems[i]) continue;
|
||||
|
||||
@ -558,7 +558,7 @@ var tab_addHandlers = function() {
|
||||
};
|
||||
}
|
||||
|
||||
var tabclosers = $(".tab-closer");
|
||||
var tabclosers = el(".tab-closer");
|
||||
for (var i = 0; i < tabclosers.length; i++) {
|
||||
if (! tabclosers[i]) continue;
|
||||
|
||||
@ -598,7 +598,7 @@ var tabcomplete_state = '';
|
||||
|
||||
var tabcompletion_start = function(direction) {
|
||||
|
||||
var cursor = $("#chatbox").value.replace(/^.*\s([^\s]+)$/, '$1');
|
||||
var cursor = el("#chatbox").value.replace(/^.*\s([^\s]+)$/, '$1');
|
||||
|
||||
if (tabcomplete_state === '') {
|
||||
// new tab completion
|
||||
@ -634,10 +634,10 @@ var tabcompletion_start = function(direction) {
|
||||
|
||||
// Replace in textbox
|
||||
|
||||
var chatprefix = $("#chatbox").value.substr(0, $("#chatbox").value.length - cursor.length);
|
||||
var chatprefix = el("#chatbox").value.substr(0, el("#chatbox").value.length - cursor.length);
|
||||
|
||||
$("#chatbox").value = chatprefix + targetName;
|
||||
$("#chatbox").focus();
|
||||
el("#chatbox").value = chatprefix + targetName;
|
||||
el("#chatbox").focus();
|
||||
};
|
||||
|
||||
var tabcompletion_inactive = function() {
|
||||
@ -686,7 +686,7 @@ MenuList.prototype.toggle = function() {
|
||||
|
||||
/* */
|
||||
|
||||
var menu = new MenuList($("#menubutton"));
|
||||
var menu = new MenuList(el("#menubutton"));
|
||||
|
||||
menu.reset = function() {
|
||||
this.clear();
|
||||
@ -782,7 +782,7 @@ var toggle_joinparts = function(ev) {
|
||||
|
||||
var updateTitle = function() {
|
||||
var prefix = "";
|
||||
var unrTabs = $(".unread");
|
||||
var unrTabs = el(".unread");
|
||||
if (unrTabs.length === 1 && unrTabs[0].getAttribute('data-tab') == "tab-main") {
|
||||
prefix = "[" + mainchat_unread_count + " NEW] "
|
||||
} else if (unrTabs.length > 0) {
|
||||
@ -883,7 +883,7 @@ var scrollback_move = function(delta) {
|
||||
}
|
||||
}
|
||||
|
||||
$("#chatbox").value = chat_scrollback[chat_scrollback_index];
|
||||
el("#chatbox").value = chat_scrollback[chat_scrollback_index];
|
||||
};
|
||||
|
||||
/* */
|
||||
@ -908,25 +908,25 @@ var transition = function(new_state) {
|
||||
switch(new_state) {
|
||||
case STATE_DISCONNECTED: {
|
||||
userlist.clear();
|
||||
$("#chatbox").disabled = true;
|
||||
$("#chatbox").value = ''; // clear
|
||||
el("#chatbox").disabled = true;
|
||||
el("#chatbox").value = ''; // clear
|
||||
} break;
|
||||
|
||||
case STATE_READY_FOR_LOGIN: {
|
||||
userlist.clear();
|
||||
$("#chatbox").spellcheck = false;
|
||||
$("#chatbox").disabled = false;
|
||||
$("#chatbox").value = ''; // clear
|
||||
el("#chatbox").spellcheck = false;
|
||||
el("#chatbox").disabled = false;
|
||||
el("#chatbox").value = ''; // clear
|
||||
} break;
|
||||
|
||||
case STATE_CONNECTING: {
|
||||
$("#chatbox").disabled = true;
|
||||
el("#chatbox").disabled = true;
|
||||
} break;
|
||||
|
||||
case STATE_ACTIVE: {
|
||||
write("tab-main").system("Now talking on "+hub_hubname);
|
||||
$("#chatbox").disabled = false;
|
||||
$("#chatbox").spellcheck = true;
|
||||
el("#chatbox").disabled = false;
|
||||
el("#chatbox").spellcheck = true;
|
||||
} break;
|
||||
}
|
||||
};
|
||||
@ -936,8 +936,8 @@ var tab_is_visible = function(tabref) {
|
||||
}
|
||||
|
||||
var tab_mark_unread = function(tabref) {
|
||||
if ($("#tabitem-"+tabref).className.indexOf('unread') === -1) {
|
||||
$("#tabitem-"+tabref).className += " unread";
|
||||
if (el("#tabitem-"+tabref).className.indexOf('unread') === -1) {
|
||||
el("#tabitem-"+tabref).className += " unread";
|
||||
updateTitle();
|
||||
}
|
||||
}
|
||||
@ -951,13 +951,13 @@ window.onload = function() {
|
||||
|
||||
// HTML event handlers
|
||||
|
||||
$("#form-none").onsubmit = function(ev) {
|
||||
el("#form-none").onsubmit = function(ev) {
|
||||
submit();
|
||||
|
||||
return noprop(ev); // don't submit form
|
||||
};
|
||||
|
||||
$("#chatbox").onkeydown = function(ev) {
|
||||
el("#chatbox").onkeydown = function(ev) {
|
||||
if (ev.keyCode === 9 /* Tab */) {
|
||||
tabcompletion_start( ev.shiftKey ? -1 : 1 );
|
||||
return noprop(ev);
|
||||
@ -985,7 +985,7 @@ window.onload = function() {
|
||||
usermenu.hide();
|
||||
};
|
||||
|
||||
$("#menubutton").onclick = function(ev) {
|
||||
el("#menubutton").onclick = function(ev) {
|
||||
menu.toggle();
|
||||
return noprop(ev);
|
||||
};
|
||||
@ -1043,7 +1043,7 @@ window.onload = function() {
|
||||
if (pre_login.indexOf(":") !== -1) {
|
||||
pre_login = pre_login.substr(0, pre_login.indexOf(":")) + ":" + SENTINEL_PASSWORD;
|
||||
}
|
||||
$("#chatbox").value = pre_login;
|
||||
el("#chatbox").value = pre_login;
|
||||
|
||||
if (have_cleared_once) {
|
||||
// re-log-in automatically
|
||||
@ -1137,6 +1137,12 @@ window.onload = function() {
|
||||
sock.on('usercommand', function(data) {
|
||||
process_usercommand(data);
|
||||
});
|
||||
sock.on('contented', function(url) {
|
||||
contented_url = url;
|
||||
menu.add("Upload", function() {
|
||||
contented_load();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
//IIFEMODE:})();
|
||||
|
Loading…
Reference in New Issue
Block a user