stuff
This commit is contained in:
parent
f5c5fef1d9
commit
70133dbfc2
|
@ -4463,6 +4463,7 @@
|
|||
settingsTableCardConfigs: "settingsTableCardConfigs-w5X9-Z",
|
||||
settingsTableCardLabel: "settingsTableCardLabel-MElgIg",
|
||||
settingsTableHeaders: "settingsTableHeaders-WKzw9_",
|
||||
settingsTableHeaderVertical: "headerVertical-4MNxqk",
|
||||
settingsTableList: "settingsTableList-f6sW2y",
|
||||
svgIcon: "icon-GhnIRB",
|
||||
table: "table-moqjM0",
|
||||
|
@ -5943,6 +5944,7 @@
|
|||
settingstableheaderoption: ["SettingsTable", "headerOption"],
|
||||
settingstableheaders: ["BDFDB", "settingsTableHeaders"],
|
||||
settingstableheadersize: ["SettingsTable", "headerSize"],
|
||||
settingstableheadervertical: ["BDFDB", "settingsTableHeaderVertical"],
|
||||
settingstablecard: ["BDFDB", "settingsTableCard"],
|
||||
settingstablecardconfigs: ["BDFDB", "settingsTableCardConfigs"],
|
||||
settingstablecardlabel: ["BDFDB", "settingsTableCardLabel"],
|
||||
|
@ -7873,7 +7875,7 @@
|
|||
}
|
||||
}
|
||||
resizeList(list, headers) {
|
||||
let toobig = false, maxWidth = 0;
|
||||
let maxWidth = 0, biggestWidth = 0;
|
||||
if (!maxWidth) {
|
||||
for (let header of headers) {
|
||||
header.style = "";
|
||||
|
@ -7881,13 +7883,18 @@
|
|||
maxWidth = width > maxWidth ? width : maxWidth;
|
||||
}
|
||||
maxWidth += 4;
|
||||
biggestWidth = maxWidth;
|
||||
}
|
||||
if (headers.length * maxWidth > 300) {
|
||||
toobig = true;
|
||||
this.props.vertical = true;
|
||||
maxWidth = parseInt(290 / headers.length);
|
||||
}
|
||||
else if (maxWidth < 36) maxWidth = 36;
|
||||
else if (maxWidth < 36) {
|
||||
maxWidth = 36;
|
||||
biggestWidth = maxWidth;
|
||||
}
|
||||
this.props.maxWidth = maxWidth;
|
||||
this.props.biggestWidth = biggestWidth;
|
||||
this.props.fullWidth = BDFDB.DOMUtils.getRects(list).width;
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
}
|
||||
|
@ -7896,22 +7903,28 @@
|
|||
this.props.renderLabel = typeof this.props.renderLabel == "function" ? this.props.renderLabel : data => data.label;
|
||||
let labelWidth = this.props.maxWidth && this.props.fullWidth && (this.props.fullWidth - 20 - (this.props.maxWidth * this.props.settings.length));
|
||||
let configWidth = this.props.maxWidth && this.props.maxWidth * this.props.settings.length;
|
||||
let isHeaderClickable = typeof this.props.onHeaderClick == "function" || typeof this.props.onHeaderContextMenu == "function";
|
||||
return BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.settingstablelist, this.props.className),
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(LibraryComponents.Flex, {
|
||||
className: BDFDB.disCN.settingstableheaders,
|
||||
align: LibraryComponents.Flex.Align.STRETCH,
|
||||
style: this.props.vertical && this.props.biggestWidth ? {
|
||||
marginTop: this.props.biggestWidth - 25 || 0
|
||||
} : {},
|
||||
children: [].concat(this.props.title || "", this.props.settings).map((setting, i) => BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.DOMUtils.formatClassName(i == 0 ? BDFDB.disCN.settingstableheadername : BDFDB.disCN.settingstableheaderoption, BDFDB.disCN.settingstableheader, BDFDB.disCN.settingstableheadersize, BDFDB.disCN.primary, BDFDB.disCN.weightbold),
|
||||
children: setting,
|
||||
className: BDFDB.DOMUtils.formatClassName(i == 0 ? BDFDB.disCN.settingstableheadername : BDFDB.disCN.settingstableheaderoption, i != 0 && this.props.vertical && BDFDB.disCN.settingstableheadersvertical, BDFDB.disCN.settingstableheader, BDFDB.disCN.settingstableheadersize, BDFDB.disCN.primary, BDFDB.disCN.weightbold, isHeaderClickable && BDFDB.disCN.cursorpointer),
|
||||
onClick: _ => {if (typeof this.props.onHeaderClick == "function") this.props.onHeaderClick(setting, this);},
|
||||
onContextMenu: _ => {if (typeof this.props.onHeaderContextMenu == "function") this.props.onHeaderContextMenu(setting, this);},
|
||||
style: i != 0 && this.props.maxWidth ? {
|
||||
maxWidth: this.props.maxWidth,
|
||||
width: this.props.maxWidth,
|
||||
flex: `0 0 ${this.props.maxWidth}px`
|
||||
} : {}
|
||||
} : {},
|
||||
children: BDFDB.ReactUtils.createElement("span", {
|
||||
children: setting
|
||||
})
|
||||
}))
|
||||
}),
|
||||
(BDFDB.ArrayUtils.is(this.props.data) ? this.props.data : [{}]).filter(n => n).map(data => BDFDB.ReactUtils.createElement(LibraryComponents.Card, BDFDB.ObjectUtils.exclude(Object.assign({}, this.props, {
|
||||
|
@ -7943,6 +7956,7 @@
|
|||
shrink: 0,
|
||||
wrap: true,
|
||||
children: BDFDB.ReactUtils.createElement(LibraryComponents.Checkbox, {
|
||||
disabled: data.disabled,
|
||||
cardId: data.key,
|
||||
settingId: setting,
|
||||
shape: LibraryComponents.Checkbox.Shapes.ROUND,
|
||||
|
@ -8515,6 +8529,16 @@
|
|||
${BDFDB.dotCNS.settingstablelist + BDFDB.dotCN.checkboxcontainer}:before {
|
||||
display: none;
|
||||
}
|
||||
${BDFDB.dotCN.settingstableheadervertical} {
|
||||
position: relative;
|
||||
}
|
||||
${BDFDB.dotCN.settingstableheadervertical} > span {
|
||||
position: absolute;
|
||||
bottom: 50%;
|
||||
right: 14px;
|
||||
margin-bottom: -5px;
|
||||
writing-mode: vertical-rl;
|
||||
}
|
||||
${BDFDB.dotCN.settingstablecard} {
|
||||
height: 60px;
|
||||
padding: 0 10px;
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -3,7 +3,7 @@
|
|||
class FriendNotifications {
|
||||
getName () {return "FriendNotifications";}
|
||||
|
||||
getVersion () {return "1.3.7";}
|
||||
getVersion () {return "1.3.8";}
|
||||
|
||||
getAuthor () {return "DevilBro";}
|
||||
|
||||
|
@ -11,102 +11,39 @@ class FriendNotifications {
|
|||
|
||||
constructor () {
|
||||
this.changelog = {
|
||||
"fixed":[["Non Friends","Fixed issue where previously configured friends that are no longer in your friend list could not be configured via non-friend list"]]
|
||||
"improved":[["New Library Structure & React","Restructured my Library and switched to React rendering instead of DOM manipulation"]]
|
||||
};
|
||||
}
|
||||
|
||||
initConstructor () {
|
||||
this.userStatusStore = {};
|
||||
|
||||
this.checkInterval = null;
|
||||
|
||||
this.timeLog = [];
|
||||
|
||||
this.timeLogModalMarkup =
|
||||
`<span class="${this.name}-modal BDFDB-modal">
|
||||
<div class="${BDFDB.disCN.backdrop}"></div>
|
||||
<div class="${BDFDB.disCN.modal}">
|
||||
<div class="${BDFDB.disCN.modalinner}">
|
||||
<div class="${BDFDB.disCNS.modalsub + BDFDB.disCN.modalsizemedium}">
|
||||
<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.modalheader}" style="flex: 0 0 auto;">
|
||||
<div class="${BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">
|
||||
<h4 class="${BDFDB.disCNS.h4 + BDFDB.disCNS.defaultcolor + BDFDB.disCN.h4defaultmargin}">Friends LogIn/-Out Timelog</h4>
|
||||
</div>
|
||||
<button type="button" class="${BDFDB.disCNS.modalclose + BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookblank + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCN.buttongrow}">
|
||||
<div class="${BDFDB.disCN.buttoncontents}">
|
||||
<svg name="Close" width="18" height="18" viewBox="0 0 12 12" style="flex: 0 1 auto;">
|
||||
<g fill="none" fill-rule="evenodd">
|
||||
<path d="M0 0h12v12H0"></path>
|
||||
<path class="fill" fill="currentColor" d="M9.5 3.205L8.795 2.5 6 5.295 3.205 2.5l-.705.705L5.295 6 2.5 8.795l.705.705L6 6.705 8.795 9.5l.705-.705L6.705 6"></path>
|
||||
</g>
|
||||
</svg>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
<div class="${BDFDB.disCNS.scrollerwrap + BDFDB.disCNS.modalcontent + BDFDB.disCNS.scrollerthemed + BDFDB.disCN.scrollerthemeghosthairline}">
|
||||
<div class="${BDFDB.disCNS.scroller + BDFDB.disCN.modalsubinner} entries">
|
||||
</div>
|
||||
</div>
|
||||
<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontalreverse + BDFDB.disCNS.horizontalreverse2 + BDFDB.disCNS.directionrowreverse + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignstretch + BDFDB.disCNS.nowrap + BDFDB.disCN.modalfooter}">
|
||||
<button type="button" class="btn-ok ${BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow}">
|
||||
<div class="${BDFDB.disCN.buttoncontents}"></div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</span>`;
|
||||
|
||||
this.logEntryMarkup =
|
||||
`<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCNS.margintop4 + BDFDB.disCN.marginbottom4} entry" style="flex: 1 1 auto;">
|
||||
<h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCNS.flexchild + BDFDB.disCNS.overflowellipsis} log-time" style="flex: 0 0 auto;"></h3>
|
||||
<div class="log-avatar"></div>
|
||||
<h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCNS.flexchild + BDFDB.disCNS.overflowellipsis} log-description" style="flex: 1 1 auto;"></h3>
|
||||
</div>`;
|
||||
|
||||
this.lastTimes = {};
|
||||
|
||||
this.css = `
|
||||
.${this.name}-modal .log-time {
|
||||
width: 110px;
|
||||
.${this.name}-Log-modal .log-time {
|
||||
width: 160px;
|
||||
}
|
||||
.${this.name}-Log-modal .log-user {
|
||||
margin: 0 10px;
|
||||
}
|
||||
.${this.name}-modal .log-avatar {
|
||||
width: 35px;
|
||||
height: 35px;
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
border-radius: 50%;
|
||||
.${this.name}-Log-modal .log-content {
|
||||
max-width: 600px;
|
||||
}
|
||||
.${this.name}-settings .type-toast, .${this.name}-settings .type-desktop {
|
||||
.${this.name}-settings .type-label {
|
||||
border-radius: 3px;
|
||||
padding: 0 3px;
|
||||
margin: 0 6px;
|
||||
}
|
||||
.${this.name}-settings .type-toast {
|
||||
background-color: #7289DA;
|
||||
}
|
||||
.${this.name}-settings .type-desktop {
|
||||
background-color: #43B581;
|
||||
}
|
||||
.${this.name}-settings .settings-avatar.desktop {
|
||||
border-color: #43B581;
|
||||
.${this.name}-settings .settings-name {
|
||||
max-width: 200px;
|
||||
}
|
||||
.${this.name}-settings .settings-avatar {
|
||||
margin: 5px;
|
||||
width: 35px;
|
||||
height: 35px;
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
border: 3px solid #7289DA;
|
||||
border-radius: 50%;
|
||||
box-sizing: border-box;
|
||||
cursor: pointer;
|
||||
margin-right: 15px;
|
||||
}
|
||||
.${this.name}-settings .settings-avatar.desktop {
|
||||
border-color: #43B581;
|
||||
}
|
||||
.${this.name}-settings .settings-avatar.disabled {
|
||||
border-color: #36393F;
|
||||
filter: grayscale(100%) brightness(50%);
|
||||
}
|
||||
.${this.name}-settings .settings-avatar.disabled ~ * {
|
||||
filter: grayscale(100%) brightness(50%);
|
||||
}`;
|
||||
|
||||
|
@ -143,156 +80,333 @@ class FriendNotifications {
|
|||
for (let type in BDFDB.DiscordConstants.ActivityTypes) this.activityTypes[BDFDB.DiscordConstants.ActivityTypes[type]] = type;
|
||||
}
|
||||
|
||||
getSettingsPanel () {
|
||||
getSettingsPanel (collapseStates = {}) {
|
||||
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||
|
||||
|
||||
let changeNotificationType = (type, userId, desktopon, disableon) => {
|
||||
let data = BDFDB.DataUtils.load(this, type, userId) || this.createDefaultConfig();
|
||||
data.desktop = desktopon;
|
||||
data.disabled = disableon;
|
||||
BDFDB.DataUtils.save(data, this, type, userId);
|
||||
this.SettingsUpdated = true;
|
||||
BDFDB.PluginUtils.refreshSettingsPanel(this, settingspanel, collapseStates);
|
||||
};
|
||||
let changeAllConfigs = (type, config, enable) => {
|
||||
let data = BDFDB.DataUtils.load(this, type);
|
||||
if (config == "type") {
|
||||
config = "desktop";
|
||||
enable = !enable;
|
||||
for (let id in data) data[id].disabled = false;
|
||||
}
|
||||
for (let id in data) data[id][config] = enable;
|
||||
BDFDB.DataUtils.save(data, this, type);
|
||||
this.SettingsUpdated = true;
|
||||
BDFDB.PluginUtils.refreshSettingsPanel(this, settingspanel, collapseStates);
|
||||
};
|
||||
let successSavedAudio = (type, parsedurl, parseddata) => {
|
||||
if (parsedurl && parseddata) BDFDB.NotificationUtils.toast(`Sound was saved successfully.`, {type:"success"});
|
||||
let notificationsound = BDFDB.DataUtils.get(this, "notificationsounds", type);
|
||||
notificationsound.url = parsedurl;
|
||||
notificationsound.song = parseddata;
|
||||
BDFDB.DataUtils.save(notificationsound, this, "notificationsounds", type);
|
||||
this.SettingsUpdated = true;
|
||||
};
|
||||
let createUserList = (users, type, title) => {
|
||||
let items = [];
|
||||
items.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
||||
className: BDFDB.disCNS.titledefault + BDFDB.disCN.cursordefault,
|
||||
children: [
|
||||
"Click on an Icon to toggle",
|
||||
BDFDB.ReactUtils.createElement("span", {
|
||||
className: "type-label",
|
||||
style: {backgroundColor: BDFDB.DiscordConstants.Colors.BRAND},
|
||||
children: "Toast"
|
||||
}),
|
||||
"Notifications for that User:"
|
||||
]
|
||||
}));
|
||||
if ("Notification" in window) items.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
||||
className: BDFDB.disCNS.titledefault + BDFDB.disCN.cursordefault,
|
||||
children: [
|
||||
"Right-Click on an Icon to toggle",
|
||||
BDFDB.ReactUtils.createElement("span", {
|
||||
className: "type-label",
|
||||
style: {backgroundColor: BDFDB.DiscordConstants.Colors.STATUS_GREEN},
|
||||
children: "Desktop"
|
||||
}),
|
||||
"Notifications for that User:"
|
||||
]
|
||||
}));
|
||||
items.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsList, {
|
||||
className: BDFDB.disCN.margintop20,
|
||||
title: "type",
|
||||
settings: Object.keys(this.defaults.notificationstrings),
|
||||
data: users,
|
||||
renderLabel: data => [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Avatar, {
|
||||
className: BDFDB.DOMUtils.formatClassName("settings-avatar", data.disabled && "disabled", data.destop && "desktop"),
|
||||
src: BDFDB.UserUtils.getAvatar(data.user.id),
|
||||
status: BDFDB.UserUtils.getStatus(data.user.id),
|
||||
size: BDFDB.LibraryComponents.Avatar.Sizes.SIZE_40,
|
||||
onClick: (e, instance) => {
|
||||
changeNotificationType(type, data.user.id, false, !(data.disabled || data.desktop));
|
||||
},
|
||||
onContextMenu: (e, instance) => {
|
||||
changeNotificationType(type, data.user.id, true, !(data.disabled || !data.desktop));
|
||||
}
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
|
||||
children: data.user.username
|
||||
})
|
||||
],
|
||||
onHeaderClick: (config, instance) => {
|
||||
changeAllConfigs(type, config, true);
|
||||
},
|
||||
onHeaderContextMenu: (config, instance) => {
|
||||
changeAllConfigs(type, config, false);
|
||||
},
|
||||
onCheckboxChange: (value, instance) => {
|
||||
let data = BDFDB.DataUtils.load(this, type, instance.props.cardId) || this.createDefaultConfig();
|
||||
data[instance.props.settingId] = value;
|
||||
BDFDB.DataUtils.save(data, this, type, instance.props.cardId);
|
||||
this.SettingsUpdated = true;
|
||||
},
|
||||
noRemove: type == "friends",
|
||||
onRemove: (e, instance) => {
|
||||
BDFDB.DataUtils.remove(this, type, instance.props.cardId);
|
||||
this.SettingsUpdated = true;
|
||||
BDFDB.PluginUtils.refreshSettingsPanel(this, settingspanel, collapseStates);
|
||||
}
|
||||
}));
|
||||
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||
title: title,
|
||||
collapseStates: collapseStates,
|
||||
dividertop: true,
|
||||
children: items
|
||||
});
|
||||
};
|
||||
|
||||
let settings = BDFDB.DataUtils.get(this, "settings");
|
||||
let amounts = BDFDB.DataUtils.get(this, "amounts");
|
||||
let notificationstrings = BDFDB.DataUtils.get(this, "notificationstrings");
|
||||
let notificationsounds = BDFDB.DataUtils.get(this, "notificationsounds");
|
||||
let amounts = BDFDB.DataUtils.get(this, "amounts");
|
||||
|
||||
let friendIDs = BDFDB.LibraryModules.FriendUtils.getFriendIDs();
|
||||
let friends = BDFDB.DataUtils.load(this, "friends");
|
||||
let nonfriends = BDFDB.DataUtils.load(this, "nonfriends");
|
||||
|
||||
let settingshtml = `<div class="${this.name}-settings BDFDB-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.titlesize18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</div><div class="BDFDB-settings-inner">`;
|
||||
settingshtml += `<div class="${BDFDB.disCNS.h2 + BDFDB.disCNS.cursorpointer + BDFDB.disCNS.margintop4 + BDFDB.disCN.marginbottom4} BDFDB-containertext"><span class="BDFDB-containerarrow closed"></span>General Settings</div><div class="BDFDB-collapsecontainer">`;
|
||||
for (let key in settings) settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[key] ? " checked" : ""}></div></div>`;
|
||||
for (let key in amounts) if (key.indexOf("desktop") == -1 || "Notification" in window) settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCN.flexchild}" style="flex: 0 0 80%;">${this.defaults.amounts[key].description}</h3><div class="${BDFDB.disCN.inputwrapper} inputNumberWrapper ${BDFDB.disCNS.vertical}" style="flex: 1 1 auto;"><span class="numberinput-buttons-zone"><span class="numberinput-button-up"></span><span class="numberinput-button-down"></span></span><input type="number"${(!isNaN(this.defaults.amounts[key].min) && this.defaults.amounts[key].min !== null ? ' min="' + this.defaults.amounts[key].min + '"' : '') + (!isNaN(this.defaults.amounts[key].max) && this.defaults.amounts[key].max !== null ? ' max="' + this.defaults.amounts[key].max + '"' : '')} option="${key}" value="${amounts[key]}" class="${BDFDB.disCNS.inputdefault + BDFDB.disCNS.input + BDFDB.disCN.titlesize16} amount-input"></div></div>`;
|
||||
settingshtml += `</div><div class="${BDFDB.disCNS.divider + BDFDB.disCN.marginbottom4}"></div>`;
|
||||
settingshtml += `<div class="${BDFDB.disCNS.h2 + BDFDB.disCNS.cursorpointer + BDFDB.disCNS.margintop4 + BDFDB.disCN.marginbottom4} BDFDB-containertext"><span class="BDFDB-containerarrow closed"></span>Friend-List</div><div class="BDFDB-collapsecontainer">`;
|
||||
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 0 0 auto;">Click on an Icon to toggle <label class="type-toast">Toast</label> Notifications for that User:</h3></div>`;
|
||||
if ("Notification" in window) settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 0 0 auto;">Rightclick on an Icon to toggle <label class="type-desktop">Desktop</label> Notifications for that User:</h3></div>`;
|
||||
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 0 0 auto;">Click/Rightclick on the table headers to batch set all Friends</h3></div>`;
|
||||
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8} BDFDB-tableheader" table-id="friends" style="flex: 0 0 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild} BDFDB-tableheadertext"><div class="${BDFDB.disCNS.margintop8 + BDFDB.disCNS.settingstableheadersize + BDFDB.disCNS.titlesize10 + BDFDB.disCNS.primary + BDFDB.disCNS.weightbold + BDFDB.disCN.cursorpointer} btn-batch" group="friends" config="desktop" style="display: inline-block; margin: 0 25px;">TYPE</div><div class="${BDFDB.disCNS.margintop8 + BDFDB.disCNS.settingstableheadersize + BDFDB.disCNS.titlesize10 + BDFDB.disCNS.primary + BDFDB.disCNS.weightbold + BDFDB.disCN.cursorpointer} btn-batch" group="friends" config="disabled" style="display: inline-block;">DISABLE</div></h3><div class="${BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifycenter + BDFDB.disCNS.alignend + BDFDB.disCN.nowrap} BDFDB-tableheadercolumns">`;
|
||||
for (let config in this.defaults.notificationstrings) settingshtml += `<div class="${BDFDB.disCNS.margintop8 + BDFDB.disCNS.settingstableheadersize + BDFDB.disCNS.titlesize10 + BDFDB.disCNS.primary + BDFDB.disCNS.weightbold + BDFDB.disCN.cursorpointer} BDFDB-tableheadercolumn" config="${config}" group="friends">${config.toUpperCase()}</div>`;
|
||||
settingshtml += `</div></div><div class="BDFDB-settings-inner-list friend-list ${BDFDB.disCN.marginbottom8}">`;
|
||||
let friendsData = BDFDB.DataUtils.load(this, "friends"), nonFriendsData = BDFDB.DataUtils.load(this, "nonfriends");
|
||||
let friends = [], nonFriends = [];
|
||||
|
||||
let settingspanel, settingsitems = [], inneritems = [];
|
||||
|
||||
for (let id of friendIDs) {
|
||||
let user = BDFDB.LibraryModules.UserStore.getUser(id);
|
||||
if (user) {
|
||||
let friend = null;
|
||||
if (friends[id]) {}
|
||||
else if (nonfriends[id]) {
|
||||
friends[id] = Object.assign({}, nonfriends[id]);
|
||||
delete nonfriends[id];
|
||||
}
|
||||
else friends[id] = this.createDefaultConfig();
|
||||
settingshtml += this.createHoverCard(user, friends[id], "friends");
|
||||
friendsData[id] = Object.assign({}, friendsData[id] || nonFriendsData[id] || this.createDefaultConfig());
|
||||
delete nonFriendsData[id];
|
||||
}
|
||||
}
|
||||
for (let id in friends) if (!friendIDs.includes(id)) {
|
||||
for (let id in friendsData) {
|
||||
let user = BDFDB.LibraryModules.UserStore.getUser(id);
|
||||
if (user) {
|
||||
nonfriends[id] = Object.assign({}, friends[id]);
|
||||
delete friends[id];
|
||||
settingshtml += this.createHoverCard(user, friends[id] || (friends[id] = this.createDefaultConfig()), "friends");
|
||||
}
|
||||
}
|
||||
settingshtml += `</div>`;
|
||||
settingshtml += `</div><div class="${BDFDB.disCNS.divider + BDFDB.disCN.marginbottom4}"></div>`;
|
||||
settingshtml += `<div class="${BDFDB.disCNS.h2 + BDFDB.disCNS.cursorpointer + BDFDB.disCNS.margintop4 + BDFDB.disCN.marginbottom4} BDFDB-containertext"><span class="BDFDB-containerarrow closed"></span>Non-Friend-List</div><div class="BDFDB-collapsecontainer">`;
|
||||
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 0 0 auto;">Click on a Icon to toggle <label class="type-toast">Toast</label> Notifications for that User:</h3></div>`;
|
||||
if ("Notification" in window) settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 0 0 auto;">Rightclick on a Icon to toggle <label class="type-desktop">Desktop</label> Notifications for that User:</h3></div>`;
|
||||
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 0 0 auto;">Click/Rightclick on the table headers to batch set all Non-Friends</h3></div>`;
|
||||
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCN.flexchild}" style="flex: 0 0 50%;">Add Non-Friend:</h3><div class="${BDFDB.disCNS.inputwrapper + BDFDB.disCNS.vertical + BDFDB.disCNS.flex2 + BDFDB.disCN.directioncolumn}" style="flex: 1 1 auto;"><input type="text" value="" placeholder="UserID" class="${BDFDB.disCNS.inputdefault + BDFDB.disCNS.input + BDFDB.disCN.titlesize16}" id="input-userid"></div><button type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} btn-add btn-adduser" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}"></div></button></div>`;
|
||||
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8} BDFDB-tableheader" table-id="nonfriends" style="flex: 0 0 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild} BDFDB-tableheadertext"><div class="${BDFDB.disCNS.margintop8 + BDFDB.disCNS.settingstableheadersize + BDFDB.disCNS.titlesize10 + BDFDB.disCNS.primary + BDFDB.disCNS.weightbold + BDFDB.disCN.cursorpointer} btn-batch" group="nonfriends" config="desktop" style="display: inline-block; margin: 0 25px;">TYPE</div><div class="${BDFDB.disCNS.margintop8 + BDFDB.disCNS.settingstableheadersize + BDFDB.disCNS.titlesize10 + BDFDB.disCNS.primary + BDFDB.disCNS.weightbold + BDFDB.disCN.cursorpointer} btn-batch" group="nonfriends" config="disabled" style="display: inline-block;">DISABLE</div></h3><div class="${BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifycenter + BDFDB.disCNS.alignend + BDFDB.disCN.nowrap} BDFDB-tableheadercolumns">`;
|
||||
for (let config in this.defaults.notificationstrings) settingshtml += `<div class="${BDFDB.disCNS.margintop8 + BDFDB.disCNS.settingstableheadersize + BDFDB.disCNS.titlesize10 + BDFDB.disCNS.primary + BDFDB.disCNS.weightbold + BDFDB.disCN.cursorpointer} BDFDB-tableheadercolumn" config="${config}" group="nonfriends">${config.toUpperCase()}</div>`;
|
||||
settingshtml += `</div></div><div class="BDFDB-settings-inner-list nonfriend-list ${BDFDB.disCN.marginbottom8}">`;
|
||||
for (let id in nonfriends) if (!friendIDs.includes(id)) {
|
||||
let user = BDFDB.LibraryModules.UserStore.getUser(id);
|
||||
if (user) {
|
||||
delete friends[id];
|
||||
settingshtml += this.createHoverCard(user, nonfriends[id] || (nonfriends[id] = this.createDefaultConfig()), "nonfriends");
|
||||
}
|
||||
}
|
||||
settingshtml += `</div>`;
|
||||
settingshtml += `</div><div class="${BDFDB.disCNS.divider + BDFDB.disCN.marginbottom4}"></div>`;
|
||||
settingshtml += `<div class="${BDFDB.disCNS.h2 + BDFDB.disCNS.cursorpointer + BDFDB.disCNS.margintop4 + BDFDB.disCN.marginbottom4} BDFDB-containertext"><span class="BDFDB-containerarrow closed"></span>Timelog</div><div class="BDFDB-collapsecontainer">`;
|
||||
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom20}" style="flex: 0 0 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">Timelog of LogIns/-Outs:</h3><button type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} btn-timelog" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}">Timelog</div></button></div>`;
|
||||
settingshtml += `</div><div class="${BDFDB.disCNS.divider + BDFDB.disCN.marginbottom4}"></div>`;
|
||||
settingshtml += `<div class="${BDFDB.disCNS.h2 + BDFDB.disCNS.cursorpointer + BDFDB.disCNS.margintop4 + BDFDB.disCN.marginbottom4} BDFDB-containertext"><span class="BDFDB-containerarrow closed"></span>Notification Message Settings</div><div class="BDFDB-collapsecontainer">`;
|
||||
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}">Allows you to configure your own message strings for the different statuses. <strong>$user</strong> is the placeholder for the username, <strong>$status</strong> for the statusname, <strong>$game</strong> for the gamename, <strong>$song</strong> for the songname and <strong>$artist</strong> for the songartist.</h3></div>`;
|
||||
for (let config in notificationstrings) {
|
||||
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCN.flexchild}" style="flex: 0 0 30%;">${config.charAt(0).toUpperCase() + config.slice(1)} Message:</h3><div class="${BDFDB.disCNS.inputwrapper + BDFDB.disCNS.vertical + BDFDB.disCNS.flex2 + BDFDB.disCN.directioncolumn}" style="flex: 1 1 auto;"><input type="text" config="${config}" value="${notificationstrings[config]}" placeholder="${this.defaults.notificationstrings[config].value}" class="${BDFDB.disCNS.inputdefault + BDFDB.disCNS.input + BDFDB.disCN.titlesize16} input-notificationstring"></div></div>`;
|
||||
}
|
||||
settingshtml += `</div><div class="${BDFDB.disCNS.divider + BDFDB.disCN.marginbottom4}"></div>`;
|
||||
settingshtml += `<div class="${BDFDB.disCNS.h2 + BDFDB.disCNS.cursorpointer + BDFDB.disCNS.margintop4 + BDFDB.disCN.marginbottom4} BDFDB-containertext"><span class="BDFDB-containerarrow closed"></span>Notification Sound Settings</div><div class="BDFDB-collapsecontainer">`;
|
||||
for (let config in notificationsounds) if (config.indexOf("desktop") == -1 || "Notification" in window) settingshtml += `<div class="${BDFDB.disCNS.flexchild + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h5 class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.h5 + BDFDB.disCNS.title + BDFDB.disCNS.titlesize12 + BDFDB.disCNS.height16 + BDFDB.disCNS.weightsemibold + BDFDB.disCNS.h5defaultmargin}" style="flex: 1 1 auto;">${config} notification sound:</h5><h5 class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.h5 + BDFDB.disCNS.title + BDFDB.disCNS.titlesize12 + BDFDB.disCNS.height16 + BDFDB.disCNS.weightsemibold + BDFDB.disCNS.h5defaultmargin}" style="flex: 0 0 auto;">Mute:</h5><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" config="${config}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} mute-checkbox"${notificationsounds[config].mute ? " checked" : ""}></div></div><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCN.nowrap}" style="flex: 1 1 auto;"><div class="${BDFDB.disCNS.inputwrapper + BDFDB.disCNS.vertical + BDFDB.disCNS.flex2 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;"><input type="text" config="${config}" value="${notificationsounds[config].url ? notificationsounds[config].url : ""}" placeholder="Url or Filepath" class="${BDFDB.disCNS.inputdefault + BDFDB.disCNS.input + BDFDB.disCN.titlesize16}"></div><button type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} file-navigator" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}"></div><input type="file" accept="audio/*,video/*" style="display:none!important;"></button><button type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} btn-save btn-savesong" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}"></div></button></div></div>`;
|
||||
settingshtml += `</div>`;
|
||||
settingshtml += `</div></div>`;
|
||||
|
||||
BDFDB.DataUtils.save(friends, this, "friends");
|
||||
BDFDB.DataUtils.save(nonfriends, this, "nonfriends");
|
||||
|
||||
let settingspanel = BDFDB.DOMUtils.create(settingshtml);
|
||||
|
||||
BDFDB.initElements(settingspanel, this);
|
||||
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "keyup", ".input-notificationstring", e => {this.saveNotificationString(e.currentTarget);});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", ".btn-savesong", e => {this.saveNotificationSound(e.currentTarget.parentElement.querySelector(BDFDB.dotCN.input));});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", ".mute-checkbox", e => {
|
||||
let config = e.currentTarget.getAttribute("config");
|
||||
if (config) {
|
||||
let notificationsound = BDFDB.DataUtils.get(this, "notificationsounds", config);
|
||||
notificationsound.mute = e.currentTarget.checked;
|
||||
BDFDB.DataUtils.save(notificationsound, this, "notificationsounds", config);
|
||||
}
|
||||
});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", ".settings-avatar", e => {
|
||||
this.changeNotificationType(e.currentTarget, false, !BDFDB.DOMUtils.containsClass(e.currentTarget, "disabled", "desktop", false));
|
||||
});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "contextmenu", ".settings-avatar", e => {
|
||||
if (!("Notification" in window)) return;
|
||||
this.changeNotificationType(e.currentTarget, true, !(BDFDB.DOMUtils.containsClass(e.currentTarget, "disabled") || !BDFDB.DOMUtils.containsClass(e.currentTarget, "desktop")));
|
||||
});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", ".btn-batch", e => {
|
||||
this.changeAllNotificationTypes(settingspanel, e.currentTarget, true);
|
||||
});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "contextmenu", ".btn-batch", e => {
|
||||
this.changeAllNotificationTypes(settingspanel, e.currentTarget, false);
|
||||
});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", BDFDB.dotCN.checkboxinput, e => {
|
||||
if (BDFDB.DOMUtils.containsClass(e.target, "remove-user")) return;
|
||||
this.changeNotificationConfig(e.currentTarget);
|
||||
});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", ".BDFDB-tableheadercolumn", e => {
|
||||
this.changeAllNotificationConfigs(settingspanel, e.currentTarget, true);
|
||||
});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "contextmenu", ".BDFDB-tableheadercolumn", e => {
|
||||
this.changeAllNotificationConfigs(settingspanel, e.currentTarget, false);
|
||||
});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", ".remove-user", e => {
|
||||
let id = e.currentTarget.getAttribute("user-id");
|
||||
let group = e.currentTarget.getAttribute("group");
|
||||
if (id && group) {
|
||||
BDFDB.DataUtils.remove(this, group, id);
|
||||
BDFDB.DOMUtils.remove(BDFDB.DOMUtils.getParent(BDFDB.dotCN.hovercard, e.currentTarget));
|
||||
this.SettingsUpdated = true;
|
||||
}
|
||||
});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", ".btn-adduser", e => {
|
||||
let idinput = settingspanel.querySelector("#input-userid");
|
||||
let id = idinput.value;
|
||||
idinput.value = "";
|
||||
if (friendIDs.includes(id)) BDFDB.NotificationUtils.toast("User is already a friend of yours. Please use the 'Friends' area to configure him/her.", {type:"error"});
|
||||
else if (BDFDB.DataUtils.load(this, "nonfriends", id)) BDFDB.NotificationUtils.toast("User is already being observed as a 'Non-Friend'.", {type:"error"});
|
||||
else {
|
||||
let user = BDFDB.LibraryModules.UserStore.getUser(id);
|
||||
if (user) {
|
||||
let data = this.createDefaultConfig();
|
||||
BDFDB.DataUtils.save(data, this, "nonfriends", user.id);
|
||||
let hovercard = BDFDB.DOMUtils.create(this.createHoverCard(user, data, "nonfriends"));
|
||||
settingspanel.querySelector(".nonfriend-list").appendChild(hovercard);
|
||||
BDFDB.initElements(hovercard);
|
||||
this.SettingsUpdated = true;
|
||||
if (!friendIDs.includes(id)) {
|
||||
nonFriendsData[id] = Object.assign({}, friendsData[id]);
|
||||
delete friendsData[id];
|
||||
}
|
||||
else if (/.+#[0-9]{4}/.test(id)) BDFDB.NotificationUtils.toast("A UserID does not consist of the username and discriminator.", {type:"error"});
|
||||
else BDFDB.NotificationUtils.toast("Please enter a valid UserID of a user that has been loaded in your client.", {type:"error"});
|
||||
else friends.push(Object.assign({}, friendsData[id], {key:id, user, className: friendsData[id].disabled ? "" : (friendsData[id].desktop ? BDFDB.disCN.cardsuccessoutline : BDFDB.disCN.cardbrandoutline)}));
|
||||
}
|
||||
});
|
||||
BDFDB.ListenerUtils.add(this, settingspanel, "click", ".btn-timelog", _ => {this.showTimeLog();});
|
||||
}
|
||||
for (let id in nonFriendsData) {
|
||||
let user = BDFDB.LibraryModules.UserStore.getUser(id);
|
||||
if (user) nonFriends.push(Object.assign({}, nonFriendsData[id], {key:id, user, className: nonFriendsData[id].disabled ? "" : (nonFriendsData[id].desktop ? BDFDB.disCN.cardsuccessoutline : BDFDB.disCN.cardbrandoutline)}));
|
||||
}
|
||||
|
||||
return settingspanel;
|
||||
BDFDB.DataUtils.save(friendsData, this, "friends");
|
||||
BDFDB.DataUtils.save(nonFriendsData, this, "nonfriends");
|
||||
|
||||
for (let key in settings) inneritems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
className: BDFDB.disCN.marginbottom8,
|
||||
type: "Switch",
|
||||
plugin: this,
|
||||
keys: ["settings", key],
|
||||
label: this.defaults.settings[key].description,
|
||||
value: settings[key]
|
||||
}));
|
||||
for (let key in amounts) if (key.indexOf("desktop") == -1 || "Notification" in window) inneritems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
className: BDFDB.disCN.marginbottom8,
|
||||
type: "TextInput",
|
||||
childProps: {
|
||||
type: "number"
|
||||
},
|
||||
plugin: this,
|
||||
keys: ["amounts", key],
|
||||
label: this.defaults.amounts[key].description,
|
||||
basis: "20%",
|
||||
min: this.defaults.amounts[key].min,
|
||||
max: this.defaults.amounts[key].max,
|
||||
value: amounts[key]
|
||||
}));
|
||||
settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||
title: "Settings",
|
||||
collapseStates: collapseStates,
|
||||
children: inneritems
|
||||
}));
|
||||
|
||||
if (friends.length) settingsitems.push(createUserList(friends, "friends", "Friend-List"));
|
||||
settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||
title: "Add new Stranger",
|
||||
collapseStates: collapseStates,
|
||||
dividertop: true,
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
||||
className: BDFDB.disCN.margintop8,
|
||||
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||
className: `input-newstranger`,
|
||||
placeholder: "userId",
|
||||
value: ""
|
||||
})
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, {
|
||||
onClick: _ => {
|
||||
let userId = settingspanel.querySelector(`.input-newstranger ` + BDFDB.dotCN.input).value.trim();
|
||||
if (friendIDs.includes(userId)) BDFDB.NotificationUtils.toast("User is already a friend of yours. Please use the 'Friend-List' area to configure him/her.", {type:"error"});
|
||||
else if (Object.keys(nonFriends).includes(userId)) BDFDB.NotificationUtils.toast("User is already being observed as a 'Stranger'.", {type:"error"});
|
||||
else {
|
||||
let user = BDFDB.LibraryModules.UserStore.getUser(userId);
|
||||
if (user) {
|
||||
BDFDB.DataUtils.save(this.createDefaultConfig(), this, "nonfriends", userId);
|
||||
this.SettingsUpdated = true;
|
||||
BDFDB.PluginUtils.refreshSettingsPanel(this, settingspanel, collapseStates);
|
||||
}
|
||||
else if (/.+#[0-9]{4}/.test(userId)) BDFDB.NotificationUtils.toast("A UserID does not consist of the username and discriminator.", {type:"error"});
|
||||
else BDFDB.NotificationUtils.toast("Please enter a valid UserID of a user that has been loaded in your client.", {type:"error"});
|
||||
}
|
||||
},
|
||||
children: BDFDB.LanguageUtils.LanguageStrings.ADD
|
||||
})
|
||||
]
|
||||
})
|
||||
}));
|
||||
if (nonFriends.length) settingsitems.push(createUserList(nonFriends, "nonfriends", "Stranger-List"));
|
||||
|
||||
settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||
title: "LogIn/-Out Timelog",
|
||||
collapseStates: collapseStates,
|
||||
dividertop: true,
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
||||
type: "Button",
|
||||
className: BDFDB.disCN.marginbottom8,
|
||||
label: "Overview of LogIns/-Outs of current Session",
|
||||
onClick: _ => {this.showTimeLog()},
|
||||
children: "Timelog"
|
||||
})
|
||||
}));
|
||||
settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||
title: "Notification Messages",
|
||||
collapseStates: collapseStates,
|
||||
dividertop: true,
|
||||
children: [BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
||||
className: BDFDB.disCN.marginbottom8,
|
||||
children: BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCNS.titledefault + BDFDB.disCN.cursordefault,
|
||||
children: [
|
||||
"Allows you to configure your own message strings for the different statuses. ",
|
||||
BDFDB.ReactUtils.createElement("strong", {children: "$user"}),
|
||||
" is the placeholder for the username, ",
|
||||
BDFDB.ReactUtils.createElement("strong", {children: "$status"}),
|
||||
" for the statusname, ",
|
||||
BDFDB.ReactUtils.createElement("strong", {children: "$game"}),
|
||||
" for the gamename, ",
|
||||
BDFDB.ReactUtils.createElement("strong", {children: "$song"}),
|
||||
" for the songname and ",
|
||||
BDFDB.ReactUtils.createElement("strong", {children: "$artist"}),
|
||||
" for the songartist."
|
||||
]
|
||||
})
|
||||
})].concat(Object.keys(notificationstrings).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
className: BDFDB.disCN.marginbottom8,
|
||||
type: "TextInput",
|
||||
plugin: this,
|
||||
keys: ["notificationstrings", key],
|
||||
placeholder: this.defaults.notificationstrings[key].value,
|
||||
label: `${BDFDB.LibraryModules.StringUtils.upperCaseFirstChar(key)} Message:`,
|
||||
basis: "70%",
|
||||
value: notificationstrings[key]
|
||||
})))
|
||||
}));
|
||||
settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||
title: "Notification Sounds",
|
||||
collapseStates: collapseStates,
|
||||
dividertop: true,
|
||||
children: Object.keys(notificationsounds).map((key, i) => (key.indexOf("desktop") == -1 || "Notification" in window) && [
|
||||
i != 0 && key.indexOf("toast") == 0 && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||
className: BDFDB.disCN.marginbottom8
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
||||
className: BDFDB.disCN.marginbottom8,
|
||||
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
|
||||
direction: BDFDB.LibraryComponents.Flex.Direction.HORIZONTAL,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsLabel, {
|
||||
label: `${key.split(/(desktop)|(toast)/).filter(n => n).map(n => BDFDB.LibraryModules.StringUtils.upperCaseFirstChar(n)).join("-")} Notification Sound:`,
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
||||
type: "Switch",
|
||||
mini: true,
|
||||
grow: 0,
|
||||
label: "Mute:",
|
||||
value: notificationsounds[key].mute,
|
||||
onChange: value => {
|
||||
notificationsounds[key].mute = value;
|
||||
BDFDB.DataUtils.save(notificationsounds, this, "notificationsounds");
|
||||
}
|
||||
})
|
||||
].filter(n => n)
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
||||
className: BDFDB.disCN.marginbottom8,
|
||||
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||
className: `input-${key}src`,
|
||||
type: "file",
|
||||
filter: ["audio", "video"],
|
||||
useFilePath: true,
|
||||
placeholder: "Url or Filepath",
|
||||
value: notificationsounds[key].url
|
||||
})
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, {
|
||||
onClick: _ => {
|
||||
let source = settingspanel.querySelector(`.input-${key}src ` + BDFDB.dotCN.input).value.trim();
|
||||
if (!source.length) {
|
||||
BDFDB.NotificationUtils.toast(`Sound file was removed.`, {type:"warn"});
|
||||
successSavedAudio(key, source, source);
|
||||
}
|
||||
else if (source.indexOf("http") == 0) BDFDB.LibraryRequires.request(source, (error, response, result) => {
|
||||
if (response) {
|
||||
let type = response.headers["content-type"];
|
||||
if (type && (type.indexOf("octet-stream") > -1 || type.indexOf("audio") > -1 || type.indexOf("video") > -1)) {
|
||||
successSavedAudio(key, source, source);
|
||||
return;
|
||||
}
|
||||
}
|
||||
BDFDB.NotificationUtils.toast("Use a valid direct link to a video or audio source. They usually end on something like .mp3, .mp4 or .wav.", {type:"danger"});
|
||||
});
|
||||
else BDFDB.LibraryRequires.fs.readFile(source, (error, response) => {
|
||||
if (error) BDFDB.NotificationUtils.toast("Could not fetch file. Please make sure the file exists.", {type:"danger"});
|
||||
else successSavedAudio(key, source, `data:audio/mpeg;base64,${response.toString("base64")}`);
|
||||
});
|
||||
},
|
||||
children: BDFDB.LanguageUtils.LanguageStrings.SAVE
|
||||
})
|
||||
]
|
||||
})
|
||||
]).flat(10).filter(n => n)
|
||||
}));
|
||||
|
||||
return settingspanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsitems);
|
||||
}
|
||||
|
||||
//legacy
|
||||
|
@ -343,123 +457,6 @@ class FriendNotifications {
|
|||
|
||||
// begin of own functions
|
||||
|
||||
createHoverCard (user, data, group) {
|
||||
let EUdata = BDFDB.DataUtils.load("EditUsers", "users", user.id) || {};
|
||||
var hovercardhtml = `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.vertical + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCNS.margintop4 + BDFDB.disCNS.marginbottom4 + BDFDB.disCN.hovercard}"><div class="${BDFDB.disCN.hovercardinner}"><div class="settings-avatar${data.desktop ? " desktop" : ""}${data.disabled ? " disabled" : ""}" group="${group}" user-id="${user.id}" style="flex: 0 0 auto; background-image: url(${EUdata.removeIcon ? "" : (EUdata.url ? EUdata.url : BDFDB.UserUtils.getAvatar(user.id))});"></div><div class="BDFDB-textscrollwrapper" style="flex: 1 1 auto;"><div class="BDFDB-textscroll">${BDFDB.StringUtils.htmlEscape(EUdata.name || user.username)}</div></div>`;
|
||||
for (let config in this.defaults.notificationstrings) {
|
||||
hovercardhtml += `<div class="${BDFDB.disCNS.checkboxcontainer + BDFDB.disCN.marginreset} BDFDB-tablecheckbox" table-id="${group}" style="flex: 0 0 auto;"><label class="${BDFDB.disCN.checkboxwrapper}"><input user-id="${user.id}" group="${group}" config="${config}" type="checkbox" class="${BDFDB.disCN.checkboxinputdefault}"${data[config] ? " checked" : ""}><div class="${BDFDB.disCNS.checkbox + BDFDB.disCNS.flexcenter + BDFDB.disCNS.flex2 + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCN.checkboxround}"><svg name="Checkmark" width="18" height="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><polyline stroke="transparent" stroke-width="2" points="3.5 9.5 7 13 15 5"></polyline></g></svg></div></label></div>`;
|
||||
}
|
||||
return hovercardhtml + `</div>${group == "nonfriends" ? `<div class="${BDFDB.disCN.hovercardbutton} remove-user" group="${group}" user-id="${user.id}"></div>` : ''}</div>`
|
||||
}
|
||||
|
||||
changeNotificationType (avatar, desktopon, disableon) {
|
||||
let id = avatar.getAttribute("user-id");
|
||||
let group = avatar.getAttribute("group");
|
||||
if (id && group) {
|
||||
let data = BDFDB.DataUtils.load(this, group, id) || this.createDefaultConfig();
|
||||
data.desktop = desktopon;
|
||||
data.disabled = disableon;
|
||||
BDFDB.DOMUtils.toggleClass(avatar, "desktop", desktopon);
|
||||
BDFDB.DOMUtils.toggleClass(avatar, "disabled", disableon);
|
||||
BDFDB.DataUtils.save(data, this, group, id);
|
||||
this.SettingsUpdated = true;
|
||||
}
|
||||
}
|
||||
|
||||
changeAllNotificationTypes (settingspanel, tableheader, enable) {
|
||||
let config = tableheader.getAttribute("config");
|
||||
let group = tableheader.getAttribute("group");
|
||||
if (config && group) {
|
||||
let data = BDFDB.DataUtils.load(this, group);
|
||||
if (config == "desktop") {
|
||||
enable = !enable;
|
||||
for (let id in data) data[id].disabled = false;
|
||||
for (let avatar of settingspanel.querySelectorAll(`.settings-avatar[group="${group}"]`)) BDFDB.DOMUtils.removeClass(avatar, "disabled");
|
||||
}
|
||||
for (let id in data) data[id][config] = enable;
|
||||
for (let avatar of settingspanel.querySelectorAll(`.settings-avatar[group="${group}"]`)) BDFDB.DOMUtils.toggleClass(avatar, config, enable);
|
||||
BDFDB.DataUtils.save(data, this, group);
|
||||
this.SettingsUpdated = true;
|
||||
}
|
||||
}
|
||||
|
||||
changeNotificationConfig (checkbox) {
|
||||
let id = checkbox.getAttribute("user-id");
|
||||
let config = checkbox.getAttribute("config");
|
||||
let group = checkbox.getAttribute("group");
|
||||
if (id && config && group) {
|
||||
let data = BDFDB.DataUtils.load(this, group, id) || this.createDefaultConfig();
|
||||
data[config] = checkbox.checked;
|
||||
BDFDB.DataUtils.save(data, this, group, id);
|
||||
this.SettingsUpdated = true;
|
||||
}
|
||||
}
|
||||
|
||||
changeAllNotificationConfigs (settingspanel, tableheader, enable) {
|
||||
let config = tableheader.getAttribute("config");
|
||||
let group = tableheader.getAttribute("group");
|
||||
if (config && group) {
|
||||
let data = BDFDB.DataUtils.load(this, group);
|
||||
for (let id in data) data[id][config] = enable;
|
||||
BDFDB.DataUtils.save(data, this, group);
|
||||
for (let checkbox of settingspanel.querySelectorAll(`${BDFDB.dotCN.checkboxinput}[config="${config}"][group="${group}"]`)) {
|
||||
checkbox.checked = enable;
|
||||
if (typeof checkbox.BDFDBupdateElement == "function") checkbox.BDFDBupdateElement();
|
||||
}
|
||||
this.SettingsUpdated = true;
|
||||
}
|
||||
}
|
||||
|
||||
createDefaultConfig () {
|
||||
return Object.assign({desktop: false, disabled: BDFDB.DataUtils.get(this, "settings", "disableForNew")}, BDFDB.ObjectUtils.map(this.defaults.notificationstrings, "init"));
|
||||
}
|
||||
|
||||
saveNotificationString (input) {
|
||||
let config = input.getAttribute("config");
|
||||
if (config) {
|
||||
BDFDB.DataUtils.save(input.value, this, "notificationstrings", config);
|
||||
this.SettingsUpdated = true;
|
||||
}
|
||||
}
|
||||
|
||||
saveNotificationSound (input) {
|
||||
let config = input.getAttribute("config");
|
||||
if (config) {
|
||||
let successSavedAudio = (parsedurl, parseddata) => {
|
||||
if (parsedurl && parseddata) BDFDB.NotificationUtils.toast(`Sound was saved successfully.`, {type:"success"});
|
||||
let notificationsound = BDFDB.DataUtils.get(this, "notificationsounds", config);
|
||||
notificationsound.url = parsedurl;
|
||||
notificationsound.song = parseddata;
|
||||
BDFDB.DataUtils.save(notificationsound, this, "notificationsounds", config);
|
||||
this.SettingsUpdated = true;
|
||||
};
|
||||
|
||||
let url = input.value;
|
||||
if (url.length == 0) {
|
||||
BDFDB.NotificationUtils.toast(`Sound file was removed.`, {type:"warn"});
|
||||
successSavedAudio(url, url);
|
||||
}
|
||||
else if (url.indexOf("http") == 0) {
|
||||
BDFDB.LibraryRequires.request(url, (error, response, result) => {
|
||||
if (response) {
|
||||
let type = response.headers["content-type"];
|
||||
if (type && (type.indexOf("octet-stream") > -1 || type.indexOf("audio") > -1 || type.indexOf("video") > -1)) {
|
||||
successSavedAudio(url, url);
|
||||
return;
|
||||
}
|
||||
}
|
||||
BDFDB.NotificationUtils.toast("Use a valid direct link to a video or audio source. They usually end on something like .mp3, .mp4 or .wav.", {type:"danger"});
|
||||
});
|
||||
}
|
||||
else {
|
||||
BDFDB.LibraryRequires.fs.readFile(url, (error, response) => {
|
||||
if (error) BDFDB.NotificationUtils.toast("Could not fetch file. Please make sure the file exists.", {type:"danger"});
|
||||
else successSavedAudio(url, `data:audio/mpeg;base64,${response.toString("base64")}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onSettingsClosed () {
|
||||
if (this.SettingsUpdated) {
|
||||
delete this.SettingsUpdated;
|
||||
|
@ -467,6 +464,13 @@ class FriendNotifications {
|
|||
}
|
||||
}
|
||||
|
||||
createDefaultConfig () {
|
||||
return Object.assign({
|
||||
desktop: false,
|
||||
disabled: BDFDB.DataUtils.get(this, "settings", "disableForNew")
|
||||
}, BDFDB.ObjectUtils.map(this.defaults.notificationstrings, "init"));
|
||||
}
|
||||
|
||||
getStatusWithMobileAndActivity (id, config) {
|
||||
let statusname = BDFDB.UserUtils.getStatus(id);
|
||||
let status = {statusname, isactivity:false};
|
||||
|
@ -497,14 +501,28 @@ class FriendNotifications {
|
|||
let user = BDFDB.LibraryModules.UserStore.getUser(id);
|
||||
let status = this.getStatusWithMobileAndActivity(id, users[id]);
|
||||
if (user && this.userStatusStore[id] != status.statusname && users[id][status.statusname]) {
|
||||
let EUdata = BDFDB.DataUtils.load("EditUsers", "users", user.id) || {};
|
||||
let EUdata = BDFDB.BDUtils.isPluginEnabled("EditUsers") && BDFDB.DataUtils.load("EditUsers", "users", user.id) || {};
|
||||
let name = EUdata.name || user.username;
|
||||
let avatar = EUdata.removeIcon ? "" : (EUdata.url || BDFDB.UserUtils.getAvatar(user.id));
|
||||
let timestring = (new Date()).toLocaleString();
|
||||
|
||||
let libstring = (this.defaults.notificationstrings[status.statusname].libstring ? BDFDB.LanguageUtils.LanguageStrings[this.defaults.notificationstrings[status.statusname].libstring] : (this.defaults.notificationstrings[status.statusname].statusname || "")).toLowerCase();
|
||||
let string = notificationstrings[status.statusname] || "$user changed status to $status";
|
||||
let toaststring = BDFDB.StringUtils.htmlEscape(string).replace(/'{0,1}\$user'{0,1}/g, `<strong>${BDFDB.StringUtils.htmlEscape(EUdata.name || user.username)}</strong>`).replace(/'{0,1}\$status'{0,1}/g, `<strong>${libstring}</strong>`);
|
||||
let toaststring = BDFDB.StringUtils.htmlEscape(string).replace(/'{0,1}\$user'{0,1}/g, `<strong>${BDFDB.StringUtils.htmlEscape(name)}</strong>`).replace(/'{0,1}\$status'{0,1}/g, `<strong>${libstring}</strong>`);
|
||||
if (status.isactivity) toaststring = toaststring.replace(/'{0,1}\$song'{0,1}|'{0,1}\$game'{0,1}/g, `<strong>${status.name || status.details}</strong>`).replace(/'{0,1}\$artist'{0,1}/g, `<strong>${status.state}</strong>`);
|
||||
let avatar = EUdata.removeIcon ? "" : (EUdata.url ? EUdata.url : BDFDB.UserUtils.getAvatar(user.id));
|
||||
this.timeLog.push({string:toaststring, avatar, time: new Date()});
|
||||
if (!(settings.muteOnDND && BDFDB.UserUtils.getStatus() == "dnd")) {
|
||||
|
||||
this.timeLog.push({
|
||||
string: toaststring,
|
||||
avatar,
|
||||
name,
|
||||
status: BDFDB.UserUtils.getStatus(user.id),
|
||||
timestring
|
||||
});
|
||||
|
||||
if (!(settings.muteOnDND && BDFDB.UserUtils.getStatus() == "dnd") && (!this.lastTimes[user.id] || this.lastTimes[user.id] != timestring)) {
|
||||
|
||||
this.lastTimes[user.id] = timestring;
|
||||
|
||||
let openChannel = _ => {
|
||||
if (settings.openOnClick) {
|
||||
let DMid = BDFDB.LibraryModules.ChannelStore.getDMFromUserId(user.id)
|
||||
|
@ -526,7 +544,7 @@ class FriendNotifications {
|
|||
}
|
||||
}
|
||||
else {
|
||||
let desktopstring = string.replace(/\$user/g, EUdata.name || user.username).replace(/\$status/g, libstring);
|
||||
let desktopstring = string.replace(/\$user/g, name).replace(/\$status/g, libstring);
|
||||
if (status.isactivity) desktopstring = desktopstring.replace(/\$song|\$game/g, status.name || status.details).replace(/\$artist/g, status.state);
|
||||
let notificationsound = notificationsounds["desktop" + status.statusname] || {};
|
||||
BDFDB.NotificationUtils.desktop(desktopstring, {icon:avatar, timeout:desktoptime, click:openChannel, silent:notificationsound.mute, sound:notificationsound.song});
|
||||
|
@ -536,21 +554,44 @@ class FriendNotifications {
|
|||
this.userStatusStore[id] = status.statusname;
|
||||
}
|
||||
}, amounts.checkInterval * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
showTimeLog () {
|
||||
let timeLogModal = BDFDB.DOMUtils.create(this.timeLogModalMarkup);
|
||||
let container = timeLogModal.querySelector(".entries");
|
||||
if (!container) return;
|
||||
let logs = this.timeLog.slice(0).reverse();
|
||||
for (let log of logs) {
|
||||
if (container.childElementCount) container.appendChild(BDFDB.DOMUtils.create(`<div class="${BDFDB.disCNS.divider + BDFDB.disCN.marginbottom4}"></div>`));
|
||||
let entry = BDFDB.DOMUtils.create(this.logEntryMarkup);
|
||||
entry.querySelector(".log-time").innerText = `[${log.time.toLocaleTimeString()}]`;
|
||||
entry.querySelector(".log-avatar").style.setProperty("background-image", `url(${log.avatar})`);
|
||||
entry.querySelector(".log-description").innerHTML = log.string;
|
||||
container.appendChild(entry)
|
||||
}
|
||||
BDFDB.appendModal(timeLogModal);
|
||||
if (!this.timeLog.slice(0).length) BDFDB.NotificationUtils.toast("No logs saved yet", {type: "error"});
|
||||
else BDFDB.ModalUtils.open(this, {
|
||||
size: "MEDIUM",
|
||||
header: "LogIn/-Out Timelog",
|
||||
subheader: "",
|
||||
className: `${this.name}-Log-modal`,
|
||||
children: this.timeLog.slice(0).reverse().map((log, i) => [
|
||||
i > 0 ? BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||
className: BDFDB.disCNS.margintop8 + BDFDB.disCN.marginbottom8
|
||||
}) : null,
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
|
||||
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextElement, {
|
||||
color: BDFDB.LibraryComponents.TextElement.Colors.PRIMARY,
|
||||
className: "log-time",
|
||||
children: `[${log.timestring}]`
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Avatar, {
|
||||
className: "log-user",
|
||||
src: log.avatar,
|
||||
status: log.status,
|
||||
size: BDFDB.LibraryComponents.Avatar.Sizes.SIZE_40
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
|
||||
className: "log-content",
|
||||
speed: 1,
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextElement, {
|
||||
color: BDFDB.LibraryComponents.TextElement.Colors.PRIMARY,
|
||||
children: BDFDB.ReactUtils.elementToReact(BDFDB.DOMUtils.create(log.string))
|
||||
})
|
||||
})
|
||||
]
|
||||
})
|
||||
]).flat(10).filter(n => n)
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue