moving the sign.js in the main refine block as this is potentially useful for all extensions that use the oauth mechanics

git-svn-id: http://google-refine.googlecode.com/svn/trunk@2511 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Stefano Mazzocchi 2012-07-12 01:52:15 +00:00
parent bccea8cebe
commit b634a03dbb
4 changed files with 13 additions and 14 deletions

View File

@ -91,7 +91,6 @@ function init() {
[ [
"scripts/extension.js", "scripts/extension.js",
"scripts/util/sign.js",
"scripts/util/freebase.js", "scripts/util/freebase.js",
"scripts/dialogs/freebase-loading-dialog.js", "scripts/dialogs/freebase-loading-dialog.js",

View File

@ -47,7 +47,8 @@ FreebaseLoadingDialog.prototype._createDialog = function() {
var loadButton = this._elmts.loadButton; var loadButton = this._elmts.loadButton;
var check_authorization = function(cont) { var check_authorization = function(cont) {
$.get("/command/freebase/check-authorization/" + provider, function(data) { var check_authorization_url = "/command/freebase/check-authorization/" + provider;
$.get(check_authorization_url, function(data) {
if ("status" in data && data.code == "/api/status/ok") { if ("status" in data && data.code == "/api/status/ok") {
authorization.html('Signed in as: <a target="_new" href="http://www.freebase.com/view/user/' + data.username + '">' + data.username + '</a> | <a href="javascript:{}" bind="signout">Sign Out</a>').show(); authorization.html('Signed in as: <a target="_new" href="http://www.freebase.com/view/user/' + data.username + '">' + data.username + '</a> | <a href="javascript:{}" bind="signout">Sign Out</a>').show();
DOM.bind(authorization).signout.click(function() { DOM.bind(authorization).signout.click(function() {
@ -73,8 +74,8 @@ FreebaseLoadingDialog.prototype._createDialog = function() {
DOM.bind(authorization).signin.click(function() { DOM.bind(authorization).signin.click(function() {
Sign.signin(function() { Sign.signin(function() {
check_authorization(cont); check_authorization(cont);
},provider); },provider,check_authorization_url);
}); });
} }
},"json"); },"json");
}; };

View File

@ -322,6 +322,7 @@ function init() {
"scripts/util/dom.js", "scripts/util/dom.js",
"scripts/util/date-time.js", "scripts/util/date-time.js",
"scripts/util/encoding.js", "scripts/util/encoding.js",
"scripts/util/sign.js",
"scripts/index.js", "scripts/index.js",
"scripts/index/create-project-ui.js", "scripts/index/create-project-ui.js",
@ -399,6 +400,7 @@ function init() {
"scripts/util/date-time.js", "scripts/util/date-time.js",
"scripts/util/custom-suggest.js", "scripts/util/custom-suggest.js",
"scripts/util/encoding.js", "scripts/util/encoding.js",
"scripts/util/sign.js",
"scripts/widgets/histogram-widget.js", "scripts/widgets/histogram-widget.js",
"scripts/widgets/slider-widget.js", "scripts/widgets/slider-widget.js",

View File

@ -23,8 +23,8 @@ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@ -62,7 +62,7 @@ if (typeof window.Sign == 'undefined') {
var top = Math.floor((pos.height - height) / 2) + pos.top; var top = Math.floor((pos.height - height) / 2) + pos.top;
// Chrome might fix this bug, but until then add some padding // Chrome might fix this bug, but until then add some padding
// to the height of the popup for the urlbar // to the height of the popup for the urlbar
var is_chrome = /chrome/.test(navigator.userAgent.toLowerCase()); var is_chrome = /chrome/.test(navigator.userAgent.toLowerCase());
if (is_chrome) { if (is_chrome) {
height += 50; height += 50;
@ -84,7 +84,7 @@ if (typeof window.Sign == 'undefined') {
var params_list = []; var params_list = [];
for (var key in params) { for (var key in params) {
if (params.hasOwnProperty(key)) { if (params.hasOwnProperty(key)) {
params_list.push(key + "=" + params[key]); params_list.push(key + "=" + params[key]);
} }
} }
@ -95,13 +95,10 @@ if (typeof window.Sign == 'undefined') {
signintize : function(cont) { signintize : function(cont) {
$('.signedin').show(); $('.signedin').show();
$('.signedout').hide(); $('.signedout').hide();
if (window.user) {
$('.user').html('<a href="http://freebase.com/view' + window.user.id + '">' + window.user.username + '</a>');
}
if (typeof cont == 'function') cont(); if (typeof cont == 'function') cont();
}, },
signin : function(success, provider, width, height) { signin : function(success, provider, check_authorization_url, width, height) {
var newwin = window.Sign.popup("/command/core/authorize/" + provider, width, height); var newwin = window.Sign.popup("/command/core/authorize/" + provider, width, height);
if (newwin !== null) { if (newwin !== null) {
@ -113,7 +110,7 @@ if (typeof window.Sign == 'undefined') {
window.location.reload(); window.location.reload();
} else { } else {
$.ajax({ $.ajax({
url: "/command/freebase/check-authorization/" + provider, url: check_authorization_url,
dataType: "json", dataType: "json",
success: function(data) { success: function(data) {
window.user = data; window.user = data;
@ -132,7 +129,7 @@ if (typeof window.Sign == 'undefined') {
signoutize : function(cont) { signoutize : function(cont) {
$('.signedin').hide(); $('.signedin').hide();
$('.signedout').show(); $('.signedout').show();
if (typeof cont == 'function') cont(); if (typeof cont == 'function') cont();
}, },