* Code APP: Automatic post when moving topic.
* Made by Daemon - 2015/03/23
JavaScript code:
PunBB:
- Code:
jQuery(document).ready(function() {
if(window.location.href.search('mode=move') >= 0) {
var jHtml = '<dl>' +
' <dt></dt>' +
' <dd>' +
' <label><input id="send_move_post" type="checkbox">Add a post to the topic that informs about this action?</label>' +
' </dd>' +
'</dl>';
jQuery(jHtml).insertBefore('.frm-buttons');
jQuery('input[name="confirm"]').on('click', function(d) {
var jVerify = jQuery('[name="new_forum"]').val();
if(jVerify.indexOf('f') >= 0) {
if(jQuery('#send_move_post').is(':checked')) {
d.preventDefault();
var jForum = jQuery('[name="f"]').val();
var jTopic = jQuery('[name="t"]').val();
var jCurrentLocal = jQuery('a.nav[href^="/f"]:last').text();
var jNewLocal = jQuery('[name="new_forum"] option:selected').text().split('--').pop();
var TID = jQuery('input[name="tid"]').val();
jQuery.post('/modcp?tid=' + TID, {
'new_forum': jVerify,
'mode': 'move',
'f': jForum,
't': jTopic,
'confirm': 'submit'
}).done(function() {
jQuery.post('/post?t=' + jTopic, {
'mode': 'reply',
'message': '[b]Automatic message[/b]\n\n\n\nThis topic has been moved from "[u]' + jCurrentLocal + '[/u]" to "[u]' + jNewLocal + '[/u]".',
'post': 'submit',
'attach_sig': '1'
}).done(function(e) {
var href = jQuery(e).find('p.message a:first').attr('href');
location.href = href;
}).fail(function() {
alert("The topic has been moved, but an error occurred while trying to send post");
});
}).fail(function() {
alert("An error occurred when trying to move the topic");
location.reload();
});
}
} else {
d.preventDefault();
alert("Select a forum");
}
});
}
});
Infos:
1 - The investment is on every page.
2 - Only works in PunBB.
Preview:
- Spoiler:
- Image 1:
Image 2: