jackysee (owner)

Revisions

gist: 45009 Download_button fork
public
Public Clone URL: git://gist.github.com/45009.git
Embed All Files: show embed
x #
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
CmdUtils.CreateCommand({
  name: "jquerify",
  author: { name: "Jacky", email: "jackysee at gmail dot com"},
  license: "GPL",
  description: "Load jquery library to page (using google's hosting)",
  help: "jquery version (default version is 1.2.6)",
  takes: {"input": noun_arb_text},
  preview: function( pblock, input ) {
    pblock.innerHTML = "Load jquery " + (input.text || "1.2.6");
  },
  execute: function(input) {
    var tab = Application.activeWindow.activeTab;
    var d = tab.document;
    var w = d.defaultView;
    if(typeof w.jQuery!='undefined') {
      displayMessage('This page already using jQuery v' + w.jQuery.fn.jquery);
    }
    else{
        var version = input.text || "1.2.6";
        var script = d.createElement('script');
        script.src = "http://ajax.googleapis.com/ajax/libs/jquery/"+version+"/jquery.min.js";
        d.getElementsByTagName('body')[0].appendChild(script);
        displayMessage('loading jquery version ' + version);
    }
  }
});