Created
March 27, 2018 12:13
-
-
Save zerfl/4e0a4ee17add80be7b5d25999645df46 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="recent-players-list"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getRecentPlayers() { | |
if (window.username.length > 0 && $('#recent-players-list a').length > 0) { | |
return; | |
} | |
if (localStorage != null) { | |
var recent = localStorage.getItem('recentv2') || ''; | |
var arr = recent != '' ? JSON.parse(recent) : []; | |
var htmlFormat = '<a href="/profile/{2}?utm_source=recentgames&utm_medium=link&utm_campaign=recentgames"><div class="recent-player"><i class="{0}"></i> {1}</div></a>'; | |
if (arr.length > 0) { | |
var html = ''; | |
$('#recent-players-list .recent-player').remove(); | |
arr.reverse().forEach(function(item, index) { | |
if (index > 6) { | |
return; | |
} | |
var h = htmlFormat; | |
if (item.console == '1') { | |
h = h.replace('{0}', 'ion-xbox'); | |
h = h.replace('{2}', 'xbox/' + item.name); | |
} else if (item.console == '2') { | |
h = h.replace('{0}', 'ion-playstation'); | |
h = h.replace('{2}', 'ps/' + item.name); | |
} else if (item.console == '3') { | |
h = h.replace('{0}', 'ion-steam'); | |
h = h.replace('{2}', 'steam/' + item.steamid); | |
} | |
h = h.replace('{1}', item.name); | |
$('#recent-players-list').append(h); | |
}); | |
} else { | |
$('#recent-players-list').hide(); | |
} | |
} | |
} | |
$(document).ready(function() { | |
getRecentPlayers(); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment