Show More
@@ -1,127 +1,147 b'' | |||
|
1 | 1 | /* |
|
2 | 2 | @licstart The following is the entire license notice for the |
|
3 | 3 | JavaScript code in this page. |
|
4 | 4 | |
|
5 | 5 | |
|
6 | 6 | Copyright (C) 2013 neko259 |
|
7 | 7 | |
|
8 | 8 | The JavaScript code in this page is free software: you can |
|
9 | 9 | redistribute it and/or modify it under the terms of the GNU |
|
10 | 10 | General Public License (GNU GPL) as published by the Free Software |
|
11 | 11 | Foundation, either version 3 of the License, or (at your option) |
|
12 | 12 | any later version. The code is distributed WITHOUT ANY WARRANTY; |
|
13 | 13 | without even the implied warranty of MERCHANTABILITY or FITNESS |
|
14 | 14 | FOR A PARTICULAR PURPOSE. See the GNU GPL for more details. |
|
15 | 15 | |
|
16 | 16 | As additional permission under GNU GPL version 3 section 7, you |
|
17 | 17 | may distribute non-source (e.g., minimized or compacted) forms of |
|
18 | 18 | that code without the copy of the GNU GPL normally required by |
|
19 | 19 | section 4, provided you include this license notice and a URL |
|
20 | 20 | through which recipients can access the Corresponding Source. |
|
21 | 21 | |
|
22 | 22 | @licend The above is the entire license notice |
|
23 | 23 | for the JavaScript code in this page. |
|
24 | 24 | */ |
|
25 | 25 | |
|
26 | 26 | var THREAD_UPDATE_DELAY = 10000; |
|
27 | 27 | |
|
28 | 28 | var loading = false; |
|
29 | 29 | var lastUpdateTime = null; |
|
30 | 30 | |
|
31 | 31 | function blink(node) { |
|
32 | 32 | var blinkCount = 2; |
|
33 | 33 | var blinkDelay = 250; |
|
34 | 34 | |
|
35 | 35 | var nodeToAnimate = node; |
|
36 | 36 | for (var i = 0; i < blinkCount; i++) { |
|
37 | 37 | nodeToAnimate = nodeToAnimate.fadeOut(blinkDelay).fadeIn(blinkDelay); |
|
38 | 38 | } |
|
39 | 39 | } |
|
40 | 40 | |
|
41 | 41 | function updateThread() { |
|
42 | 42 | if (loading) { |
|
43 | 43 | return; |
|
44 | 44 | } |
|
45 | 45 | |
|
46 | 46 | loading = true; |
|
47 | 47 | |
|
48 | 48 | var threadPosts = $('div.thread').children('.post'); |
|
49 | 49 | |
|
50 | 50 | var lastPost = threadPosts.last(); |
|
51 | 51 | var threadId = threadPosts.first().attr('id'); |
|
52 | 52 | |
|
53 | 53 | var diffUrl = '/api/diff_thread/' + threadId + '/' + lastUpdateTime + '/'; |
|
54 | 54 | $.getJSON(diffUrl) |
|
55 | 55 | .success(function(data) { |
|
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 | |
|
63 | 62 | var post = $(postText); |
|
64 | 63 | post.appendTo(lastPost.parent()); |
|
65 | 64 | addRefLinkPreview(post[0]); |
|
66 | 65 | |
|
67 | 66 | lastPost = post; |
|
68 | 67 | blink(post); |
|
69 | 68 | } |
|
70 | 69 | |
|
71 | 70 | var updatedPosts = data.updated; |
|
72 | 71 | for (var i = 0; i < updatedPosts.length; i++) { |
|
73 | 72 | var postText = updatedPosts[i]; |
|
74 | 73 | |
|
75 | 74 | var post = $(postText); |
|
76 | 75 | var postId = post.attr('id'); |
|
77 | 76 | |
|
78 | 77 | var oldPost = $('div.thread').children('.post[id=' + postId + ']'); |
|
79 | 78 | |
|
80 | 79 | oldPost.replaceWith(post); |
|
81 | 80 | addRefLinkPreview(post[0]); |
|
82 | 81 | |
|
83 | 82 | blink(post); |
|
84 | 83 | } |
|
85 | 84 | |
|
86 | 85 | // TODO Process deleted posts |
|
87 | 86 | |
|
88 | 87 | lastUpdateTime = data.last_update; |
|
89 | 88 | loading = false; |
|
90 | 89 | |
|
91 | 90 | if (bottom) { |
|
92 | 91 | var $target = $('html,body'); |
|
93 | 92 | $target.animate({scrollTop: $target.height()}, 1000); |
|
94 | 93 | } |
|
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? |
|
101 | 102 | |
|
102 | 103 | loading = false; |
|
103 | 104 | }); |
|
104 | 105 | } |
|
105 | 106 | |
|
106 | 107 | function isPageBottom() { |
|
107 | 108 | var scroll = $(window).scrollTop() / ($(document).height() |
|
108 | 109 | - $(window).height()) |
|
109 | 110 | |
|
110 | 111 | return scroll == 1 |
|
111 | 112 | } |
|
112 | 113 | |
|
113 | 114 | function initAutoupdate() { |
|
114 | 115 | loading = false; |
|
115 | 116 | |
|
116 | 117 | lastUpdateTime = $('.metapanel').attr('data-last-update'); |
|
117 | 118 | |
|
118 | 119 | setInterval(updateThread, THREAD_UPDATE_DELAY); |
|
119 | 120 | } |
|
120 | 121 | |
|
121 | 122 | function getReplyCount() { |
|
122 | 123 | return $('.thread').children('.post').length |
|
123 | 124 | } |
|
124 | 125 | |
|
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,68 +1,70 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 %} |
|
7 | 8 | <div class="post dead_post" id="{{ post.id }}"> |
|
8 | 9 | {% endif %} |
|
9 | 10 | |
|
10 | 11 | {% if post.image %} |
|
11 | 12 | <div class="image"> |
|
12 | 13 | <a |
|
13 | 14 | class="thumb" |
|
14 | 15 | href="{{ post.image.url }}"><img |
|
15 | 16 | src="{{ post.image.url_200x150 }}" |
|
16 | 17 | alt="{{ post.id }}" |
|
17 | 18 | data-width="{{ post.image_width }}" |
|
18 | 19 | data-height="{{ post.image_height }}"/> |
|
19 | 20 | </a> |
|
20 | 21 | </div> |
|
21 | 22 | {% endif %} |
|
22 | 23 | <div class="message"> |
|
23 | 24 | <div class="post-info"> |
|
24 | 25 | <span class="title">{{ post.title }}</span> |
|
25 | 26 | <a class="post_id" href="#{{ post.id }}"> |
|
26 | 27 | ({{ post.id }})</a> |
|
27 | 28 | [{{ post.pub_time }}] |
|
28 | 29 | [<a href="#" onclick="javascript:addQuickReply('{{ post.id }}') |
|
29 | 30 | ; return false;">>></a>] |
|
30 | 31 | |
|
31 | 32 | {% if moderator %} |
|
32 | 33 | <span class="moderator_info"> |
|
33 | 34 | [<a href="{% url 'delete' post_id=post.id %}" |
|
34 | 35 | >{% trans 'Delete' %}</a>] |
|
35 | 36 | ({{ post.poster_ip }}) |
|
36 | 37 | [<a href="{% url 'ban' post_id=post.id %}?next={{ request.path }}" |
|
37 | 38 | >{% trans 'Ban IP' %}</a>] |
|
38 | 39 | </span> |
|
39 | 40 | {% endif %} |
|
40 | 41 | </div> |
|
41 | 42 | {% autoescape off %} |
|
42 | 43 | {% if truncated %} |
|
43 | 44 | {{ post.text.rendered|truncatewords_html:50 }} |
|
44 | 45 | {% else %} |
|
45 | 46 | {{ post.text.rendered }} |
|
46 | 47 | {% endif %} |
|
47 | 48 | {% endautoescape %} |
|
48 | 49 | {% if post.is_referenced %} |
|
49 | 50 | <div class="refmap"> |
|
50 | 51 | {% trans "Replies" %}: |
|
51 | 52 | {% for ref_post in post.get_sorted_referenced_posts %} |
|
52 | 53 | <a href="{% post_url ref_post.id %}">>>{{ ref_post.id }}</a |
|
53 | 54 | >{% if not forloop.last %},{% endif %} |
|
54 | 55 | {% endfor %} |
|
55 | 56 | </div> |
|
56 | 57 | {% endif %} |
|
57 | 58 | </div> |
|
58 | 59 | {% if post.thread.tags.exists %} |
|
59 | 60 | <div class="metadata"> |
|
60 | 61 | <span class="tags">{% trans 'Tags' %}: |
|
61 | 62 | {% for tag in post.thread.get_tags %} |
|
62 | 63 | <a class="tag" href="{% url 'tag' tag.name %}"> |
|
63 | 64 | {{ tag.name }}</a> |
|
64 | 65 | {% endfor %} |
|
65 | 66 | </span> |
|
66 | 67 | </div> |
|
67 | 68 | {% endif %} |
|
68 | 69 | </div> |
|
70 | {% endspaceless %} No newline at end of file |
@@ -1,161 +1,163 b'' | |||
|
1 | 1 | {% extends "boards/base.html" %} |
|
2 | 2 | |
|
3 | 3 | {% load i18n %} |
|
4 | 4 | {% load cache %} |
|
5 | 5 | {% load static from staticfiles %} |
|
6 | 6 | {% load board %} |
|
7 | 7 | |
|
8 | 8 | {% block head %} |
|
9 | 9 | <title>Neboard - {{ thread.get_replies.0.get_title }}</title> |
|
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> |
|
16 | 17 | <script src="{% static 'js/thread.js' %}"></script> |
|
17 | 18 | |
|
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 %} |
|
28 | 29 | <div class="thread"> |
|
29 | 30 | {% for post in thread.get_replies %} |
|
30 | 31 | {% if bumpable %} |
|
31 | 32 | <div class="post" id="{{ post.id }}"> |
|
32 | 33 | {% else %} |
|
33 | 34 | <div class="post dead_post" id="{{ post.id }}"> |
|
34 | 35 | {% endif %} |
|
35 | 36 | {% if post.image %} |
|
36 | 37 | <div class="image"> |
|
37 | 38 | <a |
|
38 | 39 | class="thumb" |
|
39 | 40 | href="{{ post.image.url }}"><img |
|
40 | 41 | src="{{ post.image.url_200x150 }}" |
|
41 | 42 | alt="{{ post.id }}" |
|
42 | 43 | data-width="{{ post.image_width }}" |
|
43 | 44 | data-height="{{ post.image_height }}"/> |
|
44 | 45 | </a> |
|
45 | 46 | </div> |
|
46 | 47 | {% endif %} |
|
47 | 48 | <div class="message"> |
|
48 | 49 | <div class="post-info"> |
|
49 | 50 | <span class="title">{{ post.title }}</span> |
|
50 | 51 | <a class="post_id" href="#{{ post.id }}"> |
|
51 | 52 | ({{ post.id }})</a> |
|
52 | 53 | [{{ post.pub_time }}] |
|
53 | 54 | [<a href="#" onclick="javascript:addQuickReply('{{ post.id }}') |
|
54 | 55 | ; return false;">>></a>] |
|
55 | 56 | |
|
56 | 57 | {% if moderator %} |
|
57 | 58 | <span class="moderator_info"> |
|
58 | 59 | [<a href="{% url 'delete' post_id=post.id %}" |
|
59 | 60 | >{% trans 'Delete' %}</a>] |
|
60 | 61 | ({{ post.poster_ip }}) |
|
61 | 62 | [<a href="{% url 'ban' post_id=post.id %}?next={{ request.path }}" |
|
62 | 63 | >{% trans 'Ban IP' %}</a>] |
|
63 | 64 | </span> |
|
64 | 65 | {% endif %} |
|
65 | 66 | </div> |
|
66 | 67 | {% autoescape off %} |
|
67 | 68 | {{ post.text.rendered }} |
|
68 | 69 | {% endautoescape %} |
|
69 | 70 | {% if post.is_referenced %} |
|
70 | 71 | <div class="refmap"> |
|
71 | 72 | {% trans "Replies" %}: |
|
72 | 73 | {% for ref_post in post.get_sorted_referenced_posts %} |
|
73 | 74 | <a href="{% post_url ref_post.id %}">>>{{ ref_post.id }}</a |
|
74 | 75 | >{% if not forloop.last %},{% endif %} |
|
75 | 76 | {% endfor %} |
|
76 | 77 | </div> |
|
77 | 78 | {% endif %} |
|
78 | 79 | </div> |
|
79 | 80 | {% if forloop.first %} |
|
80 | 81 | <div class="metadata"> |
|
81 | 82 | <span class="tags"> |
|
82 | 83 | {% for tag in thread.get_tags %} |
|
83 | 84 | <a class="tag" href="{% url 'tag' tag.name %}"> |
|
84 | 85 | #{{ tag.name }}</a |
|
85 | 86 | >{% if not forloop.last %},{% endif %} |
|
86 | 87 | {% endfor %} |
|
87 | 88 | </span> |
|
88 | 89 | </div> |
|
89 | 90 | {% endif %} |
|
90 | 91 | </div> |
|
91 | 92 | {% endfor %} |
|
92 | 93 | </div> |
|
93 | 94 | {% endcache %} |
|
94 | 95 | |
|
95 | 96 | <form id="form" enctype="multipart/form-data" method="post" |
|
96 | 97 | >{% csrf_token %} |
|
97 | 98 | <div class="post-form-w"> |
|
98 | 99 | <div class="form-title">{% trans "Reply to thread" %} #{{ thread.get_opening_post.id }}</div> |
|
99 | 100 | <div class="post-form"> |
|
100 | 101 | <div class="form-row"> |
|
101 | 102 | <div class="form-label">{% trans 'Title' %}</div> |
|
102 | 103 | <div class="form-input">{{ form.title }}</div> |
|
103 | 104 | <div class="form-errors">{{ form.title.errors }}</div> |
|
104 | 105 | </div> |
|
105 | 106 | <div class="form-row"> |
|
106 | 107 | <div class="form-label">{% trans 'Formatting' %}</div> |
|
107 | 108 | <div class="form-input" id="mark_panel"> |
|
108 | 109 | <span class="mark_btn" id="quote"><span class="quote">>{% trans 'quote' %}</span></span> |
|
109 | 110 | <span class="mark_btn" id="italic"><i>{% trans 'italic' %}</i></span> |
|
110 | 111 | <span class="mark_btn" id="bold"><b>{% trans 'bold' %}</b></span> |
|
111 | 112 | <span class="mark_btn" id="spoiler"><span class="spoiler">{% trans 'spoiler' %}</span></span> |
|
112 | 113 | <span class="mark_btn" id="comment"><span class="comment">// {% trans 'comment' %}</span></span> |
|
113 | 114 | </div> |
|
114 | 115 | </div> |
|
115 | 116 | <div class="form-row"> |
|
116 | 117 | <div class="form-label">{% trans 'Text' %}</div> |
|
117 | 118 | <div class="form-input">{{ form.text }}</div> |
|
118 | 119 | <div class="form-errors">{{ form.text.errors }}</div> |
|
119 | 120 | </div> |
|
120 | 121 | <div class="form-row"> |
|
121 | 122 | <div class="form-label">{% trans 'Image' %}</div> |
|
122 | 123 | <div class="form-input">{{ form.image }}</div> |
|
123 | 124 | <div class="form-errors">{{ form.image.errors }}</div> |
|
124 | 125 | </div> |
|
125 | 126 | <div class="form-row form-email"> |
|
126 | 127 | <div class="form-label">{% trans 'e-mail' %}</div> |
|
127 | 128 | <div class="form-input">{{ form.email }}</div> |
|
128 | 129 | <div class="form-errors">{{ form.email.errors }}</div> |
|
129 | 130 | </div> |
|
130 | 131 | <div class="form-row"> |
|
131 | 132 | {{ form.captcha }} |
|
132 | 133 | <div class="form-errors">{{ form.captcha.errors }}</div> |
|
133 | 134 | </div> |
|
134 | 135 | <div class="form-row"> |
|
135 | 136 | <div class="form-errors">{{ form.other.errors }}</div> |
|
136 | 137 | </div> |
|
137 | 138 | </div> |
|
138 | 139 | |
|
139 | 140 | <div class="form-submit"><input type="submit" |
|
140 | 141 | value="{% trans "Post" %}"/></div> |
|
141 | 142 | <div><a href="{% url "staticpage" name="help" %}"> |
|
142 | 143 | {% trans 'Text syntax' %}</a></div> |
|
143 | 144 | </div> |
|
144 | 145 | </form> |
|
145 | 146 | |
|
147 | {% endspaceless %} | |
|
146 | 148 | {% endblock %} |
|
147 | 149 | |
|
148 | 150 | {% block metapanel %} |
|
149 | 151 | |
|
150 | 152 | {% get_current_language as LANGUAGE_CODE %} |
|
151 | 153 | |
|
152 | 154 | <span class="metapanel" data-last-update="{{ last_update }}"> |
|
153 | 155 | {% cache 600 thread_meta thread.last_edit_time moderator LANGUAGE_CODE %} |
|
154 | 156 | <span id="reply-count">{{ thread.get_reply_count }}</span> {% trans 'replies' %}, |
|
155 | 157 | <span id="image-count">{{ thread.get_images_count }}</span> {% trans 'images' %}. |
|
156 | 158 | {% trans 'Last update: ' %}{{ thread.last_edit_time }} |
|
157 | 159 | [<a href="rss/">RSS</a>] |
|
158 | 160 | {% endcache %} |
|
159 | 161 | </span> |
|
160 | 162 | |
|
161 | 163 | {% endblock %} |
General Comments 0
You need to be logged in to leave comments.
Login now