Learning Collaborative Development Lab Fall 2008 Results
Place any and all common results, code, notes here.
Zenit-Wiki Search by Ezadkiel Marbella:
CmdUtils.CreateCommand({ name: "zenit/wiki specific search:", takes: {"search zenit/wiki term": noun_arb_text}, preview: function( pblock, wikiquery ) { pblock.innerHTML = "Will Search For: " + wikiquery.text; }, execute: function( wikiquery ) { var url = "http://zenit.senecac.on.ca/wiki/index.php/Special:Search?search={QUERY}&go=Go" var query = wikiquery.text; var urlString = url.replace("{QUERY}", query); Utils.openUrlInBrowser(urlString); } })
This is my submission. I am assuming we are encouraged to reuse code wherever possible. When using the search it is recommended that you separate the terms by + signs as that is what the goggle interface inserts between search terms. I found that it works when spaces are used as well though.
--John64 16:24, 9 September 2008 (UTC)
/*This function is based off Ezadkiel Marbella's code http://zenit.senecac.on.ca/wiki/index.php/Learning_Collaborative_Development_Lab_Fall_2008_Results */ CmdUtils.CreateCommand({ name: "zenit-google-search:", takes: {"search terms seperated by a '+' sign": noun_arb_text}, preview: function( pblock, googlequery ) { pblock.innerHTML = "Will Search For: " + googlequery.text; }, execute: function( googlequery ) { var urlPrefix = "http://www.google.ca/search?hl=en&q=site%3Azenit.senecac.on.ca%2Fwiki+" var urlSuffix = "&btnG=Search&meta=" var query = googlequery.text; var urlString = urlPrefix + query + urlSuffix; Utils.openUrlInBrowser(urlString); } })
This command opens up the ChatZilla extension and connect to moznet
CmdUtils.CreateCommand({ name: "irc", author: {name: "Patrick Lam"}, icon: "https://addons.mozilla.org/en-US/firefox/images/addon_icon/16", preview: "Starts ChatZilla 0.9.83 and connects to irc://moznet/", execute: function() { Utils.openUrlInBrowser( "irc://moznet/" ); } })
This command goes to any users blog at Blogspot
CmdUtils.CreateCommand({ name: "blog", author: {name: "Patrick Lam"}, takes: {"user": noun_arb_text}, icon: "http://pplam3.blogspot.com/favicon.ico", preview: "Goes to Blogspot by default or to the specified user's blog", execute: function( directObj ) { var preText = "www"; if (directObj.text != "") { preText = directObj.text; } Utils.openUrlInBrowser( "http://" + preText + ".blogspot.com" ); } })
This command goes to either Weekly Schedule or the Planet blog
CmdUtils.CreateCommand({ name: "osd", author: {name: "Patrick Lam"}, takes: {"blog": noun_arb_text}, preview: "Goes to OSD600 Weekly Schedule. By typing 'blog' after, it goes to the Planet's Blog", execute: function( directObj ) { if( directObj.text == "") { Utils.openUrlInBrowser( "http://zenit.senecac.on.ca/wiki/index.php/DPS909_and_OSD600_Fall_2008_Weekly_Schedule" ); } else { Utils.openUrlInBrowser( "http://zenit.senecac.on.ca/~chris.tyler/planet/" ); } } })
This goes to the printable version of the current wiki page
CmdUtils.CreateCommand({ name: "print", author: {name: "Patrick Lam"}, preview: "Takes the current wiki page and make it printable", execute: function() { var currentPath = CmdUtils.getDocumentInsecure().location.href; var wikiHome = currentPath.substring(0, currentPath.lastIndexOf("/")); /* Gets the title of the document in wiki */ var wikiTitle = currentPath.substring(currentPath.lastIndexOf("/") + 1); /* Makes the printable version url */ var printURL = wikiHome + "?title=" + wikiTitle + "&printable=yes"; Utils.openUrlInBrowser( printURL ); } })
Searches the XKCD archives for whatever term you enter. Not complex, but can be enjoyable.
CmdUtils.CreateCommand({ name: "xkcd", homepage: "http://belligero.org", author: {name: "Jason", email: "slokun@belligero.org"}, license: "MPL", description: "Search XKCD", takes: {"phrase": noun_arb_text}, _getSearchUrl: function(term) { return "http://www.ohnorobot.com/?comic=56&s="+term; }, /* Preview */ preview: function(pblock, theSearch) { var msg = "<img src='http://imgs.xkcd.com/static/xkcdLogo.png'>"+ "
Search the XKCD archives for "+theSearch.text+""; pblock.innerHTML = msg; }, execute: function(theSearch) { var msg = "Search completed for "+theSearch.text+"..."; Utils.openUrlInBrowser(this._getSearchUrl(theSearch.text)); displayMessage(msg); } })
--Jtarka 17:05, 9 September 2008 (UTC)
Goto a specified users blog on wordpress, modification of Patrick Lam's code
CmdUtils.CreateCommand({ name: "wpblog", takes: {"user": noun_arb_text}, preview: "Goes to the specified user's blog on wordpress", execute: function(directObj) { var subdomain = "www"; if (directObj.text != "") { subdomain = directObj.text; } Utils.openUrlInBrowser( "http://" + subdomain + ".wordpress.com" ); } })
--nadavers 17:16, 9 September 2008 (UTC)
Simple command, goes to edit a user's page.
CmdUtils.CreateCommand( { name: "EditUserPage", author: {name: "Tony Lai"}, takes: {"user": noun_arb_text}, preview: function (pblock, user) { pblock.innerHTML = "Edits " + user + "'s profile page if the user's page exists"; }, execute: function (user) { var url = "http://zenit.senecac.on.ca/wiki/index.php?title=User:" + user.text + "&action=edit"; Utils.openUrlInBrowser(url); } })
--twlai1 17:24, 9 September 2008 (UTC)
By Sid Kalra
Modified version of zenit/wiki search. This searches the zenit/wiki users
CmdUtils.CreateCommand({ name: "zenit/wiki user search:", takes: {"search zenit/wiki user": noun_arb_text}, preview: function( pblock, wikiquery ) { pblock.innerHTML = "Searching For: " + wikiquery.text; }, execute: function( wikiquery ) { var url = "http://zenit.senecac.on.ca/wiki/index.php/Special:Search?ns2=1&search={QUERY}&searchx=Search"; var query = wikiquery.text; var urlString = url.replace("{QUERY}", query); Utils.openUrlInBrowser(urlString); } })
-- Crulshorukh 17:46, 9 September 2008 (UTC)
CmdUtils.CreateCommand({ name: "wowhead search:", homepage: "http://sidkalra.com/", author: { name: "Sid Kalra" }, description: "Searches wowhead and sorts the results", takes: {"search": noun_arb_text}, modifiers: { sort: noun_arb_text }, preview: function(pblock, search1, modifier){ var message = 'Searching for ${search} sorting by ${sort}'; }, execute: function(search, mods) { var url = "http://www.wowhead.com/?search={QUERY}"; var query = search.text; var urlString = url.replace("{QUERY}", query); urlString += "#" + mods.sort.text; Utils.openUrlInBrowser(urlString); } })
-- Crulshorukh 00:48, 10 September 2008 (UTC)
Pirate Bay Search N Sort
by ashughes
Perform a search on The Pirate Bay and sort the results.
Usage: pirate [search] sort [how to sort]
CmdUtils.CreateCommand({ name: "pirate", homepage: "http://ashughes.com/", author: { name: "Anthony Hughes", email: "anthony.s.hughes@gmail.com"}, description: "Searches The Pirate Bay and sorts the results", takes: {"search": noun_arb_text}, modifiers: { sort: noun_arb_text }, preview: function(pblock, search, mods) { var msg = 'Searches for "${search}" sorted by ${sort}.'; var subs = {search: search.text, sort: mods.sort.text}; pblock.innerHTML = CmdUtils.renderTemplate(msg, subs); pblock.innerHTML = "<h4><u>HELP</u></h4>" + "<p><b>USAGE:</b>" + "<blockquote>pirate <i>[search term]</i> sort <i>[column to sort by]</i></blockquote></p>" + "<p><b>SORT:</b><ul>" + "<li>leechers - sort by leechers</li>" + "<li>seeders - sort by seeders</li>" + "<li>size - sort by size</li>" + "<li>upload - sort by upload date/time</li>" + "</ul>"; }, execute: function(theSearch, mods) { var msg = theSearch.text + "..Search Complete"; var url = "http://thepiratebay.org/search/" + theSearch.text; if (mods.sort.text == "seeders") { url += "/0/7/0"; } else if (mods.sort.text == "leechers") { url += "/0/9/0"; } else if (mods.sort.text == "upload") { url += "/0/3/0"; } else if (mods.sort.text == "size") { url += "/0/5/0"; } Utils.openUrlInBrowser( url ); } })
Displays users IP address immediately
by AaronMT
Usage: ip
Utilizes the whatismyip website to parse the IP and display it right in the console
CmdUtils.CreateCommand({ name: "ip", homepage: "http://aaronmt.wordpress.com", author: { name: "Aaron Train", email: "aaron.train@gmail.com"}, description: "Displays your internal IP address.", help: "Just type IP", icon: "http://whatismyip.com/favicon.ico", preview: function(pblock) { var url = "http://whatismyip.com/automation/n09230945.asp"; jQuery.get( url, function(data) { pblock.innerHTML = data; }); }, execute: function() { var url = "http://whatismyip.com"; Utils.openUrlInBrowser(url); }, });
Searches Altavista for specified term, modification of Ezadkiel Marbella's code
CmdUtils.CreateCommand({ name: "altavista:", takes: {"search terms": noun_arb_text}, preview: function( pblock, searchquery ) { pblock.innerHTML = "<img src='http://us.i1.yimg.com/us.yimg.com/i/us/av/logo_srp.gif' /> Will Search For: " + searchquery.text; }, execute: function( altavistaquery ) { var url = "http://www.altavista.com/web/results?itag=ody&q={QUERY}&kgs=1&kls=0" var query = altavistaquery.text; query = query.replace("+", " "); var urlString = url.replace("{QUERY}", query); Utils.openUrlInBrowser(urlString); } })
--JesseV 23:19, 9 September 2008 (UTC)
Google Map Directions by Chris Bishop
CmdUtils.CreateCommand( { author: { name: "Chris Bishop", email: "dee132@gmail.com" }, description: "Will direct to a page displaying the directions to the addresses supplied by the user.", help: "There needs to be atleast one address and each address must end with a semi-colon.", name: "Map-Directions", takes: {from: noun_arb_text}, // load map page execute: function ( directObj ) { // get the second element which is an object with source // and destination addresses var params = this._getAddresses( directObj.text )[1]; // make sure that there is a source address if ( params != null ) { var url = "http://maps.google.com/?"; // change the object attributes into url parameters url += jQuery.param( params ); // open in a new window Utils.openUrlInBrowser( url ); } else { // error message for no address supplied displayMessage( "An address has not been inputed. Example is: New York; " ); } }, // execute // gets the addresses from the supplied text _getAddresses: function( text ) { // check if there are no valid addresses if ( text.indexOf( ";" ) == - 1 ) { return []; } // split the addresses based on a semi colon var addrs = text.split(";"); var directions = null; var params = {}; // set the first address to be the from address directions = "from: " + addrs[ 0 ]; params.saddr = addrs[ 0 ]; // loop through the rest of the addresses and add them // to the directions or parameters for ( var idx = 1; idx < addrs.length - 1; idx++ ) { directions += " to: " + addrs[ idx ]; if ( idx == 1 ) { params.daddr = addrs[ idx ]; } else { params.daddr += "+to:" + addrs[ idx ]; } } // return both the directions and parameters return [directions,params]; }, // _getAddresses // load a preview map preview: function ( pblock, directObj ) { var text = directObj.text; var directions = this._getAddresses( text )[0]; // check if a null address was returned if ( directions != null ) { pblock.innerHTML = directions; } else { pblock.innerHTML = "Enter an address followed by a semi-colon for each address to "; pblock.innerHTML += "find directions to.<br />"; pblock.innerHTML += "Example. New York; Chicago; Miami;"; pblock.innerHTML += "<br /><br />Each Address must end with a semi-colon."; } } // preview } )
I'll probably continue to work on it. Add some dynamic CSS to the preview div.
--Cbishop2 01:05, 10 September 2008 (UTC)
Searches MedicineNet with given keyword
by AaronMT
Usage: health keyword phrase
CmdUtils.CreateCommand( { name: "health", homepage: "http://medicinenet.net", author: { name: "Aaron Train", email: "aaron.train@gmail.com" }, description: "Takes keyword phrase and searches MedicineNet", help: "health <i>keyword phrase</i>", icon: "http://images.medicinenet.com/images/fav/MN.ico", takes: {"Enter a noun": noun_arb_text}, preview: function(pblock, keywordPhrase) { pblock.innerHTML = "Search the MedicineNet by entering any phrase <b>" + keywordPhrase.text + "</b>" }, execute: function(keywordPhrase) { var searchURL = "http://www.medicinenet.com/" + keywordPhrase.text; Utils.openUrlInBrowser(searchURL); } });
So I reused Ezadkiel Marbella's code and made code for searching cnet.com. this thing is so much fun I am thinking about making something else too.
- Zaid Ghansar 11th September 2008
CmdUtils.CreateCommand({ name: "cnet", author: { name: "Zaid Ghansar" }, description: "Searches cnet.com.", help: "searches for a highlighted term or typed term at cnet.com", takes: {"search terms": noun_arb_text}, preview: function( pblock, searchquery ) { pblock.innerHTML = "<img src='http://i.afterdawn.com/v3/news/cnet_logo.gif' /> Will Search For: " + searchquery.text; }, execute: function( cnetquery ) { var url = "http://www.cnet.com/1770-5_1-0.html?query={QUERY}&tag=srch" var query = cnetquery.text; query = query.replace("+", " "); var urlString = url.replace("{QUERY}", query); Utils.openUrlInBrowser(urlString); } })
and another for getting NASDAQ stock quotes:
CmdUtils.CreateCommand({ name: "nasdaq", author: { name: "Zaid Ghansar" }, description: "Shows current NASDAQ stock value.", help: "searches for a stocks current vallue at NASDAQ using google", takes: {"search stock": noun_arb_text}, preview: function( pblock, searchquery ) { pblock.innerHTML = "<img src='http://www.buylow-sellhigh.com/images/NASDAQ_logo.gif' /> Will Search For: " + searchquery.text; }, execute: function( query ) { var url = "http://finance.google.com/finance?client=ob&q=NASDAQ:" + query.text; Utils.openUrlInBrowser(url); } })
seneca-library-search
by James Boston
Search the Seneca College Library
Usage: seneca-library-search (search term)
CmdUtils.CreateCommand({ name: "seneca-library-search", takes: {"your search term": noun_arb_text}, preview: function( pblock, theSearch ) { pblock.innerHTML = "Will look for: " + theSearch.text; }, execute: function( theSearch ) { var baseUrl = "http://libcat.senecac.on.ca/cgi-bin/Pwebrecon.cgi"; var params = Utils.paramsToString({ CNT: "50", DB: "local", SL: "Submit&LOCA=Books+(no+eResources)|5", Search_Arg: theSearch.text, Search_Code: "FT*" }); Utils.openUrlInBrowser(baseUrl+params); } })