JScript

Programação & Desenvolvimento


Você não está conectado. Conecte-se ou registre-se

Teste da tag [ code ]

Ir para baixo  Mensagem [Página 1 de 1]

1Teste da tag [ code ] Empty Teste da tag [ code ] Qua 17 Jul 2013, 5:23 pm

JScript

JScript
Administradores
Administradores

Teste da tag [ code ]

Código:

<script type="text/javascript">
//<![CDATA[
/***
 * Topic Active Users (Who is read this topic?)!
 * Only one request per session to read member profile to get info!
 * Only run the code if is visible in browser window (view port)!!!
 * Made and Optimizations by JScript - 2013/07/12
 */
/* Fire event for 'scroll' to run the code... */
jQuery(window).on('scroll.topicActiveUsers', topicActiveUsers(document.getElementById("topic_active_users")));

/* Function to check if an element is visible in view port */
function isInViewPort(elem) {
 var rect = elem.getBoundingClientRect();

 return (
 rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && /*or $(window).height() */
 rect.right <= (window.innerWidth || document.documentElement.clientWidth) /*or $(window).width() */ );
}
/* Start function to run the code... */
function topicActiveUsers(elem) {
 return function() {
        /* Chech if the widget is visible in view port! */
 if (isInViewPort(elem)) {
            /* If visible, stop event!!! */
 jQuery(window).off('scroll.topicActiveUsers');
            var total_users = 0, last_views = '';
            var WereIam = '', target = 0;
            var pathname = location.pathname;
            var storListViews = pathname;
            var storTotalView = pathname + '_views';
        
            $.get('/forum', function (data) {
                target = $('#logged_in_user_list', data).find('a');
                if (target.length == 0) {
                    target = $('#onlinelist').find('p:eq(1)').find('a');
                }
            }).always(function() {
                var len = target.length, last_views = '';
                if (len == 0) {return false}
                
                searchActiveUsers(target, 0, len, 0);
            });

            function searchActiveUsers(target, start, len, index){
                if (index == len) {
                    <!-- BEGIN switch_user_logged_in -->
                    $('#topic_list_views').html('');
                    last_views = localStorage.getItem(storListViews);
                    if (last_views) {
                        $('#topic_list_views').html(last_views);
                        $('#topic_total_views').text(localStorage.getItem(storTotalView));
                    }
                    <!-- END switch_user_logged_in -->            
                    return false
                }
                var oThis = $(target[index]);
                var USER_ID = oThis.attr('href');

                if (USER_ID.length !== 0) {
                    var Removed = '<a href="' + USER_ID + '">' + oThis.html() + '</a>';
                    
                    $.get(USER_ID, function (data) {
                        WereIam = $('#field_id3', data).find('div.field_uneditable').text();
                    }).always(function() {
                        if (WereIam == pathname) {
                            if (total_users == 0) {
                                $('#topic_list_users').html('');
                                $('#topic_list_users').append(Removed);
                            } else {
                                $('#topic_list_users').append(', ' + Removed);
                            }
                            total_users++;
                            $('#topic_total_users').text(total_users);
                            $('#topic_total_members').text(total_users);
                            <!-- BEGIN switch_user_logged_in -->
                            last_views = localStorage.getItem(pathname);
                            if (last_views) {
                                if (last_views.indexOf(USER_ID) == -1) {
                                    localStorage.setItem(storListViews, last_views + ', ' + Removed);
                                    var storValue = localStorage.getItem(storTotalView);
                                    if (storValue == null) storValue = 0;
                                    localStorage.setItem(storTotalView, parseInt(storValue) + 1);
                                }
                            } else {
                                localStorage.setItem(storListViews, Removed);
                                localStorage.setItem(storTotalView, 1);
                            }
                            <!-- END switch_user_logged_in -->
                        }
                        index++;
                        try {
                            searchActiveUsers(target, start, len, index);
                        } catch (e) {
                            /*console.log(index);*/
                        }                    
                    });
                }
            }
 }
 }
}
//]]>
</script>
Teste concluído com sucesso em 18/07/2013

JS



Última edição por JScript em Qui 26 Set 2013, 1:55 pm, editado 7 vez(es)

http://autoitbrasil.com

Ir para o topo  Mensagem [Página 1 de 1]

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