BetterDiscordApp-v1/Plugins/clock.plugin.js

95 lines
2.0 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);
};
2016-06-27 19:09:48 +02:00
this.ticktock12 = function() {
var suffix = "AM";
var d = new Date();
var h = d.getHours();
var m = self.pad(d.getMinutes());
var s = self.pad(d.getSeconds());
if(h >= 12) {
h -= 12;
suffix = "PM";
}
if(h == 0) {
h = 12;
}
h = self.pad(h);
var current_time = [h,m,s].join(":") + suffix;
self.clock.html(current_time);
};
2016-04-08 19:50:40 +02:00
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";
};