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 ?

View previous topic View next topic Go down

Solved add friends on post profile ?

Post by rocket2300 on January 20th 2016, 9:01 pm

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 January 24th 2016, 9:35 pm; edited 1 time in total

rocket2300
Forumember

Male Posts : 214
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 January 21st 2016, 2: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.


SLGray
Administrator
Administrator

Male Posts : 36751
Reputation : 2449
Language : English
Location : United States

http://ztwds.forumotion.com/

Back to top Go down

Solved Re: add friends on post profile ?

Post by rocket2300 on January 21st 2016, 4: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.

rocket2300
Forumember

Male Posts : 214
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 January 22nd 2016, 10:20 am

Anyone ?

rocket2300
Forumember

Male Posts : 214
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 January 24th 2016, 8:16 am

help please ?

rocket2300
Forumember

Male Posts : 214
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 January 24th 2016, 4: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>'
                            )
                          }
                      }
                    }
                }
              }
          });
        });

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: add friends on post profile ?

Post by rocket2300 on January 24th 2016, 6:38 pm

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.

rocket2300
Forumember

Male Posts : 214
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 January 24th 2016, 6:51 pm

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.

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: add friends on post profile ?

Post by rocket2300 on January 24th 2016, 9:34 pm

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

Solved.

rocket2300
Forumember

Male Posts : 214
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 January 24th 2016, 9:36 pm

Topic solved and archived


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


SLGray
Administrator
Administrator

Male Posts : 36751
Reputation : 2449
Language : English
Location : United States

http://ztwds.forumotion.com/

Back to top Go down

View previous topic View next topic Back to top


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