Personal tools
You are here: Home ブログ hamabe LDRize + iframe
« 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 + iframe


LDRizeを自分用にカスタマイズしたものが意外と評判よかったので公開します。


主な特徴

  • 『i』キーを押すと、iframeでその場にページを開きます

  • iframe内のページはSpace, Shift-Spaceキーでスクロールできます
  • 1番目の項目は自動で開いてFeeling Lucky♪ (Googleのみ有効)


[ScreenShot]

LDRize+iframe



メモ書き

  • iframe内に開いた異なるドメインのサイトは、セキュリティ上JavaScriptによる操作はできない
  • 今回はスクロールしたいだけだったので、以下のような感じでおk
addEventListener(document, 'keydown', function(e){
if(e.keyCode == 32){
$('_iframe').contentWindow.focus();
setTimeout(function(){ window.focus() }, 0);
}
}, false);
  • ただし上のはカレント項目がiframeで開かれているときのみ発動させる
  • I'm Feeling Luckyがウザい人はLDRize.initの最後の一行を削除でおk
  • 以下のパッチを各自よくみて、自己責任でお願いします


:ldrize.patch

*** 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());

ldrize.patch ldrize.patch
Size 3.8 kB - File type text/x-patch
ldrize.user.js ldrize.user.js
Size 55.0 kB - File type application/x-javascript
The URL to Trackback this entry is:
http://dev.ariel-networks.com/Members/hamabe/ldrize-iframe/tbping
Add comment

You can add a comment by filling out the form below. Plain text formatting.

(Required)
(Required)
(Required)
(Required)
(Required)
This helps us prevent automated spamming.
Captcha Image


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