Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to highlight not being logged in

Hans-Hermann Hunfeld
Contributor
May 6, 2014

At our company many content can be accessed without being logged in. Unfortunately many users just start to search for any stuff but do not recognize that they re browsing anonymous and therefor not getting all possible results.

Thats why we re thinking about making missing login more obvious, as example change the header to red or add a banner...

Any ideas how to get this running?

Many thanks,
Hans-Hermann

1 answer

1 accepted

0 votes
Answer accepted
discountrobot
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 6, 2014
AJS.toInit(function() {
	var msg = "booh! log in!";

	var $container;

	// is the messageContainer already visable?
	if($('#messageContainer')[0]) {
		$container = $('#messageContainer')
	} else {
		$container = $('<ul id="messageContainer"></div>')
		    .prependTo('#full-height-container');	
	}

	var $msgContainer = $('<li id="confluence-message-websudo-message" class="confluence-messages noteMessage"></li>')
	    .appendTo($container);

	// if AJS finds no username, the person should be anon
	if(!AJS.params.remoteUser) {
		var $msg = $('<div class="aui-message warning "><span class="aui-icon icon-warning"></span></div>')
		   .appendTo($container);
	   $('<span></span>')
	       .text(msg)
	       .appendTo($msg);
	}

});

This adds a warning banner similar to the one you get when in the admin panel, if there is no username present (e.g anon user)

Hans-Hermann Hunfeld
Contributor
May 6, 2014

Hmm, sounds interesting!

But where to put this stuff into? In the "Custom HTML"?

discountrobot
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 6, 2014
An eariler question indicated that older verisons of confluence does not run javascript when added via the Custom HTML.
I've tested the script on confluence 5.4 by adding the following to one of the custom html boxes. 
<script>
AJS.toInit(function() {
	var msg = "booh! log in!";

	var $container;

	// is the messageContainer already visable?
	if($('#messageContainer')[0]) {
		$container = $('#messageContainer')
	} else {
		$container = $('<ul id="messageContainer"></div>')
		    .prependTo('#full-height-container');	
	}

	var $msgContainer = $('<li id="confluence-message-websudo-message" class="confluence-messages noteMessage"></li>')
	    .appendTo($container);

	// if AJS finds no username, the person should be anon
	if(!AJS.params.remoteUser) {
		var $msg = $('<div class="aui-message warning "><span class="aui-icon icon-warning"></span></div>')
		   .appendTo($container);
	   $('<span></span>')
	       .text(msg)
	       .appendTo($msg);
	}

});
</script>

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events