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.

Displaying the recent activity in the profile

2 posters

Go down

Displaying the recent activity in the profile Empty Displaying the recent activity in the profile

Post by Mihai June 1st 2021, 3:07 am

Hi all,

We have developed a code that allows the display of the latest activity in user profiles. The code has been tested and works for phpBB and modernBB.

Demonstration:
Displaying the recent activity in the profile Goood10

Panel > Modules > HTML & JAVASCRIPT > Javascript code management > Create a new JavaScript code


  • Title: Displaying the recent activity in the profile
  • Location: All Pages
  • Code:

    Code:

    $(function() {

        if (window.location.pathname.search("/u") !== -1) {
            var default_language = 0; // 0 - romanian, 1 - english

            var p_ID = window.location.pathname.replace(/[^0-9\ ]/g, ''),
                p_is_online = false,
                p_location = null,
                p_last_update = null;

            if (typeof p_ID === 'undefined') return;

            var lang = [{
                    user_is_offline: "Nu exista date disponibile.<br /> Utilizatorul nu este conectat.",
                    recent_activity: "Activitate recenta",
                    loading: "Se incarca datele ...",
                    location: "Localizare in forum:",
                    last_update: "Ultima activitate:",
                    his_profile: "Profilul lui %s"
                },
                {
                    user_is_offline: "No data available. <br /> The user is not logged in.",
                    recent_activity: "Recent activity",
                    loading: "Loading data ...",
                    location: "Location in forum:",
                    last_update: "Last activity:",
                    his_profile: "%s's profile"
                }
            ];

            $.get("/viewonline", function(data) {
                $('.forumbg a[href="/u' + p_ID + '"]', data).each(function() {
                    p_is_online = true;
                    p_username = $('a[href="/u' + p_ID + '"]', data).parent().parent().find('td:nth-child(1)').html();
                    p_location = ($('a[href="/u' + p_ID + '"]', data).parent().parent().find('td:nth-child(3)').html().search("/viewonline") > -1) ? lang[default_language].his_profile.replace("%s", p_username) : $('a[href="/u' + p_ID + '"]', data).parent().parent().find('td:nth-child(3)').html();
                    p_last_update = $('a[href="/u' + p_ID + '"]', data).parent().parent().find('td:nth-child(2)').html();
                    $("#user_activity").html("<strong>" + lang[default_language].location + "</strong> " + p_location + "<br /> <strong>" + lang[default_language].last_update + "</strong> " + p_last_update);
                });

                if (p_is_online === false) $("#user_activity").html(lang[default_language].user_is_offline);

            }, "html");

            $("#profile-advanced-right .module + .module").before('<div class="module" style="margin-bottom:4px;"><div class="inner"><span class="corners-top"><span></span></span><div class="h3"><span style="color:#EF3333"><strong>' + lang[default_language].recent_activity + '</strong></span></div><div style="text-align:left;"><div id="user_activity">' + lang[default_language].loading + '</div></div><span class="corners-bottom"><span></span></span></div></div>');
        }
    });
Mihai
Mihai
Forumember

Male Posts : 966
Reputation : 39
Language : Romanian, English
Location : Bucharest, Romania

https://fgsuport.forumotion.com/

SarkZKalie, TonnyKamper and Jucarese like this post

Back to top Go down

Displaying the recent activity in the profile Empty Re: Displaying the recent activity in the profile

Post by Beyonder December 2nd 2021, 6:45 pm

It's amazing! but is it supposed to duplicate?
Beyonder
Beyonder
Forumember

Male Posts : 726
Reputation : 29
Language : English
Location : Beyond Realm

http://fictionalomniverse.forumotion.com/

Back to top Go down

Back to top

- Similar topics

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