otwarchive-symphonyarchive/app/views/hit_count/_include.html.erb
2026-03-11 22:22:11 +00:00

19 lines
641 B
Text

<% unless RedisHitCounter.prevent_hits?(@work) || current_user&.is_author_of?(@work) %>
<% content_for :footer_js do %>
<script>
$j(document).on("loadedCSRF", function() {
function send() {
$j.post("<%= work_hit_count_path(@work, format: :json) %>")
}
// If a browser doesn't support prerendering, then document.prerendering
// will be undefined, and we'll just send the hit count immediately.
if (document.prerendering) {
document.addEventListener("prerenderingchange", send);
} else {
send();
}
})
</script>
<% end %>
<% end %>