stuff
This commit is contained in:
parent
ce93c71621
commit
e05f7c88fe
|
@ -4084,7 +4084,8 @@
|
||||||
tableStickyHeader: "stickyHeader-JabwjW header-g67q9_",
|
tableStickyHeader: "stickyHeader-JabwjW header-g67q9_",
|
||||||
textScroller: "textScroller-dc9_kz",
|
textScroller: "textScroller-dc9_kz",
|
||||||
themedPopout: "themedPopout-1TrfdI",
|
themedPopout: "themedPopout-1TrfdI",
|
||||||
tooltipCustom: "tooltipCustom-hH39_Z"
|
tooltipCustom: "tooltipCustom-hH39_Z",
|
||||||
|
userInfoDate: "date-YN6TCS"
|
||||||
};
|
};
|
||||||
DiscordClassModules.BDrepo = {
|
DiscordClassModules.BDrepo = {
|
||||||
bdAddonCard: "bd-addon-card",
|
bdAddonCard: "bd-addon-card",
|
||||||
|
@ -4162,6 +4163,9 @@
|
||||||
profileNoteCounter: "profileNoteCounter-p0fWA_",
|
profileNoteCounter: "profileNoteCounter-p0fWA_",
|
||||||
uploadCounter: "uploadCounter-iEGQQk"
|
uploadCounter: "uploadCounter-iEGQQk"
|
||||||
};
|
};
|
||||||
|
DiscordClassModules.CreationDate = {
|
||||||
|
date: "creationDate-CJwdKT"
|
||||||
|
};
|
||||||
DiscordClassModules.DisplayLargeMessages = {
|
DiscordClassModules.DisplayLargeMessages = {
|
||||||
injectButton: "injectButton-8eKqGu"
|
injectButton: "injectButton-8eKqGu"
|
||||||
};
|
};
|
||||||
|
@ -4201,6 +4205,12 @@
|
||||||
modal: "imageModal-8J0ttB",
|
modal: "imageModal-8J0ttB",
|
||||||
operations: "operations-3V47CY"
|
operations: "operations-3V47CY"
|
||||||
};
|
};
|
||||||
|
DiscordClassModules.JoinedAtDate = {
|
||||||
|
date: "joinedAtDate-IawR02"
|
||||||
|
};
|
||||||
|
DiscordClassModules.LastMessageDate = {
|
||||||
|
date: "lastMessageDate-ocEw13"
|
||||||
|
};
|
||||||
DiscordClassModules.OldTitleBar = {
|
DiscordClassModules.OldTitleBar = {
|
||||||
oldTitleBarEnabled: "oldTitleBarEnabled-D8ppJQ",
|
oldTitleBarEnabled: "oldTitleBarEnabled-D8ppJQ",
|
||||||
settingsToolbar: "settingsToolbar-wu4yfQ",
|
settingsToolbar: "settingsToolbar-wu4yfQ",
|
||||||
|
@ -4537,6 +4547,7 @@
|
||||||
_charcounterpopoutnotecounter: ["CharCounter", "popoutNoteCounter"],
|
_charcounterpopoutnotecounter: ["CharCounter", "popoutNoteCounter"],
|
||||||
_charcounterprofilenotecounter: ["CharCounter", "profileNoteCounter"],
|
_charcounterprofilenotecounter: ["CharCounter", "profileNoteCounter"],
|
||||||
_charcounteruploadcounter: ["CharCounter", "uploadCounter"],
|
_charcounteruploadcounter: ["CharCounter", "uploadCounter"],
|
||||||
|
_creationdatedate: ["CreationDate", "date"],
|
||||||
_displaylargemessagesinjectbutton: ["DisplayLargeMessages", "injectButton"],
|
_displaylargemessagesinjectbutton: ["DisplayLargeMessages", "injectButton"],
|
||||||
_displayserversaschannelsbadge: ["DisplayServersAsChannels", "badge"],
|
_displayserversaschannelsbadge: ["DisplayServersAsChannels", "badge"],
|
||||||
_displayserversaschannelsname: ["DisplayServersAsChannels", "name"],
|
_displayserversaschannelsname: ["DisplayServersAsChannels", "name"],
|
||||||
|
@ -4545,6 +4556,7 @@
|
||||||
_emojistatisticsamountcell: ["EmojiStatistics", "amountCell"],
|
_emojistatisticsamountcell: ["EmojiStatistics", "amountCell"],
|
||||||
_emojistatisticsiconcell: ["EmojiStatistics", "iconCell"],
|
_emojistatisticsiconcell: ["EmojiStatistics", "iconCell"],
|
||||||
_emojistatisticsnamecell: ["EmojiStatistics", "nameCell"],
|
_emojistatisticsnamecell: ["EmojiStatistics", "nameCell"],
|
||||||
|
_friendnotificationsfriendsonline: ["FriendNotifications", "friendsOnline"],
|
||||||
_imagegallerydetails: ["ImageGallery", "details"],
|
_imagegallerydetails: ["ImageGallery", "details"],
|
||||||
_imagegallerydetailslabel: ["ImageGallery", "detailsLabel"],
|
_imagegallerydetailslabel: ["ImageGallery", "detailsLabel"],
|
||||||
_imagegallerydetailswrapper: ["ImageGallery", "detailsWrapper"],
|
_imagegallerydetailswrapper: ["ImageGallery", "detailsWrapper"],
|
||||||
|
@ -4557,7 +4569,8 @@
|
||||||
_imagezoomimagemodal: ["ImageZoom", "modal"],
|
_imagezoomimagemodal: ["ImageZoom", "modal"],
|
||||||
_imagezoomlense: ["ImageZoom", "lense"],
|
_imagezoomlense: ["ImageZoom", "lense"],
|
||||||
_imagezoomoperations: ["ImageZoom", "operations"],
|
_imagezoomoperations: ["ImageZoom", "operations"],
|
||||||
_friendnotificationsfriendsonline: ["FriendNotifications", "friendsOnline"],
|
_joinedatdatedate: ["JoinedAtDate", "date"],
|
||||||
|
_lastmessagedatedate: ["LastMessageDate", "date"],
|
||||||
_googletranslateoptionreversebutton: ["GoogleTranslateOption", "reverseButton"],
|
_googletranslateoptionreversebutton: ["GoogleTranslateOption", "reverseButton"],
|
||||||
_googletranslateoptiontranslatebutton: ["GoogleTranslateOption", "translateButton"],
|
_googletranslateoptiontranslatebutton: ["GoogleTranslateOption", "translateButton"],
|
||||||
_googletranslateoptiontranslated: ["GoogleTranslateOption", "translated"],
|
_googletranslateoptiontranslated: ["GoogleTranslateOption", "translated"],
|
||||||
|
@ -5916,6 +5929,7 @@
|
||||||
uploadmodal: ["UploadModal", "uploadModal"],
|
uploadmodal: ["UploadModal", "uploadModal"],
|
||||||
userinfo: ["UserInfo", "userInfo"],
|
userinfo: ["UserInfo", "userInfo"],
|
||||||
userinfoavatar: ["UserInfo", "avatar"],
|
userinfoavatar: ["UserInfo", "avatar"],
|
||||||
|
userinfodate: ["BDFDB", "userInfoDate"],
|
||||||
userinfodiscordtag: ["UserInfo", "discordTag"],
|
userinfodiscordtag: ["UserInfo", "discordTag"],
|
||||||
userinfodiscriminator: ["UserInfo", "discriminator"],
|
userinfodiscriminator: ["UserInfo", "discriminator"],
|
||||||
userinfohovered: ["UserInfo", "hovered"],
|
userinfohovered: ["UserInfo", "hovered"],
|
||||||
|
@ -9106,6 +9120,28 @@
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
${BDFDB.dotCNS.userpopout + BDFDB.dotCN.userpopoutheadertext} + ${BDFDB.dotCN.userinfodate},
|
||||||
|
${BDFDB.dotCNS.userprofile + BDFDB.dotCN.userprofilenametag} + ${BDFDB.dotCN.userinfodate} {
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
${BDFDB.dotCN.userinfodate} + ${BDFDB.dotCN.userpopoutcustomstatus} {
|
||||||
|
margin-top: 4px;
|
||||||
|
}
|
||||||
|
${BDFDB.dotCNS.themelight + BDFDB.dotCNS.userpopoutheadernormal + BDFDB.dotCN.userinfodate} {
|
||||||
|
color: #b9bbbe;
|
||||||
|
}
|
||||||
|
${BDFDB.dotCNS.themelight + BDFDB.dotCN.userpopoutheader + BDFDB.notCNS.userpopoutheadernormal + BDFDB.dotCN.userinfodate},
|
||||||
|
${BDFDB.dotCNS.themedark + BDFDB.dotCNS.userpopoutheader + BDFDB.dotCN.userinfodate} {
|
||||||
|
color: hsla(0,0%,100%,.6);
|
||||||
|
}
|
||||||
|
${BDFDB.dotCNS.themelight + BDFDB.dotCNS.userprofiletopsectionnormal + BDFDB.dotCN.userinfodate} {
|
||||||
|
color: hsla(216,4%,74%,.6);
|
||||||
|
}
|
||||||
|
${BDFDB.dotCN.themelight} [class*='topSection']${BDFDB.notCNS.userprofiletopsectionnormal + BDFDB.dotCN.userinfodate},
|
||||||
|
${BDFDB.dotCN.themedark} [class*='topSection'] ${BDFDB.dotCN.userinfodate} {
|
||||||
|
color: hsla(0,0%,100%,.6);
|
||||||
|
}
|
||||||
|
|
||||||
${BDFDB.dotCN.messageavatar + BDFDB.dotCN.bdfdbbadge} {
|
${BDFDB.dotCN.messageavatar + BDFDB.dotCN.bdfdbbadge} {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
overflow: visible;
|
overflow: visible;
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
var CompleteTimestamps = (_ => {
|
var CompleteTimestamps = (_ => {
|
||||||
var languages, currentMode;
|
var languages, currentMode;
|
||||||
var settings = {}, choices = {}, formats = {};
|
var settings = {}, choices = {}, formats = {}, amounts = {};
|
||||||
|
|
||||||
return class CompleteTimestamps {
|
return class CompleteTimestamps {
|
||||||
getName () {return "CompleteTimestamps";}
|
getName () {return "CompleteTimestamps";}
|
||||||
|
|
||||||
getVersion () {return "1.4.5";}
|
getVersion () {return "1.4.6";}
|
||||||
|
|
||||||
getAuthor () {return "DevilBro";}
|
getAuthor () {return "DevilBro";}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ var CompleteTimestamps = (_ => {
|
||||||
|
|
||||||
constructor () {
|
constructor () {
|
||||||
this.changelog = {
|
this.changelog = {
|
||||||
"fixed":[["Days Ago","Now properly shows the amount of days relative to the date instead of calculated from the amount of passed hours"]]
|
"added":[["Settings","Added upper limit for $daysago and new year short form placeholder"]]
|
||||||
};
|
};
|
||||||
|
|
||||||
this.patchedModules = {
|
this.patchedModules = {
|
||||||
|
@ -32,21 +32,24 @@ var CompleteTimestamps = (_ => {
|
||||||
initConstructor () {
|
initConstructor () {
|
||||||
this.defaults = {
|
this.defaults = {
|
||||||
settings: {
|
settings: {
|
||||||
showInChat: {value:true, description:"Replace Chat Timestamp with Complete Timestamp:"},
|
showInChat: {value:true, description:"Replace chat timestamp with complete timestamp"},
|
||||||
showInEmbed: {value:true, description:"Replace Embed Timestamp with Complete Timestamp:"},
|
showInEmbed: {value:true, description:"Replace embed timestamp with complete timestamp"},
|
||||||
changeForChat: {value:true, description:"Change the Time for the Chat Time Tooltips:"},
|
changeForChat: {value:true, description:"Change the time for the chat time tooltips"},
|
||||||
changeForEdit: {value:true, description:"Change the Time for the Edited Time Tooltips:"},
|
changeForEdit: {value:true, description:"Change the time for the edited time tooltips"},
|
||||||
displayTime: {value:true, description:"Display the Time in the Timestamp:"},
|
displayTime: {value:true, description:"Display the time in the timestamp"},
|
||||||
displayDate: {value:true, description:"Display the Date in the Timestamp:"},
|
displayDate: {value:true, description:"Display the date in the timestamp"},
|
||||||
cutSeconds: {value:false, description:"Cut off Seconds of the Time:"},
|
cutSeconds: {value:false, description:"Cut off seconds of the time"},
|
||||||
forceZeros: {value:false, description:"Force leading Zeros:"},
|
forceZeros: {value:false, description:"Force leading zeros"},
|
||||||
otherOrder: {value:false, description:"Show the Time before the Date:"}
|
otherOrder: {value:false, description:"Show the time before the date"}
|
||||||
},
|
},
|
||||||
choices: {
|
choices: {
|
||||||
creationDateLang: {value:"$discord", description:"Timestamp Format:"}
|
timestampLang: {value:"$discord", description:"Timestamp Format"}
|
||||||
},
|
},
|
||||||
formats: {
|
formats: {
|
||||||
ownformat: {value:"$hour:$minute:$second, $day.$month.$year", description:"Own Format:"}
|
ownFormat: {value:"$hour:$minute:$second, $day.$month.$year", description:"Own Format"}
|
||||||
|
},
|
||||||
|
amounts: {
|
||||||
|
maxDaysAgo: {value:0, min:0, description:"Maximum count of days displayed in the $daysago placeholder", note:"0 equals no limit"}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -143,6 +146,26 @@ var CompleteTimestamps = (_ => {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||||
|
className: BDFDB.disCN.marginbottom8
|
||||||
|
}));
|
||||||
|
|
||||||
|
for (let key in amounts) 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,
|
||||||
|
note: this.defaults.amounts[key].note,
|
||||||
|
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, {
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||||
title: "Format",
|
title: "Format",
|
||||||
collapseStates: collapseStates,
|
collapseStates: collapseStates,
|
||||||
|
@ -155,14 +178,15 @@ var CompleteTimestamps = (_ => {
|
||||||
collapseStates: collapseStates,
|
collapseStates: collapseStates,
|
||||||
dividertop: true,
|
dividertop: true,
|
||||||
children: [
|
children: [
|
||||||
"$hour will be replaced with the current hour",
|
"$hour will be replaced with the hour of the date",
|
||||||
"$minute will be replaced with the current minutes",
|
"$minute will be replaced with the minutes of the date",
|
||||||
"$second will be replaced with the current seconds",
|
"$second will be replaced with the seconds of the date",
|
||||||
"$msecond will be replaced with the current milliseconds",
|
"$msecond will be replaced with the milliseconds of the date",
|
||||||
"$timemode will change $hour to a 12h format and will be replaced with AM/PM",
|
"$timemode will change $hour to a 12h format and will be replaced with AM/PM",
|
||||||
"$year will be replaced with the current year",
|
"$year will be replaced with the year of the date",
|
||||||
"$month will be replaced with the current month",
|
"$yearS will be replaced with the year in short form",
|
||||||
"$day will be replaced with the current day",
|
"$month will be replaced with the month of the date",
|
||||||
|
"$day will be replaced with the day of the date",
|
||||||
"$monthnameL will be replaced with the monthname in long format based on the Discord Language",
|
"$monthnameL will be replaced with the monthname in long format based on the Discord Language",
|
||||||
"$monthnameS will be replaced with the monthname in short format based on the Discord Language",
|
"$monthnameS will be replaced with the monthname in short format based on the Discord Language",
|
||||||
"$weekdayL will be replaced with the weekday in long format based on the Discord Language",
|
"$weekdayL will be replaced with the weekday in long format based on the Discord Language",
|
||||||
|
@ -214,6 +238,20 @@ var CompleteTimestamps = (_ => {
|
||||||
}
|
}
|
||||||
}, BDFDB.LanguageUtils.languages);
|
}, BDFDB.LanguageUtils.languages);
|
||||||
|
|
||||||
|
// REMOVE 19.07.2020
|
||||||
|
let oldChoices = BDFDB.DataUtils.load(this, "choices");
|
||||||
|
if (oldChoices.creationDateLang) {
|
||||||
|
oldChoices.timestampLang = oldChoices.creationDateLang;
|
||||||
|
delete oldChoices.creationDateLang;
|
||||||
|
BDFDB.DataUtils.save(oldChoices, this, "choices");
|
||||||
|
}
|
||||||
|
let oldFormats = BDFDB.DataUtils.load(this, "formats");
|
||||||
|
if (oldFormats.ownformat) {
|
||||||
|
oldFormats.ownFormat = oldFormats.ownformat;
|
||||||
|
delete oldFormats.ownformat;
|
||||||
|
BDFDB.DataUtils.save(oldFormats, this, "formats");
|
||||||
|
}
|
||||||
|
|
||||||
this.forceUpdateAll();
|
this.forceUpdateAll();
|
||||||
}
|
}
|
||||||
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
|
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
|
||||||
|
@ -266,14 +304,14 @@ var CompleteTimestamps = (_ => {
|
||||||
processEmbed (e) {
|
processEmbed (e) {
|
||||||
if (e.instance.props.embed.timestamp && settings.showInEmbed) {
|
if (e.instance.props.embed.timestamp && settings.showInEmbed) {
|
||||||
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props:[["className", BDFDB.disCN.embedfootertext]]});
|
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props:[["className", BDFDB.disCN.embedfootertext]]});
|
||||||
if (index > -1 && BDFDB.ArrayUtils.is(children[index].props.children)) children[index].props.children.splice(children[index].props.children.length - 1, 1, this.getTimestamp(languages[choices.creationDateLang].id, e.instance.props.embed.timestamp._i));
|
if (index > -1 && BDFDB.ArrayUtils.is(children[index].props.children)) children[index].props.children.splice(children[index].props.children.length - 1, 1, this.getTimestamp(languages[choices.timestampLang].id, e.instance.props.embed.timestamp._i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
processSystemMessage (e) {
|
processSystemMessage (e) {
|
||||||
if (settings.showInChat) {
|
if (settings.showInChat) {
|
||||||
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "time"});
|
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "time"});
|
||||||
if (index > -1) children[index].props.children = this.getTimestamp(languages[choices.creationDateLang].id, e.instance.props.timestamp._i);
|
if (index > -1) children[index].props.children = this.getTimestamp(languages[choices.timestampLang].id, e.instance.props.timestamp._i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,7 +325,7 @@ var CompleteTimestamps = (_ => {
|
||||||
if (tooltipIndex > -1) tooltipWrapper = children[tooltipIndex];
|
if (tooltipIndex > -1) tooltipWrapper = children[tooltipIndex];
|
||||||
}
|
}
|
||||||
if (tooltipWrapper) {
|
if (tooltipWrapper) {
|
||||||
let timestamp = this.getTimestamp(languages[choices.creationDateLang].id, parent[index].props.timestamp._i);
|
let timestamp = this.getTimestamp(languages[choices.timestampLang].id, parent[index].props.timestamp._i);
|
||||||
if (change.tooltip) {
|
if (change.tooltip) {
|
||||||
tooltipWrapper.props.text = timestamp;
|
tooltipWrapper.props.text = timestamp;
|
||||||
tooltipWrapper.props.delay = 0;
|
tooltipWrapper.props.delay = 0;
|
||||||
|
@ -307,53 +345,54 @@ var CompleteTimestamps = (_ => {
|
||||||
}
|
}
|
||||||
|
|
||||||
getTimestamp (languageId, time) {
|
getTimestamp (languageId, time) {
|
||||||
let timeobj = time || new Date();
|
let timeObj = time || new Date();
|
||||||
if (typeof time == "string") timeobj = new Date(time);
|
if (typeof time == "string") timeObj = new Date(time);
|
||||||
if (timeobj.toString() == "Invalid Date") timeobj = new Date(parseInt(time));
|
if (timeObj.toString() == "Invalid Date") timeObj = new Date(parseInt(time));
|
||||||
if (timeobj.toString() == "Invalid Date") return;
|
if (timeObj.toString() == "Invalid Date") return;
|
||||||
let timestring = "";
|
let timeString = "";
|
||||||
if (languageId != "own") {
|
if (languageId != "own") {
|
||||||
let timestamp = [];
|
let timestamp = [];
|
||||||
if (settings.displayDate) timestamp.push(timeobj.toLocaleDateString(languageId));
|
if (settings.displayDate) timestamp.push(timeObj.toLocaleDateString(languageId));
|
||||||
if (settings.displayTime) timestamp.push(settings.cutSeconds ? this.cutOffSeconds(timeobj.toLocaleTimeString(languageId)) : timeobj.toLocaleTimeString(languageId));
|
if (settings.displayTime) timestamp.push(settings.cutSeconds ? this.cutOffSeconds(timeObj.toLocaleTimeString(languageId)) : timeObj.toLocaleTimeString(languageId));
|
||||||
if (settings.otherOrder) timestamp.reverse();
|
if (settings.otherOrder) timestamp.reverse();
|
||||||
timestring = timestamp.length > 1 ? timestamp.join(", ") : (timestamp.length > 0 ? timestamp[0] : "");
|
timeString = timestamp.length > 1 ? timestamp.join(", ") : (timestamp.length > 0 ? timestamp[0] : "");
|
||||||
if (timestring && settings.forceZeros) timestring = this.addLeadingZeros(timestring);
|
if (timeString && settings.forceZeros) timeString = this.addLeadingZeros(timeString);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
languageId = BDFDB.LanguageUtils.getLanguage().id;
|
languageId = BDFDB.LanguageUtils.getLanguage().id;
|
||||||
let now = new Date();
|
let now = new Date();
|
||||||
let hour = timeobj.getHours(), minute = timeobj.getMinutes(), second = timeobj.getSeconds(), msecond = timeobj.getMilliseconds(), day = timeobj.getDate(), month = timeobj.getMonth()+1, timemode = "", daysago = Math.round((Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) - Date.UTC(timeobj.getFullYear(), timeobj.getMonth(), timeobj.getDate()))/(1000*60*60*24));
|
let hour = timeObj.getHours(), minute = timeObj.getMinutes(), second = timeObj.getSeconds(), msecond = timeObj.getMilliseconds(), day = timeObj.getDate(), month = timeObj.getMonth()+1, timemode = "", daysago = Math.round((Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) - Date.UTC(timeObj.getFullYear(), timeObj.getMonth(), timeObj.getDate()))/(1000*60*60*24));
|
||||||
if (formats.ownformat.indexOf("$timemode") > -1) {
|
if (formats.ownFormat.indexOf("$timemode") > -1) {
|
||||||
timemode = hour >= 12 ? "PM" : "AM";
|
timemode = hour >= 12 ? "PM" : "AM";
|
||||||
hour = hour % 12;
|
hour = hour % 12;
|
||||||
hour = hour ? hour : 12;
|
hour = hour ? hour : 12;
|
||||||
}
|
}
|
||||||
timestring = formats.ownformat
|
timeString = formats.ownFormat
|
||||||
.replace("$hour", settings.forceZeros && hour < 10 ? "0" + hour : hour)
|
.replace(/\$hour/g, settings.forceZeros && hour < 10 ? "0" + hour : hour)
|
||||||
.replace("$minute", minute < 10 ? "0" + minute : minute)
|
.replace(/\$minute/g, minute < 10 ? "0" + minute : minute)
|
||||||
.replace("$second", second < 10 ? "0" + second : second)
|
.replace(/\$second/g, second < 10 ? "0" + second : second)
|
||||||
.replace("$msecond", settings.forceZeros ? (msecond < 10 ? "00" + msecond : (msecond < 100 ? "0" + msecond : msecond)) : msecond)
|
.replace(/\$msecond/g, settings.forceZeros ? (msecond < 10 ? "00" + msecond : (msecond < 100 ? "0" + msecond : msecond)) : msecond)
|
||||||
.replace("$timemode", timemode)
|
.replace(/\$timemode/g, timemode)
|
||||||
.replace("$weekdayL", timeobj.toLocaleDateString(languageId,{weekday: "long"}))
|
.replace(/\$weekdayL/g, timeObj.toLocaleDateString(languageId, {weekday: "long"}))
|
||||||
.replace("$weekdayS", timeobj.toLocaleDateString(languageId,{weekday: "short"}))
|
.replace(/\$weekdayS/g, timeObj.toLocaleDateString(languageId, {weekday: "short"}))
|
||||||
.replace("$monthnameL", timeobj.toLocaleDateString(languageId,{month: "long"}))
|
.replace(/\$monthnameL/g, timeObj.toLocaleDateString(languageId, {month: "long"}))
|
||||||
.replace("$monthnameS", timeobj.toLocaleDateString(languageId,{month: "short"}))
|
.replace(/\$monthnameS/g, timeObj.toLocaleDateString(languageId, {month: "short"}))
|
||||||
.replace("$daysago", daysago > 0 ? BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", daysago) : BDFDB.LanguageUtils.LanguageStrings.SEARCH_SHORTCUT_TODAY)
|
.replace(/\$daysago/g, amounts.maxDaysAgo == 0 || amounts.maxDaysAgo <= daysago ? (daysago > 0 ? BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", daysago) : BDFDB.LanguageUtils.LanguageStrings.SEARCH_SHORTCUT_TODAY) : "")
|
||||||
.replace("$day", settings.forceZeros && day < 10 ? "0" + day : day)
|
.replace(/\$day/g, settings.forceZeros && day < 10 ? "0" + day : day)
|
||||||
.replace("$month", settings.forceZeros && month < 10 ? "0" + month : month)
|
.replace(/\$month/g, settings.forceZeros && month < 10 ? "0" + month : month)
|
||||||
.replace("$year", timeobj.getFullYear())
|
.replace(/\$yearS/g, parseInt(timeObj.getFullYear().toString().slice(-2)))
|
||||||
|
.replace(/\$year/g, timeObj.getFullYear())
|
||||||
.trim().split(" ").filter(n => n).join(" ");
|
.trim().split(" ").filter(n => n).join(" ");
|
||||||
}
|
}
|
||||||
return timestring;
|
return timeString;
|
||||||
}
|
}
|
||||||
|
|
||||||
cutOffSeconds (timestring) {
|
cutOffSeconds (timeString) {
|
||||||
return timestring.replace(/(.{1,2}:.{1,2}):.{1,2}(.*)/, "$1$2").replace(/(.{1,2}\..{1,2})\..{1,2}(.*)/, "$1$2").replace(/(.{1,2} h .{1,2} min) .{1,2} s(.*)/, "$1$2");
|
return timeString.replace(/(.{1,2}:.{1,2}):.{1,2}(.*)/, "$1$2").replace(/(.{1,2}\..{1,2})\..{1,2}(.*)/, "$1$2").replace(/(.{1,2} h .{1,2} min) .{1,2} s(.*)/, "$1$2");
|
||||||
}
|
}
|
||||||
|
|
||||||
addLeadingZeros (timestring) {
|
addLeadingZeros (timeString) {
|
||||||
let charArray = timestring.split("");
|
let charArray = timeString.split("");
|
||||||
let numreg = /[0-9]/;
|
let numreg = /[0-9]/;
|
||||||
for (let i = 0; i < charArray.length; i++) {
|
for (let i = 0; i < charArray.length; i++) {
|
||||||
if (!numreg.test(charArray[i-1]) && numreg.test(charArray[i]) && !numreg.test(charArray[i+1])) charArray[i] = "0" + charArray[i];
|
if (!numreg.test(charArray[i-1]) && numreg.test(charArray[i]) && !numreg.test(charArray[i+1])) charArray[i] = "0" + charArray[i];
|
||||||
|
@ -366,7 +405,7 @@ var CompleteTimestamps = (_ => {
|
||||||
if (currentMode != compact) {
|
if (currentMode != compact) {
|
||||||
currentMode = compact;
|
currentMode = compact;
|
||||||
if (compact && timestamp.props.className && typeof timestamp.type == "string") {
|
if (compact && timestamp.props.className && typeof timestamp.type == "string") {
|
||||||
let tempTimestamp = BDFDB.DOMUtils.create(`<div class="${BDFDB.disCN.messagecompact}"><${timestamp.type} class="${timestamp.props.className}" style="width: auto !important;">${this.getTimestamp(languages[choices.creationDateLang].id, new Date(253402124399995))}</${timestamp.type}></div>`);
|
let tempTimestamp = BDFDB.DOMUtils.create(`<div class="${BDFDB.disCN.messagecompact}"><${timestamp.type} class="${timestamp.props.className}" style="width: auto !important;">${this.getTimestamp(languages[choices.timestampLang].id, new Date(253402124399995))}</${timestamp.type}></div>`);
|
||||||
document.body.appendChild(tempTimestamp);
|
document.body.appendChild(tempTimestamp);
|
||||||
let width = BDFDB.DOMUtils.getRects(tempTimestamp.firstElementChild).width + 10;
|
let width = BDFDB.DOMUtils.getRects(tempTimestamp.firstElementChild).width + 10;
|
||||||
tempTimestamp.remove();
|
tempTimestamp.remove();
|
||||||
|
@ -392,6 +431,7 @@ var CompleteTimestamps = (_ => {
|
||||||
settings = BDFDB.DataUtils.get(this, "settings");
|
settings = BDFDB.DataUtils.get(this, "settings");
|
||||||
choices = BDFDB.DataUtils.get(this, "choices");
|
choices = BDFDB.DataUtils.get(this, "choices");
|
||||||
formats = BDFDB.DataUtils.get(this, "formats");
|
formats = BDFDB.DataUtils.get(this, "formats");
|
||||||
|
amounts = BDFDB.DataUtils.get(this, "amounts");
|
||||||
|
|
||||||
BDFDB.ModuleUtils.forceAllUpdates(this);
|
BDFDB.ModuleUtils.forceAllUpdates(this);
|
||||||
BDFDB.MessageUtils.rerenderAll();
|
BDFDB.MessageUtils.rerenderAll();
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
var CreationDate = (_ => {
|
var CreationDate = (_ => {
|
||||||
var languages;
|
var languages;
|
||||||
var settings = {}, choices = {}, formats = {};
|
var settings = {}, choices = {}, formats = {}, amounts = {};
|
||||||
|
|
||||||
return class CreationDate {
|
return class CreationDate {
|
||||||
getName () {return "CreationDate";}
|
getName () {return "CreationDate";}
|
||||||
|
|
||||||
getVersion () {return "1.3.7";}
|
getVersion () {return "1.3.8";}
|
||||||
|
|
||||||
getAuthor () {return "DevilBro";}
|
getAuthor () {return "DevilBro";}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ var CreationDate = (_ => {
|
||||||
|
|
||||||
constructor () {
|
constructor () {
|
||||||
this.changelog = {
|
this.changelog = {
|
||||||
"fixed":[["Settings changes","Fixed issue where settings changes would only apply after plugin was reloaded"]]
|
"added":[["Settings","Added upper limit for $daysago, option to hide the default timestamp text and new year short form placeholder"]]
|
||||||
};
|
};
|
||||||
|
|
||||||
this.patchedModules = {
|
this.patchedModules = {
|
||||||
|
@ -27,44 +27,25 @@ var CreationDate = (_ => {
|
||||||
}
|
}
|
||||||
|
|
||||||
initConstructor () {
|
initConstructor () {
|
||||||
this.css = `
|
|
||||||
${BDFDB.dotCNS.userpopout + BDFDB.dotCN.userpopoutheadertext} {
|
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
|
||||||
.creationDate + ${BDFDB.dotCN.userpopoutcustomstatus} {
|
|
||||||
margin-top: 4px;
|
|
||||||
}
|
|
||||||
${BDFDB.dotCNS.themelight + BDFDB.dotCN.userpopoutheadernormal} .creationDate {
|
|
||||||
color: #b9bbbe;
|
|
||||||
}
|
|
||||||
${BDFDB.dotCNS.themelight + BDFDB.dotCN.userpopoutheader + BDFDB.notCN.userpopoutheadernormal} .creationDate,
|
|
||||||
${BDFDB.dotCNS.themedark + BDFDB.dotCN.userpopoutheader} .creationDate {
|
|
||||||
color: hsla(0,0%,100%,.6);
|
|
||||||
}
|
|
||||||
${BDFDB.dotCNS.themelight + BDFDB.dotCN.userprofiletopsectionnormal} .creationDate {
|
|
||||||
color: hsla(216,4%,74%,.6);
|
|
||||||
}
|
|
||||||
${BDFDB.dotCN.themelight} [class*='topSection']${BDFDB.notCN.userprofiletopsectionnormal} .creationDate,
|
|
||||||
${BDFDB.dotCN.themedark} [class*='topSection'] .creationDate {
|
|
||||||
color: hsla(0,0%,100%,.6);
|
|
||||||
}`;
|
|
||||||
|
|
||||||
|
|
||||||
this.defaults = {
|
this.defaults = {
|
||||||
settings: {
|
settings: {
|
||||||
addInUserPopout: {value:true, description:"Add in User Popouts:"},
|
addInUserPopout: {value:true, description:"Add in User Popouts"},
|
||||||
addInUserProfil: {value:true, description:"Add in User Profile Modal:"},
|
addInUserProfil: {value:true, description:"Add in User Profile Modal"},
|
||||||
displayTime: {value:true, description:"Display the Time in the Timestamp:"},
|
displayText: {value:true, description:"Display 'Created on' text in the timestamp"},
|
||||||
displayDate: {value:true, description:"Display the Date in the Timestamp:"},
|
displayTime: {value:true, description:"Display the time in the timestamp"},
|
||||||
cutSeconds: {value:false, description:"Cut off Seconds of the Time:"},
|
displayDate: {value:true, description:"Display the date in the timestamp"},
|
||||||
forceZeros: {value:false, description:"Force leading Zeros:"},
|
cutSeconds: {value:false, description:"Cut off seconds of the time"},
|
||||||
otherOrder: {value:false, description:"Show the Time before the Date:"}
|
forceZeros: {value:false, description:"Force leading zeros"},
|
||||||
|
otherOrder: {value:false, description:"Show the time before the date"}
|
||||||
},
|
},
|
||||||
choices: {
|
choices: {
|
||||||
creationDateLang: {value:"$discord", description:"Creation Date Format:"}
|
creationDateLang: {value:"$discord", description:"Creation Date Format"}
|
||||||
},
|
},
|
||||||
formats: {
|
formats: {
|
||||||
ownFormat: {value:"$hour:$minute:$second, $day.$month.$year", description:"Own Format:"}
|
ownFormat: {value:"$hour:$minute:$second, $day.$month.$year", description:"Own Format"}
|
||||||
|
},
|
||||||
|
amounts: {
|
||||||
|
maxDaysAgo: {value:0, min:0, description:"Maximum count of days displayed in the $daysago placeholder", note:"0 equals no limit"}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -73,7 +54,7 @@ var CreationDate = (_ => {
|
||||||
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||||
let settingsPanel, settingsItems = [], innerItems = [];
|
let settingsPanel, settingsItems = [], innerItems = [];
|
||||||
|
|
||||||
for (let key in settings) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
for (let key in settings) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||||
className: BDFDB.disCN.marginbottom8,
|
className: BDFDB.disCN.marginbottom8,
|
||||||
type: "Switch",
|
type: "Switch",
|
||||||
plugin: this,
|
plugin: this,
|
||||||
|
@ -86,11 +67,15 @@ var CreationDate = (_ => {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||||
className: BDFDB.disCN.marginbottom8
|
title: "Settings",
|
||||||
|
collapseStates: collapseStates,
|
||||||
|
children: innerItems
|
||||||
}));
|
}));
|
||||||
|
|
||||||
for (let key in choices) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
innerItems = [];
|
||||||
|
|
||||||
|
for (let key in choices) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||||
className: BDFDB.disCN.marginbottom8,
|
className: BDFDB.disCN.marginbottom8,
|
||||||
type: "Select",
|
type: "Select",
|
||||||
plugin: this,
|
plugin: this,
|
||||||
|
@ -139,11 +124,11 @@ var CreationDate = (_ => {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||||
className: BDFDB.disCN.marginbottom8
|
className: BDFDB.disCN.marginbottom8
|
||||||
}));
|
}));
|
||||||
|
|
||||||
for (let key in formats) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
for (let key in formats) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||||
className: BDFDB.disCN.marginbottom8,
|
className: BDFDB.disCN.marginbottom8,
|
||||||
type: "TextInput",
|
type: "TextInput",
|
||||||
plugin: this,
|
plugin: this,
|
||||||
|
@ -157,19 +142,47 @@ var CreationDate = (_ => {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||||
|
className: BDFDB.disCN.marginbottom8
|
||||||
|
}));
|
||||||
|
|
||||||
|
for (let key in amounts) 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,
|
||||||
|
note: this.defaults.amounts[key].note,
|
||||||
|
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: "Format",
|
||||||
|
collapseStates: collapseStates,
|
||||||
|
dividertop: true,
|
||||||
|
children: innerItems
|
||||||
|
}));
|
||||||
|
|
||||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||||
title: "Placeholder Guide",
|
title: "Placeholder Guide",
|
||||||
dividertop: true,
|
dividertop: true,
|
||||||
collapseStates: collapseStates,
|
collapseStates: collapseStates,
|
||||||
children: [
|
children: [
|
||||||
"$hour will be replaced with the current hour",
|
"$hour will be replaced with the hour of the date",
|
||||||
"$minute will be replaced with the current minutes",
|
"$minute will be replaced with the minutes of the date",
|
||||||
"$second will be replaced with the current seconds",
|
"$second will be replaced with the seconds of the date",
|
||||||
"$msecond will be replaced with the current milliseconds",
|
"$msecond will be replaced with the milliseconds of the date",
|
||||||
"$timemode will change $hour to a 12h format and will be replaced with AM/PM",
|
"$timemode will change $hour to a 12h format and will be replaced with AM/PM",
|
||||||
"$year will be replaced with the current year",
|
"$year will be replaced with the year of the date",
|
||||||
"$month will be replaced with the current month",
|
"$yearS will be replaced with the year in short form",
|
||||||
"$day will be replaced with the current day",
|
"$month will be replaced with the month of the date",
|
||||||
|
"$day will be replaced with the day of the date",
|
||||||
"$monthnameL will be replaced with the monthname in long format based on the Discord Language",
|
"$monthnameL will be replaced with the monthname in long format based on the Discord Language",
|
||||||
"$monthnameS will be replaced with the monthname in short format based on the Discord Language",
|
"$monthnameS will be replaced with the monthname in short format based on the Discord Language",
|
||||||
"$weekdayL will be replaced with the weekday in long format based on the Discord Language",
|
"$weekdayL will be replaced with the weekday in long format based on the Discord Language",
|
||||||
|
@ -268,60 +281,62 @@ var CreationDate = (_ => {
|
||||||
}
|
}
|
||||||
|
|
||||||
injectDate (children, index, user) {
|
injectDate (children, index, user) {
|
||||||
|
let timestamp = this.getTimestamp(languages[choices.creationDateLang].id, user.createdAt);
|
||||||
children.splice(index, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
|
children.splice(index, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
|
||||||
className: "creationDate " + BDFDB.disCN.textrow,
|
className: BDFDB.disCNS._creationdatedate + BDFDB.disCNS.userinfodate + BDFDB.disCN.textrow,
|
||||||
children: this.labels.createdat_text.replace("{{time}}", this.getTimestamp(languages[choices.creationDateLang].id, user.createdAt))
|
children: settings.displayText ? this.labels.createdat_text.replace("{{time}}", timestamp) : timestamp
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
getTimestamp (languageId, time) {
|
getTimestamp (languageId, time) {
|
||||||
let timeobj = time || new Date();
|
let timeObj = time || new Date();
|
||||||
if (typeof time == "string") timeobj = new Date(time);
|
if (typeof time == "string") timeObj = new Date(time);
|
||||||
if (timeobj.toString() == "Invalid Date") timeobj = new Date(parseInt(time));
|
if (timeObj.toString() == "Invalid Date") timeObj = new Date(parseInt(time));
|
||||||
if (timeobj.toString() == "Invalid Date") return;
|
if (timeObj.toString() == "Invalid Date") return;
|
||||||
let timestring = "";
|
let timeString = "";
|
||||||
if (languageId != "own") {
|
if (languageId != "own") {
|
||||||
let timestamp = [];
|
let timestamp = [];
|
||||||
if (settings.displayDate) timestamp.push(timeobj.toLocaleDateString(languageId));
|
if (settings.displayDate) timestamp.push(timeObj.toLocaleDateString(languageId));
|
||||||
if (settings.displayTime) timestamp.push(settings.cutSeconds ? this.cutOffSeconds(timeobj.toLocaleTimeString(languageId)) : timeobj.toLocaleTimeString(languageId));
|
if (settings.displayTime) timestamp.push(settings.cutSeconds ? this.cutOffSeconds(timeObj.toLocaleTimeString(languageId)) : timeObj.toLocaleTimeString(languageId));
|
||||||
if (settings.otherOrder) timestamp.reverse();
|
if (settings.otherOrder) timestamp.reverse();
|
||||||
timestring = timestamp.length > 1 ? timestamp.join(", ") : (timestamp.length > 0 ? timestamp[0] : "");
|
timeString = timestamp.length > 1 ? timestamp.join(", ") : (timestamp.length > 0 ? timestamp[0] : "");
|
||||||
if (timestring && settings.forceZeros) timestring = this.addLeadingZeros(timestring);
|
if (timeString && settings.forceZeros) timeString = this.addLeadingZeros(timeString);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
languageId = BDFDB.LanguageUtils.getLanguage().id;
|
languageId = BDFDB.LanguageUtils.getLanguage().id;
|
||||||
let now = new Date();
|
let now = new Date();
|
||||||
let hour = timeobj.getHours(), minute = timeobj.getMinutes(), second = timeobj.getSeconds(), msecond = timeobj.getMilliseconds(), day = timeobj.getDate(), month = timeobj.getMonth()+1, timemode = "", daysago = Math.round((Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) - Date.UTC(timeobj.getFullYear(), timeobj.getMonth(), timeobj.getDate()))/(1000*60*60*24));
|
let hour = timeObj.getHours(), minute = timeObj.getMinutes(), second = timeObj.getSeconds(), msecond = timeObj.getMilliseconds(), day = timeObj.getDate(), month = timeObj.getMonth()+1, timemode = "", daysago = Math.round((Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) - Date.UTC(timeObj.getFullYear(), timeObj.getMonth(), timeObj.getDate()))/(1000*60*60*24));
|
||||||
if (formats.ownFormat.indexOf("$timemode") > -1) {
|
if (formats.ownFormat.indexOf("$timemode") > -1) {
|
||||||
timemode = hour >= 12 ? "PM" : "AM";
|
timemode = hour >= 12 ? "PM" : "AM";
|
||||||
hour = hour % 12;
|
hour = hour % 12;
|
||||||
hour = hour ? hour : 12;
|
hour = hour ? hour : 12;
|
||||||
}
|
}
|
||||||
timestring = formats.ownFormat
|
timeString = formats.ownFormat
|
||||||
.replace("$hour", settings.forceZeros && hour < 10 ? "0" + hour : hour)
|
.replace(/\$hour/g, settings.forceZeros && hour < 10 ? "0" + hour : hour)
|
||||||
.replace("$minute", minute < 10 ? "0" + minute : minute)
|
.replace(/\$minute/g, minute < 10 ? "0" + minute : minute)
|
||||||
.replace("$second", second < 10 ? "0" + second : second)
|
.replace(/\$second/g, second < 10 ? "0" + second : second)
|
||||||
.replace("$msecond", settings.forceZeros ? (msecond < 10 ? "00" + msecond : (msecond < 100 ? "0" + msecond : msecond)) : msecond)
|
.replace(/\$msecond/g, settings.forceZeros ? (msecond < 10 ? "00" + msecond : (msecond < 100 ? "0" + msecond : msecond)) : msecond)
|
||||||
.replace("$timemode", timemode)
|
.replace(/\$timemode/g, timemode)
|
||||||
.replace("$weekdayL", timeobj.toLocaleDateString(languageId,{weekday: "long"}))
|
.replace(/\$weekdayL/g, timeObj.toLocaleDateString(languageId, {weekday: "long"}))
|
||||||
.replace("$weekdayS", timeobj.toLocaleDateString(languageId,{weekday: "short"}))
|
.replace(/\$weekdayS/g, timeObj.toLocaleDateString(languageId, {weekday: "short"}))
|
||||||
.replace("$monthnameL", timeobj.toLocaleDateString(languageId,{month: "long"}))
|
.replace(/\$monthnameL/g, timeObj.toLocaleDateString(languageId, {month: "long"}))
|
||||||
.replace("$monthnameS", timeobj.toLocaleDateString(languageId,{month: "short"}))
|
.replace(/\$monthnameS/g, timeObj.toLocaleDateString(languageId, {month: "short"}))
|
||||||
.replace("$daysago", daysago > 0 ? BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", daysago) : BDFDB.LanguageUtils.LanguageStrings.SEARCH_SHORTCUT_TODAY)
|
.replace(/\$daysago/g, amounts.maxDaysAgo == 0 || amounts.maxDaysAgo <= daysago ? (daysago > 0 ? BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", daysago) : BDFDB.LanguageUtils.LanguageStrings.SEARCH_SHORTCUT_TODAY) : "")
|
||||||
.replace("$day", settings.forceZeros && day < 10 ? "0" + day : day)
|
.replace(/\$day/g, settings.forceZeros && day < 10 ? "0" + day : day)
|
||||||
.replace("$month", settings.forceZeros && month < 10 ? "0" + month : month)
|
.replace(/\$month/g, settings.forceZeros && month < 10 ? "0" + month : month)
|
||||||
.replace("$year", timeobj.getFullYear())
|
.replace(/\$yearS/g, parseInt(timeObj.getFullYear().toString().slice(-2)))
|
||||||
|
.replace(/\$year/g, timeObj.getFullYear())
|
||||||
.trim().split(" ").filter(n => n).join(" ");
|
.trim().split(" ").filter(n => n).join(" ");
|
||||||
}
|
}
|
||||||
return timestring;
|
return timeString;
|
||||||
}
|
}
|
||||||
|
|
||||||
cutOffSeconds (timestring) {
|
cutOffSeconds (timeString) {
|
||||||
return timestring.replace(/(.{1,2}:.{1,2}):.{1,2}(.*)/, "$1$2").replace(/(.{1,2}\..{1,2})\..{1,2}(.*)/, "$1$2").replace(/(.{1,2} h .{1,2} min) .{1,2} s(.*)/, "$1$2");
|
return timeString.replace(/(.{1,2}:.{1,2}):.{1,2}(.*)/, "$1$2").replace(/(.{1,2}\..{1,2})\..{1,2}(.*)/, "$1$2").replace(/(.{1,2} h .{1,2} min) .{1,2} s(.*)/, "$1$2");
|
||||||
}
|
}
|
||||||
|
|
||||||
addLeadingZeros (timestring) {
|
addLeadingZeros (timeString) {
|
||||||
let charArray = timestring.split("");
|
let charArray = timeString.split("");
|
||||||
let numreg = /[0-9]/;
|
let numreg = /[0-9]/;
|
||||||
for (let i = 0; i < charArray.length; i++) {
|
for (let i = 0; i < charArray.length; i++) {
|
||||||
if (!numreg.test(charArray[i-1]) && numreg.test(charArray[i]) && !numreg.test(charArray[i+1])) charArray[i] = "0" + charArray[i];
|
if (!numreg.test(charArray[i-1]) && numreg.test(charArray[i]) && !numreg.test(charArray[i+1])) charArray[i] = "0" + charArray[i];
|
||||||
|
@ -334,6 +349,7 @@ var CreationDate = (_ => {
|
||||||
settings = BDFDB.DataUtils.get(this, "settings");
|
settings = BDFDB.DataUtils.get(this, "settings");
|
||||||
choices = BDFDB.DataUtils.get(this, "choices");
|
choices = BDFDB.DataUtils.get(this, "choices");
|
||||||
formats = BDFDB.DataUtils.get(this, "formats");
|
formats = BDFDB.DataUtils.get(this, "formats");
|
||||||
|
amounts = BDFDB.DataUtils.get(this, "amounts");
|
||||||
|
|
||||||
BDFDB.ModuleUtils.forceAllUpdates(this);
|
BDFDB.ModuleUtils.forceAllUpdates(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
var JoinedAtDate = (_ => {
|
var JoinedAtDate = (_ => {
|
||||||
var loadedUsers, requestedUsers, languages;
|
var loadedUsers, requestedUsers, languages;
|
||||||
var settings = {}, choices = {}, formats = {};
|
var settings = {}, choices = {}, formats = {}, amounts = {};
|
||||||
|
|
||||||
return class JoinedAtDate {
|
return class JoinedAtDate {
|
||||||
getName () {return "JoinedAtDate";}
|
getName () {return "JoinedAtDate";}
|
||||||
|
|
||||||
getVersion () {return "1.2.0";}
|
getVersion () {return "1.2.1";}
|
||||||
|
|
||||||
getAuthor () {return "DevilBro";}
|
getAuthor () {return "DevilBro";}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ var JoinedAtDate = (_ => {
|
||||||
|
|
||||||
constructor () {
|
constructor () {
|
||||||
this.changelog = {
|
this.changelog = {
|
||||||
"fixed":[["Settings changes","Fixed issue where settings changes would only apply after plugin was reloaded"]]
|
"added":[["Settings","Added upper limit for $daysago, option to hide the default timestamp text and new year short form placeholder"]]
|
||||||
};
|
};
|
||||||
|
|
||||||
this.patchedModules = {
|
this.patchedModules = {
|
||||||
|
@ -30,43 +30,25 @@ var JoinedAtDate = (_ => {
|
||||||
loadedUsers = {};
|
loadedUsers = {};
|
||||||
requestedUsers = {};
|
requestedUsers = {};
|
||||||
|
|
||||||
this.css = `
|
|
||||||
${BDFDB.dotCNS.userpopout + BDFDB.dotCN.userpopoutheadertext} {
|
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
|
||||||
.joinedAtDate + ${BDFDB.dotCN.userpopoutcustomstatus} {
|
|
||||||
margin-top: 4px;
|
|
||||||
}
|
|
||||||
${BDFDB.dotCNS.themelight + BDFDB.dotCN.userpopoutheadernormal} .joinedAtDate {
|
|
||||||
color: #b9bbbe;
|
|
||||||
}
|
|
||||||
${BDFDB.dotCNS.themelight + BDFDB.dotCN.userpopoutheader + BDFDB.notCN.userpopoutheadernormal} .joinedAtDate,
|
|
||||||
${BDFDB.dotCNS.themedark + BDFDB.dotCN.userpopoutheader} .joinedAtDate {
|
|
||||||
color: hsla(0,0%,100%,.6);
|
|
||||||
}
|
|
||||||
${BDFDB.dotCNS.themelight + BDFDB.dotCN.userprofiletopsectionnormal} .joinedAtDate {
|
|
||||||
color: hsla(216,4%,74%,.6);
|
|
||||||
}
|
|
||||||
${BDFDB.dotCN.themelight} [class*='topSection']${BDFDB.notCN.userprofiletopsectionnormal} .joinedAtDate,
|
|
||||||
${BDFDB.dotCN.themedark} [class*='topSection'] .joinedAtDate {
|
|
||||||
color: hsla(0,0%,100%,.6);
|
|
||||||
}`;
|
|
||||||
|
|
||||||
this.defaults = {
|
this.defaults = {
|
||||||
settings: {
|
settings: {
|
||||||
addInUserPopout: {value:true, description:"Add in User Popouts:"},
|
addInUserPopout: {value:true, description:"Add in User Popouts"},
|
||||||
addInUserProfil: {value:true, description:"Add in User Profile Modal:"},
|
addInUserProfil: {value:true, description:"Add in User Profile Modal"},
|
||||||
displayTime: {value:true, description:"Display the Time in the Timestamp:"},
|
displayText: {value:true, description:"Display 'Joined on' text in the timestamp"},
|
||||||
displayDate: {value:true, description:"Display the Date in the Timestamp:"},
|
displayTime: {value:true, description:"Display the time in the timestamp"},
|
||||||
cutSeconds: {value:false, description:"Cut off Seconds of the Time:"},
|
displayDate: {value:true, description:"Display the date in the timestamp"},
|
||||||
forceZeros: {value:false, description:"Force leading Zeros:"},
|
cutSeconds: {value:false, description:"Cut off seconds of the time"},
|
||||||
otherOrder: {value:false, description:"Show the Time before the Date:"}
|
forceZeros: {value:false, description:"Force leading zeros"},
|
||||||
|
otherOrder: {value:false, description:"Show the time before the date"}
|
||||||
},
|
},
|
||||||
choices: {
|
choices: {
|
||||||
joinedAtDateLang: {value:"$discord", description:"Joined At Date Format:"}
|
joinedAtDateLang: {value:"$discord", description:"Joined At Date Format"}
|
||||||
},
|
},
|
||||||
formats: {
|
formats: {
|
||||||
ownFormat: {value:"$hour:$minute:$second, $day.$month.$year", description:"Own Format:"}
|
ownFormat: {value:"$hour:$minute:$second, $day.$month.$year", description:"Own Format"}
|
||||||
|
},
|
||||||
|
amounts: {
|
||||||
|
maxDaysAgo: {value:0, min:0, description:"Maximum count of days displayed in the $daysago placeholder", note:"0 equals no limit"}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -75,7 +57,7 @@ var JoinedAtDate = (_ => {
|
||||||
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||||
let settingsPanel, settingsItems = [], innerItems = [];
|
let settingsPanel, settingsItems = [], innerItems = [];
|
||||||
|
|
||||||
for (let key in settings) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
for (let key in settings) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||||
className: BDFDB.disCN.marginbottom8,
|
className: BDFDB.disCN.marginbottom8,
|
||||||
type: "Switch",
|
type: "Switch",
|
||||||
plugin: this,
|
plugin: this,
|
||||||
|
@ -88,11 +70,15 @@ var JoinedAtDate = (_ => {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||||
className: BDFDB.disCN.marginbottom8
|
title: "Settings",
|
||||||
|
collapseStates: collapseStates,
|
||||||
|
children: innerItems
|
||||||
}));
|
}));
|
||||||
|
|
||||||
for (let key in choices) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
innerItems = [];
|
||||||
|
|
||||||
|
for (let key in choices) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||||
className: BDFDB.disCN.marginbottom8,
|
className: BDFDB.disCN.marginbottom8,
|
||||||
type: "Select",
|
type: "Select",
|
||||||
plugin: this,
|
plugin: this,
|
||||||
|
@ -141,11 +127,11 @@ var JoinedAtDate = (_ => {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||||
className: BDFDB.disCN.marginbottom8
|
className: BDFDB.disCN.marginbottom8
|
||||||
}));
|
}));
|
||||||
|
|
||||||
for (let key in formats) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
for (let key in formats) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||||
className: BDFDB.disCN.marginbottom8,
|
className: BDFDB.disCN.marginbottom8,
|
||||||
type: "TextInput",
|
type: "TextInput",
|
||||||
plugin: this,
|
plugin: this,
|
||||||
|
@ -159,19 +145,47 @@ var JoinedAtDate = (_ => {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||||
|
className: BDFDB.disCN.marginbottom8
|
||||||
|
}));
|
||||||
|
|
||||||
|
for (let key in amounts) 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,
|
||||||
|
note: this.defaults.amounts[key].note,
|
||||||
|
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: "Format",
|
||||||
|
collapseStates: collapseStates,
|
||||||
|
dividertop: true,
|
||||||
|
children: innerItems
|
||||||
|
}));
|
||||||
|
|
||||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||||
title: "Placeholder Guide",
|
title: "Placeholder Guide",
|
||||||
dividertop: true,
|
dividertop: true,
|
||||||
collapseStates: collapseStates,
|
collapseStates: collapseStates,
|
||||||
children: [
|
children: [
|
||||||
"$hour will be replaced with the current hour",
|
"$hour will be replaced with the hour of the date",
|
||||||
"$minute will be replaced with the current minutes",
|
"$minute will be replaced with the minutes of the date",
|
||||||
"$second will be replaced with the current seconds",
|
"$second will be replaced with the seconds of the date",
|
||||||
"$msecond will be replaced with the current milliseconds",
|
"$msecond will be replaced with the milliseconds",
|
||||||
"$timemode will change $hour to a 12h format and will be replaced with AM/PM",
|
"$timemode will change $hour to a 12h format and will be replaced with AM/PM",
|
||||||
"$year will be replaced with the current year",
|
"$year will be replaced with the year of the date",
|
||||||
"$month will be replaced with the current month",
|
"$yearS will be replaced with the year in short form",
|
||||||
"$day will be replaced with the current day",
|
"$month will be replaced with the month of the date",
|
||||||
|
"$day will be replaced with the day of the date",
|
||||||
"$monthnameL will be replaced with the monthname in long format based on the Discord Language",
|
"$monthnameL will be replaced with the monthname in long format based on the Discord Language",
|
||||||
"$monthnameS will be replaced with the monthname in short format based on the Discord Language",
|
"$monthnameS will be replaced with the monthname in short format based on the Discord Language",
|
||||||
"$weekdayL will be replaced with the weekday in long format based on the Discord Language",
|
"$weekdayL will be replaced with the weekday in long format based on the Discord Language",
|
||||||
|
@ -283,60 +297,64 @@ var JoinedAtDate = (_ => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (!loadedUsers[guildId][user.id]) requestedUsers[guildId][user.id].push(instance);
|
else if (!loadedUsers[guildId][user.id]) requestedUsers[guildId][user.id].push(instance);
|
||||||
else children.splice(index, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
|
else {
|
||||||
className: "joinedAtDate " + BDFDB.disCN.textrow,
|
let timestamp = this.getTimestamp(languages[choices.joinedAtDateLang].id, loadedUsers[guildId][user.id]);
|
||||||
children: this.labels.joinedat_text.replace("{{time}}", this.getTimestamp(languages[choices.joinedAtDateLang].id, loadedUsers[guildId][user.id]))
|
children.splice(index, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
|
||||||
}));
|
className: BDFDB.disCNS._joinedatdatedate + BDFDB.disCNS.userinfodate + BDFDB.disCN.textrow,
|
||||||
|
children: settings.displayText ? this.labels.joinedat_text.replace("{{time}}", timestamp) : timestamp
|
||||||
|
}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getTimestamp (languageId, time) {
|
getTimestamp (languageId, time) {
|
||||||
let timeobj = time || new Date();
|
let timeObj = time || new Date();
|
||||||
if (typeof time == "string") timeobj = new Date(time);
|
if (typeof time == "string") timeObj = new Date(time);
|
||||||
if (timeobj.toString() == "Invalid Date") timeobj = new Date(parseInt(time));
|
if (timeObj.toString() == "Invalid Date") timeObj = new Date(parseInt(time));
|
||||||
if (timeobj.toString() == "Invalid Date") return;
|
if (timeObj.toString() == "Invalid Date") return;
|
||||||
let timestring = "";
|
let timeString = "";
|
||||||
if (languageId != "own") {
|
if (languageId != "own") {
|
||||||
let timestamp = [];
|
let timestamp = [];
|
||||||
if (settings.displayDate) timestamp.push(timeobj.toLocaleDateString(languageId));
|
if (settings.displayDate) timestamp.push(timeObj.toLocaleDateString(languageId));
|
||||||
if (settings.displayTime) timestamp.push(settings.cutSeconds ? this.cutOffSeconds(timeobj.toLocaleTimeString(languageId)) : timeobj.toLocaleTimeString(languageId));
|
if (settings.displayTime) timestamp.push(settings.cutSeconds ? this.cutOffSeconds(timeObj.toLocaleTimeString(languageId)) : timeObj.toLocaleTimeString(languageId));
|
||||||
if (settings.otherOrder) timestamp.reverse();
|
if (settings.otherOrder) timestamp.reverse();
|
||||||
timestring = timestamp.length > 1 ? timestamp.join(", ") : (timestamp.length > 0 ? timestamp[0] : "");
|
timeString = timestamp.length > 1 ? timestamp.join(", ") : (timestamp.length > 0 ? timestamp[0] : "");
|
||||||
if (timestring && settings.forceZeros) timestring = this.addLeadingZeros(timestring);
|
if (timeString && settings.forceZeros) timeString = this.addLeadingZeros(timeString);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
languageId = BDFDB.LanguageUtils.getLanguage().id;
|
languageId = BDFDB.LanguageUtils.getLanguage().id;
|
||||||
let now = new Date();
|
let now = new Date();
|
||||||
let hour = timeobj.getHours(), minute = timeobj.getMinutes(), second = timeobj.getSeconds(), msecond = timeobj.getMilliseconds(), day = timeobj.getDate(), month = timeobj.getMonth()+1, timemode = "", daysago = Math.round((Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) - Date.UTC(timeobj.getFullYear(), timeobj.getMonth(), timeobj.getDate()))/(1000*60*60*24));
|
let hour = timeObj.getHours(), minute = timeObj.getMinutes(), second = timeObj.getSeconds(), msecond = timeObj.getMilliseconds(), day = timeObj.getDate(), month = timeObj.getMonth()+1, timemode = "", daysago = Math.round((Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) - Date.UTC(timeObj.getFullYear(), timeObj.getMonth(), timeObj.getDate()))/(1000*60*60*24));
|
||||||
if (formats.ownFormat.indexOf("$timemode") > -1) {
|
if (formats.ownFormat.indexOf("$timemode") > -1) {
|
||||||
timemode = hour >= 12 ? "PM" : "AM";
|
timemode = hour >= 12 ? "PM" : "AM";
|
||||||
hour = hour % 12;
|
hour = hour % 12;
|
||||||
hour = hour ? hour : 12;
|
hour = hour ? hour : 12;
|
||||||
}
|
}
|
||||||
timestring = formats.ownFormat
|
timeString = formats.ownFormat
|
||||||
.replace("$hour", settings.forceZeros && hour < 10 ? "0" + hour : hour)
|
.replace(/\$hour/g, settings.forceZeros && hour < 10 ? "0" + hour : hour)
|
||||||
.replace("$minute", minute < 10 ? "0" + minute : minute)
|
.replace(/\$minute/g, minute < 10 ? "0" + minute : minute)
|
||||||
.replace("$second", second < 10 ? "0" + second : second)
|
.replace(/\$second/g, second < 10 ? "0" + second : second)
|
||||||
.replace("$msecond", settings.forceZeros ? (msecond < 10 ? "00" + msecond : (msecond < 100 ? "0" + msecond : msecond)) : msecond)
|
.replace(/\$msecond/g, settings.forceZeros ? (msecond < 10 ? "00" + msecond : (msecond < 100 ? "0" + msecond : msecond)) : msecond)
|
||||||
.replace("$timemode", timemode)
|
.replace(/\$timemode/g, timemode)
|
||||||
.replace("$weekdayL", timeobj.toLocaleDateString(languageId,{weekday: "long"}))
|
.replace(/\$weekdayL/g, timeObj.toLocaleDateString(languageId, {weekday: "long"}))
|
||||||
.replace("$weekdayS", timeobj.toLocaleDateString(languageId,{weekday: "short"}))
|
.replace(/\$weekdayS/g, timeObj.toLocaleDateString(languageId, {weekday: "short"}))
|
||||||
.replace("$monthnameL", timeobj.toLocaleDateString(languageId,{month: "long"}))
|
.replace(/\$monthnameL/g, timeObj.toLocaleDateString(languageId, {month: "long"}))
|
||||||
.replace("$monthnameS", timeobj.toLocaleDateString(languageId,{month: "short"}))
|
.replace(/\$monthnameS/g, timeObj.toLocaleDateString(languageId, {month: "short"}))
|
||||||
.replace("$daysago", daysago > 0 ? BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", daysago) : BDFDB.LanguageUtils.LanguageStrings.SEARCH_SHORTCUT_TODAY)
|
.replace(/\$daysago/g, amounts.maxDaysAgo == 0 || amounts.maxDaysAgo <= daysago ? (daysago > 0 ? BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", daysago) : BDFDB.LanguageUtils.LanguageStrings.SEARCH_SHORTCUT_TODAY) : "")
|
||||||
.replace("$day", settings.forceZeros && day < 10 ? "0" + day : day)
|
.replace(/\$day/g, settings.forceZeros && day < 10 ? "0" + day : day)
|
||||||
.replace("$month", settings.forceZeros && month < 10 ? "0" + month : month)
|
.replace(/\$month/g, settings.forceZeros && month < 10 ? "0" + month : month)
|
||||||
.replace("$year", timeobj.getFullYear())
|
.replace(/\$yearS/g, parseInt(timeObj.getFullYear().toString().slice(-2)))
|
||||||
|
.replace(/\$year/g, timeObj.getFullYear())
|
||||||
.trim().split(" ").filter(n => n).join(" ");
|
.trim().split(" ").filter(n => n).join(" ");
|
||||||
}
|
}
|
||||||
return timestring;
|
return timeString;
|
||||||
}
|
}
|
||||||
|
|
||||||
cutOffSeconds (timestring) {
|
cutOffSeconds (timeString) {
|
||||||
return timestring.replace(/(.{1,2}:.{1,2}):.{1,2}(.*)/, "$1$2").replace(/(.{1,2}\..{1,2})\..{1,2}(.*)/, "$1$2").replace(/(.{1,2} h .{1,2} min) .{1,2} s(.*)/, "$1$2");
|
return timeString.replace(/(.{1,2}:.{1,2}):.{1,2}(.*)/, "$1$2").replace(/(.{1,2}\..{1,2})\..{1,2}(.*)/, "$1$2").replace(/(.{1,2} h .{1,2} min) .{1,2} s(.*)/, "$1$2");
|
||||||
}
|
}
|
||||||
|
|
||||||
addLeadingZeros (timestring) {
|
addLeadingZeros (timeString) {
|
||||||
let charArray = timestring.split("");
|
let charArray = timeString.split("");
|
||||||
let numreg = /[0-9]/;
|
let numreg = /[0-9]/;
|
||||||
for (let i = 0; i < charArray.length; i++) {
|
for (let i = 0; i < charArray.length; i++) {
|
||||||
if (!numreg.test(charArray[i-1]) && numreg.test(charArray[i]) && !numreg.test(charArray[i+1])) charArray[i] = "0" + charArray[i];
|
if (!numreg.test(charArray[i-1]) && numreg.test(charArray[i]) && !numreg.test(charArray[i+1])) charArray[i] = "0" + charArray[i];
|
||||||
|
@ -349,6 +367,7 @@ var JoinedAtDate = (_ => {
|
||||||
settings = BDFDB.DataUtils.get(this, "settings");
|
settings = BDFDB.DataUtils.get(this, "settings");
|
||||||
choices = BDFDB.DataUtils.get(this, "choices");
|
choices = BDFDB.DataUtils.get(this, "choices");
|
||||||
formats = BDFDB.DataUtils.get(this, "formats");
|
formats = BDFDB.DataUtils.get(this, "formats");
|
||||||
|
amounts = BDFDB.DataUtils.get(this, "amounts");
|
||||||
|
|
||||||
BDFDB.ModuleUtils.forceAllUpdates(this);
|
BDFDB.ModuleUtils.forceAllUpdates(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
var LastMessageDate = (_ => {
|
var LastMessageDate = (_ => {
|
||||||
var loadedUsers, requestedUsers, languages;
|
var loadedUsers, requestedUsers, languages;
|
||||||
var settings = {}, choices = {}, formats = {};
|
var settings = {}, choices = {}, formats = {}, amounts = {};
|
||||||
|
|
||||||
return class LastMessageDate {
|
return class LastMessageDate {
|
||||||
getName () {return "LastMessageDate";}
|
getName () {return "LastMessageDate";}
|
||||||
|
|
||||||
getVersion () {return "1.1.6";}
|
getVersion () {return "1.1.7";}
|
||||||
|
|
||||||
getAuthor () {return "DevilBro";}
|
getAuthor () {return "DevilBro";}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ var LastMessageDate = (_ => {
|
||||||
|
|
||||||
constructor () {
|
constructor () {
|
||||||
this.changelog = {
|
this.changelog = {
|
||||||
"fixed":[["Settings changes","Fixed issue where settings changes would only apply after plugin was reloaded"]]
|
"added":[["Settings","Added upper limit for $daysago, option to hide the default timestamp text and new year short form placeholder"]]
|
||||||
};
|
};
|
||||||
|
|
||||||
this.patchedModules = {
|
this.patchedModules = {
|
||||||
|
@ -30,44 +30,25 @@ var LastMessageDate = (_ => {
|
||||||
loadedUsers = {};
|
loadedUsers = {};
|
||||||
requestedUsers = {};
|
requestedUsers = {};
|
||||||
|
|
||||||
this.css = `
|
|
||||||
${BDFDB.dotCNS.userpopout + BDFDB.dotCN.userpopoutheadertext} {
|
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
|
||||||
.lastMessageDate + ${BDFDB.dotCN.userpopoutcustomstatus} {
|
|
||||||
margin-top: 4px;
|
|
||||||
}
|
|
||||||
${BDFDB.dotCNS.themelight + BDFDB.dotCN.userpopoutheadernormal} .lastMessageDate {
|
|
||||||
color: #b9bbbe;
|
|
||||||
}
|
|
||||||
${BDFDB.dotCNS.themelight + BDFDB.dotCN.userpopoutheader + BDFDB.notCN.userpopoutheadernormal} .lastMessageDate,
|
|
||||||
${BDFDB.dotCNS.themedark + BDFDB.dotCN.userpopoutheader} .lastMessageDate {
|
|
||||||
color: hsla(0,0%,100%,.6);
|
|
||||||
}
|
|
||||||
${BDFDB.dotCNS.themelight + BDFDB.dotCN.userprofiletopsectionnormal} .lastMessageDate {
|
|
||||||
color: hsla(216,4%,74%,.6);
|
|
||||||
}
|
|
||||||
${BDFDB.dotCN.themelight} [class*='topSection']${BDFDB.notCN.userprofiletopsectionnormal} .lastMessageDate,
|
|
||||||
${BDFDB.dotCN.themedark} [class*='topSection'] .lastMessageDate {
|
|
||||||
color: hsla(0,0%,100%,.6);
|
|
||||||
}`;
|
|
||||||
|
|
||||||
|
|
||||||
this.defaults = {
|
this.defaults = {
|
||||||
settings: {
|
settings: {
|
||||||
addInUserPopout: {value:true, description:"Add in User Popouts:"},
|
addInUserPopout: {value:true, description:"Add in User Popouts"},
|
||||||
addInUserProfil: {value:true, description:"Add in User Profile Modal:"},
|
addInUserProfil: {value:true, description:"Add in User Profile Modal"},
|
||||||
displayTime: {value:true, description:"Display the Time in the Timestamp:"},
|
displayText: {value:true, description:"Display 'Last message on' text in the timestamp"},
|
||||||
displayDate: {value:true, description:"Display the Date in the Timestamp:"},
|
displayTime: {value:true, description:"Display the time in the timestamp"},
|
||||||
cutSeconds: {value:false, description:"Cut off Seconds of the Time:"},
|
displayDate: {value:true, description:"Display the date in the timestamp"},
|
||||||
forceZeros: {value:false, description:"Force leading Zeros:"},
|
cutSeconds: {value:false, description:"Cut off seconds of the time"},
|
||||||
otherOrder: {value:false, description:"Show the Time before the Date:"}
|
forceZeros: {value:false, description:"Force leading zeros"},
|
||||||
|
otherOrder: {value:false, description:"Show the time before the date"}
|
||||||
},
|
},
|
||||||
choices: {
|
choices: {
|
||||||
lastMessageDateLang: {value:"$discord", description:"Last Message Date Format:"}
|
lastMessageDateLang: {value:"$discord", description:"Last Message Date Format"}
|
||||||
},
|
},
|
||||||
formats: {
|
formats: {
|
||||||
ownFormat: {value:"$hour:$minute:$second, $day.$month.$year", description:"Own Format:"}
|
ownFormat: {value:"$hour:$minute:$second, $day.$month.$year", description:"Own Format"}
|
||||||
|
},
|
||||||
|
amounts: {
|
||||||
|
maxDaysAgo: {value:0, min:0, description:"Maximum count of days displayed in the $daysago placeholder", note:"0 equals no limit"}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -76,7 +57,7 @@ var LastMessageDate = (_ => {
|
||||||
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||||
let settingsPanel, settingsItems = [], innerItems = [];
|
let settingsPanel, settingsItems = [], innerItems = [];
|
||||||
|
|
||||||
for (let key in settings) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
for (let key in settings) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||||
className: BDFDB.disCN.marginbottom8,
|
className: BDFDB.disCN.marginbottom8,
|
||||||
type: "Switch",
|
type: "Switch",
|
||||||
plugin: this,
|
plugin: this,
|
||||||
|
@ -89,11 +70,15 @@ var LastMessageDate = (_ => {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||||
className: BDFDB.disCN.marginbottom8
|
title: "Settings",
|
||||||
|
collapseStates: collapseStates,
|
||||||
|
children: innerItems
|
||||||
}));
|
}));
|
||||||
|
|
||||||
for (let key in choices) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
innerItems = [];
|
||||||
|
|
||||||
|
for (let key in choices) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||||
className: BDFDB.disCN.marginbottom8,
|
className: BDFDB.disCN.marginbottom8,
|
||||||
type: "Select",
|
type: "Select",
|
||||||
plugin: this,
|
plugin: this,
|
||||||
|
@ -142,11 +127,11 @@ var LastMessageDate = (_ => {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||||
className: BDFDB.disCN.marginbottom8
|
className: BDFDB.disCN.marginbottom8
|
||||||
}));
|
}));
|
||||||
|
|
||||||
for (let key in formats) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
for (let key in formats) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||||
className: BDFDB.disCN.marginbottom8,
|
className: BDFDB.disCN.marginbottom8,
|
||||||
type: "TextInput",
|
type: "TextInput",
|
||||||
plugin: this,
|
plugin: this,
|
||||||
|
@ -160,19 +145,47 @@ var LastMessageDate = (_ => {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
|
||||||
|
className: BDFDB.disCN.marginbottom8
|
||||||
|
}));
|
||||||
|
|
||||||
|
for (let key in amounts) 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,
|
||||||
|
note: this.defaults.amounts[key].note,
|
||||||
|
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: "Format",
|
||||||
|
collapseStates: collapseStates,
|
||||||
|
dividertop: true,
|
||||||
|
children: innerItems
|
||||||
|
}));
|
||||||
|
|
||||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||||
title: "Placeholder Guide",
|
title: "Placeholder Guide",
|
||||||
dividertop: true,
|
dividertop: true,
|
||||||
collapseStates: collapseStates,
|
collapseStates: collapseStates,
|
||||||
children: [
|
children: [
|
||||||
"$hour will be replaced with the current hour",
|
"$hour will be replaced with the hour of the date",
|
||||||
"$minute will be replaced with the current minutes",
|
"$minute will be replaced with the minutes of the date",
|
||||||
"$second will be replaced with the current seconds",
|
"$second will be replaced with the seconds of the date",
|
||||||
"$msecond will be replaced with the current milliseconds",
|
"$msecond will be replaced with the milliseconds of the date",
|
||||||
"$timemode will change $hour to a 12h format and will be replaced with AM/PM",
|
"$timemode will change $hour to a 12h format and will be replaced with AM/PM",
|
||||||
"$year will be replaced with the current year",
|
"$year will be replaced with the year of the date",
|
||||||
"$month will be replaced with the current month",
|
"$yearS will be replaced with the year in short form",
|
||||||
"$day will be replaced with the current day",
|
"$month will be replaced with the month of the date",
|
||||||
|
"$day will be replaced with the day of the date",
|
||||||
"$monthnameL will be replaced with the monthname in long format based on the Discord Language",
|
"$monthnameL will be replaced with the monthname in long format based on the Discord Language",
|
||||||
"$monthnameS will be replaced with the monthname in short format based on the Discord Language",
|
"$monthnameS will be replaced with the monthname in short format based on the Discord Language",
|
||||||
"$weekdayL will be replaced with the weekday in long format based on the Discord Language",
|
"$weekdayL will be replaced with the weekday in long format based on the Discord Language",
|
||||||
|
@ -307,60 +320,64 @@ var LastMessageDate = (_ => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (loadedUsers[guildId][user.id] === undefined) requestedUsers[guildId][user.id].push(instance);
|
else if (loadedUsers[guildId][user.id] === undefined) requestedUsers[guildId][user.id].push(instance);
|
||||||
else children.splice(index, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
|
else {
|
||||||
className: "lastMessageDate " + BDFDB.disCN.textrow,
|
let timestamp = loadedUsers[guildId][user.id] ? this.getTimestamp(languages[choices.lastMessageDateLang].id, loadedUsers[guildId][user.id]) : "---";
|
||||||
children: this.labels.lastmessage_text.replace("{{time}}", loadedUsers[guildId][user.id] ? this.getTimestamp(languages[choices.lastMessageDateLang].id, loadedUsers[guildId][user.id]) : "---")
|
children.splice(index, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
|
||||||
}));
|
className: BDFDB.disCNS._lastmessagedatedate + BDFDB.disCNS.userinfodate + BDFDB.disCN.textrow,
|
||||||
|
children: settings.displayText ? this.labels.lastmessage_text.replace("{{time}}", timestamp) : timestamp
|
||||||
|
}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getTimestamp (languageId, time) {
|
getTimestamp (languageId, time) {
|
||||||
let timeobj = time || new Date();
|
let timeObj = time || new Date();
|
||||||
if (typeof time == "string") timeobj = new Date(time);
|
if (typeof time == "string") timeObj = new Date(time);
|
||||||
if (timeobj.toString() == "Invalid Date") timeobj = new Date(parseInt(time));
|
if (timeObj.toString() == "Invalid Date") timeObj = new Date(parseInt(time));
|
||||||
if (timeobj.toString() == "Invalid Date") return;
|
if (timeObj.toString() == "Invalid Date") return;
|
||||||
let settings = BDFDB.DataUtils.get(this, "settings"), timestring = "";
|
let settings = BDFDB.DataUtils.get(this, "settings"), timeString = "";
|
||||||
if (languageId != "own") {
|
if (languageId != "own") {
|
||||||
let timestamp = [];
|
let timestamp = [];
|
||||||
if (settings.displayDate) timestamp.push(timeobj.toLocaleDateString(languageId));
|
if (settings.displayDate) timestamp.push(timeObj.toLocaleDateString(languageId));
|
||||||
if (settings.displayTime) timestamp.push(settings.cutSeconds ? this.cutOffSeconds(timeobj.toLocaleTimeString(languageId)) : timeobj.toLocaleTimeString(languageId));
|
if (settings.displayTime) timestamp.push(settings.cutSeconds ? this.cutOffSeconds(timeObj.toLocaleTimeString(languageId)) : timeObj.toLocaleTimeString(languageId));
|
||||||
if (settings.otherOrder) timestamp.reverse();
|
if (settings.otherOrder) timestamp.reverse();
|
||||||
timestring = timestamp.length > 1 ? timestamp.join(", ") : (timestamp.length > 0 ? timestamp[0] : "");
|
timeString = timestamp.length > 1 ? timestamp.join(", ") : (timestamp.length > 0 ? timestamp[0] : "");
|
||||||
if (timestring && settings.forceZeros) timestring = this.addLeadingZeros(timestring);
|
if (timeString && settings.forceZeros) timeString = this.addLeadingZeros(timeString);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
languageId = BDFDB.LanguageUtils.getLanguage().id;
|
languageId = BDFDB.LanguageUtils.getLanguage().id;
|
||||||
let now = new Date();
|
let now = new Date();
|
||||||
let hour = timeobj.getHours(), minute = timeobj.getMinutes(), second = timeobj.getSeconds(), msecond = timeobj.getMilliseconds(), day = timeobj.getDate(), month = timeobj.getMonth()+1, timemode = "", daysago = Math.round((Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) - Date.UTC(timeobj.getFullYear(), timeobj.getMonth(), timeobj.getDate()))/(1000*60*60*24));
|
let hour = timeObj.getHours(), minute = timeObj.getMinutes(), second = timeObj.getSeconds(), msecond = timeObj.getMilliseconds(), day = timeObj.getDate(), month = timeObj.getMonth()+1, timemode = "", daysago = Math.round((Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) - Date.UTC(timeObj.getFullYear(), timeObj.getMonth(), timeObj.getDate()))/(1000*60*60*24));
|
||||||
if (formats.ownFormat.indexOf("$timemode") > -1) {
|
if (formats.ownFormat.indexOf("$timemode") > -1) {
|
||||||
timemode = hour >= 12 ? "PM" : "AM";
|
timemode = hour >= 12 ? "PM" : "AM";
|
||||||
hour = hour % 12;
|
hour = hour % 12;
|
||||||
hour = hour ? hour : 12;
|
hour = hour ? hour : 12;
|
||||||
}
|
}
|
||||||
timestring = formats.ownFormat
|
timeString = formats.ownFormat
|
||||||
.replace("$hour", settings.forceZeros && hour < 10 ? "0" + hour : hour)
|
.replace(/\$hour/g, settings.forceZeros && hour < 10 ? "0" + hour : hour)
|
||||||
.replace("$minute", minute < 10 ? "0" + minute : minute)
|
.replace(/\$minute/g, minute < 10 ? "0" + minute : minute)
|
||||||
.replace("$second", second < 10 ? "0" + second : second)
|
.replace(/\$second/g, second < 10 ? "0" + second : second)
|
||||||
.replace("$msecond", settings.forceZeros ? (msecond < 10 ? "00" + msecond : (msecond < 100 ? "0" + msecond : msecond)) : msecond)
|
.replace(/\$msecond/g, settings.forceZeros ? (msecond < 10 ? "00" + msecond : (msecond < 100 ? "0" + msecond : msecond)) : msecond)
|
||||||
.replace("$timemode", timemode)
|
.replace(/\$timemode/g, timemode)
|
||||||
.replace("$weekdayL", timeobj.toLocaleDateString(languageId,{weekday: "long"}))
|
.replace(/\$weekdayL/g, timeObj.toLocaleDateString(languageId, {weekday: "long"}))
|
||||||
.replace("$weekdayS", timeobj.toLocaleDateString(languageId,{weekday: "short"}))
|
.replace(/\$weekdayS/g, timeObj.toLocaleDateString(languageId, {weekday: "short"}))
|
||||||
.replace("$monthnameL", timeobj.toLocaleDateString(languageId,{month: "long"}))
|
.replace(/\$monthnameL/g, timeObj.toLocaleDateString(languageId, {month: "long"}))
|
||||||
.replace("$monthnameS", timeobj.toLocaleDateString(languageId,{month: "short"}))
|
.replace(/\$monthnameS/g, timeObj.toLocaleDateString(languageId, {month: "short"}))
|
||||||
.replace("$daysago", daysago > 0 ? BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", daysago) : BDFDB.LanguageUtils.LanguageStrings.SEARCH_SHORTCUT_TODAY)
|
.replace(/\$daysago/g, amounts.maxDaysAgo == 0 || amounts.maxDaysAgo <= daysago ? (daysago > 0 ? BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", daysago) : BDFDB.LanguageUtils.LanguageStrings.SEARCH_SHORTCUT_TODAY) : "")
|
||||||
.replace("$day", settings.forceZeros && day < 10 ? "0" + day : day)
|
.replace(/\$day/g, settings.forceZeros && day < 10 ? "0" + day : day)
|
||||||
.replace("$month", settings.forceZeros && month < 10 ? "0" + month : month)
|
.replace(/\$month/g, settings.forceZeros && month < 10 ? "0" + month : month)
|
||||||
.replace("$year", timeobj.getFullYear())
|
.replace(/\$yearS/g, parseInt(timeObj.getFullYear().toString().slice(-2)))
|
||||||
|
.replace(/\$year/g, timeObj.getFullYear())
|
||||||
.trim().split(" ").filter(n => n).join(" ");
|
.trim().split(" ").filter(n => n).join(" ");
|
||||||
}
|
}
|
||||||
return timestring;
|
return timeString;
|
||||||
}
|
}
|
||||||
|
|
||||||
cutOffSeconds (timestring) {
|
cutOffSeconds (timeString) {
|
||||||
return timestring.replace(/(.{1,2}:.{1,2}):.{1,2}(.*)/, "$1$2").replace(/(.{1,2}\..{1,2})\..{1,2}(.*)/, "$1$2").replace(/(.{1,2} h .{1,2} min) .{1,2} s(.*)/, "$1$2");
|
return timeString.replace(/(.{1,2}:.{1,2}):.{1,2}(.*)/, "$1$2").replace(/(.{1,2}\..{1,2})\..{1,2}(.*)/, "$1$2").replace(/(.{1,2} h .{1,2} min) .{1,2} s(.*)/, "$1$2");
|
||||||
}
|
}
|
||||||
|
|
||||||
addLeadingZeros (timestring) {
|
addLeadingZeros (timeString) {
|
||||||
let charArray = timestring.split("");
|
let charArray = timeString.split("");
|
||||||
let numreg = /[0-9]/;
|
let numreg = /[0-9]/;
|
||||||
for (let i = 0; i < charArray.length; i++) {
|
for (let i = 0; i < charArray.length; i++) {
|
||||||
if (!numreg.test(charArray[i-1]) && numreg.test(charArray[i]) && !numreg.test(charArray[i+1])) charArray[i] = "0" + charArray[i];
|
if (!numreg.test(charArray[i-1]) && numreg.test(charArray[i]) && !numreg.test(charArray[i+1])) charArray[i] = "0" + charArray[i];
|
||||||
|
@ -373,6 +390,7 @@ var LastMessageDate = (_ => {
|
||||||
settings = BDFDB.DataUtils.get(this, "settings");
|
settings = BDFDB.DataUtils.get(this, "settings");
|
||||||
choices = BDFDB.DataUtils.get(this, "choices");
|
choices = BDFDB.DataUtils.get(this, "choices");
|
||||||
formats = BDFDB.DataUtils.get(this, "formats");
|
formats = BDFDB.DataUtils.get(this, "formats");
|
||||||
|
amounts = BDFDB.DataUtils.get(this, "amounts");
|
||||||
|
|
||||||
BDFDB.ModuleUtils.forceAllUpdates(this);
|
BDFDB.ModuleUtils.forceAllUpdates(this);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue