Closed cburschka closed 8 years ago
The JS code for the classes is this:
jidClass: function(jid) {
return 'jid-node-' + visual.escapeClass(Strophe.unescapeNode(Strophe.getNodeFromJid(jid)).toLowerCase()) + ' '
+ 'jid-domain-' + visual.escapeClass(Strophe.getDomainFromJid(jid)) + ' '
+ 'jid-resource-' + visual.escapeClass(Strophe.getResourceFromJid(jid));
},
// Escape values to make a valid CSS class:
// All values are allowed except whitespace, NUL and backslash.
// These are replaced with \DEC, where DEC is their ASCII value.
escapeClass: function(text) {
return text ? text.replace(/[\s\0\\]/g, function(x) {
return '\\' + x.charCodeAt(0);
}) : '';
}
In PHP, I think it would basically look like
function escape_class($string) {
return $string ? preg_replace_callback('/[\\s\0\\\\]/', function ($x) {
return '\\' . ord($x[0]);
}) : '';
}
function jid_classes(XMPPJid $jid) {
return 'jid-node-' . escape_class(strtolower($jid->node))
. ' jid-domain-' . escape_class($jid->domain)
// (we don't really care about the resource)
. ' jid-resource-' . escape_class($jid->resource);
}
Can we have this in :tell, too? Wrapping the JID in <span data-jid="">
would allow you to do stuff like send direct messages and open the context menu - and adding the JID classes would put flairs on them as well.
(I'll open a new issue, this looks a bit more complex.)
As you mentioned in the chat.
The markup you'd want to send is basically
I've just tried it, and the data-* goes through XMPP just fine. If the classes are set as well, even the flair is added.