/* * @copyright Leyun internet Technology(Shanghai)Co.,Ltd * @license http://www.dzzoffice.com/licenses/license.txt * @package DzzOffice * @link http://www.dzzoffice.com * @author zyx(zyx@dzz.cc) */ function checkAdminLogin(str){ if(str.match(/id=\"loginform\"/i)){ return true; }else{ return false; } } function show_guide(){ jQuery('#orguser_container').load(ajaxurl+'do=guide',function(){ location.hash=''; }); } function delDepart(obj){ jQuery(obj).parent().parent().remove(); } var tpml_index=0; function addorgsel(){ jQuery('#selorg_container').append('
'); tpml_index++; } function selJob(obj){ var jobid=jQuery(obj).attr('_jobid'); var li=jQuery(obj).parent().parent().parent(); var html=obj.innerHTML; li.find('.dropdown-toggle').attr('_jobid',jobid).find('span').html(html); li.find('input').val(jobid); } function selDepart(obj){ var orgid=jQuery(obj).val(); var li=jQuery(obj).parent(); li.parent().find('.job .dropdown-menu').load(ajaxurl+'do=getjobs&orgid='+orgid,function(html){ if(checkAdminLogin(html)){ location.reload(); } if(li.parent().find('.job .dropdown-menu li').length>1) li.parent().find('.job .dropdown-toggle').trigger('click'); }); li.parent().find('.job .dropdown-toggle').attr('_jobid',0).find('span').html(__lang.none); li.parent().find('.job input').val('0'); } function errormessage(id, msg,passlevel) { if(jQuery('#'+id).length > 0) { msg = !msg ? '' : msg; if(msg == 'succeed') { msg = ''; jQuery('#suc_' + id).addClass('p_right'); } else if(msg !== '') { jQuery('#suc_' + id).removeClass('p_right'); } jQuery('#chk_' + id).find('kbd').html(msg); if(msg && !passlevel) jQuery('#'+id).parent().parent().addClass('has-warning'); else jQuery('#'+id).parent().parent().removeClass('has-warning'); } } function checkemail(id) { errormessage(id); var email = trim(jQuery('#'+id).val()); email=email.toLowerCase(); if(jQuery('#'+id).parent()[0].className.match(/ p_right/) && (email == '' || email == lastemail ) || email == lastemail) { return; } if(email.match(/<|"/ig)) { errormessage(id, __lang.Email_sensitivity); return; } var x = new Ajax(); jQuery('#suc_' + id).removeClass('p_right'); jQuery.getJSON('user.php?mod=ajax&inajax=yes&infloat=register&handlekey=register&ajaxmenu=1&action=checkemail&email=' + email, function(json) { if(json.error){ errormessage(id, json.error); }else{ errormessage(id, 'succeed'); } }); } function checknick(id) { errormessage(id); var username = trim(jQuery('#'+id).val()); if(jQuery('#chk_' + id).parent()[0].className.match(/ p_right/) && (username == '' || username == lastusername) || username == lastusername) { return; } if(username.match(/<|"/ig)) { errormessage(id, __lang.profile_nickname_illegal); return; } if(username){ var unlen = username.replace(/[^\x00-\xff]/g, "**").length; if(unlen < 3 || unlen > 30) { errormessage(id, unlen < 3 ? __lang.username_character : __lang.username_character); return; } var x = new Ajax(); jQuery('#suc_' + id).removeClass('p_right'); jQuery.getJSON('user.php?mod=ajax&inajax=yes&infloat=register&handlekey=register&ajaxmenu=1&action=checkusername&username=' + encodeURI(username), function(json) { if(json.error){ errormessage(id, json.error); }else{ errormessage(id, 'succeed'); } }); } } function checkPwdComplexity(firstObj, secondObj, modify) { modifypwd = modify || false; firstObj.onblur = function () { if(firstObj.value == '') { var pwmsg = !modifypwd ? __lang.register_password_tips : __lang.js_change_password; if(pwlength > 0) { pwmsg += ', '+__lang.register_password_length_tips1+pwlength+__lang.register_password_length_tips2; } if(!modifypwd) errormessage(firstObj.id, pwmsg); }else{ errormessage(firstObj.id, !modifypwd ? 'succeed' : __lang.js_change_password); } checkpassword(firstObj.id, secondObj.id); }; firstObj.onkeyup = function () { if(pwlength == 0 || jQuery('#'+firstObj.id).value.length >= pwlength) { var passlevels = new Array('',__lang.weak,__lang.center,__lang.strong); var passlevel = checkstrongpw(firstObj.id); errormessage(firstObj.id, ''+__lang.intension+':'+passlevels[passlevel]+'','passlevel'); } }; secondObj.onblur = function () { if(secondObj.value == '') { if(!modifypwd) errormessage(secondObj.id, !modifypwd ?'succeed' : __lang.register_repassword_tips); } checkpassword(firstObj.id, secondObj.id); }; } function checkstrongpw(id) { var passlevel = 0; var el=document.getElementById(id); var val=el.value; if(val && val.match(/\d+/g)) { passlevel ++; } if(val && val.match(/[a-z]+/ig)) { passlevel ++; } if(val && val.match(/[^a-z0-9]+/ig)) { passlevel ++; } return passlevel; } function checkpassword(id1, id2) { if(!document.getElementById(id1).value && !document.getElementById(id2).value) { //return; } if(pwlength > 0) { if(document.getElementById(id1).value.length < pwlength) { errormessage(id1, __lang.password_too_short+pwlength+__lang.register_password_length_tips2); return; } } if(strongpw) { var strongpw_error = false, j = 0; var strongpw_str = new Array(); for(var i in strongpw) { if(strongpw[i] === 1 && !document.getElementById(id1).value.match(/\d+/g)) { strongpw_error = true; strongpw_str[j] = __lang.strongpw_1; j++; } if(strongpw[i] === 2 && !document.getElementById(id1).value.match(/[a-z]+/g)) { strongpw_error = true; strongpw_str[j] = __lang.strongpw_2; j++; } if(strongpw[i] === 3 && !document.getElementById(id1).value.match(/[A-Z]+/g)) { strongpw_error = true; strongpw_str[j] = __lang.strongpw_3; j++; } if(strongpw[i] === 4 && !document.getElementById(id1).value.match(/[^A-Za-z0-9]+/g)) { strongpw_error = true; strongpw_str[j] = __lang.strongpw_4; j++; } } if(strongpw_error) { errormessage(id1, __lang.password_weak+strongpw_str.join(',')); return; } } errormessage(id2); if(document.getElementById(id1).value !=document.getElementById(id2).value) { errormessage(id2, __lang.profile_passwd_notmatch); } else { if(modifypwd) errormessage(id1, 'succeed' ); errormessage(id2, 'succeed' ); } } function jstree_search(val){ console.log(val); if(val=='stop'){ jQuery('#jstree_search_input').val(''); jQuery('#searchval').val(''); jQuery('.classtree-search').slideUp(500); jQuery("#classtree").jstree(true).search(); }else{ if(val==''){ jQuery('#jstree_search_input').val(''); jQuery('#searchval').val(''); jQuery('.classtree-search').slideUp(500); } jQuery("#classtree").jstree(true).search(val); } } function jstree_create_organization(){ var inst = jQuery("#classtree").jstree(true); jQuery.post(ajaxurl+'do=create',{'forgid':0,'t':new Date().getTime()},function(json){ if(!json || json.error){ showmessage(json.error,'danger',3000,1); }else if(json.orgid>0){ var arr={"id":json.orgid,"text":json.orgname,"type":"organization","icon":'dzz/system/images/organization.png'} inst.create_node(inst.get_node('#'), arr, "first", function (new_node) { setTimeout(function () { inst.edit(new_node); },0); }); } },'json'); } function jstree_create_dir(){ var inst = jQuery("#classtree").jstree(true),obj; if(inst.get_selected(true).length>0){ obj=inst.get_selected(true); obj=obj[0]; }else{ showmessage(__lang.please_select_one_organization_department,'danger',1000,1); return; } if(obj.type=='user'){ showmessage(__lang.please_select_one_organization_department,'danger',1000,1); return true; } if(inst.is_disabled(obj)){ return true; } var inst = jQuery("#classtree").jstree(true); jQuery.post(ajaxurl+'do=create',{'forgid':obj.id,'t':new Date().getTime()},function(json){ if(!json || json.error){ showmessage(json.error,'danger',3000,1); }else if(json.orgid>0){ var arr={"id":json.orgid,"text":json.orgname,"type":"organization","icon":(json.forgid>0)?'dzz/system/images/department.png':'dzz/system/images/organization.png'} inst.create_node(obj, arr, "first", function (new_node) { setTimeout(function () { inst.edit(new_node); },0); }); } },'json'); } function jstree_create_user(flag){ var inst = jQuery("#classtree").jstree(true),obj; if(inst.get_selected(true).length>0){ obj=inst.get_selected(true); obj=obj[0]; }else{ if(flag) flag=0; obj=inst.get_node('#'); } if(obj.type=='user'){ obj=inst.get_node(obj.parent); } if(inst.is_disabled(obj)){ return true; } showDetail(0,'user',null,obj.id); } function showDetail(id,idtype,ajaxdo,orgid){ var hash=idtype+'_'+id; var urladd='' if(ajaxdo){ hash+='_'+ajaxdo; urladd+='&do='+ajaxdo } if(orgid){ hash+='_'+orgid; urladd+='&orgid='+orgid } currentHash=hash; location.hash=hash; //console..log(hash); urladd+='&t='+new Date().getTime() jQuery('#orguser_container').load(baseurl+'op=view&id='+id+'&idtype='+idtype+urladd,function(html){ if(checkAdminLogin(html)){ location.reload(); } }); } function open_node_dg(inst,node,arr){ //自动打开有权限的目录树 inst.open_node(node,function(node){ var i=jQuery.inArray(node.id,arr); if(i