⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 util.js

📁 一些Acjax的控件简单应用学习实例
💻 JS
📖 第 1 页 / 共 3 页
字号:
    var shape = map.model.drawMgr.shapes[$(id).parentNode.parentNode.id];
    var model = shape.model;
    model.title = $F("title"+id)||null;
    model.notes = $F("notes"+id)||null;
    model.imgUrl = $F("imgUrl"+id)||null;
    model.linkUrl = $F("link"+id)||null;
    
    var url = "../login.jsf";
    //--------点-----------
    //增加参数
    var params = 'mapViewerAjax=mapViewerAjax&fieldValue=';
    params += 'TITLE:'+model.title;
    params += '-:-IMAGEURL:'+model.imgUrl;
    params += '-:-NOTES:'+model.notes;
    params += '-:-LINKURL:'+model.linkUrl;
    params += '-:-MARKERURL:'+model.markerUrl;
    params += '-:-LEVELS:'+model.levels;
    params += '-:-USERNAME:'+model.username;
    params += '-:-SHAPEID:'+model.id;
    params += '-:-TIPID:'+model.tipId;
    params += '-:-XY:'+model.xy;
    params += '&tableName=GX_POINT&optType=3&shapeType=0&queryType=4';
    
    //lineWidth/fullColor/lineColor
//    var params ='mapViewerAjax=mapViewerAjax&fieldValue=TITLE:'+model.title+'-:-IMAGEURL:'+model.imgUrl+'-:-NOTES:'+model.notes+'-:-LINKURL:'+model.linkUrl
//    +'-:-MARKERURL:'+model.markerUrl+'-:-LEVELS:'+model.levels+'-:-USERNAME:'+model.username+'-:-SHAPEID:'+model.id+'-:-TIPID:1-:-XY:'+model.xy+'&tableName=GX_POINT&optType=3&shapeType=0&queryType=4';
    //查询参数
    //var params ="mapViewerAjax=mapViewerAjax&fieldValue=whereExpression:OBJECTID equal 689&tableName=GX_POINT&optType=0&shapeType=0&queryType=4";
	//修改参数
    //var params ="mapViewerAjax=mapViewerAjax&fieldValue=objectid:18-:-NAME:testU1-:-MARKIMAGEURL:mark-:-SCALES:10000-:-USERNAME:user1-:-IMAGEID:7-:-TIPID:1&tableName=GX_POINT&optType=1&shapeType=0&queryType=4";
    //删除参数
    //var params ="mapViewerAjax=mapViewerAjax&fieldValue=objectid:17&tableName=GX_POINT&optType=2&shapeType=0&queryType=4";
    //--------------------
    //--------线-----------
    //增加参数
//    var params ='mapViewerAjax=mapViewerAjax&fieldValue=NAME:test1-:-MARKIMAGEURL:mark-:-SCALES:10000-:-USERNAME:user1-:-IMAGEID:7-:-TIPID:1-:-xy:113.28108,23.13431;113.26108,23.14431;113.26108,23.16431;113.28108,23.13431&tableName=GX_PLOYGON&optType=3&shapeType=2&queryType=4';
    //查询参数
    //var params ="mapViewerAjax=mapViewerAjax&fieldValue=whereExpression:objectid equal 1&tableName=GX_POINT&optType=0&shapeType=1&queryType=4";
	//修改参数
    //var params ="mapViewerAjax=mapViewerAjax&fieldValue=objectid:18-:-NAME:testU1-:-MARKIMAGEURL:mark-:-SCALES:10000-:-USERNAME:user1-:-IMAGEID:7-:-TIPID:1&tableName=GX_POINT&optType=1&shapeType=1&queryType=4";
    //删除参数
    //var params ="mapViewerAjax=mapViewerAjax&fieldValue=objectid:17&tableName=GX_POINT&optType=2&shapeType=1&queryType=4";
    //--------------------
    alert(params);
    new Ajax.Request(url, {method:"post", parameters:params, onComplete:function(res){
        var result = res.responseXML.getElementsByTagName("optResult").item(0).firstChild.nodeValue;
        if(result=="succeed"){
            model.objectId = res.responseXML.getElementsByTagName("fieldValue").item(0).firstChild.nodeValue.split(':')[1];
        }
        else
            alert("false");
            
    }});
    $(id).style.display = "none";
    shape.updateTitle($F("title"+id));
}

editHandler = function(id){
    var shape = map.model.drawMgr.shapes[$(id).parentNode.parentNode.id];
    var model = shape.model;
    shape.resetTip("Edit");   
    $("title"+id).value = model.title;//obj["TITLE"];
    $("notes"+id).value = model.notes;//obj["NOTES"];
    $("imgUrl"+id).value = model.imgUrl;//obj["IMAGEURL"];
    $("link"+id).value = model.linkUrl;//obj["LINKURL"];
   
}

cancelHandler = function(id){
    var mgr = map.model.drawMgr;
    var shape = mgr.shapes[$(id).parentNode.parentNode.id];
    if(shape.hasTitle){
        mgr.hideTip($(id));
    }
    else{
        mgr.removeTipAndShapeAndTitle($(id).parentNode.parentNode);
    }    
}

delHandler = function(id){
    var mgr = map.model.drawMgr;
    mgr.removeTipAndShapeAndTitle($(id).parentNode.parentNode);
}
linkHandler = function(id){
    var mgr = map.model.drawMgr;
    var shape = mgr.shapes[$(id).parentNode.parentNode.id];
    window.open(shape.model.linkUrl,"_blank");
}
shapeHandler = function(id){
    alert("该功能暂不实现");
}




var traceWindow;
var isdebug = 1;
function trace(s) {
    if (isdebug) {
        var curr = new Date();
        try {
            traceWindow.document.write("[" + curr.toLocaleDateString() + " " + curr.toLocaleTimeString() + "] " + s + "<br>");
        }
        catch (e) {
            traceWindow = window.open("", "trace");
            traceWindow.document.write("[" + curr.toLocaleDateString() + " " + curr.toLocaleTimeString() + "] " + s + "<br>");
        }
    }
}

//上传图片
Util.uploadPic=function (src)
{
	map.model.curPic=$(src);
	if(!map.model.upload)
	{
		var wid = Util.getValueOfNoPX($("map").style.width);
		var heigh = Util.getValueOfNoPX($("map").style.height);	

		if(!map.model.cover)
		{
			var locker=Util.createDiv('lock_cover',0.1,0.1,wid,heigh,null,"absolute","0px solid blue");
			locker.style.backgroundColor = "gray";
			var hei=$("map").style.height;
			var lo=$("map").style.width;
			locker.style.zIndex=50000;
			locker.style.filter = "alpha(opacity=40)"; 
			locker.style.opacity = "0.40";
			$("map").appendChild(locker);
			map.model.cover=locker;
			
		}
			
		var upload=Util.createDiv('upload_pic',wid/2-110,heigh/2-90,220,80,null,"absolute","0px solid blue");
		upload.innerHTML="";
		$("map").appendChild(upload);
//		upload.style.display="none";
		upload.innerHTML='<iframe id="upload_pic_frm" src="./map/common/upload.htm" style=" width:250;height:100;border: 2px solid #0cc" scrolling="no" frameborder="0"></iframe>';
		upload.style.zIndex=50001;
		map.model.upload=upload;
	}
	map.model.cover.style.display="";
	map.model.upload.style.display="";
}
function recallAftUpload(rst)
{
	map.model.upload.style.display="none";
	map.model.cover.style.display="none";
	$("upload_pic_frm").src="./map/upload.htm";
	map.model.curPic.value=rst;
}

function cancelUploadPic()
{
	map.model.upload.style.display="none";
	map.model.cover.style.display="none";
}


//根据屏幕分辨调整地图控件的宽度和高度 Deng Guoqi 2008-05-26
function AdjustMapDiv (id,left,top,width,height){
    if(!document.getElementById(id)){
	    return;
    }
    var e = document.getElementById(id);
    
    if(left)
    {
        e.style.left = parseInt(left) + "px";
    }
    else
    {
        e.style.left = "0px";
    }
    
    if(top)
    {
        e.style.top = parseInt(top) + "px";
    }
    else
    {
        e.style.top = "0px";
    }
    
    //取得屏幕分辨率

    var wHeight = window.screen.height;
    var wWidth = window.screen.width;
    
    //调整宽度
    if(width)
    {
        e.style.width = parseInt(width) + "px";
    }
    else
    {
        var width = wWidth - 26;//减去窗口两边框宽度

        e.style.width = parseInt(width) + "px";
    }

    //调整高度
    if(height)
    {
        e.style.height = parseInt(height) + "px";
    }
    else
    {
        //var height = wHeight - (45+61+19+8) -157;//-(45+61+19+8)减去工具条、Logo及边缘条的高度 -157窗口上下栏高度  IE有工具栏的情况
        var height = wHeight - (45+61+19+8) - (20+26);//-(45+61+19+8)减去工具条、Logo及边缘条的高度 -(20+26)窗口上下栏高度 IE无工具栏的情况

        e.style.height = parseInt(height) + "px";
    }

}

//根据屏幕分辨调整Logo栏中各元素的宽度 Deng Guoqi 2008-05-26
function AdjustPageHeader(){
    var e = new Array();
    e.push(document.getElementById('table01'));
    e.push(document.getElementById('table02'));
    e.push(document.getElementById('table03'));
 
    e.push(document.getElementById('td01'));
    e.push(document.getElementById('td02'));
    e.push(document.getElementById('td03'));
    e.push(document.getElementById('td04'));
    e.push(document.getElementById('td05'));
    e.push(document.getElementById('td06'));
//    e.push(document.getElementById('bar'));

    //取得屏幕分辨率

//    var wWidth = window.screen.width;
    var wWidth = window.screen.width-2;
	for (var i=0;i<e.length ;i++ )
	{
		if(e[i])
		{
		    var val = e[i].width;
			e[i].width =  val * (wWidth/1280);	
		}		 
	}
 }
 
//调整各工具中Flag标记位

var tool_indexPos = new Array();
function AdjustToolsIndexPos(){
    var wWidth = window.screen.width;
    //var wWidth = window.screen.width;
    var e = document.getElementById('td05');
    var firstPos = e.width * (wWidth/1280);//266;
	tool_indexPos.push(firstPos+(585-firstPos)* (wWidth/1280));//625-400
	tool_indexPos.push(firstPos+(465-firstPos)* (wWidth/1280));//514
	tool_indexPos.push(firstPos+(700-firstPos)* (wWidth/1280));//743
	tool_indexPos.push(firstPos+(790-firstPos)* (wWidth/1280));//820
	tool_indexPos.push(firstPos+(880-firstPos)* (wWidth/1280));//907
	tool_indexPos.push(firstPos+(960-firstPos)* (wWidth/1280));//985
}

//根据屏幕分辨调整工具栏中各组Button元素的位置 Deng Guoqi 2008-05-26
function AdjustButtonsPos(e,j)
{
    var flagImgWidth = 12;//标记图标的宽度

    var toolsWidth = toolInterval * e.length;//toolInterval--工具组中Button的宽度

    var firstPos = tool_indexPos[j] + flagImgWidth/2 - toolsWidth/2;//计算工具组按钮开始位置

 
    //调整位置
 	for (var i=0;i<e.length ;i++ )
	{
		if(e[i])
		{
		    var val = firstPos + i*toolInterval;
			e[i].style.left =  parseInt(val) + "px";	
		}		 
	}

}

//根据屏幕分辨调整工具栏中各组工具中的各个Button的位置 Deng Guoqi 2008-05-26
function AdjustToolsPos(){
    var e1 = new Array();
    e1.push(document.getElementById('locate'));
    e1.push(document.getElementById('personSearch'));
    e1.push(document.getElementById('houseSearch'));
    AdjustButtonsPos(e1,1);
    
    var e2 = new Array();
    e2.push(document.getElementById('drawDot'));
    e2.push(document.getElementById('drawHouse'));
    e2.push(document.getElementById('polyline'));
    e2.push(document.getElementById('area'));
    AdjustButtonsPos(e2,0);
   
    var e3 = new Array();
    e3.push(document.getElementById('personInfo'));
    e3.push(document.getElementById('unitInfo'));
    e3.push(document.getElementById('houseInfo'));
    e3.push(document.getElementById('clewInfo'));
    e3.push(document.getElementById('tempPerson'));
    e3.push(document.getElementById('lendHouse'));
    AdjustButtonsPos(e3,2);
   
    var e4 = new Array();
    e4.push(document.getElementById('leaderTask'));
    e4.push(document.getElementById('policeFrame'));
    AdjustButtonsPos(e4,3);
   
    var e5 = new Array();
    e5.push(document.getElementById('houseInfoReg'));
    e5.push(document.getElementById('lendHouseInfo'));
    e5.push(document.getElementById('unitReg'));
    e5.push(document.getElementById('happyPlaceReg'));
    e5.push(document.getElementById('keyUnitReg'));
    e5.push(document.getElementById('personInfoReg'));
    e5.push(document.getElementById('peaceKeepReg'));
    e5.push(document.getElementById('mediHouseReg'));
    AdjustButtonsPos(e5,4);
  
    var e6 = new Array();
    e6.push(document.getElementById('sysRunStic'));
    e6.push(document.getElementById('policeDataStic'));
    e6.push(document.getElementById('communityStic'));
    AdjustButtonsPos(e6,5);

};

//对数组类型进行扩展,增加插入和删除方法
Array.prototype.insert = function( index, value ) 
{         
    var part1 = this.slice( 0, index );
    var part2 = this.slice( index );
    part1.push( value );
    return( part1.concat( part2 ) );
};

Array.prototype.remove = function( index )
{
    var part1 = this.slice( 0, index );
    var part2 = this.slice( index );
    part1.pop();
    return( part1.concat( part2 ) );
}; 

//当前鼠标点中的地理要素
Util.MouseClickGeoItem = null;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -