Skip to content
Permalink
Browse files

Refactor and fix the things

fix the bad
use bdStorage API
make header in settings visible
  • Loading branch information...
MorkHub committed Aug 17, 2017
1 parent 2844bbb commit fcc9b6b831261e3aa039c359b2e651df4b17173a
Showing with 28 additions and 73 deletions.
  1. +28 −73 morkMoji.plugin.js
@@ -1,79 +1,34 @@
//META{"name":"BetterEmoji"}*//

var BetterEmoji = function () {};

BetterEmoji.prototype.start = function () {
this.data = localStorage.getItem('BetterEmoji')
this.update(this.data.size);
};

var BetterEmoji = function() {};
BetterEmoji.prototype.data = {};

BetterEmoji.prototype.saveData = function () {
localStorage.setItem('BetterEmoji',this.data);
};

BetterEmoji.prototype.update = function (size) {
this.data.size = size;
BdApi.clearCSS("BetterEmoji");
BdApi.injectCSS("BetterEmoji",
"img.emoji.jumboable {\
width:"+size+"px !important;\
height:auto !important;\
max-height:"+size+"px;\
}"
);
BetterEmoji.prototype.defaultData = function() { return { size: 64 } };

BetterEmoji.prototype.load = function() { this.loadData(); }
BetterEmoji.prototype.unload = function() {};
BetterEmoji.prototype.observer = function(e) {};

BetterEmoji.prototype.getName = function() { return "BetterEmoji"; };
BetterEmoji.prototype.getVersion = function() { return "0.1"; };
BetterEmoji.prototype.getAuthor = function() { return "TheMork#1944"; };
BetterEmoji.prototype.getDescription = function () { return "Allows you to set a custom size for emoji."; };
BetterEmoji.prototype.getSettingsPanel = function() { return '<h3 style="color:white">Settings for BetterEmoji</h3><br/>'+'<input type="range" id="BE_size" min="32" value="'+this.data.size+'" max="96" onchange="BetterEmoji.prototype.update(this.value)" style="width:100%"><br/>'+'<div class="markup" data-colour="true" style="color: rgb(35, 236, 236); background-color: #36393e; padding: 5px; border-radius: 5px"><span class="timestamp" data-24="true"><span class="username-wrapper"><strong class="user-name" style="color: rgb(35, 236, 236);">TheMork</strong><i class="highlight-separator right-pad">: </i></span><span class="message-content"><img draggable="false" class="emoji jumboable" alt=":ok_hand:" src="/assets/b6f700d4bc253abdb5ad576917b756d8.svg"></span>'+'</div>'; }

BetterEmoji.prototype.stop = function() { BdApi.clearCSS("BetterEmoji"); };
BetterEmoji.prototype.start = function() { this.loadData(); this.update(this.data.size); };
BetterEmoji.prototype.onSwitch = function() {};
BetterEmoji.prototype.onMessage = function() {};

BetterEmoji.prototype.saveData = function() { bdStorage.set('BetterEmoji', JSON.stringify(this.data)); };
BetterEmoji.prototype.loadData = function() {
this.data = bdStorage.get('BetterEmoji') ? JSON.parse(bdStorage.get('BetterEmoji')) : this.defaultData();
this.saveData();
};

BetterEmoji.prototype.load = function () {
this.data = localStorage.getItem('BetterEmoji') || { "size": 32 };
};

BetterEmoji.prototype.unload = function () {

};

BetterEmoji.prototype.reload = function () {
this.stop();
this.start()
};

BetterEmoji.prototype.stop = function () {
BdApi.clearCSS("morkMoji");
};

BetterEmoji.prototype.onMessage = function () {

};

BetterEmoji.prototype.onSwitch = function () {

};

BetterEmoji.prototype.observer = function (e) {

};

BetterEmoji.prototype.getSettingsPanel = function () {
return '<h3>Settings for BetterEmoji</h3><br/>\
<input type="range" id="BE_size" min="32" value="'+this.data.size+'" max="96" onchange="BetterEmoji.prototype.update(this.value)" style="width:100%"><br/>\
<div class="markup" data-colour="true" style="color: rgb(35, 236, 236); background-color: #36393e; padding: 5px; border-radius: 5px"><span class="timestamp" data-24="true"><span class="username-wrapper"><strong class="user-name" style="color: rgb(35, 236, 236);">TheMork</strong><i class="highlight-separator right-pad">: </i></span><span class="message-content"><img draggable="false" class="emoji jumboable" alt=":ok_hand:" src="/assets/b6f700d4bc253abdb5ad576917b756d8.svg"></span>\
</div>';
};

BetterEmoji.prototype.getName = function () {
return "BetterEmoji";
};

BetterEmoji.prototype.getDescription = function () {
return "Allows you to set a custom size for emoji.";
};

BetterEmoji.prototype.getVersion = function () {
return "1.0.3";
};

BetterEmoji.prototype.getAuthor = function () {
return "TheMork#1944: MorkHub <Mork@TheMork.co.uk>";
BetterEmoji.prototype.update = function (size) {
this.data.size = Math.min(96, Math.max(8, size));
BdApi.clearCSS("BetterEmoji");
BdApi.injectCSS("BetterEmoji",
"img.emoji.jumboable {width:"+size+"px !important; height:auto !important;\ max-height:"+size+"px;}"
);
this.saveData();
};

0 comments on commit fcc9b6b

Please sign in to comment.
You can’t perform that action at this time.