Skip to content

Commit

Permalink
reworked design and add sip support
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismatthieu committed Oct 9, 2010
1 parent d19f0f0 commit c3827fd
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 47 deletions.
57 changes: 34 additions & 23 deletions app/controllers/facebook_controller.rb
Expand Up @@ -2,8 +2,8 @@ class FacebookController < ApplicationController
def index

#Testing
# session["id"] = "1115105088"
# friends = nil
session["id"] = "1115105088"
friends = nil

@user = User.find_by_facebookid(session["id"])

Expand Down Expand Up @@ -31,6 +31,8 @@ def index
@friends = JSON.parse(friends.body)
end

else
redirect_to "/oauth/start", {:target=>"_parent"}
end

end
Expand Down Expand Up @@ -73,33 +75,42 @@ def telephone

# Look up user by id and call their SIP address and posted number
userid = params[:id]
if userid
@user = User.find_by_facebookid(userid)
if @user
@transfermode = "one" # "all" = simultaneous rings or "one" = one phone at a time
@did = ""
if @user.sip
sipraw = @user.sip
if sipraw.index("@") and !sipraw.index("sip:")
sipraw = "sip:" + sipraw
end
@did << sipraw + ","
if userid
if userid.index("@")
if !userid.index("sip:")
@phone = "sip:" + userid
else
@phone = userid
end
if @user.phonenumber
phoneraw = @user.phonenumber.gsub("-", "").gsub("(", "").gsub(")", "").gsub("+", "")
if phoneraw.index("@") and !phoneraw.index("sip:")
phoneraw = "sip:" + phoneraw
@did = userid
@display = userid
else
@user = User.find_by_facebookid(userid)
if @user
@transfermode = "one" # "all" = simultaneous rings or "one" = one phone at a time
@did = ""
if @user.sip
sipraw = @user.sip
if sipraw.index("@") and !sipraw.index("sip:")
sipraw = "sip:" + sipraw
end
@did << sipraw + ","
end
if isNumeric(phoneraw) and phoneraw.length == 10
phoneraw = "1" + phoneraw
if @user.phonenumber
phoneraw = @user.phonenumber.gsub("-", "").gsub("(", "").gsub(")", "").gsub("+", "")
if phoneraw.index("@") and !phoneraw.index("sip:")
phoneraw = "sip:" + phoneraw
end
if isNumeric(phoneraw) and phoneraw.length == 10
phoneraw = "1" + phoneraw
end
@did << phoneraw + ","
end
@did << phoneraw + ","
@did = @did.chop #remove last comma from @did string
@phone = "app:9991443419"
end
@did = @did.chop #remove last comma from @did string
@phone = "app:9991443419"
end
end
puts @did
render 'phono', :layout => false

end
Expand Down
3 changes: 0 additions & 3 deletions app/controllers/oauth_controller.rb
Expand Up @@ -14,9 +14,6 @@ def callback
)

user_json = access_token.get('/me')
# in reality you would at this point store the access_token.token value as well as
# any user info you wanted
# render :json => user_json

if !user_json.nil?

Expand Down
19 changes: 6 additions & 13 deletions app/views/facebook/index.html.erb
@@ -1,7 +1,3 @@
<h1>
<%=image_tag 'spaz-icon-alpha.png', {:width=>"75"}%><br/>
Telephone <span style="font-size:18px;">(<%=link_to "App Home / Invite Friends", "http://www.facebook.com/apps/application.php?id=104425026288823&v=page_getting_started", {:target=>"_parent"} %>)</span>
</h1>
<% if @user %>

<!-- Launch Telephone popup on page launch -->
Expand Down Expand Up @@ -68,17 +64,14 @@
<p>

<%#button_to_function "Authorize", "window.location = '/authorize/new'" %>
<%=button_to_function "Authorize", "window.location = '/oauth/start'" %>
<%# button_to_function "Authorize", "window.location = '/oauth/start'" %>
</p>

<% end %>

<p><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fapps.facebook.com%2Ftelephone%2F&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>
</p>

<p>
<hr/>
<%=image_tag("coolphone2.gif", {:align=>"right"})%>

<%#image_tag("coolphone2.gif", {:align=>"right"})%>
Telephone is a real telephone that it lives on the web - like you. Best of all, it's absolutely <b>FREE</b> to make and receive phone calls online while not exposing your phone number to other Facebook users! There is nothing to download -

<!-- <p>
Expand All @@ -88,13 +81,13 @@
<% if @user %>
just follow these steps:</p>
<p>
<%=image_tag("circle_1.gif", {:width=>"30"})%> <%= link_to_redbox('Add', :inline_phone, html_options = {})%> your mobile phone number.
<%=image_tag("Circle_1.gif", {:width=>"30"})%> <%= link_to_redbox('Add', :inline_phone, html_options = {})%> your mobile phone number.
</p>
<p>
<%=image_tag("circle_2.gif", {:width=>"30"})%> <%=link_to_function "Find", visual_effect(:toggle_slide, "phonebook", :duration => 0.5) %> Facebook friends using Telephone. Click on your friend's photo to call them or simply launch Telephone to make and receive real phone calls!
<%=image_tag("Circle_2.gif", {:width=>"30"})%> <%=link_to_function "Find", visual_effect(:toggle_slide, "phonebook", :duration => 0.5) %> Facebook friends using Telephone. Click on your friend's photo to call them or simply launch Telephone to make and receive real phone calls!
</p>
<p>
<%=image_tag("circle_3.gif", {:width=>"30"})%> <a href="#" onclick="popitup('/telephone')">Launch</a> your new Telephone now! (Note: This application works best when used with headphones to stop the echoing.)
<%=image_tag("Circle_3.gif", {:width=>"30"})%> <a href="#" onclick="popitup('/telephone')">Launch</a> your new Telephone now! <br/>(Note: This application works best when used with headphones to stop the echoing. You can also click the "remember" button on the security popup.)
</p>

<% else %>
Expand Down
14 changes: 12 additions & 2 deletions app/views/facebook/phono.html.erb
Expand Up @@ -31,7 +31,7 @@
var dialString = document.getElementById("dialstring");
var destString = document.getElementById("destinationTxt");
var didString = document.getElementById("did");
destString.value = "app:9991443313"
// destString.value = "app:9991443313"
if(dialString.value.substring(0,1) == '1')
{
didString.value = dialString.value;
Expand All @@ -41,6 +41,16 @@
didString.value = '1' + dialString.value;
}

// Determine SIP or PSTN
if(dialString.value.substring(0,1) == 's')
{
destString.value = dialString.value;
}
else
{
destString.value = "app:9991443313";
}

makeCall();
}
function dialClear()
Expand Down Expand Up @@ -289,7 +299,7 @@
<input type="hidden" id="callState" />
<input type="hidden" id="sessionId" />

<input type="text" id="dialstring">
<input type="text" id="dialstring" value="<%=@display-%>">
<input type="hidden" id="destinationTxt" value="<%=@phone%>" />
<input type="hidden" id="did" value="<%=@did%>" />
<!-- <a href="javascript:window.close()"><img src="/images/delete.gif" align="right" width="25" border="0"></a> -->
Expand Down
3 changes: 3 additions & 0 deletions app/views/facebook/policy.html.erb
@@ -0,0 +1,3 @@
<h1>
Policy - coming soon...
</h1>
3 changes: 3 additions & 0 deletions app/views/facebook/terms.html.erb
@@ -0,0 +1,3 @@
<h1>
Terms - coming soon...
</h1>
33 changes: 29 additions & 4 deletions app/views/layouts/application.html.erb
Expand Up @@ -25,10 +25,31 @@
// -->
</script>


<%= yield(:head) %>

</head>
<body>

<div id="container">
<div id="sidebar">
<p><h2><%=image_tag 'spaz-icon-alpha.png', {:width=>"75"}%><br/>

<%=link_to "Telephone", "/" %>
</h2>
<center>
<%#link_to "Facebook App", "http://www.facebook.com/apps/application.php?id=104425026288823&v=page_getting_started", {:target=>"_parent"} %>
<%=link_to "Terms", "terms" %> | <%=link_to "Policy", "policy" %></center>
<%#link_to "App Home", "http://www.facebook.com/apps/application.php?id=104425026288823&v=page_getting_started", {:target=>"_parent"} %></p>
<p><br/>
Like Button
</p>
<p>
Share Link
</p>
</div>

<div id="content">

<div id="inline_invite" style="display: none">
<div style="width: 450px">
<%= link_to_close_redbox(raw('<img src="/images/close-btn.png" align="right" width="24" height="24" class="close-btn" border="0">'), html_options = {}) %>
Expand Down Expand Up @@ -62,12 +83,16 @@
</center>
</div>
</div>


<%= yield %>
<%= yield %>

<div id="footer">
<p>&copy; Voxeo</p>
</div>
</div>

<!-- <div id="footer">
<p>&copy; Voxeo</p>
</div> -->

</body>
</html>
6 changes: 5 additions & 1 deletion config/routes.rb
Expand Up @@ -14,11 +14,15 @@
match 'facebook/update_phonoaddress' => 'facebook#update_phonoaddress'
match 'facebook/invite' => 'facebook#invite'

match 'telephone(/:id)' => 'facebook#telephone'
match 'telephone(/:id)' => 'facebook#telephone' # WHY IS THE PERIOD GETTING CHOPPED OFF THE ID?

match 'oauth/start' => 'oauth#start'
match 'oauth/callback' => 'oauth#callback'

match 'terms' => 'facebook#terms'
match 'policy' => 'facebook#policy'


# The priority is based upon order of creation:
# first created -> highest priority.

Expand Down
2 changes: 1 addition & 1 deletion public/stylesheets/redbox.css
Expand Up @@ -30,7 +30,7 @@
display: block;
text-align: left;
overflow: hidden;
margin: 20px auto 0 auto;
margin: 20px 250px 0px auto;
position:fixed;
position: absolute;
-webkit-border-radius:10px;
Expand Down
24 changes: 24 additions & 0 deletions public/stylesheets/scaffold.css
Expand Up @@ -13,6 +13,29 @@ pre {
font-size: 11px;
}

#container {
width: 760px;
}

#sidebar {
background-color: #eee;
margin: 10px;
padding: 10px;
font-size: 12px;
width: 200px;
height: 500px;
float: left;
text-align: center;
}

#content {
background-color: #FFF;
font-size: 14px;
width: 520px;
height: auto;
float: right;
}

a { color: #00f;
text-decoration:underline; }

Expand Down Expand Up @@ -73,6 +96,7 @@ div.field, div.actions {
/* background: #0098DB url(/images/img08blue.gif) repeat-x;*/
color: #999;
font-size: 1.5em;
float: bottom;
}

#footer p {
Expand Down

0 comments on commit c3827fd

Please sign in to comment.