Personal tools
You are here: Home ブログ hamabe Stuff ldrize.patch
« December 2010 »
Su Mo Tu We Th Fr Sa
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
Recent comments
Re:コマンド入力を実装しよう inoue 2007-08-14
 
Document Actions

ldrize.patch

Greasemonkey用スクリプトのLDRize[http://userscripts.org/scripts/show/11562]に当てたパッチ

Click here to get the file

Size 3.8 kB - File type text/x-patch

File contents

*** 11562.user.js	2007-10-31 01:20:50.000000000 +0900
--- ldrize.user.js	2007-10-31 01:23:38.000000000 +0900
***************
*** 16,21 ****
--- 16,22 ----
  	  'S-j' : 'NextPage',
  	  'S-k' : 'PrevPage',
  	  'v'   : 'View',
+ 	  'i'   : 'Iframe',
  	  'p'   : 'Pin',
  	  'o'   : 'Open',
  	  'l'   : 'List',
***************
*** 31,36 ****
--- 32,38 ----
  	  'NextPage'       : 'Scroll next page',
  	  'PrevPage'       : 'Scroll prev page',
  	  'View'           : 'Open in current tab',
+ 	  'Iframe'         : 'Open in iframe',
  	  'Pin'            : 'Pin',
  	  'Open'           : 'Open pinned items or current item',
  	  'List'           : 'Toggle pinned items list',
***************
*** 199,204 ****
--- 201,207 ----
  		  }
  
  		  LDRize._enable = true;
+ 		  document.addEventListener('keydown', LDRize.focusOnIframe, false);
  		  document.addEventListener('keypress', LDRize.handleKey, false);
  		  document.addEventListener('mousemove', function(){LDRize.invisibleRemove(LDRize.invisiblelist)}, true);
  		  LDRize.initCommand();
***************
*** 216,221 ****
--- 219,225 ----
  		  css += LDRize.setCSS();
  		  css += LDRize.initSpace();
  		  if(css != '') addStyle(css);
+ 		  if(window.document.URL.match(/http:\/\/.*google.*\/.*/)) LDRize.viewCurrent('iframe');
  	  }
    },
    initBindCommand : function(){
***************
*** 224,229 ****
--- 228,235 ----
  	  LDRize.bindNextPage  = LDRize.scrollNextPage;
  	  LDRize.bindPrevPage  = LDRize.scrollPrevPage;
  	  LDRize.bindView  = function(){LDRize.viewCurrent('here')};
+ 	  LDRize.bindIframe  = function(){LDRize.viewCurrent('iframe')};
+ 	  LDRize.bindIframeFocus  = LDRize.iframeFocus;
  	  LDRize.bindPin   = LDRize.attachPin;
  	  LDRize.bindOpen  = LDRize.openPinned;
  	  LDRize.bindList  = LDRize.togglePinList;
***************
*** 758,763 ****
--- 764,771 ----
  	  if(LDRize.css_highlight_link) css += "\n.gm_ldrize_link {" + LDRize.css_highlight_link + "}";
  	  if(LDRize.css_highlight_pinned) css += "\n.gm_ldrize_pinned {" + LDRize.css_highlight_pinned + "}";
  	  css += ".gm_ldrize_invisible { visibility:hidden; }";
+ 	  css += ".gm_ldrize_iframe { border:3px ridge #6f6 !important; }";
+ 	  css += ".gm_ldrize_iframe iframe { width:100% !important; min-height:200px !important; border:none !important; }";
  	  return css;
    },
  
***************
*** 1091,1101 ****
--- 1099,1133 ----
  		  LDRize.scrollNext();
  	  }else if(type=='here'){
  		  window.location.href = url;
+ 	  }else if(type=='iframe'){
+ 		  if(!LDRize.current_parapraph) return;
+ 		  var node = LDRize.current_parapraph.lastChild;
+ 		  if(!node || (node.nodeType == 1 && node.className.match(/gm_ldrize_iframe/))) return;
+ 		  if(url.match(/.pdf$/)){ LDRize.viewCurrent('here'); return; }
+ 		  var div = document.createElement('div');
+ 		  div.setAttribute('class', 'gm_ldrize_iframe');
+ 		  var iframe = document.createElement('iframe');
+ 		  iframe.style.height = (window.innerHeight - LDRize.current_parapraph.offsetHeight - 25) + ' !important;';
+ 		  iframe.src = url;
+ 		  iframe.addEventListener('load', function(){ window.focus() }, false);
+ 		  div.appendChild(iframe);
+ 		  LDRize.current_parapraph.appendChild(div);
  	  }else{
  		  window.open(url);
  	  }
    },
  
+ // space
+   focusOnIframe : function(event) {
+ 	  if(event.keyCode != 32) return;
+ 	  if(/input|textarea/i.test(event.target.tagName)) return;
+ 	  if(!LDRize.current_parapraph) return;
+ 	  var node = LDRize.current_parapraph.lastChild;
+ 	  if(!node || node.nodeType != 1 || !node.className.match(/gm_ldrize_iframe/)) return;
+ 	  node.firstChild.contentWindow.focus();
+ 	  setTimeout(function(){ window.focus() }, 0);
+   },
+ 
  // ?
    toggleHelpMessage : function(){
  	  return (LDRize.hideHelpMessage() || LDRize.showHelpMessage());

Copyright(C) 2001 - 2006 Ariel Networks, Inc. All rights reserved.