Changeset 37011
- Timestamp:
- 03/14/10 20:07:23 (3 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/vimperator-plugins/trunk/tabsort.js
r35099 r37011 37 37 <VimperatorPlugin> 38 38 <name>tabsort</name> 39 <description>Add ":tabsort" command.</description>40 <description lang="ja"> tabsortコマンドを追加する</description>41 <version>1. 0.1</version>39 <description>Add ":tabsort" and ":tabuniq" command.</description> 40 <description lang="ja">":tabsort", ":tabuniq" コマンドを追加する</description> 41 <version>1.1.0</version> 42 42 <author mail="anekos@snca.net" homepage="http://d.hatena.ne.jp/nokturnalmortum/">anekos</author> 43 <minVersion>2. 2pre</minVersion>44 <maxVersion>2. 2pre</maxVersion>43 <minVersion>2.3</minVersion> 44 <maxVersion>2.3</maxVersion> 45 45 <updateURL>http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/tabsort.js</updateURL> 46 46 <license>new BSD License (Please read the source code comments of this plugin)</license> … … 69 69 function (a, b) a[name].toString().localeCompare(b[name].toString()); 70 70 71 function getTabs () [ 72 { 73 index: i, 74 tab: tab, 75 doc: #1=(tab.linkedBrowser.contentDocument), 76 url: #1#.location.href, 77 title: #1#.title, 78 } 79 for ([i, tab] in util.Array(config.browser.mTabs)) 80 ]; 81 82 function tabUniq (cmp) { 83 let rms = []; 84 let tabs = getTabs(); 85 86 for (let [i, tabA] in Iterator(tabs)) { 87 for each (let tabB in tabs.slice(i + 1)) { 88 if (cmp(tabA, tabB) === 0) 89 rms.push(tabB); 90 } 91 } 92 93 rms.forEach(function (rm) config.tabbrowser.removeTab(rm.tab)); 94 } 95 71 96 function tabSort (cmp) { 72 let nbrowsers = getBrowser().browsers.length; 73 let ts = []; 74 for (let [i,] in tabs.browsers) { 75 let b = getBrowser().getBrowserAtIndex(i); 76 let c = b.contentDocument; 77 ts.push({ 78 index: i, 79 tab: gBrowser.mTabs[i], 80 url: c.location.href, 81 title: c.title 82 }); 83 } 84 ts.sort(cmp).forEach(function (it, i) (i == it.index) || getBrowser().moveTabTo(it.tab, i)); 97 getTabs().sort(cmp).forEach(function (it, i) (i == it.index) || config.tabbrowser.moveTabTo(it.tab, i)); 85 98 } 86 99 … … 93 106 targetOptions.some(function ([n,]) n == value); 94 107 108 function completer (context) { 109 context.title = ['Target', 'Action']; 110 context.completions = targetOptions; 111 } 112 113 commands.addUserCommand( 114 ['tabu[niq]'], 115 'Uniq tabs', 116 function (arg) { 117 tabUniq(memberCompare(arg[0] || arg['-target'] || 'url')); 118 }, 119 { 120 options: [ 121 [['-target', '-t'], commands.OPTION_STRING, targetValidater, targetOptions], 122 ], 123 completer: completer 124 }, 125 true 126 ); 127 95 128 commands.addUserCommand( 96 129 ['tabso[rt]'], 97 130 'Sort tabs', 98 131 function (arg) { 99 tabSort(memberCompare(arg[ '-target'] || 'title'));132 tabSort(memberCompare(arg[0] || arg['-target'] || 'title')); 100 133 }, 101 134 { 102 argCount: '0',103 135 options: [ 104 136 [['-target', '-t'], commands.OPTION_STRING, targetValidater, targetOptions], 105 137 ], 138 completer: completer 106 139 }, 107 140 true
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)