-
-
Save jackysee/45009 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment