Show More
@@ -1,363 +1,364 | |||||
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 ITEM_VOLUME_LEVEL = 'volumeLevel'; |
|
26 | var ITEM_VOLUME_LEVEL = 'volumeLevel'; | |
27 | var ITEM_HIDDEN_POSTS = 'hiddenPosts'; |
|
27 | var ITEM_HIDDEN_POSTS = 'hiddenPosts'; | |
28 |
|
28 | |||
29 | var IMAGE_TYPES = ['image/png', 'image/jpg', 'image/jpeg', 'image/bmp', 'image/gif']; |
|
29 | var IMAGE_TYPES = ['image/png', 'image/jpg', 'image/jpeg', 'image/bmp', 'image/gif']; | |
30 |
|
30 | |||
31 | /** |
|
31 | /** | |
32 | * An email is a hidden file to prevent spam bots from posting. It has to be |
|
32 | * An email is a hidden file to prevent spam bots from posting. It has to be | |
33 | * hidden. |
|
33 | * hidden. | |
34 | */ |
|
34 | */ | |
35 | function hideEmailFromForm() { |
|
35 | function hideEmailFromForm() { | |
36 | $('.form-email').parent().parent().hide(); |
|
36 | $('.form-email').parent().parent().hide(); | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | /** |
|
39 | /** | |
40 | * Highlight code blocks with code highlighter |
|
40 | * Highlight code blocks with code highlighter | |
41 | */ |
|
41 | */ | |
42 | function highlightCode(node) { |
|
42 | function highlightCode(node) { | |
43 | node.find('pre code').each(function(i, e) { |
|
43 | node.find('pre code').each(function(i, e) { | |
44 | hljs.highlightBlock(e); |
|
44 | hljs.highlightBlock(e); | |
45 | }); |
|
45 | }); | |
46 | } |
|
46 | } | |
47 |
|
47 | |||
48 | function updateFavPosts(data) { |
|
48 | function updateFavPosts(data) { | |
49 | var includePostBody = $('#fav-panel').is(":visible"); |
|
49 | var includePostBody = $('#fav-panel').is(":visible"); | |
50 |
|
50 | |||
51 | var allNewPostCount = 0; |
|
51 | var allNewPostCount = 0; | |
52 |
|
52 | |||
53 | if (includePostBody) { |
|
53 | if (includePostBody) { | |
54 | var favoriteThreadPanel = $('#fav-panel'); |
|
54 | var favoriteThreadPanel = $('#fav-panel'); | |
55 | favoriteThreadPanel.empty(); |
|
55 | favoriteThreadPanel.empty(); | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | $.each($.parseJSON(data), function (_, dict) { |
|
58 | $.each($.parseJSON(data), function (_, dict) { | |
59 | var newPostCount = dict.new_post_count; |
|
59 | var newPostCount = dict.new_post_count; | |
60 | allNewPostCount += newPostCount; |
|
60 | allNewPostCount += newPostCount; | |
61 |
|
61 | |||
62 | if (includePostBody) { |
|
62 | if (includePostBody) { | |
63 | var favThreadNode = $('<div class="post"></div>'); |
|
63 | var favThreadNode = $('<div class="post"></div>'); | |
64 | favThreadNode.append($(dict.post_url)); |
|
64 | favThreadNode.append($(dict.post_url)); | |
65 | favThreadNode.append(' '); |
|
65 | favThreadNode.append(' '); | |
66 | favThreadNode.append($('<span class="title">' + dict.title + '</span>')); |
|
66 | favThreadNode.append($('<span class="title">' + dict.title + '</span>')); | |
67 |
|
67 | |||
68 | if (newPostCount > 0) { |
|
68 | if (newPostCount > 0) { | |
69 | favThreadNode.append(' (<a href="' + dict.newest_post_link + '">+' + newPostCount + "</a>)"); |
|
69 | favThreadNode.append(' (<a href="' + dict.newest_post_link + '">+' + newPostCount + "</a>)"); | |
70 | } |
|
70 | } | |
71 |
|
71 | |||
72 | favoriteThreadPanel.append(favThreadNode); |
|
72 | favoriteThreadPanel.append(favThreadNode); | |
73 |
|
73 | |||
74 | addRefLinkPreview(favThreadNode[0]); |
|
74 | addRefLinkPreview(favThreadNode[0]); | |
75 | } |
|
75 | } | |
76 | }); |
|
76 | }); | |
77 |
|
77 | |||
78 | var newPostCountNode = $('#new-fav-post-count'); |
|
78 | var newPostCountNode = $('#new-fav-post-count'); | |
79 | if (allNewPostCount > 0) { |
|
79 | if (allNewPostCount > 0) { | |
80 | newPostCountNode.text('(+' + allNewPostCount + ')'); |
|
80 | newPostCountNode.text('(+' + allNewPostCount + ')'); | |
81 | newPostCountNode.show(); |
|
81 | newPostCountNode.show(); | |
82 | } else { |
|
82 | } else { | |
83 | newPostCountNode.hide(); |
|
83 | newPostCountNode.hide(); | |
84 | } |
|
84 | } | |
85 | } |
|
85 | } | |
86 |
|
86 | |||
87 | function initFavPanel() { |
|
87 | function initFavPanel() { | |
88 | var favPanelButton = $('#fav-panel-btn'); |
|
88 | var favPanelButton = $('#fav-panel-btn'); | |
89 | if (favPanelButton.length > 0 && typeof SharedWorker != 'undefined') { |
|
89 | if (favPanelButton.length > 0 && typeof SharedWorker != 'undefined') { | |
90 | var worker = new SharedWorker($('body').attr('data-update-script')); |
|
90 | var worker = new SharedWorker($('body').attr('data-update-script')); | |
91 | worker.port.onmessage = function(e) { |
|
91 | worker.port.onmessage = function(e) { | |
92 | updateFavPosts(e.data); |
|
92 | updateFavPosts(e.data); | |
93 | }; |
|
93 | }; | |
94 | worker.onerror = function(event){ |
|
94 | worker.onerror = function(event){ | |
95 | throw new Error(event.message + " (" + event.filename + ":" + event.lineno + ")"); |
|
95 | throw new Error(event.message + " (" + event.filename + ":" + event.lineno + ")"); | |
96 | }; |
|
96 | }; | |
97 | worker.port.start(); |
|
97 | worker.port.start(); | |
98 |
|
98 | |||
99 | $(favPanelButton).click(function() { |
|
99 | $(favPanelButton).click(function() { | |
100 | var favPanel = $('#fav-panel'); |
|
100 | var favPanel = $('#fav-panel'); | |
101 | favPanel.toggle(); |
|
101 | favPanel.toggle(); | |
102 |
|
102 | |||
103 | worker.port.postMessage({ includePostBody: favPanel.is(':visible')}); |
|
103 | worker.port.postMessage({ includePostBody: favPanel.is(':visible')}); | |
104 |
|
104 | |||
105 | return false; |
|
105 | return false; | |
106 | }); |
|
106 | }); | |
107 |
|
107 | |||
108 | $(document).on('keyup.removepic', function(e) { |
|
108 | $(document).on('keyup.removepic', function(e) { | |
109 | if(e.which === 27) { |
|
109 | if(e.which === 27) { | |
110 | $('#fav-panel').hide(); |
|
110 | $('#fav-panel').hide(); | |
111 | } |
|
111 | } | |
112 | }); |
|
112 | }); | |
113 | } |
|
113 | } | |
114 | } |
|
114 | } | |
115 |
|
115 | |||
116 | function setVolumeLevel(level) { |
|
116 | function setVolumeLevel(level) { | |
117 | localStorage.setItem(ITEM_VOLUME_LEVEL, level); |
|
117 | localStorage.setItem(ITEM_VOLUME_LEVEL, level); | |
118 | } |
|
118 | } | |
119 |
|
119 | |||
120 | function getVolumeLevel() { |
|
120 | function getVolumeLevel() { | |
121 | var level = localStorage.getItem(ITEM_VOLUME_LEVEL); |
|
121 | var level = localStorage.getItem(ITEM_VOLUME_LEVEL); | |
122 | if (level == null) { |
|
122 | if (level == null) { | |
123 | level = 1.0; |
|
123 | level = 1.0; | |
124 | } |
|
124 | } | |
125 | return level |
|
125 | return level | |
126 | } |
|
126 | } | |
127 |
|
127 | |||
128 | function processVolumeUser(node) { |
|
128 | function processVolumeUser(node) { | |
129 | if (!window.localStorage) return; |
|
129 | if (!window.localStorage) return; | |
130 | node.prop("volume", getVolumeLevel()); |
|
130 | node.prop("volume", getVolumeLevel()); | |
131 | node.on('volumechange', function(event) { |
|
131 | node.on('volumechange', function(event) { | |
132 | setVolumeLevel(event.target.volume); |
|
132 | setVolumeLevel(event.target.volume); | |
133 | $("video,audio").prop("volume", getVolumeLevel()); |
|
133 | $("video,audio").prop("volume", getVolumeLevel()); | |
134 | }); |
|
134 | }); | |
135 | } |
|
135 | } | |
136 |
|
136 | |||
137 | function getHiddenPosts() { |
|
137 | function getHiddenPosts() { | |
138 | var arr = Array(); |
|
138 | var arr = Array(); | |
139 | var hiddenPosts = localStorage && localStorage.getItem(ITEM_HIDDEN_POSTS); |
|
139 | var hiddenPosts = localStorage && localStorage.getItem(ITEM_HIDDEN_POSTS); | |
140 | if (hiddenPosts) { |
|
140 | if (hiddenPosts) { | |
141 | arr = JSON.parse(hiddenPosts); |
|
141 | arr = JSON.parse(hiddenPosts); | |
142 | } |
|
142 | } | |
143 | return arr; |
|
143 | return arr; | |
144 | } |
|
144 | } | |
145 |
|
145 | |||
146 | function processPostHiding(posts) { |
|
146 | function processPostHiding(posts) { | |
147 | if (!window.localStorage) return; |
|
147 | if (!window.localStorage) return; | |
148 | var hiddenPosts = getHiddenPosts(); |
|
148 | var hiddenPosts = getHiddenPosts(); | |
149 |
|
149 | |||
150 | $.each(posts, function(index) { |
|
150 | $.each(posts, function(index) { | |
151 | var post = $(this); |
|
151 | var post = $(this); | |
152 | if (hiddenPosts.indexOf(post.attr("id")) > -1) { |
|
152 | if (hiddenPosts.indexOf(post.attr("id")) > -1) { | |
153 | post.toggleClass("hidden_post"); |
|
153 | post.toggleClass("hidden_post"); | |
154 | } |
|
154 | } | |
155 | }); |
|
155 | }); | |
156 | } |
|
156 | } | |
157 |
|
157 | |||
158 | /** |
|
158 | /** | |
159 | * Add all scripts than need to work on post, when the post is added to the |
|
159 | * Add all scripts than need to work on post, when the post is added to the | |
160 | * document. |
|
160 | * document. | |
161 | */ |
|
161 | */ | |
162 | function addScriptsToPost(post) { |
|
162 | function addScriptsToPost(post) { | |
163 | addRefLinkPreview(post[0]); |
|
163 | addRefLinkPreview(post[0]); | |
164 | highlightCode(post); |
|
164 | highlightCode(post); | |
165 | processVolumeUser(post.find("video,audio")); |
|
165 | processVolumeUser(post.find("video,audio")); | |
166 | processPostHiding([post]); |
|
166 | processPostHiding([post]); | |
167 | } |
|
167 | } | |
168 |
|
168 | |||
169 | /** |
|
169 | /** | |
170 | * Fix compatibility issues with some rare browsers |
|
170 | * Fix compatibility issues with some rare browsers | |
171 | */ |
|
171 | */ | |
172 | function compatibilityCrutches() { |
|
172 | function compatibilityCrutches() { | |
173 | if (window.operamini) { |
|
173 | if (window.operamini) { | |
174 | $('#form textarea').each(function() { this.placeholder = ''; }); |
|
174 | $('#form textarea').each(function() { this.placeholder = ''; }); | |
175 | } |
|
175 | } | |
176 | } |
|
176 | } | |
177 |
|
177 | |||
178 | function togglePostHidden(postId) { |
|
178 | function togglePostHidden(postId) { | |
179 | var hiddenPosts = getHiddenPosts(); |
|
179 | var hiddenPosts = getHiddenPosts(); | |
180 |
|
180 | |||
181 | var elIndex = hiddenPosts.indexOf(postId); |
|
181 | var elIndex = hiddenPosts.indexOf(postId); | |
182 | if (elIndex > -1) { |
|
182 | if (elIndex > -1) { | |
183 | hiddenPosts.splice(elIndex, 1); |
|
183 | hiddenPosts.splice(elIndex, 1); | |
184 | } else { |
|
184 | } else { | |
185 | hiddenPosts.push(postId); |
|
185 | hiddenPosts.push(postId); | |
186 | } |
|
186 | } | |
187 | localStorage.setItem(ITEM_HIDDEN_POSTS, JSON.stringify(hiddenPosts)); |
|
187 | localStorage.setItem(ITEM_HIDDEN_POSTS, JSON.stringify(hiddenPosts)); | |
188 |
|
188 | |||
189 | $('#' + postId).toggleClass("hidden_post"); |
|
189 | $('#' + postId).toggleClass("hidden_post"); | |
190 | } |
|
190 | } | |
191 |
|
191 | |||
192 | function addContextMenu() { |
|
192 | function addContextMenu() { | |
193 | $.contextMenu({ |
|
193 | $.contextMenu({ | |
194 | selector: '.file-menu', |
|
194 | selector: '.file-menu', | |
195 | trigger: 'left', |
|
195 | trigger: 'left', | |
196 |
|
196 | |||
197 | build: function($trigger, e) { |
|
197 | build: function($trigger, e) { | |
198 | var fileSearchUrl = $trigger.data('search-url'); |
|
198 | var fileSearchUrl = $trigger.data('search-url'); | |
199 | var isImage = IMAGE_TYPES.indexOf($trigger.data('type')) > -1; |
|
199 | var isImage = IMAGE_TYPES.indexOf($trigger.data('type')) > -1; | |
200 | var hasUrl = fileSearchUrl.length > 0; |
|
200 | var hasUrl = fileSearchUrl.length > 0; | |
201 | var id = $trigger.data('id'); |
|
201 | var id = $trigger.data('id'); | |
202 | return { |
|
202 | return { | |
203 | items: { |
|
203 | items: { | |
204 | duplicates: { |
|
204 | duplicates: { | |
205 | name: gettext('Duplicates search'), |
|
205 | name: gettext('Duplicates search'), | |
206 | callback: function(key, opts) { |
|
206 | callback: function(key, opts) { | |
207 | window.location = '/feed/?image=' + $trigger.data('filename'); |
|
207 | window.location = '/feed/?image=' + $trigger.data('filename'); | |
208 | } |
|
208 | } | |
209 | }, |
|
209 | }, | |
210 | google: { |
|
210 | google: { | |
211 | name: 'Google', |
|
211 | name: 'Google', | |
212 | visible: isImage && hasUrl, |
|
212 | visible: isImage && hasUrl, | |
213 | callback: function(key, opts) { |
|
213 | callback: function(key, opts) { | |
214 | window.location = 'https://www.google.com/searchbyimage?image_url=' + fileSearchUrl; |
|
214 | window.location = 'https://www.google.com/searchbyimage?image_url=' + fileSearchUrl; | |
215 | } |
|
215 | } | |
216 | }, |
|
216 | }, | |
217 | iqdb: { |
|
217 | iqdb: { | |
218 | name: 'IQDB', |
|
218 | name: 'IQDB', | |
219 | visible: isImage && hasUrl, |
|
219 | visible: isImage && hasUrl, | |
220 | callback: function(key, opts) { |
|
220 | callback: function(key, opts) { | |
221 | window.location = 'http://iqdb.org/?url=' + fileSearchUrl; |
|
221 | window.location = 'http://iqdb.org/?url=' + fileSearchUrl; | |
222 | } |
|
222 | } | |
223 | }, |
|
223 | }, | |
224 | tineye: { |
|
224 | tineye: { | |
225 | name: 'TinEye', |
|
225 | name: 'TinEye', | |
226 | visible: isImage && hasUrl, |
|
226 | visible: isImage && hasUrl, | |
227 | callback: function(key, opts) { |
|
227 | callback: function(key, opts) { | |
228 | window.location = 'http://tineye.com/search?url=' + fileSearchUrl; |
|
228 | window.location = 'http://tineye.com/search?url=' + fileSearchUrl; | |
229 | } |
|
229 | } | |
230 | }, |
|
230 | }, | |
231 | addAlias: { |
|
231 | addAlias: { | |
232 | name: gettext('Add local sticker'), |
|
232 | name: gettext('Add local sticker'), | |
233 | callback: function(key, opts) { |
|
233 | callback: function(key, opts) { | |
234 | var alias = prompt(gettext('Input sticker name')); |
|
234 | var alias = prompt(gettext('Input sticker name')); | |
235 | if (alias) { |
|
235 | if (alias) { | |
236 | window.location = '/stickers/?action=add&name=' + alias + '&id=' + id; |
|
236 | window.location = '/stickers/?action=add&name=' + alias + '&id=' + id; | |
237 | } |
|
237 | } | |
238 | } |
|
238 | } | |
239 | } |
|
239 | } | |
240 | } |
|
240 | } | |
241 | }; |
|
241 | }; | |
242 | } |
|
242 | } | |
243 | }); |
|
243 | }); | |
244 |
|
244 | |||
245 | $.contextMenu({ |
|
245 | $.contextMenu({ | |
246 | selector: '.post .post-menu', |
|
246 | selector: '.post .post-menu', | |
247 | trigger: 'left', |
|
247 | trigger: 'left', | |
248 | build: function($trigger, e) { |
|
248 | build: function($trigger, e) { | |
249 | var canEditPost = PERMS['change_post']; |
|
249 | var canEditPost = PERMS['change_post']; | |
250 | var canDeletePost = PERMS['delete_post']; |
|
250 | var canDeletePost = PERMS['delete_post']; | |
251 | var canEditThread = PERMS['change_thread']; |
|
251 | var canEditThread = PERMS['change_thread']; | |
252 | var canDeleteThread = PERMS['delete_thread']; |
|
252 | var canDeleteThread = PERMS['delete_thread']; | |
253 |
|
253 | |||
254 | var post = $trigger.parents('.post'); |
|
254 | var post = $trigger.parents('.post'); | |
255 |
|
255 | |||
256 | var isOpening = post.data('opening') === 'True'; |
|
256 | var isOpening = post.data('opening') === 'True'; | |
257 | var threadId = post.data('thread-id'); |
|
257 | var threadId = post.data('thread-id'); | |
258 | var hasGlobalId = post.data('has-global-id') === 'True'; |
|
258 | var hasGlobalId = post.data('has-global-id') === 'True'; | |
259 |
|
259 | |||
260 | var posterIp = $trigger.siblings('.pub_time').attr('title'); |
|
260 | var posterIp = $trigger.siblings('.pub_time').attr('title'); | |
261 | var hasIp = posterIp != null; |
|
261 | var hasIp = posterIp != null; | |
262 |
|
262 | |||
263 | var postId = post.attr('id'); |
|
263 | var postId = post.attr('id'); | |
264 |
|
264 | |||
265 | return { |
|
265 | return { | |
266 | items: { |
|
266 | items: { | |
267 | hide: { |
|
267 | hide: { | |
268 | name: gettext('Hide/show'), |
|
268 | name: gettext('Hide/show'), | |
269 | callback: function(key, opt) { |
|
269 | callback: function(key, opt) { | |
270 | togglePostHidden(postId); |
|
270 | togglePostHidden(postId); | |
271 | } |
|
271 | }, | |
|
272 | visible: !!localStorage | |||
272 | }, |
|
273 | }, | |
273 | edit: { |
|
274 | edit: { | |
274 | name: gettext('Edit'), |
|
275 | name: gettext('Edit'), | |
275 | callback: function(key, opt) { |
|
276 | callback: function(key, opt) { | |
276 | window.location = '/admin/boards/post/' + postId + '/change/'; |
|
277 | window.location = '/admin/boards/post/' + postId + '/change/'; | |
277 | }, |
|
278 | }, | |
278 | visible: canEditPost |
|
279 | visible: canEditPost | |
279 | }, |
|
280 | }, | |
280 | deletePost: { |
|
281 | deletePost: { | |
281 | name: gettext('Delete post'), |
|
282 | name: gettext('Delete post'), | |
282 | callback: function(key, opt) { |
|
283 | callback: function(key, opt) { | |
283 | window.location = '/admin/boards/post/' + postId + '/delete/'; |
|
284 | window.location = '/admin/boards/post/' + postId + '/delete/'; | |
284 | }, |
|
285 | }, | |
285 | visible: !isOpening && canDeletePost |
|
286 | visible: !isOpening && canDeletePost | |
286 | }, |
|
287 | }, | |
287 | editThread: { |
|
288 | editThread: { | |
288 | name: gettext('Edit thread'), |
|
289 | name: gettext('Edit thread'), | |
289 | callback: function(key, opt) { |
|
290 | callback: function(key, opt) { | |
290 | window.location = '/admin/boards/thread/' + threadId + '/change/'; |
|
291 | window.location = '/admin/boards/thread/' + threadId + '/change/'; | |
291 | }, |
|
292 | }, | |
292 | visible: isOpening && canEditThread |
|
293 | visible: isOpening && canEditThread | |
293 | }, |
|
294 | }, | |
294 | deleteThread: { |
|
295 | deleteThread: { | |
295 | name: gettext('Delete thread'), |
|
296 | name: gettext('Delete thread'), | |
296 | callback: function(key, opt) { |
|
297 | callback: function(key, opt) { | |
297 | window.location = '/admin/boards/thread/' + threadId + '/delete/'; |
|
298 | window.location = '/admin/boards/thread/' + threadId + '/delete/'; | |
298 | }, |
|
299 | }, | |
299 | visible: isOpening && canDeleteThread |
|
300 | visible: isOpening && canDeleteThread | |
300 | }, |
|
301 | }, | |
301 | findByIp: { |
|
302 | findByIp: { | |
302 | name: 'IP = ' + posterIp, |
|
303 | name: 'IP = ' + posterIp, | |
303 | callback: function(key, opt) { |
|
304 | callback: function(key, opt) { | |
304 | window.location = '/feed/?ip=' + posterIp; |
|
305 | window.location = '/feed/?ip=' + posterIp; | |
305 | }, |
|
306 | }, | |
306 | visible: canEditPost && hasIp |
|
307 | visible: canEditPost && hasIp | |
307 | }, |
|
308 | }, | |
308 | raw: { |
|
309 | raw: { | |
309 | name: 'RAW', |
|
310 | name: 'RAW', | |
310 | callback: function(key, opt) { |
|
311 | callback: function(key, opt) { | |
311 | window.location = '/post_xml/' + postId; |
|
312 | window.location = '/post_xml/' + postId; | |
312 | }, |
|
313 | }, | |
313 | visible: canEditPost && hasGlobalId |
|
314 | visible: canEditPost && hasGlobalId | |
314 | }, |
|
315 | }, | |
315 | ban: { |
|
316 | ban: { | |
316 | name: gettext('Ban'), |
|
317 | name: gettext('Ban'), | |
317 | callback: function(key, opt) { |
|
318 | callback: function(key, opt) { | |
318 | if (confirm(gettext('Are you sure?'))) { |
|
319 | if (confirm(gettext('Are you sure?'))) { | |
319 | window.location = '/utils?method=ban&post_id=' + postId; |
|
320 | window.location = '/utils?method=ban&post_id=' + postId; | |
320 | } |
|
321 | } | |
321 | }, |
|
322 | }, | |
322 | visible: canEditPost && hasIp |
|
323 | visible: canEditPost && hasIp | |
323 | }, |
|
324 | }, | |
324 | banAndDelete: { |
|
325 | banAndDelete: { | |
325 | name: gettext('Ban and delete'), |
|
326 | name: gettext('Ban and delete'), | |
326 | callback: function(key, opt) { |
|
327 | callback: function(key, opt) { | |
327 | if (confirm(gettext('Are you sure?'))) { |
|
328 | if (confirm(gettext('Are you sure?'))) { | |
328 | window.location = '/utils?method=ban_and_delete&post_id=' + postId; |
|
329 | window.location = '/utils?method=ban_and_delete&post_id=' + postId; | |
329 | } |
|
330 | } | |
330 | }, |
|
331 | }, | |
331 | visible: hasIp && canDeletePost |
|
332 | visible: hasIp && canDeletePost | |
332 | } |
|
333 | } | |
333 | } |
|
334 | } | |
334 | }; |
|
335 | }; | |
335 | } |
|
336 | } | |
336 | }); |
|
337 | }); | |
337 | } |
|
338 | } | |
338 |
|
339 | |||
339 | $( document ).ready(function() { |
|
340 | $( document ).ready(function() { | |
340 | hideEmailFromForm(); |
|
341 | hideEmailFromForm(); | |
341 |
|
342 | |||
342 | $("a[href='#top']").click(function() { |
|
343 | $("a[href='#top']").click(function() { | |
343 | $("html, body").animate({ scrollTop: 0 }, "slow"); |
|
344 | $("html, body").animate({ scrollTop: 0 }, "slow"); | |
344 | return false; |
|
345 | return false; | |
345 | }); |
|
346 | }); | |
346 |
|
347 | |||
347 | addImgPreview(); |
|
348 | addImgPreview(); | |
348 |
|
349 | |||
349 | addRefLinkPreview(); |
|
350 | addRefLinkPreview(); | |
350 |
|
351 | |||
351 | highlightCode($(document)); |
|
352 | highlightCode($(document)); | |
352 |
|
353 | |||
353 | initFavPanel(); |
|
354 | initFavPanel(); | |
354 |
|
355 | |||
355 | var volumeUsers = $("video,audio"); |
|
356 | var volumeUsers = $("video,audio"); | |
356 | processVolumeUser(volumeUsers); |
|
357 | processVolumeUser(volumeUsers); | |
357 |
|
358 | |||
358 | addContextMenu(); |
|
359 | addContextMenu(); | |
359 |
|
360 | |||
360 | compatibilityCrutches(); |
|
361 | compatibilityCrutches(); | |
361 |
|
362 | |||
362 | processPostHiding($('.post')); |
|
363 | processPostHiding($('.post')); | |
363 | }); |
|
364 | }); |
General Comments 0
You need to be logged in to leave comments.
Login now