Created
September 5, 2008 23:19
-
-
Save trotter/9056 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: "mbox-login", | |
homepage: "http://www.motionbox.com", | |
author: {name: "Trotter Cashion", email: "trotter.cashion@motionbox.com"}, | |
license: "MIT", | |
description: "Quick and easy login to motionbox", | |
help: "Will log you into Motionbox and open a new tab with your profile page", | |
takes: {login: noun_arb_text}, | |
modifiers: {"/": noun_arb_text, host: noun_arb_text}, | |
_host: function(host) { | |
return host || "www.motionbox.com"; | |
}, | |
_login_url: function(host) { | |
return "http://" + this._host(host) + "/user/login"; | |
}, | |
preview: function(pblock, login, mods) { | |
var template = "Login to ${url} using ${login} / ${password}"; | |
var subs = {url: this._login_url(mods.host.text), login: login.text, password: mods["/"].text}; | |
pblock.innerHTML = CmdUtils.renderTemplate(template, subs); | |
}, | |
execute: function(login, mods) { | |
var url = this._login_url(mods.host.text); | |
var params = {"user[login]": login.text, "user[password]": mods["/"].text}; | |
var redirect_url = "http://" + this._host(mods.host.text); | |
jQuery.post(url, params, function(response) { | |
Utils.openUrlInBrowser(redirect_url); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment