Advertisement
SSYT

Fast Reply

Feb 28th, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. * Functia fast post message, am facut acest cod pentru cei care vor sa aiba si eu un fast reply pentru topicuri, fara sa mai faca reload page cand postezi
  3. * Versiune: v1.0
  4. * Developer: SSYT (ForumGratuit)
  5. */
  6.  
  7. (function($) {
  8.     window.FastReply = function(version) {
  9.         if(version == "phpbb3")
  10.         {
  11.             var arrType = new Array();
  12.             // Prevent reload page of form submit !
  13.             $('form#quick_reply').on("submit", function(e){e.preventDefault()});
  14.            
  15.             $('form#quick_reply input[name="post"][type="submit"]').on("click", function(e) {
  16.                 e.preventDefault();
  17.                 arrType['formData'] = $('form#quick_reply');
  18.                 arrType['tid'] = $('input[name="tid"]', arrType.formData).val();
  19.                 arrType['t'] = $('input[name="t"]', arrType.formData).val();
  20.                 arrType['lt'] = $('input[name="lt"]', arrType.formData).val();
  21.                 arrType['auth1'] = $('input[name="auth"]:eq(0)', arrType.formData).val();
  22.                 arrType['auth2'] = $('input[name="auth"]:eq(1)', arrType.formData).val();
  23.                 arrType['message'] = $("#text_editor_textarea", arrType.formData).sceditor('instance').val();
  24.                 arrType['value'] = $("#text_editor_textarea", arrType.formData).sceditor("instance").val().replace(/\s/g, '').length;
  25.                 arrType['urlaction'] = "/post?t="+ arrType[2] +"&mode=reply";
  26.                
  27.                 if(5 <= arrType.value || arrType.message == "") {
  28.                     alert("Nu a fost introdus numarul minim de caractere, sau nu exista nici un caracter !");
  29.                 } else {
  30.                     $.post(arrType.urlaction, {
  31.                         'message': arrType.message,
  32.                         'attach_sig': 1,
  33.                         'mode': "reply",
  34.                         'tid': arrType.tid,
  35.                         't': arrType.t,
  36.                         'lt': arrType.lt,
  37.                         'notify': 0,
  38.                         'auth': arrType.auth1,
  39.                         'auth': arrType.auth2,
  40.                         'post': 1
  41.                     }, function(succes) {
  42.                         if(succes.indexOf("Flood") != -1) {
  43.                             alert("Error!\nYou must wait 5 second before replying");
  44.                             $(".lreply").fadeOut(300);
  45.                         }
  46.                        
  47.                         if(succes.indexOf("A new") != -1) {
  48.                             alert("Error!\nSomeone had replied before you posted\nYou must refresh the page to continue.\nNotice : You should save or copy your message if you don't want it gone");
  49.                             $(".lreply").fadeOut(300);
  50.                         }
  51.                        
  52.                         if($(succes).find(".message a:first").attr('href').length > 1) {
  53.                             arrType['urlPost'] = $(succes).find(".message a:first").attr('href');
  54.                            
  55.                             $.get(arrType.urlPost, function(z) {
  56.                                 $("#quick_reply input[name='auth[]']:last").val($(z).find("#quick_reply input[name='auth[]']:last").val());
  57.                                 $("#quick_reply input[name='lt']").val($(z).find("#quick_reply input[name='lt']").val());
  58.                                 $(z).find(".post:last").hide().insertAfter(".post:last").slideDown(400);
  59.                             });
  60.                         }
  61.                     }).fail(function() {
  62.                         alert("Error!\nA aparut o problema la trimiterea acestui mesaj !");
  63.                         $(".lreply").fadeOut(300);
  64.                     });
  65.                     $("#text_editor_textarea").sceditor('instance').val("");
  66.                     $(".lreply").fadeOut(300);
  67.                 }
  68.             });
  69.             console.log("[FG Plugin] Succes load plugin `Fast Reply` by SSYT !\n[FG Plugin] Your curent version used:", version);
  70.         } else { alert("Error !\n Please select your forum version") };
  71.     }
  72. }(jQuery));
  73. FastReply("phpbb3");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement