From b634a03dbbef665dc099aacbaed2262bc18b52cb Mon Sep 17 00:00:00 2001 From: Stefano Mazzocchi Date: Thu, 12 Jul 2012 01:52:15 +0000 Subject: [PATCH] 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 --- .../freebase/module/MOD-INF/controller.js | 1 - .../scripts/dialogs/freebase-loading-dialog.js | 7 ++++--- main/webapp/modules/core/MOD-INF/controller.js | 2 ++ .../webapp/modules/core}/scripts/util/sign.js | 17 +++++++---------- 4 files changed, 13 insertions(+), 14 deletions(-) rename {extensions/freebase/module => main/webapp/modules/core}/scripts/util/sign.js (90%) diff --git a/extensions/freebase/module/MOD-INF/controller.js b/extensions/freebase/module/MOD-INF/controller.js index d7049792c..206e395c9 100644 --- a/extensions/freebase/module/MOD-INF/controller.js +++ b/extensions/freebase/module/MOD-INF/controller.js @@ -91,7 +91,6 @@ function init() { [ "scripts/extension.js", - "scripts/util/sign.js", "scripts/util/freebase.js", "scripts/dialogs/freebase-loading-dialog.js", diff --git a/extensions/freebase/module/scripts/dialogs/freebase-loading-dialog.js b/extensions/freebase/module/scripts/dialogs/freebase-loading-dialog.js index 03c35c7e4..a18e7791c 100644 --- a/extensions/freebase/module/scripts/dialogs/freebase-loading-dialog.js +++ b/extensions/freebase/module/scripts/dialogs/freebase-loading-dialog.js @@ -47,7 +47,8 @@ FreebaseLoadingDialog.prototype._createDialog = function() { var loadButton = this._elmts.loadButton; 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") { authorization.html('Signed in as: ' + data.username + ' | Sign Out').show(); DOM.bind(authorization).signout.click(function() { @@ -73,8 +74,8 @@ FreebaseLoadingDialog.prototype._createDialog = function() { DOM.bind(authorization).signin.click(function() { Sign.signin(function() { check_authorization(cont); - },provider); - }); + },provider,check_authorization_url); + }); } },"json"); }; diff --git a/main/webapp/modules/core/MOD-INF/controller.js b/main/webapp/modules/core/MOD-INF/controller.js index a6b1d6c95..e69806e3f 100644 --- a/main/webapp/modules/core/MOD-INF/controller.js +++ b/main/webapp/modules/core/MOD-INF/controller.js @@ -322,6 +322,7 @@ function init() { "scripts/util/dom.js", "scripts/util/date-time.js", "scripts/util/encoding.js", + "scripts/util/sign.js", "scripts/index.js", "scripts/index/create-project-ui.js", @@ -399,6 +400,7 @@ function init() { "scripts/util/date-time.js", "scripts/util/custom-suggest.js", "scripts/util/encoding.js", + "scripts/util/sign.js", "scripts/widgets/histogram-widget.js", "scripts/widgets/slider-widget.js", diff --git a/extensions/freebase/module/scripts/util/sign.js b/main/webapp/modules/core/scripts/util/sign.js similarity index 90% rename from extensions/freebase/module/scripts/util/sign.js rename to main/webapp/modules/core/scripts/util/sign.js index d0b1fd2c4..795ea1d67 100644 --- a/extensions/freebase/module/scripts/util/sign.js +++ b/main/webapp/modules/core/scripts/util/sign.js @@ -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 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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; // 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()); if (is_chrome) { height += 50; @@ -84,7 +84,7 @@ if (typeof window.Sign == 'undefined') { var params_list = []; for (var key in params) { - if (params.hasOwnProperty(key)) { + if (params.hasOwnProperty(key)) { params_list.push(key + "=" + params[key]); } } @@ -95,13 +95,10 @@ if (typeof window.Sign == 'undefined') { signintize : function(cont) { $('.signedin').show(); $('.signedout').hide(); - if (window.user) { - $('.user').html('' + window.user.username + ''); - } 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); if (newwin !== null) { @@ -113,7 +110,7 @@ if (typeof window.Sign == 'undefined') { window.location.reload(); } else { $.ajax({ - url: "/command/freebase/check-authorization/" + provider, + url: check_authorization_url, dataType: "json", success: function(data) { window.user = data; @@ -132,7 +129,7 @@ if (typeof window.Sign == 'undefined') { signoutize : function(cont) { $('.signedin').hide(); - $('.signedout').show(); + $('.signedout').show(); if (typeof cont == 'function') cont(); },