diff options
author | anekos | 2009-02-27 13:31:58 +0000 |
---|---|---|
committer | anekos | 2009-02-27 13:31:58 +0000 |
commit | 2dd736586382f41a72faa181999bbe000367740e (patch) | |
tree | 6a6fd188842baa5fee341ed9a771c717ab6e4b7e | |
parent | ac7be85f715265c42f6ab467ffbe50e11f4f77d3 (diff) | |
download | vimperator-plugins-2dd736586382f41a72faa181999bbe000367740e.tar.bz2 |
initial release: IE の Ctrl-A 画像を暴くプラグイン
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@30596 d0d07461-0603-4401-acd4-de1884942a52
-rw-r--r-- | reveal-ie-ctrl-a-images.js | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/reveal-ie-ctrl-a-images.js b/reveal-ie-ctrl-a-images.js new file mode 100644 index 0000000..ed73c3e --- /dev/null +++ b/reveal-ie-ctrl-a-images.js @@ -0,0 +1,141 @@ +/* NEW BSD LICENSE {{{ +Copyright (c) 2009, anekos. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + 3. The names of the authors may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + + +################################################################################### +# http://sourceforge.jp/projects/opensource/wiki/licenses%2Fnew_BSD_license # +# に参考になる日本語訳がありますが、有効なのは上記英文となります。 # +################################################################################### + +}}} */ + +// PLUGIN_INFO {{{ +let PLUGIN_INFO = +<VimperatorPlugin> + <name>Reveal Image</name> + <description>Reveal IE Ctrl-A images.</description> + <description lang="ja">IE の Ctrl-A 画像を暴く</description> + <version>1.0.0</version> + <author mail="anekos@snca.net" homepage="http://d.hatena.ne.jp/nokturnalmortum/">anekos</author> + <license>new BSD License (Please read the source code comments of this plugin)</license> + <license lang="ja">修正BSDライセンス (ソースコードのコメントを参照してください)</license> + <updateURL>http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/ie-grid.js</updateURL> + <minVersion>2.0pre</minVersion> + <maxVersion>2.0</maxVersion> + <detail><![CDATA[ + == Description == + Reveal IE Ctrl-A images. + == Global Variables == + g:ie_grid_mode_normal = 'r': + Hints mode for normal version. + g:ie_grid_mode_reverse = 'R': + Hints mode for reverse version. + ]]></detail> + <detail lang="ja"><![CDATA[ + == Description == + IE の Ctrl-A 画像を暴く + == Global Variables == + g:ie_grid_mode_normal = 'r': + 通常版のヒントモード + g:ie_grid_mode_reverse = 'R': + 反対版のヒントモード + ]]></detail> +</VimperatorPlugin>; +// }}} + +(function () { + let ieimg = 'data:image/gif;base64,'+ + 'R0lGODlhAgACAIABAF6BvP///yH+EUNyZWF0ZWQgd2l0aCBHSU1QACH5BAEKAAEALAAAAAACAAIA'+ + 'AAIDRAIFADs='; + + function getPosition (elem) { + return { + x: elem.offsetLeft || 0, + y: elem.offsetTop || 0 + }; + } + + function getAbsPosition (elem) { + let p = getPosition(elem); + liberator.log(p) + if (elem.offsetParent) { + let q = getAbsPosition(elem.offsetParent); + return { + x: p.x + q.x, + y: p.y + q.y, + }; + } else { + return p; + } + } + + function reveal (elem, sec, zura) { + if (sec <= 0) + sec = 2; + let body = elem.ownerDocument.body; + let indicator = elem.ownerDocument.createElement('div'); + let pos = getAbsPosition(elem); + //let rect = elem.getBoundingClientRect(); + indicator.id = 'detect-hidden-indicator'; + let style = 'background-image: url(' + ieimg + ');' + + //'opacity: 0.8;' + //TODO + 'background-repeat: repeat;' + + 'z-index: 999;' + + 'position: absolute; ' + + 'top: ' + (pos.y + (zura ? 1 : 0)) + 'px;' + + 'height:' + elem.clientHeight + 'px;'+ + 'left: ' + pos.x + 'px;' + + 'width: ' + elem.clientWidth + 'px'; + indicator.setAttribute('style', style); + body.appendChild(indicator); + setTimeout(function () body.removeChild(indicator), sec * 1000); + } + + // for debug + if (0) { + let xpath = '/html/body/div[2]/div[3]/table/tbody/tr/td[2]/div/table/tbody/tr/td[2]/div/img'; + let node = buffer.evaluateXPath(xpath).snapshotItem(0); + reveal(node, 1); + } + + [ + ['r', false], + ['R', true] + ].forEach(function ([mode, zura]) { + hints.addMode( + mode, + 'description', + function (elem, loc, count) { + reveal(elem, count, zura); + }, + function () '//img' + ); + }); + +})(); + +// vim:sw=2 ts=2 et si fdm=marker: + |