-
-
Save dave1010/55510 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* | |
TODO: | |
match beginnings of function names | |
say if no functions found | |
if > 1 function result, have a list of them | |
option to show more details of function? | |
get it working with gotapi.com and all languages it supports | |
*/ | |
CmdUtils.CreateCommand({ | |
name: "search-php", | |
homepage: "http://createopen.com/blog/", | |
author: { name: "David Hulbert", email: "[email protected]"}, | |
icon: "http://static.php.net/www.php.net/favicon.ico", | |
license: "MPL", | |
takes: {"function": noun_arb_text}, | |
description: "Searches PHP for a function.", | |
help: "Searches PHP for a function and previews the description. Example: 'search-php strpos'", | |
preview: function(pblock, term) { | |
if (term.text) { | |
pblock.innerHTML = "Searching PHP.net..."; | |
var url = "http://php.net/{QUERY}"; | |
var query = term.text; | |
var urlString = url.replace("{QUERY}", query); | |
jQuery.get(urlString, {}, function(d){ | |
if( d.length > 0 ) { | |
var desc = jQuery(".description", d).html(); | |
var title = jQuery(".refpurpose", d).html(); | |
} | |
if (title.length || desc.length) { | |
pblock.innerHTML = title + desc; | |
} else { | |
pblock.innerHTML = 'No match found'; | |
} | |
}); | |
} else { | |
pblock.innerHTML = "Search PHP for a function" | |
} | |
}, | |
execute: function(functionname) { | |
var url = "http://php.net/{QUERY}" | |
var query = functionname.text; | |
var urlString = url.replace("{QUERY}", query); | |
Utils.openUrlInBrowser(urlString); | |
} | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment