Skip to content

Commit

Permalink
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
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 56 deletions.
8 changes: 2 additions & 6 deletions _locales/en/messages.json
@@ -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"}
}
28 changes: 28 additions & 0 deletions api.js
@@ -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!"
}


}
1 change: 1 addition & 0 deletions background.html
@@ -1 +1,2 @@
<script src="api.js"></script>
<script src="content_script.js"></script>
89 changes: 39 additions & 50 deletions content_script.js
@@ -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});
1 change: 1 addition & 0 deletions manifest.json
Expand Up @@ -6,6 +6,7 @@
"description": "__MSG_extDesc__",
"version": "0.1",
"permissions": ["contextMenus",
"notifications",
"http://*/*",
"https://*/*"],
"background_page": "background.html",
Expand Down

0 comments on commit 55163fa

Please sign in to comment.