BetterDiscordApp-v2/Plugins/clock.plugin.js

73 lines
1.6 KiB
JavaScript
Raw Normal View History

2016-04-08 19:50:40 +02:00
//META{"name":"clockPlugin"}*//
//Original clock code from http://cssdeck.com/labs/minimal-css3-digital-clock
var clockPlugin = function () {};
clockPlugin.prototype.start = function () {
BdApi.clearCSS("clockPluginCss");
2016-05-07 17:53:52 +02:00
BdApi.injectCSS("clockPluginCss", '#clockPluginClock { position:absolute; color:#FFF; background:#333333; padding:0 12px 0 13px; min-width:55px; max-width:55px; z-index:100; }');
2016-04-08 19:50:40 +02:00
var self = this;
this.clock = $("<div/>", { id: "clockPluginClock" });
$("body").append(this.clock);
this.pad = function(x) {
return x < 10 ? '0'+x : x;
};
this.ticktock = function() {
var d = new Date();
var h = self.pad(d.getHours());
var m = self.pad(d.getMinutes());
var s = self.pad(d.getSeconds());
var current_time = [h,m,s].join(':');
self.clock.html(current_time);
};
this.ticktock();
this.interval = setInterval(this.ticktock, 1000);
};
clockPlugin.prototype.load = function () {
};
clockPlugin.prototype.unload = function () {}
;
clockPlugin.prototype.stop = function () {
BdApi.clearCSS("clockPluginCss");
clearInterval(this.interval);
this.clock.remove();
};
clockPlugin.prototype.onMessage = function () {
};
clockPlugin.prototype.onSwitch = function () {
};
clockPlugin.prototype.observer = function (e) {
};
clockPlugin.prototype.getSettingsPanel = function () {
return "";
};
clockPlugin.prototype.getName = function () {
return "Clock Plugin";
};
clockPlugin.prototype.getDescription = function () {
return "Adds a clock to Discord";
};
clockPlugin.prototype.getVersion = function () {
return "0.1.0";
};
clockPlugin.prototype.getAuthor = function () {
return "Jiiks";
};