Guest User

Untitled

a guest
Feb 22nd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. var noun_type_xab = {
  2. _name: "xab name",
  3.  
  4. // Returns all tabs from all windows.
  5. getTabs: function(){
  6. var tabs = {};
  7.  
  8. for( var j=0; j < Application.windows.length; j++ ) {
  9. var window = Application.windows[j];
  10. for (var i = 0; i < window.tabs.length; i++) {
  11. var tab = window.tabs[i];
  12. tabs[tab.document.title] = tab;
  13. }
  14. }
  15.  
  16. return tabs;
  17. },
  18.  
  19. suggest: function( text, html ) {
  20.  
  21. var suggestions = [];
  22. var tabs = noun_type_tab.getTabs();
  23.  
  24. //TODO: implement a better match algorithm
  25. for ( var tabName in tabs ) {
  26. if (tabName.match(text, "i"))
  27. suggestions.push( CmdUtils.makeSugg(tabName) );
  28. }
  29.  
  30. // Return a list of input objects, limited to at most five:
  31. return suggestions.splice(0,5);
  32. }
  33. }
  34.  
  35. CmdUtils.CreateCommand({
  36. name: "xab",
  37. takes: {"xab name": noun_type_xab},
  38.  
  39. execute: function( directObj ) {
  40. var tabName = directObj.text;
  41. var tabs = noun_type_tab.getTabs();
  42. CmdUtils.setSelection(tabName);
  43. // tabs[tabName]._window.focus();
  44. // tabs[tabName].focus();
  45. },
  46.  
  47. preview: function( pblock, directObj ) {
  48. var tabName = directObj.text;
  49. if( tabName.length > 1 ){
  50. var msg = "Changes to <b style=\"color:yellow\">%s</b> tab.";
  51. pblock.innerHTML = msg.replace(/%s/, tabName);
  52. }
  53. else
  54. pblock.innerHTML = "Make a macbay link of the tab.";
  55. }
  56. })
Add Comment
Please, Sign In to add comment