//初始化选中科室functionselectedDepart(dp){
if(dp){
$("#select-no").html("");
vardepart= $("#condition-depart li>a[data-id="+dp+"]");
depart.addClass("selected").siblings().removeClass("selected");
varcopyThisA= ""+depart.text()+"";
if($("#selectA").length> 0) {
$("#selectAspan").html(depart.text());
} else{
$("#condition-checked").prepend(copyThisA);
}
}
}
//初始化选中职称functionselectedPr(pr){
if(pr){
$("#select-no").html("");
vartitle= $("#condition-position a[data-id="+pr+"]");
title.addClass("selected").siblings().removeClass("selected");
varcopyThisB= ""+title.text()+"";
if($("#selectB").length> 0) {
$("#selectBspan").html(title.text());
} else{
$("#condition-checked").append(copyThisB);
}
}
}
//筛选参数functiongetQueryString(){
varresult= location.search.match(newRegExp("[\?\&][^\?\&]+=[^\?\&]+","g"));
if(result== null){
return"";
}
for(vari= 0; i< result.length; i++){
result[i] = result[i].substring(1);
}
returnresult;
}
//重新定义urlfunctiongoSort(name,value,that) {
varstring_array= getQueryString();
varoldUrl= document.URL;
varnewUrl;
if(string_array.length > 0)//如果已经有筛选条件{
varrepeatField= false;
for(vari= 0; i< string_array.length; i++) {
if(!(string_array[i].indexOf(name) == -1)) {
repeatField= true;//如果有重复筛选条件,替换条件值newUrl= oldUrl.replace(string_array[i], name + "="+ value);
}
}
// 如果没有重复的筛选字段if(repeatField== false) {
newUrl= oldUrl+ "&"+ name + "="+ value;
}
}
if(string_array.length == false) {
newUrl= document.URL + "?"+ name + "="+ value;
}
that.attr('href', newUrl);
}
//删除筛选functiondeleteSort(name,that){
varstring_array= getQueryString();
varoldUrl= document.URL;
varnewUrl= oldUrl.split('?')[0];
varlen= string_array.length;
varreg=newRegExp(name);
if(len> 0){
for(vari=0;i
if(string_array[i].match(reg)){
string_array.pop(string_array[i]);
}
}
}
if(string_array.length>0){
newUrl= newUrl+'?'+string_array[0]
}
that.attr('href',newUrl);
}
$(document).ready(function() {
//初始化$("#doctor-condition .cate li:first").addClass('cur');
$("#condition-departli:first").show().siblings().hide();
$("#doctor-condition .cate li").hover(function() {
$(this).addClass("cur").siblings().removeClass("cur");
$("#doctor-condition .depart li").eq($(this).index()).show().siblings().hide();
});
$("#condition-departa").click(function() {
$("#select-no").html("");
$(this).addClass("selected").siblings().removeClass("selected");
varcopyThisA= ""+$(this).text()+"";
if($("#selectA").length> 0) {
$("#selectAspan").html($(this).text());
} else{
$("#condition-checked").prepend(copyThisA);
}
//筛选varvalue= $(this).attr('data-id');
varname= 'dp';
goSort(name,value,$(this));
});
$("#condition-positiona").click(function() {
$("#select-no").html("");
$(this).addClass("selected").siblings().removeClass("selected");
varcopyThisB= ""+$(this).text()+"";
if($("#selectB").length> 0) {
$("#selectBspan").html($(this).text());
} else{
$("#condition-checked").append(copyThisB);
}
//筛选varvalue= $(this).attr('data-id');
varname= 'pr';
goSort(name,value,$(this));
});
});
functionconditionRemoveA(ele){
ele.remove();
$("#condition-departa.selected").removeClass('selected');
if($("#condition-checkeda").length==0){
$("#condition-checked #select-no").html("尚未选择");
}
//删除链接中的dp参数并重定向deleteSort('dp',ele);
}
functionconditionRemoveB(ele){
ele.remove();
$("#condition-positiona.selected").removeClass('selected');
if($("#condition-checkeda").length==0){
$("#condition-checked #select-no").html("尚未选择");
}
//删除链接中的pr参数并重定向deleteSort('pr',ele);
}