From ac1e75cb25b7150327a28e5b219738260447d8ae Mon Sep 17 00:00:00 2001 From: Avi Ginsberg Date: Wed, 4 Feb 2015 18:53:30 -0500 Subject: [PATCH] Cleaned up code & Added real error parsing/displaying --- Fox.ci_Chrome_Extension/manifest.json | 4 +- .../src/browser_action/popup.js | 37 ++++++------------- 2 files changed, 14 insertions(+), 27 deletions(-) diff --git a/Fox.ci_Chrome_Extension/manifest.json b/Fox.ci_Chrome_Extension/manifest.json index 99256ad..f540e17 100755 --- a/Fox.ci_Chrome_Extension/manifest.json +++ b/Fox.ci_Chrome_Extension/manifest.json @@ -1,6 +1,6 @@ { "name": "Fox.ci", - "version": "0.0.1", + "version": "0.0.2", "manifest_version": 2, "description": "Fox.ci URL Shortener", "homepage_url": "http://fox.ci", @@ -13,7 +13,7 @@ "browser_action": { "default_icon": "icons/icon19.png", - "default_title": "browser action demo", + "default_title": "Fox.ci URL Shortener", "default_popup": "src/browser_action/browser_action.html" }, "permissions": [ diff --git a/Fox.ci_Chrome_Extension/src/browser_action/popup.js b/Fox.ci_Chrome_Extension/src/browser_action/popup.js index 42d0f69..a59d1e0 100644 --- a/Fox.ci_Chrome_Extension/src/browser_action/popup.js +++ b/Fox.ci_Chrome_Extension/src/browser_action/popup.js @@ -3,7 +3,7 @@ var currentURL; window.onload = function () { - // alert('The browser action was clicked! Yay!'); + chrome.tabs.query({active: true, currentWindow: true}, function(arrayOfTabs) { @@ -11,14 +11,10 @@ chrome.tabs.query({active: true, currentWindow: true}, function(arrayOfTabs) { // since only one tab should be active and in the current window at once // the return variable should only have one entry var activeTab = arrayOfTabs[0]; - var activeTabId = arrayOfTabs[0].id; // or do whatever you need + var activeTabId = arrayOfTabs[0].id; var activeTabURL = arrayOfTabs[0].url; -//document.write(activeTabURL); + currentURL = activeTabURL; -//$("#content").append("activeTabURL: "+activeTabURL+"
"); - -//$("#content").append("currentURL: "+currentURL+"
"); - $.get( "http://fox.ci/api/?url="+currentURL ) @@ -28,36 +24,27 @@ currentURL = activeTabURL; var obj = jQuery.parseJSON(data); if((obj.statuscode==="100")||(obj.statuscode==="101")){ - //document.write("Success! Our short URL is: "+obj.shorturl); - //$("#content").append("Short URL:
"); - - - -var copyFrom = $('