Expand my Community achievements bar.

SOLVED

Needs to add custom js on each and every page in AEM

Avatar

Level 4

Hi Team,

 

We want to add some custom JS on aem author instance on each and every page.

Can anyone please help me to suggest where I put this JS so that call on each page.

 

Thanks

Bhagchand

1 Accepted Solution

Avatar

Correct answer by
Community Advisor
11 Replies

Avatar

Correct answer by
Community Advisor

Avatar

Community Advisor

Hi @bhagchand,

 

In addition to Himanshu's comment earlier, if you have a common clientlibs and need to be loaded only in author mode, you can add it in the page component and restrict it only to author mode.

 

<sly data-sly-test="${wcmmode.preview || wcmmode.edit}" data-sly-call="${clientLib.all @ categories='category.name'}"/>

 

I hope it helps.

 

Regards,

Rohit

Avatar

Community Advisor

@bhagchand , is this js required for any dialog validation or dialog function or any direct functionality on the page?

I am asking this because you mentioned AUTHOR instance.

Avatar

Level 4

Hi @Umesh_Thakur ,

Basically we want admin user logged out after 15 mins inactivity.

we also changed apache token expiration configuration from admin but it will forcefully logged out user after 15 mins.

 

So from the JS we can manage like this.

 

https://social.msdn.microsoft.com/Forums/en-US/3ce8cbd1-e1a1-430f-b32a-a6456a33a8de/if-no-activity-f...  

Avatar

Community Advisor

what all will be included in user activity ? will it be limited to content authoring or it will be extended to any activity by the author like changing system configuration, making any change in workflow model etc?

Normally mouse click or key pressing are being taken as activity? so can you confirm that as well 

based on this answer we can decide the approach thru JS or thru any server side implementation.

 

Avatar

Level 4

Yes @Umesh_Thakur , 

we want to track user on mouse-hover, key press.

So I found one header.jsp in /apps/granite/ui/components/shell/collectionpage/header.jsp

We put custom  js in this file and working fine on the pages which have the common header.

But this is not working in the distribution pages and osgi configuration console.

 

Can you please help to suggest any better approach for the same.

 

Thanks

Avatar

Level 4

Yes, Tried already but this forcefully logged out user after certain period.

It not consider user inactivity. 

Avatar

Community Advisor

oookay...!

In this case we need to think of a solution which fits into this requirement.

Anyway the proposed solution by you may work in page editing case not certainly will not work when user will access the other consoles of AEM like confManager etc.

So can you think of anything like chrome browser plugin creation with the same js, you have written for your solution. this plugin will track user's inactivity and then clear the session cookie  from the browser.

this way you can handle the stuff easily and effectively.

Hope this helps

Umesh Thakur