Replace ugly fed-id user title on user pages
(function($){ | |
$(function(){ | |
//on domready | |
muut(function(app){ //on forum load | |
//init custom DOM structure | |
var userFeedTitle = $('<span class="userpage-title"></span>'); | |
var title = $('.m-pagetitle').prepend(userFeedTitle); | |
//on load and update events | |
app.on('load update', function (_, e) { | |
//switch userpage class | |
if(e.type == "user"){ //if userpage | |
title.addClass('userpage'); | |
//the following looks for this user's name in the DOM (if any post is available!) | |
var firstUserPost = $('.m-moot .m-seed .m-facelink[href="#!/'+e.user.path+'"]', app.root).closest('.m-moot').first(); | |
if(firstUserPost.length){ | |
var userName = firstUserPost.find('.m-seed .m-meta .m-name').text(); | |
userFeedTitle.text(userName); | |
}else{ | |
userFeedTitle.text('User Feed'); | |
} | |
}else{ | |
title.removeClass('userpage'); | |
} | |
}); | |
}); | |
}); | |
})(window.jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment