<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Dd_setting.aspx.cs" Inherits="HteamDd.Web.Web.Dd_setrting" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>设置|海客轻微博</title>
    <link href="/css/public.css" rel="stylesheet" type="text/css" />
    <link href="/css/FeedBack.css" rel="stylesheet" type="text/css" />
    <link href="/css/Dd_setting.css" rel="stylesheet" type="text/css" />
     <script type="text/javascript" language="javascript" src="/jscript/jquery-1.4.2.js"></script>
    <script src="/jscript/Dd_image_deal.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript">
        var jq = jQuery.noConflict();
        jq(document).ready(function () {
            var user = "";
            var cookie_info = ' <%=user_Mes%>';
            if (cookie_info != "") {
                user = cookie_info.split(',');
                blogname.innerHTML = user[1];
                user_nickname.innerHTML = user[1];
                img_user(user[0], "2"); //处理个人图片问题
            }
            //退出时，进行session和cookie的清空
            jq("#uer_Exit").click(function () {
                jq.ajax({
                    type: "post",
                    url: '/ashx/Dd_userExit.ashx',
                    data: { type: "exit", time: new Date().getDate() },
                    success: function (data) {
                        if (data == "1") {
                            window.location.href = "/Dd_login.aspx";
                        }
                    },
                    error: function () {

                    }
                });
            });
            jq("#email").val(user[2]); //通过cookie获取用户登录时输入的电子邮箱
            jq("#old-password").focus(function () {//聚焦当前密码框时，新密码框可用
                jq("#new-passwd").attr("disabled", "");
                jq("#re-new-passwd").attr("disabled", "");
            });
            jq("#old-password").blur(function () {//失去聚焦时，判断当前密码框输入的内容是否为空
                if (jq.trim(jq("#old-password").val()) != "") {
                    jq("#new-passwd").attr("disabled", "");
                    jq("#re-new-passwd").attr("disabled", "");
                }
                else {
                    jq("#new-passwd").attr("disabled", "disabled");
                    jq("#re-new-passwd").attr("disabled", "disabled");
                }
            });
            jq("#save-setting-btn").click(function () {
                var psw = jq("#old-password").val();
                var newpsw = jq("#new-passwd").val();
                var email_user = jq("#email").val();
                if (check_mail(email_user))////邮箱账号验证
                {
                    if (jq.trim(psw) != "") {//密码不能为空
                        if (jq.trim(jq("#re-new-passwd").val()) == jq.trim(newpsw)) {//密码和重复密码一致
                            if (check_length(newpsw)) {//控制密码的长度安全
                                jq.ajax({
                                    type: "post",
                                    url: '/ashx/Dd_setting.ashx',
                                    data: { user_ID: user[0], email: email_user, user_psw: psw, new_psw: newpsw, mark: "setting", time: new Date().getDate() },
                                    success: function (data) {
                                        if (data == "psw_Error") {
                                            jq("#J_SettingErr").css("display", "");
                                        }
                                        else if (data == "0") {
                                            alert("修改失败！！！");
                                        }
                                        else {
                                            jq("#J_SettingErr").css("display", "none");
                                            alert("恭喜你修改成功！！！");
                                            window.location = '/Default.aspx'; //修改成功，跳转首页
                                        }
                                    },
                                    error: function () {
                                        alert("修改失败！！！");
                                    }
                                });
                            }
                        }
                        else {
                            jq("#J_SettingErr").css("display", "");
                            jq("#J_SettingErr").text("两次密码输入不一致，请确认!");
                        }
                    }
                    else {
                        window.location = '/Default.aspx'; //密码为空跳转首页
                    }
                }
            });
        });
      
        function check_mail(mail) {
            var reg = /^[_a-zA-Z\d\-\.]+@[_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+$/;
            if (jq.trim(mail) != "") {//验证输入的不为空
                if (!reg.test(mail)) {//进行邮箱格式的验证
                    jq("#J_SettingErr").css("display", "");
                    jq("#J_SettingErr").text("邮箱格式不正确!");
                    return false;
                }
                else {
                    return true;
                }
            }
            else {
                return false;
            }
        }

        function check_length(re_psw) {//控制密码的长度安全
            if (jq.trim(re_psw).length < 6) {
                jq("#J_SettingErr").css("display", "");
                jq("#J_SettingErr").text("密码长度太短，换个长的吧！");
                return false;
            }
            else if (jq.trim(re_psw).length > 20) {
                jq("#J_SettingErr").css("display", "");
                jq("#J_SettingErr").text("长度不能超过20!");
                return false;
            }
            else {
                return true;
            }
        }
      </script>      
</head>
<body>
<div id="wrap">
        <div id="header" class="clearfix">
        <div id="logo">
            <a href="/Default.aspx">海客网</a>
        </div>
        <ul id="nav">
            <li id="nav-index" class="active">
                <a class="nav-item" href="/Default.aspx">首页</a>
                <a id="new-feed-count" class="header-pop-notice" style="display:none"></a>
            </li>
            <li>
                <a id="nav-explore" class="nav-item" href="/Web/Dd_discover/Dd_FerverTag.aspx">发现</a>
            </li>
        </ul>
        <ul id="sub-nav">
            <li>
                <a href="/Dd_login.aspx" id="uer_Exit">退出</a>
            </li>
            <li>
                <a href="/Web/Dd_setting.aspx">设置</a>
            </li>
            <li>
                <a href="/Web/Dd_Intro_Master/Dd_aboutme.aspx">关于</a>
            </li>
           <%-- <li>
                <a href="#">手机</a>
            </li>
            <li>
                <a href="#">邀请</a>
            </li>--%>
        </ul>
        <ul id="nav-blog-list" class="clearfix">
            <li id="nav-blog-8500453" >
                <a href="/Web/Dd_private_index.aspx">
                    <span class="nav-blog-avatar">
                        <img width="20" height="20" id="img_personal" src="/images/avatar_30_30.$1095.png" alt=""/>
                    </span>
                    <span class="nav-blog-name" id="blogname"></span>

                </a>
            </li>
        </ul>
    </div>
    <div id="content-holder">
        <div id="content">
            <div id="setting-header clearfix">
                <h2 style=" margin-left:20px;">设置</h2>
                
            </div>
            <div id="settting" style=" height:70px; width:100%"></div>
            <div id="J_SettingErr" class="setting-error-msg"  style=" display:none;">当前密码错误!</div>
            <div id="setting-holder">
                <form class="setting-form" id="setting-form" method="post" action="#">
                    <div class="setting-item" id="setting-email"><label>电子邮件地址</label><div class="setting-item-main"><input name="email" class="input-text" id="email" /></div></div>
                    <div class="setting-item" id="setting-pw"><label>当前密码</label><div class="setting-item-main"><input name="oldpassword" class="input-text" id="old-password" type="password"/></div></div>
                    <div class="setting-item" id="setting-newpw"><label>新密码</label><div class="setting-item-main"><div><input name="new_password" class="input-text new-password disabled" id="new-passwd" disabled="disabled" type="password"/></div><div><input name="new_password" class="input-text disabled" id="re-new-passwd" disabled="disabled" type="password"/></div></div></div>
                    <div class="setting-item clearfix" id="setting-feed"><label>动态设置：</label><div class="setting-item-main clearfix"><label class="label-for-checkbox"><input name="useLargeFeedImage"type="checkbox" value="true"/><span>在动态中直接显示大图</span></label></div></div>
                    <div class="setting-item clearfix" id="setting-notify"><label>通知：</label><div class="setting-item-main clearfix"><div class="one-blog-setting clearfix"><h3><span id="user_nickname"></span></h3><div class="one-blog-setting-item clearfix">
                        <label class="label-for-checkbox"><input name="notIgnoreFollow" type="checkbox" checked="checked" value="true"/>博客被关注</label>
                        <label class="label-for-checkbox"><input name="notIgnoreFollow" type="checkbox" checked="checked" value="true"/>文章被回应</label>
                        <label class="label-for-checkbox"><input name="notIgnoreFollow" type="checkbox" checked="checked" value="true"/>文章被转载</label>
                        <label class="label-for-checkbox"><input name="notIgnoreFollow" type="checkbox" checked="checked" value="true"/>文章被喜欢</label>
                    </div><p class="setting-item-tips">勾选后将会收到对应的系统消息</p></div></div></div>
                    <div class="setting-item clearfix" id="setting-mail"><label>邮件提醒：</label><div class="setting-item-main clearfix">
                        <label class="label-for-checkbox"><input name="mail_type" type="checkbox" checked="checked" value="1"/><span>被人关注</span></label>
                        <label class="label-for-checkbox"><input name="mail_type" type="checkbox" checked="checked" value="1"/><span>收到稿件</span></label>
                        <label class="label-for-checkbox"><input name="mail_type" type="checkbox" checked="checked" value="1"/><span>收到私信</span></label>
                        <label class="label-for-checkbox"><input name="mail_type" type="checkbox" checked="checked" value="1"/><span>海客周刊</span></label>
                        <p class="setting-item-tips">勾选后将会收到对应的提醒邮件</p>
                    </div></div>
                    <div class="setting-bottom-nav"><a href="/Web/Dd_Attention/Dd_BlackList.aspx">黑名单</a></div>
                    <div class="setting-submit"><a class="blue-button" id="save-setting-btn">保存</a></div>
                </form>
            </div>
        </div>
    </div>
    </div>
</body>
</html>