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.
The forum of the forums
4 posters

    Exclude User ID From Javascript

    timberella
    timberella
    Forumember


    Female Posts : 111
    Reputation : 5
    Language : English

    Solved Exclude User ID From Javascript

    Post by timberella May 20th 2018, 12:47 am

    I have installed this Javascript module to hide profile signatures in certain topics/forums/categories.

    Code:
    $(function(){

    /* --- CONFIGURATION --- */
    // Topic IDs where the signatures are hidden
    var topic_ids = [1, 2, 3];
    // Forum IDs where the signatures are hidden
    var forum_ids = [4, 5];
    // Category IDs where the signatures are hidden
    var cat_ids = [7];
    /* --- CONFIGURATION --- */

    var topic_match = window.location.pathname.match(/\/t(\d+)/); if (!topic_match) return;
     Â var current_topic = topic_match[1];
     Â var navbar = document.querySelector('.pathname-box');
     Â if (!current_topic || !navbar) return;
     Â var forum_selector = navbar.querySelectorAll('.nav');
     Â var current_forum = forum_selector[forum_selector.length - 1]; if (!current_forum) return;
     Â var forum_match = current_forum.href.match(/\/f(\d+)/); if (!forum_match) return;
     Â current_forum = forum_match[1]; if (!current_forum) return;
     Â if (topic_ids.includes(parseInt(current_topic)) || forum_ids.includes(parseInt(current_forum))) {
     Â   $('.signature_div').filter(function(){ this.style.display = "none" });
     Â }
     Â var cat_selector = navbar.querySelectorAll('.nav');
     Â var current_cat = cat_selector[cat_selector.length - 2]; if (!current_cat) return;
     Â var cat_match = current_cat.href.match(/\/c(\d+)/); if (!cat_match) return;
     Â current_cat = cat_match[1]; if (!current_cat) return;
     Â if (topic_ids.includes(parseInt(current_topic)) || cat_ids.includes(parseInt(current_cat))) {
     Â   $('.signature_div').filter(function(){ this.style.display = "none" });
     Â }
    });

    I have a member who would like to view the profile signatures in one of these categories, so I want to ask if there is some code that can be added to my code above for excluding a member based on their user ID.  It would make her so happy if this can be done.  Thanks in advance for whatever you can do!

    Our forum is phpbb3.
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51554
    Reputation : 3523
    Language : English
    Location : United States

    Solved Re: Exclude User ID From Javascript

    Post by SLGray May 20th 2018, 12:58 am

    I believe it would be easier if you used a code that hide all signatures,but there would be a button to click to view the signatures.



    Exclude User ID From Javascript Slgray10

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


    Female Posts : 111
    Reputation : 5
    Language : English

    Solved Re: Exclude User ID From Javascript

    Post by timberella May 20th 2018, 1:11 am

    Thank you for the reply, @SLGray.

    If your suggestion is possible, then I would be happy to receive that code and give that suggestion a try.
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51554
    Reputation : 3523
    Language : English
    Location : United States

    Solved Re: Exclude User ID From Javascript

    Post by SLGray May 20th 2018, 1:27 am

    http://fmdesign.forumotion.com/t196-clip-and-toggle-signatures

    You can change the height part of the code to zero that will hide all signatures. Then you just have to click the button to see them.



    Exclude User ID From Javascript Slgray10

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


    Female Posts : 111
    Reputation : 5
    Language : English

    Solved Re: Exclude User ID From Javascript

    Post by timberella May 20th 2018, 2:35 am

    This code looks like you would have to click a button on a reply-by-reply basis to reveal the signature.
    Is that correct?

    I would need a button that would reveal all the signatures on a page, not just one at a time.
    Draxion
    Draxion
    Helper
    Helper


    Male Posts : 2518
    Reputation : 321
    Language : English
    Location : USA

    Solved Re: Exclude User ID From Javascript

    Post by Draxion May 20th 2018, 2:47 am

    Based on your first question regarding that script, are you saying you want to enable a member (the one with the ID) to be excluded from the script?
    Wecoc
    Wecoc
    Forumember


    Male Posts : 144
    Reputation : 111
    Language : Catalan, Spanish, English

    Solved Re: Exclude User ID From Javascript

    Post by Wecoc May 20th 2018, 3:30 am

    Here's it.

    Code:
    $(function(){
    if ([4].includes(_userdata.user_id)) return;
     
    /* --- CONFIGURATION --- */
    // Topic IDs where the signatures are hidden
    var topic_ids = [1, 2, 3];
    // Forum IDs where the signatures are hidden
    var forum_ids = [4, 5];
    // Category IDs where the signatures are hidden
    var cat_ids = [7];
    /* --- CONFIGURATION --- */
     
    var topic_match = window.location.pathname.match(/\/t(\d+)/); if (!topic_match) return;
      var current_topic = topic_match[1];
      var navbar = document.querySelector('.pathname-box');
      if (!current_topic || !navbar) return;
      var forum_selector = navbar.querySelectorAll('.nav');
      var current_forum = forum_selector[forum_selector.length - 1]; if (!current_forum) return;
      var forum_match = current_forum.href.match(/\/f(\d+)/); if (!forum_match) return;
      current_forum = forum_match[1]; if (!current_forum) return;
      if (topic_ids.includes(parseInt(current_topic)) || forum_ids.includes(parseInt(current_forum))) {
        $('.signature_div').filter(function(){ this.style.display = "none" });
      }
      var cat_selector = navbar.querySelectorAll('.nav');
      var current_cat = cat_selector[cat_selector.length - 2]; if (!current_cat) return;
      var cat_match = current_cat.href.match(/\/c(\d+)/); if (!cat_match) return;
      current_cat = cat_match[1]; if (!current_cat) return;
      if (topic_ids.includes(parseInt(current_topic)) || cat_ids.includes(parseInt(current_cat))) {
        $('.signature_div').filter(function(){ this.style.display = "none" });
      }
    });

    It's the second line, change 4 for the user ID (on its profile, the number on the link).
    You can use as many as you want, for example [4, 8, 15, 16, 23, 42] to block the script on different users.

    PS: I checked the other problem with this script but I have no idea what's wrong with it, sorry.
    timberella
    timberella
    Forumember


    Female Posts : 111
    Reputation : 5
    Language : English

    Solved Re: Exclude User ID From Javascript

    Post by timberella May 20th 2018, 7:13 am

    Yes, @Draxion, and it looks like @Wecoc has provided me with what I was looking for.

    Thanks so much, Wecoc, you're always helping me with my Javascript needs, and I really appreciate it!  I'm sure the member who would like to see these signatures will be thrilled, and the rest of us that don't want to see them will also be happy.

    I'm sorry to hear that you can't see why the toolbar isn't showing for the Quick Reply editor in IE, but thanks so much for giving it a look.

    Cheers.

    I'll mark this topic as solved.
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51554
    Reputation : 3523
    Language : English
    Location : United States

    Solved Re: Exclude User ID From Javascript

    Post by SLGray May 20th 2018, 10:01 am

    Problem solved & topic archived.
    Please read our forum rules:  ESF General Rules



    Exclude User ID From Javascript Slgray10

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

      Current date/time is November 12th 2024, 3:28 am