//@ sourceURL=password.js
$(function (){
/**
 * 提交按钮点击事件
 */
$("#send").on("click",function (t) {
    var validatorResult = validator.checkAll($("#password_form"));
    if(!validatorResult){
        return;
    }
    $.ajax({
        type: "POST",
        contentType: "application/json;charset=UTF-8",
        url: "/thmz/modify-user/",
        dataType: 'json',
        data: JSON.stringify({"password":$("#password").val(),"oldPassword":$("#oldPassword").val()}),
        headers:{'Accept': 'application/json','Authorization':'Bearer '+ localStorage.getItem("token")},
        success: function(result) {
            if(result=='401' || result==401){
                window.location.href='/thmz/login/view'
                return;
            }
            if(result.code == 0) {
                profileInfo(result);
            } else {
                errorMesage(result);
            }
        }
    });
});

/**
 * 取消按钮点击事件
 */
$("#cancel").on("click",function (t) {
    //profileInfo();
});


    //数据校验
    init_validator();
});





/**
 * 跳转回主页
 */
function profileInfo(result) {
    //TODO 跳转回主页
    successMesage(result);
    $("#buttonDiv").removeClass('in').addClass('hide');
    setTimeout(function(){
        loginOut()
    },2000);
}