Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var noun_type_xab = {
- _name: "xab name",
- // Returns all tabs from all windows.
- getTabs: function(){
- var tabs = {};
- for( var j=0; j < Application.windows.length; j++ ) {
- var window = Application.windows[j];
- for (var i = 0; i < window.tabs.length; i++) {
- var tab = window.tabs[i];
- tabs[tab.document.title] = tab;
- }
- }
- return tabs;
- },
- suggest: function( text, html ) {
- var suggestions = [];
- var tabs = noun_type_tab.getTabs();
- //TODO: implement a better match algorithm
- for ( var tabName in tabs ) {
- if (tabName.match(text, "i"))
- suggestions.push( CmdUtils.makeSugg(tabName) );
- }
- // Return a list of input objects, limited to at most five:
- return suggestions.splice(0,5);
- }
- }
- CmdUtils.CreateCommand({
- name: "xab",
- takes: {"xab name": noun_type_xab},
- execute: function( directObj ) {
- var tabName = directObj.text;
- var tabs = noun_type_tab.getTabs();
- CmdUtils.setSelection(tabName);
- // tabs[tabName]._window.focus();
- // tabs[tabName].focus();
- },
- preview: function( pblock, directObj ) {
- var tabName = directObj.text;
- if( tabName.length > 1 ){
- var msg = "Changes to <b style=\"color:yellow\">%s</b> tab.";
- pblock.innerHTML = msg.replace(/%s/, tabName);
- }
- else
- pblock.innerHTML = "Make a macbay link of the tab.";
- }
- })
Add Comment
Please, Sign In to add comment