1
edit
Changes
→show time in
==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====
[http://matrix.senecac.on.ca/%7Eevmarbella/ Zenit-Wiki Search] by [http://zadkielm.blogspot.com/2008/09/lab-in-ubiquityin-search-of.html Ezadkiel Marbella]:
----
====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.
----
====Open irc====
--[[User:pplam3|Patrick Lam]]
})
====Goto blogspot user====
This command goes to any users blog at Blogspot
CmdUtils.CreateCommand({
})
====Goto Planet or Schedule====
This command goes to either Weekly Schedule or the Planet blog
CmdUtils.CreateCommand({
})
====Print current wiki page====
This goes to the printable version of the current wiki page
CmdUtils.CreateCommand({
})
----
====Search XKCD====
Searches the XKCD archives for whatever term you enter. Not complex, but can be enjoyable.
CmdUtils.CreateCommand({
----
====Goto a wordpress blog====
Goto a specified users blog on wordpress, modification of Patrick Lam's code
--[[User:nadavers|nadavers]] 17:16, 9 September 2008 (UTC)
====Edit a wiki user page====
---- Simple command, goes to edit a user's page.
--[[User:twlai1|twlai1]] 17:24, 9 September 2008 (UTC)
====Search for wiki user====
---- <b>By Sid Kalra</b><br />Modified version of zenit/wiki search. This searches the zenit/wiki users
<pre>
-- [[User:Crulshorukh|Crulshorukh]] 17:46, 9 September 2008 (UTC)
====Search wowhead====
<pre>
CmdUtils.CreateCommand({
----
====Search Pirate Bay====
<b>Pirate Bay Search N Sort</b><br />
by [[User:Ashughes|ashughes]]<br />
</pre>
----
====Display IP address====
<b>Displays users IP address immediately</b><br />
by [[User:AaronMT|AaronMT]]<br />
});
</pre>
====Search Altavista====
----Searches Altavista for specified term, modification of Ezadkiel Marbella's code
----
====Google Map Directions====
[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>
</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>
by [[User:AaronMT|AaronMT]]<br />
<br>
------
====Search cnet.com====
<br> 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.<br>
- Zaid Ghansar 11th September 2008
})
</pre>
====Get NASDAQ quote====
and another for getting NASDAQ stock quotes:
<pre>
<br>
----
====Seneca Library Search====
[http://matrix.senecac.on.ca/~jwboston/ubiquity/ seneca-library-search]<br />
by [http://jamesboston.ca James Boston]<br />
}
})
----
====Paste to pastebin====
[http://matrix.senecac.on.ca/~jwboston/ubiquity/ pastebin]<br />
by [http://jamesboston.ca James Boston]<br />
Send highlighted text to pastebin<br />
'''Usage''': pastebin (code)<br />
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!");
}
});
}
})
<br>
----
====Get timezone====
["Now in" timezone]<br />
by [http://felisfelis.blogspot.com/ Irina Sh.]<br />
v.0.1, must be fixed for using winter-summer time...<br />
noun_type_city = new CmdUtils.NounType( "City",["Abidjan","Abu Dhabi","Adana","Addis AbabaAddisAbaba","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() ); } }) ---<br />
----
====Timer====
Written by: [[User:Scott|Scott Lunel]] <br />
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<br />been dealing with threads and sleeping them in C++.<br /><br />
At first I attempted something along the lines of:<br />
<pre>
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!" ); }})</pre>---
<br />
However this wasn't exactly what I was looking for because it caused the browser to freeze while the command was running.<br /><br />
I did a little more looking and found this method instead:<br />
<pre>
CmdUtils.CreateCommand({
})
</pre>
<br />
Unlike the previous command, it will not freeze the browser while the timed command is being performed.<br />
---
----
====Simple Google Image Search====
[[User:jsdoodna|Joshua Doodnauth]]
<br />
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 +" <br /><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);
}
})
====Cuil Search====
[[User:cdpatel1|Chinmay Patel]]
<br />