Posts Tagged 'firefox'

Ubiquity weather command

Ubiquity from Mozilla labs features a nice command for querying the weather. It creates a query to the Google Weather service and returns the result. But with Google’s location/ IP dependent search results you can get the weather information in various languages depending where you conduct the search. For example if your language preference is Filipino (politically correct) or Tagalog (ISO language standard code) TL, you get the results in the corresponding language and in the unit standard used in the area.

But as a metric thinking type of guy, I hate it when Google gives me the results in Fahrenheit! I did some tweaking to get the weather in the metric system while using the English language.  The simple solution is to use the EN-UK language code. Simply edit your ~/.mozilla/[profile_name]/extentions/ubiquity@labs.mozilla.com/chrome/content/builtincmds.js and modify the command “weather”:


CmdUtils.CreateCommand({
  name: "weather",
  takes: {"location": noun_arb_text},
  icon: "http://www.wunderground.com/favicon.ico",
  description: "Checks the weather for a given location.",
  help: "Try issuing "weather chicago".  It works with zip-codes, too.",
  execute: function( directObj ) {
    var location = directObj.text;
    var url = "http://www.wunderground.com/cgi-bin/findweather/getForecast?query=";
    url += escape( location );

    Utils.openUrlInBrowser( url );
  },

  preview: function( pblock, directObj ) {
    var location = directObj.text;
    if( location.length < 1 ) {
      pblock.innerHTML = "Gets the weather for a zip code/city.";
      return;
    }

    var url = "http://www.google.com/ig/api";
    jQuery.get( url, {weather: location, hl: "EN-GB"}, function(xml) {
      var el = jQuery(xml).find("current_conditions");
      if( el.length == 0 ) return;

      var condition = el.find("condition").attr("data");

      var weatherId = WEATHER_TYPES.indexOf( condition.toLowerCase() );
      var imgSrc = "http://l.yimg.com/us.yimg.com/i/us/nws/weather/gr/";
      imgSrc += weatherId + "d.png";

      var weather = {
        condition: condition,
        temp: el.find("temp_c").attr("data"),
        humidity: el.find("humidity").attr("data"),
        wind: el.find("wind_condition").attr("data"),
        img: imgSrc
      };

      weather["img"] = imgSrc;

      var html = CmdUtils.renderTemplate( {file:"weather.html"}, {w:weather}
                                        );

      jQuery(pblock).html( html );
      }, "xml");
  }
});

Tweak your del.icio.us most visited sites

The del.icio.us Firefox add-on provides very neat integration into the latest version of Firefox three. I like the synchronization between local bookmarks, shortcuts, etc. The “most visited” tab actually counts how many times you clicked a bookmark and updates the toolbar respectively. The only problem is that for private bookmarks like the ones that initiate javascript link calls do not update the bookmark counters.

One of my favorite links is the citeulike.org‘s add to library shortcuts which initiates a javascript call containing the current url on your browser such as an overview page of a journal article. This frustrated me for a while but after “grep”-ing my Firefox profile directory for the name of my citeulike bookmark, I edited the citeulike entry in my ~/.mozilla/firefox/$PROFILENAME/delcious.rdf:



    bibliography
    citation
    bookmarking
    research
    reference
    academic
    tagging
    300
    Tue Jul 03 07:49:43 2007 +000000
    Tue Jul 03 07:49:43 2007 +000000

The code entry above shows the XML entry for a bookmark. Simply change the “NC:VisitCount” tag to a very high value and it will appear at the top of your del.icio.us toolbar most-visited tab.

Enjoy your new favorite bookmark!