Changes

Jump to: navigation, search

Learning Collaborative Development Lab Fall 2008 Results

5,749 bytes added, 16:22, 12 September 2008
no edit summary
--[[User:Cbishop2|Cbishop2]] 01:05, 10 September 2008 (UTC)
----
 
====Google Map Directions Ver 1.1====
<b></b>
by [[User:Park KiWon|kwpark1]]<br />
<b>Usage:</b>
<pre>
CmdUtils.CreateCommand(
{
author: { name: "Park, KiWon", email: "kwpark1@gmail.com" },
 
description: "Will direct to a page displaying the directions to the addresses supplied by the user.",
//Original Version Chris Bishop(dee132@gmail.com)
//
//2009-09-12 add two functions:
// - do not need tying ';' end of "To" position
// ex)
// Before) Map-Directions Seneca;New York;
// Modify) Map-Directions Seneca;New York
 
// - preview map display:
// function :_preViewMap()
//
 
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},
icon: "chrome://ubiquity/content/icons/map.png",
 
 
 
//*************************************************//
// it displays map on the Ubiquity window
// copy from builtin command 'map' function
//*************************************************//
_preViewMap:function(pblock,location)
{
CmdUtils.showPreviewFromFile( pblock,
"templates/map.html",
function(winInsecure) {
winInsecure.setPreview( location );
 
winInsecure.insertHtml = function(html) {
var doc = context.focusedWindow.document;
var focused = context.focusedElement;
 
// This would be nice to store the map in the buffer...
// But for now, it causes a problem with a large image showing up as the default
//CmdUtils.setLastResult( html );
 
if (doc.designMode == "on") {
doc.execCommand("insertHTML", false, location + "<br/>" + html);
}
else if (CmdUtils.getSelection()) {
CmdUtils.setSelection(html);
}
else {
displayMessage("Cannot insert in a non-editable space. Use 'edit page' for an editable page.");
}
};});
},
 
//*************************************************//
 
 
// 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 [];
}
 
//*************************************************//
//if a user dose not type ";" at the end
//*************************************************//
if( text.indexOf(";") != text.length )
{
text+=";";
}
//*************************************************//
 
// 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.";
}
 
//*************************************************//
// it displays only typing area's map
// ex) Map-Directions Seneca <-- display seneca
Map-Directions Seneca;New York <-- display New York
//*************************************************//
if ( text != null )
{
var disPlayLocation = null;
if(text.indexOf(";") < 0 ) //has value, it means desplay "TO" position
{
disPlayLocation = text;
}
else // display "from" position
{
disPlayLocation = text.substring(text.lastIndexOf(";"));
}
this._preViewMap(pblock,disPlayLocation);
}
 
//*************************************************//
} // preview
}
)
 
 
</pre>
<br />
------
 
====Search MedicineNet====
<b>Searches MedicineNet with a given keyword</b>
1
edit

Navigation menu