Browse Source

Completely rewrite fix-report-delete-submit.js, add report/delete to menu

pull/40/head
8chan 9 years ago
committed by czaks
parent
commit
95a9b7b72b
  1. 64
      js/fix-report-delete-submit.js
  2. 41
      templates/main.js

64
js/fix-report-delete-submit.js

@ -1,26 +1,68 @@
/*
* fix-report-delete-submit.js
* https://github.com/savetheinternet/Tinyboard/blob/master/js/fix-report-delete-submit.js
*
* Fixes a known bug regarding the delete/report submit buttons.
*
* Released under the MIT license
* Copyright (c) 2012 Michael Save <savetheinternet@tinyboard.org>
*
* Usage:
* $config['additional_javascript'][] = 'js/jquery.min.js';
* $config['additional_javascript'][] = 'js/post-menu.js';
* $config['additional_javascript'][] = 'js/fix-report-delete-submit.js';
*
*/
if (active_page == 'thread' || active_page == 'index') {
$(document).ready(function(){
$('form[name="postcontrols"] div.delete input:not([type="checkbox"]):not([type="submit"]):not([type="hidden"])').keypress(function(e) {
if(e.which == 13) {
if ($('.delete #password').length) {
Menu.add_item("delete_post_menu", "Delete post");
Menu.add_item("delete_file_menu", "Delete file");
Menu.onclick(function(e, $buf) {
var ele = e.target.parentElement.parentElement;
var $ele = $(ele);
var threadId = $ele.parent().attr('id').replace('thread_', '');
var postId = $ele.find('.post_no').not('[id]').text();
$buf.find('#delete_post_menu,#delete_file_menu').click(function(e) {
e.preventDefault();
$(this).next().click();
return false;
$('#delete_'+postId).prop('checked', 'checked');
if ($(this).attr('id') === 'delete_file_menu') {
$('#delete_file').prop('checked', 'checked');
} else {
$('#delete_file').prop('checked', '');
}
$('input[name=delete][type=submit]').click();
});
});
}
Menu.add_item("report_menu", "Report");
Menu.add_item("global_report_menu", "Global report");
Menu.onclick(function(e, $buf) {
var ele = e.target.parentElement.parentElement;
var $ele = $(ele);
var threadId = $ele.parent().attr('id').replace('thread_', '');
var postId = $ele.find('.post_no').not('[id]').text();
$buf.find('#report_menu,#global_report_menu').click(function(e) {
$('#delete_'+postId).prop('checked', 'checked');
if ($(this).attr('id') === 'global_report_menu') {
header = "<div><h1>Attention!</h1><p>This form is only for reporting <strong>child pornography</strong>, <strong>bot spam</strong> and <strong>credit card numbers, social security numbers or banking information</strong>. DMCA requests and all other deletion requests <em>MUST</em> be sent via email to [email protected].</p><p>8chan is unmoderated and allows posts without collecting <em>ANY</em> information from the poster less the details of their post. Furthermore, all boards on 8chan are user created and not actively monitored by anyone but the board creator.</p><p>8chan has a small volunteer staff to handle this queue, please do not waste their time by filling it with nonsense! <em>If you made a report with this tool and the post was not deleted, <strong>do not make the report again!</strong> Email [email protected] instead.</em> Abuse of the global report system could lead to address blocks against your IP from 8chan.</p><p>Again, 8chan's global volunteers <em>do not</em> handle board specific issues. You most likely want to click \"Report\" instead to reach the creator and volunteers he assigned to this board.</p>";
$('#global_report').prop('checked', 'checked');
} else {
header = "";
$('#global_report').prop('checked', '');
}
return true;
alert(header+"Enter reason below...<br/><input type='text' id='alert_reason'>", true, function(){
$('#reason').val($('#alert_reason').val());
$('input[name=report][type=submit]').click();
});
});
});
$(document).on('new_post', function(){
$('div.delete').hide();
$('input.delete').hide();
});
$('div.delete').hide();
$('input.delete').hide();
})}

41
templates/main.js

@ -71,25 +71,40 @@ var datelocale =
function alert(a) {
var handler, div;
var close = function() {
handler.fadeOut(400, function() { handler.remove(); });
return false;
};
function alert(a, do_confirm, confirm_ok_action, confirm_cancel_action) {
var handler, div, bg, closebtn, okbtn;
var close = function() {
handler.fadeOut(400, function() { handler.remove(); });
return false;
};
handler = $("<div id='alert_handler'></div>").hide().appendTo('body');
handler = $("<div id='alert_handler'></div>").hide().appendTo('body');
$("<div id='alert_background'></div>").click(close).appendTo(handler);
bg = $("<div id='alert_background'></div>").appendTo(handler);
div = $("<div id='alert_div'></div>").appendTo(handler);
$("<a id='alert_close' href='javascript:void(0)'><i class='fa fa-times'></i></div>")
.click(close).appendTo(div);
div = $("<div id='alert_div'></div>").appendTo(handler);
closebtn = $("<a id='alert_close' href='javascript:void(0)'><i class='fa fa-times'></i></div>")
.appendTo(div);
$("<div id='alert_message'></div>").html(a).appendTo(div);
$("<div id='alert_message'></div>").html(a).appendTo(div);
$("<button class='button alert_button'>"+_("OK")+"</button>").click(close).appendTo(div);
okbtn = $("<button class='button alert_button'>"+_("OK")+"</button>").appendTo(div);
handler.fadeIn(400);
if (do_confirm) {
confirm_ok_action = (typeof confirm_ok_action !== "function") ? function(){} : confirm_ok_action;
confirm_cancel_action = (typeof confirm_cancel_action !== "function") ? function(){} : confirm_cancel_action;
okbtn.click(confirm_ok_action);
$("<button class='button alert_button'>"+_("Cancel")+"</button>").click(confirm_cancel_action).click(close).appendTo(div);
bg.click(confirm_cancel_action);
okbtn.click(confirm_cancel_action);
closebtn.click(confirm_cancel_action);
}
bg.click(close);
okbtn.click(close);
closebtn.click(close);
handler.fadeIn(400);
}
var saved = {};

Loading…
Cancel
Save