Пример #1
0
 var assignHotKeys = function () {
   return hotkeys.Hotkey({
     combo: "accel-alt-shift-c",
     onPress: function() {
       loadCachedPage ();
     }
   });
 };
Пример #2
0
exports["test no exception on unmodified keypress"] = function(assert) {
  var element = require("window-utils").activeBrowserWindow.document.documentElement;
  var someHotkey = Hotkey({
    combo: "control-alt-1",
    onPress: function() {
    }
  });
  keyDown(element, "a");
  assert.pass("No exception throw, unmodified keypress passed");
};
Пример #3
0
(function(){
    const { Hotkey } = require("hotkeys");
    const {Panel } = require("panel");
    const tabs  = require("tabs");
    const data = require("self").data;
    const fileUtils = require("fireedit/fileUtils");
    const {Cc, Ci } = require("chrome");
    const nsIFP = Ci.nsIFilePicker;

    // bind the editor to ctrl-shift-e
    var toggleHotKey = Hotkey({
        combo: "control-shift-e",
        onPress: function() {
            wireupEditor();
        }
    });

    /**
     *  Wires up the editor, opens it in a new tab, setsup workers
     **/
    function wireupEditor() {
        tabs.open({
            url: data.url("editor.html"),
            onReady: function(tab) {
                var worker = tab.attach({
                    contentScriptFile: [data.url("ff-integration.js") ]
                });
                worker.port.on("openFile", function(dummypath){
                    try{
                        var window = require("window-utils").activeWindow;
                        var filePicker = Cc["@mozilla.org/filepicker;1"].createInstance(nsIFP);
                        var path = "";

                        filePicker.init(window, "Choose JS file", nsIFP.modeOpen);

                        var res = filePicker.show();
                        path = filePicker.file.path;
                        var contents = fileUtils.openFile(path);
                        worker.port.emit("fileContents", contents);
                    }catch(error) {
                        console.log(error);
                    }
                });
                worker.port.on("saveFile", function(dataWithPath) {
                    try{
                        fileUtils.writeFile(dataWithPath.path, dataWithPath.contents);
                    }catch(error) {
                        console.log(error);
                    }
                });
            }
        });
    }
}());
Пример #4
0
function setHotKey(key, panel) {
	
	const { Hotkey } = require("hotkeys");
    // attach hotkey
    var showHotKey = Hotkey( {
	    combo: key,
	    onPress: function() {
		toggleFireTrack(panel);
	    }
	});
	return showHotKey;
}
Пример #5
0
exports.main=function(options){

if(options.loadReason=="install"){
	require("tabs").open(data.url("welcome.html")); //Welcome HTML file
	//Configurar con pagina XUL o HTML o Javascript
	
}
if(options.loadReason=="upgrade"){
	require("tabs").open(data.url("changelog.html")); //Changelog HTML file
}

 var mm = require("context-menu");
 var menuItem = mm.Item({
  label: "Share on Google+",
  contentScript: 'self.on("click", function () {' +
                 '  self.postMessage(document.URL);' +
                 '});',
  onMessage: function (url) {
    ShareURL(url);
  }
});
var shareHotKey = Hotkey({
  combo: prefs.hotkey,
  //combo: "accel-shift-s",
  onPress: function() {
    ShareURL(tab.activeTab.url);
  }
});

require("simple-prefs").on("review",function (){
	require("tabs").open("http://addons.mozilla.org/en/firefox/addon/google-share");
});


var pluspanel=panel.Panel({
	height: prefs.height,
	width: prefs.width,
	contentURL: "about:blank"

});

var pluswidget=widget.Widget({
	id: "google-share-widget",
	label: "Google+ Share",
	contentURL: data.url("icon64.png"), 	
	panel: pluspanel,
	onClick: function() {
		pluspanel.contentURL="http://plus.google.com/share?url="+tab.activeTab.url;		
	}
});


}
Пример #6
0
exports["test hotkey: function key"] = function(assert, done) {
  var element = require("window-utils").activeBrowserWindow.document.documentElement;
  var showHotKey = Hotkey({
    combo: "f1",
    onPress: function() {
      assert.pass("first callback is called");
      keyDown(element, "f2");
      showHotKey.destroy();
    }
  });

  var hideHotKey = Hotkey({
    combo: "f2",
    onPress: function() {
      assert.pass("second callback is called");
      hideHotKey.destroy();
      done();
    }
  });

  keyDown(element, "f1");
};
Пример #7
0
exports["test hotkey: control alt ! -"] = function(assert, done) {
  var element = require("window-utils").activeWindow.document.documentElement;
  var showHotKey = Hotkey({
    combo: "control-!",
    onPress: function() {
      assert.pass("first callback is called");
      keyPress(element, "meta--");
      showHotKey.destroy();
    }
  });

  var hideHotKey = Hotkey({
    combo: "meta--",
    onPress: function() {
      assert.pass("second callback is called");
      hideHotKey.destroy();
      done();
    }
  });

  keyPress(element, "control-!");
};
Пример #8
0
exports["test hotkey meta & control"] = function(assert, done) {
  var element = require("window-utils").activeWindow.document.documentElement;
  var showHotKey = Hotkey({
    combo: "meta-3",
    onPress: function() {
      assert.pass("first callback is called");
      keyPress(element, "alt-control-shift-b");
      showHotKey.destroy();
    }
  });

  var hideHotKey = Hotkey({
    combo: "Ctrl-Alt-Shift-B",
    onPress: function() {
      assert.pass("second callback is called");
      hideHotKey.destroy();
      done();
    }
  });

  keyPress(element, "meta-3");
};
Пример #9
0
exports["test hotkey: accel alt shift"] = function(assert, done) {
  var element = require("window-utils").activeWindow.document.documentElement;
  var showHotKey = Hotkey({
    combo: "accel-shift-p",
    onPress: function() {
      assert.pass("first callback is called");
      keyPress(element, "accel-alt-shift-p");
      showHotKey.destroy();
    }
  });

  var hideHotKey = Hotkey({
    combo: "accel-alt-shift-p",
    onPress: function() {
      assert.pass("second callback is called");
      hideHotKey.destroy();
      done();
    }
  });

  keyPress(element, "accel-shift-p");
};
Пример #10
0
 updatePrefs: function(p) {
   //update hotkey
   if (prefs.prefs[p].length === 1 && prefs.prefs[p] !== "") {
     main.translateHotkey.destroy();
     main.translateHotkey = Hotkey({
       combo: main.modifier + prefs.prefs[p],
       onPress: function() {
         main.translatePage(tabs.activeTab.url);
       }
     });
   } else {
     main.notify("Settings Error", "Make sure you enter a valid key code that is one character.");
   }
 }
Пример #11
0
exports.init = function () {

  this.log('Binding tabs "onActivate" event...');
  tabs.on('activate', function (tab) {
    require('module-page-ruler').checkTabStatus(tab);
  });
  this.log('Binding tabs "onActivate" event... Done.');

  this.log('Loading the pageMod...');
  myPageMod = pageMod.PageMod({
    include: "*",
    contentScriptWhen: 'end',
    contentScriptFile: [
      data.url("page-ruler.js")
    ],
    onAttach: function onAttach(worker) {
      worker.port.emit('init', tabs.activeTab.url);
      worker.port.on('init', function (message) {
        if (message == 'true')
          require('module-page-ruler').addWorker(worker);
      });
    }
  });
  this.log('Loading the pageMod... Done.');

  this.log('Loading the widget...');
  myWidget = widgets.Widget({
    id: "page-ruler",
    label: "Page ruler",
    contentURL: data.url("favicon.off.ico"),
    onClick: function() {
      require('module-page-ruler').enable('Widget clicked.');
    }
  });
  this.log('Loading the widget... Done.');

  this.log('Loading the hotkey...');
  myHotkey = Hotkey({
    combo: "control-m",
    onPress: function() {
      require('module-page-ruler').enable("Hotkey pressed.");
    }
  });
  this.log('Loading the hotkey... Done.');
};
Пример #12
0
 assert.throws(function() {
   Hotkey({
     combo: "d",
     onPress: function() {}
   });
 }, "throws if no modifier is present");
Пример #13
0
}

function next() {
    current_index += 1;
    if (current_index == 20) {
        Logger.log("4,END");
        return;
    }
    var url = URLs[current_index];
    tabs.activeTab.url = url;
}

Hotkey({
    combo: "accel-1",
    onPress: function() {
        Logger.log("3,1");
        next();
    }
});

Hotkey({
    combo: "accel-2",
    onPress: function() {
        Logger.log("3,2");
        next();
    }
});

Hotkey({
    combo: "accel-3",
    onPress: function() {
Пример #14
0
const {Cc, Ci, Cu} = require('chrome');
const lm = Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
const wm = Cc['@mozilla.org/appshell/window-mediator;1'].getService(Ci.nsIWindowMediator);

var { Hotkey } = require("hotkeys");

var showHotKey = Hotkey({
    combo: "alt-z",
    onPress: function() {
        fillDoc(wm.getMostRecentWindow('navigator:browser').gBrowser.contentWindow);
    }
});



function fillDoc(win) {
    var frames = win.frames;
    
    var doc = win.document;
    var forms = doc.forms;
    if (!forms || forms.length == 0) return;
	Cu.reportError("_fillDocument processing " + forms.length + " forms on " + doc.documentURI);
	for (var i = 0; i < forms.length; i++) {
		var form = forms[i];
		Cu.reportError("_fillDocument processing form[" + i + "]");
        var filled = lm.fillForm(form);
		Cu.reportError('form ' + i + ': ' + filled);
        if (filled) {
            doc.defaultView.alert('filled');
        }
	} // foreach form
Пример #15
0
var data = require('self').data;
var { Hotkey } = require("hotkeys");
var tabs = require("tabs");
var gist_url_rx = /^https:\/\/gist.github.com\/[\d]+$/;

require("page-mod").PageMod({
	include: gist_url_rx,
	contentScriptFile: [data.url('jquery.js'), data.url('cs.js')]
});
 
var showHotKey = Hotkey({
	combo: "accel-z",
	onPress: function() {
		if (!gist_url_rx.test(tabs.activeTab.url)) {
			return;
		}
		var gist_id = /.+\/([\d]+)$/.exec(tabs.activeTab.url).pop();
	var gist_io_url = 'http://gist.io/'+ gist_id;
	tabs.activeTab.url = gist_io_url;
	}
});

Пример #16
0
 init: function() {
   //keyboard shortcut for translating whole entire page
   main.translateHotkey = Hotkey({
     combo: main.modifier + main.settings("keyCode"),
     onPress: function() {
       main.translatePage(tabs.activeTab.url);
     }
   });
   //set button in addon bar
   //BUG: Events will stop working when button is moved around. Will continue working again when browser is restarted
   main.translateWidget = widget.Widget({
       id: "translate-button",
       label: main.name + " - Translate Page",
       contentURL: main.iconSmall,
       contentScriptWhen: 'ready',
       contentScriptFile: main.widget
   });
   //check for left click, if there is a left click open a new tab with the translated version of the page
   main.translateWidget.port.on('left-click', function() {
       main.translatePage(tabs.activeTab.url, main.settings("language"));
   });
   //This used to open a settings panel, now direct users to about:addons
   main.translateWidget.port.on('right-click', function() {
       main.notify("Just a note...", "The settings panel has moved, you can find it under the addons area.")
       tabs.open("about:addons");
   });
   //Translate selection
   main.menuItem = contextMenu.Item({
       label: main.name + " - Selection",
       image: main.iconSmall,
       // Show this item when a selection exists.
       context: contextMenu.SelectionContext(),
       // When this item is clicked, post a message to the item with the text
       contentScript: 'self.on("click", function () {' +
                      '  self.postMessage(window.getSelection().toString());' +
                      '});',
       //Translate text
       onMessage: function(text) {
         main.translateText(text);
       }
   });
   //Translate current page
   main.pageItem = contextMenu.Item({
     label: main.name + " - Page",
     image: main.iconSmall,
     contentScript: 'self.on("click", function () {' +
                    '  self.postMessage(document.URL);' +
                    '});',
     onMessage: function(url) {
       main.translatePage(url);
     }
   });
   //Translate links
   main.linkItem = contextMenu.Item({
     label: main.name + " - Link",
     image: main.iconSmall,
     // Show this item when a selection exists.
     context: contextMenu.SelectorContext("a[href]"),
     // When this item is clicked, post a message to the item with the link's URL
     contentScript: 'self.on("click", function (node) {' +
                    '   self.postMessage(node.href);' +
                    '});',
     onMessage: function (url) {
       main.translatePage(url);
     }
   });
   return this;
 },
Пример #17
0
function start() {
  Hotkey({ combo: 'accel-alt-j', onPress: scratch })
}
Пример #18
0
(function(){
    const { Hotkey } = require("hotkeys");
    const {Panel } = require("panel");
    const tabs  = require("tabs");
    const data = require("self").data;
    const fileUtils = require("fireedit/fileUtils");
    const {Cc, Ci } = require("chrome");
    const nsIFP = Ci.nsIFilePicker;
    const cm = require("context-menu");
    const preferenceService = require("preferences-service")

    // bind the editor to ctrl-shift-f
    var toggleHotKey = Hotkey({
        combo: "control-shift-f",
        onPress: function() {
            wireupEditor();
        }
    });

    cm.Item({
        label: "FireEdit",
        contentScript: "self.on('click', self.postMessage)",
        onMessage: function() {
            wireupEditor();
        }
    });


    /**
     *  Wires up the editor, opens it in a new tab, setsup workers
     **/
    function wireupEditor() {
        var preferencePrefix = "extensions.fireedit.";

        tabs.open({
            url: data.url("editor.html"),
            onReady: function(tab) {
                // create a page-mod
                var worker = tab.attach({
                    contentScriptFile: [data.url("jquery.js"),data.url("ff-integration.js") ]
                });
                worker.port.on("openFile", function(dummypath){
                    try{
                        var window = require("window-utils").activeWindow;
                        var filePicker = Cc["@mozilla.org/filepicker;1"].createInstance(nsIFP);
                        var path;

                        filePicker.init(window, "Choose JS file", nsIFP.modeOpen);

                        var res = filePicker.show();
                        if (res == nsIFP.returnOK || res == nsIFP.returnReplace) {
                            path = filePicker.file.path
                            var contents = fileUtils.openFile(path);
                            worker.port.emit("fileContents", {"path":path, "contents":contents});
                        }
                    }catch(error) {
                        console.log(error);
                    }
                });
                worker.port.on("saveFile", function(dataWithPath) {
                    try{
                        fileUtils.writeFile(dataWithPath.path, dataWithPath.contents);
                    }catch(error) {
                        console.log(error);
                    }
                });
                worker.port.on("getUrl",function(urlRequest) {
                    worker.port.emit("urlContents", {"contents":data.load(urlRequest.path), "callerId": urlRequest.callerId});
                });
                worker.port.on("getLocalUrl",function(urlRequest) {
                    try{
                        var fileContents = fileUtils.openFile(urlRequest.path);
                        worker.port.emit("urlContents", {"contents":fileContents, "callerId": urlRequest.callerId});
                    }catch(e) {
                        worker.port.emit("urlContents", {"contents":"No File at "+urlRequest, "callerId": urlRequest.callerId});
                    }
                });
                worker.port.on("getAllPrefernces",function(message) {
                    var preferences = {}, i, key, preferenceKeys, value;
                    preferenceKeys = message.contents;
                    console.log("get All called " + message + preferenceKeys);
                    for (i = 0; i < preferenceKeys.length; i++) {
                        key = preferenceKeys[i];
                        value = preferenceService.get( preferencePrefix + key);
                        preferences[key] = value;
                        console.log(key +" " +value);
                    }
                    worker.port.emit("allPreferences", {"contents":preferences});
                });
                worker.port.on("storeAllPreferences",function(message) {
                    var value, key, preferences;
                    preferences = message.contents;
                    console.log("store All called " + message + preferences);

                    for (key in preferences) {
                        value = preferences[key];
                        preferenceService.set(preferencePrefix + key, value);
                    }
                });
            }
        });
    }
}());
Пример #19
0
  worker.port.emit("click", {
    css: data.url('readability.css'), 
    storage: {
      size: ss.storage.size, 
      margin: ss.storage.margin,  
      style: ss.storage.style
    }
  });
  
  worker.port.on("ready", function(){
    worker.port.emit("init");
  });
  
  worker.port.on('style', function(opts){
    ss.storage[opts.rule] = opts.value ; 
  });
};

var widget = widgets.Widget({
  id: "mozilla-link",
  label: "Mozilla website",
  contentURL: data.url("logo.ico"),
  contentScriptWhen: "ready",
  hotkey: Hotkey({
    combo: "control-alt-r",
    onPress: onClick
  }),
  onClick: onClick
});

Пример #20
0
  }
});

var shortenHotKey = Hotkey({
  combo: "accel-shift-u",
  onPress: function() {
    if (/^http[s]*:\/\//.test(tabs.activeTab.url)) {
      shortening.shorten(tabs.activeTab.url, function(response) {
        let clipboard = require("clipboard");
        clipboard.set(response.id)
        notifications.notify({
          title: "Copied url: " + response.id + " to the clipboard.",
          text: "Click this notification to test the new Url.",
          data: response.id,
          iconUrl: data.url("google.png"),
          onClick: function(url) {
            tabs.open(url);
          }
        });
      });
    } else {
      notifications.notify({
        title: "Url error!",
        text: "The url " + tabs.activeTab.url + " doesn't seem to be a valid web url.",
        iconUrl: data.url("google.png")
      });
    }
  }
});


Пример #21
0
 assert.throws(function() {
   Hotkey({
     combo: "alt",
     onPress: function() {}
   });
 }, "throws if no key is present");
Пример #22
0
 assert.throws(function() {
   Hotkey({
     combo: "alt p b",
     onPress: function() {}
   });
 }, "throws if more then one key is present");
Пример #23
0
widget.port.on('translationRequest', function(data) {
//    translate.ling(data, function(response){
//        appPanel.port.emit('translationResponse', response);
//        widget.port.emit('translationResponse', 'Response from ' + data + ' request!');
//        appPanel.show();
//    });
    translate.megaslownik(data, function(response){
        appPanel.port.emit('translationResponse', response);
        widget.port.emit('translationResponse', response);
        appPanel.show();
    });
});

var focusInput = hotkeys.Hotkey({
    combo: "accel-shift-i",
    onPress: function() {
        widget.port.emit('focusInput');
    }
});

var panelShow = hotkeys.Hotkey({
    combo: "accel-alt-i",
    onPress: function(){
        if (selection.text) {
            translate.megaslownik(selection.text, function(response){
                appPanel.port.emit('translationResponse', response);
                widget.port.emit('translationResponse', response);
                appPanel.show();
            });
        } else {
            appPanel.show();
        }