Show More
@@ -1,147 +1,164 b'' | |||||
1 | /* |
|
1 | /* | |
2 | @licstart The following is the entire license notice for the |
|
2 | @licstart The following is the entire license notice for the | |
3 | JavaScript code in this page. |
|
3 | JavaScript code in this page. | |
4 |
|
4 | |||
5 |
|
5 | |||
6 | Copyright (C) 2013 neko259 |
|
6 | Copyright (C) 2013 neko259 | |
7 |
|
7 | |||
8 | The JavaScript code in this page is free software: you can |
|
8 | The JavaScript code in this page is free software: you can | |
9 | redistribute it and/or modify it under the terms of the GNU |
|
9 | redistribute it and/or modify it under the terms of the GNU | |
10 | General Public License (GNU GPL) as published by the Free Software |
|
10 | General Public License (GNU GPL) as published by the Free Software | |
11 | Foundation, either version 3 of the License, or (at your option) |
|
11 | Foundation, either version 3 of the License, or (at your option) | |
12 | any later version. The code is distributed WITHOUT ANY WARRANTY; |
|
12 | any later version. The code is distributed WITHOUT ANY WARRANTY; | |
13 | without even the implied warranty of MERCHANTABILITY or FITNESS |
|
13 | without even the implied warranty of MERCHANTABILITY or FITNESS | |
14 | FOR A PARTICULAR PURPOSE. See the GNU GPL for more details. |
|
14 | FOR A PARTICULAR PURPOSE. See the GNU GPL for more details. | |
15 |
|
15 | |||
16 | As additional permission under GNU GPL version 3 section 7, you |
|
16 | As additional permission under GNU GPL version 3 section 7, you | |
17 | may distribute non-source (e.g., minimized or compacted) forms of |
|
17 | may distribute non-source (e.g., minimized or compacted) forms of | |
18 | that code without the copy of the GNU GPL normally required by |
|
18 | that code without the copy of the GNU GPL normally required by | |
19 | section 4, provided you include this license notice and a URL |
|
19 | section 4, provided you include this license notice and a URL | |
20 | through which recipients can access the Corresponding Source. |
|
20 | through which recipients can access the Corresponding Source. | |
21 |
|
21 | |||
22 | @licend The above is the entire license notice |
|
22 | @licend The above is the entire license notice | |
23 | for the JavaScript code in this page. |
|
23 | for the JavaScript code in this page. | |
24 | */ |
|
24 | */ | |
25 |
|
25 | |||
26 | var THREAD_UPDATE_DELAY = 10000; |
|
26 | var THREAD_UPDATE_DELAY = 10000; | |
27 |
|
27 | |||
28 | var loading = false; |
|
28 | var loading = false; | |
29 | var lastUpdateTime = null; |
|
29 | var lastUpdateTime = null; | |
30 |
|
30 | |||
31 | function blink(node) { |
|
31 | function blink(node) { | |
32 | var blinkCount = 2; |
|
32 | var blinkCount = 2; | |
33 | var blinkDelay = 250; |
|
33 | var blinkDelay = 250; | |
34 |
|
34 | |||
35 | var nodeToAnimate = node; |
|
35 | var nodeToAnimate = node; | |
36 | for (var i = 0; i < blinkCount; i++) { |
|
36 | for (var i = 0; i < blinkCount; i++) { | |
37 | nodeToAnimate = nodeToAnimate.fadeOut(blinkDelay).fadeIn(blinkDelay); |
|
37 | nodeToAnimate = nodeToAnimate.fadeOut(blinkDelay).fadeIn(blinkDelay); | |
38 | } |
|
38 | } | |
39 | } |
|
39 | } | |
40 |
|
40 | |||
41 | function updateThread() { |
|
41 | function updateThread() { | |
42 | if (loading) { |
|
42 | if (loading) { | |
43 | return; |
|
43 | return; | |
44 | } |
|
44 | } | |
45 |
|
45 | |||
46 | loading = true; |
|
46 | loading = true; | |
47 |
|
47 | |||
48 | var threadPosts = $('div.thread').children('.post'); |
|
48 | var threadPosts = $('div.thread').children('.post'); | |
49 |
|
49 | |||
50 | var lastPost = threadPosts.last(); |
|
50 | var lastPost = threadPosts.last(); | |
51 | var threadId = threadPosts.first().attr('id'); |
|
51 | var threadId = threadPosts.first().attr('id'); | |
52 |
|
52 | |||
53 | var diffUrl = '/api/diff_thread/' + threadId + '/' + lastUpdateTime + '/'; |
|
53 | var diffUrl = '/api/diff_thread/' + threadId + '/' + lastUpdateTime + '/'; | |
54 | $.getJSON(diffUrl) |
|
54 | $.getJSON(diffUrl) | |
55 | .success(function(data) { |
|
55 | .success(function(data) { | |
56 | var bottom = isPageBottom(); |
|
56 | var bottom = isPageBottom(); | |
57 |
|
57 | |||
58 | var addedPosts = data.added; |
|
58 | var addedPosts = data.added; | |
59 | for (var i = 0; i < addedPosts.length; i++) { |
|
59 | for (var i = 0; i < addedPosts.length; i++) { | |
60 | var postText = addedPosts[i]; |
|
60 | var postText = addedPosts[i]; | |
61 |
|
61 | |||
62 | var post = $(postText); |
|
62 | var post = $(postText); | |
63 | post.appendTo(lastPost.parent()); |
|
63 | post.appendTo(lastPost.parent()); | |
64 | addRefLinkPreview(post[0]); |
|
64 | addRefLinkPreview(post[0]); | |
65 |
|
65 | |||
66 | lastPost = post; |
|
66 | lastPost = post; | |
67 | blink(post); |
|
67 | blink(post); | |
68 | } |
|
68 | } | |
69 |
|
69 | |||
70 | var updatedPosts = data.updated; |
|
70 | var updatedPosts = data.updated; | |
71 | for (var i = 0; i < updatedPosts.length; i++) { |
|
71 | for (var i = 0; i < updatedPosts.length; i++) { | |
72 | var postText = updatedPosts[i]; |
|
72 | var postText = updatedPosts[i]; | |
73 |
|
73 | |||
74 | var post = $(postText); |
|
74 | var post = $(postText); | |
75 | var postId = post.attr('id'); |
|
75 | var postId = post.attr('id'); | |
76 |
|
76 | |||
77 | var oldPost = $('div.thread').children('.post[id=' + postId + ']'); |
|
77 | var oldPost = $('div.thread').children('.post[id=' + postId + ']'); | |
78 |
|
78 | |||
79 | oldPost.replaceWith(post); |
|
79 | oldPost.replaceWith(post); | |
80 | addRefLinkPreview(post[0]); |
|
80 | addRefLinkPreview(post[0]); | |
81 |
|
81 | |||
82 | blink(post); |
|
82 | blink(post); | |
83 | } |
|
83 | } | |
84 |
|
84 | |||
85 | // TODO Process deleted posts |
|
85 | // TODO Process deleted posts | |
86 |
|
86 | |||
87 | lastUpdateTime = data.last_update; |
|
87 | lastUpdateTime = data.last_update; | |
88 | loading = false; |
|
88 | loading = false; | |
89 |
|
89 | |||
90 | if (bottom) { |
|
90 | if (bottom) { | |
91 | var $target = $('html,body'); |
|
91 | var $target = $('html,body'); | |
92 | $target.animate({scrollTop: $target.height()}, 1000); |
|
92 | $target.animate({scrollTop: $target.height()}, 1000); | |
93 | } |
|
93 | } | |
94 |
|
94 | |||
95 | $('#reply-count').text(getReplyCount()); |
|
95 | $('#reply-count').text(getReplyCount()); | |
96 | $('#image-count').text(getImageCount()); |
|
96 | $('#image-count').text(getImageCount()); | |
97 |
|
97 | |||
98 | updateBumplimitProgress(data.added.length); |
|
98 | updateBumplimitProgress(data.added.length); | |
|
99 | updatePostBumpableStatus(); | |||
99 | }) |
|
100 | }) | |
100 | .error(function(data) { |
|
101 | .error(function(data) { | |
101 | // TODO Show error message that server is unavailable? |
|
102 | // TODO Show error message that server is unavailable? | |
102 |
|
103 | |||
103 | loading = false; |
|
104 | loading = false; | |
104 | }); |
|
105 | }); | |
105 | } |
|
106 | } | |
106 |
|
107 | |||
107 | function isPageBottom() { |
|
108 | function isPageBottom() { | |
108 | var scroll = $(window).scrollTop() / ($(document).height() |
|
109 | var scroll = $(window).scrollTop() / ($(document).height() | |
109 | - $(window).height()) |
|
110 | - $(window).height()) | |
110 |
|
111 | |||
111 | return scroll == 1 |
|
112 | return scroll == 1 | |
112 | } |
|
113 | } | |
113 |
|
114 | |||
114 | function initAutoupdate() { |
|
115 | function initAutoupdate() { | |
115 | loading = false; |
|
116 | loading = false; | |
116 |
|
117 | |||
117 | lastUpdateTime = $('.metapanel').attr('data-last-update'); |
|
118 | lastUpdateTime = $('.metapanel').attr('data-last-update'); | |
118 |
|
119 | |||
119 | setInterval(updateThread, THREAD_UPDATE_DELAY); |
|
120 | setInterval(updateThread, THREAD_UPDATE_DELAY); | |
120 | } |
|
121 | } | |
121 |
|
122 | |||
122 | function getReplyCount() { |
|
123 | function getReplyCount() { | |
123 | return $('.thread').children('.post').length |
|
124 | return $('.thread').children('.post').length | |
124 | } |
|
125 | } | |
125 |
|
126 | |||
126 | function getImageCount() { |
|
127 | function getImageCount() { | |
127 | return $('.thread').find('img').length |
|
128 | return $('.thread').find('img').length | |
128 | } |
|
129 | } | |
129 |
|
130 | |||
|
131 | /** | |||
|
132 | * Update bumplimit progress bar | |||
|
133 | */ | |||
130 | function updateBumplimitProgress(postDelta) { |
|
134 | function updateBumplimitProgress(postDelta) { | |
131 | var progressBar = $('#bumplimit_progress'); |
|
135 | var progressBar = $('#bumplimit_progress'); | |
132 | if (progressBar) { |
|
136 | if (progressBar) { | |
133 | var postsToLimitElement = $('#left_to_limit'); |
|
137 | var postsToLimitElement = $('#left_to_limit'); | |
134 |
|
138 | |||
135 | var oldPostsToLimit = parseInt(postsToLimitElement.text()); |
|
139 | var oldPostsToLimit = parseInt(postsToLimitElement.text()); | |
136 | var postCount = getReplyCount(); |
|
140 | var postCount = getReplyCount(); | |
137 | var bumplimit = postCount - postDelta + oldPostsToLimit; |
|
141 | var bumplimit = postCount - postDelta + oldPostsToLimit; | |
138 |
|
142 | |||
139 | var newPostsToLimit = bumplimit - postCount; |
|
143 | var newPostsToLimit = bumplimit - postCount; | |
140 | if (newPostsToLimit < 0) { |
|
144 | if (newPostsToLimit <= 0) { | |
141 |
|
|
145 | $('.bar-bg').remove(); | |
142 | } else { |
|
146 | } else { | |
143 | postsToLimitElement.text(newPostsToLimit); |
|
147 | postsToLimitElement.text(newPostsToLimit); | |
144 | progressBar.width((100 - postCount / bumplimit * 100.0) + '%'); |
|
148 | progressBar.width((100 - postCount / bumplimit * 100.0) + '%'); | |
145 | } |
|
149 | } | |
146 | } |
|
150 | } | |
147 | } |
|
151 | } | |
|
152 | ||||
|
153 | /** | |||
|
154 | * If the bumplimit is reached, add dead_post class to all posts | |||
|
155 | */ | |||
|
156 | function updatePostBumpableStatus() { | |||
|
157 | var postCount = getReplyCount(); | |||
|
158 | var postsToLimitElement = $('#left_to_limit'); | |||
|
159 | var postsToLimit = parseInt(postsToLimitElement.text()); | |||
|
160 | ||||
|
161 | if (postsToLimit <= 0) { | |||
|
162 | $('.thread').find('.post').addClass('dead_post'); | |||
|
163 | } | |||
|
164 | } |
@@ -1,48 +1,48 b'' | |||||
1 | = Features = |
|
1 | = Features = | |
2 | [DONE] Connecting tags to each other |
|
2 | [DONE] Connecting tags to each other | |
3 | [DONE] Connect posts to the replies (in messages), get rid of the JS reply map |
|
3 | [DONE] Connect posts to the replies (in messages), get rid of the JS reply map | |
4 | [DONE] Better django admin pages to simplify admin operations |
|
4 | [DONE] Better django admin pages to simplify admin operations | |
5 | [DONE] Regen script to update all posts |
|
5 | [DONE] Regen script to update all posts | |
6 | [DONE] Remove jump links from refmaps |
|
6 | [DONE] Remove jump links from refmaps | |
7 | [DONE] Ban reasons. Split bans into 2 types "read-only" and "read |
|
7 | [DONE] Ban reasons. Split bans into 2 types "read-only" and "read | |
8 | denied". Use second only for autoban for spam |
|
8 | denied". Use second only for autoban for spam | |
9 | [DONE] Clean up tests and make them run ALWAYS |
|
9 | [DONE] Clean up tests and make them run ALWAYS | |
10 | [DONE] Use transactions in tests |
|
10 | [DONE] Use transactions in tests | |
11 | [DONE] Thread autoupdate (JS + API) |
|
11 | [DONE] Thread autoupdate (JS + API) | |
12 | [DONE] Split up post model into post and thread, |
|
12 | [DONE] Split up post model into post and thread, | |
13 | and move everything that is used only in 1st post to thread model. |
|
13 | and move everything that is used only in 1st post to thread model. | |
14 | [DONE] Show board speed in the lower panel (posts per day) |
|
14 | [DONE] Show board speed in the lower panel (posts per day) | |
15 |
|
15 | |||
16 | [NOT STARTED] Tree view (JS) |
|
16 | [NOT STARTED] Tree view (JS) | |
17 | [NOT STARTED] Adding tags to images filename |
|
17 | [NOT STARTED] Adding tags to images filename | |
18 | [NOT STARTED] Federative network for s2s communication |
|
18 | [NOT STARTED] Federative network for s2s communication | |
19 | [NOT STARTED] XMPP gate |
|
19 | [NOT STARTED] XMPP gate | |
20 | [NOT STARTED] Bitmessage gate |
|
20 | [NOT STARTED] Bitmessage gate | |
21 | [NOT STARTED] Notification engine |
|
21 | [NOT STARTED] Notification engine | |
22 | [NOT STARTED] Javascript disabling engine |
|
22 | [NOT STARTED] Javascript disabling engine | |
23 | [NOT STARTED] Group tags by first letter in all tags list |
|
23 | [NOT STARTED] Group tags by first letter in all tags list | |
24 | [NOT STARTED] Character counter in the post field |
|
24 | [NOT STARTED] Character counter in the post field | |
25 | [NOT STARTED] Save image thumbnails size to the separate field |
|
25 | [NOT STARTED] Save image thumbnails size to the separate field | |
26 | [NOT STARTED] Whitelist functionality. Permin autoban of an address |
|
26 | [NOT STARTED] Whitelist functionality. Permin autoban of an address | |
27 | [NOT STARTED] Statistics module. Count views (optional, may result in bad |
|
27 | [NOT STARTED] Statistics module. Count views (optional, may result in bad | |
28 | performance), posts per day/week/month, users (or IPs) |
|
28 | performance), posts per day/week/month, users (or IPs) | |
29 | [NOT STARTED] Quote button next to "reply" for posts in thread to include full |
|
29 | [NOT STARTED] Quote button next to "reply" for posts in thread to include full | |
30 | post or its part (delimited by N characters) into quote of the new post. |
|
30 | post or its part (delimited by N characters) into quote of the new post. | |
31 | [NOT STARTED] Ban confirmation page with reason |
|
31 | [NOT STARTED] Ban confirmation page with reason | |
32 | [NOT STARTED] Post deletion confirmation page |
|
32 | [NOT STARTED] Post deletion confirmation page | |
33 | [NOT STARTED] Moderating page. Tags editing and adding |
|
33 | [NOT STARTED] Moderating page. Tags editing and adding | |
34 | [NOT STARTED] Get thread graph image using pygraphviz |
|
34 | [NOT STARTED] Get thread graph image using pygraphviz | |
35 | [NOT STARTED] Creating post via AJAX without reloading page |
|
35 | [NOT STARTED] Creating post via AJAX without reloading page | |
36 | [NOT STARTED] Subscribing to tag via AJAX |
|
36 | [NOT STARTED] Subscribing to tag via AJAX | |
37 |
|
37 | |||
38 | = Bugs = |
|
38 | = Bugs = | |
39 | [DONE] Fix bug with creating threads from tag view |
|
39 | [DONE] Fix bug with creating threads from tag view | |
40 | [DONE] Quote characters within quote causes quote parsing to fail |
|
40 | [DONE] Quote characters within quote causes quote parsing to fail | |
41 |
|
41 | |||
42 | [IN PROGRESS] Replies, images, last update time in bottom panel doesn't change when |
|
42 | [IN PROGRESS] Replies, images, last update time in bottom panel doesn't change when | |
43 | thread updates |
|
43 | thread updates (last update changing left) | |
44 |
|
44 | |||
45 | = Testing = |
|
45 | = Testing = | |
46 | [NOT STARTED] Make tests for every view |
|
46 | [NOT STARTED] Make tests for every view | |
47 | [NOT STARTED] Make tests for every model |
|
47 | [NOT STARTED] Make tests for every model | |
48 | [NOT STARTED] Make tests for every form |
|
48 | [NOT STARTED] Make tests for every form |
General Comments 0
You need to be logged in to leave comments.
Login now