Changeset 36928
- Timestamp:
- 03/04/10 20:26:43 (3 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/vimperator-plugins/trunk/feedSomeKeys_3.js
r36927 r36928 40 40 <description>feed some defined key events into the Web content</description> 41 41 <description lang="ja">キーイベントをWebコンテンツ側に送る</description> 42 <version>1. 5.2</version>42 <version>1.6.0</version> 43 43 <author mail="anekos@snca.net" homepage="http://d.hatena.ne.jp/nokturnalmortum/">anekos</author> 44 44 <license>new BSD License (Please read the source code comments of this plugin)</license> … … 172 172 const EVENTS = 'keypress keydown keyup'.split(/\s+/); 173 173 const EVENTS_WITH_V = EVENTS.concat(['v' + n for each (n in EVENTS)]); 174 const IGNORE_URLS = /<ALL>/; 174 175 175 176 const VKeys = { … … 306 307 (values && !values.some(function (value) !list.some(function (event) event === value))); 307 308 308 function unmap (filter, patternOrUrl, ignoreUrls) { 309 let result = 0; 310 309 function findMappings ({all, filter, urls, ignoreUrls, not, result}) { 311 310 function match (map) { 312 311 let r = ( 313 312 map.feedSomeKeys && 314 (!filter || filter === map.names[0]) && 315 (ignoreUrls || mappings._matchingUrlsTest(map, patternOrUrl)) 313 (all || 314 (!filter || filter === map.names[0]) && 315 (ignoreUrls || urls === IGNORE_URLS || mappings._matchingUrlsTest(map, urls))) 316 316 ); 317 result++; 318 return r; 317 if (result && r) { 318 if (typeof result.matched === 'number') 319 result.matched++; 320 else 321 result.matched = 1; 322 } 323 return !!r ^ !!not; 319 324 } 320 325 321 let mode = modes.NORMAL;322 mappings._user[mode] = [323 map324 for each (map in mappings._user[mode])325 if (!match(map))326 ];327 return result;328 }329 330 function gets (filter) {331 326 if (filter) 332 327 filter = mappings._expandLeader(filter); 333 return [ 334 map 335 for (map in mappings._mappingsIterator([modes.NORMAL], mappings._user)) 336 if (map.feedSomeKeys && (!filter || map.names[0] == filter)) 337 ]; 338 } 339 340 function list (filter) { 341 let maps = gets(filter); 328 if (urls) 329 urls = RegExp(urls); 330 331 return mappings._user[modes.NORMAL].filter(match); 332 } 333 334 function unmap (condition) { 335 condition.not = true; 336 mappings._user[modes.NORMAL] = findMappings(condition); 337 } 338 339 function list (condition) { 340 let maps = findMappings(condition); 342 341 let template = modules.template; 343 342 let list = … … 347 346 template.map(map.names, function (name) 348 347 <tr> 349 <td >{name}</td>350 <td >{map.feedSomeKeys.rhs}</td>348 <td style="font-weight: bold">{name}</td> 349 <td style="font-weight: bold">{map.feedSomeKeys.rhs}</td> 351 350 <td>{map.matchingUrls ? map.matchingUrls : '[Global]'}</td> 352 351 </tr>)) … … 368 367 map.feedSomeKeys.rhs + ' for ' + (map.matchingUrls ? map.matchingUrls : 'Global') 369 368 ] 370 for each (map in gets())369 for each (map in findMappings({urls: args['-urls'], ignoreUrls: args['-ignoreurls']})) 371 370 ]; 372 371 } 373 372 374 373 function urlCompleter (context, args) { 375 let maps = gets();374 let maps = findMappings({all: true}); 376 375 let uniq = {}; 377 376 return [ … … 419 418 matchingUrls: args['-urls'], 420 419 feedSomeKeys: { 421 rhs: rhs 420 rhs: rhs, 422 421 } 423 422 }, … … 432 431 let [, lhs, rhs] = args.literalArg.match(/^(\S+)\s+(.*)$/) || args.literalArg; 433 432 if (!rhs) { 434 list(args.literalArg.trim()); 433 list({ 434 filter: args.literalArg.trim(), 435 urls: args['-urls'], 436 ignoreUrls: !args['-urls'] 437 }); 435 438 } else { 436 439 add([lhs, rhs]); … … 471 474 function (args) { 472 475 if (args.bang) { 473 unmap( null, null, true);474 liberator.log('All fmappings were removed ');476 unmap({ignoreUrls: true}); 477 liberator.log('All fmappings were removed.'); 475 478 } else { 476 let urls = args.literalArg; 477 liberator.echo( 478 unmap(null, urls && RegExp(urls), false) ? 479 'Some fmappings were removed' : 480 'Not found specifed fmappings' 481 ); 479 let result = {}; 480 unmap({urls: args.literalArg, result: result}); 481 liberator.echo(result.matched ? 'Some fmappings were removed.' : 'Not found specifed fmappings.'); 482 482 } 483 483 }, … … 502 502 return liberator.echoerr('E471: Argument required'); 503 503 504 liberator.echo( 505 unmap(name, urls && RegExp(urls), args['-ignoreurls']) ? 506 'Some fmappings were removed' : 507 'Not found specifed fmappings' 508 ); 504 let result = {}; 505 unmap({filter: name, urls: urls, ignoreUrls: args['-ignoreurls'], result: result}); 506 liberator.echo(result.matched ? 'Some fmappings were removed.' : 'Not found specifed fmappings.'); 509 507 }, 510 508 { … … 531 529 532 530 __context__.API = 533 'VKeys feed getFrames fromXPath virtualize unmap gets list'.split(/\s+/).reduce(531 'VKeys feed getFrames fromXPath virtualize unmap findMappings list'.split(/\s+/).reduce( 534 532 function (result, name) 535 533 (result[name] = eval(name), result),
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)