Open main menu

CDOT Wiki β

Changes

Learning Collaborative Development Lab Fall 2008 Results

13,053 bytes added, 15:36, 12 June 2009
show time in
=Ubiquity commands= ==Introduction== These are the results for the [[DPS909]]/[[OSD600]] [[Learning Collaborative Development Lab Fall 2008|lab 1]]. Place any and all common results, code, notes here.
====Zenit Wiki Search====
</pre>
I'll probably continue to work on it. Add some dynamic CSS to the preview div. <br />
 
I was successful at adding a preview. Check the link above for the updated version.
--[[User:Cbishop2|Cbishop2]] 01:05, 10 September 2008 (UTC)
----
 
====Chris Bishop's Google Map Directions Ver 1.1====
<b></b>
by [[User:kwpark1|Park KiWon]]<br />
Add two functions: do not need to type ';' end of 'To:' position, and preview the map.
<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's
//Google Map Directions (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
 
// - map preview:
// add new 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.
// thic code copies 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 -1 )
{
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 current 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>
----
 
====Go to a specific web page using Aliases or URL====
[[User:Hellwolf36]]
This add-on allows you to go to a specific web page using goto (url). You may also specify an alias that will take you to a different location without having to specify the complete URL (to add on your own, you must add on to the source array, and to the noun listing.
 
noun_type_link = new CmdUtils.NounType( "link",["blog","facebook","mail","google","battleforums",
"south-park","japtoeng","wwe","zy-el","zenit-wiki", "pso",
"d2m", "nezmod", "schtserv", "mySeneca","Senecamail",
"orderofthestick", "8bit", "news"]);
CmdUtils.CreateCommand({ name: "goto",
takes: {url: noun_type_link},
description: "Causes the browser to open a specific webpage via URL or Keywords",
//Original author: {name: "benny sheerin"}, url: "http://www.bennysheerin.com/cmd_news.js",
//This Version Author
author: {name: "Chris Cameirao"}, url: 'http://zenit.senecac.on.ca/wiki/',
preview: function(preview,vendor)
{
if(vendor.text != "") {
{
preview.innerHTML = "Opens "+vendor.text+" in a new window or tab.";
}
else
{
preview.innerHTML = "Opens the selected URL in a new window or tab.";
},
execute: function(vendor)
{ //Site listing
//Keywords
var sources = new Array();
sources['facebook'] = 'http://www.facebook.com/';
sources['mail'] = 'http://www.hotmail.com/';
sources['google'] = 'http://www.google.com/';
sources['battleforums'] = 'http://www.battleforums.com/';
sources['wwe'] = 'http://www.wwe.com/';
sources['zy-el'] = 'http://http://zyel.wikispaces.com/';
sources['zenit-wiki'] = 'http://zenit.senecac.on.ca/wiki/';
sources['homepage'] = 'http://zenit.senecac.on.ca/wiki/index.php/User:Hellwolf36';
sources['japtoeng'] = 'http://http://rut.org/cgi-bin/j-e/dict/';
sources['blog'] = 'http://hellwolf36.blogspot.com/';
sources['south-park'] = 'http://www.southparkzone.com/';
sources['pso'] = 'http://www.pso-world.com/';
sources['schtserv'] = 'http://schtserv.com/forum/';
sources['d2m'] = 'http://www.d2maniacs.org/';
sources['mininova'] = 'http://www.mininova.org/';
sources['nezmod'] = 'http://www.nez.exofire.net/forum/';
sources['mySeneca'] = 'http://my.senecacollege.ca/';
sources['Senecamail'] = 'http://learn.senecac.on.ca/';
sources['orderofthestick'] = 'http://www.giantitp.com/comics/oots.html';
sources['8bit'] = 'http://www.nuklearpower.com/archive.php';
sources['news'] = 'http://www.drudgereport.com';
Utils.openUrlInBrowser(sources[vendor.text]); }
})
//Revision History from original
//Replaced Yahoo with Hotmail
//Added some personal sites
//Rewrote preview messages
 
---
====Share a webpage on Facebook!====
[[User:tjbro]]
This command allows a user to share a web page on Facebook. Although I couldn't get the preview to act the way I orginally had in mind I'm going to continue working on it in hopes of avoiding the pop-up window.
<br />
<pre>
CmdUtils.CreateCommand(
{
name: "share-fb:",
preview: function( pblock, wikiquery ) {
pblock.innerHTML = "Share this page on Facebook!";
},
author: {name: "Thomas Brown"},
execute: function() {
window.open("http://www.new.facebook.com/sharer.php?u=" + context.focusedWindow.document.location,"Share on Facebook","menubar=no,width=600,height=360,toolbar=no");
}
})
</pre>
<br />
---
---
====Sherdog Fight Finder Search====
[[User:bbarcick]]
This command allows a user to search the Sherdog Fight Finder for a specific fighter. Currently only allows the first word to be the fighters first name and the second word to be the fighters last name.
<br />
<pre>
CmdUtils.CreateCommand({
name: "fight-finder",
author: {name:"Bartosz Barcicki", email:"bartb_69@hotmail.com"},
description: "Searches the Sherdog Fight Finder",
takes: {"search-string": noun_arb_text},
preview: function(pblock, search) {
pblock.innerHTML = "Sherdog Fight Finder Search: " + search.text;
},
execute: function(search) {
var name = search.text.split(' ');
if (!name[1])
{
name[1] = "";
}
var url = "http://sherdog.com/fightfinder.php?firstname=" + name[0] + "&lastname=" + name[1] + "&search=yes&nickname=&association=&weight=";
Utils.openUrlInBrowser(url);
}
})
 
 
</pre>
<br />
---
====Start a new cl1p.net page====
by [http://johpan.thruhere.net/opensource/ Johann Manzano]:<br/>
I originally wanted to make it so that selected text would make it into the page created by this command but i couldn't figure it out. It'll be something I'll continue to look into when time permits.
 
cl1p.net is an internet clipboard like pastebin but you can select the name that your clipboard gets. This command allows you to select the name of the page via ubiquity and it loads it for you. If you don't supply a name, it just takes you to the site.
[http://johpan.thruhere.net/opensource/?p=7 original post here]
 
<pre>
function cl1pPage( name ) {
var url = "http://cl1p.net/" + name;
Utils.openUrlInBrowser(url);
}
 
CmdUtils.CreateCommand ({
name: "cl1p",
takes: {"page name": noun_arb_text},
 
preview: function(pBlock, directObj) {
if (directObj.text)
pBlock.innerHTML = "goto cl1p.net/" + directObj.text;
else
pBlock.innerHTML = "goto cl1p.net";
},
 
execute: function(directObj) {
var text = directObj.text
cl1pPage(text);
}
 
});
</pre>
----
 
====show time in====
[http://gist.github.com/128853 show-time-in] command by [[User: Jyoti | Jyoti]]
This command shows the current time in the place specified
 
 
 
CmdUtils.CreateCommand({
name: "show time in",
author: {name:"jyoti", email: "mail2jyoti88@gmail.com"},
description:"It will show the current time in the place you specified.",
takes: {"name of a place" : noun_arb_text},
_time: function(term)
{
return "http://www.timeanddate.com/worldclock/results.html?query="+term;
},
preview: function(pblock,pname)
{
var msg="It will show the current time in "+ pname.text;
pblock.innerHTML=msg;
},
execute: function(pname)
{
if (pname.text=="")
{
displayMessage("enter name of the place whose current time u want to know");
}
else
Utils.openUrlInBrowser(this._time(pname.text));
}
})
1
edit