##// END OF EJS Templates
Updating bumplimit progress on thread update
neko259 -
r420:fbd9ed91 default
parent child Browse files
Show More
@@ -56,7 +56,6 b' function updateThread() {'
56 56 var bottom = isPageBottom();
57 57
58 58 var addedPosts = data.added;
59
60 59 for (var i = 0; i < addedPosts.length; i++) {
61 60 var postText = addedPosts[i];
62 61
@@ -95,6 +94,8 b' function updateThread() {'
95 94
96 95 $('#reply-count').text(getReplyCount());
97 96 $('#image-count').text(getImageCount());
97
98 updateBumplimitProgress(data.added.length + data.updated.length);
98 99 })
99 100 .error(function(data) {
100 101 // TODO Show error message that server is unavailable?
@@ -125,3 +126,22 b' function getReplyCount() {'
125 126 function getImageCount() {
126 127 return $('.thread').find('img').length
127 128 }
129
130 function updateBumplimitProgress(postDelta) {
131 var progressBar = $('#bumplimit_progress');
132 if (progressBar) {
133 var postsToLimitElement = $('#left_to_limit');
134
135 var oldPostsToLimit = parseInt(postsToLimitElement.text());
136 var postCount = getReplyCount();
137 var bumplimit = postCount - postDelta + oldPostsToLimit;
138
139 var newPostsToLimit = bumplimit - postCount;
140 if (newPostsToLimit < 0) {
141 progressBar.remove();
142 } else {
143 postsToLimitElement.text(newPostsToLimit);
144 progressBar.width((100 - postCount / bumplimit * 100.0) + '%');
145 }
146 }
147 } No newline at end of file
@@ -1,6 +1,7 b''
1 1 {% load i18n %}
2 2 {% load board %}
3 3
4 {% spaceless %}
4 5 {% if can_bump %}
5 6 <div class="post" id="{{ post.id }}">
6 7 {% else %}
@@ -66,3 +67,4 b''
66 67 </div>
67 68 {% endif %}
68 69 </div>
70 {% endspaceless %} No newline at end of file
@@ -10,6 +10,7 b''
10 10 {% endblock %}
11 11
12 12 {% block content %}
13 {% spaceless %}
13 14 {% get_current_language as LANGUAGE_CODE %}
14 15
15 16 <script src="{% static 'js/thread_update.js' %}"></script>
@@ -18,10 +19,10 b''
18 19 {% cache 600 thread_view thread.id thread.last_edit_time moderator LANGUAGE_CODE %}
19 20 {% if bumpable %}
20 21 <div class="bar-bg">
21 <div class="bar-value" style="width:{{ bumplimit_progress }}%">
22 <div class="bar-value" style="width:{{ bumplimit_progress }}%" id="bumplimit_progress">
22 23 </div>
23 24 <div class="bar-text">
24 {{ posts_left }} {% trans 'posts to bumplimit' %}
25 <span id="left_to_limit">{{ posts_left }}</span> {% trans 'posts to bumplimit' %}
25 26 </div>
26 27 </div>
27 28 {% endif %}
@@ -143,6 +144,7 b''
143 144 </div>
144 145 </form>
145 146
147 {% endspaceless %}
146 148 {% endblock %}
147 149
148 150 {% block metapanel %}
General Comments 0
You need to be logged in to leave comments. Login now