/* Utility Functions for Ubiquity */
function openUrl(url, postData) {
  var windowManager = 
Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator);
  var browserWindow = 
windowManager.getMostRecentWindow("navigator:browser");
  var browser = browserWindow.getBrowser();

  if(browser.mCurrentBrowser.currentURI.spec == "about:blank")
    browserWindow.loadURI(url, null, postData, false);
  else
    browser.loadOneTab(url, null, null, postData, false, false);
}

function openTab(url, postData) {
  var windowManager = 
Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator);
  var browserWindow = 
windowManager.getMostRecentWindow("navigator:browser");
  var browser = browserWindow.getBrowser();
    browser.loadOneTab(url, null, null, postData, false, false);
}

CmdUtils.CreateCommand({  
  name: "switch-domain", 
  homepage: "https://w.amazon.com/?Micklos";,
  author: { name: "Jonathan Micklos", email: "[email protected]"},
  contributors: [""],
  icon: "http://www.amazon.co.jp/favicon.ico";,
  description: "Takes the current URL and swaps the domain and sub 
domains with another domain and other subdomains.",
  takes: {"Domain": noun_arb_text},
  execute: function(domainObj ) {
    var domain = domainObj.text;
    var url = CmdUtils.getWindow().location.href;
    var colonDoubleSlashIndex = 0;
    var singleSlashIndex = 0;
   
    //remove the protocol and ://
    colonDoubleSlashIndex = url.indexOf("://");
    singleSlashIndex = url.indexOf("/");
   
    //Make sure that :// exists and it is right before the domain before 
removing the protocol and ://
    if(colonDoubleSlashIndex >=0 && singleSlashIndex == 
(colonDoubleSlashIndex + 1)) {
      url = url.substring(colonDoubleSlashIndex + 3);
    }
   
    //remove the domain
    singleSlashIndex = url.indexOf("/");
   
    if(singleSlashIndex >= 0) {
      url = domain+url.substring(singleSlashIndex);
    } else {
      url = domain;
    }
   
    openTab(url);
  }
});

Jonathan Micklos wrote:
> I actually had to write a command to do this for work. The idea would 
> be that you would capture the current URL, remove the domain name and 
> swap it with another domain name. Assuming that the structure of 
> en.wikipedia.org and de.wikipedia.org are the same, this should work.
>
> I'll boot up my work machine and see if I can get it for you.
>
> -Jonathan
>
> sL!z3r wrote:
>> Hi,
>> i want to edit the wiki command to change the search from
>> en.wikipedia.org to de.wikipedia.org (to get german results)
>> how can i edit this command?
>>
>> >>
>>   

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ubiquity-firefox" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/ubiquity-firefox?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to