Created
March 12, 2009 02:20
-
-
Save teramako/77869 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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