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 / docinfo.kmm < prev    next >
Text File  |  2007-05-04  |  8KB  |  91 lines

  1. # K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
  2.  
  3. # ---------- Document And Document Element Information -------------------------------------------------------------
  4. #
  5. # Dependencies    : main.kmm ($macroPrefBranch, JS, ExecMacros)
  6. # Resources    : [MacroFolder]\docinfo\docinfo.css
  7. # Preferences    : kmeleon.plugins.macros.docinfo.forceLayer.images
  8. #          kmeleon.plugins.macros.docinfo.forceLayer.links
  9. #          kmeleon.plugins.macros.docinfo.forceLayer.linkedImages
  10. #
  11. # ------------------------------------------------------------------------------------------------------------------
  12.  
  13. DocInfo_Image{
  14. $JS_doitImage="a=false;var l=getAttribute('longdesc'),s='"._("Image Properties:")."\\n\\n"._("URL:\\t%s")."'.replace(/%s/,unescape(src))+'\\n"._("Size:\\t%W x %H Pixels")."'.replace(/%W/,width).replace(/%H/,height);if(alt)s+='\\n"._("Alt. Text:\\t%s")."'.replace(/%s/,alt);if(l){s+='\\n\\n"._("A description is available for this image. Do you want to view it now?")."';if(confirm(s)){if(top.location==self.location)open(l);top.location.href=l}}else alert(s)";
  15. $JS_doitInput="a=false;var s='"._("Image Properties:")."\\n\\n"._("URL:\\t%s")."'.replace(/%s/,unescape(src));if(alt)s+='\\n"._("Alt. Text:\\t%s")."'.replace(/%s/,alt);alert(s);a=false"; &JS_hndlImage;
  16. }
  17. DocInfo_Link{
  18. $JS_doitLink="j=a.length;var l=getAttribute('hreflang'),p=getAttribute('ping'),t=getAttribute('type'),s='"._("Link Properties:")."\\n\\n"._("URL:\\t%s")."'.replace(/%s/,unescape(href));if(p)s+='\\n"._("Ping:\\t%s")."'.replace(/%s/,unescape(p));if(l||t){s+='\\n\\n"._("Properties of Linked Resource:")."\\n';if(t)s+='\\n"._("MIME Type:\\t%s")."'.replace(/%s/,t);if(l)s+='\\n"._("Language:\\t%s")."'.replace(/%s/,l)}s+='\\n\\n"._("Do you want to view the linked resource now?")."';if(confirm(s)){if(top.location==self.location)open(href);top.location.href=href}"; &JS_hndlLink;
  19. }
  20.  
  21. DocInfo_Page_Links{
  22. &_DocInfo_lstLinks; $ExecMacros="JS_hndlDocs"; $ForceLayer=$_DocInfo_ForceLayer; &ExecMacros_Popups;
  23. }
  24. DocInfo_Frame_Links{
  25. &_DocInfo_lstLinks; $ExecMacros="JS_hndlDoc";  $ForceLayer=$_DocInfo_ForceLayer; &ExecMacros_Popups;
  26. }
  27.  
  28. DocInfo_Page_LinkedImages{
  29. &_DocInfo_lstLinkedImages; $ExecMacros="JS_hndlDocs"; $ForceLayer=$_DocInfo_ForceLayer; &ExecMacros_Popups;
  30. }
  31. DocInfo_Frame_LinkedImages{
  32. &_DocInfo_lstLinkedImages; $ExecMacros="JS_hndlDoc";  $ForceLayer=$_DocInfo_ForceLayer; &ExecMacros_Popups;
  33. }
  34.  
  35. DocInfo_Page_Images{
  36. &_DocInfo_lstImages; $ExecMacros="JS_hndlDocs"; $ForceLayer=$_DocInfo_ForceLayer; &ExecMacros_Popups;
  37. }
  38. DocInfo_Frame_Images{
  39. &_DocInfo_lstImages; $ExecMacros="JS_hndlDoc";  $ForceLayer=$_DocInfo_ForceLayer; &ExecMacros_Popups;
  40. }
  41.  
  42. # ----- PRIVATE
  43.  
  44. $_DocInfo_ForceLayer=false;
  45. $_DocInfo_FrameError="txt+='<fieldset><legend>"._("(unknown)")."</legend><p>"._("A script error occured accessing this frame. Probably this frame belongs to another domain and access was denied for security reasons.")."</p></fieldset>'";
  46. $_DocInfo_PopupStyle="left=0,top=0,width=600,height=300,minimizable=yes,resizable=yes,status=yes,scrollbars=yes";
  47. $_DocInfo_StyleSheet=getfolder(MacroFolder)."\\docinfo\\docinfo.css";
  48.  
  49. _DocInfo_lstLinks{
  50. $_DocInfo_ForceLayer=getpref(BOOL,$macroPrefBranch."docinfo.forceLayer.links");
  51. $JS_func="with(document)var h='kmHOST',l='kmLINK',w=window.name,n=(w&&!getElementsByTagName('body')[0])?w.replace(h,''):Math.floor(Math.random()*1000),hstWinName=window.name=h+n,lnkWinName=l+n,cnt=0,nlf='"._("No links found.")."',tit='"._("Links: %s")."'.replace(/%s/,(title)?title:unescape(URL)),txt='';";
  52. $JS_doit="if(getElementsByTagName('body')[0]){txt+='\\n<fieldset><legend>'+((title)?title:unescape(URL)).link(URL)+'</legend><ol>';cnt+=links.length;if(links.length)for(var j=0;j<links.length;j++)txt+='\\n<li>'+((links[j].text)?links[j].text.link(links[j]):unescape(links[j]).link(links[j]))+' </li>';else txt+='\\n<p>'+nlf+'</p>';txt+='</ol>\\n</fieldset>'}";
  53. $JS_last="if(cnt){var lnkWin=open('',lnkWinName,'".$_DocInfo_PopupStyle."');with(lnkWin.document){open();write('<html><head><title>'+tit+'</title><style type=\"text/css\">\\n".gsub("\n","\\n",readfile($_DocInfo_StyleSheet))."\\n</style><base target=\"'+hstWinName+'\"></head>\\n<body class=\"km_DocInfo_lstLinks\">'+txt+'\\n</body></html>');close()}lnkWin.focus()}else alert(nlf)";
  54. $JS_fail=$_DocInfo_FrameError;
  55. }
  56. _DocInfo_lstLinkedImages{
  57. $_DocInfo_ForceLayer=getpref(BOOL,$macroPrefBranch."docinfo.forceLayer.linkedImages");
  58. $JS_func="with(document)var ext=new Array('bmp','gif','giff','jpg','jpeg','png','ico'),cnt=0,nlf='"._("No linked images found.")."',tit='"._("Linked Images: %s")."'.replace(/%s/,(title)?title:unescape(URL)),txt='';";
  59. $JS_doit="if(getElementsByTagName('body')[0]){var url=new Array();function add(s){for(var j=0;j<url.length;j++)if(s==url[j])return;for(var j=0,x=s.split('.');j<ext.length;j++)if(x[x.length-1].toLowerCase()==ext[j])url[url.length]=s}for(var j=0,l=links;j<l.length;j++)add(l[j].href);txt+='\\n<fieldset><legend>'+((title)?title:unescape(URL)).link(URL)+'</legend><ol>';cnt+=url.length;if(url.length)for(var j=0;j<url.length;j++)txt+='\\n<li><img src=\"'+url[j]+'\"></li>';else txt+='\\n<p>'+nlf+'</p>';txt+='</ol>\\n</fieldset>'}";
  60. $JS_last="if(cnt){var imgWin=open('','kmLINKIMG'+Math.floor(Math.random()*1000),'".$_DocInfo_PopupStyle."');with(imgWin.document){open();write('<html><head><title>'+tit+'</title><style type=\"text/css\">\\n".gsub("\n","\\n",readfile($_DocInfo_StyleSheet))."\\n</style></head>\\n<body class=\"km_DocInfo_lstLinkedImages\">'+txt+'\\n</body></html>');close()}}else alert(nlf)";
  61. $JS_fail=$_DocInfo_FrameError;
  62. }
  63. _DocInfo_lstImages{
  64. $_DocInfo_ForceLayer=getpref(BOOL,$macroPrefBranch."docinfo.forceLayer.images");
  65. $JS_func="with(document)var cnt=0,nif='"._("No images found.")."',tit='"._("Images: %s")."'.replace(/%s/,(title)?title:unescape(URL)),txt='';";
  66. $JS_doit="if(getElementsByTagName('body')[0]){var url=new Array();function add(s){for(var j=0;j<url.length;j++)if(s==url[j])return;url[url.length]=s}for(var j=0,i=images;j<i.length;j++)add(i[j].src);for(var j=0,i=getElementsByTagName('input');j<i.length;j++)if((i[j].getAttribute('type')=='image')&&(i[j].getAttribute('src')))add(i[j].src);txt+='\\n<fieldset><legend>'+((title)?title:unescape(URL)).link(URL)+'</legend><ol>';cnt+=url.length;if(url.length)for(var j=0;j<url.length;j++)txt+='\\n<li><img src=\"'+url[j]+'\"></li>';else txt+='\\n<p>'+nif+'</p>';txt+='</ol>\\n</fieldset>'}";
  67. $JS_last="if(cnt){var imgWin=open('','kmIMG'+Math.floor(Math.random()*1000),'".$_DocInfo_PopupStyle."');with(imgWin.document){open();write('<html><head><title>'+tit+'</title><style type=\"text/css\">\\n".gsub("\n","\\n",readfile($_DocInfo_StyleSheet))."\\n</style></head>\\n<body class=\"km_DocInfo_lstImages\">'+txt+'\\n</body></html>');close()}}else alert(nif)";
  68. $JS_fail=$_DocInfo_FrameError;
  69. }
  70.  
  71. _DocInfo_BuildMenu{
  72. # context menus
  73. setmenu(ImageProperties,macro,"Image &Properties",DocInfo_Image,0);
  74. setmenu(LinkProperties,macro,"Link &Properties",DocInfo_Link,0);
  75. $__m="Page &Properties";
  76. setmenu($__m,macro,"Li&nks",DocInfo_Page_Links,ID_VIEW_SOURCE);
  77. setmenu($__m,macro,"Link&ed Images",DocInfo_Page_LinkedImages,ID_VIEW_SOURCE);
  78. setmenu($__m,macro,"Im&ages",DocInfo_Page_Images,ID_VIEW_SOURCE);
  79. $__m="Page Pro&perties";
  80. setmenu($__m,macro,"Li&nks",DocInfo_Page_Links,ID_VIEW_IMAGE);
  81. setmenu($__m,macro,"Link&ed Images",DocInfo_Page_LinkedImages,ID_VIEW_IMAGE);
  82. setmenu($__m,macro,"Im&ages",DocInfo_Page_Images,ID_VIEW_IMAGE);
  83. $__m="Frame &Properties";
  84. setmenu($__m,macro,"Li&nks",DocInfo_Frame_Links,ID_VIEW_FRAME_SOURCE);
  85. setmenu($__m,macro,"Link&ed Images",DocInfo_Frame_LinkedImages,ID_VIEW_FRAME_SOURCE);
  86. setmenu($__m,macro,"Im&ages",DocInfo_Frame_Images,ID_VIEW_FRAME_SOURCE);
  87. }
  88. $OnInit=$OnInit."_DocInfo_BuildMenu;";
  89.  
  90. # ------------------------------------------------------------------------------------------------------------------
  91. $macroModules=$macroModules."DocInfo;";