/*
Jappix - An open social platform
These are the links JS script for Jappix
-------------------------------------------------
License: dual-licensed under AGPL and MPLv2
Authors: Valérian Saliou, Maranda
Last revision: 26/08/11
*/
// Apply links in a string
function applyLinks(string, mode, style) {
// Special stuffs
var style, target;
// Links style
if(!style)
style = '';
else
style = ' style="' + style + '"';
// Open in new tabs
if(mode != 'xhtml-im')
target = ' target="_blank"';
else
target = '';
// XMPP address
string = string.replace(/(\s|
|^)(([a-zA-Z0-9\._-]+)@([a-zA-Z0-9\.\/_-]+))(,|\s|$)/gi, '$1$2$5');
// Simple link
string = string.replace(/(\s|
|^|\()((https?|ftp|file|xmpp|irc|mailto|vnc|webcal|ssh|ldap|smb|magnet|spotify)(:)([^<>'"\s\)]+))/gim, '$1$2');
return string;
}