The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

add friends on post profile ?

Go down

Solved add friends on post profile ?

Post by rocket2300 on Thu Jan 21, 2016 4:01 am

I know there is already a topic about this and I used the script given on there by @JScript

Code:
       
        $(function() {
          if (!_userdata.session_logged_in) {
              return false;
          }
          var FFinPosts = {
              sFriend: "Add As Friend",
              sFoes: "Add To Foes",
              oTarget: $('.post'),
              iLen: 0,
              sUser_name: "",
              oFF_list: null,
              aFF_list: [],
              vTemp: null,
              oThis: null
          };
          FFinPosts.iLen = FFinPosts.oTarget.length;
       
          $.ajax({
              url: "/u" + _userdata.user_id + 'friends',
              cache: false,
              type: "get",
              dataType: "text",
              success: function(response, status, xhr) {
                if (xhr.status == 200) {
                    FFinPosts.oFF_list = $('#profile-advanced-details ol .message-header > a[href^="/u"]', response);
       
                    for (var i = 0; i < FFinPosts.oFF_list.length; i++) {
                      FFinPosts.aFF_list[FFinPosts.aFF_list.length] = $(FFinPosts.oFF_list[i]).text();
                    }
       
                    for (var i = 0; i < FFinPosts.iLen; i++) {
                      FFinPosts.oThis = $(FFinPosts.oTarget[i]);
                      FFinPosts.sUser_name = FFinPosts.oThis.find('.author a, .name, .user a[href^="/u"]').text();
       
                      if (FFinPosts.sUser_name !== _userdata.username) {
                          FFinPosts.vTemp = FFinPosts.oThis.find('.postprofile dd:last, .postdetails.poster-profile, .user-contact');
       
                          if (FFinPosts.aFF_list.indexOf(FFinPosts.sUser_name) == -1) {
       
                            FFinPosts.vTemp.append(
                                '<a class="profile-icon" href="/profile?friend=' + encodeURIComponent(FFinPosts.sUser_name) + '&mode=editprofile&page_profil=friendsfoes">' +
                                '  <img title="Add As Friend" alt="Add As Friend" src="http://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/16/Actions-list-add-user-icon.png" width="25" height="25">' +
                                '</a>'
                            )
                          } else {
                            FFinPosts.vTemp.append(
                                '<a class="profile-icon" href="/profile?foe=' + encodeURIComponent(FFinPosts.sUser_name) + '&mode=editprofile&page_profil=friendsfoes">' +
                                '  <img title="Add To Foes" alt="Add To Foes" src="http://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/16/Actions-list-remove-user-icon.png" width="25" height="25">' +
                                '</a>'
                            )
                          }
                      }
                    }
                }
              }
          });
        });

Which is supposed to remove the add friend icon once a particular person is in your friends
list, but the icon is still showing for me, so is there some modification I can make to the
script to make it disappear ?

Im using PhpBB3.



Last edited by Mick-1800 on Mon Jan 25, 2016 4:35 am; edited 1 time in total
avatar
rocket2300
Forumember

Male Posts : 218
Reputation : 4
Language : english
Location : United Kingdom

http://www.suzuki-intruder.org

Back to top Go down

Solved Re: add friends on post profile ?

Post by SLGray on Thu Jan 21, 2016 9:29 am

Are you should it is the add friends button, not the add foe button?

= foe
= friend


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

avatar
SLGray
Administrator
Administrator

Male Posts : 42749
Reputation : 3010
Language : English
Location : United States

https://fmthemes.forumotion.com/

Back to top Go down

Solved Re: add friends on post profile ?

Post by rocket2300 on Thu Jan 21, 2016 11:41 am

yes definitely the add friend, it has the + on the icon and when I look on my friends list
it says "The member that you wish to add is already present in Friends list", but the icon
is still showing on his post profile.
avatar
rocket2300
Forumember

Male Posts : 218
Reputation : 4
Language : english
Location : United Kingdom

http://www.suzuki-intruder.org

Back to top Go down

Solved Re: add friends on post profile ?

Post by rocket2300 on Fri Jan 22, 2016 5:20 pm

Anyone ?
avatar
rocket2300
Forumember

Male Posts : 218
Reputation : 4
Language : english
Location : United Kingdom

http://www.suzuki-intruder.org

Back to top Go down

Solved Re: add friends on post profile ?

Post by rocket2300 on Sun Jan 24, 2016 3:16 pm

help please ?
avatar
rocket2300
Forumember

Male Posts : 218
Reputation : 4
Language : english
Location : United Kingdom

http://www.suzuki-intruder.org

Back to top Go down

Solved Re: add friends on post profile ?

Post by Ange Tuteur on Sun Jan 24, 2016 11:04 pm

Yep, I think the flaw may be with the script itself.. I see that the script sends a request to this page :
Code:
"/u" + _userdata.user_id + 'friends'
which would be equal to your own friends list. For example : http://help.forumotion.com/u88576friends

As you can see, there's multiple pages so it would take multiple requests to get every friend on your friend list. Unfortunately the script you're using only makes one request to the first page of your friends list, ignoring the rest of the people you've added. The best page to use would be this one : http://help.forumotion.com/profile?mode=editprofile&page_profil=friendsfoes as it displays all your friends and foes.

I made a modification to use the page I suggested, let me know if it works for you.
Code:
     
        $(function() {
          if (!_userdata.session_logged_in) {
              return false;
          }
          var FFinPosts = {
              sFriend: "Add As Friend",
              sFoes: "Add To Foes",
              oTarget: $('.post'),
              iLen: 0,
              sUser_name: "",
              oFF_list: null,
              aFF_list: [],
              vTemp: null,
              oThis: null
          };
          FFinPosts.iLen = FFinPosts.oTarget.length;
     
          $.ajax({
              url: '/profile?mode=editprofile&page_profil=friendsfoes',
              cache: false,
              type: "get",
              dataType: "text",
              success: function(response, status, xhr) {
                if (xhr.status == 200) {
                    FFinPosts.oFF_list = $('div:has(> a[href*="page_profil=friendsfoes&remove"]) a:first-child', response);
     
                    for (var i = 0; i < FFinPosts.oFF_list.length; i++) {
                      FFinPosts.aFF_list[FFinPosts.aFF_list.length] = $(FFinPosts.oFF_list[i]).text();
                    }
     
                    for (var i = 0; i < FFinPosts.iLen; i++) {
                      FFinPosts.oThis = $(FFinPosts.oTarget[i]);
                      FFinPosts.sUser_name = FFinPosts.oThis.find('.author a, .name, .user a[href^="/u"]').text();
     
                      if (FFinPosts.sUser_name !== _userdata.username) {
                          FFinPosts.vTemp = FFinPosts.oThis.find('.postprofile dd:last, .postdetails.poster-profile, .user-contact');
     
                          if (FFinPosts.aFF_list.indexOf(FFinPosts.sUser_name) == -1) {
     
                            FFinPosts.vTemp.append(
                                '<a class="profile-icon" href="/profile?friend=' + encodeURIComponent(FFinPosts.sUser_name) + '&mode=editprofile&page_profil=friendsfoes">' +
                                '  <img title="Add As Friend" alt="Add As Friend" src="http://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/16/Actions-list-add-user-icon.png" width="25" height="25">' +
                                '</a>'
                            )
                          } else {
                            FFinPosts.vTemp.append(
                                '<a class="profile-icon" href="/profile?foe=' + encodeURIComponent(FFinPosts.sUser_name) + '&mode=editprofile&page_profil=friendsfoes">' +
                                '  <img title="Add To Foes" alt="Add To Foes" src="http://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/16/Actions-list-remove-user-icon.png" width="25" height="25">' +
                                '</a>'
                            )
                          }
                      }
                    }
                }
              }
          });
        });
avatar
Ange Tuteur
Forumaster

Male Posts : 13194
Reputation : 2907
Language : EN10, FR5, JA5
Location : Macungie, PA

https://github.com/SethClydesdale

Back to top Go down

Solved Re: add friends on post profile ?

Post by rocket2300 on Mon Jan 25, 2016 1:38 am

Many many thanks for the reply Ange, yes it kind of works, but I only want the add friend icon
and for it to disappear once they have been added. The code you gave me replaced the
add friend icon with the add to foes icon once they were added to my friends.
avatar
rocket2300
Forumember

Male Posts : 218
Reputation : 4
Language : english
Location : United Kingdom

http://www.suzuki-intruder.org

Back to top Go down

Solved Re: add friends on post profile ?

Post by Ange Tuteur on Mon Jan 25, 2016 1:51 am

Oh no problem, replace the script with this instead :
Code:
   
        $(function() {
          if (!_userdata.session_logged_in) {
              return false;
          }
          var FFinPosts = {
              sFriend: "Add As Friend",
              sFoes: "Add To Foes",
              oTarget: $('.post'),
              iLen: 0,
              sUser_name: "",
              oFF_list: null,
              aFF_list: [],
              vTemp: null,
              oThis: null
          };
          FFinPosts.iLen = FFinPosts.oTarget.length;
   
          $.ajax({
              url: '/profile?mode=editprofile&page_profil=friendsfoes',
              cache: false,
              type: "get",
              dataType: "text",
              success: function(response, status, xhr) {
                if (xhr.status == 200) {
                    FFinPosts.oFF_list = $('div:has(> a[href*="page_profil=friendsfoes&remove"]) a:first-child', response);
   
                    for (var i = 0; i < FFinPosts.oFF_list.length; i++) {
                      FFinPosts.aFF_list[FFinPosts.aFF_list.length] = $(FFinPosts.oFF_list[i]).text();
                    }
   
                    for (var i = 0; i < FFinPosts.iLen; i++) {
                      FFinPosts.oThis = $(FFinPosts.oTarget[i]);
                      FFinPosts.sUser_name = FFinPosts.oThis.find('.author a, .name, .user a[href^="/u"]').text();
   
                      if (FFinPosts.sUser_name !== _userdata.username) {
                          FFinPosts.vTemp = FFinPosts.oThis.find('.postprofile dd:last, .postdetails.poster-profile, .user-contact');
   
                          if (FFinPosts.aFF_list.indexOf(FFinPosts.sUser_name) == -1) {
   
                            FFinPosts.vTemp.append(
                                '<a class="profile-icon" href="/profile?friend=' + encodeURIComponent(FFinPosts.sUser_name) + '&mode=editprofile&page_profil=friendsfoes">' +
                                '  <img title="Add As Friend" alt="Add As Friend" src="http://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/16/Actions-list-add-user-icon.png" width="25" height="25">' +
                                '</a>'
                            )
                          } else {
                            // foes
                          }
                      }
                    }
                }
              }
          });
        });

That should remove the foes button.
avatar
Ange Tuteur
Forumaster

Male Posts : 13194
Reputation : 2907
Language : EN10, FR5, JA5
Location : Macungie, PA

https://github.com/SethClydesdale

Back to top Go down

Solved Re: add friends on post profile ?

Post by rocket2300 on Mon Jan 25, 2016 4:34 am

Your an absolute star Ange, works perfectly. Thankyou very much!. Bow 2

Solved.
avatar
rocket2300
Forumember

Male Posts : 218
Reputation : 4
Language : english
Location : United Kingdom

http://www.suzuki-intruder.org

Back to top Go down

Solved Re: add friends on post profile ?

Post by SLGray on Mon Jan 25, 2016 4:36 am

Topic solved and archived


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

avatar
SLGray
Administrator
Administrator

Male Posts : 42749
Reputation : 3010
Language : English
Location : United States

https://fmthemes.forumotion.com/

Back to top Go down

Back to top


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