`;
this.dividerMarkup = ``;
this.css = `
.guilds > .friends-online {
cursor: pointer;
}
.stalkernotifications-modal .log-time {
width: 110px;
}
.stalkernotifications-modal .log-avatar {
width: 35px;
height: 35px;
background-size: cover;
background-position: center;
border-radius: 50%;
}
.StalkerNotifications-settings .avatar-list {
display: flex;
align-items: center;
flex-wrap: wrap;
}
.StalkerNotifications-settings .type-toast, .StalkerNotifications-settings .type-desktop {
border-radius: 3px;
padding: 0 3px;
}
.StalkerNotifications-settings .type-toast {
background-color: #7289DA;
}
.StalkerNotifications-settings .type-desktop {
background-color: #43B581;
}
.StalkerNotifications-settings .settings-avatar.desktop {
border-color: #43B581;
}
.StalkerNotifications-settings .settings-avatar {
margin: 5px;
width: 50px;
height: 50px;
background-size: cover;
background-position: center;
border: 5px solid #7289DA;
border-radius: 50%;
box-sizing: border-box;
cursor: pointer;
}
.StalkerNotifications-settings .settings-avatar.desktop {
border-color: #43B581;
}
.StalkerNotifications-settings .settings-avatar.disabled {
border-color: #36393F;
filter: grayscale(100%) brightness(50%);
}
.StalkerNotifications-settings .settings-avatar ${BDFDB.dotCN.hovercardbutton} {
position: relative;
top: -10px;
right: -25px;
}
.StalkerNotifications-settings .settings-avatar:not(:hover) ${BDFDB.dotCN.hovercardbutton} {
opacity: 1;
}`;
this.defaults = {
settings: {
muteOnDND: {value:false, description:"Do not notify me when I am DnD:"},
onlyOnOnline: {value:false, description:"Only notify me when a User logs in:"},
openOnClick: {value:false, description:"Open the DM when you click a Notification:"}
},
amounts: {
checkInterval: {value:10, description:"Check Users every X seconds:"}
}
};
}
getName () {return "StalkerNotifications";}
getDescription () {return "Lets you observe the status of people that aren't your friends.";}
getVersion () {return "1.0.7";}
getAuthor () {return "DevilBro";}
getSettingsPanel () {
if (!this.started || typeof BDFDB !== "object") return;
var amounts = BDFDB.getAllData(this, "amounts");
var settings = BDFDB.getAllData(this, "settings");
var users = BDFDB.loadAllData(this, "users");
var notificationsound = BDFDB.loadAllData(this, "notificationsound");
var settingshtml = `
${this.getName()}
`;
settingshtml += `
Add User:
`;
for (let key in amounts) {
settingshtml += `
${this.defaults.amounts[key].description}
`;
}
for (let key in settings) {
settingshtml += `
${this.defaults.settings[key].description}
`;
}
if ("Notification" in window) settingshtml += `
Desktop Notification Sound:
Mute:
`;
settingshtml += `
Click on a Icon to toggle Notifications for that User:
`;
if ("Notification" in window) settingshtml += `
Rightclick on a Icon to toggle Notifications for that User:
`;
settingshtml += `
`;
for (let id in users) {
let user = this.UserUtils.getUser(id);
if (user) settingshtml += this.createSettingsAvatarHtml(user, users[id]);
}
settingshtml += `
`;
settingshtml += `
Batch set Users:
${"Notification" in window ? `` : ``}
`;
settingshtml += `
Timelog of LogIns/-Outs:
`;
settingshtml += `
`;
var settingspanel = $(settingshtml)[0];
BDFDB.initElements(settingspanel);
$(settingspanel)
.on("click", ".settings-checkbox", () => {this.updateSettings(settingspanel);})
.on("click", ".btn-savesong", () => {this.saveAudio(settingspanel);})
.on("click", ".mute-checkbox", (e) => {
var notificationsound = BDFDB.loadAllData(this, "notificationsound");
notificationsound.mute = e.currentTarget.checked;
BDFDB.saveAllData(notificationsound, this, "notificationsound");
})
.on("mouseenter", ".settings-avatar", (e) => {
let user = this.UserUtils.getUser(e.currentTarget.getAttribute("user-id"));
let data = BDFDB.loadData(user.id, "EditUsers", "users") || {};
BDFDB.createTooltip(data.name ? data.name : user.username, e.currentTarget, {type:"top"});
})
.on("contextmenu", ".settings-avatar", (e) => {
if (!("Notification" in window)) return;
let desktopoff = !e.currentTarget.classList.contains("desktop");
let id = e.currentTarget.getAttribute("user-id");
e.currentTarget.classList.remove("disabled");
e.currentTarget.classList.toggle("desktop", desktopoff);
BDFDB.saveData(id, {"desktop":desktopoff,"disabled":false}, this, "users");
})
.on("click", ".settings-avatar", (e) => {
if (e.target.classList.contains("remove-user")) return;
let disableoff = !e.currentTarget.classList.contains("disabled");
let id = e.currentTarget.getAttribute("user-id");
e.currentTarget.classList.remove("desktop");
e.currentTarget.classList.toggle("disabled", disableoff);
BDFDB.saveData(id, {"desktop":false,"disabled":disableoff}, this, "users");
})
.on("click", ".disable-all, .toast-all, .desktop-all", (e) => {
let button = e.currentTarget;
let disableon = button.getAttribute("do-disable");
let desktopon = button.getAttribute("do-desktop");
let users = BDFDB.loadAllData(this, "users");
settingspanel.querySelectorAll(".settings-avatar").forEach(avatar => {
let id = avatar.getAttribute("user-id");
avatar.classList.toggle("disabled", disableon);
avatar.classList.toggle("desktop", desktopon);
users[id].desktop = desktopon ? true : false;
users[id].disabled = disableon ? true : false;
});
BDFDB.saveAllData(users, this, "users");
})
.on("click", ".btn-adduser", (e) => {
let idinput = settingspanel.querySelector("#input-userid");
let user = this.UserUtils.getUser(idinput.value);
if (user) {
idinput.value = "";
BDFDB.saveData(user.id, {desktop:false,disabled:false}, this, "users");
settingspanel.querySelectorAll(".settings-avatar").forEach(entry => {entry.remove();});
let listhtml = `
`;
let users = BDFDB.loadAllData(this, "users");
for (let id in users) {
let user = this.UserUtils.getUser(id);
if (user) listhtml += this.createSettingsAvatarHtml(user, users[id]);
}
listhtml += `
`;
settingspanel.querySelector(".avatar-list").innerHTML = listhtml;
}
else BDFDB.showToast("Please enter a valid UserID.",{type:"error"});
})
.on("click", ".remove-user", (e) => {
BDFDB.removeData(e.currentTarget.parentElement.getAttribute("user-id"), this, "users");
settingspanel.querySelectorAll(".settings-avatar").forEach(entry => {entry.remove();});
let listhtml = `
`;
let users = BDFDB.loadAllData(this, "users");
for (let id in users) {
let user = this.UserUtils.getUser(id);
if (user) listhtml += this.createSettingsAvatarHtml(user, users[id]);
}
listhtml += `