K-Meleon

KMeleonWiki > Resources > MacroLibrary > Slideshow Generator

Submitted by: Johnny Sim-Bravenboer

Notes:

This macro is a combination of the Auto Reload function (which was made part of K-Meleon 0.9) and the Link Increment macro.

When looking at a picture on a webpage that has pictures that are named in sequence, (pic01.jpg, pic02.jpg, pic03.jpg, etc...) this macro will create an instant slideshow and automatically go to the next picture in sequence.

To stop the slideshow, click on the "back" button.

Because this is a Javascript program, there is a limited functionality while watching the slideshow, for example;

  • The only way to stop the slideshow is the "back" button or to close the tab/window.
  • Before the slideshow starts, the user needs to enter a time for the interval between pictures loading.
  • The counter will not wait for a picture to load before it goes on to the next, so you will need to set a longer time for slow web-servers.
  • The Address Bar will not be updated during the slideshow, instead the current link will be displayed at the bottom of the screen.

This is not a full featured macro, but it does the job ;-)


Open your User Macro Folder (Edit > Configuration > User-Defined Macros) or your Macro Folder (Edit > Configuration > Macros) and create the following text file:

SlideShow?.kmm

# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)

# ---------- Slide Show --------------------------------------------------------------------------------------------
#
# Dependencies : -
# Resources    : -
# Preferences  : -
#
# ------------------------------------------------------------------------------------------------------------------

# ----- PRIVATE

# SLIDESHOW GENERATOR
_SLIDESHOW_GENERATOR{

  # Enable JavaScript
  $_jscurrent=getpref(BOOL,$pref_JavaScript);
  setpref(BOOL,$pref_JavaScript, true);

  # Run the SlideShow
  open("javascript:(function(){var intv=prompt('Enter number of seconds between images. (Click Back to stop the show)');if(intv&&!isNaN(intv)){with(document){write('<html><frameset rows=\"*,22\" framespacing=0 border=0 frameborder=no><frame noresize frameborder=no><frame scrolling=no noresize frameborder=no></frameset></html>');frames[0].location.href=document.location.href;var docstr='<html><body bgcolor=#33FF99 style=\"margin-top:0px\">\n';docstr+='<span id=\"caption\"></span></body>\n';docstr+='<script>\n var reloadIntv='+intv+';\n var secsLeft='+intv+';\n function reloadFrame(){secsLeft=reloadIntv+1;Increment();}\n function countDown(){secsLeft--;showTime();}\n function showTime(){document.getElementById(\"caption\").innerHTML=\"-- Current image: \"+L.substring(0,s)+newNum+L.slice(e+1)+\"  --  Next image in \"+ parseInt(secsLeft)+\" secs.\";}\n function Increment(){IB=1;\n function isDigit(c){return (\"0\" <= c && c <= \"9\");}L = parent.frames[0].location.href;LL = L.length;for (e=LL-1; e>=0; --e)if (isDigit(L.charAt(e))){for(s=e-1; s>=0; --s)if (!isDigit(L.charAt(s)))break;break;}++s;if (e<0)return;oldNum = L.substring(s,e+1);newNum = \"\" + (parseInt(oldNum,10) + IB);while (newNum.length < oldNum.length)newNum = \"0\" + newNum;parent.frames[0].location.href = L.substring(0,s) + newNum + L.slice(e+1);}\n setInterval(\"reloadFrame()\",'+intv*1000+');\n setInterval(\"countDown()\",1000);\n showTime();\n </script>\n </html>';frames[1].document.write(docstr);}}})();");

}

_SSG_BuildMenu{
  setmenu(PageDisplay, macro, "Start Slide Show", _SLIDESHOW_GENERATOR);
  setmenu("Page &Properties", macro, "Start Slide Show", _SLIDESHOW_GENERATOR, 3);
}

$OnInit=$OnInit."_SSG_BuildMenu;";

# ------------------------------------------------------------------------------------------------------------------
$macroModules=$macroModules."SlideShow;";


Comments & Questions

K-Meleon

(c) 2000-2010 kmeleonbrowser.org. All rights reserved.
design by splif.