mirror of
https://github.com/c0de-archive/Fox.ci_Chrome_Extension.git
synced 2024-12-22 13:42:39 +00:00
Cleaned up code & Added real error parsing/displaying
This commit is contained in:
parent
3e4b4b7e7d
commit
ac1e75cb25
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "Fox.ci",
|
"name": "Fox.ci",
|
||||||
"version": "0.0.1",
|
"version": "0.0.2",
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"description": "Fox.ci URL Shortener",
|
"description": "Fox.ci URL Shortener",
|
||||||
"homepage_url": "http://fox.ci",
|
"homepage_url": "http://fox.ci",
|
||||||
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
"browser_action": {
|
"browser_action": {
|
||||||
"default_icon": "icons/icon19.png",
|
"default_icon": "icons/icon19.png",
|
||||||
"default_title": "browser action demo",
|
"default_title": "Fox.ci URL Shortener",
|
||||||
"default_popup": "src/browser_action/browser_action.html"
|
"default_popup": "src/browser_action/browser_action.html"
|
||||||
},
|
},
|
||||||
"permissions": [
|
"permissions": [
|
||||||
|
@ -3,7 +3,7 @@ var currentURL;
|
|||||||
window.onload = function () {
|
window.onload = function () {
|
||||||
|
|
||||||
|
|
||||||
// alert('The browser action was clicked! Yay!');
|
|
||||||
|
|
||||||
|
|
||||||
chrome.tabs.query({active: true, currentWindow: true}, function(arrayOfTabs) {
|
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
|
// since only one tab should be active and in the current window at once
|
||||||
// the return variable should only have one entry
|
// the return variable should only have one entry
|
||||||
var activeTab = arrayOfTabs[0];
|
var activeTab = arrayOfTabs[0];
|
||||||
var activeTabId = arrayOfTabs[0].id; // or do whatever you need
|
var activeTabId = arrayOfTabs[0].id;
|
||||||
var activeTabURL = arrayOfTabs[0].url;
|
var activeTabURL = arrayOfTabs[0].url;
|
||||||
//document.write(activeTabURL);
|
|
||||||
currentURL = activeTabURL;
|
currentURL = activeTabURL;
|
||||||
//$("#content").append("activeTabURL: "+activeTabURL+"<br>");
|
|
||||||
|
|
||||||
//$("#content").append("currentURL: "+currentURL+"<br>");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$.get( "http://fox.ci/api/?url="+currentURL )
|
$.get( "http://fox.ci/api/?url="+currentURL )
|
||||||
@ -28,36 +24,27 @@ currentURL = activeTabURL;
|
|||||||
var obj = jQuery.parseJSON(data);
|
var obj = jQuery.parseJSON(data);
|
||||||
|
|
||||||
if((obj.statuscode==="100")||(obj.statuscode==="101")){
|
if((obj.statuscode==="100")||(obj.statuscode==="101")){
|
||||||
//document.write("Success! Our short URL is: "+obj.shorturl);
|
|
||||||
//$("#content").append("Short URL: <input type=\"text\" id=\"copyBox\" value=\""+obj.shorturl+"\"><br>");
|
|
||||||
|
|
||||||
|
|
||||||
|
var copyFrom = $('<textarea/>');
|
||||||
|
copyFrom.text(obj.shorturl);
|
||||||
|
$('body').append(copyFrom);
|
||||||
|
copyFrom.select();
|
||||||
|
document.execCommand('copy');
|
||||||
|
|
||||||
var copyFrom = $('<textarea/>');
|
$("#content").append("Fox.ci ShortURL copied to clipboard!<br>");
|
||||||
copyFrom.text(obj.shorturl);
|
|
||||||
$('body').append(copyFrom);
|
|
||||||
copyFrom.select();
|
|
||||||
document.execCommand('copy');
|
|
||||||
//copyFrom.remove();
|
|
||||||
|
|
||||||
$("#content").append("Fox.ci ShortURL copied to clipboard!<br>");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
document.write("nuuu something went wrong and it failed");
|
document.write("Error: "+obj.statusdescription);
|
||||||
}
|
}
|
||||||
//document.write("<br>"+obj.statuscode);
|
|
||||||
//document.write(obj.statusdescription);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//$("#content").append("Current URL: "+currentURL+"<br>");
|
|
||||||
//$("mainPopup").append('Test');
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user