diff --git a/profiles/static/js/edit.js b/profiles/static/js/edit.js index 42d3b47..53d7928 100644 --- a/profiles/static/js/edit.js +++ b/profiles/static/js/edit.js @@ -1,25 +1,6 @@ -//show edit forms -$(function() { - $("#edit").on('click', function () { - $(".user-form-input").show() - $(".user-form-value").hide() - $("#save").show() - $("#edit").hide() - }); -}); - -//show image upload on click -$(function() { - $("#self-picture").on('click', function () { - $("#upload-form").toggle() - }); -}); - -//upload form data -$(function() { - $("#save").on('click', function (e) { - - var form_data = { +function submitFormData() { + return new Promise((resolve, reject) => { + var form_data = { "name": $("#user-name").val(), "birthday": $("#user-birthday").val(), "phone": $(".user-mobile").map(function() { @@ -52,14 +33,62 @@ $(function() { contentType: 'application/json', data: JSON.stringify(form_data), success: function (data, textStatus, jqXHR) { - location.reload(); + resolve(data); }, error: function(error) { console.log(error); + reject(error); } }); }); +} + + +//show edit forms +$(function() { + $("#edit").on('click', function () { + $(".user-form-input").show() + $(".user-form-value").hide() + $("#save").show() + $("#edit").hide() + $("#social-media").css("text-align", "left") + }); +}); + +//show image upload on click +$(function () { + $("#self-picture").on('click', function () { + $("#upload-form").toggle() + }); +}); + +//upload form data +$(function () { + $("#save").on('click', function (e) { + submitFormData().then(function (data) { + location.reload(); + }).catch(function (error) { + console.log(error); + }); + }); +}); + +//redirects to eac +$(function () { + $(".add-socials").on('click', function () { + submitFormData().then(function (data) { + $(".user-form-input").hide() + $(".user-form-value").show() + $("#save").hide() + $("#edit").show() + $("#social-media").css("text-align", "center") + + window.location.href = 'https://eac.csh.rit.edu' + }).catch(function (error) { + console.log(error); + }); + }); }); //************* PROFILE PICTURE ************* diff --git a/profiles/templates/profile.html b/profiles/templates/profile.html index 016032b..aaf642f 100644 --- a/profiles/templates/profile.html +++ b/profiles/templates/profile.html @@ -106,48 +106,51 @@
+ +
+ + {% endif %} + {% if member_info.user_obj.blogURL %} + ++ +
+ + {% endif %} + {% if member_info.user_obj.resumeURL %} + ++ +
+ + {% endif %} + {% if member_info.user_obj.github %} + ++ +
+ + {% endif %} + {% if member_info.user_obj.googleScreenName %} ++
- - {% endif %} - + {% endif %} + {% if member_info.user_obj.twitterName %} + ++ +
+ + {% endif %} + +