View Single Post
Old 09-10-2018, 12:41 PM   #1
babloyi
Member
babloyi began at the beginning.
 
Posts: 16
Karma: 10
Join Date: Feb 2015
Device: none
Question How to show random images on poweroff?

Hi all!

I've got KSM and koreader on my Kobo Aura, and I want to show random images from a list. If I save my poweroff_info.html as this:
Code:
<html>
<head>
<script type="text/javascript">
  var imageURLs = [
       "1.png"
     , "2.png"
     , "3.png"
     , "4.png"
     , "5.png"
     , "6.png"
  ];
  function getImageTag() {
    var img = '<img src="/mnt/onboard/.adds/kbmenu_user/txt/';
    var randomIndex = Math.floor(Math.random() * imageURLs.length);
    img += imageURLs[randomIndex];
    img += '"/>';
    return img;
  }
</script>
</head>
<body>
<script type="text/javascript">
  document.write(getImageTag());
</script>
</body>
</html>
Nothing happens, and the reader powers off with a blank white page.

However, if I do this:
Code:
<html>
<body>
	<img src="/mnt/onboard/.adds/kbmenu_user/txt/1.png"/>
</body>
</html>
It shows 1.png fine. I've not done html in ages, and I'm not that skilled in javascript, so is that the problem, or is it something else? I copied the code off the net, but if I run it in a random folder on my PC, with the path corrected, it works fine.
babloyi is offline   Reply With Quote