@DownPW From memory, you should be using a function that looks like this in PROD
$(window).on('action:ajaxify.end', function (data) {
function updateUsername() {
$('.getUsername .username').text(app.user.username);
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', updateUsername);
} else {
updateUsername();
}
var thehours = new Date().getHours();
var themessage;
var morning = ('Good morning');
var afternoon = ('Good afternoon');
var evening = ('Good evening');
var matched = false;
$('#getConsent').attr("href", "/user/" + app.user.username + "/consent");
if (thehours >= 0 && thehours < 12) {
themessage = morning;
} else if (thehours >= 12 && thehours < 17) {
themessage = afternoon;
} else if (thehours >= 17 && thehours < 24) {
themessage = evening;
}
$('.getUsername').prepend(themessage);
});
You’ll need the same function in your development environment if you don’t have it already, and will need to add
$('.topicUsername').text(app.user.username);
Right after line 3, so
$(window).on('action:ajaxify.end', function(data) {
function updateUsername() {
$('.getUsername .username').text(app.user.username);
$('.topicUsername').text(app.user.username);
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', updateUsername);
} else {
updateUsername();
}
var thehours = new Date().getHours();
var themessage;
var morning = ('Good morning');
var afternoon = ('Good afternoon');
var evening = ('Good evening');
var matched = false;
$('#getConsent').attr("href", "/user/" + app.user.username + "/consent");
if (thehours >= 0 && thehours < 12) {
themessage = morning;
} else if (thehours >= 12 && thehours < 17) {
themessage = afternoon;
} else if (thehours >= 17 && thehours < 24) {
themessage = evening;
}
if (window.location.href.indexOf("topic") > -1) {
//console.log("This is a topic, so hide the user welcome message");
$('#mainbanner').hide();
} else {
$('.getUsername').prepend(themessage);
}
// $('.getUsername').prepend(themessage);
});
Note that your function might look different as I recall you modifying the code I supplied to meet your own needs.