replace self links client side

This commit is contained in:
barisusakli
2014-04-30 17:42:50 -04:00
parent c8efeb7d7c
commit 63d88957a8
4 changed files with 17 additions and 19 deletions

View File

@@ -90,6 +90,7 @@ var socket,
socket.on('event:connect', function (data) {
app.username = data.username;
app.userslug = data.userslug;
app.uid = data.uid;
app.isAdmin = data.isAdmin;
@@ -285,6 +286,16 @@ var socket,
});
};
app.replaceSelfLinks = function(selector) {
selector = selector || $('a');
selector.each(function() {
var href = $(this).attr('href')
if (href && app.userslug) {
$(this).attr('href', href.replace(/\[self\]/g, app.userslug));
}
});
};
app.processPage = function () {
app.populateOnlineUsers();
@@ -299,6 +310,8 @@ var socket,
app.createStatusTooltips();
app.replaceSelfLinks();
setTimeout(function () {
window.scrollTo(0, 1); // rehide address bar on mobile after page load completes.
}, 100);