$(document).ready(function(){$(".profile-update-btn").click(function(){$("form.td-profile").submit()});$(".td-profile").validate({rules:{name:"required",email:{required:!0,email:!0}},submitHandler:function(c){document.querySelector(".td-profile #email").value.trim();let a=document.querySelector(".td-profile #company").value.trim(),b=document.querySelector(".td-profile #bio").value.trim(),e=document.querySelector(".td-profile #name").value.trim();$(".profile-update-btn").prop("disabled",!0);$(".profile-update-btn").text("Please wait");
chrome.storage.local.get(["login"],function(f){$.ajax({method:"POST",url:endpoint+"updateprofile",headers:{Authorization:"Bearer "+f.login},data:{company:a,bio:b,name:e,number:chrome.runtime.getManifest().version},success:function(d,g,h){$(".profile-update-btn").prop("disabled",!1);$(".profile-update-btn").text("Update");0==d.status?pn(d.message,"error"):(Store.set({name:e}),Store.set({company:a}),Store.set({bio:b}),$(".user-name").text(e),$(".company-name").text(a),$(".bio").text(b),pn(d.message,
"success"))},statusCode:{500:function(d){Store.set({login:!1});pn("","error")},401:function(){Store.set({login:!1});pn("","error")},422:function(d){Store.set({login:!1});$(".login-btn").prop("disabled",!1);$(".login-btn").text("Login");pn(d.responseJSON.error,"error")}}})})}});$(document).on("click",".change-user-image",function(){$(".add-profile-image").click()});$(".add-profile-image").change(function(){var c=this.files[0];$(".change-user-image").attr("src",URL.createObjectURL(c));$(".save-as-profile-image").show()});
$(document).on("click",".save-as-profile-image",function(){var c=new FormData;c.append("image",$(".add-profile-image[type=file]")[0].files[0]);chrome.storage.local.get(["login"],function(a){pn("Uploading image. Please wait.","warning");$.ajax({data:c,type:"POST",contentType:!1,processData:!1,url:endpoint+"uploadimage",headers:{Authorization:"Bearer "+a.login},success:function(b,e,f){1==b.status?(Store.set({image:b.image}),$(".profile-image, .change-user-image").prop("src",b.image),pn(b.message,"success"),
$(".save-as-profile-image").hide()):pn("Something weng wrong!","error")},statusCode:{500:function(b){},401:function(){},422:function(b){}}})})})});
function deleteAccount(){chrome.storage.local.get(["login"],function(c){$.ajax({method:"POST",url:endpoint+"deleteaccount",headers:{Authorization:"Bearer "+c.login},success:function(a,b,e){addingSkeletonLoadingForPromotedPost(!1);1==a.status?(pn(a.message,"success"),$(".logout").click()):pn(a.message,"error")},statusCode:{500:function(a){},401:function(){},422:function(a){}}})})};
