Skip to content

Instantly share code, notes, and snippets.

@teramako
Created March 12, 2009 02:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teramako/77869 to your computer and use it in GitHub Desktop.
Save teramako/77869 to your computer and use it in GitHub Desktop.
/*
* http://www.bijint.com/
*
* == Start ==
* js plugins.bijin_clock.start(min)
* min: interval minutes (default: 1)
*
* == Stop ==
* js plugins.bijin_clock.stop()
*/
liberator.plugins.bijin_clock = (function(){
const BASE_URL = 'http://www.bijint.com/jp/img/photo/';
const TITLE = "美人時計";
const NAME = "Bijin Clock";
const alertService = Cc["@mozilla.org/alerts-service;1"]
.getService(Ci.nsIAlertsService);
let interval = null;
let observer = {
observe: function(aSubject, aTopic, aData){
if (aTopic == "alertclickcallback" && aData){
liberator.open(aData, liberator.NEW_TAB);
}
}
};
function getTimeString(date){
let time = date.toTimeString();
return time.substr(0,2) + time.substr(3,2);
}
function showBijinClock(){
let date = new Date;
let URL = BASE_URL + getTimeString(date) + ".jpg";
alertService.showAlertNotification(
URL,
TITLE,
date.toLocaleString(),
true,
URL,
observer,
NAME
)
}
return {
start: function(min){
if (interval) return;
if (!min) min = 1;
return interval = window.setInterval(showBijinClock, min * 60 * 1000);
},
stop: function(){
if (interval){
window.clearInterval(interval);
interval = null;
}
},
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment