|
@@ -1,79 +1,102 @@
|
|
|
//评卷状态模块
|
|
|
var change_name = function(option, success) {
|
|
|
- var object = new ChangeName(option);
|
|
|
- success();
|
|
|
- return object;
|
|
|
+ var object = new ChangeName(option);
|
|
|
+ success();
|
|
|
+ return object;
|
|
|
}
|
|
|
|
|
|
function ChangeName(option) {
|
|
|
- this.markControl = option.markControl;
|
|
|
- this.url = option.url;
|
|
|
- this.context = option.markControl.context;
|
|
|
- this.userName = option.markControl.container.header.find('#mark-user-name');
|
|
|
+ this.markControl = option.markControl;
|
|
|
+ this.url = option.url;
|
|
|
+ this.context = option.markControl.context;
|
|
|
+ this.userName = option.markControl.container.header.find('#mark-user-name');
|
|
|
|
|
|
- this.popover = getDom(this.popover_dom, this.markControl);
|
|
|
- this.popover.userNameInput = this.popover.find('input.userName-input');
|
|
|
- this.popover.passWordInput = this.popover.find('input.passWord-input');
|
|
|
- this.popover.userNameMessage = this.popover.find('i.userName');
|
|
|
- this.popover.submitButton = this.popover.find('a.btn');
|
|
|
- this.popover.cancelButton = this.popover.find('p.image-close');
|
|
|
- this.popover.appendTo(this.markControl.container);
|
|
|
+ this.popover = getDom(this.popover_dom, this.markControl);
|
|
|
+ this.popover.userNameInput = this.popover.find('input.username-input');
|
|
|
+ this.popover.passwordInput = this.popover.find('input.password-input');
|
|
|
+ this.popover.password2Input = this.popover.find('input.password2-input');
|
|
|
+ this.popover.userNameMessage = this.popover.find('i.username');
|
|
|
+ this.popover.password2Message = this.popover.find('i.password2');
|
|
|
+ this.popover.submitButton = this.popover.find('a.btn');
|
|
|
+ this.popover.cancelButton = this.popover.find('p.image-close');
|
|
|
+ this.popover.appendTo(this.markControl.container);
|
|
|
|
|
|
- var self = this;
|
|
|
+ var self = this;
|
|
|
|
|
|
- this.markControl.container.header.find('a.useinfo').click(function() {
|
|
|
- self.toggle(true);
|
|
|
- });
|
|
|
- this.popover.cancelButton.click(function() {
|
|
|
+ this.markControl.container.header.find('a.useinfo').click(function() {
|
|
|
+ self.toggle(true);
|
|
|
+ });
|
|
|
+ this.popover.cancelButton.click(function() {
|
|
|
+ self.toggle(false);
|
|
|
+ });
|
|
|
+ this.popover.submitButton.click(function() {
|
|
|
+ var logout = false;
|
|
|
+ var nameText = self.popover.userNameInput.val();
|
|
|
+ nameText = nameText.replace(/(^\s*)|(\s*$)/g, "");
|
|
|
+ var pwText = self.popover.passwordInput.val();
|
|
|
+ pwText = pwText.replace(/(^\s*)|(\s*$)/g, "");
|
|
|
+ var pw2Text = self.popover.password2Input.val();
|
|
|
+ pw2Text = pw2Text.replace(/(^\s*)|(\s*$)/g, "");
|
|
|
+ if (nameText.length == 0) {
|
|
|
+ self.popover.userNameMessage.html('姓名不能为空');
|
|
|
+ return false;
|
|
|
+ } else if (nameText.length > 8) {
|
|
|
+ self.popover.userNameMessage.html('长度不能超过8个字');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(pwText.length > 0 || pw2Text.length > 0) {
|
|
|
+ logout = true;
|
|
|
+ if (!pw2Text) {
|
|
|
+ self.popover.password2Message.html('请再次输入您的密码');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (pwText != pw2Text) {
|
|
|
+ self.popover.password2Message.html('两次密码请保持一致');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $.post(self.url, {
|
|
|
+ name: nameText,
|
|
|
+ password:pwText
|
|
|
+ }, function(result) {
|
|
|
+ if (result.success == true) {
|
|
|
+ self.userName.html(result.name);
|
|
|
self.toggle(false);
|
|
|
- });
|
|
|
- this.popover.submitButton.click(function() {
|
|
|
- var nameText = self.popover.userNameInput.val();
|
|
|
- nameText = nameText.replace(/(^\s*)|(\s*$)/g, "");
|
|
|
- var pwText = self.popover.passWordInput.val();
|
|
|
- pwText = pwText.replace(/(^\s*)|(\s*$)/g, "");
|
|
|
- if (nameText.length == 0) {
|
|
|
- self.popover.userNameMessage.html('姓名不能为空');
|
|
|
- } else if (nameText.length > 8) {
|
|
|
- self.popover.userNameMessage.html('长度不能超过8个字');
|
|
|
- } else {
|
|
|
- $.post(self.url, {
|
|
|
- name: nameText,
|
|
|
- password:pwText
|
|
|
- }, function(result) {
|
|
|
- if (result.success == true) {
|
|
|
- self.userName.html(result.name);
|
|
|
- self.toggle(false);
|
|
|
- } else {
|
|
|
- self.popover.userNameMessage.html('修改失败,请稍后重试');
|
|
|
- }
|
|
|
- }).error(function() {
|
|
|
- self.popover.userNameMessage.html('网络通信错误,请稍后重试');
|
|
|
- });
|
|
|
+ if(logout){//修改密码后请重新登陆
|
|
|
+ window.location.href = '/mark/logout';
|
|
|
}
|
|
|
+ } else {
|
|
|
+ self.popover.userNameMessage.html('修改失败,请稍后重试');
|
|
|
+ }
|
|
|
+ }).error(function() {
|
|
|
+ self.popover.userNameMessage.html('网络通信错误,请稍后重试');
|
|
|
});
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
ChangeName.prototype.toggle = function(enable) {
|
|
|
- if (enable == true) {
|
|
|
- this.enable = true;
|
|
|
- this.popover.userNameInput.val('');
|
|
|
- this.popover.passWordInput.val('');
|
|
|
- this.popover.userNameMessage.html('');
|
|
|
- this.popover.show();
|
|
|
- this.context.listenKeyboard = false;
|
|
|
- } else {
|
|
|
- this.enable = false;
|
|
|
- this.popover.hide();
|
|
|
- this.context.listenKeyboard = true;
|
|
|
- }
|
|
|
+ if (enable == true) {
|
|
|
+ this.enable = true;
|
|
|
+ this.popover.userNameInput.val('');
|
|
|
+ this.popover.passwordInput.val('');
|
|
|
+ this.popover.userNameMessage.html('');
|
|
|
+ this.popover.password2Message.html('');
|
|
|
+ this.popover.show();
|
|
|
+ this.context.listenKeyboard = false;
|
|
|
+ } else {
|
|
|
+ this.enable = false;
|
|
|
+ this.popover.hide();
|
|
|
+ this.context.listenKeyboard = true;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
ChangeName.prototype.popover_dom = '<div class="message-popover" style="display:none"><div class="popover-header">\
|
|
|
<p class="title">修改个人信息</p><p class="image-close"><img src="{staticServer}/mark-new/images/images-close.png" /></p></div>\
|
|
|
-<div class="popover-cont"><span style="color: red;">*</span><input type="text" class="userName-input" placeholder="请输入您的姓名" />\
|
|
|
-<i class="wrong userName"></i></div>\
|
|
|
-<div class="popover-cont"><input type="text" class="passWord-input" placeholder="请输入新的密码" />\
|
|
|
- <i class="wrong passWord"></i></div>\
|
|
|
+<div class="popover-cont"><span style="color: red;">*</span><input type="text" class="username-input" placeholder="请输入您的姓名" />\
|
|
|
+<i class="wrong username"></i></div>\
|
|
|
+<div class="popover-cont"><input type="password" class="password-input" placeholder="请输入新的密码" />\
|
|
|
+ <i class="wrong password"></i></div>\
|
|
|
+ <div class="popover-cont"><input type="password" class="password2-input" placeholder="请再次输入您的密码" /> \
|
|
|
+ <i class="wrong password2"></i></div>\
|
|
|
<a href="#" class="btn btn-small btn-info text-userInfo">确定</a>\
|
|
|
</div>';
|