home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 September / PCWorld_2008-09_cd.bin / komunikace / kmeleon / K-Meleon1.1.3en-US.exe / macros / reload.kmm < prev    next >
Text File  |  2007-05-04  |  3KB  |  53 lines

  1. # K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
  2.  
  3. # ---------- Continuous Reload -------------------------------------------------------------------------------------
  4. #
  5. # Dependencies    : main.kmm ($macroPrefBranch, $pref_Frames, ExecMacros, OpenURL)
  6. # Resources    : -
  7. # Preferences    : kmeleon.plugins.macros.reload.interval
  8. #
  9. # ------------------------------------------------------------------------------------------------------------------
  10.  
  11. Reload_Continuously{
  12. $ExecMacros="_Reload_1st"; &ExecMacros_JavaScript;
  13. }
  14.  
  15. # ----- PRIVATE
  16.  
  17. $_Reload_Interval=$macroPrefBranch."reload.interval";
  18. $_Reload_OnLoad="";
  19.  
  20. _Reload_1st{
  21. # When frames are toggled from disabled to enabled, the current page must be loaded into a new window/layer
  22. $_Reload_OnLoad="_Reload_2nd";
  23. $OpenURL=$URL; $ExecMacros=getpref(BOOL,$pref_Frames)==false?"OpenURL_InNew":$_Reload_OnLoad; &ExecMacros_Frames;
  24. }
  25. _Reload_2nd{
  26. $_Reload_OnLoad="";
  27. $__pre=getpref(INT,$_Reload_Interval);
  28. $__sec=prompt(_("Enter number of seconds between reloads:"),_("Continuous Reload"),$__pre);
  29. $__sec==""?0:injectJS("(function(){var t=parseInt('".$__sec."');if(!isNaN(t)&&(t>0))with(document){open();write('<html><head><style type=\"text/css\">#b{position:absolute;left:0;width:100%;height:2em;bottom:0;padding:0 0 0.25em;font:inherit;}#i{position:absolute;left:0;width:100%;bottom:2em;top:0;border:0;}</style></head><body style=\"font:menu\"><iframe id=\"i\" src=\"'+location.href+'\"></iframe><button id=\"b\" onclick=\"quit()\"></button></body><script type=\"text/javascript\">var tspan='+t+',tleft=tspan+1,buttn=document.getElementsByTagName(\"button\")[0],units=new Array(\""._("hours")."\",\""._("minutes")."\",\""._("seconds")."\"),title=\""._("Reloading: %s")."\",btext=\""._("Reloading in %t %u (Click to abort)")."\";doit();setInterval(\"doit()\",1000);function doit(){if(!--tleft){tleft=tspan;frames[0].location.reload()}var h=Math.floor(tleft/3600),m=Math.floor((tleft%3600)/60),s=tleft%60,ttext=((h)?(h+((m<10)?\":0\":\":\")+m):((m)?m:\"\"))+((h||m)?((s<10)?\":0\":\":\"):\"\")+s,utext=((h)?units[0]:((m)?units[1]:units[2]));buttn.innerHTML=btext.replace(/%t/,ttext).replace(/%u/,utext);document.title=title.replace(/%s/,frames[0].document.title)}function quit(){history.back()}</script></html>');close()}})()");
  30. setpref(INT,$_Reload_Interval,$__sec); getpref(INT,$_Reload_Interval)>0?0:setpref(INT,$_Reload_Interval,$__pre);
  31. }
  32.  
  33. _Reload_BuildMenu{
  34. $__r="Reloa&ding";
  35. $kLayers==true?0:setmenu(Nav,popup,$__r,ID_NAV_FORCE_RELOAD);
  36. $kLayers==true?0:setmenu(Nav,command,"",ID_NAV_FORCE_RELOAD);
  37. $kLayers==true?0:setmenu($__r,command,"&Force Reload",ID_NAV_FORCE_RELOAD);
  38. setmenu($__r,macro,"&Continuous Reload...",Reload_Continuously);
  39. }
  40. $OnInit=$OnInit."_Reload_BuildMenu;";
  41.  
  42. _Reload_OnLoad{
  43. macros($_Reload_OnLoad);
  44. }
  45.  
  46. _Reload_SetDefaults{
  47. getpref(INT,$_Reload_Interval)==0?setpref(INT,$_Reload_Interval,120):0;
  48. $OnLoad=$OnLoad."_Reload_OnLoad;";
  49. }
  50. $OnStartup=$OnStartup."_Reload_SetDefaults;";
  51.  
  52. # ------------------------------------------------------------------------------------------------------------------
  53. $macroModules=$macroModules."Reload;";