diff options
author | motemen | 2009-06-16 16:02:34 +0000 |
---|---|---|
committer | motemen | 2009-06-16 16:02:34 +0000 |
commit | 18a1cb21fced55e4c8fd68461ef02d29055cfe26 (patch) | |
tree | 1ba74241d35381601786e58a74826820d696d3c0 /hint-tombloo.js | |
parent | ddde424838d049f9df8f775c921f345e29da8bfd (diff) | |
download | vimperator-plugins-18a1cb21fced55e4c8fd68461ef02d29055cfe26.tar.bz2 |
hint-tombloo.js
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@34009 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'hint-tombloo.js')
-rw-r--r-- | hint-tombloo.js | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/hint-tombloo.js b/hint-tombloo.js new file mode 100644 index 0000000..143a9b5 --- /dev/null +++ b/hint-tombloo.js @@ -0,0 +1,75 @@ +var PLUGIN_INFO = +<VimperatorPlugin> +<name>{NAME}</name> +<description>Hint mode for Tombloo</description> +<author>motemen</author> +<version>0.1</version> +<minVersion>2.0pre</minVersion> +<maxVersion>2.0pre</maxVersion> +<updateURL>http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/hint-tombloo.js</updateURL> +<detail><![CDATA[ +== SETTINGS == + +let g:hint_tombloo_key = 'R' +let g:hint_tombloo_xpath = '//img' + +== MAPPINGS == +;R : + Share target element by Tombloo + +]]></detail> +</VimperatorPlugin>; + +(function () { + +var hintKey = liberator.globalVariables.hint_tombloo_key || 'R'; +var hintXPath = liberator.globalVariables.hint_tombloo_xpath || '//img'; + +hints.addMode( + hintKey, + 'Share by Tombloo', + function (elem) { + var tomblooService = Cc['@brasil.to/tombloo-service;1'].getService().wrappedJSObject.Tombloo.Service; + + var d = window.content.document; + var w = window.content.wrappedJSObject; + var context = { + document: d, + window: w, + title: d.title, + target: elem, + }; + for (let p in w.location) { + context[p] = w.location[p]; + } + + var extractors = tomblooService.check(context); + + liberator.modules.commandline.input( + 'Extractor: ', + function (string) { + var extractor; + for (let i = 0; i < extractors.length; i++) { + if (extractors[i].name == string) { + extractor = extractors[i]; + break; + } + } + if (!extractor) return; + + tomblooService.share(context, extractor, true); + }, + { + completer: function (context) { + context.title = ['Tombloo Extractors']; + context.completions = extractors.map( + function (_) [ _.name, _.name ] + ); + } + } + ); + }, + function () hintXPath +); + +})(); |