szurubooru/public_html/templates/history.tpl

83 lines
2 KiB
Smarty
Raw Normal View History

<%
var reprValue = function(value) {
if (typeof(value) === 'string' || value instanceof String) {
return value;
}
return JSON.stringify(value);
};
2014-11-19 10:22:59 +01:00
var showDifference = function(className, difference) {
_.each(difference, function(value, key) {
if (!Array.isArray(value)) {
value = [value];
}
_.each(value, function(v) {
%><li class="<%= className %> difference-<%= key %>"><%= key + ':' + reprValue(v) %></li><%
});
});
};
%>
2014-09-26 20:41:28 +02:00
<table class="history">
<tbody>
<% _.each(history, function( historyEntry) { %>
<tr>
2014-12-20 10:30:10 +01:00
<td class="time" title="<%= util.formatAbsoluteTime(historyEntry.time) %>">
<%= util.formatRelativeTime(historyEntry.time) %>
2014-09-26 20:41:28 +02:00
</td>
<td class="user">
<% var userName = historyEntry.user && historyEntry.user.name || '' %>
<% if (userName) { %>
<a href="#/user/<%= userName %>">
<% } %>
2014-10-05 11:05:34 +02:00
<img width="20" height="20" class="author-avatar"
2014-09-26 20:41:28 +02:00
src="/data/thumbnails/20x20/avatars/<%= userName || '!' %>"
alt="<%= userName || 'Anonymous user' %>"/>
<%= userName || 'Anonymous user' %>
<% if (userName) { %>
</a>
<% } %>
</td>
<td class="subject">
<% if (historyEntry.type === 0) { %>
2014-09-26 20:41:28 +02:00
<a href="#/post/<%= historyEntry.primaryKey %>">
@<%= historyEntry.primaryKey %>
</a>
<% } else if (historyEntry.type === 1) { %>
<a href="#/tag/<%= historyEntry.data.name %>">
#<%= historyEntry.data.name %>
</a>
2014-09-26 20:41:28 +02:00
<% } else { %>
?
<% } %>
</td>
<td class="difference">
2014-11-09 17:04:04 +01:00
<% if (historyEntry.operation == 2) { %>
2014-09-26 20:41:28 +02:00
deleted
<% } else { %>
2014-11-09 17:04:04 +01:00
<% if (historyEntry.operation == 0) { %>
added
<% } else { %>
changed
<% } %>
2014-09-26 20:41:28 +02:00
<% if (historyEntry.dataDifference) { %>
<ul><!--
2014-11-19 10:22:59 +01:00
--><% showDifference('addition', historyEntry.dataDifference['+']) %><!--
--><% showDifference('removal', historyEntry.dataDifference['-']) %><!--
2014-09-26 20:41:28 +02:00
--></ul>
<% } %>
<% } %>
</td>
</tr>
<% }) %>
</tbody>
</table>