The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Quick reply fix for Staff Background

3 posters

Go down

Solved Quick reply fix for Staff Background

Post by TheCrow May 1st 2016, 3:13 am

Technical Details


Forum version : #phpBB3
Position : Founder
Concerned browser(s) : Mozilla Firefox, Google Chrome, Internet Explorer, Opera, Safari, Other
Screenshot of problem : https://i.gyazo.com/89f189acc64c46a0158fa3aeae3f963f.gif
Who the problem concerns : All members
Forum link : http://www.thinktankforum.net

Description of problem

Hello,

I am currently using the Quick Reply code that posts without the page refresh and currently i added the Staff Background code to add a border left and border right based on the member's rank and once you Send the post, the post does not include the Staff Background.

Here's how it should look:
Quick reply fix for Staff Background M8AxjCq
And here's how it looks now:
Quick reply fix for Staff Background 5IMr1SX

This is the code i am using for the Quick Reply without a page refresh:
Code:
// phpBB3 version;
//By doannamthai-getover || forumotion-forumvi ;
$(function () {
$('#quick_reply input[name="post"]').click(function(a){
a.preventDefault();
var g = $("#text_editor_textarea").sceditor('instance').val();
var href = $('a[href*="mode=reply"]').attr("href");
var value = $("#text_editor_textarea").sceditor("instance").val().replace(/\s/g, '').length;
if(2 <= value){
$('<span class="lreply" style="color: red;font-weight: bold; text-transform: uppercase;"><br>Your message is being posted...</span>').appendTo("#quick_reply div:last");
$.post(href, {
            "message" : g,
            "auth[]": $("#quick_reply input[name='auth[]']:last").val(),
            "lt" : $("#quick_reply input[name='lt']").val(),
            "tid" : $("#quick_reply input[name='tid']").val(),
            "attach_sig" : "1" ,
            "post": "Send"
}, function(t) {
if(t.indexOf("Flood") != -1){
alert("Error!\nYou must wait 5 second before replying");
$(".lreply").fadeOut(300);
}
if(t.indexOf("A new") != -1){
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");
$(".lreply").fadeOut(300);
}
if($(t).find('.panel a[href*="/viewtopic"]:first').attr('href').length >1) {
var f = $(t).find('.panel a[href*="/viewtopic"]:first').attr('href');
var postid = f.split('#')[1];
$.get(f , function(z){
$("#quick_reply input[name='auth[]']:last").val($(z).find("#quick_reply input[name='auth[]']:last").val());
$("#quick_reply input[name='lt']").val($(z).find("#quick_reply input[name='lt']").val());
$(z).find("#p"+postid).hide().insertAfter(".post:last").slideDown(400);
});
$("#text_editor_textarea").sceditor('instance').val("");
$(".lreply").fadeOut(300);
}
});
}
else {
alert("Sorry\nThe content is too short to send!\nYou must write at least 2 characters.");
}
});
});

Any help will be appreciated!

Edit: This is how it looks when someone presses send for their post:
Quick reply fix for Staff Background 89f189acc64c46a0158fa3aeae3f963f
The Staff Background appears then once you refresh the page and i'd love that to work even before the refresh if possible.

Regards,
Luffy :rose:
TheCrow
TheCrow
Manager
Manager

Male Posts : 6913
Reputation : 794
Language : Greek, English

https://forumote.forumotion.com

Back to top Go down

Solved Re: Quick reply fix for Staff Background

Post by Ange Tuteur May 1st 2016, 3:21 am

@Luffy I'll be going to bed soon, but If you can send me the script you're using for the staff posts then I'll be able to fix it up for you.

See you bye
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13246
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Quick reply fix for Staff Background

Post by TheCrow May 1st 2016, 3:23 am

@Ange Tuteur here's the script:
Code:
$(function() {
  var groups = [
    'admin', /* administrator */
    'smod', /* super moderator */
    'mmod', /* moderator */
    'gmem', /* golden member */
    'gmas', /* gaming master */
    'memb' /* members */
  ],
 
  profil = $('.postprofile'),
  html,
  post,
  i = 0,
  j = profil.length,
  k,
  l = groups.length;
 
  for (; i < j; i++) {
    html = profil[i].innerHTML.replace(/\n/gm,'');
   
    if (/class="st-rang.*?"/.test(html)) {
      html = html.replace(/.*class="st-rang\s(.*?)".*/, '$1').replace(/\s/g, '');
      post = profil[i].parentNode.parentNode;
      post.className += ' st-answer';
     
      for (k = 0; k < l; k++) {
        if (html == groups[k]) {
          post.className += ' ' + groups[k];
          break;
        }
      }
    }
   
  }
});
and here's the CSS:
Code:
.post.st-answer.admin{border-left:5px solid #9A5C26!important;border-right:5px solid #9A5C26!important;}
.post.st-answer.smod{border-left:5px solid #37778E!important;border-right:5px solid #37778E!important;}
.post.st-answer.mmod{border-left:5px solid #348428!important;border-right:5px solid #348428!important;}
.post.st-answer.gmem{border-left:5px solid #ABA926!important;border-right:5px solid #ABA926!important;}
.post.st-answer.gmas{border-left:5px solid #CC3535!important;border-right:5px solid #CC3535!important;}
.post.st-answer.memb{border-left:5px solid #9A9292!important;border-right:5px solid #9A9292!important;}
TheCrow
TheCrow
Manager
Manager

Male Posts : 6913
Reputation : 794
Language : Greek, English

https://forumote.forumotion.com

Back to top Go down

Solved Re: Quick reply fix for Staff Background

Post by Ange Tuteur May 1st 2016, 5:13 pm

Thanks :rose:

Replace your staff post script with this one :
Code:
function parseGroupPosts() {
  var groups = [
    'admin', /* administrator */
    'smod', /* super moderator */
    'mmod', /* moderator */
    'gmem', /* golden member */
    'gmas', /* gaming master */
    'memb' /* members */
  ],
 
  profil = $('.post:not(.st-answer) .postprofile'),
  html,
  post,
  i = 0,
  j = profil.length,
  k,
  l = groups.length;
 
  for (; i < j; i++) {
    html = profil[i].innerHTML.replace(/\n/gm,'');
 
    if (/class="st-rang.*?"/.test(html)) {
      html = html.replace(/.*class="st-rang\s(.*?)".*/, '$1').replace(/\s/g, '');
      post = profil[i].parentNode.parentNode;
      post.className += ' st-answer';
   
      for (k = 0; k < l; k++) {
        if (html == groups[k]) {
          post.className += ' ' + groups[k];
          break;
        }
      }
    }
 
  }
};

$(parseGroupPosts);


and replace your quick reply script with this one :
Code:
// phpBB3 version;
//By doannamthai-getover || forumotion-forumvi ;
$(function () {
$('#quick_reply input[name="post"]').click(function(a){
a.preventDefault();
var g = $("#text_editor_textarea").sceditor('instance').val();
var href = $('a[href*="mode=reply"]').attr("href");
var value = $("#text_editor_textarea").sceditor("instance").val().replace(/\s/g, '').length;
if(2 <= value){
$('<span class="lreply" style="color: red;font-weight: bold; text-transform: uppercase;"><br>Your message is being posted...</span>').appendTo("#quick_reply div:last");
$.post(href, {
            "message" : g,
            "auth[]": $("#quick_reply input[name='auth[]']:last").val(),
            "lt" : $("#quick_reply input[name='lt']").val(),
            "tid" : $("#quick_reply input[name='tid']").val(),
            "attach_sig" : "1" ,
            "post": "Send"
}, function(t) {
if(t.indexOf("Flood") != -1){
alert("Error!\nYou must wait 5 second before replying");
$(".lreply").fadeOut(300);
}
if(t.indexOf("A new") != -1){
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");
$(".lreply").fadeOut(300);
}
if($(t).find('.panel a[href*="/viewtopic"]:first').attr('href').length >1) {
var f = $(t).find('.panel a[href*="/viewtopic"]:first').attr('href');
var postid = f.split('#')[1];
$.get(f , function(z){
$("#quick_reply input[name='auth[]']:last").val($(z).find("#quick_reply input[name='auth[]']:last").val());
$("#quick_reply input[name='lt']").val($(z).find("#quick_reply input[name='lt']").val());
$(z).find("#p"+postid).hide().insertAfter(".post:last").slideDown(400);
parseGroupPosts();
});
$("#text_editor_textarea").sceditor('instance').val("");
$(".lreply").fadeOut(300);
}
});
}
else {
alert("Sorry\nThe content is too short to send!\nYou must write at least 2 characters.");
}
});
});

If any problems let me know. salut
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13246
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Quick reply fix for Staff Background

Post by TheCrow May 1st 2016, 10:13 pm

@Ange Tuteur this works perfectly now! :rose:

Thanks a lot for your help!! Much appreciated!! Smile

Solved! Very Happy
TheCrow
TheCrow
Manager
Manager

Male Posts : 6913
Reputation : 794
Language : Greek, English

https://forumote.forumotion.com

Back to top Go down

Solved Re: Quick reply fix for Staff Background

Post by SLGray May 1st 2016, 10:28 pm

Topic solved and archived


Quick reply fix for Staff Background Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51489
Reputation : 3519
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum