Commit 2198561f3f76b2b72886bfbd1935cf91cda632ea

Authored by Ahmed Owian
1 parent a2ae3c10d8
Exists in master

Refactored code

Showing 1 changed file with 38 additions and 34 deletions   Show diff stats
prototype/skype.html
... ... @@ -10,49 +10,53 @@
10 10 <body>
11 11  
12 12 <script type="text/javascript">
  13 + function processProfileLink(element, username)
  14 + {
  15 + element.hover(function()
  16 + {
  17 + var id = "skype_bubble_" + username;
  18 + var skypeBubble = $("#" + id);
  19 +
  20 + if (skypeBubble.length)
  21 + {
  22 + console.log("found it");
  23 + element.append(skypeBubble);
  24 + }
  25 + else
  26 + {
  27 + //TODO: Determine if this user has a skype id, and then display Skype buttons
  28 + //Perhaps use Yahoo bubble like we did for Roles
  29 + element.append($("<div id=\"" + id
  30 + + "\" style=\"background-color: #0094ff\" />"));
  31 + Skype.ui(
  32 + {
  33 + name : "dropdown",
  34 + element : id,
  35 + participants : [ "kngtinc117-test-skype" ],//["echo123"],
  36 + imageSize : 32,
  37 + imageColor : "white",
  38 + video : true
  39 + });
  40 + }
  41 +
  42 + }, function()
  43 + {
  44 + //TODO: Only remove after a few seconds if user is not hovering above this or the skype bubble
  45 + element.find("div:last").remove();
  46 + });
  47 + }
  48 +
13 49 $(document).ready(function()
14 50 {
15 51 $("a[href$=\"/profile\"").each(function(index)
16 52 {
17   - // Ensures that we are dealing with a user profile
  53 + // Ensures that we are dealing with a user profile link
18 54 var href = $(this).attr("href");
19 55 var regex = /share\/page\/user\/(.+)\/profile/;
20 56 var match = regex.exec(href);
21 57 if (match !== null && match.length > 1)
22 58 {
23   - $(this).hover(function()
24   - {
25   - var username = match[1];
26   - var id = "skype_bubble_" + username;
27   - var skypeBubble = $("#" + id);
28   -
29   - if (skypeBubble.length)
30   - {
31   - console.log("found it");
32   - $(this).append(skypeBubble);
33   - }
34   - else
35   - {
36   - //TODO: Determine if this user has a skype id, and then display Skype buttons
37   - //Perhaps use Yahoo bubble like we did for Roles
38   - $(this).append($("<div id=\"" + id
39   - + "\" style=\"background-color: #0094ff\" />"));
40   - Skype.ui(
41   - {
42   - name : "dropdown",
43   - element : id,
44   - participants : [ "kngtinc117-test-skype" ],//["echo123"],
45   - imageSize : 32,
46   - imageColor : "white",
47   - video : true
48   - });
49   - }
50   -
51   - }, function()
52   - {
53   - //TODO: Only remove after a few seconds if user is not hovering above this or the skype bubble
54   - $(this).find("div:last").remove();
55   - });
  59 + processProfileLink($(this), match[1]);
56 60 }
57 61 });
58 62 });
... ...