Learning Collaborative Development Lab Fall 2008 Results

From CDOT Wiki
Revision as of 22:18, 11 September 2008 by Jamesboston (talk | contribs) (Added headings to create content box)
Jump to: navigation, search

Place any and all common results, code, notes here.

Zenit Wiki Search

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);
 }
})

Zenit Google Search

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);
 }
})

Open irc

--Patrick Lam

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/" );
 }
})

Goto blogspot user

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" );
 }
})

Goto Planet or Schedule

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/" );
   }
 }
})

Print current wiki page

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 );
 }
})

Search XKCD

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 wordpress blog

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)

Edit a wiki user page


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)

Search for wiki user


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)

Search wowhead

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)


Search Pirate Bay

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 );
  }
})

Display IP address

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);
  },
});

Search Altavista


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

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)


Search MedicineNet

Searches MedicineNet with a given keyword by AaronMT

Usage: health keyword phrase

CmdUtils.CreateCommand(
{
	name: "health",
	homepage: "http://medicinenet.com",
	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);
	}
});



Search cnet.com


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);
 }
})

Get NASDAQ quote

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

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);
  }
})

Paste to pastebin

pastebin
by James Boston

Send highlighted text to pastebin
Usage: pastebin (code)

CmdUtils.CreateCommand({
  name: "pastebin",
  takes: {"your code": noun_arb_text},
  preview: function( pblock, theCode ) {
    pblock.innerHTML = "Will paste: " + theCode.text;
  },
  execute: function( theCode ) {
    var baseUrl = "http://pastebin.mozilla.org";
    // var params = Utils.paramsToString({code2: theCode.text, parent_pid: ""});
    var params = {
      format: "text",
      poster: "ubiquity",
      expiry: "m",
      code2: theCode.text,
      paste: "Send"
    };    
    jQuery.post( baseUrl, params, function(html) {       
      var re = /dl=(.+?)"/;    
      var pid = re.exec(html); 
      if (pid) { 
        displayMessage(pid[1]);
        Utils.openUrlInBrowser("http://pastebin.mozilla.org/"+pid[1]);
      }
      else { 
        displayMessage("Failure!");
      }
    });
  }
})



Get timezone

["Now in" timezone]
by Irina Sh.

Tells you what time is it now in (city). Suggests some of them when you type the first letter(s)
Usage: Now-in (city)

v.0.1, must be fixed for using winter-summer time...

noun_type_city = new CmdUtils.NounType( "City", ["Abidjan","Abu Dhabi","Adana","AddisAbaba","Adelaide*","Aden","Aklavik","Aleutian","Alexandria","Algiers","Amsterdam","Anadyr","Anchorage","Ankara","Antananarivo","Antwerp","Asuncion *","Athens","Atlanta","Auckland *","Aveiro","Baghdad","Bamako","Bandar Seri Begawan","Bangkok","Bangui","Banjul","Barcelona","Barranquilla","Beijing","Beirut","Belgrade","Belize City","Berlin","Blantyre","Bogota","Bologna","Bombay - Mumbai","Brasilia","Bratislava","Brazzaville","Bridgetown","Brisbane","Brussels","Bucharest","Budapest","Buenos Aires","Bujumbura","Cairo","Calcutta","Calgary","Cali","Cape Town","Caracas","Cebu","Chicago","Christchurch","Colombo","Conakry","Copenhagen","Cotonou","Dakar","Dallas","Darwin","Delhi","Detroit","Dhaka","Djibouti","Dover","Dubai","Dublin","Dusseldorf","Edmonton","Fairbanks","Florence","Fort de France","Frankfurt","Freetown","Gaborone","Geneva","Gibraltar","Scotland","GMT","Guatemala City","Guayaquil","Hamilton","Harare","Havana","Helsinki","Hobart","Hong Kong","Honolulu","Indianapolis","Ipswich","Islamabad","Istanbul","Jakarta","Jerusalem","Johannesburg","Kabul","Kaduna","Kahira","Kamchatka","Kano","Karachi","Kathmandu","Kiev","Kigali","Kingston","Kinshasa","Kobe","Kosice","Kuala Lumpur","Kuwait City","Kyoto","La Paz","Lagos","Libreville","Lima","Limon","Lisbon","Lome","London","Los Angeles","Lubumbashi","Luxembourg","Madrid","Manama","Manila","Maracaibo","Maseru","Mayaguez","Mbabane","Medan","Medellin","Melbourne *","Mexico City","Milan","Mogadishu","Mombasa","Monrovia","Monte Carlo","Montevideo","Montreal","Morgantown","Moscow","Mumbai - Bombay","Munich","Murmansk","Muscat","N'Djamena","Nagasaki","Nagoya","Nairobi","Naples","Nassau","New Hebrides","New York City","Newfoundland","Niamey","Nice","Nicosia","Nome","Nottingham","Nouakchott","Nuk","Odessa","Oran","Osaka","Oslo","Ottawa","Ouagadougou","Oulu","Oxford","Palma","Panjim","Paramaribo","Paris","Peking","Perth","Phoenix","Ponce","Port Louis","Port Moresby","Port of Spain","Prague","Praia","Puntarenas","Quebec","Quito","Rangoon","Reykjavik","Riga","Rio de Janeiro","Riyadh","Rome","Saigon","Saint Petersburg - Leningrad","Salt Lake City","Salzburg","San Francisco","San Jose","San Juan","Santa Cruz de Tenerife","Santiago *","Santo Domingo","Sao Paulo","Sapporo","Sarajevo","Seattle","Seoul","Shanghai","Singapore","Sofia","Stockholm","Stuttgart","Surabaya","Suva","Sydney *","Taipei","Tallinn","Tampere","Tashkent","Tegucigalpa","Tehran","Tel Aviv","Tokyo","Toronto","Tripoli","Tunis","Turin","Ulanbatar","Valletta","Vancouver","Vatican","Venice","Victoria Falls","Vienna","Vientiane","Vladimir","Vladivostok","Warsaw","Washington DC","Wellington","Winnipeg","Yalta","Zagreb","Zaragoza","Zurich"] );

var timezone = new Array(); timezone["abidjan"] = +0; timezone["abu dhabi"] = +4; timezone["adana"] = +2; timezone["addis ababa"] = +3; timezone["adelaide *"] = +10; timezone["aden"] = +3; timezone["aklavik"] = -9; timezone["aleutian"] = -10; timezone["alexandria"] = +2; timezone["algiers"] = +0; timezone["amsterdam"] = +1; timezone["anadyr"] = +13; timezone["anchorage"] = -9; timezone["ankara"] = +2; timezone["antananarivo"] = +3; timezone["antwerp"] = +0; timezone["asuncion *"] = -3; timezone["athens"] = +2; timezone["atlanta"] = +5; timezone["auckland *"] = +12; timezone["aveiro"] = +0; timezone["baghdad"] = +3; timezone["bamako"] = +0; timezone["bandar seri begawan"] = +8; timezone["bangkok"] = +7; timezone["bangui"] = +1; timezone["banjul"] = +1; timezone["barcelona"] = +1; timezone["barranquilla"] = -5; timezone["beijing"] = +8; timezone["beirut"] = +2; timezone["belgrade"] = +1; timezone["belize city"] = -5; timezone["berlin"] = +1; timezone["blantyre"] = +2; timezone["bogota"] = -5; timezone["bologna"] = +2; timezone["bombay - mumbai"] = +6; timezone["brasilia"] = -3; timezone["bratislava"] = +1; timezone["brazzaville"] = +0; timezone["bridgetown"] = -4; timezone["brisbane"] = +10; timezone["brussels"] = +1; timezone["bucharest"] = +2; timezone["budapest"] = +1; timezone["buenos aires"] = -3; timezone["bujumbura"] = +2; timezone["cairo"] = +2; timezone["calcutta"] = +6; timezone["calgary"] = -6; timezone["cali"] = +0; timezone["cape town"] = +1; timezone["caracas"] = -4; timezone["cebu"] = +8; timezone["chicago"] = -6; timezone["christchurch"] = +12; timezone["colombo"] = +5; timezone["conakry"] = +0; timezone["copenhagen"] = +1; timezone["cotonou"] = +0; timezone["dakar"] = +0; timezone["dallas"] = -6; timezone["darwin"] = +10; timezone["delhi"] = +5; timezone["detroit"] = -5; timezone["dhaka"] = +6; timezone["djibouti"] = +2; timezone["dover"] = -5; timezone["dubai"] = +3; timezone["dublin"] = +0; timezone["dusseldorf"] = +1; timezone["edmonton"] = -7; timezone["fairbanks"] = -9; timezone["florence"] = +2; timezone["fort de france"] = -4; timezone["frankfurt"] = +1; timezone["freetown"] = +0; timezone["gaborone"] = +1; timezone["geneva"] = +1; timezone["gibraltar"] = +1; timezone["scotland"] = +0; timezone["gmt"] = +0; timezone["guatemala city"] = -6; timezone["guayaquil"] = -5; timezone["hamilton"] = -4; timezone["harare"] = +2; timezone["havana"] = -5; timezone["helsinki"] = +2; timezone["hobart"] = +10; timezone["hong kong"] = +8; timezone["honolulu"] = -10; timezone["indianapolis"] = -5; timezone["ipswich"] = +10; timezone["islamabad"] = +5; timezone["istanbul"] = +2; timezone["jakarta"] = +7; timezone["jerusalem"] = +2; timezone["johannesburg"] = +2; timezone["kabul"] = +5; timezone["kaduna"] = +0; timezone["kahira"] = +2; timezone["kamchatka"] = +11; timezone["kano"] = +1; timezone["karachi"] = +5; timezone["kathmandu"] = +6; timezone["kiev"] = +3; timezone["kigali"] = +1; timezone["kingston"] = -5; timezone["kinshasa"] = +1; timezone["kobe"] = +9; timezone["kosice"] = +1; timezone["kuala lumpur"] = +8; timezone["kuwait city"] = +3; timezone["kyoto"] = +9; timezone["la paz"] = -5; timezone["lagos"] = +1; timezone["libreville"] = +0; timezone["lima"] = -5; timezone["limon"] = -5; timezone["lisbon"] = +0; timezone["lome"] = +0; timezone["london"] = +0; timezone["los angeles"] = -8; timezone["lubumbashi"] = +1; timezone["luxembourg"] = +1; timezone["madrid"] = +1; timezone["manama"] = +3; timezone["manila"] = +8; timezone["maracaibo"] = -5; timezone["maseru"] = +2; timezone["mayaguez"] = -4; timezone["mbabane"] = +2; timezone["medan"] = +8; timezone["medellin"] = -5; timezone["melbourne *"] = +10; timezone["mexico city"] = -6; timezone["milan"] = +1; timezone["mogadishu"] = +3; timezone["mombasa"] = +3; timezone["monrovia"] = +0; timezone["monte carlo"] = +1; timezone["montevideo"] = -3; timezone["montreal"] = -5; timezone["morgantown"] = -5; timezone["moscow"] = +3; timezone["mumbai - bombay"] = +5; timezone["munich"] = +1; timezone["murmansk"] = +2; timezone["muscat"] = +3; timezone["n'djamena"] = +0; timezone["nagasaki"] = +9; timezone["nagoya"] = +9; timezone["nairobi"] = +3; timezone["naples"] = +1; timezone["nassau"] = -5; timezone["new hebrides"] = +11; timezone["new york city"] = -5; timezone["newfoundland"] = -3; timezone["niamey"] = +0; timezone["nice"] = +1; timezone["nicosia"] = +2; timezone["nome"] = -9; timezone["nottingham"] = +0; timezone["nouakchott"] = +0; timezone["nuk"] = -3; timezone["odessa"] = +3; timezone["oran"] = +0; timezone["osaka"] = +9; timezone["oslo"] = +1; timezone["ottawa"] = -5; timezone["ouagadougou"] = +0; timezone["oulu"] = +2; timezone["oxford"] = +0; timezone["palma"] = +1; timezone["panjim"] = +5; timezone["paramaribo"] = -4; timezone["paris"] = +1; timezone["peking"] = +8; timezone["perth"] = +8; timezone["phoenix"] = -7; timezone["ponce"] = -4; timezone["port louis"] = +4; timezone["port moresby"] = +10; timezone["port of spain"] = -4; timezone["prague"] = +1; timezone["praia"] = -2; timezone["puntarenas"] = -5; timezone["quebec"] = -5; timezone["quito"] = -5; timezone["rangoon"] = +7; timezone["reykjavik"] = -1; timezone["riga"] = +4; timezone["rio de janeiro"] = -3; timezone["riyadh"] = +3; timezone["rome"] = +1; timezone["saigon"] = +7; timezone["saint petersburg - leningrad"] = +3; timezone["salt lake city"] = -7; timezone["salzburg"] = +1; timezone["san francisco"] = -8; timezone["san jose"] = -6; timezone["san juan"] = -4; timezone["santa cruz de tenerife"] = +0; timezone["santiago *"] = -3; timezone["santo domingo"] = -4; timezone["sao paulo"] = -3; timezone["sapporo"] = +9; timezone["sarajevo"] = +1; timezone["seattle"] = -8; timezone["seoul"] = +9; timezone["shanghai"] = +8; timezone["singapore"] = +8; timezone["sofia"] = +2; timezone["stockholm"] = +1; timezone["stuttgart"] = +1; timezone["surabaya"] = +7; timezone["suva"] = +12; timezone["sydney *"] = +11; timezone["taipei"] = +8; timezone["tallinn"] = +2; timezone["tampere"] = +2; timezone["tashkent"] = +3; timezone["tegucigalpa"] = -5; timezone["tehran"] = +4; timezone["tel aviv"] = +2; timezone["tokyo"] = +9; timezone["toronto"] = -5; timezone["tripoli"] = +1; timezone["tunis"] = +1; timezone["turin"] = +1; timezone["ulanbatar"] = +8; timezone["valletta"] = +1; timezone["vancouver"] = -8; timezone["vatican"] = +1; timezone["venice"] = +1; timezone["victoria falls"] = +2; timezone["vienna"] = +1; timezone["vientiane"] = +7; timezone["vladimir"] = +3; timezone["vladivostok"] = +10; timezone["warsaw"] = +1; timezone["washington dc"] = -5; timezone["wellington"] = +12; timezone["winnipeg"] = -6; timezone["yalta"] = +3; timezone["zagreb"] = +1; timezone["zaragoza"] = +1; timezone["zurich"] = +1;


CmdUtils.CreateCommand({

  name: "now-in",
  takes: {"city": noun_type_city},
  execute: function nowIn(city) {
    var localDate = new Date();
    var localTime = localDate.getTime();
    var localOffset = localDate.getTimezoneOffset() * 60000;
    var utc = localTime + localOffset;
    var offset = timezone[city.text];  
    var tz = utc + (3600000*offset);
    var now = new Date(tz);
    displayMessage( "Now in " + city.text + " : " + now.toLocaleString() );
  }
}) 

Timer

Written by: Scott Lunel
For this lab I was interested to see whether or not it would be possible to run a delayed command under Ubiquity. I've recently
been dealing with threads and sleeping them in C++.

At first I attempted something along the lines of:


CmdUtils.CreateCommand({
  name: "Timer",
  author: "Scott Lunel",
  takes: {"Time": noun_arb_text},
  preview: "A simple timer that executes a message to the user after the entered time period.",
  execute: function(directObj) {
    var start = new Date().getTime();
    var cur = start;
    var secDuration = start + parseInt(directObj.text);

    while(parseInt(cur) < parseInt(secDuration)){
      cur = new Date().getTime();
    }

    displayMessage( "Time's Up!" );
    
  }
})


However this wasn't exactly what I was looking for because it caused the browser to freeze while the command was running.

I did a little more looking and found this method instead:

CmdUtils.CreateCommand({
  name: "Timer",
  author: "Scott Lunel",
  takes: {"Time": noun_arb_text},
  preview: "A simple timer that executes a message to the user after the entered time period.",
  execute: function(directObj) {

    Utils.setTimeout(function() { displayMessage("Time's Up!"); }, parseInt(directObj.text)); 
    
  }
})


Unlike the previous command, it will not freeze the browser while the timed command is being performed.
---


Simple Google Image Search

Joshua Doodnauth
Simple Google Image Search, working on retrieving some images to for preview

CmdUtils.CreateCommand({
  name: "image-search",
  author: {name:"Joshua Doodnauth", email:"jsdoodnauth@gmail.com"},
  licence: "GPL",
  description: "Searches for images on Google",
  takes: {"image-search": noun_arb_text},
  preview: function(pblock, imSearch) {
     pblock.innerHTML = "Google Image Search: " + imSearch.text +" 
<img src='http://www.google.ca/intl/en_ALL/images/images_hp.gif' width='150' />"; }, execute: function(imSearch) { var URL = "http://images.google.ca/images?gbv=2&hl=en&safe=on&q={QUERY}&btnG=Search+Images"; var query = imSearch.text; var searchStr = URL.replace("{QUERY}",query); Utils.openUrlInBrowser(searchStr); } })