Only show delete links for your posts. Close #649

This commit is contained in:
Nicolas Stepien 2013-02-23 18:38:52 +01:00
parent 0c220617d9
commit 67b05f6757
4 changed files with 42 additions and 37 deletions

View File

@ -2409,7 +2409,7 @@
DeleteLink = {
init: function() {
var div, fileEl, fileEntry, postEl, postEntry;
if (g.VIEW === 'catalog' || !Conf['Menu'] || !Conf['Delete Link']) {
if (g.VIEW === 'catalog' || !Conf['Menu'] || !Conf['Delete Link'] || !Conf['Quick Reply']) {
return;
}
div = $.el('div', {
@ -2437,21 +2437,25 @@
open: function(_arg) {
var file;
file = _arg.file;
if (!file || file.isDead) {
return false;
}
fileEl.textContent = 'File';
$.on(fileEl, 'click', DeleteLink["delete"]);
return !!file;
return true;
}
};
$.event('AddMenuEntry', {
return $.event('AddMenuEntry', {
type: 'post',
el: div,
order: 40,
open: function(post) {
var node, seconds;
if (post.isDead) {
var node, seconds, thread, _ref;
if (post.isDead || !((thread = QR.yourPosts.threads[post.thread]) && (_ref = post.ID, __indexOf.call(thread, _ref) >= 0))) {
return false;
}
DeleteLink.post = post;
DeleteLink.cooldown.start(post);
node = div.firstChild;
if (seconds = DeleteLink.cooldown[post.fullID]) {
node.textContent = "Delete (" + seconds + ")";
@ -2464,7 +2468,6 @@
},
subEntries: [postEntry, fileEntry]
});
return $.on(d, 'QRPostSuccessful', this.cooldown.start);
},
"delete": function() {
var form, link, m, post, pwd;
@ -2512,12 +2515,14 @@
return $.on(link, 'click', DeleteLink["delete"]);
},
cooldown: {
start: function(e) {
var board, fullID, postID, seconds, _ref;
_ref = e.detail, board = _ref.board, postID = _ref.postID;
seconds = board.ID === 'q' ? 600 : 30;
fullID = "" + board + "." + postID;
return DeleteLink.cooldown.count(fullID, seconds, seconds);
start: function(post) {
var length, seconds;
if (post.fullID in DeleteLink.cooldown) {
return;
}
length = post.board.ID === 'q' ? 600 : 30;
seconds = Math.ceil((length * $.SECOND - (Date.now() - post.info.date)) / $.SECOND);
return DeleteLink.cooldown.count(post.fullID, seconds, length);
},
count: function(fullID, seconds, length) {
var el;
@ -6537,13 +6542,13 @@
};
$.set('QR.persona', persona);
_ref1 = h1.nextSibling.textContent.match(/thread:(\d+),no:(\d+)/), _ = _ref1[0], threadID = _ref1[1], postID = _ref1[2];
threadID = +threadID;
postID = +postID;
threadID = +threadID || postID;
((_base = QR.yourPosts.threads)[threadID] || (_base[threadID] = [])).push(postID);
$.set("yourPosts." + g.BOARD, QR.yourPosts);
$.event('QRPostSuccessful', {
board: g.BOARD,
threadID: threadID || postID,
threadID: threadID,
postID: postID
}, QR.el);
QR.cooldown.set({
@ -6551,9 +6556,9 @@
isReply: !!threadID
});
QR.cooldown.auto = QR.replies.length > 1;
if (!threadID) {
$.open("//boards.4chan.org/" + g.BOARD + "/res/" + postID);
} else if (g.VIEW === 'reply' && !QR.cooldown.auto) {
if (threadID === postID) {
$.open("//boards.4chan.org/" + g.BOARD + "/res/" + threadID);
} else if (g.VIEW === 'index' && !QR.cooldown.auto) {
$.open("//boards.4chan.org/" + g.BOARD + "/res/" + threadID + "#p" + postID);
}
if (Conf['Persistent QR'] || QR.cooldown.auto) {

View File

@ -10,8 +10,9 @@ beta
Quick Reply shortcut
Image Expansion
Can be auto-hidden.
(You):
Egocentrism:
"(You)" will be added to quotes linking to your posts.
Delete links in the post menu will only appear for your posts.
QR changes:
Clicking the submit button while uploading will abort the upload and won't start re-uploading automatically anymore.

View File

@ -1254,7 +1254,7 @@ ReportLink =
DeleteLink =
init: ->
return if g.VIEW is 'catalog' or !Conf['Menu'] or !Conf['Delete Link']
return if g.VIEW is 'catalog' or !Conf['Menu'] or !Conf['Delete Link'] or !Conf['Quick Reply']
div = $.el 'div',
className: 'delete-link'
@ -1275,17 +1275,19 @@ DeleteLink =
fileEntry =
el: fileEl
open: ({file}) ->
return false if !file or file.isDead
fileEl.textContent = 'File'
$.on fileEl, 'click', DeleteLink.delete
!!file
true
$.event 'AddMenuEntry',
type: 'post'
el: div
order: 40
open: (post) ->
return false if post.isDead
return false if post.isDead or !((thread = QR.yourPosts.threads[post.thread]) and post.ID in thread)
DeleteLink.post = post
DeleteLink.cooldown.start post
node = div.firstChild
if seconds = DeleteLink.cooldown[post.fullID]
node.textContent = "Delete (#{seconds})"
@ -1296,8 +1298,6 @@ DeleteLink =
true
subEntries: [postEntry, fileEntry]
$.on d, 'QRPostSuccessful', @cooldown.start
delete: ->
{post} = DeleteLink
return if DeleteLink.cooldown[post.fullID]
@ -1340,15 +1340,14 @@ DeleteLink =
$.on link, 'click', DeleteLink.delete
cooldown:
start: (e) ->
{board, postID} = e.detail
seconds =
if board.ID is 'q'
600
else
30
fullID = "#{board}.#{postID}"
DeleteLink.cooldown.count fullID, seconds, seconds
start: (post) ->
return if post.fullID of DeleteLink.cooldown
length = if post.board.ID is 'q'
600
else
30
seconds = Math.ceil (length * $.SECOND - (Date.now() - post.info.date)) / $.SECOND
DeleteLink.cooldown.count post.fullID, seconds, length
count: (fullID, seconds, length) ->
return unless 0 <= seconds <= length
setTimeout DeleteLink.cooldown.count, 1000, fullID, seconds-1, length

View File

@ -812,8 +812,8 @@ QR =
$.set 'QR.persona', persona
[_, threadID, postID] = h1.nextSibling.textContent.match /thread:(\d+),no:(\d+)/
threadID = +threadID
postID = +postID
threadID = +threadID or postID
(QR.yourPosts.threads[threadID] or= []).push postID
$.set "yourPosts.#{g.BOARD}", QR.yourPosts
@ -821,7 +821,7 @@ QR =
# Post/upload confirmed as successful.
$.event 'QRPostSuccessful', {
board: g.BOARD
threadID: threadID or postID
threadID
postID
}, QR.el
@ -832,9 +832,9 @@ QR =
# Enable auto-posting if we have stuff to post, disable it otherwise.
QR.cooldown.auto = QR.replies.length > 1
unless threadID # new thread
$.open "//boards.4chan.org/#{g.BOARD}/res/#{postID}"
else if g.VIEW is 'reply' and !QR.cooldown.auto # posting from the index
if threadID is postID # new thread
$.open "//boards.4chan.org/#{g.BOARD}/res/#{threadID}"
else if g.VIEW is 'index' and !QR.cooldown.auto # posting from the index
$.open "//boards.4chan.org/#{g.BOARD}/res/#{threadID}#p#{postID}"
if Conf['Persistent QR'] or QR.cooldown.auto