jackysee (owner)

Revisions

gist: 18906 Download_button fork
public
Description:
Ubiquity Command to set document.body to a input width, auto align to center
Public Clone URL: git://gist.github.com/18906.git
JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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";
    }
  }
});