mirror of
https://github.com/chylex/Discord-History-Tracker.git
synced 2025-04-13 15:27:16 +03:00
Add scr.discord.js to renderer with templates and HTML generation
This commit is contained in:
parent
679a2d8532
commit
1bd72406b6
33
src/renderer/scr.discord.js
Normal file
33
src/renderer/scr.discord.js
Normal file
@ -0,0 +1,33 @@
|
||||
var DISCORD = (function(){
|
||||
var templateChannelServer;
|
||||
var templateChannelPrivate;
|
||||
var templateMessage;
|
||||
|
||||
return {
|
||||
setup: function(){
|
||||
templateChannelServer = new TEMPLATE("<div data-channel='{id}'><strong class='name'>{name}</strong> <span class='msgcount'>({msgcount})</span><br><span class='server'>{server.name}</span> <span class='type'>({server.type})</span></div>");
|
||||
templateChannelPrivate = new TEMPLATE("<div data-channel='{id}'><strong class='name'>{name}</strong> <span class='msgcount'>({msgcount})</span><br><span class='type'>({server.type})</span></div>");
|
||||
templateMessage = new TEMPLATE("<div><h2><strong class='username'>{user.name}</strong><span class='time'>{timestamp}</span></h2><div class='message'>{contents}</div></div>");
|
||||
},
|
||||
|
||||
getChannelHTML: function(channel){
|
||||
return (channel.server.type === "SERVER" ? templateChannelServer : templateChannelPrivate).apply(channel, (property, value) => {
|
||||
if (property === "server.type"){
|
||||
switch(value){
|
||||
case "SERVER": return "server";
|
||||
case "GROUP": return "group";
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
getMessageHTML: function(message){
|
||||
return templateMessage.apply(message, (property, value) => {
|
||||
if (property === "timestamp"){
|
||||
var date = new Date(value);
|
||||
return date.toLocaleDateString()+", "+date.toLocaleTimeString();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
})();
|
Loading…
x
Reference in New Issue
Block a user