store post view counts in reportbooru/fetch view counts from reportbooru #2128

This commit is contained in:
r888888888
2015-07-21 13:09:32 -07:00
parent ee52ca8b66
commit 9e6d08600c
6 changed files with 66 additions and 0 deletions

View File

@@ -25,6 +25,7 @@
this.initialize_post_image_resize_links();
this.initialize_post_image_resize_to_window_link();
this.initialize_similar();
this.initialize_view_count();
if (Danbooru.meta("always-resize-images") === "true") {
$("#image-resize-to-window-link").click();
@@ -529,6 +530,25 @@
}
});
}
Danbooru.Post.initialize_view_count = function() {
if ($("#views-for-post").length) {
$("#views-for-post-li").hide();
var current_post_id = $("meta[name=post-id]").attr("content");
$.ajax({
url: Danbooru.meta("report-server") + "/hits/pv-" + current_post_id,
success: function(data) {
$("#views-for-post").html(data);
$("#views-for-post-li").show();
},
dataType: "text"
});
}
}
Danbooru.Post.set_view_count = function(count) {
$("#views-for-post").html(count);
}
})();
$(document).ready(function() {