var WindowWidth = null; WindowWidth = $(window).width(); var user_id; $(document).ready(function() { // get user profile $.ajax({ url: "/valid/submitinfo/myData", type: "GET", headers: { accept: "application/json", "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"), }, cache: false, contentType: false, processData: false, success: function(res) { $('#firstname').val(res.data.first_name); $('#lastname').val(res.data.last_name); if (res.data.degree != null) { $('#degree').val(res.data.degree); } if (res.data.major != null) { $('#major').val(res.data.major); } $('#mobilenumber').val(res.data.mobile); if (res.data.avatar != null) { $('#fileshow').attr("src", "/" + res.data.avatar); } user_id = res.data.id; $('#showloginkarbar').modal({ backdrop: 'static', keyboard: false }) $("#showloginkarbar").modal('show') }, }); picturenumber = Math.floor(Math.random() * 13) + 1; if (picturenumber == 1) { imagekol = "../dist/images/modalrms/100.jpg"; } else if (picturenumber == 2) { imagekol = "../dist/images/modalrms/101.jpg"; } else if (picturenumber == 3) { imagekol = "../dist/images/modalrms/102.jpg"; } else if (picturenumber == 4) { imagekol = "../dist/images/modalrms/103.jpg"; } else if (picturenumber == 5) { imagekol = "../dist/images/modalrms/104.jpg"; } else if (picturenumber == 6) { imagekol = "../dist/images/modalrms/105.jpg"; } else if (picturenumber == 7) { imagekol = "../dist/images/modalrms/106.jpg"; } else if (picturenumber == 8) { imagekol = "../dist/images/modalrms/107.jpg"; } else if (picturenumber == 9) { imagekol = "../dist/images/modalrms/108.jpg"; } else if (picturenumber == 10) { imagekol = "../dist/images/modalrms/109.jpg"; } else if (picturenumber == 11) { imagekol = "../dist/images/modalrms/110.jpg"; } else if (picturenumber == 12) { imagekol = "../dist/images/modalrms/111.jpg"; } else if (picturenumber == 13) { imagekol = "../dist/images/modalrms/112.jpg"; } $(".bodypic").css({ "background-image": "url(" + imagekol + ")" }); if (WindowWidth <= 800) { $(".logoPart").empty(); $(".logoPart").append( '
\ \ \
\
\ \ تماس با ما\ \
' ); } }); $("#inputFile1").change(function() { $("#fileshow").css("display", "none"); readURL2(this); }); function readURL2(input) { if (input.files && input.files[0]) { var reader = new FileReader(); reader.onload = function(e) { $("#image_upload_previewmostanad").css("display", "block"); $("#removepic2").css("display", "block"); $("#image_upload_previewmostanad").attr("src", e.target.result); }; reader.readAsDataURL(input.files[0]); } } function shownextpage() { console.log("here"); // validation require $('#errorBox').css('display', 'none') $('#errors').empty(); var isRequire = true; var isEqual = true; var isValid = true; if ($('#firstname').val() == '') { isValid = false; console.log("firstname"); isRequire = false; } if ($('#lastname').val() == '') { isValid = false; console.log("lastname"); isRequire = false; } if ($('#degree').val() == '') { isValid = false; console.log("degree"); isRequire = false; } if ($('#major').val() == '') { isValid = false; console.log("major"); isRequire = false; } if ($('#mobilenumber').val() == '') { isValid = false; console.log("mobilenumber"); isRequire = false; } if ($('#passcode').val() != '' && $('#passcode').val() !== $('#passcodere').val()) { isValid = false; console.log("passcode"); isEqual = false; } //send data if (isValid) { var data = new FormData(); data.append("first_name", $('#firstname').val()); data.append("last_name", $('#lastname').val()); data.append("degree", $('#degree').val()); data.append("major", $('#major').val()); data.append("mobile", $('#mobilenumber').val()); if ($('#passcode').val() != '') { data.append("password", $('#passcode').val()); } if ((typeof $('#inputFile1').get(0).files[0] !== "undefined")) data.append("avatar", $('#inputFile1').get(0).files[0]); $.ajax({ url: "/profile/edit", type: "POST", beforeSend: function() { $('#submitform').attr('disabled', 'disabled'); $('#submitform').text('در حال ثبت'); }, headers: { accept: "application/json", "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"), }, cache: false, data: data, contentType: false, processData: false, success: function(res) { $('#submitform').text('ثبت شد'); $('#submitform').removeClass('btn-primary'); $('#submitform').addClass('btn-success'); window.location = "/"; }, error: function(xhr) { $('#submitform').removeAttr('disabled'); $('#submitform').text('ثبت'); }, }); } else { $('#errorBox').css('display', '') if (!isRequire) $('#errors').append(`
  • تمامی فیلد ها باید تکمیل شود.
  • `) if (!isEqual) $('#errors').append(`
  • تکرار رمز عبور درست نمی باشد.
  • `) } }