account.js 692 B

123456789101112131415161718192021222324252627282930
  1. window.addEvent('domready', function() {
  2. 'use strict';
  3. $('update_emails').addEvent('click', function() {
  4. new Request.JSON({
  5. 'url': '/github_emails',
  6. 'onSuccess': function(response) {
  7. var emails = $('emails');
  8. response.each(function(email) {
  9. var div = new Element('div');
  10. div.appendText(email['email']);
  11. div.addEvent('click', function() {
  12. set_email(email['email']);
  13. });
  14. emails.grab(div, 'top');
  15. });
  16. },
  17. }).get();
  18. });
  19. function set_email(email) {
  20. new Request({
  21. 'url': '/account/contact_info',
  22. 'onSuccess': function(response) {
  23. if (response)
  24. location.reload();
  25. },
  26. }).post({'info_type': 0, 'info': email});
  27. }
  28. });