Changes

Jump to: navigation, search

Learning Collaborative Development Lab Fall 2008 Results

3,141 bytes added, 21:05, 9 September 2008
Added my ubiquity command
</pre>
--[[User:JesseV|JesseV]] 23:19, 9 September 2008 (UTC)
 
----
[http://matrix.senecac.on.ca/~cbishop2/ubiquity.html Google Map Directions] by [http://zenit.senecac.on.ca/wiki/index.php/User:Cbishop2 Chris Bishop]
<pre>
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
}
)
 
 
</pre>
I'll probably continue to work on it. Add some dynamic CSS to the preview div. <br />
--[[User:Cbishop2|Cbishop2]] 01:05, 10 September 2008 (UTC)
1
edit

Navigation menu