AvacWeb
  • HomeHome  
  • SearchSearch  

    Search Query


    Display results as :


    Advanced Search Advanced Search

  • MemberlistMemberlist  
  • RegisterRegister  
  • AWC  
  • Log inLog in  

Topics

    Users

      Posts

        NEW AWC 2.1 UPDATE IS HERE | Get it here!
        (150px x 30px Banner)
        #tutorial #LGBB #tips #OST #AWC
        Trending Hashtags

        The most tagged members


        Page 1 of 1 • 

        [TUTORIAL] Automatic post when moving topic

        DaemonDaemon
        Status : No status yet...

        Posts : 21
        Join date : 2013-02-04
        Post #22850
        on 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:
        Image 1:


        Image 2:
        Thank Poster
        fasciculariafascicularia
        Status : No status yet...

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

        Posts : 21
        Join date : 2013-02-04
        Post #22872
        on 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
        Thank Poster
        pedro
        pedro
        Status : http://illiweb.com/fa/invision/pp-blank-thumb.png

        Posts : 330
        Join date : 2012-10-18
        Post #22873
        on Sat 28 Mar 2015, 17:12
        Hello Daemon's you can do to invision . thank you very much
        Thank Poster
        avatarBloodbath
        Bloodbath
        Status : No status yet...

        Posts : 745
        Join date : 2013-05-31
        Age : 22
        Post #22874
        on 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.
        Thank Poster
        fasciculariafascicularia
        Status : No status yet...

        Posts : 22
        Join date : 2012-10-04
        Post #23024
        on 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
        Thank Poster
        kenshakensha
        Status : No status yet...

        Posts : 5
        Join date : 2015-01-14
        Post #23268
        on Sat 06 Jun 2015, 01:45
        hi,
        can you help me with this code to phpbb3 ?
        Thank Poster
        Sponsored contentSponsored content
        Post #0
        Thank Poster

        Previous Topic • Next Topic

        Copyright © Avacweb 2011 -

        Free forum | © phpBB | Free forum support | Contact | Report an abuse | Free forum