From 18a1cb21fced55e4c8fd68461ef02d29055cfe26 Mon Sep 17 00:00:00 2001 From: motemen Date: Tue, 16 Jun 2009 16:02:34 +0000 Subject: hint-tombloo.js git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@34009 d0d07461-0603-4401-acd4-de1884942a52 --- hint-tombloo.js | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 hint-tombloo.js (limited to 'hint-tombloo.js') 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 = + +{NAME} +Hint mode for Tombloo +motemen +0.1 +2.0pre +2.0pre +http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/hint-tombloo.js + +; + +(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 +); + +})(); -- cgit v1.2.3