Commit a2ae3c10d8ad6443ae7ec98f9ab026b4d57b914c

Authored by Ahmed Owian
1 parent 14fb1efa20
Exists in master

Used Regex instead of indexOf

Showing 1 changed file with 5 additions and 9 deletions   Show diff stats
prototype/skype.html
... ... @@ -14,17 +14,15 @@
14 14 {
15 15 $("a[href$=\"/profile\"").each(function(index)
16 16 {
  17 + // Ensures that we are dealing with a user profile
17 18 var href = $(this).attr("href");
18   - if (href.indexOf("/share/page/user/") > -1)
  19 + var regex = /share\/page\/user\/(.+)\/profile/;
  20 + var match = regex.exec(href);
  21 + if (match !== null && match.length > 1)
19 22 {
20 23 $(this).hover(function()
21 24 {
22   - // Parses out the Alfresco username.
23   - //TODO: Use regex
24   - var user = "/user/";
25   - var start = href.indexOf(user) + user.length;
26   - var end = href.indexOf("/profile");
27   - var username = href.substring(start, end);
  25 + var username = match[1];
28 26 var id = "skype_bubble_" + username;
29 27 var skypeBubble = $("#" + id);
30 28  
... ... @@ -66,8 +64,6 @@
66 64 <a href="/share/page/user/dsamarzija2/profile" class="theme-color-1">Dario
67 65 Samarzija2</a>
68 66  
69   -<span id="jelena">something</span>
70   -
71 67 <div id="SkypeButton_Call_ahmedowian_1">
72 68 <script type="text/javascript">
73 69 Skype.ui(
... ...