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.

Friend & Foes request in posts.

5 posters

Go down

Friend & Foes request in posts. Empty Friend & Foes request in posts.

Post by JScript June 18th 2015, 8:50 pm

A code based on this suggestion https://help.forumotion.com/t50435p30-friend-request-in-posts at the same time an improvement based on this code: https://help.forumotion.com/t50435p30-#945167

In your ACP: Modules -> HTML&JAVASCRIPT -> JavaScript codes management -> [Create a new JavaScript]
Title *: <- Whatever you want
Placement : <- In topics
Javascript Code * : <- Select, copy and paste the code below in this field:
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>'
                     )
                  }
               }
            }
         }
      }
   });
});

I appreciate if someone test and post a "print" of the result...

JS
JScript
JScript
Forumember

Male Posts : 741
Reputation : 175
Language : PT-BR, EN
Location : Brazil

http://jscript.forumeiros.com/

Back to top Go down

Friend & Foes request in posts. Empty Re: Friend & Foes request in posts.

Post by SLGray June 19th 2015, 12:29 am

I added this to my punBB forum.  The options show up in the topics, but they are not clickable.


Friend & Foes request in posts. 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 : 51581
Reputation : 3525
Language : English
Location : United States

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

Back to top Go down

Friend & Foes request in posts. Empty Re: Friend & Foes request in posts.

Post by JScript June 19th 2015, 1:12 am

@SLGray
Ok, in this case you could provide me a temporary account so that I can test logged in your forum?

JS
JScript
JScript
Forumember

Male Posts : 741
Reputation : 175
Language : PT-BR, EN
Location : Brazil

http://jscript.forumeiros.com/

Back to top Go down

Friend & Foes request in posts. Empty Re: Friend & Foes request in posts.

Post by SLGray June 19th 2015, 8:08 am

You are already a member (FM Themes).


Friend & Foes request in posts. 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 : 51581
Reputation : 3525
Language : English
Location : United States

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

Back to top Go down

Friend & Foes request in posts. Empty Re: Friend & Foes request in posts.

Post by JScript June 19th 2015, 11:25 am

@SLGray
Ok, I thought it was this: http://beingcreative.forumotion.com/

Well, there is a small error in your CSS that makes the links of class .user-contact .profile_left stay behind!
It's a bit complicated to explain, but follow these steps and the problem will be solved:

1. Add the following CSS:
Code:

.postfoot {
  bottom: -11px;
  position: relative;
}
.pun .postfoot .user-contact {
  bottom: 11px;
  position: relative;
}

2. Now remove this section of your CSS:
Code:

.post-options {
  bottom: -11px;
  position: relative;
}

JS
JScript
JScript
Forumember

Male Posts : 741
Reputation : 175
Language : PT-BR, EN
Location : Brazil

http://jscript.forumeiros.com/

Back to top Go down

Friend & Foes request in posts. Empty Re: Friend & Foes request in posts.

Post by Mati June 19th 2015, 12:47 pm

Hi, is this option for all forum version ?
Mati
Mati
Active Poster

Posts : 1933
Reputation : 333
Language : HTML, CSS & JavaScript
Location : Forum Services

https://fm-focus.forumotion.com/

Back to top Go down

Friend & Foes request in posts. Empty Re: Friend & Foes request in posts.

Post by JScript June 19th 2015, 1:02 pm

Mati wrote:Hi, is this option for all forum version ?
Hello, yes, all my codes are meant for all versions currently available!

In my opinion I think meaningless to write code that does not work in all versions...

JS
JScript
JScript
Forumember

Male Posts : 741
Reputation : 175
Language : PT-BR, EN
Location : Brazil

http://jscript.forumeiros.com/

Back to top Go down

Friend & Foes request in posts. Empty Re: Friend & Foes request in posts.

Post by SLGray June 19th 2015, 7:31 pm

After adding and removing the CSS code, I tested it, and it worked.


Friend & Foes request in posts. 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 : 51581
Reputation : 3525
Language : English
Location : United States

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

Back to top Go down

Friend & Foes request in posts. Empty Re: Friend & Foes request in posts.

Post by Enalahs89 August 22nd 2015, 8:29 am

Tested it on mine. The friend section worked but no button to add as a foe.

Friend & Foes request in posts. INmGXNA
Enalahs89
Enalahs89
Forumember

Female Posts : 54
Reputation : 5
Language : English
Location : In your dreams

http://astariel.userboard.net

Back to top Go down

Friend & Foes request in posts. Empty Re: Friend & Foes request in posts.

Post by Abdalah_98 May 16th 2016, 9:06 am

When i click add icon it's show name twice ?!!

like this

his name : gamer

when i click on add icon

go to friends page and show the name twice on box of friends

Code:
gamergamer
Abdalah_98
Abdalah_98
Forumember

Male Posts : 32
Reputation : 1
Language : EN,AR
Location : Earth :D

http://uteach.forum0.net/

Back to top Go down

Friend & Foes request in posts. Empty Re: Friend & Foes request in posts.

Post by SLGray February 23rd 2017, 8:04 am

This will no longer be supported by JScript: https://help.forumotion.com/t151137-in-memory-of-jscript-joao-carlos.


Friend & Foes request in posts. 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 : 51581
Reputation : 3525
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