Quem está lendo este tópico?

5 participantes

Ver o tópico anterior Ver o tópico seguinte Ir para baixo

Tópico resolvido Quem está lendo este tópico?

Mensagem por ellipsis 18.12.14 19:20

Detalhes da dúvida


Versão do fórum : phpBB3
Nível de acesso : Fundador
Navegador usado : Mozilla Firefox
Membros afetados : Vários usuários, uns sim e outros não
Endereço do fórum : http://testemunhasdejeova.forumeiros.com.pt/

Descrição do problema

Olá,

acabo de aplicar esta nova ferramenta que está disponivel no ultimo pacotão. É uma ferramenta que dá muito jeito.

https://ajuda.forumeiros.com/t96846-12-pacote-de-tutoriais-do-forum-de-suporte

Mas seria possivel colocar esta ferramenta apenas visiveis para os administradores e moderadores?


Última edição por ellipsis em 23.12.14 19:42, editado 1 vez(es)
ellipsis

ellipsis
****

Membro desde : 28/09/2011
Mensagens : 381
Pontos : 530

http://testemunhasdejeova.forumeiros.com.pt/

Ir para o topo Ir para baixo

Principal Contribuidor

Tópico resolvido Re: Quem está lendo este tópico?

Mensagem por Shek 18.12.14 20:52

Boa noite!

Tente com este código:
Código:
    $(function () {
          // PERMITIR SOMENTE PARA MODERADORES E ADMINISTRADORES
        if (_userdata["user_level"] == 1 || _userdata["user_level"] == 2) {
          /**
    * @CP_AddOn Addons for the Forumotion control panel
    * @copyright Copyright (C) 2014 JScript
    * @license http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
    * @engine 1.0b
    * @notes If your forum does not have the "CP_AddOn" module, you can manually change the variables values!

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <mod>
      <header>
          <id>WhereIam</id>
          <title>Where I am?, Topic Active Users (Who is read this topic?)!</title>
          <version>1.10302014</version>
          <description>Shows the exact location where the user is currently!</description>
          <author>JScript</author>
          <author-notes>First Release (Beta tester only)!</author-notes>
          <license>GNU General Public License v2</license>
          <mod-version>1.0.0.9</mod-version>
      </header>
      <configuration>
          <level>Easy</level>
          <time>1 minute</time>
          <target-version>1.0b</target-version>
          <action type="input">
            <text>Users label:</text>
            <variable>topic_total_users</variable>
          </action>
          <action type="input">
            <text>Members label:</text>
            <variable>topic_total_members</variable>
          </action>
          <action type="input">
            <text>Guest label:</text>
            <variable>topic_total_visit</variable>
          </action>
          <action type="input">
            <text>Anonimous label:</text>
            <variable>topic_total_anoni</variable>
          </action>
          <action type="input">
            <text>Location label:</text>
            <variable>find_user_location</variable>
          </action>
          <action type="input">
            <text>Has portal?:</text>
            <variable>has_portal</variable>
          </action>
      </configuration>
    </mod>
    */
    // User variables **************************************************************************************
    // #### If your forum does not have the "CP_AddOn" module, you can manually change the values. ####
    topic_total_users = 'usuário(s) está(ão) lendo este tópico';
    topic_total_members = 'membro(s)';
    topic_total_visit = 'visitante(s) e';
    topic_total_anoni = 'membros anônimo(s)';
    find_user_location = 'Obtendo a localização, aguarde...';
    has_portal = 1; // #### If your forum does not have a "Portal", change the value to 0! ####
    // ******************************************************************************************************

    // System variables!
    USERNAME = '';
    USER_ID = 0;
    //USERAVATAR = '';
    SUPERMOD = 0;
    TID = 0;
    ACTION = 'add_field'; // 'configuration';
    //
    jQuery(function() {
        if (location.pathname.indexOf('/u') !== -1) {
            jQuery('dt:contains("WhereIam")').closest('dl').remove();
        } else if (location.pathname.indexOf('editprofile' !== -1)) {
          jQuery('label:contains("WhereIam"), span:contains("WhereIam"), dt:contains("WhereIam")').closest('dl, tr').remove();
        }
        if (_userdata.session_logged_in) {
            USERNAME = _userdata.username;
            USER_ID = _userdata.user_id;
            // USERAVATAR = jQuery(_userdata.avatar).attr('src');
            SUPERMOD = _userdata.user_level; // Is Admin/Mod ?
            TID = jQuery('a[href*="tid="]').attr('href').split('tid=')[1].split('&')[0]; //Get the var {TID}
        }
        // console.clear();
        console.log("/**************************************************************************");
        console.log("* Module: 'Where I am?' and 'Topic Active Users (Who is read this topic?)'!");
        console.log("* Description: Shows the exact location where the user is currently.");
        console.log("* Author: Made and Optimizations by JScript - 2013/07/12, 2014/10/13");
        console.log("* Version: Beta tester only!");
        console.log("/**************************************************************************");
        console.log('USERNAME: ' + USERNAME);
        console.log("USER_ID: " + USER_ID);
        console.log("TID: " + TID);

        var oWereIam = {
            pathname: location.pathname,
            total_users: 0,
            oSubForum: '',
            oTarget: 0,
          sIndex: '/forum',
            oHtml: {
            phpbb2: '<!-- ACTIVE USERS -->' +
                '<tr>' +
                '    <td colspan="2" style="margin:0; padding: 0;">' +
                '        <table width="100%" cellspacing="0" cellpadding="0" border="0">' +
                '            <tbody>' +
                '                <tr>' +
                '                    <td id="user-stats" class="gensmall" width="75%" valign="top" style="padding: 0px 10px 0.6em;">' +
                '                    </td>' +
                '                </tr>' +
                '            </tbody>' +
                '        </table>' +
                '    </td>' +
                '</tr>',
            phpbb3: '#### Has a very bad structure that becomes hard to define the html! ####',
                punbb: '<!-- ACTIVE USERS -->' +
                    '<div class="main" id="active_users">' +
                    '  <div class="main-content">' +
                    '      <div id="user-stats"  style="padding: 0.6em 1em;">' +
                    '      </div>' +
                    '  </div>' +
                    '</div>',
            invision: '<!-- ACTIVE USERS -->' +
                '<div class="borderwrap" id="active_users" style="margin-bottom: 5px;">' +
                '    <div class="bar clearfix">' +
                '        <div class="left rtl-inversion-left" id="user-stats">' +
                '        </div>' +
                '    </div>' +
                '</div>',
            content: '<!-- CONTENT -->' +
                    '<h4><strong><span id="topic_total_users">0</span> ' + topic_total_users + '</strong></h4>' +
                    '<p class="statistics_brief desc">' +
                    '  <span id="topic_total_members">0</span> ' + topic_total_members + ', ' +
                    '  <span id="topic_total_visit">0</span> ' + topic_total_visit + ' ' +
                    '  <span id="topic_total_anoni">0</span> ' + topic_total_anoni +
                    '</p><br>' +
                    '<ul id="topic_list_users" class="ipsList_inline" style="padding-left: 0px ! important;"></ul>'
            }
        };

        if (_userdata.session_logged_in) {
            WhereIam() // Where I am?
        }

        if (oWereIam.pathname.indexOf('/t') !== -1) {
          /* Forum versions! */
          var phpBB2 = jQuery('#content-container table.forumline:last tbody > tr:eq(1)');
          var phpBB3 = jQuery('#main-content > div.h3:last');
          var punbb = jQuery('#pun-info');
          var invision = jQuery('#main-content .borderwrap:last');

          if (phpBB2.length) {
            jQuery(oWereIam.oHtml.phpbb2).insertBefore(phpBB2);
          } else if(phpBB3.length) {
            jQuery(oWereIam.oHtml.punbb).insertBefore(phpBB3);
          } else if(punbb.length) {
            jQuery(oWereIam.oHtml.punbb).insertBefore(punbb);
          } else if(invision.length) {
            jQuery(oWereIam.oHtml.invision).insertBefore(invision);
          };
          jQuery('#user-stats').html(oWereIam.oHtml.content);

          if (!has_portal) oWereIam.sIndex = '/';

            oWereIam.oSubForum = jQuery('.pun-crumbs.noprint a.nav[href^="/f"], #navstrip a.nav[href^="/f"], .pathname-box:first a.nav[href^="/f"], span.nav a.nav[href^="/f"]').attr('href');
            try {
                jQuery.get(oWereIam.oSubForum, function(data) {
                oWereIam.oTarget = jQuery('#stats > a, #info_open td[colspan="2"]:not(.catBottom) .gensmall a, #main-content > a[href^="/u"], .activeusers-box .row1 a', data);

                }).always(function() {
                    if (oWereIam.oTarget.length !== 0) {
                        var guest = Math.floor(Math.random() * (5 - 0));
                        jQuery('#topic_total_visit').text(guest);
                        searchActiveUsers(oWereIam.oTarget, 0, oWereIam.oTarget.length, 0, guest);
                    }
                });
            } catch (e) {
                // console.log(e);
            }
        }

        function searchActiveUsers(oTarget, start, len, index, guest) {
            if (index > 10) {
                return false
            }
            var oThis = jQuery(oTarget[index]),
                sHref = oThis.attr('href'),
                $JScript;

            if ((sHref !== undefined)) {
                var user_name = '<a href="' + sHref + '">' + oThis.html() + '</a>';

                jQuery.get(sHref, function(data) {
                    var Field_Text = jQuery('dt:contains("WhereIam")', data).closest('dl').find('div.field_uneditable').text();

                    try {
                        $JScript = JSON.parse(Field_Text.replace(/'/g, '"'));
                    } catch (e) {
                        // console.log(e);
                    }
                    console.log(Field_Text);
                }).always(function() {
                    try {
                        if ($JScript.path.url == oWereIam.pathname) {
                            if (oWereIam.total_users == 0) {
                                $('#topic_list_users').html('');
                                $('#topic_list_users').append(user_name);
                            } else {
                                $('#topic_list_users').append(', ' + user_name);
                            }
                            oWereIam.total_users++;
                            $('#topic_total_users').text(oWereIam.total_users + guest);
                            $('#topic_total_members').text(oWereIam.total_users);
                        }
                    } catch (e) {
                        // console.log(e);
                    }
                    index++;
                    try {
                        searchActiveUsers(oTarget, start, len, index, guest);
                    } catch (e) {
                        // console.log(e);
                    }
                });
            }
        }
    });

    function WhereIam() {
        jQuery.ajaxSetup({
            async: false
        });
        jQuery.get('/profile?mode=editprofile', function(data) {
            var found = 1;
          var Profile_Field_ID = jQuery('label:contains("WhereIam"), span:contains("WhereIam"), dt:contains("WhereIam")', data).closest('dl, tr').find('textarea').attr('id');

            console.log("Profile_Field_ID: " + Profile_Field_ID);

            if ((Profile_Field_ID == undefined) && (SUPERMOD == 1)) {
                jQuery.post("/admin/index.forum?part=users_groups&sub=users&mode=avatar_profil2&extended_admin=1&tid=" + TID, { /* <- Parameters! */
                    /* Post action */
                    action: ACTION,
                    id: 0,
                    type: 0,
                    action: 'configuration_final',
                    list_type_field: 2,
                    field_name: 'WhereIam',
                    field_desc: 'Where I am? - Made and Optimizations by JScript - 2013/07/12, 2014/10/13',
                    field_oblig: 0,
                    field_display_profil: 1,
                    list_field_type_view: 0,
                    list_auth_field_modo: 1,
                    list_auth_field_himself: 1,
                    list_field_view: -1,
                    list_separator: 0,
                    field_type_2_lng_max: 15000,
                    submit: 1,
                    field_type_11_max_before: 14,
                    field_type_11_max_after: 6
                }).done(function() {
                    console.log('Add profile field done!');
                    jQuery.get('/profile?mode=editprofile', function(data) {
                        Profile_Field_ID = jQuery('label:contains("WhereIam"), span:contains("WhereIam"), dt:contains("WhereIam")', data).closest('dl, tr').find('textarea').attr('id');
                    }).fail(function() {
                        console.log('Failed to get field Profile_Field_ID!');
                        found = 0;
                    });
                }).fail(function() {
                    console.log('Add profile field Fail!');
                    found = 0;
                });
            }
            if (found) {
                var sTitle = jQuery('.pun-crumbs:first p strong:last').text();
                if ((sTitle == 'undefined') || (sTitle == '')) sTitle = location.pathname;

                var now = new Date;
                var $JScript = {
                    appInfo: {
                        module: 'Where I am?',
                        description: 'Shows the exact location where the user is currently.',
                        author: 'JScript',
                        version: '1.00',
                        release: '2014/10/13'
                    },
                    userInfo: {
                        oscpu: navigator.oscpu,
                        appName: navigator.appName,
                        language: navigator.language,
                        userAgent: navigator.userAgent
                    },
                    path: {
                        title: sTitle,
                        url: location.pathname,
                        param: location.search,
                        state: '0',
                        time: now.getHours() + ":" + now.getMinutes(),
                        date: now.getDate() + "/" + now.getMonth() + "/" + now.getFullYear()
                    }
                };

                jQuery.post("/ajax_profile.forum?jsoncallback=?", {
                    id: Profile_Field_ID.substring(16, Profile_Field_ID.length),
                    user: USER_ID,
                    active: "1",
                    content: '[["' + Profile_Field_ID + '", "' + JSON.stringify($JScript).replace(/"/g, "'") + '"]]',
                    tid: TID
                }, function(data) {
                    console.log("OK: ajax_profile, userID = " + USER_ID);
                }, "json").fail(function() {
                    console.log("error: ajax_profile, userID = " + USER_ID);
                });
            }
        }).done(function() {
            // Done!!!
        }).fail(function() {
            console.log('Failed to get field Profile_Field_ID');
        });
        jQuery.ajaxSetup({
            async: true
        });
    }// TERMINA AQUI
        }
    });
Substitua pelo que é dado no tutorial e salve.

Até mais!
Shek

Shek
Principal Contribuidor
Principal Contribuidor

Membro desde : 11/04/2009
Mensagens : 18896
Pontos : 22793

https://shiftactive.blogspot.com/ https://www.facebook.com/ShiftActif https://twitter.com/ShiftActif

Ir para o topo Ir para baixo

Tópico resolvido Re: Quem está lendo este tópico?

Mensagem por ellipsis 18.12.14 22:19

Obrigada Sheck. Já fiz o teste e só aparece à moderação.
Mas ao fazer este teste reparei ele não indica o numero de pessoas.
No tópico em questão estava eu mais dois usuarios que tenho para testes. E no meu não mencionava que havia usuários lendo o tópico, ou seja estava sempre a zero.
ellipsis

ellipsis
****

Membro desde : 28/09/2011
Mensagens : 381
Pontos : 530

http://testemunhasdejeova.forumeiros.com.pt/

Ir para o topo Ir para baixo

Tópico resolvido Re: Quem está lendo este tópico?

Mensagem por JScript 19.12.14 0:48

@ellipsis
Olá!

Substitua pelo código abaixo:
Código:

/**
 * @CP_AddOn Addons for the Forumotion control panel
 * @copyright Copyright (C) 2014 JScript
 * @license http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
 * @engine 1.0b
 * @notes If your forum does not have the "CP_AddOn" module, you can manually change the variables values!

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<mod>
   <header>
      <id>WhereIam</id>
      <title>Where I am?, Topic Active Users (Who is read this topic?)!</title>
      <version>1.10302014</version>
      <description>Shows the exact location where the user is currently!</description>
      <author>JScript</author>
      <author-notes>First Release (Beta tester only)!</author-notes>
      <license>GNU General Public License v2</license>
      <mod-version>1.0.0.9</mod-version>
   </header>
   <configuration>
      <level>Easy</level>
      <time>1 minute</time>
      <target-version>1.0b</target-version>
      <action type="input">
         <text>Texto para usuários:</text>
         <variable>topic_total_users</variable>
      </action>
      <action type="input">
         <text>Texto para membros:</text>
         <variable>topic_total_members</variable>
      </action>
      <action type="input">
         <text>Texto para visitantes:</text>
         <variable>topic_total_visit</variable>
      </action>
      <action type="input">
         <text>Texto para anônimos:</text>
         <variable>topic_total_anoni</variable>
      </action>
      <action type="input">
         <text>Texto de localização:</text>
         <variable>find_user_location</variable>
      </action>
      <action type="input">
         <text>Tem portal? (1=sim, 0=não!):</text>
         <variable>has_portal</variable>
      </action>
   </configuration>
</mod>
*/
// User variables **************************************************************************************
// #### If your forum does not have the "CP_AddOn" module, you can manually change the values. ####
topic_total_users = 'usuário(s) está(ão) lendo este tópico';
topic_total_members = 'membro(s)';
topic_total_visit = 'visitante(s) e';
topic_total_anoni = 'membros anônimo(s)';
find_user_location = 'Obtendo a localização, aguarde...';
has_portal = 1; // #### If your forum does not have a "Portal", change the value to 0! ####
// ******************************************************************************************************

// System variables!
USERNAME = '';
USER_ID = 0;
//USERAVATAR = '';
SUPERMOD = 0;
TID = 0;
ACTION = 'add_field'; // 'configuration';
//
jQuery(function() {
    if (location.pathname.indexOf('/u') !== -1) {
        jQuery('dt:contains("WhereIam")').closest('dl').remove();
    } else if (location.pathname.indexOf('editprofile' !== -1)) {
      jQuery('label:contains("WhereIam"), span:contains("WhereIam"), dt:contains("WhereIam")').closest('dl, tr').remove();
    }
    if (_userdata.session_logged_in) {
        USERNAME = _userdata.username;
        USER_ID = _userdata.user_id;
        // USERAVATAR = jQuery(_userdata.avatar).attr('src');
        SUPERMOD = _userdata.user_level; // Is Admin/Mod ?
        TID = jQuery('a[href*="tid="]').attr('href').split('tid=')[1].split('&')[0]; //Get the var {TID}
    }
    // console.clear();
    console.log("/**************************************************************************");
    console.log("* Module: 'Where I am?' and 'Topic Active Users (Who is read this topic?)'!");
    console.log("* Description: Shows the exact location where the user is currently.");
    console.log("* Author: Made and Optimizations by JScript - 2013/07/12, 2014/10/13");
    console.log("* Version: Beta tester only!");
    console.log("/**************************************************************************");
    console.log('USERNAME: ' + USERNAME);
    console.log("USER_ID: " + USER_ID);
    console.log("TID: " + TID);

    var oWereIam = {
        pathname: location.pathname,
        total_users: 0,
        oSubForum: '',
        oTarget: 0,
      sIndex: '/forum',
        oHtml: {
         phpbb2: '<!-- ACTIVE USERS -->' +
            '<tr>' +
            '    <td colspan="2" style="margin:0; padding: 0;">' +
            '        <table width="100%" cellspacing="0" cellpadding="0" border="0">' +
            '            <tbody>' +
            '                <tr>' +
            '                    <td id="user-stats" class="gensmall" width="75%" valign="top" style="padding: 0px 10px 0.6em;">' +
            '                    </td>' +
            '                </tr>' +
            '            </tbody>' +
            '        </table>' +
            '    </td>' +
            '</tr>',
         phpbb3: '#### Has a very bad structure that becomes hard to define the html! ####',
            punbb: '<!-- ACTIVE USERS -->' +
                '<div class="main" id="active_users">' +
                '   <div class="main-content">' +
                '      <div id="user-stats"  style="padding: 0.6em 1em;">' +
                '      </div>' +
                '   </div>' +
                '</div>',
         invision: '<!-- ACTIVE USERS -->' +
            '<div class="borderwrap" id="active_users" style="margin-bottom: 5px;">' +
            '    <div class="bar clearfix">' +
            '        <div class="left rtl-inversion-left" id="user-stats">' +
            '        </div>' +
            '    </div>' +
            '</div>',
         content: '<!-- CONTENT -->' +
                '<h4><strong><span id="topic_total_users">0</span> ' + topic_total_users + '</strong></h4>' +
                '<p class="statistics_brief desc">' +
                '   <span id="topic_total_members">0</span> ' + topic_total_members + ', ' +
                '   <span id="topic_total_visit">0</span> ' + topic_total_visit + ' ' +
                '   <span id="topic_total_anoni">0</span> ' + topic_total_anoni +
                '</p><br>' +
                '<ul id="topic_list_users" class="ipsList_inline" style="padding-left: 0px ! important;"></ul>'
        }
    };

    if (_userdata.session_logged_in) {
        WhereIam() // Where I am?
    }
   /* Apenas visiveis para os administradores e moderadores?
   http://ajuda.forumeiros.com/t96909-quem-esta-lendo-este-topico#663591 */
   if (_userdata.user_level == 0) {
      return false;
   }
   
    if (oWereIam.pathname.indexOf('/t') !== -1) {
      /* Forum versions! */
      var phpBB2 = jQuery('#content-container table.forumline:last tbody > tr:eq(1)');
      var phpBB3 = jQuery('#main-content > div.h3:last');
      var punbb = jQuery('#pun-info');
      var invision = jQuery('#main-content .borderwrap:last');

      if (phpBB2.length) {
         jQuery(oWereIam.oHtml.phpbb2).insertBefore(phpBB2);
      } else if(phpBB3.length) {
         jQuery(oWereIam.oHtml.punbb).insertBefore(phpBB3);
      } else if(punbb.length) {
         jQuery(oWereIam.oHtml.punbb).insertBefore(punbb);
      } else if(invision.length) {
         jQuery(oWereIam.oHtml.invision).insertBefore(invision);
      };
      jQuery('#user-stats').html(oWereIam.oHtml.content);

      if (!has_portal) oWereIam.sIndex = '/';

        oWereIam.oSubForum = jQuery('.pun-crumbs.noprint a.nav[href^="/f"], #navstrip a.nav[href^="/f"], .pathname-box:first a.nav[href^="/f"], span.nav a.nav[href^="/f"]').attr('href');
        try {
            jQuery.get(oWereIam.oSubForum, function(data) {
            oWereIam.oTarget = jQuery('#stats > a, #info_open td[colspan="2"]:not(.catBottom) .gensmall a, #main-content > a[href^="/u"], .activeusers-box .row1 a', data);

            }).always(function() {
                if (oWereIam.oTarget.length !== 0) {
                    var guest = Math.floor(Math.random() * (5 - 0));
                    jQuery('#topic_total_visit').text(guest);
                    searchActiveUsers(oWereIam.oTarget, 0, oWereIam.oTarget.length, 0, guest);
                }/* else {
                    jQuery.get(oWereIam.sIndex, function(data) {
                        var oOnlineList = /(?:\b<br>([\s\S]*?)<br>)/
                            .exec(
                                jQuery('#onlinelist > p:not(.right)', data).html()
                            )[1];
                        var memDiv = jQuery('<div>').html(oOnlineList);

                        oWereIam.oTarget = memDiv.find('a');
                    }).always(function() {
                        if (oWereIam.oTarget.length !== 0) {
                            var guest = Math.floor(Math.random() * (5 - 0));
                            jQuery('#topic_total_visit').text(guest);
                            searchActiveUsers(oWereIam.oTarget, 0, oWereIam.oTarget.length, 0, guest);
                        }
                    });
                }*/
            });
        } catch (e) {
            /*jQuery.get(oWereIam.sIndex, function(data) {
                var oOnlineList = /(?:\b<br>([\s\S]*?)<br>)/
                    .exec(
                        jQuery('#onlinelist > p:not(.right)', data).html()
                    )[1];
                var memDiv = jQuery('<div>').html(oOnlineList);

                oWereIam.oTarget = memDiv.find('a');
            }).always(function() {
                if (oWereIam.oTarget.length !== 0) {
                    var guest = Math.floor(Math.random() * (5 - 0));
                    jQuery('#topic_total_visit').text(guest);
                    searchActiveUsers(oWereIam.oTarget, 0, oWereIam.oTarget.length, 0, guest);
                }
            });*/
        }
    }

    function searchActiveUsers(oTarget, start, len, index, guest) {
        if (index > 10) {
            return false
        }
        var oThis = jQuery(oTarget[index]),
            sHref = oThis.attr('href'),
            $JScript;

        if ((sHref !== undefined)) {
            var user_name = '<a href="' + sHref + '">' + oThis.html() + '</a>';

            jQuery.get(sHref, function(data) {
                var Field_Text = jQuery('dt:contains("WhereIam")', data).closest('dl').find('div.field_uneditable').text();

                try {
                    $JScript = JSON.parse(Field_Text.replace(/'/g, '"'));
                } catch (e) {
                    // console.log(e);
                }
                console.log(Field_Text);
            }).always(function() {
                try {
                    if ($JScript.path.url == oWereIam.pathname) {
                        if (oWereIam.total_users == 0) {
                            $('#topic_list_users').html('');
                            $('#topic_list_users').append(user_name);
                        } else {
                            $('#topic_list_users').append(', ' + user_name);
                        }
                        oWereIam.total_users++;
                        $('#topic_total_users').text(oWereIam.total_users + guest);
                        $('#topic_total_members').text(oWereIam.total_users);
                    }
                } catch (e) {
                    // console.log(e);
                }
                index++;
                try {
                    searchActiveUsers(oTarget, start, len, index, guest);
                } catch (e) {
                    // console.log(e);
                }
            });
        }
    }
});

function WhereIam() {
    jQuery.ajaxSetup({
        async: false
    });
    jQuery.get('/profile?mode=editprofile', function(data) {
        var found = 1;
      var Profile_Field_ID = jQuery('label:contains("WhereIam"), span:contains("WhereIam"), dt:contains("WhereIam")', data).closest('dl, tr').find('textarea').attr('id');

        console.log("Profile_Field_ID: " + Profile_Field_ID);

        if ((Profile_Field_ID == undefined) && (SUPERMOD == 1)) {
            jQuery.post("/admin/index.forum?part=users_groups&sub=users&mode=avatar_profil2&extended_admin=1&tid=" + TID, { /* <- Parameters! */
                /* Post action */
                action: ACTION,
                id: 0,
                type: 0,
                action: 'configuration_final',
                list_type_field: 2,
                field_name: 'WhereIam',
                field_desc: 'Where I am? - Made and Optimizations by JScript - 2013/07/12, 2014/10/13',
                field_oblig: 0,
                field_display_profil: 1,
                list_field_type_view: 0,
                list_auth_field_modo: 1,
                list_auth_field_himself: 1,
                list_field_view: -1,
                list_separator: 0,
                field_type_2_lng_max: 15000,
                submit: 1,
                field_type_11_max_before: 14,
                field_type_11_max_after: 6
            }).done(function() {
                console.log('Add profile field done!');
                jQuery.get('/profile?mode=editprofile', function(data) {
                    Profile_Field_ID = jQuery('label:contains("WhereIam"), span:contains("WhereIam"), dt:contains("WhereIam")', data).closest('dl, tr').find('textarea').attr('id');
                }).fail(function() {
                    console.log('Failed to get field Profile_Field_ID!');
                    found = 0;
                });
            }).fail(function() {
                console.log('Add profile field Fail!');
                found = 0;
            });
        }
        if (found) {
            var sTitle = jQuery('.pun-crumbs:first p strong:last').text();
            if ((sTitle == 'undefined') || (sTitle == '')) sTitle = location.pathname;

            var now = new Date;
            var $JScript = {
                appInfo: {
                    module: 'Where I am?',
                    description: 'Shows the exact location where the user is currently.',
                    author: 'JScript',
                    version: '1.00',
                    release: '2014/10/13'
                },
                userInfo: {
                    oscpu: navigator.oscpu,
                    appName: navigator.appName,
                    language: navigator.language,
                    userAgent: navigator.userAgent
                },
                path: {
                    title: sTitle,
                    url: location.pathname,
                    param: location.search,
                    state: '0',
                    time: now.getHours() + ":" + now.getMinutes(),
                    date: now.getDate() + "/" + now.getMonth() + "/" + now.getFullYear()
                }
            };

            jQuery.post("/ajax_profile.forum?jsoncallback=?", {
                id: Profile_Field_ID.substring(16, Profile_Field_ID.length),
                user: USER_ID,
                active: "1",
                content: '[["' + Profile_Field_ID + '", "' + JSON.stringify($JScript).replace(/"/g, "'") + '"]]',
                tid: TID
            }, function(data) {
                console.log("OK: ajax_profile, userID = " + USER_ID);
            }, "json").fail(function() {
                console.log("error: ajax_profile, userID = " + USER_ID);
            });
        }
    }).done(function() {
        // Done!!!
    }).fail(function() {
        console.log('Failed to get field Profile_Field_ID');
    });
    jQuery.ajaxSetup({
        async: true
    });
}

JS
JScript

JScript
Super Membro

Membro desde : 15/03/2013
Mensagens : 1449
Pontos : 1901

http://jscript.forumeiros.com/

Ir para o topo Ir para baixo

Tópico resolvido Re: Quem está lendo este tópico?

Mensagem por ellipsis 19.12.14 20:24

Olá @JScrip,

Apliquei o seu código e fiz o teste. Estando eu mais dois usuarios no mesmo tópico, a aplicação me informava que estavam 0 usuários, membros, visitantes ou membros anónimos.
ellipsis

ellipsis
****

Membro desde : 28/09/2011
Mensagens : 381
Pontos : 530

http://testemunhasdejeova.forumeiros.com.pt/

Ir para o topo Ir para baixo

Tópico resolvido Re: Quem está lendo este tópico?

Mensagem por JScript 19.12.14 22:35

@ellipsis

Vou tentar explicar:

Quando se está em um (sub)fórum, por exemplo https://ajuda.forumeiros.com/f70-questoes-sobre-javascript-jquery , uma lista é atualizada pelo servidor da Forumeiros como mostra a figura abaixo:
topico - Quem está lendo este tópico?  EcKb0wA
Essa lista é preenchida quando se está no (sub)fórum ou em tópicos dentro do (sub)fórum!
Porém essa lista nem sempre é atualizada no momento exato que estamos, uma atualização de página já faz com que apareça nosso nick nela.

Perceba que no momento do "print" somente eu estava na lista, mas há ocasiões como eu expliquei acima em que mesmo estando em um (sub)fórum ou em um tópico, a lista nem sempre é atualizada no mesmo momento, algumas vezes é preciso uma atualização da página...

Então o meu código se baseia nesta lista para obter os nicks de cada membro e com isso poder "ler" os dados armazenados no campo WereIam do perfil, que é gravado a cada momento em que se acessa um link do fórum ou mudança de página (que dá no mesmo!).

Então duas coisas afetam a informação da localização do membro, no caso a gravação no perfil:
1- Se a lista que mostrei na imagem acima falhar, nem sempre, mas falha, a sua localização será gravada, mas como seu nick não está na lista, não poderei ler seu perfil para obter os dados
2- Se você abrir mais de uma página, significa se a gravação da sua localização será sempre a última página que você visitou/abriu em uma nova aba!
Em outras palavras: se está no index (índice), sua localização será essa, mas se manter essa página aberta e abrir outra em uma nova aba ou janela, sua localização será desta nova página!!!

Em resumo: Não é falha do código, nem tão pouco da lista, ela apenas não foi atualizada a tempo!

Veja um exemplo (meu fórum de testes):
topico - Quem está lendo este tópico?  DAaolmG

Outro detalhe importante: Se você entrar em um tópico e no momento não tiver ninguém nele, então só irá aparecer seu nick, mas se eu entrar neste mesmo tópico, aparecerá para mim o meu nick e o seu, porém para você enquanto não atualizar a página, só ficará o seu nick!!!

Espero que entenda,

JS
JScript

JScript
Super Membro

Membro desde : 15/03/2013
Mensagens : 1449
Pontos : 1901

http://jscript.forumeiros.com/

Ir para o topo Ir para baixo

Tópico resolvido Re: Quem está lendo este tópico?

Mensagem por ellipsis 20.12.14 18:14

JScript, seria injusto com você se dissesse que compreendia tudo aquilo que escreveu. Mas eu não entendo nada desta linguagem informática.

Eu me limito a seguir os tutoriais. E quando algo não está bem peço ajuda.

Mas continuo a achar que algo não está bem. Pelo menos a ferramenta devia de informar que eu estou no tópico. Mas não informa nada...

A ferramenta está lá, mas, ... é obsoleta.

topico - Quem está lendo este tópico?  2utk9vq

ellipsis

ellipsis
****

Membro desde : 28/09/2011
Mensagens : 381
Pontos : 530

http://testemunhasdejeova.forumeiros.com.pt/

Ir para o topo Ir para baixo

Tópico resolvido Re: Quem está lendo este tópico?

Mensagem por JScript 20.12.14 19:59

ellipsis escreveu:Pelo menos a ferramenta devia de informar que eu estou no tópico. Mas não informa nada...
Faça um teste simples: Vá neste link http://testemunhasdejeova.forumeiros.com.pt/f16-noticias e veja se seu nick aparece na parte debaixo da página como mostra a figura abaixo:
topico - Quem está lendo este tópico?  GSr4JHC

Observe que na imagem acima eu circulei a área onde deveria aparecer o(s) nick(s) de quem estiver online no sub fórum, porém isso é uma lista atualizada pela Forumeiros, não pelo meu código!

Se seu nick aparecer nesta lista, basta ir em algum tópico deste sub fórum e observe se seu nick irá aparecer com o meu código.

ellipsis escreveu:A ferramenta está lá, mas, ...  é obsoleta.
Então eu lamento, pois em meus testes e nos fóruns que sou cadastrado e que possuem esse meu código, está tudo funcionando perfeitamente!

Mas se não estiver satisfeito e achar que é uma "ferramenta obsoleta", é simples: Basta removê-la!

JS
JScript

JScript
Super Membro

Membro desde : 15/03/2013
Mensagens : 1449
Pontos : 1901

http://jscript.forumeiros.com/

Ir para o topo Ir para baixo

Tópico resolvido Re: Quem está lendo este tópico?

Mensagem por ellipsis 20.12.14 21:47

JScript escreveu:

ellipsis escreveu:A ferramenta está lá, mas, ...  é obsoleta.
Então eu lamento, pois em meus testes e nos fóruns que sou cadastrado e que possuem esse meu código, está tudo funcionando perfeitamente!

Mas se não estiver satisfeito e achar que é uma "ferramenta obsoleta", é simples: Basta removê-la!

JS

JS, compreenda que não estou dizendo o que disse de animo leve. Mas porque fico triste. Não sei se te lembras , mas quando começaste com esta ideia eu havia dito que iria ficar atento, pois esta ferramenta, me interessa muito.
Pois é muito útil como ferramenta para a minha moderação.

Voltando ao problema. Fiz o que me disse e reparei que em todos os sub-fóruns aparece o meu nick ou outro forista que esteja lá. Mas se eu entro no tópico o seu codigo continua a informar que não existe ninguém (zero) incluindo eu.... Chorando ou muito tr Chorando ou muito tr Chorando ou muito tr Chorando ou muito tr
ellipsis

ellipsis
****

Membro desde : 28/09/2011
Mensagens : 381
Pontos : 530

http://testemunhasdejeova.forumeiros.com.pt/

Ir para o topo Ir para baixo

Tópico resolvido Re: Quem está lendo este tópico?

Mensagem por Οto 20.12.14 22:46

Esse erro acontece em muitos fóruns.
O que achei estranho, foi que na BestSkins, onde você @jScript é administrador, o código funciona sempre perfeitamente e sem nenhuma falha.
So nos outros é se as vezes acontece esse erro.

Deve ser por ser administrador e reforçar melhor lá o código.
Οto

Οto
Novo Membro

Membro desde : 21/11/2014
Mensagens : 18
Pontos : 33

https://ajuda.forumeiros.com/

Ir para o topo Ir para baixo

Tópico resolvido Re: Quem está lendo este tópico?

Mensagem por JScript 20.12.14 23:11

@ellipsis
Ok, então faça o seguinte: Crie uma conta temporária no grupo moderador, pois você pediu que o código só ficasse visível à staff, e poste usuário e senha para que eu possa logar lá e ver o que está acontecendo.

@Οto
Ai é que você se engana pois não é pelo fato de que sou adm lá que o código vai ter um funcionamento melhor!!!

Edit:
@ellipsis

Eu acabei de perceber que o seu template dos tópicos está modificado e com isso o meu código que foi projetado para templates que seguem o modelo padrão, podendo ou não serem modificados, mas tem que seguir o modelo HTML padrão, o que não é o caso do seu fórum, por isso meu código não funcionou como deveria!

Faça o seguinte, procure no meu código a seguinte linha:
Código:
oWereIam.oSubForum = jQuery('.pun-crumbs.noprint a.nav[href^="/f"], #navstrip a.nav[href^="/f"], .pathname-box:first a.nav[href^="/f"], span.nav a.nav[href^="/f"]').attr('href');

E troque por esta:
Código:
oWereIam.oSubForum = jQuery('.pun-crumbs.noprint a.nav[href^="/f"]:last, #navstrip a.nav[href^="/f"], .pathname-box:first a.nav[href^="/f"]:last, span.nav a.nav[href^="/f"]:last').attr('href');

Faça um teste ok?

JS


Última edição por JScript em 20.12.14 23:29, editado 1 vez(es) (Motivo da edição : Novas informações...)
JScript

JScript
Super Membro

Membro desde : 15/03/2013
Mensagens : 1449
Pontos : 1901

http://jscript.forumeiros.com/

Ir para o topo Ir para baixo

Tópico resolvido Re: Quem está lendo este tópico?

Mensagem por Οto 20.12.14 23:50

@jScript , peço desculpa por afirmar algo errado.... Triste
Οto

Οto
Novo Membro

Membro desde : 21/11/2014
Mensagens : 18
Pontos : 33

https://ajuda.forumeiros.com/

Ir para o topo Ir para baixo

Tópico resolvido Re: Quem está lendo este tópico?

Mensagem por JScript 21.12.14 0:40

Οto escreveu:@jScript , peço desculpa por afirmar algo errado.... Triste
Sem problemas!
Só para finalizar: Os templates na BestSkins são modificados, mas seguem o padrão do HTML, por isso meu código funciona lá. Como eu já afirmei, o código foi projetado para o HTML padrão da Forumeiros, mas existem inúmeras skins por ai que não seguem o padrão ou o usuário modificou manualmente e com isso, não só o meu, mas vários códigos não funcionam!

Vamos aguardar o @ellipsis responder essa mensagem: https://ajuda.forumeiros.com/t96909-quem-esta-lendo-este-topico#663798

JS
JScript

JScript
Super Membro

Membro desde : 15/03/2013
Mensagens : 1449
Pontos : 1901

http://jscript.forumeiros.com/

Ir para o topo Ir para baixo

Tópico resolvido Re: Quem está lendo este tópico?

Mensagem por ellipsis 21.12.14 21:19

@JScrip agora sim está funcionando.

Troquei o código que disse e a ferramenta agora está bombar correctamente.

Só queria pedir uma coisa. No meu fórum não há entrada para anónimos. Por isso não faz sentido ter lá a contagem para os anónimos.

Podias-me dizer qual parte do código tenho que tirar para que os anónimos saiam.

Desde já obrigado
ellipsis

ellipsis
****

Membro desde : 28/09/2011
Mensagens : 381
Pontos : 530

http://testemunhasdejeova.forumeiros.com.pt/

Ir para o topo Ir para baixo

Tópico resolvido Re: Quem está lendo este tópico?

Mensagem por Οto 21.12.14 21:31

Acho que é só trocar o seu código javaScript por este:
Código:
/**
 * @CP_AddOn Addons for the Forumotion control panel
 * @copyright Copyright (C) 2014 JScript
 * @license http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
 * @engine 1.0b
 * @notes If your forum does not have the "CP_AddOn" module, you can manually change the variables values!

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<mod>
   <header>
      <id>WhereIam</id>
      <title>Where I am?, Topic Active Users (Who is read this topic?)!</title>
      <version>1.10302014</version>
      <description>Shows the exact location where the user is currently!</description>
      <author>JScript</author>
      <author-notes>First Release (Beta tester only)!</author-notes>
      <license>GNU General Public License v2</license>
      <mod-version>1.0.0.9</mod-version>
   </header>
   <configuration>
      <level>Easy</level>
      <time>1 minute</time>
      <target-version>1.0b</target-version>
      <action type="input">
         <text>Texto para usuários:</text>
         <variable>topic_total_users</variable>
      </action>
      <action type="input">
         <text>Texto para membros:</text>
         <variable>topic_total_members</variable>
      </action>
      <action type="input">
         <text>Texto para visitantes:</text>
         <variable>topic_total_visit</variable>
      </action>
      <action type="input">
         <text>Texto de localização:</text>
         <variable>find_user_location</variable>
      </action>
      <action type="input">
         <text>Tem portal? (1=sim, 0=não!):</text>
         <variable>has_portal</variable>
      </action>
   </configuration>
</mod>
*/
// User variables **************************************************************************************
// #### If your forum does not have the "CP_AddOn" module, you can manually change the values. ####
topic_total_users = 'usuário(s) está(ão) lendo este tópico';
topic_total_members = 'membro(s)';
topic_total_visit = 'visitante(s) e';
find_user_location = 'Obtendo a localização, aguarde...';
has_portal = 1; // #### If your forum does not have a "Portal", change the value to 0! ####
// ******************************************************************************************************

// System variables!
USERNAME = '';
USER_ID = 0;
//USERAVATAR = '';
SUPERMOD = 0;
TID = 0;
ACTION = 'add_field'; // 'configuration';
//
jQuery(function() {
    if (location.pathname.indexOf('/u') !== -1) {
        jQuery('dt:contains("WhereIam")').closest('dl').remove();
    } else if (location.pathname.indexOf('editprofile' !== -1)) {
      jQuery('label:contains("WhereIam"), span:contains("WhereIam"), dt:contains("WhereIam")').closest('dl, tr').remove();
    }
    if (_userdata.session_logged_in) {
        USERNAME = _userdata.username;
        USER_ID = _userdata.user_id;
        // USERAVATAR = jQuery(_userdata.avatar).attr('src');
        SUPERMOD = _userdata.user_level; // Is Admin/Mod ?
        TID = jQuery('a[href*="tid="]').attr('href').split('tid=')[1].split('&')[0]; //Get the var {TID}
    }
    // console.clear();
    console.log("/**************************************************************************");
    console.log("* Module: 'Where I am?' and 'Topic Active Users (Who is read this topic?)'!");
    console.log("* Description: Shows the exact location where the user is currently.");
    console.log("* Author: Made and Optimizations by JScript - 2013/07/12, 2014/10/13");
    console.log("* Version: Beta tester only!");
    console.log("/**************************************************************************");
    console.log('USERNAME: ' + USERNAME);
    console.log("USER_ID: " + USER_ID);
    console.log("TID: " + TID);

    var oWereIam = {
        pathname: location.pathname,
        total_users: 0,
        oSubForum: '',
        oTarget: 0,
      sIndex: '/forum',
        oHtml: {
         phpbb2: '<!-- ACTIVE USERS -->' +
            '<tr>' +
            '    <td colspan="2" style="margin:0; padding: 0;">' +
            '        <table width="100%" cellspacing="0" cellpadding="0" border="0">' +
            '            <tbody>' +
            '                <tr>' +
            '                    <td id="user-stats" class="gensmall" width="75%" valign="top" style="padding: 0px 10px 0.6em;">' +
            '                    </td>' +
            '                </tr>' +
            '            </tbody>' +
            '        </table>' +
            '    </td>' +
            '</tr>',
         phpbb3: '#### Has a very bad structure that becomes hard to define the html! ####',
            punbb: '<!-- ACTIVE USERS -->' +
                '<div class="main" id="active_users">' +
                '   <div class="main-content">' +
                '      <div id="user-stats"  style="padding: 0.6em 1em;">' +
                '      </div>' +
                '   </div>' +
                '</div>',
         invision: '<!-- ACTIVE USERS -->' +
            '<div class="borderwrap" id="active_users" style="margin-bottom: 5px;">' +
            '    <div class="bar clearfix">' +
            '        <div class="left rtl-inversion-left" id="user-stats">' +
            '        </div>' +
            '    </div>' +
            '</div>',
         content: '<!-- CONTENT -->' +
                '<h4><strong><span id="topic_total_users">0</span> ' + topic_total_users + '</strong></h4>' +
                '<p class="statistics_brief desc">' +
                '   <span id="topic_total_members">0</span> ' + topic_total_members + ', ' +
                '   <span id="topic_total_visit">0</span> ' + topic_total_visit + ' ' +
                '</p><br>' +
                '<ul id="topic_list_users" class="ipsList_inline" style="padding-left: 0px ! important;"></ul>'
        }
    };

    if (_userdata.session_logged_in) {
        WhereIam() // Where I am?
    }
   /* Apenas visiveis para os administradores e moderadores?
   http://ajuda.forumeiros.com/t96909-quem-esta-lendo-este-topico#663591 */
   if (_userdata.user_level == 0) {
      return false;
   }
  
    if (oWereIam.pathname.indexOf('/t') !== -1) {
      /* Forum versions! */
      var phpBB2 = jQuery('#content-container table.forumline:last tbody > tr:eq(1)');
      var phpBB3 = jQuery('#main-content > div.h3:last');
      var punbb = jQuery('#pun-info');
      var invision = jQuery('#main-content .borderwrap:last');

      if (phpBB2.length) {
         jQuery(oWereIam.oHtml.phpbb2).insertBefore(phpBB2);
      } else if(phpBB3.length) {
         jQuery(oWereIam.oHtml.punbb).insertBefore(phpBB3);
      } else if(punbb.length) {
         jQuery(oWereIam.oHtml.punbb).insertBefore(punbb);
      } else if(invision.length) {
         jQuery(oWereIam.oHtml.invision).insertBefore(invision);
      };
      jQuery('#user-stats').html(oWereIam.oHtml.content);

      if (!has_portal) oWereIam.sIndex = '/';

        oWereIam.oSubForum = jQuery('.pun-crumbs.noprint a.nav[href^="/f"]:last, #navstrip a.nav[href^="/f"], .pathname-box:first a.nav[href^="/f"]:last, span.nav a.nav[href^="/f"]:last').attr('href');
        try {
            jQuery.get(oWereIam.oSubForum, function(data) {
            oWereIam.oTarget = jQuery('#stats > a, #info_open td[colspan="2"]:not(.catBottom) .gensmall a, #main-content > a[href^="/u"], .activeusers-box .row1 a', data);

            }).always(function() {
                if (oWereIam.oTarget.length !== 0) {
                    var guest = Math.floor(Math.random() * (5 - 0));
                    jQuery('#topic_total_visit').text(guest);
                    searchActiveUsers(oWereIam.oTarget, 0, oWereIam.oTarget.length, 0, guest);
                }/* else {
                    jQuery.get(oWereIam.sIndex, function(data) {
                        var oOnlineList = /(?:\b<br>([\s\S]*?)<br>)/
                            .exec(
                                jQuery('#onlinelist > p:not(.right)', data).html()
                            )[1];
                        var memDiv = jQuery('<div>').html(oOnlineList);

                        oWereIam.oTarget = memDiv.find('a');
                    }).always(function() {
                        if (oWereIam.oTarget.length !== 0) {
                            var guest = Math.floor(Math.random() * (5 - 0));
                            jQuery('#topic_total_visit').text(guest);
                            searchActiveUsers(oWereIam.oTarget, 0, oWereIam.oTarget.length, 0, guest);
                        }
                    });
                }*/
            });
        } catch (e) {
            /*jQuery.get(oWereIam.sIndex, function(data) {
                var oOnlineList = /(?:\b<br>([\s\S]*?)<br>)/
                    .exec(
                        jQuery('#onlinelist > p:not(.right)', data).html()
                    )[1];
                var memDiv = jQuery('<div>').html(oOnlineList);

                oWereIam.oTarget = memDiv.find('a');
            }).always(function() {
                if (oWereIam.oTarget.length !== 0) {
                    var guest = Math.floor(Math.random() * (5 - 0));
                    jQuery('#topic_total_visit').text(guest);
                    searchActiveUsers(oWereIam.oTarget, 0, oWereIam.oTarget.length, 0, guest);
                }
            });*/
        }
    }

    function searchActiveUsers(oTarget, start, len, index, guest) {
        if (index > 10) {
            return false
        }
        var oThis = jQuery(oTarget[index]),
            sHref = oThis.attr('href'),
            $JScript;

        if ((sHref !== undefined)) {
            var user_name = '<a href="' + sHref + '">' + oThis.html() + '</a>';

            jQuery.get(sHref, function(data) {
                var Field_Text = jQuery('dt:contains("WhereIam")', data).closest('dl').find('div.field_uneditable').text();

                try {
                    $JScript = JSON.parse(Field_Text.replace(/'/g, '"'));
                } catch (e) {
                    // console.log(e);
                }
                console.log(Field_Text);
            }).always(function() {
                try {
                    if ($JScript.path.url == oWereIam.pathname) {
                        if (oWereIam.total_users == 0) {
                            $('#topic_list_users').html('');
                            $('#topic_list_users').append(user_name);
                        } else {
                            $('#topic_list_users').append(', ' + user_name);
                        }
                        oWereIam.total_users++;
                        $('#topic_total_users').text(oWereIam.total_users + guest);
                        $('#topic_total_members').text(oWereIam.total_users);
                    }
                } catch (e) {
                    // console.log(e);
                }
                index++;
                try {
                    searchActiveUsers(oTarget, start, len, index, guest);
                } catch (e) {
                    // console.log(e);
                }
            });
        }
    }
});

function WhereIam() {
    jQuery.ajaxSetup({
        async: false
    });
    jQuery.get('/profile?mode=editprofile', function(data) {
        var found = 1;
      var Profile_Field_ID = jQuery('label:contains("WhereIam"), span:contains("WhereIam"), dt:contains("WhereIam")', data).closest('dl, tr').find('textarea').attr('id');

        console.log("Profile_Field_ID: " + Profile_Field_ID);

        if ((Profile_Field_ID == undefined) && (SUPERMOD == 1)) {
            jQuery.post("/admin/index.forum?part=users_groups&sub=users&mode=avatar_profil2&extended_admin=1&tid=" + TID, { /* <- Parameters! */
                /* Post action */
                action: ACTION,
                id: 0,
                type: 0,
                action: 'configuration_final',
                list_type_field: 2,
                field_name: 'WhereIam',
                field_desc: 'Where I am? - Made and Optimizations by JScript - 2013/07/12, 2014/10/13',
                field_oblig: 0,
                field_display_profil: 1,
                list_field_type_view: 0,
                list_auth_field_modo: 1,
                list_auth_field_himself: 1,
                list_field_view: -1,
                list_separator: 0,
                field_type_2_lng_max: 15000,
                submit: 1,
                field_type_11_max_before: 14,
                field_type_11_max_after: 6
            }).done(function() {
                console.log('Add profile field done!');
                jQuery.get('/profile?mode=editprofile', function(data) {
                    Profile_Field_ID = jQuery('label:contains("WhereIam"), span:contains("WhereIam"), dt:contains("WhereIam")', data).closest('dl, tr').find('textarea').attr('id');
                }).fail(function() {
                    console.log('Failed to get field Profile_Field_ID!');
                    found = 0;
                });
            }).fail(function() {
                console.log('Add profile field Fail!');
                found = 0;
            });
        }
        if (found) {
            var sTitle = jQuery('.pun-crumbs:first p strong:last').text();
            if ((sTitle == 'undefined') || (sTitle == '')) sTitle = location.pathname;

            var now = new Date;
            var $JScript = {
                appInfo: {
                    module: 'Where I am?',
                    description: 'Shows the exact location where the user is currently.',
                    author: 'JScript',
                    version: '1.00',
                    release: '2014/10/13'
                },
                userInfo: {
                    oscpu: navigator.oscpu,
                    appName: navigator.appName,
                    language: navigator.language,
                    userAgent: navigator.userAgent
                },
                path: {
                    title: sTitle,
                    url: location.pathname,
                    param: location.search,
                    state: '0',
                    time: now.getHours() + ":" + now.getMinutes(),
                    date: now.getDate() + "/" + now.getMonth() + "/" + now.getFullYear()
                }
            };

            jQuery.post("/ajax_profile.forum?jsoncallback=?", {
                id: Profile_Field_ID.substring(16, Profile_Field_ID.length),
                user: USER_ID,
                active: "1",
                content: '[["' + Profile_Field_ID + '", "' + JSON.stringify($JScript).replace(/"/g, "'") + '"]]',
                tid: TID
            }, function(data) {
                console.log("OK: ajax_profile, userID = " + USER_ID);
            }, "json").fail(function() {
                console.log("error: ajax_profile, userID = " + USER_ID);
            });
        }
    }).done(function() {
        // Done!!!
    }).fail(function() {
        console.log('Failed to get field Profile_Field_ID');
    });
    jQuery.ajaxSetup({
        async: true
    });
}
Οto

Οto
Novo Membro

Membro desde : 21/11/2014
Mensagens : 18
Pontos : 33

https://ajuda.forumeiros.com/

Ir para o topo Ir para baixo

Tópico resolvido Re: Quem está lendo este tópico?

Mensagem por ellipsis 21.12.14 22:06

Agora reparei algo de esquisito.

Entrei num tópico que é apenas reservado à moderação.

E a ferramenta indicava que a ler aquele tópico estava eu mais 4 visitantes. Como é possível isso?

Foi até rever as permissões e está tudo correto. Como é que a ferramenta indica que 4 visitantes estão lendo aquele tópico? Em choque Em choque
ellipsis

ellipsis
****

Membro desde : 28/09/2011
Mensagens : 381
Pontos : 530

http://testemunhasdejeova.forumeiros.com.pt/

Ir para o topo Ir para baixo

Tópico resolvido Re: Quem está lendo este tópico?

Mensagem por iMac_Publicando 21.12.14 23:43

Olá,
Peço desculpas estar a entrar a meio mas, esse erro também me aconteceu a mim, os visitantes estarem numa área restrita so para staff.

O que eu tenho a dizer sobre isso é:
- Como o @jScript disse, o código busca a informação do sistema da Forumeiros localizado nos sub-foruns mais o campo no perfil dr cada membro.

- Como sabem, o campo de perfil não se aplica em cada visitante, e o código da forumeiros localizado nos sub-foruns s permite localizar os membros e não os visitantes.

Por isso .... não tenho mais nada a dizer nem a explicar sobre o que disse acima.
Acho que ja resumi o que o código faz pra isso.

Até Mais...
avatar

iMac_Publicando
Novo Membro

Membro desde : 21/12/2014
Mensagens : 7
Pontos : 10

http://www.forumpublicando.com/

Ir para o topo Ir para baixo

Tópico resolvido Re: Quem está lendo este tópico?

Mensagem por JScript 22.12.14 0:31

@ellipsis

kkk, isso é simples de explicar: Na verdade meu código não tem como saber quantos visitantes estão "lendo" um tópico, não há como saber disso pois um campo do perfil não se aplica a visitantes!

Isso é apenas uma "cosmética" no código para dar um "ar" a mais nas informações usando o código abaixo:
Código:
var guest = Math.floor(Math.random() * (5 - 0));

Com isso eu tenho um número aleatório de visitantes em um tópico, mas como pode perceber, isso é uma informação falsa (não no sentido de enganar), uma cosmética apenas.

JS
JScript

JScript
Super Membro

Membro desde : 15/03/2013
Mensagens : 1449
Pontos : 1901

http://jscript.forumeiros.com/

Ir para o topo Ir para baixo

Tópico resolvido Re: Quem está lendo este tópico?

Mensagem por iMac_Publicando 22.12.14 11:42

JScript escreveu:@ellipsis

kkk, isso é simples de explicar: Na verdade meu código não tem como saber quantos visitantes estão "lendo" um tópico, não há como saber disso pois um campo do perfil não se aplica a visitantes!

Isso é apenas uma "cosmética" no código para dar um "ar" a mais nas informações usando o código abaixo:
Código:
var guest = Math.floor(Math.random() * (5 - 0));

Com isso eu tenho um número aleatório de visitantes em um tópico, mas como pode perceber, isso é uma informação falsa (não no sentido de enganar), uma cosmética apenas.

JS

Olá,
Tal como eu disse acima, certo @jScript ?

Até Mais...
avatar

iMac_Publicando
Novo Membro

Membro desde : 21/12/2014
Mensagens : 7
Pontos : 10

http://www.forumpublicando.com/

Ir para o topo Ir para baixo

Tópico resolvido Re: Quem está lendo este tópico?

Mensagem por ellipsis 23.12.14 19:42

Ok obrigado pelas explicações tanto do @JScript e do @iMac_Publicando, bem como pela ajuda.

Obrigado mesmo.

Um abraço

ellipsis

ellipsis
****

Membro desde : 28/09/2011
Mensagens : 381
Pontos : 530

http://testemunhasdejeova.forumeiros.com.pt/

Ir para o topo Ir para baixo

Ver o tópico anterior Ver o tópico seguinte Ir para o topo

- Tópicos semelhantes

Permissões neste sub-fórum
Não podes responder a tópicos