Skip to content

Instantly share code, notes, and snippets.

@iontom
Created August 18, 2014 22:00
Show Gist options
  • Save iontom/27db214da0b34dc37ba8 to your computer and use it in GitHub Desktop.
Save iontom/27db214da0b34dc37ba8 to your computer and use it in GitHub Desktop.
How to make user login responsive
//Make file called nav_users.js and put this in there somewhere. Then reference nav_users from main.js
document.getElementById('usersubmit').addEventListener('click', function (e) {
e = e || window.event;
$user = document.getElementById('user_css_id').value;
$pass = document.getElementById('pass_css_id').value;
$pass = document.getElementById('email_css_id').value;
tryLogin($user,$pass,$email);
}, false);
//Then go to main.js and make a var & function
//Near the top:
var addUser;
//Then later down, inside function RSimulate(opts) {}
addUser = function ($user, $pass $email) {
// NOTE: send ephemeris without a name; the server will assign one
var cmd = 'create';
var credentials = {
user: $user;
pass: $user;
email: $email;
};
var data = {cmd: cmd, user:...........};
var stringify = JSON.stringify(data).replace(/\"+/g, "\'");
console.log("Creating new User");
//You need to figure out what goes in here:
ws.send(message('playerLogin', "{'cmd': 'pObjCreate', 'objectId': None, 'type': 'Probe', " +
"'model': 'Magellan', 'data': "+stringify+'}'));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment