className="sel";
inputId="PastCity";
hiddenInputId="PastCity_Id";
this.sel = new Object();
sel.url="Line_Content_Add.aspx";
sel.showCityList =function(){
$("cityBox").style.display="";
var el = Ext.get("cityListButton");///初始化各大城市选择框位置
$("cityBox").style.left=el.getX()+$("cityListButton").offsetWidth+"px";
$("cityBox").style.top=el.getY()+"px";
if($("cityBox").style.pixelWidth<300){//实现动态进入
$("cityBox").style.width=$("cityBox").style.pixelWidth+50;
$("cityBox").style.height=$("cityBox").style.pixelHeight+34;
setTimeout("showCityList()",1);
}
else{//加载内容
sel.doOperator(0,2,0);
}
}
sel.result ="ccc";
sel.showPlan =document.getElementById("cityBox");//document.createElement("div");
sel.initShowPlan =function(id,left,top){
sel.showPlan.setAttributor("id",id);
sel.showPlan.style.positon="relative";
sel.showPlan.style.left =left+"px";
sel.showPlan.style.top =top +"px";
var bodyContent =document.body||document.documentElement;
bodyContent.appendChild(sel.showPlan);
}
sel.doOperator =function(isForeign,status,id){
var selectId =id;
var showPlanTop ="";
var showPlanContent ="";
var showPlanBottom ="";
var resultList =sel.result.split("c");
if(isForeign==1){
switch(status){
case 2:if(selectId==0){
var resultList =sel.result.split("c");
resultList[1].split("|");
for(var i=1;i<resultList[1].split("|").length;i++){
selectId=resultList[1].split("|")[i].split(",")[0];
break;
}
if(selectId==0){
alert("你没有选择州,请选择州");
sel.doOperator(1,1,0);
return;
}
}
break;
case 3:if(selectId==0){
var resultList =sel.result.split("c");
resultList[2].split("|");
for(var i=1;i<resultList[2].split("|").length;i++){
if(resultList[2].split("|")[i].split(",")[0]!=0){
selectId=resultList[2].split("|")[i].split(",")[1];
break;
}
}
if(selectId==0){
alert("你没有选择国家,请选择州国家");
sel.doOperator(1,2,0);
return;
}
}
break;
}
switch(status){
case 1:showPlanTop ="";
showPlanTop +="<div style='background-color:InfoBackground;'><span style='font-weight:bold;'>请选择洲:</span><a href='' onclick='sel.doOperator(0,2,0);return false;'>选择国内</a></div>";
break;
case 2:showPlanTop ="";
showPlanTop +="<div style='padding-top:5px;background-color:InfoBackground;'><span style='font-weight:bold;'>已经选择的洲:</span><div style='padding-top:5px;background-color:InfoBackground;'><ul>";
var plateName="";
var plateId="";
for(var i=1;i<resultList[1].split("|").length;i++){
plateName=resultList[1].split("|")[i].split(",")[1];
plateId=resultList[1].split("|")[i].split(",")[0];
if(plateId==selectId){
showPlanTop +="<li style='display:inline;margin-left:4px;margin-right:6px;background:#000000;color:#FFF;'><a href='' style='' onclick='"+className+".doOperator(1,2,"+plateId+");return false;'>"+plateName+"</a></li>";
}
else{
showPlanTop +="<li style='display:inline;margin-left:4px;margin-right:6px'><a href='' onclick='"+className+".doOperator(1,2,"+plateId+");return false;'>"+plateName+"</a></li>";
}
}
showPlanTop +="</ul></div></div>";
break;
case 3:showPlanTop ="";
showPlanTop +="<div style='padding-top:5px;background-color:InfoBackground;'><div><span style='font-weight:bold;'>已经选择的国家:</span></div><div style='padding-top:5px;'><ul>";
var countryName="";
var countryId="";
for(var i=1;i<resultList[2].split("|").length;i++){
countryName=resultList[2].split("|")[i].split(",")[2];
countryId=resultList[2].split("|")[i].split(",")[1];
if(resultList[2].split("|")[i].split(",")[0]!=0){
if(countryId==selectId){
showPlanTop +="<li style='display:inline;margin-left:4px;margin-right:6px;background:#000000;color:#FFF;'><a href='###' style='color:#FFF' onclick='"+className+".doOperator(1,3,"+countryId+");return false;'>"+countryName+"</a></li>";
}
else{
showPlanTop +="<li style='display:inline;margin-left:4px;margin-right:6px'><a href='' onclick='"+className+".doOperator(1,3,"+countryId+");return false;'>"+countryName+"</a></li>";
}
}
}
showPlanTop +="</ul></div></div>";
break;
}
switch(status){
case 1:showPlanBottom +="<div class='cityBoxFoot'><a href='' onclick='"+className+".doOperator(1,2,0);return false;'>下一步>></a> <a href='###' onclick='"+className+".doOperator(1,1,0);return false;'>返回洲列表</a> <a href='' onclick='return "+className+".close()'>取消</a></div>";
break;
case 2:showPlanBottom +="<div class='cityBoxFoot' ><a href='' onclick='"+className+".doOperator(1,3,0);return false;'>下一步>></a> <a href='###' onclick='"+className+".doOperator(1,1,0);return false;'>返回洲列表</a> <a href='' onclick='return "+className+".close()'>取消</a></div>";
break;
case 3:showPlanBottom +="<div class='cityBoxFoot'><a href='' onclick='"+className+".doOperator(1,2,0);return false;'>返回国家列表</a> <a href='###' onclick='"+className+".doOperator(1,1,0);return false;'>返回洲列表</a> <a href='' onclick='return "+className+".close()'>完成</a></div>";
break;
}
switch(status){
case 1:{
showPlanContent="";
var pars = "action=getprovincecity&all=all";
var plateInfo="";
var myAjax = new Ajax.Request(
sel.url,
{method: 'post',
parameters: pars,
onComplete: function(s){
showPlanContent +="<div style='padding-top:5px'>";
if(s.responseText.trim() !=""){
plateInfo =s.responseText;
var plateInfoList =plateInfo.split("|");
var plateName ="";
var plateId ="";
var plateNameId="";
for(var i=1;i<plateInfoList.length;i++){
plateName=plateInfoList[i].split(",")[1];
plateId=plateInfoList[i].split(",")[0];
if(sel.result.split("c")[1].indexOf(plateId)!=-1){
showPlanContent +="<input type='checkbox' onclick=\""+className+".saveResult( 1,"+plateId+",'"+plateName+"',this);\" checked/>"+plateName;
}
else{
showPlanContent +="<input type='checkbox' onclick=\""+className+".saveResult( 1,"+plateId+",\'"+plateName+"\',this);\"/>"+plateName;
}
}
showPlanContent +="</div>";
document.getElementById("cityBox").innerHTML=showPlanTop+showPlanContent+showPlanBottom;
}
else{
showPlanContent +="没有数据</div>";
document.getElementById("cityBox").innerHTML=showPlanTop+showPlanContent+showPlanBottom;
}
}
}
);
break;
}
case 2:{
showPlanContent="";
var pars = "action=getprovincecity&plateid="+selectId;
var countryInfo="";
var myAjax = new Ajax.Request(
sel.url,
{method: 'post',
parameters: pars,
onComplete: function(s){
showPlanContent +="<div style='padding-top:5px'>";
if(s.responseText.trim() !=""){
countryInfo =s.responseText;
countryInfoList = countryInfo.split("|");
countryName ="";
countryId ="";
countryNameId="";
for(var i=1;i<countryInfoList.length;i++){
countryName=countryInfoList[i].split(",")[2];
countryId=countryInfoList[i].split(",")[0]+","+countryInfoList[i].split(",")[1];
if(sel.result.split("c")[2].indexOf(countryId)!=-1){
showPlanContent +="<input type='checkbox' onclick=\""+className+".saveResult( 2,'"+countryId+"','"+countryName+"',this)\" checked/>"+countryName;
}
else
{
showPlanContent +="<input type='checkbox' onclick=\""+className+".saveResult( 2,'"+countryId+"','"+countryName+"',this)\"/>"+countryName;
}
if(i%5==0)
showPlanContent +="</br>";
}
showPlanContent +="</div>";
document.getElementById("cityBox").innerHTML=showPlanTop+showPlanContent+showPlanBottom;
}
else{
showPlanContent +="没有数据</div>";
document.getElementById("cityBox").innerHTML=showPlanTop+showPlanContent+showPlanBottom;
}
}
}
);
break;
}
case 3:{
showPlanContent="";
var pars = "action=getprovincecity&countryid="+selectId;
var cityInfo="";
var myAjax = new Ajax.Request(
sel.url,
{method: 'post',
parameters: pars,
onComplete: function(s){
showPlanContent +="<div style='padding-top:5px'>";
if(s.responseText !=""){
cityInfo =s.responseText;
cityInfoList = cityInfo.split("|");
cityName ="";
cityId ="";
cityNameId="";
for(var i=1;i<cityInfoList.length;i++){
cityName=cityInfoList[i].split(",")[3];
cityId=cityInfoList[i].split(",")[0]+","+cityInfoList[i].split(",")[1]+","+cityInfoList[i].split(",")[2];
if(sel.result.split("c")[3].indexOf(cityId)!=-1){
showPlanContent +="<input type='checkbox' onclick=\""+className+".saveResult( 3,'"+ cityId+"','"+ cityName+"',this)\" checked/>"+ cityName;
}
else{
showPlanContent +="<input type='checkbox' onclick=\""+className+".saveResult( 3,'"+ cityId+"','"+ cityName+"',this)\"/>"+ cityName;
}
if(i%5==0)
showPlanContent +="</br>";
}
showPlanContent +="</div>";
document.getElementById("cityBox").innerHTML=showPlanTop+showPlanContent+showPlanBottom;
}
else{
showPlanContent +="没有数据</div>";
document.getElementById("cityBox").innerHTML=showPlanTop+showPlanContent+showPlanBottom;
}
}
}
);
break;
}
}
document.getElementById("cityBox").innerHTML=showPlanTop+showPlanContent+showPlanBottom;
}
else{
switch(status){
case 3: if(selectId==0){
var rusultList= sel.result.split("c");
for(var i=1;i<resultList[2].split("|").length;i++){
if(resultList[2].split("|")[i].split(",")[0]==0){
selectId=resultList[2].split("|")[i].split(",")[1];
break;
}
}
if(selectId==0){
alert("你没有选择省,请选择省");
sel.doOperator(0,2,0);
return;
}
}
break;
}
switch(status){
case 2:showPlanTop ="";
showPlanTop +="<div id='cityBoxHead' style='background-color:InfoBackground;padding-top:5px'><span style='font-weight:bold;'>请先选择省份:</span><a href='' onclick='sel.doOperator(1,1,0);return false;'>选择国外</a></div>";
break;
case 3:showPlanTop ="";
showPlanTop +="<div id='cityBoxHead' style='background-color:InfoBackground;padding-top:5px''><div style='background: infobackground;' ><span style='font-weight:bold;'>已选择的省份:</span><ul style='padding-top:5px'>";
var provinceId="";
var provinceName="";
var resultListDetail =sel.result.split("c")[2].split("|");
for(var i=1;i<resultListDetail.length;i++){
provinceId=resultListDetail[i].split(",")[1];
provinceName=resultListDetail[i].split(",")[2]
if(resultListDetail[i].split(",")[0]==0){
if(resultListDetail[i].split(",")[1]==selectId)
showPlanTop +="<li style='display:inline;margin-right:6px;background:#000000;color:#FFF;'><a href='###' onclick='"+className+".doOperator(0,3,"+provinceId+");return false;'>"+ provinceName+"</a></li>";
else
showPlanTop +="<li style='display:inline;margin-right:6px;'><a href='###' onclick='"+className+".doOperator(0,3,"+provinceId+");return false;'>"+ provinceName+"</a></li>";
}
}
showPlanTop +="</ul></div><div style='clear:both'></div></div>";
}
switch(status){
case 2:showPlanBottom ="";
showPlanBottom +="<div class='cityBoxFoot'><a href='###' onclick='"+className+".doOperator(0,3,0);return false;'>下一步>></a> <a href='' onClick='return sel.close();'>取消</a></div>";
break;
case 3:showPlanBottom =""
showPlanBottom +="<div class='cityBoxFoot'><a href='###' onclick='"+className+".doOperator(0,2,0);return false;'>返回省份列表</a> <a href='' onClick='return sel.close();'>完成</a></div>";
break;
}
switch(status){
case 2: showPlanContent=""
showPlanContent+="<div style='padding-top:5px'>";
var provinceInfoList = provinceInfo.split("|");
var resultList =sel.result.split("c");
var resultListDetail = resultList[2].split("|");
var provinceId="";
var provinceName="";
for(var i=1;i< provinceInfoList.length;i++){
provinceName=provinceInfoList[i].split(",")[1];
provinceId="0,"+provinceInfoList[i].split(",")[0];
if(resultList[2].indexOf(provinceId+",") !=-1)
showPlanContent+="<input type='checkbox' onclick=\""+className+".saveResult( 2,'"+ provinceId+"','"+ provinceName+"',this)\" id='DesProvince_"+i+"' checked /><label for='DesProvince_"+i+"'>"+provinceName+"</label>";
else
showPlanContent+="<input type='checkbox' onclick=\""+className+".saveResult( 2,'"+ provinceId+"','"+ provinceName+"',this)\" id='DesProvince_"+i+"' /><label for='DesProvince_"+i+"'>"+provinceName+"</label>";
if(i%6==0)
showPlanContent +="</br>";
}
document.getElementById("cityBox").innerHTML=showPlanTop+showPlanContent+showPlanBottom;
break;
case 3: showPlanContent="";
var pars = "action=getprovincecity&provinceId="+selectId;
var cityInfo="";
var myAjax = new Ajax.Request(
sel.url,
{method: 'post',
parameters: pars,
onComplete: function(s){
showPlanContent +="<div>";
if(s.responseText !=""){
cityInfo =s.responseText;
cityInfoList = cityInfo.split("|");
cityName ="";
cityId ="";
cityNameId="";
for(var i=1;i<cityInfoList.length;i++){
cityName=cityInfoList[i].split(",")[2];
cityId="0,"+cityInfoList[i].split(",")[0]+","+cityInfoList[i].split(",")[1];
if(sel.result.split("c")[3].indexOf(cityId)!=-1){
showPlanContent +="<input type='checkbox' onclick=\""+className+".saveResult( 3,'"+ cityId+"','"+ cityName+"',this)\" checked/>"+ cityName;
}
else{
showPlanContent +="<input type='checkbox' onclick=\""+className+".saveResult( 3,'"+ cityId+"','"+ cityName+"',this)\"/>"+ cityName;
}
if(i%6==0)
showPlanContent +="</br>";
}
showPlanContent +="</div>";
document.getElementById("cityBox").innerHTML=showPlanTop+showPlanContent+showPlanBottom;
}
else{
showPlanContent +="没有数据</div>";
document.getElementById("cityBox").innerHTML=showPlanTop+showPlanContent+showPlanBottom;
}
}
}
);
break;
}
}
}
sel.saveResult =function(status,id,name,elementChk){
var resultList = sel.result.split("c");
var resultListDetail =resultList[status];
if(elementChk.checked){
if(resultListDetail.indexOf("|"+id+","+name)==-1){
resultListDetail +="|"+id+","+name;
}
resultList[status]=resultListDetail;
}
else{
for(var i=status;i<4;i++){
var regstring="";
regstring ="http://www.cnblogs.com/swneng/admin/file://%7c(/?:\\d+,)*?(?:"+id+",)(?:\\d+,)*?(?:[\\u4E00-\\u9FA5]+)";
var repreg =new RegExp(regstring,"g");
resultListDetail =resultList[i];
if(resultListDetail.indexOf(id)!=-1){
resultListDetail=resultListDetail.replace(repreg,"");
}
resultList[i]=resultListDetail;
}
}
sel.result =resultList.join("c");
var resultCity ="";
var resultCityId =",";
var resultCountryId =",";
for(var i=1;i<resultList[3].split("|").length;i++){
resultCity +=resultList[3].split("|")[i].split(",")[3]+",";
resultCityId +=resultList[3].split("|")[i].split(",")[2]+",";
}
for(var i=1;i<resultList[2].split("|").length;i++){
if(resultList[3].indexOf(","+resultList[2].split("|")[i].split(",")[1]+",")!=-1)
resultCountryId +=resultList[2].split("|")[i].split(",")[1]+",";
}
sel.input.value=resultCity;
sel.hiddenInput.value=resultCountryId+"|"+resultCityId;
}
sel.close =function(){
$("cityBox").style.display="none";
$("cityBox").style.width =0;
$("cityBox").style.height =0;
$("cityBox").innerHTML="";
return false;
}