##// 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 var bottom = isPageBottom();
56 var bottom = isPageBottom();
57
57
58 var addedPosts = data.added;
58 var addedPosts = data.added;
59
60 for (var i = 0; i < addedPosts.length; i++) {
59 for (var i = 0; i < addedPosts.length; i++) {
61 var postText = addedPosts[i];
60 var postText = addedPosts[i];
62
61
@@ -95,6 +94,8 b' function updateThread() {'
95
94
96 $('#reply-count').text(getReplyCount());
95 $('#reply-count').text(getReplyCount());
97 $('#image-count').text(getImageCount());
96 $('#image-count').text(getImageCount());
97
98 updateBumplimitProgress(data.added.length + data.updated.length);
98 })
99 })
99 .error(function(data) {
100 .error(function(data) {
100 // TODO Show error message that server is unavailable?
101 // TODO Show error message that server is unavailable?
@@ -125,3 +126,22 b' function getReplyCount() {'
125 function getImageCount() {
126 function getImageCount() {
126 return $('.thread').find('img').length
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 {% load i18n %}
1 {% load i18n %}
2 {% load board %}
2 {% load board %}
3
3
4 {% spaceless %}
4 {% if can_bump %}
5 {% if can_bump %}
5 <div class="post" id="{{ post.id }}">
6 <div class="post" id="{{ post.id }}">
6 {% else %}
7 {% else %}
@@ -66,3 +67,4 b''
66 </div>
67 </div>
67 {% endif %}
68 {% endif %}
68 </div>
69 </div>
70 {% endspaceless %} No newline at end of file
@@ -10,6 +10,7 b''
10 {% endblock %}
10 {% endblock %}
11
11
12 {% block content %}
12 {% block content %}
13 {% spaceless %}
13 {% get_current_language as LANGUAGE_CODE %}
14 {% get_current_language as LANGUAGE_CODE %}
14
15
15 <script src="{% static 'js/thread_update.js' %}"></script>
16 <script src="{% static 'js/thread_update.js' %}"></script>
@@ -18,10 +19,10 b''
18 {% cache 600 thread_view thread.id thread.last_edit_time moderator LANGUAGE_CODE %}
19 {% cache 600 thread_view thread.id thread.last_edit_time moderator LANGUAGE_CODE %}
19 {% if bumpable %}
20 {% if bumpable %}
20 <div class="bar-bg">
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 </div>
23 </div>
23 <div class="bar-text">
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 </div>
26 </div>
26 </div>
27 </div>
27 {% endif %}
28 {% endif %}
@@ -143,6 +144,7 b''
143 </div>
144 </div>
144 </form>
145 </form>
145
146
147 {% endspaceless %}
146 {% endblock %}
148 {% endblock %}
147
149
148 {% block metapanel %}
150 {% block metapanel %}
General Comments 0
You need to be logged in to leave comments. Login now