aboutsummaryrefslogtreecommitdiffstats
path: root/tombloo.js
diff options
context:
space:
mode:
authorretlet2008-11-05 06:04:44 +0000
committerretlet2008-11-05 06:04:44 +0000
commitc4489d32e21b8548976fec780eff4df613697a53 (patch)
tree1ecf88b6f2d562dde2f06e4824d7916f83fe4d8c /tombloo.js
parent56cb882fc6f122c75608f8eb6142a607d3dc855f (diff)
downloadvimperator-plugins-c4489d32e21b8548976fec780eff4df613697a53.tar.bz2
手元の環境で動いているものをtags/2.0pre_1016からコピー
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/branches/1.2@22751 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'tombloo.js')
-rw-r--r--tombloo.js72
1 files changed, 72 insertions, 0 deletions
diff --git a/tombloo.js b/tombloo.js
new file mode 100644
index 0000000..085287d
--- /dev/null
+++ b/tombloo.js
@@ -0,0 +1,72 @@
+/**
+ * ==VimperatorPlugin==
+ * @name tombloo.js
+ * @description Tombloo integrate plugin
+ * @description-ja Tombloo経由で選択領域などをpostする
+ * @author Trapezoid
+ * @version 0.1d
+ * ==/VimperatorPlugin==
+ *
+ * Usage:
+ * :tombloo arg -> post by Tombloo (don't use prompt)
+ * :tombloo! arg -> post by Tombloo (use prompt)
+ * :tomblooAction arg -> execute Tombloo's action in tool menu
+ **/
+var TomblooService = Components.classes['@brasil.to/tombloo-service;1'].getService().wrappedJSObject;
+function update(target,src,keys){
+ if(keys){
+ keys.forEach(function(key){
+ target[key] = src[key];
+ });
+ } else {
+ for(let key in src)
+ target[key] = src[key];
+ }
+
+ return target;
+}
+
+function getContext(){
+ var doc = window.content.document;
+ var win = window.content.wrappedJSObject;
+ return update(update({
+ document : doc,
+ window : win,
+ title : ''+doc.title || '',
+ selection : ''+win.getSelection(),
+ target : doc,
+ //event : event,
+ //mouse : mouse,
+ //menu : gContextMenu,
+ },{}),win.location);
+}
+
+liberator.commands.addUserCommand(['tomblooAction'],'Execute Tombloo actions',
+ function(arg){
+ TomblooService.Tombloo.Service.actions[arg].execute();
+ },{
+ completer: function(filter){
+ var completionList = new Array();
+ for(let name in TomblooService.Tombloo.Service.actions)
+ if(name.indexOf(filter) > -1)
+ completionList.push([name,name]);
+ return [0,completionList];
+ }
+ }
+);
+
+liberator.commands.addUserCommand(['tombloo'],'Post by Tombloo',
+ function(arg,special){
+ TomblooService.Tombloo.Service.share(getContext(),TomblooService.Tombloo.Service.extractors[arg],special);
+ },{
+ bang: true,
+ completer: function(filter){
+ var completionList = new Array();
+ var exts = TomblooService.Tombloo.Service.check(getContext());
+ for(let i=0,l=exts.length; i < l; i++)
+ if(exts[i].name.indexOf(filter) > -1)
+ completionList.push([exts[i].name,exts[i].name]);
+ return [0,completionList];
+ }
+ }
+);