Permalink
Browse files

Fixing Twitter OAuth authentication.

  • Loading branch information...
cezarsa committed May 2, 2011
1 parent 55007e6 commit cfe9e4e36fccd78fdc6adfd18278f019a1b93254
Showing with 17 additions and 15 deletions.
  1. +17 −15 lib/oauth_authorizer.js
View
@@ -1,33 +1,35 @@
function getAuthPin() {
chrome.extension.sendRequest({check_pin_needed: 1}, function(response) {
var fullText = $("div.message-content:not(.new_div)").text();
var fullText = $("#bd").text();
if(fullText.match(/chromed bird/i) && !fullText.match(/denied/i)) {
var pin = $.trim($("#oauth_pin").text());
$("div.message-content").hide();
var message = "<h2>" + chrome.i18n.getMessage("authorizing") + "</h2>" + chrome.i18n.getMessage("yourPIN", pin);
var newDiv = $("<div class='message-content new_div'>").
html(message).
insertAfter("div.message-content");
var pin = $.trim($("code").text());
var oauthMessageArea = $("#oauth_pin p");
oauthMessageArea.css({
'-webkit-user-select': 'text',
'user-select': 'text',
'cursor': 'inherit'
});
var message = '<h2>' + chrome.i18n.getMessage("authorizing") + "</h2><h2>" + chrome.i18n.getMessage("yourPIN", pin) + '</h2>';
oauthMessageArea.html(message);
var nextOpacity = 1;
function animateLoop() {
if(nextOpacity == 1) nextOpacity = 0.3;
else nextOpacity = 1;
$("div.message-content.new_div").animate({opacity: nextOpacity}, 500, null, animateLoop);
oauthMessageArea.animate({opacity: nextOpacity}, 500, null, animateLoop);
}
animateLoop();
chrome.extension.sendRequest({cr_oauth_pin: pin}, function(response) {
$("div.message-content.new_div").css('opacity', 1);
$("div.message-content.new_div").stop();
var message;
oauthMessageArea.css('opacity', 1).stop();
if(response) {
message = "<h2>" + chrome.i18n.getMessage("successAuth") + "</h2>" +
"<div id='oauth_pin' style='font-size: 2.5em;'>" + chrome.i18n.getMessage("cbAuthorized") + "</div>";
$("div.message-content.new_div").html(message);
message = chrome.i18n.getMessage("successAuth");
} else {
message = "<h2>" + chrome.i18n.getMessage("cbNotAuthorized") + "</h2>";
$("div.message-content.new_div").html(message);
message = chrome.i18n.getMessage("cbNotAuthorized") + " " + chrome.i18n.getMessage("yourPIN", pin);
}
oauthMessageArea.html('<h2>' + message + '</h2>');
});
}
});

0 comments on commit cfe9e4e

Please sign in to comment.