Created
July 14, 2009 08:35
-
-
Save erikvold/146842 to your computer and use it in GitHub Desktop.
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
CmdUtils.CreateCommand({ | |
names: [ "mcafee siteadvisor", "siteadvisor" ], | |
arguments: [ {role: 'object', nountype: noun_arb_text, label: 'text'} ], | |
homepage:"http://erikvold.com/tools/ubiquity/mcafee/mcafee-siteadvisor", | |
icon:"http://www.siteadvisor.com/favicon.ico", | |
author:{name:"Erik Vergobbi Vold",email:"erikvvold@gmail.com"}, | |
description:"Search McAfee SiteAdvisor for site information on the provided domain.", | |
help:"Just provide a domain or url for a site information lookup on McAfee SiteAdvisor.", | |
version:"0.2", | |
execute:function( args ){ | |
var selectedURL=jQuery.trim( args.object.text ); | |
if(selectedURL==""){ | |
selectedURL=context.focusedWindow.document.location; | |
} | |
selectedURL = selectedURL + ""; | |
try{ | |
selectedURL = Utils.url(selectedURL).host; | |
} | |
catch(e){ | |
displayMessage( _( "Your url string is invalid, please correct it and try again." ) ); | |
return false; | |
} | |
var urlString = "http://www.siteadvisor.com/sites/" + selectedURL; | |
Utils.openUrlInBrowser( urlString ); | |
return; | |
}, | |
preview:function( pblock, args ){ | |
var selectedURL = jQuery.trim( args.object.text ); | |
if( selectedURL == "" ){ | |
selectedURL = context.focusedWindow.document.location; | |
} | |
selectedURL = selectedURL + ""; | |
try{ | |
selectedURL = Utils.url(selectedURL).host; | |
} | |
catch(e){ | |
displayMessage( _( "Your url string is invalid, please correct it and try again." ) ); | |
return false; | |
} | |
var previewTemplate = "Search McAfee SiteAdvisor for site information on ${query}"; | |
var previewData = { query: selectedURL }; | |
pblock.innerHTML = _( CmdUtils.renderTemplate( previewTemplate, previewData ) ); | |
return; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment