Aevann 2024-08-18 18:19:57 +03:00
parent 4c72c9c49a
commit bd51c90345
5 changed files with 18 additions and 19 deletions

View File

@ -124,7 +124,7 @@ document.addEventListener("click", function(e) {
popover.getElementsByClassName('pop-coins')[0].innerHTML = author["coins"] popover.getElementsByClassName('pop-coins')[0].innerHTML = author["coins"]
popover.getElementsByClassName('pop-marseybux')[0].innerHTML = author["marseybux"] popover.getElementsByClassName('pop-marseybux')[0].innerHTML = author["marseybux"]
popover.getElementsByClassName('pop-view_more')[0].href = author["url"] popover.getElementsByClassName('pop-view_more')[0].href = author["url"]
popover.getElementsByClassName('pop-created-date')[0].innerHTML = author["created_date"] popover.getElementsByClassName('pop-created-date')[0].innerHTML = formatDate(new Date(author["created_utc"]*1000));
popover.getElementsByClassName('pop-id')[0].innerHTML = author["id"] popover.getElementsByClassName('pop-id')[0].innerHTML = author["id"]
if (author["original_usernames"]) { if (author["original_usernames"]) {
popover.getElementsByClassName('pop-original-usernames')[0].innerHTML = author["original_usernames"] popover.getElementsByClassName('pop-original-usernames')[0].innerHTML = author["original_usernames"]

View File

@ -224,15 +224,21 @@ function showmore(t) {
t.remove() t.remove()
} }
function formatDate(d) {
return d.toLocaleTimeString([], {year: 'numeric', month: 'short', day: 'numeric'}).split(',').slice(0, -1)
}
if (!location.pathname.startsWith('/chat/')) {
for (const e of document.querySelectorAll('[data-date]')) {
e.innerHTML = formatDate(new Date(e.dataset.date*1000));
};
}
function formatTime(d) { function formatTime(d) {
const options = {year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', timeZoneName: 'short'}; const options = {year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', timeZoneName: 'short'};
return d.toLocaleTimeString([], options) return d.toLocaleTimeString([], options)
} }
const timestamps = document.querySelectorAll('[data-time]');
if (!location.pathname.startsWith('/chat/')) { if (!location.pathname.startsWith('/chat/')) {
for (const e of timestamps) { for (const e of document.querySelectorAll('[data-time]')) {
e.innerHTML = formatTime(new Date(e.dataset.time*1000)); e.innerHTML = formatTime(new Date(e.dataset.time*1000));
}; };
} }

View File

@ -546,13 +546,6 @@ class User(Base):
def created_date(self): def created_date(self):
return time.strftime("%d %b %Y", time.gmtime(self.created_utc)) return time.strftime("%d %b %Y", time.gmtime(self.created_utc))
@property
@lazy
def last_active_date(self):
if self.last_active == 0:
return "never"
return time.strftime("%d %b %Y", time.gmtime(self.last_active))
@property @property
@lazy @lazy
def is_cakeday(self): def is_cakeday(self):
@ -1100,7 +1093,7 @@ class User(Base):
'post_count': commas(self.real_post_count(v)), 'post_count': commas(self.real_post_count(v)),
'comment_count': commas(self.real_comment_count(v)), 'comment_count': commas(self.real_comment_count(v)),
'badges': [[x.path, x.text, x.until] for x in self.ordered_badges(v)], 'badges': [[x.path, x.text, x.until] for x in self.ordered_badges(v)],
'created_date': self.created_date, 'created_utc': self.created_utc,
'original_usernames': self.original_usernames_popover, 'original_usernames': self.original_usernames_popover,
} }

View File

@ -26,10 +26,10 @@
{% endif %} {% endif %}
</div> </div>
<div id="profile--joined">Joined on <span id="profile--joined--time" data-time="{{u.created_utc}}"></span></div> <div id="profile--joined">Joined on <span id="profile--joined--time" data-date="{{u.created_utc}}"></span></div>
{% if v.admin_level >= PERMS['VIEW_LAST_ACTIVE'] -%} {% if v.admin_level >= PERMS['VIEW_LAST_ACTIVE'] -%}
<div id="profile--lastactive" class="mt-3">Last active on <span id="profile--lastactive--time" data-time="{{u.last_active}}"></span></div> <div id="profile--lastactive" class="mt-3">Last active on <span id="profile--lastactive--time" data-date="{{u.last_active}}"></span></div>
{%- endif %} {%- endif %}
{% if FEATURES['USERS_PROFILE_BODYTEXT'] and not hide_bios and u.bio_html and can_see(v, u) %} {% if FEATURES['USERS_PROFILE_BODYTEXT'] and not hide_bios and u.bio_html and can_see(v, u) %}

View File

@ -115,10 +115,10 @@
{% endif %} {% endif %}
</div> </div>
<span id="profile--joined">Joined <span id="profile--joined--time" data-bs-toggle="tooltip" data-bs-placement="bottom" data-nonce="{{g.nonce}}" data-onmouseover="timestamp(this, '{{u.created_utc}}')">{{u.created_date}}</span></span> <span id="profile--joined">Joined <span id="profile--joined--time" data-bs-toggle="tooltip" data-bs-placement="bottom" data-nonce="{{g.nonce}}" data-onmouseover="timestamp(this, '{{u.created_utc}}')" data-date="{{u.created_utc}}"></span></span>
{% if v and v.admin_level >= PERMS['VIEW_LAST_ACTIVE'] -%} {% if v and v.admin_level >= PERMS['VIEW_LAST_ACTIVE'] -%}
<span id="profile--lastactive" class="ml-2">last active <span id="profile--lastactive--time" data-bs-toggle="tooltip" data-bs-placement="bottom" data-nonce="{{g.nonce}}" data-onmouseover="timestamp(this, '{{u.last_active}}')">{{u.last_active_date}}</span></span> <span id="profile--lastactive" class="ml-2">last active <span id="profile--lastactive--time" data-bs-toggle="tooltip" data-bs-placement="bottom" data-nonce="{{g.nonce}}" data-onmouseover="timestamp(this, '{{u.last_active}}')" data-date="{{u.last_active}}"></span></span>
{%- endif %} {%- endif %}
</div> </div>
@ -425,10 +425,10 @@
<img loading="lazy" alt="marseybux" class="ml-1 mb-1 mr-2" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Marseybux" height="15" width="35" src="{{SITE_FULL_IMAGES}}/i/marseybux.webp?x=11"> <img loading="lazy" alt="marseybux" class="ml-1 mb-1 mr-2" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Marseybux" height="15" width="35" src="{{SITE_FULL_IMAGES}}/i/marseybux.webp?x=11">
{% endif %} {% endif %}
<br><span id="profile-mobile--joined">Joined <span id="profile-mobile--joined--time" data-bs-toggle="tooltip" data-bs-placement="bottom" data-nonce="{{g.nonce}}" data-onmouseover="timestamp(this, '{{u.created_utc}}')" class="font-weight-bold">{{u.created_date}}</span></span> <br><span id="profile-mobile--joined">Joined <span id="profile-mobile--joined--time" data-bs-toggle="tooltip" data-bs-placement="bottom" data-nonce="{{g.nonce}}" data-onmouseover="timestamp(this, '{{u.created_utc}}')" class="font-weight-bold" data-date="{{u.created_utc}}"></span></span>
{% if v and v.admin_level >= PERMS['VIEW_LAST_ACTIVE'] -%} {% if v and v.admin_level >= PERMS['VIEW_LAST_ACTIVE'] -%}
<br><span id="profile-mobile--lastactive">last active <span id="profile-mobile--lastactive--time" data-bs-toggle="tooltip" data-bs-placement="bottom" data-nonce="{{g.nonce}}" data-onmouseover="timestamp(this, '{{u.last_active}}')" class="font-weight-bold">{{u.last_active_date}}</span></span> <br><span id="profile-mobile--lastactive">last active <span id="profile-mobile--lastactive--time" data-bs-toggle="tooltip" data-bs-placement="bottom" data-nonce="{{g.nonce}}" data-onmouseover="timestamp(this, '{{u.last_active}}')" class="font-weight-bold" data-date="{{u.last_active}}"></span></span>
{%- endif %} {%- endif %}
</div> </div>