Skip to content

Instantly share code, notes, and snippets.

@defunkt
Created October 23, 2008 03:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save defunkt/18911 to your computer and use it in GitHub Desktop.
Save defunkt/18911 to your computer and use it in GitHub Desktop.
CmdUtils.CreateCommand({
name: "page-width",
author: { name: "Jacky See"},
license: "GPL",
description: "Limit the page width by a given parameter, align it to center",
help: "e.g. page-width 400",
takes: {"input": noun_arb_text},
preview: function( pblock, input ) {
var template = "Setting page to width ${w} (default is 500)";
var width = 500; //default width
try{
width = parseInt(input.text);
}catch(ex){}
pblock.innerHTML = CmdUtils.renderTemplate(template, {"w": width});
},
execute: function(input) {
var body = Application.activeWindow.activeTab.document.body;
var width = 500; //default width
try{
width = parseInt(input.text);
}catch(ex){}
if(body){
body.style.width = width + "px";
body.style.margin = "0 auto";
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment