Tag Archives: javascript

Ubiquity for Opera gets a “bing” command

Another micro update to Ubiquity for Opera. This time I added the Bing command, to search the web with Microsoft Bing search engine.

So, Bing fans, it wasn't fair to discriminate you, so now you can search Bing through ubiquity for Opera as well. Enjoy!

As usual, you can download the script here:

Batteries and installation instructions included. Have fun.

URL shortening in Ubiquity for Opera too…

Given the cool recent activity around url shortening in Opera, I thought I could also give my small contribution.

In fact, a url shortening command is missing in Ubiquity for Opera. Or rather, it was missing.

There's a new command, shorten-url, based on bit.ly's API, that allows you, as usual with Ubiquity commands, to shorten the current open tab URL, or shorten any URL you type in the Ubiquity window. Here you can see a screenshot as example:

This new command also uses the amazing ajax-enabling UserJS library by xErath. Another interesting news is that from now on, I'll use YUI Compressor to also ship a minified version of the ubiquity javascript code, that almost halves the size, so that's good, since we're already at ~80kb uncompressed.

As usual, you can download Ubiquity for Opera,
(or the minified version), or go to the Ubiquity for Opera github repository.

Enjoy :-)

Ubiquity for Opera, “currency converter” and more…

Today I went back to a project that I really like, Ubiquity for Opera. Usually I do that when I'm annoyed by something (in this case I needed to quickly convert currency amounts), or when I find something funny.

This time, Ubiquity gets some more commands and some updates to existing ones.

  • the isdown command, that checks if a host is up, has been changed to be interactive. This is the first one that I managed to make interactive, as it requires a bit more magic than just opening a browser window.
  • the currency-converter command,
  • the instant-rimshot command

Download Ubiquity for Opera,
or go to the Ubiquity for Opera github repository.

Enjoy :-)

Why Opera doesn’t work with some web sites? Part 1

Today I received a mail from a friend. Some weeks ago, he tried Opera and then contacted me, reporting some problems with the Vodafone web site. I couldn't reproduce them because a personal account was needed.

Today he got back to me, reporting another site, Adecco's. This time, no login was required, so I could dedicate some time to investigate a bit more on what was happening.

The page is the following, from the Adecco italian web site:

http://candidate.adecco.adeccoweb.com/ecit/_General/DataPages/newCandidate/candidatesearchoffers.asp?MenuSelectedLevel1=115&Selected=1

It's just a simple form, with some SELECT controls and submit button ("Cerca…").
The problem is that using Opera the submit button does not work.

So, I fired up the javascript errors window, and I saw:

JavaScript - http://candidate.adecco.adeccoweb.com/ecit/_General/DataPages/newCandidate/candidatesearchoffers.asp?MenuSelectedLevel1=115&Selected=1
Event thread: click
Error:
name: TypeError
message: Statement on line 46: Cannot convert undefined or null to Object
Backtrace:
  Line 46 of inline#2 script in http://candidate.adecco.adeccoweb.com/ecit/_General/DataPages/newCandidate/candidatesearchoffers.asp?MenuSelectedLevel1=115&Selected=1: In function multiple_TypeBusinessLines
    	for(x=0;x<obj.length;x++){
  Line 81 of inline#2 script in http://candidate.adecco.adeccoweb.com/ecit/_General/DataPages/newCandidate/candidatesearchoffers.asp?MenuSelectedLevel1=115&Selected=1: In function cmdSearch_onclick
    		vTypeBusinessLineId= multiple_TypeBusinessLines().join(gCARACTER_SINGLE_SEPARATOR);
  Line 1 of function script 
    cmdSearch_onclick();
  ...
stacktrace: n/a; see 'opera:config#UserPrefs|Exceptions Have Stacktrace'

Ooook. Time to learn Dragonfly a bit more… I fired up Dragonfly, and I dug my way through the innards of this site javascript files. It turned out the "interesting" bits are here (javascript ahead):

http://candidate.adecco.adeccoweb.com/ecit/_includes/jscommonbrowser.js

If you open up this file in your text editor, you will see a getObject() function:

//-----------------------------------------------------------------------------
// getObject
//-----------------------------------------------------------------------------
//	Convierte una cadena con el nombre de un Objeto en la referencia
//	de un objeto. 
//-----------------------------------------------------------------------------
function getObject(obj) {
	var theObj;
	if (typeof obj == "string") {
		if (oBrowser.ns6 || oBrowser.ie5) {//si es Netscape6 o Explorer 5
			theObj = document.getElementById(obj);
		} else {
			if (oBrowser.ie4) {//si es Explorer 4
				theObj = document.all[obj];
			}
		}
	} else {
		theObj = obj;
	}
	return theObj;
}// getObject

So, what's wrong with this function? Who wrote this probably wrote it some years ago, because it's still testing for MSIE 4.0 or 5.0, or Netscape 6. Well, no wonder it doesn't work for Opera. Maybe it doesn't work for Safari either, nor for Chrome.

Anyway, time to fix this. How? As Hallvord said on dev.opera.com, it's probably a good idea, and this script shows it, to avoid testing for browsers. Let's test the functionality instead. We need getElementById().

What about this revised version:

function getObject(obj) {
  var theObj;
  if (typeof obj == "string") {
    if (document.getElementById)
      theObj = document.getElementById(obj);
    else if (document.all)
      theObj = document.all[obj];
  } else
    theObj = obj;
  return theObj;
}

I reported the problem through the Adecco web site contact form.
Let's hope that someone will consider it…