/*** Created by A.J on 2019/9/25.*/$(document).ready(function(){var URL = window.URL || window.webkitURL;var image = $('#image');var options = {aspectRatio: 1 / 1,preview: '.img-preview'};image.cropper(options);var uploadedImageName = 'cropped.jpg';var uploadedImageType = 'image/jpeg';var uploadedImageURL;var inputImage = $('#inputImage');if (URL) {inputImage.on("change", function () {var files = this.files;var file;if (!image.data('cropper')) {return;}if (files && files.length) {file = files[0];if (/^image\/\w+$/.test(file.type)) {uploadedImageName = file.name;uploadedImageType = file.type;if (uploadedImageURL) {URL.revokeObjectURL(uploadedImageURL);}uploadedImageURL = URL.createObjectURL(file);image.cropper('destroy').attr('src', uploadedImageURL).cropper(options);inputImage.val('');} else {window.alert('Please choose an image file.');}}});} else {inputImage.prop('disabled', true).parent().addClass('disabled');}$("#upload").on("click", function(){if($("#image").attr("src") == ""){$.alert({title: $('#chucuo').text(),content: $('#avatarnotselected').text(),buttons: {confirm: {text: $('#queding').text(),btnClass: 'btn-info',keys: ['enter']}}});return false;}var obj = $(this);obj.attr("disabled", true).children("i:last").removeClass("d-none");image.cropper("getCroppedCanvas", { 'width': 128, 'height': 128 }).toBlob(function(blob){var fd = new FormData();fd.append('file', blob);fd.append('verification', $("#verification").text());$.ajax({url: $("#uploadimg").text(),type: "POST",data: fd,cache: false,processData: false,contentType: false,success: function(data){obj.attr("disabled", false).children("i:last").addClass("d-none");if(data == 'ok'){$.alert({title: '',content: $("#avatarsaved").text(),buttons: {confirm: {text: $('#queding').text(),btnClass: 'btn-info',keys: ['enter']}}});}else{$.alert({title: $('#chucuo').text(),content: data,buttons: {confirm: {text: $('#queding').text(),btnClass: 'btn-info',keys: ['enter']}}});}}});});});});