Random manual previous/next navigation in viewer

Hi,

Would it be possible to manually go to the previous or next image with Show VIEWERCMD=next & prev but in a random fashion just like the automatic slideshow can do instead of the current linear next & prev navigation?

Thank you in advance .

function OnClick(clickData)
{
	viewer = DOpus.viewers.lastactive;
	if (!viewer) return
	
	itemsCount = viewer.files.count;
	if (itemsCount == 1) return
	
	viewerIndex = viewer.index;
	do
	{
		randomIndex = Math.floor(Math.random() * itemsCount);
	} while (randomIndex == viewerIndex)
	viewer.command('goto,' + randomIndex)
}
3 Likes

Exactly what I was looking for. Thank you :slightly_smiling_face: