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 on slow web-pages.
  • The Address Bar will not be properly 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

_START_SLIDESHOW{
  _ENABLE_JAVASCRIPT;
  _SLIDE_SHOW;
  _RESTORE_JAVASCRIPT;
}

_ENABLE_JAVASCRIPT{
  $_jscurrent= getpref(BOOL, $pref_JavaScript)
  setpref(BOOL,$pref_JavaScript, true);
}

_RESTORE_JAVASCRIPT{
  setpref(BOOL,$pref_JavaScript, $_jscurrent);
}

_SLIDE_SHOW{
  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>\nvar reloadIntv='+intv+';\nvar secsLeft='+intv+';\nfunction reloadFrame(){secsLeft=reloadIntv+1;Increment();}\nfunction countDown(){secsLeft--;showTime();}\nfunction showTime(){document.getElementById(\"caption\").innerHTML=\"-- Current link: \"+L.substring(0,s)+newNum+L.slice(e+1)+\"  --  Next image in \"+ parseInt(secsLeft)+\" secs.\";}\nfunction Increment(){IB=1;\nfunction 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);}\nsetInterval(\"reloadFrame()\",'+intv*1000+');\nsetInterval(\"countDown()\",1000);\nshowTime();\n</script>\n</html>';frames[1].document.write(docstr);}}})();");
}

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

$OnInit=$OnInit."_SSG_BuildMenu;";

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


Comments & Questions

K-Meleon

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