Like SystemiConnectFri 15 Oct 2021, 04:50
Auto Save MessagesLGforumFri 26 Feb 2021, 13:31
New tutorial questionTheCrowMon 15 Feb 2021, 08:12
Support iOS Emojis (and other platforms)LGforumSun 14 Feb 2021, 01:25
LGforum (2806)
[TUTORIAL] Automatic post when moving topic Vote_lcap[TUTORIAL] Automatic post when moving topic Voting_bar[TUTORIAL] Automatic post when moving topic Vote_rcap 
Mr.Easybb (1587)
[TUTORIAL] Automatic post when moving topic Vote_lcap[TUTORIAL] Automatic post when moving topic Voting_bar[TUTORIAL] Automatic post when moving topic Vote_rcap 
Bloodbath (745)
[TUTORIAL] Automatic post when moving topic Vote_lcap[TUTORIAL] Automatic post when moving topic Voting_bar[TUTORIAL] Automatic post when moving topic Vote_rcap 
Rukiafan (533)
[TUTORIAL] Automatic post when moving topic Vote_lcap[TUTORIAL] Automatic post when moving topic Voting_bar[TUTORIAL] Automatic post when moving topic Vote_rcap 
Dom (513)
[TUTORIAL] Automatic post when moving topic Vote_lcap[TUTORIAL] Automatic post when moving topic Voting_bar[TUTORIAL] Automatic post when moving topic Vote_rcap 
puppycheese (446)
[TUTORIAL] Automatic post when moving topic Vote_lcap[TUTORIAL] Automatic post when moving topic Voting_bar[TUTORIAL] Automatic post when moving topic Vote_rcap 
pedro (330)
[TUTORIAL] Automatic post when moving topic Vote_lcap[TUTORIAL] Automatic post when moving topic Voting_bar[TUTORIAL] Automatic post when moving topic Vote_rcap 
Neymar (301)
[TUTORIAL] Automatic post when moving topic Vote_lcap[TUTORIAL] Automatic post when moving topic Voting_bar[TUTORIAL] Automatic post when moving topic Vote_rcap 
Hitsu (281)
[TUTORIAL] Automatic post when moving topic Vote_lcap[TUTORIAL] Automatic post when moving topic Voting_bar[TUTORIAL] Automatic post when moving topic Vote_rcap 
Flora (275)
[TUTORIAL] Automatic post when moving topic Vote_lcap[TUTORIAL] Automatic post when moving topic Voting_bar[TUTORIAL] Automatic post when moving topic Vote_rcap 


[TUTORIAL] Automatic post when moving topic

avatarDaemon
Status : No status yet...

Posts : 20
Join date : 2013-02-04
Mon 23 Mar 2015, 12:56
* 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:
avatarfascicularia
Status : No status yet...

Posts : 22
Join date : 2012-10-04
Sat 28 Mar 2015, 02:36
Hello Daemon's ,
too bad there is no version for phpbb2 . this script is awesome
avatarDaemon
Status : No status yet...

Posts : 20
Join date : 2013-02-04
Sat 28 Mar 2015, 15:15
fascicularia wrote:[quotelink="http://www.avacweb.com/t2379-tutorial-automatic-post-when-moving-topic#22869"]Hello Daemon's ,
too bad there is no version for phpbb2 . this script is awesome
Try that:
Code:
jQuery(document).ready(function() {
if(window.location.href.search('mode=move') >= 0) {
      var jHtml = '<input id="send_move_post" type="checkbox">Add a post to the topic that informs about this action?' +
                  '<br><br>';
      jQuery(jHtml).insertBefore('input[name="move_leave_shadow"]');
      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('a[href^="/viewtopic"]').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");
            }
      });
  }
});
Wink
avatarpedro
Status : https://2img.net/i/fa/invision/pp-blank-thumb.png

Posts : 330
Join date : 2012-10-18
Sat 28 Mar 2015, 17:12
Hello Daemon's you can do to invision . thank you very much
BloodbathBloodbath
Status : No status yet...

Posts : 745
Join date : 2013-05-31
Age : 28
Sat 28 Mar 2015, 18:01
Hey Daemon, thanks for posting this, it's appreciated that you share your knowledge here.

I don't want to sound like an anti-jQuery preacher, but maybe you could see if you get this to work with as little jQuery as possible.
avatarfascicularia
Status : No status yet...

Posts : 22
Join date : 2012-10-04
Mon 20 Apr 2015, 13:57
Daemon wrote:[quotelink="http://www.avacweb.com/t2379-tutorial-automatic-post-when-moving-topic#22872"]
fascicularia wrote:[quotelink="http://www.avacweb.com/t2379-tutorial-automatic-post-when-moving-topic#22869"]Hello Daemon's ,
too bad there is no version for phpbb2 . this script is awesome
Try that:
Code:
jQuery(document).ready(function() {
if(window.location.href.search('mode=move') >= 0) {
      var jHtml = '<input id="send_move_post" type="checkbox">Add a post to the topic that informs about this action?' +
                  '<br><br>';
      jQuery(jHtml).insertBefore('input[name="move_leave_shadow"]');
      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('a[href^="/viewtopic"]').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");
            }
      });
  }
});
Wink
Hi Daemon,
Does not work unfortunately. Too bad, the script is really very interesting.
Daemon, do not bother to change the script. I changed my template tellment I guess one of my changes is reponsable of this dysfunction.

Thank you all the same for this aid
avatarkensha
Status : No status yet...

Posts : 5
Join date : 2015-01-14
Sat 06 Jun 2015, 01:45
hi,
can you help me with this code to phpbb3 ?
Sponsored content