diff --git a/app/assets/images/connection/Thumbs.db b/app/assets/images/connection/Thumbs.db new file mode 100755 index 00000000..47897e3f Binary files /dev/null and b/app/assets/images/connection/Thumbs.db differ diff --git a/app/assets/images/connection/facebook.png b/app/assets/images/connection/facebook.png new file mode 100755 index 00000000..f8c4f219 Binary files /dev/null and b/app/assets/images/connection/facebook.png differ diff --git a/app/assets/images/connection/gmail.png b/app/assets/images/connection/gmail.png new file mode 100755 index 00000000..ec897f23 Binary files /dev/null and b/app/assets/images/connection/gmail.png differ diff --git a/app/assets/images/connection/twitter.png b/app/assets/images/connection/twitter.png new file mode 100755 index 00000000..a8071eea Binary files /dev/null and b/app/assets/images/connection/twitter.png differ diff --git a/app/assets/javascripts/desktop/orbitdesktop.js b/app/assets/javascripts/desktop/orbitdesktop.js index 065d64cb..b5a44940 100755 --- a/app/assets/javascripts/desktop/orbitdesktop.js +++ b/app/assets/javascripts/desktop/orbitdesktop.js @@ -32,7 +32,6 @@ //enableLanguageSelect( dom ) children will be binded with language, data-lang = string ex "en"|"zh_tw" will toggle all data-langunage throughout the page //enableSharing( dom ) children will be binded with share, data-mode = string ex "public"|"private" will change the mode for all the selected items. the dom with class should have data-link = url data-var = vaiable_name, default will be mode - $.extend($.expr[':'], { 'containsi': function (elem, i, match, array) { return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0; @@ -1349,50 +1348,52 @@ var orbitDesktop = function(dom){ this.initializeSettings.connection = function(){ var bindHandlers = function(){ - $("#connection_setting ul a").click(function(){ + $("#connection_setting ul div.s_action a").click(function(){ var what = $(this).attr("for"), - type = $(this).attr("href"), - $ul = $("#"+type+"_connection"), - usernm = $ul.find("input[type=text]").val(), - pwd = $ul.find("input[type=password]").val(); - switch(what){ - case "save": - case "new": - if(usernm!="" && pwd!=""){ - $ul.find("input[type=text]").replaceWith("
"+usernm+"
") - $ul.find("input[type=password]").replaceWith("
••••••
"); - $(this).text("Edit").attr("for","edit"); - $(this).parent().find("a[for=delete]").show(); - $ul.find("span.c_status").text("Connected").addClass("c_status_on"); - if(what=="save") - what="edit"; - saveaccount(usernm,pwd,type,what); - } - break; - case "edit": - var un = $ul.find("div.usrnm").text(); - $ul.find("div.usrnm").replaceWith(''); - $ul.find("div.pwd").replaceWith(''); - $(this).text("Save").attr("for","save"); - break; - case "delete": - var $this = $(this); - o.confirm({ - message : "Are you sure that you want to remove this account?", - buttons : ["Yes","No"], - highlighted : 2 - },function(reply){ - if(reply){ - $this.hide(); - $ul.find("div.usrnm").replaceWith(''); - $ul.find("div.pwd").replaceWith(''); - $ul.find("span.c_status").text("No Connection").removeClass("c_status_on"); - $this.parent().find("a[for=edit]").text("Connect").attr("for","new"); - saveaccount("","",type,what); + type = $(this).attr("href"), + $ul = $("#"+type+"_connection"), + usernm = $ul.find("input[type=text]").val(), + pwd = $ul.find("input[type=password]").val(); + + switch(what){ + case "save": + case "new": + if(usernm!="" && pwd!=""){ + $ul.find("input[type=text]").replaceWith("
"+usernm+"
") + $ul.find("input[type=password]").replaceWith("
••••••
"); + $(this).text("Edit").attr("for","edit"); + $(this).parent().find("a[for=delete]").show(); + $ul.find("span.c_status").text("Connected").addClass("c_status_on"); + if(what=="save") + what="edit"; + saveaccount(usernm,pwd,type,what); + } - }) - break; - } + break; + case "edit": + var un = $ul.find("div.usrnm").text(); + $ul.find("div.usrnm").replaceWith(''); + $ul.find("div.pwd").replaceWith(''); + $(this).text("Save").attr("for","save"); + break; + case "delete": + var $this = $(this); + o.confirm({ + message : "Are you sure that you want to remove this account?", + buttons : ["Yes","No"], + highlighted : 2 + },function(reply){ + if(reply){ + $this.hide(); + $ul.find("div.usrnm").replaceWith(''); + $ul.find("div.pwd").replaceWith(''); + $ul.find("span.c_status").text("No Connection").removeClass("c_status_on"); + $this.parent().find("a[for=edit]").text("Connect").attr("for","new"); + saveaccount("","",type,what); + } + }) + break; + } }) var $conlist = $('.s_form'), @@ -1418,17 +1419,17 @@ var orbitDesktop = function(dom){ }) } - // $.getJSON("/otheraccounts/getaccounts",function(accounts){ - // $.each(accounts,function(i,account){ - // $ul = $("#"+account.type+"_connection"); - // $ul.find("input[type=text]").replaceWith("
"+account.email+"
") - // $ul.find("input[type=password]").replaceWith("
••••••
"); - // $ul.find("a[for=new]").text("Edit").attr("for","edit"); - // $ul.find("a[for=delete]").show(); - // $ul.find(".c_status").text("Connected").addClass("c_status_on"); - // }) - // bindHandlers(); - // }) + $.getJSON("/otheraccounts/getaccounts",function(accounts){ + $.each(accounts,function(i,account){ + $ul = $("#"+account.type+"_connection"); + $ul.find("input[type=text]").replaceWith("
"+account.email+"
") + $ul.find("input[type=password]").replaceWith("
••••••
"); + $ul.find("a[for=new]").text("Edit").attr("for","edit"); + $ul.find("a[for=delete]").show(); + $ul.find(".c_status").text("Connected").addClass("c_status_on"); + }) + bindHandlers(); + }) } diff --git a/app/controllers/desktop_controller.rb b/app/controllers/desktop_controller.rb index 79c9f926..4e301dc9 100644 --- a/app/controllers/desktop_controller.rb +++ b/app/controllers/desktop_controller.rb @@ -52,7 +52,8 @@ class DesktopController< ApplicationController end def connections - @url = "http://fb.tp.rulingcom.com/login?callback=http://harry.tp.rulingcom.com/facebook/register_fb?user="+current_user.id.to_s + # @url = "http://fb.tp.rulingcom.com/login?callback=http://harry.tp.rulingcom.com/facebook/register_fb?user="+current_user.id.to_s + @user_id = current_user.id.to_s render "desktop/settings/connections", :layout => false end diff --git a/app/controllers/otheraccounts_controller.rb b/app/controllers/otheraccounts_controller.rb index d946bd3c..ee4e9b9f 100644 --- a/app/controllers/otheraccounts_controller.rb +++ b/app/controllers/otheraccounts_controller.rb @@ -1,4 +1,4 @@ -class Desktop::OtheraccountsController< ApplicationController +class OtheraccountsController < ApplicationController require 'open-uri' require 'rexml/document' require 'net/http' @@ -11,12 +11,13 @@ class Desktop::OtheraccountsController< ApplicationController @email = params['email'] @password = params['password'] @account = params['account'] + case @dowhat when "new" OtherAccount.create(user_id: current_user.id, email: @email, encrypted_password: @password, type: @account) when "edit" - @otheraccount = OtherAccount.where(:type.all => [@account],:user_id.all => [current_user.id]) rescue nil - @otheraccount.first.update_attributes(:email => @email, :encrypted_password => @password) + @otheraccount = current_user.other_accounts.where(:type => @account).first rescue nil + @otheraccount.update_attributes(:email => @email, :encrypted_password => @password) when "delete" @otheraccount = OtherAccount.where(:type.all => [@account], :user_id.all => [current_user.id]) rescue nil @otheraccount.destroy_all @@ -27,7 +28,7 @@ class Desktop::OtheraccountsController< ApplicationController end def gmail - @gmailaccount = OtherAccount.where(:type.all => ["gmail"],:user_id.all => [current_user.id]) rescue nil + @gmailaccount = current_user.other_accounts.where(:type => "gmail") rescue nil if @gmailaccount.first != nil @decrypted_password = @gmailaccount.first.encrypted_password.decrypt @email = @gmailaccount.first.email @@ -44,7 +45,7 @@ class Desktop::OtheraccountsController< ApplicationController root = Document.new(response.read_body).root render :text=>root else - msg = "trueAccount setting problem." + msg = "Unauthorized

No account connected.

" respond_to do |m| m.xml {render :xml=>msg} end @@ -72,7 +73,7 @@ class Desktop::OtheraccountsController< ApplicationController end def getaccounts - @accounts = OtherAccount.where(:user_id.all => [current_user.id]).without(:encrypted_password) + @accounts = current_user.other_accounts.without(:encrypted_password) render :json => @accounts.to_json end end \ No newline at end of file diff --git a/app/views/desktop/settings/connections.html.erb b/app/views/desktop/settings/connections.html.erb index 57b186d1..da543b3c 100644 --- a/app/views/desktop/settings/connections.html.erb +++ b/app/views/desktop/settings/connections.html.erb @@ -1,11 +1,11 @@ -
- Connect FaceBook +
+ +
- --> +
diff --git a/app/views/desktop/settings/themes.html.erb b/app/views/desktop/settings/themes.html.erb index 9960d374..836ccec9 100644 --- a/app/views/desktop/settings/themes.html.erb +++ b/app/views/desktop/settings/themes.html.erb @@ -7,7 +7,7 @@ -
+
<% @themes.each do |theme| %> diff --git a/config/routes.rb b/config/routes.rb index f8174291..69430665 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -317,7 +317,7 @@ Orbit::Application.routes.draw do match '/twitter/'=>'otheraccounts#twitter' match '/forgmail/'=>'otheraccounts#gmail' match '/otheraccounts/getaccounts'=>'otheraccounts#getaccounts' - match '/save_account_info/'=>'otheraccounts#saveaccountinfo' + match '/desktop/save_account_info/'=>'otheraccounts#saveaccountinfo' match '/desktop_appstore/appstore'=>'desktop_appstore#appstore' match '/desktop_appstore/onlinestore'=>'desktop_appstore#onlinestore'