speed up mod view display
This commit is contained in:
parent
eaf53df13f
commit
c36d856b8f
|
@ -74,13 +74,14 @@ trait DateHelper { self: I18nHelper =>
|
|||
def isoDate(date: DateTime): String = isoFormatter print date
|
||||
|
||||
private val oneDayMillis = 1000 * 60 * 60 * 24
|
||||
def momentFromNow(date: DateTime, alwaysRelative: Boolean = false) = Html {
|
||||
def momentFromNow(date: DateTime, alwaysRelative: Boolean = false, once: Boolean = false) = Html {
|
||||
if (!alwaysRelative && (date.getMillis - nowMillis) > oneDayMillis) absClientDateTime(date)
|
||||
s"""<time class="timeago" datetime="${isoDate(date)}"></time>"""
|
||||
s"""<time class="timeago${if (once) " once" else ""}" datetime="${isoDate(date)}"></time>"""
|
||||
}
|
||||
def absClientDateTime(date: DateTime) = Html {
|
||||
s"""<time class="timeago abs" datetime="${isoDate(date)}"></time>"""
|
||||
}
|
||||
def momentFromNowOnce(date: DateTime) = momentFromNow(date, once = true)
|
||||
|
||||
def secondsFromNow(seconds: Int, alwaysRelative: Boolean = false)(implicit ctx: Context) =
|
||||
momentFromNow(DateTime.now plusSeconds seconds, alwaysRelative)
|
||||
|
|
|
@ -233,7 +233,7 @@
|
|||
@if(history.nonEmpty) {
|
||||
<ul>
|
||||
@history.map { e =>
|
||||
<li>@userIdLink(e.mod.some, withTitle=false) <b>@e.showAction</b> @e.details @momentFromNow(e.date)</li>
|
||||
<li>@userIdLink(e.mod.some, withTitle=false) <b>@e.showAction</b> @e.details @momentFromNowOnce(e.date)</li>
|
||||
}
|
||||
</ul>
|
||||
<br />
|
||||
|
@ -250,7 +250,7 @@
|
|||
@userIdLink(r.user.some)
|
||||
<div class="atoms">
|
||||
<div class="atom">
|
||||
@userIdLink(r.user.some), @momentFromNow(atom.at): @shorten(atom.text, 200)
|
||||
@userIdLink(r.user.some), @momentFromNowOnce(atom.at): @shorten(atom.text, 200)
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
@ -268,7 +268,7 @@
|
|||
<div class="atoms">
|
||||
@r.bestAtoms(3).map { atom =>
|
||||
<div class="atom">
|
||||
By @userIdLink(atom.by.value.some), @momentFromNow(atom.at): @shorten(atom.text, 200)
|
||||
By @userIdLink(atom.by.value.some), @momentFromNowOnce(atom.at): @shorten(atom.text, 200)
|
||||
</div>
|
||||
}
|
||||
@if(r.atoms.size > 3) { (and @{r.atoms.size - 3} more) }
|
||||
|
@ -309,8 +309,8 @@
|
|||
}
|
||||
@userMarks(o, bans.get(o.id))
|
||||
</td>
|
||||
<td data-sort="@o.createdAt.getMillis">@momentFromNow(o.createdAt)</td>
|
||||
<td data-sort="@o.seenAt.map(_.getMillis)">@o.seenAt.map(momentFromNow(_))</td>
|
||||
<td data-sort="@o.createdAt.getMillis">@momentFromNowOnce(o.createdAt)</td>
|
||||
<td data-sort="@o.seenAt.map(_.getMillis)">@o.seenAt.map(momentFromNowOnce)</td>
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
|
@ -326,7 +326,7 @@
|
|||
@ips.map { ip =>
|
||||
<li class="ip">
|
||||
<a class="address @if(ip.blocked){blocked}" href="@{routes.Mod.search}?q=@ip.ip.value">
|
||||
<ip>@ip.ip.value.value</ip> @momentFromNow(ip.ip.date)
|
||||
<ip>@ip.ip.value.value</ip> @momentFromNowOnce(ip.ip.date)
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
|
@ -339,7 +339,7 @@
|
|||
<div class="spy_uas">
|
||||
<strong>@spy.uas.size User agent(s)</strong> <ul>@spy.uas.sorted.map { ua =>
|
||||
<li>
|
||||
@ua.value @momentFromNow(ua.date)
|
||||
@ua.value @momentFromNowOnce(ua.date)
|
||||
</li>
|
||||
}</ul>
|
||||
</div>
|
||||
|
@ -347,7 +347,7 @@
|
|||
<strong>@pluralize("Fingerprint", spy.prints.size)</strong> <ul>@spy.prints.sorted.map { fp =>
|
||||
<li>
|
||||
<a href="@{routes.Mod.search}?q=@{java.net.URLEncoder.encode(fp.value.value, "US-ASCII")}">
|
||||
@fp.value.value @momentFromNow(fp.date)
|
||||
@fp.value.value @momentFromNowOnce(fp.date)
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
|
|
|
@ -75,7 +75,8 @@ lichess.timeago = (function() {
|
|||
str = formatter()(node.date);
|
||||
if (abs) node.textContent = str;
|
||||
else node.setAttribute('title', str);
|
||||
node.classList.add('set');
|
||||
cl.add('set');
|
||||
if (cl.contains('once')) cl.remove('timeago');
|
||||
}
|
||||
if (!abs) node.textContent = formatDiff(diffSec(node.date));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue