Skip to content

Instantly share code, notes, and snippets.

@hayamiz
Created August 29, 2008 23:25
Show Gist options
  • Save hayamiz/8075 to your computer and use it in GitHub Desktop.
Save hayamiz/8075 to your computer and use it in GitHub Desktop.
// Ubiquity plugin
// Tokyo amesh.
CmdUtils.CreateCommand({
name: "amesh",
author: { name: "Y. Hayamizu", email: "y.hayamizu@gmail.com"},
description: "Check weather around Tokyo.",
help: "Just type \"amesh\", and then you get weather information.",
_zeropad: function(num, width){
if (width - num.toString().length > 0){
return (new Array(width - num.toString().length + 1)).join("0") + num.toString();
} else {
return num.toString();
}
},
preview: function(pblock){
var now = new Date();
var sec = now.getTime() - 5 * 60 * 1000; // five minutes ago
now.setTime(sec - (sec % (10 * 60 * 1000)));
var datestr = "" + now.getFullYear() + this._zeropad(now.getMonth()+1, 2) + this._zeropad(now.getDate(), 2) + this._zeropad(now.getHours(), 2) + this._zeropad(now.getMinutes() - (now.getMinutes() % 10), 2);
pblock.innerHTML = "<div><strong>東京アメッシュ</strong> " + now.toLocaleString() + "の関東の天気図</div>" + "<div style=\"width: 385px; height: 240px;\"><img src=\"http://tokyo-ame.jwa.or.jp/map/map000.jpg\" style=\"width: 385px; height: 240px; position: absolute;\" /><img src=\"http://tokyo-ame.jwa.or.jp/mesh/000/" + datestr + ".gif\" style=\"width: 385px; height: 240px; position: absolute; \" /><img src=\"http://tokyo-ame.jwa.or.jp/map/msk000.png\" style=\"width: 385px; height: 240px; position: absolute;\" /></div>"
},
execute: function(){
Utils.openUrlInBrowser("http://tokyo-ame.jwa.or.jp/");
}
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment