Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Added mock calls to external API + notifications
- Loading branch information
Andrew Bananos
committed
Aug 27, 2011
1 parent
7cc328f
commit 55163fa
Showing
5 changed files
with
71 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
{ | ||
"extName": {"message": "Online-Convert.com", "description": "Extension name"}, | ||
"extDesc": {"message": "Online-Convert extension", "description": "Extension description"}, | ||
"convert_image": {"message": "Convert image", "description": "image"}, | ||
"convert_doc": {"message": "Convert to document", "description": "doc"}, | ||
"convert_video": {"message": "Convert video", "description": "video"}, | ||
"convert_audio": {"message": "Convert audio", "description": "audio"}, | ||
"convert_ebook": {"message": "Convert page to ebook", "description": "ebook"} | ||
} | ||
"download_video": {"message": "Download video from this page", "description": "video"} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
This will contain methods for API calls to | ||
http://api.online-convert.com/queue-insert | ||
**/ | ||
|
||
|
||
ocapi = { | ||
|
||
|
||
// This will submit specified URL to queue & return queue hashcode | ||
"submitVideo" : function(url, callback) { | ||
console.log("We are here!"); | ||
|
||
var hashCode = "Myhashccode" | ||
// todo: receive hashcode from remote service & pass it to callback | ||
callback(hashCode); | ||
}, | ||
|
||
// This will check the status of specified conversion process in OC queue by hashCode | ||
"checkStatus" : function(hashCode, callback) { | ||
|
||
return "Blyaaa!" | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
<script src="api.js"></script> | ||
<script src="content_script.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,53 @@ | ||
var conversion_page='?external_url=' | ||
var links = { | ||
// image: 'http://image-conversion.online-convert.com/', | ||
// ebook: 'http://ebook-conversion.online-convert.com/', | ||
// doc: 'http://document-conversion.online-convert.com/', | ||
video: 'http://video-conversion.online-convert.com/' | ||
// audio: 'http://audio-conversion.online-convert.com/' | ||
} | ||
// | ||
// function convert_image(info, tab) { | ||
// var img_url = info.linkUrl || info.srcUrl; | ||
// var url = links.image+conversion_page+img_url; | ||
// window.open(url); | ||
// } | ||
|
||
// | ||
// function convert_ebook(info, tab) { | ||
// var url = links.ebook+conversion_page+info.pageUrl; | ||
// window.open(url); | ||
// } | ||
// | ||
// function convert_doc(info, tab) { | ||
// chrome.tabs.sendRequest(tab.id, {"msg": "findImages"}, function(r){ | ||
// images = ""; | ||
// for (img in r.images) | ||
// images += r.images[img].url; | ||
// alert(images); | ||
// }); | ||
// | ||
// var url = links.doc+conversion_page+(info.linkUrl || info.pageUrl); | ||
// } | ||
|
||
|
||
|
||
/** | ||
Submits current page URL into OC queue | ||
**/ | ||
function convert_video(info, tab) { | ||
var url = links.video+conversion_page+info.pageUrl; | ||
console.log("Info:" + info); | ||
console.log("Tab:" + tab) | ||
var pageUrl = info.pageUrl; | ||
|
||
// console.log(info); | ||
// console.log(tab) | ||
// window.open(url); | ||
|
||
// submit URL to OC queue | ||
ocapi.submitVideo(pageUrl, function(hashCode) { | ||
// alert("Hashcode:" + hashCode) | ||
|
||
// Create a simple text notification: | ||
var notification = webkitNotifications.createNotification( | ||
'logo.png', // icon url - can be relative | ||
'Hello!', // notification title | ||
'Lorem ipsum...' // notification body text | ||
); | ||
|
||
// // Or create an HTML notification: | ||
// var notification = webkitNotifications.createHTMLNotification( | ||
// 'notification.html' // html url - can be relative | ||
// ); | ||
|
||
// Then show the notification. | ||
notification.show(); | ||
}); | ||
|
||
|
||
|
||
|
||
|
||
|
||
} | ||
|
||
// var image_menu = chrome.contextMenus.create({"title": chrome.i18n.getMessage("convert_image"), | ||
// "contexts": ["image"], | ||
// "onclick": convert_image}); | ||
// | ||
// var ebook_menu = chrome.contextMenus.create({"title": chrome.i18n.getMessage("convert_ebook"), | ||
// "contexts": ["page"], | ||
// "onclick": convert_ebook}); | ||
// | ||
// var doc_menu = chrome.contextMenus.create({"title": chrome.i18n.getMessage("convert_doc"), | ||
// "contexts": ["page", "link"], | ||
// "onclick": convert_doc}); | ||
|
||
var video_menu = chrome.contextMenus.create({"title": chrome.i18n.getMessage("convert_video"), | ||
|
||
/* inject "Download" link into page/link context menus */ | ||
|
||
var video_menu = chrome.contextMenus.create({"title": chrome.i18n.getMessage("download_video"), | ||
"contexts": ["page", "link"], | ||
"onclick": convert_video | ||
// "documentUrlPatterns": ['*://*.youtube.com/watch*', | ||
// '*://vimeo.com/*', | ||
// '*://5min.com/*', | ||
// ] | ||
}); | ||
|
||
// | ||
// var audio_menu = chrome.contextMenus.create({"title": chrome.i18n.getMessage("convert_audio"), | ||
// "contexts": ["link"], | ||
// "onclick": convert_audio}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters