Skip to content

Instantly share code, notes, and snippets.

@hayamiz
Created September 5, 2008 16:47
Show Gist options
  • Save hayamiz/8988 to your computer and use it in GitHub Desktop.
Save hayamiz/8988 to your computer and use it in GitHub Desktop.
// Ubiquity plugin
// Latest earth quake information by tenki.jp
CmdUtils.CreateCommand({
name: "quake",
author: {name: "Y. Hayamizu", email: "y.hayamizu@gmail.com"},
description: "Check latest earthquake information in Japan.",
preview: function(pblock){
jQuery.ajax({
url: "http://tenki.jp/earthquake/",
dataType: "html",
type: "GET",
success: function(html){
var htmlstr = html.toString();
var start = htmlstr.search(/<body>/);
var end = htmlstr.search(/<\/body>/) + "</body>".length;
var bodystr = htmlstr.substring(start, end);
var tempElement = CmdUtils.getHiddenWindow().document.createElementNS("http://www.w3.org/1999/xhtml", "div");
tempElement.innerHTML = bodystr;
var imgdom = jQuery(jQuery(tempElement).find("div.earthquakeWrap")[0]).find("img")[0];
pblock.innerHTML = '<img src="' + imgdom.src + '" width="480" />';
}
});
},
execute: function(){
Utils.openUrlInBrowser("http://tenki.jp/earthquake/");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment