Another version of back (still a bit goofy):

CmdUtils.getURLSnapshot = function(url, options){
  if(!options) options = {};  
  var hw = CmdUtils.getHiddenWindow();
  hw.document.location.href = url;
  cw = CmdUtils.getWindow()
  hw.innerWidth = cw.innerWidth
  hw.innerHeight = cw.innerHeight
  var th_hw = CmdUtils.getHiddenWindow();
  var th = 
th_hw.document.createElementNS("http://www.w3.org/1999/xhtml";, "canvas" );
  width = options.width || 200;
  var scale =  width / hw.innerWidth;
  var ratio = hw.innerHeight / hw.innerWidth;
  th.mozOpaque = true;
  th.width = width;
  th.height = th.width * ratio;
  var ctx = th.getContext("2d");
  ctx.scale(scale, scale);
  ctx.drawWindow(hw, hw.scrollX, hw.scrollY,
                 hw.innerWidth, hw.innerWidth, "rgb(255,255,255)");
  return th.toDataURL("image/jpeg", "quality=90");
}

var noun_type_history = {
  _name: "history urls",
  suggest: function( text, html ) {
    var suggestions  = [];
    var history = CmdUtils.getWindow().history;
    for ( var i = 0; i < history.length; i++ ) {
      url = history[i];
      if (url.match(text, "i"))
        suggestions.push(CmdUtils.makeSugg(url));
    }
    return suggestions.splice(0, 5);
  }
};


CmdUtils.CreateCommand({
  name: "back",
  description: "Go one step back in history",
  takes: {"input": noun_type_history},
  preview: function( pblock, input ) {
    if (input.text) {var url = input.text;
    } else { var url = CmdUtils.getWindow().history.previous;}
    var imgData = CmdUtils.getURLSnapshot(url, {width:500} );
    pblock.innerHTML = "Changes to <b style=\"color:yellow\">%s</b> 
document.".replace(/%s/, url);
    pblock.innerHTML += "<br/><img src='%s'>".replace(/%s/, imgData );
  },
  execute: function(input) {
    if (input.text){
      CmdUtils.getWindow().location.href = input.text;
    } else {
      CmdUtils.getWindow().history.go(-1);
    }
  }
});

--~--~---------~--~----~------------~-------~--~----~
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