Advertisement
SSYT

[Project] Last visitors on member profile

Feb 11th, 2017
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /***
  2.  * Application: LatestVisitors.js
  3.  * Description: Shows the last 10 visitors to your profile!
  4.  * Version: 0.02282015-jq1.9.1
  5.  *          RC1 (Release candidate 1!) - Tot (Imhotep-hwcp)
  6.  * Author: JScript - 2015/02/28
  7.  * Copyright (c) 2015 JScript <jscriptbrasil at live dot com>
  8.  * This work is free. You can redistribute it and/or modify it
  9.  * under the terms of the WTFPL, Version 2
  10.  */
  11. var lastVisit = {
  12.     autor: "JScript",
  13.     version: "1.02282015-jq1.9.1",
  14.     codename: "Tot (Imhotep-hwcp)",
  15.  
  16.     observe: 100,
  17.     startMsg: "<p class=\"ipsPad desc\">Starting, wait...</p>",
  18.     noVisitors: "<p class=\"ipsPad desc\">No latest visitors to show</p>",
  19.  
  20.     initialize: function() {
  21.         if (location.pathname.indexOf("/u") == -1) {
  22.             return false;
  23.         }
  24.         var wrapper = setInterval(function() {
  25.             if (typeof(_userdata) !== "undefined") {
  26.                 clearInterval(wrapper);
  27.                 if (_userdata.user_level == 0) {
  28.                     $('a[href*="wall"]:first').parent().hide();
  29.                 }
  30.                 if ((location.pathname.indexOf('wall') !== -1) && (_userdata.user_level !== 1)) {
  31.                     return location.pathname = location.pathname.split('wall')[0];
  32.                 }
  33.                 jQuery(function() {
  34.                     lastVisit.view();
  35.                 });
  36.             }
  37.         }, lastVisit.observe);
  38.     },
  39.  
  40.     dataRead: function() {
  41.         $.ajax({
  42.             url: location.pathname + 'wall',
  43.             cache: false,
  44.             type: "get",
  45.             dataType: "text",
  46.             success: function(response, status, xhr) {
  47.                 if (xhr.status == 200) {
  48.                     var oTarget = $('#profile-advanced-details ol > li', response),
  49.                         content = '<ul class="ipsList_withminiphoto ipsPad" style="padding: 0;">',
  50.                         oThis = null,
  51.                         oID = null,
  52.                         iFound = 0;
  53.  
  54.                     if (oTarget.length) {
  55.                         for (i = 0, len = oTarget.length; i < len; i++) {
  56.                             oThis = $(oTarget[i]);
  57.                             content += '<li class="clearfix"><div class="list_content">' + oThis.html() + '</div></li>';
  58.                             oID = oThis.find('.message-header a');
  59.                             if (oID.attr('href') == ("/u" + _userdata.user_id)) {
  60.                                 iFound = 1;
  61.                             }
  62.                         }
  63.                         $("#lastvisit").html(content + '</ul>');
  64.                         if (_userdata.user_level > 0) {
  65.                             $('#lastvisit .message-footer').show();
  66.                         }
  67.                         $('#lastvisit .message-text').remove();
  68.             $('.ipsPad li.clearfix .list_content').each(function() {
  69.                 var i = this;
  70.                 var user_id = $('.avatar a', i).attr('href').match(/\d+/g)[0];
  71.                 var user_avatar = $('.avatar a img', i).attr('src');
  72.                 var visit_date = $('.message-date', i).text();
  73.                 var user_guest = $('.message-header a', i).text();
  74.                
  75.                 $(i).before('<a href="http://www.bitcoding.tk/u'+ user_id +'" title="View Profile" class="ipsUserPhotoLink left"><img src="'+ user_avatar +'" alt="Photo" class="ipsUserPhoto ipsUserPhoto_mini" /></a>');
  76.                 $(i).html('<a hovercard-ref="member" hovercard-id="'+ user_id +'" data-ipb="noparse" class="url fn name  ___hover___member _hoversetup" href="http://www.bitcoding.tk/u'+ user_id +'" title="" id="anonymous_element_1"><span itemprop="name">'+ user_guest +'</span></a><br /><span class="desc lighter">'+ visit_date +'</span>');
  77.             });
  78.                     } else {
  79.                         $("#lastvisit").html(lastVisit.noVisitors);
  80.                     }
  81.  
  82.                     var user_id = Number(location.pathname.split('u')[1]);
  83.  
  84.                     if ((user_id !== _userdata.user_id) && (!iFound)) {
  85.                         $.get('/privmsg?mode=post_profile&u=' + user_id, function(data) {
  86.                             $.post("/privmsg", {
  87.                                 mode: "post_profile",
  88.                                 folder: "profile",
  89.                                 username: $('input[name="username"]', data).val(),
  90.                                 subject: "last_visit",
  91.                                 message: "last_visit",
  92.                                 lt: "",
  93.                                 post: 1,
  94.                             }, function(e) {
  95.                                 // OK!
  96.                             });
  97.                         });
  98.                     }
  99.                 }
  100.             }
  101.         });
  102.     },
  103.  
  104.     view: function() {
  105.         var forumline = "forumline";
  106.         if ($('#phpbb').length) {
  107.             forumline = "phpbb3"
  108.         }
  109.         $('table[cellpadding="1"] > tbody > tr:last > td:last > .forumline:first, #profile-advanced-right .module:first').after(
  110.             '<div class="general_box clearfix">'+
  111.                 '<h3>Latest Visitors</h3>'+
  112.                 '<div id="lastvisit">'+ lastVisit.startMsg +'</div>' +
  113.             '</div>'
  114.         );
  115.  
  116.         lastVisit.dataRead();
  117.     }
  118. };
  119. lastVisit.initialize();
  120.  
  121. $(function() {
  122.     window.onload = function() {
  123.     if($('div#profile_content').length  > 0 && $('div#profile-advanced-right .general_box.clearfix').length > 0) {
  124.        
  125.             if($('#user_status_cell').length  > 0 && ($('span.status_length').text() === "No status" || $('span.status_length').text() === "  -")) {
  126.                 $('#user_status_cell').remove();
  127.             }
  128.            
  129.             $('div#profile_content .ipsLayout_right .general_box.clearfix:eq(2)').replaceWith($('div#profile-advanced-right .general_box.clearfix'));
  130.             var x = $('div#profile_content .ipsLayout_right .general_box.clearfix:eq(2)');
  131.             $('.ipsPad li.clearfix .list_content', x).each(function() {
  132.                 var i = this;
  133.                 var user_id = $('.avatar a', i).attr('href').match(/\d+/g)[0];
  134.                 var user_avatar = $('.avatar a img', i).attr('src');
  135.                 var visit_date = $('.message-date', i).text();
  136.                 var user_guest = $('.message-header a', i).text();
  137.                
  138.                 $(i).before('<a href="/u'+ user_id +'" title="View Profile" class="ipsUserPhotoLink left"><img src="'+ user_avatar +'" alt="Photo" class="ipsUserPhoto ipsUserPhoto_mini" /></a>');
  139.                 $(i).html('<a hovercard-ref="member" hovercard-id="'+ user_id +'" data-ipb="noparse" class="url fn name  ___hover___member _hoversetup" href="/u'+ user_id +'" title="" id="anonymous_element_1"><span itemprop="name">'+ user_guest +'</span></a><br /><span class="desc lighter">'+ visit_date +'</span>');
  140.             });
  141.         }
  142.     }
  143. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement