]> git.mxchange.org Git - friendica-addons.git/blob - jappixmini/jappix/js/links.js
Merge pull request #520 from rabuzarus/20180206_-_membersince_frio_support
[friendica-addons.git] / jappixmini / jappix / js / links.js
1 /*
2
3 Jappix - An open social platform
4 These are the links JS script for Jappix
5
6 -------------------------------------------------
7
8 License: AGPL
9 Authors: Vanaryon, Maranda
10 Last revision: 26/08/11
11
12 */
13
14 // Apply links in a string
15 function applyLinks(string, mode, style) {
16         // Special stuffs
17         var style, target;
18         
19         // Links style
20         if(!style)
21                 style = '';
22         else
23                 style = ' style="' + style + '"';
24         
25         // Open in new tabs
26         if(mode != 'xhtml-im')
27                 target = ' target="_blank"';
28         else
29                 target = '';
30         
31         // XMPP address
32         string = string.replace(/(\s|<br \/>|^)(([a-zA-Z0-9\._-]+)@([a-zA-Z0-9\.\/_-]+))(,|\s|$)/gi, '$1<a href="xmpp:$2" target="_blank"' + style + '>$2</a>$5');
33         
34         // Simple link
35         string = string.replace(/(\s|<br \/>|^|\()((https?|ftp|file|xmpp|irc|mailto|vnc|webcal|ssh|ldap|smb|magnet|spotify)(:)([^<>'"\s\)]+))/gim, '$1<a href="$2"' + target + style + '>$2</a>');
36         
37         return string;
38 }