diff --git a/app/assets/javascripts/page.coffee b/app/assets/javascripts/page.coffee index ebfe681..afcb0f3 100644 --- a/app/assets/javascripts/page.coffee +++ b/app/assets/javascripts/page.coffee @@ -44,7 +44,7 @@ $ -> $('.dropdown-menu li a').live 'click', -> $(this).parent().parent().parent().toggleClass('open') false - $('.foreign-link').live 'click', -> + $('.foreign-link').live 'click', (e) -> # window.open($(this).attr('href')) e.preventDefault(); false \ No newline at end of file diff --git a/app/assets/javascripts/vkontakte.coffee b/app/assets/javascripts/vkontakte.coffee index 1d0d51d..ab28880 100644 --- a/app/assets/javascripts/vkontakte.coffee +++ b/app/assets/javascripts/vkontakte.coffee @@ -22,12 +22,9 @@ class window.Vkontakte if typeof response isnt 'undefined' and response.session _session = new Session(response.session) _session.query '/user/auth', {}, (ar) -> - if ar.ok_reload - window.location.reload() - false if ar.newbie VK.Api.call 'getVariable', key: 1281, (r) -> - _session.query '/user/update', name: r.response, (ar2) -> + _session.query '/user/update', params: { name: r.response }, (ar2) -> _session.setUser ar2.user $('#username') .html (if _session.getUser().name then _session.getUser().name else '%username%') @@ -35,6 +32,12 @@ class window.Vkontakte _ajax.detectPage() _session.displayAuthorizedContent() $('#authorized').css display: 'block' + if ar.ok_reload + window.location.reload() + false + else if ar.ok_reload + window.location.reload() + false else _session.setUser ar.user diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 547639a..1b77e8f 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -16,7 +16,8 @@ class UserController < ApplicationController if session.key != session_key session.key = session_key session.save - render :json => { 'ok_reload' => true } + @res[:ok_reload] = true + render :json => @res return end