input框type=file设置cursor:pointer的问题

为了让美化上传文件框,设置了cursor:pointer;,然而不起作用,然后百度找到了解决方法,设置font-size:0,这样就可以了。
  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>便民设施系统</title> <meta http-equiv="content-type" content="text/html; charset=gbk"/> <link rel="stylesheet" type="text/css" href="style.css"></link> <script src="http://ditu.google.com/maps?file=api&v=2& key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ- i1QfUnH94QxWIa6N4U6MouMmBA&h1=zh-CN" type="text/javascript"></script> <script type="text/javascript"> //实现选放大缩小功能 function DragZoomControl(opts_boxStyle, opts_other, opts_callbacks) { this.globals = { draggingOn: false, cornerTopDiv: null, cornerRightDiv: null, cornerBottomDiv: null, cornerLeftDiv: null, mapPosition: null, outlineDiv: null, mapWidth: 0, mapHeight: 0, mapRatio: 0, startX: 0, startY: 0, borderCorrection: 0 }; //设置的style this.globals.style = { opacity: .2, fillColor: "#000", border: "2px solid blue" }; var style = this.globals.style; for (var s in opts_boxStyle) { style[s]=opts_boxStyle[s]; } var borderStyleArray = style.border.split(' '); style.outlineWidth = parseInt(borderStyleArray[0].replace(/\D/g,'')); style.outlineColor = borderStyleArray[2]; style.alphaIE = 'alpha(opacity=' + (style.opacity * 100) + ')'; this.globals.backStack=[]; //其他选项 this.globals.options={ buttonHTML: 'zoom ...', buttonStartingStyle: {width: '52px', border: '1px solid black', padding: '2px'}, buttonStyle: {background: '#FFF'}, backButtonHTML: 'zoom back', backButtonStyle: {background: '#FFF', display: 'none'}, buttonZoomingHTML: 'Drag a region on the map', buttonZoomingStyle: {background: '#FF0'}, overlayRemoveTime: 6000, backButtonEnabled: false, stickyZoomEnabled: false, rightMouseZoomOutEnabled: false }; for (var s in opts_other) { this.globals.options[s] = opts_other[s] } //callbacks:buttonclick,dragstart,dragging,dragend,backbuttonclick if (opts_callbacks == null) { opts_callbacks = {} } this.globals.callbacks = opts_callbacks; } DragZoomControl.prototype = new GControl(); /** *方法 */ DragZoomControl.prototype.saveMapContext = function(text) { if (this.globals.options.backButtonEnabled) { this.saveBackContext_(text,true); this.globals.backButtonDiv.style.display = 'block'; } }; DragZoomControl.prototype.initiateZoom = function() {this.buttonclick_()}; DragZoomControl.prototype.initiateZoomBack = function() { if (this.globals.options.backButtonEnabled) this.backbuttonclick_()}; DragZoomControl.prototype.initButton_ = function(buttonContainerDiv) { var G = this.globals; var buttonDiv = document.createElement('div'); buttonDiv.innerHTML = G.options.buttonHTML; DragZoomUtil.style([buttonDiv], {cursor: 'pointer', zIndex:200}); DragZoomUtil.style([buttonDiv], G.options.buttonStartingStyle); DragZoomUtil.style([buttonDiv], G.options.buttonStyle); buttonContainerDiv.appendChild(buttonDiv); return buttonDiv; }; //初始化后退按钮 DragZoomControl.prototype.initBackButton_ = function(buttonContainerDiv) { var G = this.globals; var backButtonDiv = document.createElement('div'); backButtonDiv.innerHTML = G.options.backButtonHTML; DragZoomUtil.style([backButtonDiv], {cursor: 'pointer', zIndex:200}); DragZoomUtil.style([backButtonDiv], G.options.buttonStartingStyle); DragZoomUtil.style([backButtonDiv], G.options.backButtonStyle); buttonContainerDiv.appendChild(backButtonDiv); return backButtonDiv; }; //设置按钮模式 DragZoomControl.prototype.setButtonMode_ = function(mode){ var G = this.globals; if (mode == 'zooming') { G.buttonDiv.innerHTML = G.options.buttonZoomingHTML; DragZoomUtil.style([G.buttonDiv], G.options.buttonStartingStyle); DragZoomUtil.style([G.buttonDiv], G.options.buttonZoomingStyle); } else { G.buttonDiv.innerHTML = G.options.buttonHTML; DragZoomUtil.style([G.buttonDiv], G.options.buttonStartingStyle); DragZoomUtil.style([G.buttonDiv], G.options.buttonStyle); } }; //初始化控件 DragZoomControl.prototype.initialize = function(map) { var G = this.globals; var me = this; var mapDiv = map.getContainer(); // Create div for both buttons var buttonContainerDiv = document.createElement("div"); DragZoomUtil.style([buttonContainerDiv], {cursor: 'pointer', zIndex: 150}); // create and init the zoom button //DOM:button var buttonDiv = this.initButton_(buttonContainerDiv); // create and init the back button //DOM:button var backButtonDiv = this.initBackButton_(buttonContainerDiv); // Add the two buttons to the map mapDiv.appendChild(buttonContainerDiv); //DOM:map covers var zoomDiv = document.createElement("div"); var DIVS_TO_CREATE = ['outlineDiv', 'cornerTopDiv', 'cornerLeftDiv', 'cornerRightDiv', 'cornerBottomDiv']; for (var i=0; i<DIVS_TO_CREATE.length; i++) { var id = DIVS_TO_CREATE[i]; var div = document.createElement("div"); DragZoomUtil.style([div], {position: 'absolute', display: 'none'}); zoomDiv.appendChild(div); G[id] = div; } DragZoomUtil.style([zoomDiv], {position: 'absolute', display: 'none', overflow: 'hidden', cursor: 'crosshair', zIndex: 101}); mapDiv.appendChild(zoomDiv); // add event listeners GEvent.addDomListener(buttonDiv, 'click', function(e) { me.buttonclick_(e); }); GEvent.addDomListener(backButtonDiv, 'click', function(e) { me.backbuttonclick_(e); }); GEvent.addDomListener(zoomDiv, 'mousedown', function(e) { me.coverMousedown_(e); }); GEvent.addDomListener(document, 'mousemove', function(e) { me.drag_(e); }); GEvent.addDomListener(document, 'mouseup', function(e) { me.mouseup_(e); }); // get globals G.mapPosition = DragZoomUtil.getElementPosition(mapDiv); G.buttonDiv = buttonDiv; G.backButtonDiv = backButtonDiv; G.mapCover = zoomDiv; G.map = map; G.borderCorrection = G.style.outlineWidth * 2; this.setDimensions_(); //styles this.initStyles_(); // disable text selection on map cover G.mapCover.onselectstart = function() {return false}; return buttonContainerDiv; }; DragZoomControl.prototype.getDefaultPosition = function() { return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(3, 120)); }; //鼠标按下事件 DragZoomControl.prototype.coverMousedown_ = function(e){ var G = this.globals; var pos = this.getRelPos_(e); G.startX = pos.left; G.startY = pos.top; if (e.which) { var rightMouse = (e.which != 1); } else if (e.button) { var rightMouse = (e.button != 1); } G.draggingRightMouse = rightMouse; DragZoomUtil.style([G.mapCover], {background: 'transparent', opacity: 1, filter: 'alpha(opacity=100)'}); DragZoomUtil.style([G.outlineDiv], {left: G.startX + 'px', top: G.startY + 'px', display: 'block', width: '1px', height: '1px'}); G.draggingOn = true; G.cornerTopDiv.style.top = (G.startY - G.mapHeight) + 'px'; G.cornerTopDiv.style.display ='block'; G.cornerLeftDiv.style.left = (G.startX - G.mapWidth) +'px'; G.cornerLeftDiv.style.top = G.startY + 'px'; G.cornerLeftDiv.style.display = 'block'; G.cornerRightDiv.style.left = G.startX + 'px'; G.cornerRightDiv.style.top = G.startY + 'px'; G.cornerRightDiv.style.display = 'block'; G.cornerBottomDiv.style.left = G.startX + 'px'; G.cornerBottomDiv.style.top = G.startY + 'px'; G.cornerBottomDiv.style.width = '0px'; G.cornerBottomDiv.style.display = 'block'; // invoke the callback if provided if (G.callbacks.dragstart != null) { G.callbacks.dragstart(G.startX, G.startY); } return false; }; //鼠标拖动事件 DragZoomControl.prototype.drag_ = function(e){ var G = this.globals; if(G.draggingOn) { var pos = this.getRelPos_(e); var rect = this.getRectangle_(G.startX, G.startY, pos, G.mapRatio); if (rect.left) { addX = -rect.width; } else { addX = 0; } if (rect.top) { addY = -rect.height; } else { addY = 0; } DragZoomUtil.style([G.outlineDiv], {left: G.startX + addX + 'px', top: G.startY + addY + 'px', display: 'block', width: '1px', height: '1px'}); G.outlineDiv.style.width = rect.width + "px"; G.outlineDiv.style.height = rect.height + "px"; G.cornerTopDiv.style.height = ((G.startY + addY) - (G.startY - G.mapHeight)) + 'px'; G.cornerLeftDiv.style.top = (G.startY + addY) + 'px'; G.cornerLeftDiv.style.width = ((G.startX + addX) - (G.startX - G.mapWidth)) + 'px'; G.cornerRightDiv.style.top = G.cornerLeftDiv.style.top; G.cornerRightDiv.style.left = (G.startX + addX + rect.width + G.borderCorrection) + 'px'; G.cornerBottomDiv.style.top = (G.startY + addY + rect.height + G.borderCorrection) + 'px'; G.cornerBottomDiv.style.left = (G.startX - G.mapWidth + ((G.startX + addX) - (G.startX - G.mapWidth))) + 'px'; G.cornerBottomDiv.style.width = (rect.width + G.borderCorrection) + 'px'; // invoke callback if provided if (G.callbacks.dragging != null) { G.callbacks.dragging(G.startX, G.startY, rect.endX, rect.endY) } return false; } }; //鼠标弹起事件 DragZoomControl.prototype.mouseup_ = function(e){ var G = this.globals; if (G.draggingOn) { var pos = this.getRelPos_(e); G.draggingOn = false; var rect = this.getRectangle_(G.startX, G.startY, pos, G.mapRatio); if (rect.left) rect.endX = rect.startX - rect.width; if (rect.top) rect.endY = rect.startY - rect.height; this.resetDragZoom_(); var nwpx = new GPoint(rect.startX, rect.startY); var nepx = new GPoint(rect.endX, rect.startY); var sepx = new GPoint(rect.endX, rect.endY); var swpx = new GPoint(rect.startX, rect.endY); var nw = G.map.fromContainerPixelToLatLng(nwpx); var ne = G.map.fromContainerPixelToLatLng(nepx); var se = G.map.fromContainerPixelToLatLng(sepx); var sw = G.map.fromContainerPixelToLatLng(swpx); var zoomAreaPoly = new GPolyline([nw, ne, se, sw, nw], G.style.outlineColor, G.style.outlineWidth + 1,.4); try{ G.map.addOverlay(zoomAreaPoly); setTimeout (function() {G.map.removeOverlay(zoomAreaPoly)}, G.options.overlayRemoveTime); }catch(e) {} var polyBounds = zoomAreaPoly.getBounds(); var ne = polyBounds.getNorthEast(); var sw = polyBounds.getSouthWest(); var se = new GLatLng(sw.lat(), ne.lng()); var nw = new GLatLng(ne.lat(), sw.lng()); if (G.options.rightMouseZoomOutEnabled && G.draggingRightMouse) { var mapSpan = G.map.getBounds().toSpan(); var polySpan = polyBounds.toSpan(); var dSize = Math.max(mapSpan.lat()/polySpan.lat(), mapSpan.lng()/polySpan.lng()); var zoomLevel = G.map.getZoom() - Math.ceil(Math.log(dSize, 2)); } else { var zoomLevel = G.map.getBoundsZoomLevel(polyBounds); } var center = polyBounds.getCenter(); G.map.setCenter(center, zoomLevel); // invoke callback if provided if (G.callbacks.dragend != null) { G.callbacks.dragend(nw, ne, se, sw, nwpx, nepx, sepx, swpx); } //re-init if sticky if (G.options.stickyZoomEnabled) { //GLog.write("stickyZoomEnabled, re-initting"); this.initCover_(); if (G.options.backButtonEnabled) this.saveBackContext_(G.options.backButtonHTML,false); // save the map context for back button G.backButtonDiv.style.display='none'; } } }; //保存缩放尺寸 DragZoomControl.prototype.setDimensions_ = function() { var G = this.globals; var mapSize = G.map.getSize(); G.mapWidth = mapSize.width; G.mapHeight = mapSize.height; G.mapRatio = G.mapHeight / G.mapWidth; // set left:0px in next <div>s in case we inherit text-align:center from map <div> in IE. DragZoomUtil.style([G.mapCover, G.cornerTopDiv, G.cornerRightDiv, G.cornerBottomDiv, G.cornerLeftDiv], {top: '0px', left: '0px', width: G.mapWidth + 'px', height: G.mapHeight +'px'}); }; //初始化style DragZoomControl.prototype.initStyles_ = function(){ var G = this.globals; DragZoomUtil.style([G.mapCover, G.cornerTopDiv, G.cornerRightDiv, G.cornerBottomDiv, G.cornerLeftDiv], {filter: G.style.alphaIE, opacity: G.style.opacity, background:G.style.fillColor}); G.outlineDiv.style.border = G.style.border; }; //选button的click事件 DragZoomControl.prototype.buttonclick_ = function(){ var G = this.globals; G.backButtonDiv.style.display='none'; if (G.mapCover.style.display == 'block') { // reset if clicked before dragging this.resetDragZoom_(); if (G.options.backButtonEnabled) { this.restoreBackContext_(); // pop the backStack on a button reset if (G.backStack.length==0) G.backButtonDiv.style.display='none'; } } else { this.initCover_(); if ( G.options.backButtonEnabled ) this.saveBackContext_(G.options.backButtonHTML,false); // save the map context for back button } }; //后退按钮的click事件 DragZoomControl.prototype.backbuttonclick_ = function(){ var G = this.globals; if (G.options.backButtonEnabled && G.backStack.length > 0) { this.restoreBackContext_(); // invoke the callback if provided if (G.callbacks['backbuttonclick'] != null) { G.callbacks.backbuttonclick(G.methodCall); } } }; //后退保存功能 DragZoomControl.prototype.saveBackContext_ = function(text,methodCall) { var G = this.globals; var backFrame = {}; backFrame["center"] = G.map.getCenter(); backFrame["zoom"] = G.map.getZoom(); backFrame["maptype"] = G.map.getCurrentMapType(); backFrame["text"] = G.backButtonDiv.innerHTML; // this saves the previous button text backFrame["methodCall"] = methodCall; //This determines if it was an internal or method call G.backStack.push(backFrame); G.backButtonDiv.innerHTML = text; // Back Button is turned on in resetDragZoom_() }; //后退功能 DragZoomControl.prototype.restoreBackContext_ = function() { var G = this.globals; var backFrame = G.backStack.pop(); G.map.setCenter(backFrame["center"],backFrame["zoom"],backFrame["maptype"]); G.backButtonDiv.innerHTML = backFrame["text"]; G.methodCall = backFrame["methodCall"]; if (G.backStack.length==0) G.backButtonDiv.style.display = 'none'; // if we're at the top of the stack, hide the back botton }; //在地图上显示叠加层 DragZoomControl.prototype.initCover_ = function(){ var G = this.globals; G.mapPosition = DragZoomUtil.getElementPosition(G.map.getContainer()); this.setDimensions_(); this.setButtonMode_('zooming'); DragZoomUtil.style([G.mapCover], {display: 'block', background: G.style.fillColor}); DragZoomUtil.style([G.outlineDiv], {width: '0px', height: '0px'}); //invoke callback if provided if(G.callbacks['buttonclick'] != null){ G.callbacks.buttonclick(); } }; //获得鼠标的坐标 DragZoomControl.prototype.getRelPos_ = function(e) { var pos = DragZoomUtil.getMousePosition(e); var G = this.globals; return {top: (pos.top - G.mapPosition.top), left: (pos.left - G.mapPosition.left)}; }; //当用户拉时求的矩形 DragZoomControl.prototype.getRectangle_=function(startX,startY,pos,ratio){ var left=false; var top=false; var dX=pos.left-startX; var dY=pos.top-startY; if(dX<0){ dX=dX*-1; top=true; } delta=dX>dY?dX:dY; return{ startX:startX, startY:startY, endX:startX+delta, endY:startY+parseInt(delta*ratio), width:delta, height:parseInt(delta*ratio), left:left, top:top } }; //重置Buttonde的CSS DragZoomControl.prototype.resetDragZoom_=function(){ var G=this.globals; DragZoomUtil.style([G.mapCover,G.cornerTopDiv,G.cornerRightDiv,G.cornerBottomDiv,G.cornerLeftDiv], {display:'none',opacity:G.style.opacity,fillter:G.style.alphaIE}); G.outlineDiv.style.display='none'; this.setButtonMode_('normal'); if(G.options.backButtonEnabled && (G.backStack.length>0))G.backButtonDiv.style.display='block'; }; var DragZoomUtil={}; //根据ID取得元素 DragZoomUtil.gE=function(sId){ return document.getElementById(sId); }; //取得DOM元素的绝对位置 DragZoomUtil.getMousePosition=function(e){ var posX=0; var posY=0; if(!e)var e=window.event; if(e.pageX||e.pageY){ posX=e.pageX; posY=e.pageY; }else if(e.clientX||e.clientY){ posX=e.clientX+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft); posY=e.clientY+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop); } return {left:posX,top:posY}; }; //取得某一DOM元素的位置 DragZoomUtil.getElementPosition=function(element){ var leftPos=element.offsetLeft; var topPos=element.offsetTop; var parElement=element.offsetParent; while(parElement!=null){ leftPos+=parElement.offsetLeft; topPos+=parElement.offsetTop; parElement=parElement.offsetParent; } return{left:leftPos,top:topPos}; }; //将style应用于DOM元素 DragZoomUtil.style=function(elements,styles){ if(typeof(elements)=='string'){ eiements=DragZoomUtil.getManyElements(elements); } for(var i=0;i<elements.length;i++){ for(var s in styles){ elements[i].style[s]=styles[s]; } } }; //根据DOM元素的集合ID取得DOM元素 DragZoomUtil.getManyElements=function(idsString){ var idsArray=idsString.split(','); var eiement=[]; for(var i=0;i<idsArray.length;i++){ eiements[elements.length]=DragZoomUtil.gE(idsArray[i]) }; return eiement; }; //实现搜索功能 var geocoder=null; var map; var contextmenu; var GoogleGeocoder=null; var GGeoAddressAccuracy=["Unkown location.", "Country level accuracy.", "Region (state,province,prefecture,etc.)level accuracy.", "Sub-region(country,municipality,etc.)level accuracy.", "Town(city,village)level accuracy.", "Post code (zip code)level accuracy.", "Street level accuracy.", "Intersection level accuracy.", "Address level accuracy.", "Premise (building name,property name,shopping center,etc.)level accuracy." ]; var status=[]; status[G_GEO_SUCCESS]="Success"; status[G_GEO_MISSING_ADDRESS]="Missing Address"; status[G_GEO_UNKNOWN_ADDRESS]="Unknown Address"; status[G_GEO_UNAVAILABLE_ADDRESS]="Unavailable Address"; status[G_GEO_BAD_KEY]="Bad Key"; status[G_GEO_TOO_MANY_QUERIES]="Too Many Queries"; status[G_GEO_SERVER_ERROR]="Server Error"; function showLocation(){ //清除marker map.clearOverlays(); document.getElementById('divOutput').innerHTML="搜索中..."; var address=document.getElementById('txtAddress').value; geocoder.getLocations(address,cb_showLocation); } function cb_showLocation(result){ //显示结果 if(result.Status.code==G_GEO_SUCCESS){ //成功表明 document.getElementById("divOutput").innerHTML="成功("+result.Placemark.length+")<br/>"; for(var i=0;i<result.Placemark.length;i++){ var lat=result.Placemark[i].Point.coordinates[1]; var lng=result.Placemark[i].Point.coordinates[0]; var address=result.Placemark[i].address;//地址 var point=new GLatLng(lat,lng); var marker=new GMarker(point,{title:i+1});; map.addOverlay(marker); document.getElementById("divOutput").innerHTML+=((i+1)+""+ address+"<small>"+point.toString()+"</small><br/>"); //(address"<a href=javascript:go("+lat+","+lng+")>go</a><br/>"); }//for }//if else{ document.getElementById("divOutput").innerHTML=result.Status.code; }//else } /** * 这个例子演示了 Google Map API 的以下功能: * * 可拖拽的标注 * * 在地图上覆盖折线 * * 计算地理距离 * * 事件处理(单击、拖拽) * * 消息提示窗口(气泡窗口) * * 利用链表维护各种对象 * * 自定义控件 * * 注意:为了在 IE6 中正常显示折线,必须在网页的 <HTML> 标签中加上: * <html xmlns:v="urn:schemas-microsoft-com:vml"> * * @author haogang */ /** * 本示例用一个双向链表维护用户设定的标注,能够容易的实现标注的遍历和删除 * 每个链表结点 m 有如下字段: * m.prev 前驱标注 * m.next 后继标注 * m.segPrev 连接本标注与前驱标注的线段 * m.segNext 连接本标注与后继标注的线段 */ function GRulerControl() { var me = this; // 可国际化的字符串 me.RESET_BUTTON_TITLE_ = '清除所有测距标注'; me.ENABLE_BUTTON_TITLE_ = '添加测距标注已启用,单击这里禁用'; me.DISABLE_BUTTON_TITLE_ = '添加测距标注已禁用,单击这里启用'; me.DELETE_BUTTON_TITLE_ = '删除'; me.RESET_BUTTON_IMAGE_ = 'images/ruler_clear.png'; me.ENABLE_BUTTON_IMAGE_ = 'images/ruler_enabled.png'; me.DISABLE_BUTTON_IMAGE_ = 'images/ruler_disabled.png'; me.BACKGROUND_IMAGE_ = 'images/ruler_background.png' me.KILOMETER_ = '公里'; me.METER_ = '米'; } GRulerControl.prototype = new GControl(); /** * 初始化标尺控件 */ GRulerControl.prototype.initialize = function(map) { var me = this; var container = document.createElement('div'); /** *默认位置在右上角 */ GRulerControl.prototype.getDefaultPosition = function() { return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(8, 30)); } me.setButtonStyle_(container); // “启用/禁用”按钮 var btnEnable = document.createElement('img'); btnEnable.width = btnEnable.height = 20; GEvent.addDomListener(btnEnable, 'click', function() { me.setEnabled(!me.isEnabled()); } ); container.appendChild(btnEnable); // “重置”按钮 var btnReset = document.createElement('img'); btnReset.width = btnReset.height = 20; btnReset.src = me.RESET_BUTTON_IMAGE_; btnReset.title = me.RESET_BUTTON_TITLE_; GEvent.addDomListener(btnReset, 'click', function() { me.reset(); } ); container.appendChild(btnReset); // 距离标签 var txtInfo = document.createElement('div'); txtInfo.style.font = 'small Arial'; txtInfo.style.fontWeight = 'bold'; txtInfo.style.fontSize = '9pt'; txtInfo.style.width = "82px"; container.appendChild(txtInfo); // 初始化内部变量 map.rulerControl_ = me; me.map_ = map; me.head_ = new Object(); me.tail_ = new Object(); me.head_.next_ = me.tail_; me.tail_.prev_ = me.head_; me.btnEnable_ = btnEnable; me.btnReset_ = btnReset; me.txtInfo_ = txtInfo; me.setEnabled(true); map.getContainer().appendChild(container); return container; } /** * 设置控件的格式 */ GRulerControl.prototype.setButtonStyle_ = function(button) { button.style.backgroundImage = 'url(' + this.BACKGROUND_IMAGE_ + ')'; button.style.font = "small Arial"; button.style.border = "1px solid #888888"; button.style.padding = "4px"; button.style.textAlign = "right"; button.style.cursor = "pointer"; } /** * 用恰当的格式表示距离 */ GRulerControl.prototype.formatDistance_ = function(len) { var me = this; len = Math.round(len); if (len <= 1000) { return len + ' ' + me.METER_; } else if (len <= 1000000) { return len / 1000 + ' ' + me.KILOMETER_; } return Math.round(len / 1000) + ' ' + me.KILOMETER_; } /** * 格式化角度为字符串 */ GRulerControl.prototype.formatDegree_ = function(value) { value = Math.abs(value); var v1 = Math.floor(value); var v2 = Math.floor((value - v1) * 60); var v3 = Math.round((value - v1) * 3600 % 60); return v1 + '°' + v2 + '\'' + v3 + '"'; } /** * 格式化经纬度为字符串 */ GRulerControl.prototype.formatLatLng_ = function(pt) { var me = this; var latName, lngName; var lat = pt.lat(); var lng = pt.lng(); latName = lat >= 0 ? '北纬' : '南纬'; lngName = lng >= 0 ? '东经' : '西经'; return lngName + me.formatDegree_(lng) + ',' + latName + me.formatDegree_(lat); } /** * 返回控件的默认位置 */ GRulerControl.prototype.getDefaultPosition = function() { return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(8, 8)); } /** * 返回控件是否已启用 */ GRulerControl.prototype.isEnabled = function() { return this.enabled_; } /** * 设置控件的“启用/禁用"状态 */ GRulerControl.prototype.setEnabled = function(value) { var me = this; if (value == me.enabled_) return; me.enabled_ = value; if (me.enabled_) { me.mapClickHandle_ = GEvent.addListener(me.map_, 'click', me.onMapClick_); me.txtInfo_.style.display = 'block'; me.btnReset_.style.display = 'inline'; me.btnEnable_.src = me.ENABLE_BUTTON_IMAGE_; me.btnEnable_.title = me.ENABLE_BUTTON_TITLE_; me.updateDistance_(); } else { GEvent.removeListener(me.mapClickHandle_); me.txtInfo_.style.display = 'none'; me.btnReset_.style.display = 'none'; me.btnEnable_.src = me.DISABLE_BUTTON_IMAGE_; me.btnEnable_.title = me.DISABLE_BUTTON_TITLE_; } } /** * 事件处理函数:当用户单击地图时,要在该位置添加一个标注 */ GRulerControl.prototype.onMapClick_ = function(marker, point) { var me = this.rulerControl_; // 如果用户单击的是标注,不再这里处理 if (marker) return; // 创建标注,并添加到链表中 var newMarker = new GMarker(point, {draggable: true}); var pos = me.tail_.prev_; newMarker.prev_ = pos; newMarker.next_ = pos.next_; pos.next_.prev_ = newMarker; pos.next_ = newMarker; // 为标注添加事件处理函数:拖拽标注时要更新连接线段和距离 GEvent.addListener(newMarker, 'dragend', function() { me.map_.closeInfoWindow(); me.updateSegments_(newMarker); me.updateDistance_(); } ); // 为标注添加事件处理函数:单击标注时要显示气泡窗口 GEvent.addListener(newMarker, 'click', function() { newMarker.openInfoWindow(me.createInfoWindow_(newMarker)); } ); // 将创建的标注添加到地图中 me.map_.addOverlay(newMarker); if (newMarker.prev_ != me.head_) { // 如果这不是第一个标注,则创建连接到上一个标注的线段,并显示在地图中 var segment = [newMarker.prev_.getPoint(), point]; newMarker.segPrev_ = new GPolyline(segment); newMarker.prev_.segNext_ = newMarker.segPrev_; me.map_.addOverlay(newMarker.segPrev_); // 更新距离显示 me.updateDistance_(); } } /** * 统计总距离,并显示在网页中 */ GRulerControl.prototype.updateDistance_ = function() { var me = this; var len = me.getDistance(); // 结果显示在网页中 me.txtInfo_.innerHTML = me.formatDistance_(len); } /** * 遍历链表,统计总距离 */ GRulerControl.prototype.getDistance = function() { var me = this; var len = 0; // 周游链表,累计相邻两个标注间的距离 for (var m = me.head_; m != me.tail_; m = m.next_) { if (m.prev_ && m.prev_.getPoint) len += m.prev_.getPoint().distanceFrom(m.getPoint()); } return len; } /** * 清除所有标注,初始化链表 */ GRulerControl.prototype.reset = function() { var me = this; for (var m = me.head_.next_; m != me.tail_; m = m.next_) { me.map_.removeOverlay(m); if (m.segNext_) me.map_.removeOverlay(m.segNext_); } me.head_ = new Object(); me.tail_ = new Object(); me.head_.next_ = me.tail_; me.tail_.prev_ = me.head_; me.updateDistance_(); } /** * 事件处理函数:当用户拖拽标注、标注坐标改变时被调用,这里要更新与该标注连接的线段 * @param {GMarker} marker 被拖拽的标注 */ GRulerControl.prototype.updateSegments_ = function(marker) { var me = this; var segment; // 更新连接前驱的线段 if (marker.segPrev_ && marker.prev_.getPoint) { // 从地图上删除旧的线段 me.map_.removeOverlay(marker.segPrev_); // 根据标注的当前坐标构造新的线段,并更新链表结点的相关字段 segment = [marker.prev_.getPoint(), marker.getPoint()]; marker.segPrev_ = new GPolyline(segment); marker.prev_.segNext_ = marker.segPrev_; // 将新线段添加到地图中 me.map_.addOverlay(marker.segPrev_); } // 更新连接后继的线段,与上类似 if (marker.segNext_ && marker.next_.getPoint) { me.map_.removeOverlay(marker.segNext_); segment = [marker.getPoint(), marker.next_.getPoint()]; marker.segNext_ = new GPolyline(segment); marker.next_.segPrev_ = marker.segNext_; me.map_.addOverlay(marker.segNext_); } } /** * 为气泡提示窗口创建 DOM 对象,包括标注的坐标和“删除”按钮 * @param {GMarker} marker 对应的标注 */ GRulerControl.prototype.createInfoWindow_ = function(marker) { var me = this; // 为气泡提示窗口创建动态 DOM 对象,这里我们用 DIV 标签 var div = document.createElement('div'); div.style.fontSize = '10.5pt'; div.style.width = '250px'; div.appendChild( document.createTextNode(me.formatLatLng_(marker.getPoint()))); var hr = document.createElement('hr'); hr.style.border = 'solid 1px #cccccc'; div.appendChild(hr); // 创建“删除”按钮 var lnk = document.createElement('div'); lnk.innerHTML = me.DELETE_BUTTON_TITLE_; lnk.style.color = '#0000cc'; lnk.style.cursor = 'pointer'; lnk.style.textDecoration = 'underline'; // 为“删除”按钮添加事件处理:调用 removePoint() 并重新计算距离 lnk.onclick = function() { me.map_.closeInfoWindow(); me.removePoint_(marker); me.updateDistance_(); }; div.appendChild(lnk); // 当用户关闭气泡时 Google Map API 会自动释放该对象 return div; } /** * 事件处理函数:当用户选择删除标注时被调用,这里要删除与该标注连接的线段 * @param {GMarker} marker 要删除的标注 */ GRulerControl.prototype.removePoint_ = function(marker) { var me = this; // 先从地图上删除该标注 me.map_.removeOverlay(marker); // 对于中间结点,还要把它的前驱和后继用线段连接起来 if (marker.prev_.getPoint && marker.next_.getPoint) { var segment = [marker.prev_.getPoint(), marker.next_.getPoint()]; var polyline = new GPolyline(segment); marker.prev_.segNext_ = polyline; marker.next_.segPrev_ = polyline; me.map_.addOverlay(polyline); } marker.prev_.next_ = marker.next_; marker.next_.prev_ = marker.prev_; if (marker.segPrev_) me.map_.removeOverlay(marker.segPrev_); if (marker.segNext_) me.map_.removeOverlay(marker.segNext_); } </script> <script type="text/javascript"> function load(){ //检查浏览器的兼容性 if(GBrowserIsCompatible()){ //加载地图 map=new GMap2(document.getElementById("map_canvas")); //设置地图的中心坐标 var center=new GLatLng(24.49933,118.13800); map.setCenter(center,12); //设置地图的缩放工具 map.setUIToDefault(); //添加缩略图 map.addControl(new GOverviewMapControl()); //激活地图的双击放大功能和支持滑轮缩放 map.enableDoubleClickZoom(); map.enableScrollWheelZoom(); //给地图添加右键菜单 createContextMenu(map); //位于左上角 var topLeft=new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(0,0)); //添加地址导航控件 map.addControl(new GNavLabelControl(),topLeft); //添加自定义的控件 map.addControl(new GRulerControl()); //定义一个选缩放控件样式 var styleOpts={}; //定义选控件的参数 var otherOpts={}; //设置按钮的名称 otherOpts.buttonHTML='选缩放'; //设置点击后的名称 otherOpts.buttonZoomingHTML='请在地图上拉一个'; //支持连续选缩放 otherOpts.stickyZoomEnabled=true; //设置清除的时间间隔 otherOpts.overlayRemoveTime=60; //拉时地图的透明度,取值从0~1 styleOpts.opacity=0; //支持右键啦缩小地图 otherOpts.rightMouseZoomOutEnabled=true; var zcontrol=new DragZoomControl(styleOpts,otherOpts,{}); //位于左下角 var bottomLeft=new GControlPosition(G_ANCHOR_BOTTOM_LEFT,new GSize(0,0)); //添加自定义的控件 map.addControl(zcontrol,bottomLeft); //初始化GClientGeocoder对象 GoogleGeocoder=new GClientGeocoder(); var icon=new GIcon(); html='<div>这是什么</div>'; icon.image="http://labs.google.com/ridefinder/images/mm_20_red.png"; icon.iconSize=new GSize(21,29); var marker=createMarker(point,icon,html); var point=marker.getPoint(112.429714,39.934522); map.addOverlay(marker); geocoder=new GClientGeocoder(); var marker=new GMarker(center,{draggable:true}); map.addOverlay(marker); document.getElementById("lat").innerHTML=center.lat().toFixed(5); document.getElementById("lng").innerHTML=center.lng().toFixed(5); GEvent.addListener(marker,"dragend",function(){ var point=marker.getPoint(); map.panTo(point); document.getElementById("lat").innerHTML=point.lat().toFixed(5); document.getElementById("lng").innerHTML=point.lng().toFixed(5); }); GEvent.addListener(map,"moveend",function(){ map.clearOverlays(); var center=map.getCenter(); var marker=new GMarker(center,{draggable:true}); map.addOverlay(marker); document.getElementById("lat").innerHTML=center.lat().toFixed(5); document.getElementById("lng").innerHTML=center.lng().toFixed(5); GEvent.addListener(marker,"dragend",function(){ var point=marker.getPoint(); map.panTo(point); document.getElementById("lat").innerHTML=point.lat().toFixed(5); document.getElementById("lng").innerHTML=point.lng().toFixed(5); }); }); } else alert("error"); } //创建右键菜单,参数为地图对象,即为该地图添加右键菜单功能 function createContextMenu(map){ //右键菜单其实是一个DIV contextmenu=document.createElement("div"); //初始创建时右键菜单不可见 contextmenu.style.visibility="hidden"; //设置右键菜单的背景色及宽度 contextmenu.style.background="#ffffff"; contextmenu.style.border="1px solid #8888FF"; //获取地图对象的容器,并将菜单的DIV添加上去,但此时的菜单中不可见的 map.getContainer().appendChild(contextmenu); //为地图的右键添加事件侦听。当右键点击地图时,在地图右键点击的地方把菜单显示出来 GEvent.addListener(map,"singlerightclick",function(pixel,title){ //获取右键点击时的坐标位置(指像素) clickedPixel=pixel; var x=pixel.x; var y=pixel.y; //如果右键点击达到了屏幕的边界,调整菜单的位置 if(x>map.getSize().width-120) { x=map.getSize().width-120 } if(y>map.getSize().height-100) { y=map.getSize().height-100 } //实例化一个地图的位置控件 var pos=new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(x,y)); //把菜单DIV作为对象传递给地图位置控件 pos.apply(contextmenu); //把菜单设置为可见 contextmenu.style.visibility="visible"; }); //为地图添加click事件侦听器,当单击地图时,把菜单隐藏 GEvent.addListener(map,"click",function(){ contextmenu.style.visiblity="hidden"; }); } function createMarker(point,baseIcon,html){ var icon=new GIcon(baseIcon); var marker=new GMarker(point,icon); GEvent.addListener(marker,"click",function(){ marker.openInfoWindowHtml(html); }); return marker; } //初始化地图 window.onload=load; //卸载地图 window.onunload=GUnload; </script> </head> <body onload="load()" onunload="GUnload()" topmargin="0" leftmargin="0"> <b><span style="font-size:15pt"> 厦门旅游服务系统 </span></b> <div id="intro" style="width:700px;"></div> 查询地址:<input type="text" id="txtAddress" name="txtAddress" size="40" /> <input type="button" value="查询" onclick="showLocation();"/> <table> <tr> <td> <p> <b><span style="font-size:12pt"> 提示:单击您的当前位置和每个便民设施标注点通过测量距离选择您要的路线 </span></b></p> </td> </tr> </table> <table> <tr> <td> <div id="map_canvas" style="width:800px;height:480px;float:left;"> </div> </td> <td> <div id="divOutput" style="float:left;"></div> <div id="msg"></div> </td> </tr> <table> <tr><td> <p> <b><span style="font-size:9pt"> 用鼠标拖拉地图中心的红色气球标记就可以显示所在位置的经纬度坐标数据 </span></b> </p> </td> <td width="50"> <p align="right"> <b span style="font-size:9pt">纬度:</b> </p> </td> <td id="lat"></td> <td width="50"> <p align="right"> <b span style="font-size:9pt">经度:</b> </p> </td> <td id="lng"></td> </tr> </table> </table> </body> </html>
eclipse-testng 离线包<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:math="http://exslt.org/math" xmlns:testng="http://testng.org"> <xsl:output method="html" indent="yes" omit-xml-declaration="yes" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/> <xsl:output name="text" method="text"/> <xsl:output name="xml" method="xml" indent="yes"/> <xsl:output name="html" method="html" indent="yes" omit-xml- declaration="yes"/> <xsl:output name="xhtml" method="xhtml" indent="yes" omit-xml-declaration="yes"/> <xsl:param name="testNgXslt.outputDir"/> <xsl:param name="testNgXslt.cssFile"/> <xsl:param name="testNgXslt.showRuntimeTotals"/> <xsl:param name="testNgXslt.reportTitle"/> <xsl:param name="testNgXslt.sortTestCaseLinks"/> <xsl:param name="testNgXslt.chartScaleFactor"/> <!-- FAIL,PASS,SKIP,CONF,BY_CLASS--> <xsl:param name="testNgXslt.testDetailsFilter"/> <xsl:variable name="testDetailsFilter" select="if ($testNgXslt.testDetailsFilter) then $testNgXslt.testDetailsFilter else 'FAIL,PASS,SKIP'"/> <xsl:variable name="chartWidth" select="round(600 * testng:getVariableSafe($testNgXslt.chartScaleFactor, 1))"/> <xsl:variable name="chartHeight" select="round(200 * testng:getVariableSafe($testNgXslt.chartScaleFactor, 1))"/> <xsl:template name="writeCssFile"> <xsl:result- document href="{testng:absolutePath('style.css')}" format="text"> <xsl:choose> <xsl:when test="testng:isFilterSelected('CONF') = 'true'"> .testMethodStatusCONF { } </xsl:when> <xsl:otherwise> .testMethodStatusCONF { display: none; } </xsl:otherwise> </xsl:choose> <xsl:choose> <xsl:when test="testng:isFilterSelected('FAIL') = 'true'"> .testMethodStatusFAIL { background-color: #FFBBBB; } </xsl:when> <xsl:otherwise> .testMethodStatusFAIL { background-color: #FFBBBB; display: none; } </xsl:otherwise> </xsl:choose> <xsl:choose> <xsl:when test="testng:isFilterSelected ('PASS') = 'true'"> .testMethodStatusPASS { background-color: lightgreen; } </xsl:when> <xsl:otherwise> .testMethodStatusPASS { background-color: lightgreen; display: none; } </xsl:otherwise> </xsl:choose> <xsl:choose> <xsl:when test="testng:isFilterSelected('SKIP') = 'true'"> .testMethodStatusSKIP { background-color: #FFFFBB; } </xsl:when> <xsl:otherwise> .testMethodStatusSKIP { background-color: #FFFFBB; display: none; } </xsl:otherwise> </xsl:choose> <![CDATA[ body { font-family: Arial, sans-serif; font-size: 12px; padding: 10px; margin: 0px; background-color: white; } a, a:hover, a:active, a:visited { color: navy; } .suiteMenuHeader { margin-top: 10px; } .suiteMenuHeader td { padding: 5px; background-color: #e0e0e0; font-size: 12px; width: 100%; vertical-align: top; } .suiteStatusPass, .suiteStatusFail { padding-right: 20px; width: 20px; height: 20px; margin: 2px 4px 2px 2px; display: inline; } .suiteStatusPass { background-color: green; } .suiteStatusFail { background-color: red; } .testCaseLink, .testCaseLinkSelected { margin-top: 2px; padding: 4px; cursor: pointer; } .testCaseLink { background-color: #f6f6f6; } .testCaseLinkSelected { background-color: lightblue; border: 1px solid gray; padding: 3px; } .testCaseFail, .testCasePass, .testCaseSkip { padding-right: 15px; width: 15px; height: 15px; margin: 2px 4px 2px 2px; display: inline; } .testCaseFail { background-color: red; } .testCasePass { background-color: green; } .testCaseSkip { background-color: yellow; } tr.methodsTableHeader { background-color: #eaf0f7; font-weight: bold; } tr.methodsTableHeader td { padding: 3px; } .testMethodStatusFAIL a, .testMethodStatusPASS a, .testMethodStatusSKIP a { color:navy; text-decoration: none; cursor: pointer; } .testMethodStatusFAIL td, .testMethodStatusPASS td, .testMethodStatusSKIP td { padding: 3px; } .testMethodDetails, .testMethodDetailsVisible { padding: 5px; background-color: #f5f5f5; margin: 1px; } .testMethodDetails { display: none; } .testMethodsTable { margin-top: 10px; font-size: 12px; } .testMethodsTable td { border-width: 1px 0 0 1px; border-color: white; border-style:solid; } .testMethodsTable .testMethodStatusCONF td.firstMethodCell { border-left: 5px solid gray; } ]]> </xsl:result-document> </xsl:template> <xsl:template name="writeJsFile"> <xsl:result-document href="{testng:absolutePath('main.js')}" format="text"> <![CDATA[ var selectedTestCaseLink; function clearAllSelections() { if (selectedTestCaseLink != null) { selectedTestCaseLink.className = "testCaseLink"; } } function selectTestCaseLink(testCaseLinkElement) { clearAllSelections(); testCaseLinkElement.className = "testCaseLinkSelected"; selectedTestCaseLink = testCaseLinkElement; } function switchTestMethodsView(checkbox) { document.getElementById ("testMethodsByStatus").style["display"] = checkbox.checked ? "none" : "block"; document.getElementById ("testMethodsByClass").style["display"] = checkbox.checked ? "block" : "none"; } function toggleVisibility(elementId) { var displayElement = document.getElementById(elementId); if (getCurrentStyle(displayElement, "display") == "none") { displayElement.style["display"] = "block"; } else { displayElement.style["display"] = "none"; } } function toggleDetailsVisibility(elementId) { var displayElement = document.getElementById(elementId); if (displayElement.className == "testMethodDetails") { displayElement.className = "testMethodDetailsVisible"; } else { displayElement.className = "testMethodDetails"; } } function getCurrentStyle(elem, prop) { if (elem.currentStyle) { var ar = prop.match(/\w[^-]*/g); var s = ar[0]; for(var i = 1; i < ar.length; ++i) { s += ar[i].replace(/\w/, ar[i].charAt(0).toUpperCase()); } return elem.currentStyle[s]; } else if (document.defaultView.getComputedStyle) { return document.defaultView.getComputedStyle(elem, null).getPropertyValue(prop); } } function testMethodsFilterChanged(filterCheckBox, status) { var filterAll = document.getElementById ("methodsFilter_ALL"); var filterFail = document.getElementById("methodsFilter_FAIL"); var filterPass = document.getElementById("methodsFilter_PASS"); var filterSkip = document.getElementById ("methodsFilter_SKIP"); var filterConf = document.getElementById("methodsFilter_CONF"); if (filterCheckBox != filterAll) { filterMethods(filterCheckBox, status); checkMainFilter(filterAll, filterFail, filterPass, filterSkip, filterConf); } else { filterFail.checked = filterPass.checked = filterSkip.checked = filterConf.checked = filterAll.checked; filterMethods(filterAll, "FAIL"); filterMethods(filterAll, "PASS"); filterMethods (filterAll, "SKIP"); filterMethods(filterAll, "CONF"); } closeAllExpandedDetails(); } function checkMainFilter(filterAll, filterFail, filterPass, filterSkip, filterConf) { if ((filterFail.checked == filterPass.checked) && (filterPass.checked == filterSkip.checked) && (filterSkip.checked == filterConf.checked)) { filterAll.checked = filterFail.checked; } else { filterAll.checked = false; } } function filterMethods (filterCheckBox, status) { var visible = filterCheckBox.checked; alterCssElement ("testMethodStatus" + status, "display", visible ? "" : "none"); } function alterCssElement(cssClass, element, value) { var rules; if (document.all) { rules = 'rules'; } else if (document.getElementById) { rules = 'cssRules'; } for (var i = 0; i < document.styleSheets.length; i++) { for (var j = 0; j < document.styleSheets [i][rules].length; j++) { if (document.styleSheets[i][rules][j].selectorText.indexOf(cssClass) > -1) { document.styleSheets[i][rules][j].style[element] = value; break; } } } } function closeAllExpandedDetails() { var node = document.getElementsByTagName("body")[0]; //var re = new RegExp("\ \btestMethodDetailsVisible\\b"); var els = document.getElementsByTagName("div"); for (var i = 0,j = els.length; i < j; i++) { if (els[i].className == "testMethodDetailsVisible") { els[i].className = "testMethodDetails"; } } } function renderSvgEmbedTag(chartWidth, chartHeight) { var success = false; var userAgent = navigator.userAgent; if (userAgent.indexOf("Firefox") > -1 || userAgent.indexOf("Safari") > -1) { success = true; } else if (navigator.mimeTypes != null && navigator.mimeTypes.length > 0) { if (navigator.mimeTypes["image/svg+xml"] != null) { success = true; } } else if (window.ActiveXObject) { try { testObj = new ActiveXObject("Adobe.SVGCtl"); success = true; } catch (e) {} } var chartContainer = document.getElementById('chart-container'); if (success) { var chart = document.createElement('embed'); chart.src = 'overview-chart.svg'; chart.type = 'image/svg+xml'; chart.width = chartWidth; chart.height = chartHeight; chartContainer.appendChild(chart); } else { var message = document.createElement('h4'); var text = document.createTextNode('SVG Pie Charts are not available. Please install a SVG viewer for your browser.'); message.style.color = 'navy'; message.appendChild(text); chartContainer.appendChild(message); } } ]]> </xsl:result- document> </xsl:template> <xsl:template name="htmlHead"> <head> <title> <xsl:value- of select="testng:getVariableSafe($testNgXslt.reportTitle, 'TestNG Results')"/> </title> <meta http- equiv="content-type" content="text/html; charset=utf-8"/> <meta http-equiv="pragma" content="no-cache"/> <meta http-equiv="cache-control" content="max-age=0"/> <meta http-equiv="cache-control" content="no-cache"/> <meta http-equiv="cache-control" content="no-store"/> <LINK rel="stylesheet" href="style.css"/> <xsl:if test="$testNgXslt.cssFile"> <LINK rel="stylesheet" href="{$testNgXslt.cssFile}"/> </xsl:if> <script type="text/javascript" src="main.js"/> </head> </xsl:template> <xsl:function name="testng:getVariableSafe"> <xsl:param name="testVar"/> <xsl:param name="defaultValue"/> <xsl:value-of select="if ($testVar) then $testVar else $defaultValue"/> </xsl:function> <xsl:function name="testng:trim"> <xsl:param name="arg"/> <xsl:sequence select="replace(replace($arg,'\s+$',''),'^\s +','')"/> </xsl:function> <xsl:function name="testng:absolutePath"> <xsl:param name="fileName"/> <xsl:value-of select="concat('file:////', $testNgXslt.outputDir, '/', $fileName)"/> </xsl:function> <xsl:function name="testng:safeFileName"> <xsl:param name="fileName"/> <xsl:value-of select="translate($fileName, '[]{}`~! @#$%^*(){};?/\|' , '______________________')"/> </xsl:function> <xsl:function name="testng:suiteContentFileName"> <xsl:param name="suiteElement"/> <xsl:value-of select="testng:safeFileName(concat($suiteElement/@name, '.html'))"/> </xsl:function> <xsl:function name="testng:suiteGroupsFileName"> <xsl:param name="suiteElement"/> <xsl:value-of select="testng:safeFileName(concat($suiteElement/@name, '_groups.html'))"/> </xsl:function> <xsl:function name="testng:testCaseContentFileName"> <xsl:param name="testCaseElement"/> <xsl:value-of select="testng:safeFileName(concat($testCaseElement/../@name, '_', $testCaseElement/@name, '.html'))"/> </xsl:function> <xsl:function name="testng:concatParams"> <xsl:param name="params"/> <xsl:variable name="outputString"> <xsl:value-of separator="," select="for $i in ($params) return $i"/> </xsl:variable> <xsl:value-of select="$outputString"/> </xsl:function> <xsl:function name="testng:testMethodStatus"> <xsl:param name="testMethodElement"/> <xsl:variable name="status" select="$testMethodElement/@status"/> <xsl:variable name="statusClass" select="concat('testMethodStatus', $status)"/> <xsl:value-of select="if ($testMethodElement/@is-config) then concat($statusClass, ' testMethodStatusCONF') else $statusClass"/> </xsl:function> <xsl:function name="testng:suiteMethodsCount"> <xsl:param name="testCasesElements"/> <xsl:param name="state"/> <xsl:value-of select="if ($state = '*') then count($testCasesElements/class/test- method[not(@is-config)]) else count($testCasesElements/class/test-method[(@status=$state) and (not(@is-config))])"/> </xsl:function> <xsl:function name="testng:testCaseMethodsCount"> <xsl:param name="testCaseElement"/> <xsl:param name="state"/> <xsl:value-of select="if ($state = '*') then count ($testCaseElement/class/test-method[not(@is-config)]) else count($testCaseElement/class/test-method[(@status=$state) and (not(@is-config))])"/> </xsl:function> <xsl:function name="testng:suiteStateClass"> <xsl:param name="testCaseElements"/> <xsl:value-of select="if (count($testCaseElements/class/test-method[(@status='FAIL') and (not(@is-config))]) > 0) then 'suiteStatusFail' else 'suiteStatusPass'"/> </xsl:function> <xsl:function name="testng:methodsDuration"> <xsl:param name="testMethods"/> <xsl:variable name="durationMs" select="sum ($testMethods/@duration-ms)"/> <xsl:value-of select="testng:formatDuration($durationMs)"/> </xsl:function> <xsl:function name="testng:formatDuration"> <xsl:param name="durationMs"/> <!--Days--> <xsl:if test="$durationMs > 86400000"> <xsl:value-of select="format-number($durationMs div 86400000, '#')"/>d </xsl:if> <!--Hours--> <xsl:if test="($durationMs > 3600000) and ($durationMs mod 86400000 > 1000)"> <xsl:value-of select="format-number(($durationMs mod 86400000) div 3600000, '#')"/>h </xsl:if> <xsl:if test="$durationMs < 86400000"> <!--Minutes--> <xsl:if test="($durationMs > 60000) and ($durationMs mod 3600000 > 1000)"> <xsl:value-of select="format-number(($durationMs mod 3600000) div 60000, '#')"/>m </xsl:if> <!--Seconds--> <xsl:if test="($durationMs > 1000) and ($durationMs mod 60000 > 1000)"> <xsl:value-of select="format-number(($durationMs mod 60000) div 1000, '#')"/>s </xsl:if> </xsl:if> <!--Milliseconds - only when less than a second--> <xsl:if test="$durationMs < 1000"> <xsl:value-of select="$durationMs"/> ms </xsl:if> </xsl:function> <xsl:function name="testng:isFilterSelected"> <xsl:param name="filterName"/> <xsl:value-of select="contains ($testDetailsFilter, $filterName)"/> </xsl:function> <xsl:template name="formField"> <xsl:param name="label"/> <xsl:param name="value"/> <xsl:if test="$value"> <div> <b> <xsl:value-of select="$label"/>: </b> <xsl:value-of select="$value"/> </div> </xsl:if> </xsl:template> <xsl:template name="formFieldList"> <xsl:param name="label"/> <xsl:param name="value"/> <xsl:if test="count($value) > 0"> <div> <b> <xsl:value- of select="$label"/>: </b> <xsl:for-each select="$value"> <div>     - <xsl:value-of select="."/> </div> </xsl:for-each> </div> </xsl:if> </xsl:template> <xsl:template match="/testng-results"> <xsl:call-template name="writeCssFile"/> <xsl:call-template name="writeJsFile"/> <html> <xsl:call-template name="htmlHead"/> <frameset cols="250px, 100%" frameborder="1"> <frame name="navigation" src="navigation.html"/> <frame name="content" src="overview.html"/> </frameset> </html> <xsl:variable name="suiteElements" select="if (suite/@url) then document(suite/@url)/suite else suite"/> <xsl:call-template name="navigationFile"> <xsl:with-param name="suiteElements" select="$suiteElements"/> <xsl:with-param name="reporterOutputElement" select="reporter-output"/> </xsl:call-template> <!--TODO: Review this--> <xsl:result-document href="{testng:absolutePath('overview- chart.svg')}" format="xml"> <svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid meet" width="{$chartWidth}" height="{$chartHeight}" viewBox="0 0 900 300"> <defs> <style type="text/css"> <![CDATA[ .axistitle { font- weight:bold; font-size:24px; font-family:Arial; text-anchor:middle; } .xgrid, .ygrid, .legendtext { font-weight:normal; font-size:24px; font-family:Arial; } .xgrid {text- anchor:middle;} .ygrid {text-anchor:end;} .gridline { stroke:black; stroke-width:1; } .values { fill:black; stroke:none; text-anchor:middle; font-size:12px; font-weight:bold; } ]]> </style> </defs> <svg id="graphzone" preserveAspectRatio="xMidYMid meet" x="0" y="0"> <xsl:variable name="testCaseElements" select=" if (suite/@url) then if (document (suite/@url)/suite/test/@url) then document(document(suite/@url)/suite/test/@url)/test else document(suite/@url)/suite/test else suite/test"/> <xsl:variable name="failedCount" select="testng:suiteMethodsCount($testCaseElements, 'FAIL')"/> <xsl:variable name="passedCount" select="testng:suiteMethodsCount($testCaseElements, 'PASS')"/> <xsl:variable name="skippedCount" select="testng:suiteMethodsCount($testCaseElements, 'SKIP')"/> <xsl:variable name="totalCount" select="testng:suiteMethodsCount($testCaseElements, '*')"/> <xsl:variable name="pi" select="3.141592"/> <xsl:variable name="radius" select="130"/> <xsl:variable name="failedPercent" select="format-number($failedCount div $totalCount, '###%')"/> <xsl:variable name="failedAngle" select="($failedCount div $totalCount) * $pi * 2"/> <xsl:variable name="failedX" select="$radius * math:cos($failedAngle)"/> <xsl:variable name="failedY" select="-1 * $radius * math:sin($failedAngle)"/> <xsl:variable name="failedArc" select="if ($failedAngle >= $pi) then 1 else 0"/> <xsl:variable name="failedAngle_text" select="$failedAngle div 2"/> <xsl:variable name="failedX_text" select="($radius div 2) * math:cos($failedAngle_text)"/> <xsl:variable name="failedY_text" select="(-1 * ($radius div 2) * math:sin($failedAngle_text))"/> <xsl:variable name="passPercent" select="format-number($passedCount div $totalCount, '###%')"/> <xsl:variable name="passAngle" select="($passedCount div $totalCount) * $pi * 2"/> <xsl:variable name="passX" select="$radius * math:cos($passAngle)"/> <xsl:variable name="passY" select="-1 * $radius * math:sin ($passAngle)"/> <xsl:variable name="passArc" select="if ($passAngle >= $pi) then 1 else 0"/> <xsl:variable name="skipPercent" select="format-number($skippedCount div $totalCount, '###%')"/> <xsl:variable name="skipAngle" select="($skippedCount div $totalCount) * $pi * 2"/> <xsl:variable name="skipX" select="$radius * math:cos($skipAngle)"/> <xsl:variable name="skipY" select="-1 * $radius * math:sin($skipAngle)"/> <xsl:variable name="skipArc" select="if ($skipAngle >= $pi) then 1 else 0"/> <rect style="fill:red;stroke-width:1;stroke:black;" x="10" y="86" width="20" height="20"/> <text class="legendtext" x="40" y="105">Failed (<xsl:value-of select="$failedPercent"/>) </text> <rect style="fill:green;stroke-width:1;stroke:black;" x="10" y="125" width="20" height="20"/> <text class="legendtext" x="40" y="143">Passed (<xsl:value-of select="$passPercent"/>) </text> <rect style="fill:yellow;stroke-width:1;stroke:black;" x="10" y="163" width="20" height="20"/> <text class="legendtext" x="40" y="182">Skipped (<xsl:value-of select="$skipPercent"/>) </text> <g style="stroke:black;stroke-width:1" transform="translate(450,150)"> <xsl:variable name="failedRotation" select="(($skippedCount) div $totalCount) * 360"/> <xsl:if test="($failedCount div $totalCount) > 0"> <g style="fill:red" transform="rotate(- {$failedRotation}) translate({round($failedX_text div 4)}, {round($failedY_text div 4)})"> <path d="M 0 0 h {$radius} A {$radius},{$radius} 0,{$failedArc},0 {$failedX},{$failedY} z"/> </g> </xsl:if> <xsl:variable name="passRotation" select="(($failedCount + $skippedCount) div $totalCount) * 360"/> <xsl:if test="($passedCount div $totalCount) > 0"> <g style="fill:green" transform="rotate(-{$passRotation})"> <path d="M 0 0 h {$radius} A {$radius},{$radius} 0,{$passArc},0 {$passX},{$passY} z"/> </g> </xsl:if> <xsl:if test="($skippedCount div $totalCount) > 0"> <g style="fill:yellow" transform="rotate(360)"> <path d="M 0 0 h {$radius} A {$radius}, {$radius} 0,{$skipArc},0 {$skipX},{$skipY} z"/> </g> </xsl:if> </g> </svg> </svg> </xsl:result-document> <!-- Results overview file --> <xsl:result-document href="{testng:absolutePath('overview.html')}" format="xhtml"> <html xmlns="http://www.w3.org/1999/xhtml"> <xsl:call-template name="htmlHead"/> <body> <h2>Test suites overview</h2> <table width="100%"> <tr> <td align="center" id="chart-container"> <script type="text/javascript"> renderSvgEmbedTag(<xsl:value-of select="$chartWidth"/>, <xsl:value-of select="$chartHeight"/>); </script> </td> </tr> </table> <xsl:for-each select="$suiteElements"> <xsl:variable name="testCaseElements" select="if (test/@url) then document(test/@url)/test else test"/> <table width="100%" cellpadding="5" cellspacing="1"> <tr style="background-color: #eaf0f7;"> <td width="100%"> <div class="{testng:suiteStateClass($testCaseElements)}"/> <xsl:value-of select="@name"/> </td> <xsl:call-template name="percentageOverview"> <xsl:with-param name="failedCount" select="testng:suiteMethodsCount($testCaseElements, 'FAIL')"/> <xsl:with-param name="passedCount" select="testng:suiteMethodsCount ($testCaseElements, 'PASS')"/> <xsl:with-param name="skippedCount" select="testng:suiteMethodsCount($testCaseElements, 'SKIP')"/> <xsl:with-param name="totalCount" select="testng:suiteMethodsCount ($testCaseElements, '*')"/> <xsl:with-param name="totalDuration" select="testng:methodsDuration($testCaseElements/class/test-method)"/> </xsl:call-template> </tr> <xsl:for-each select="$testCaseElements"> <tr style="background-color: #f5f5f5; font-size: 12px;"> <td> <xsl:value-of select="@name"/> </td> <td align="center"> <xsl:value-of select="testng:testCaseMethodsCount(., 'FAIL')"/> </td> <td align="center"> <xsl:value-of select="testng:testCaseMethodsCount(., 'PASS')"/> </td> <td align="center"> <xsl:value-of select="testng:testCaseMethodsCount(., 'SKIP')"/> </td> <td align="center"> <xsl:value-of select="testng:testCaseMethodsCount(., '*')"/> </td> <td align="center" style="font-weight: bold;"> <xsl:value-of select="if (testng:testCaseMethodsCount(., '*') > 0) then format-number(testng:testCaseMethodsCount(., 'PASS') div testng:testCaseMethodsCount(., '*'), '###%') else '100%'"/> </td> <xsl:if test="compare($testNgXslt.showRuntimeTotals, 'true') = 0"> <td align="center" nowrap="true"> <xsl:value-of select="testng:methodsDuration(./class/test-method)"/> </td> </xsl:if> </tr> </xsl:for-each> </table> <br/> </xsl:for-each> <xsl:call- template name="powered-by"/> </body> </html> </xsl:result-document> <!-- Reporter output file --> <xsl:result-document href="{testng:absolutePath('reporterOutput.html')}" format="xhtml"> <html xmlns="http://www.w3.org/1999/xhtml"> <xsl:call-template name="htmlHead"/> <body> <h2>Reporter output</h2> <xsl:for-each select="reporter-output/line"> <div> <code> <xsl:value-of select="."/> </code> </div> </xsl:for-each> <xsl:call-template name="powered-by"/> </body> </html> </xsl:result-document> </xsl:template> <xsl:template name="navigationFile"> <xsl:param name="suiteElements"/> <xsl:param name="reporterOutputElement"/> <xsl:result-document href="{testng:absolutePath('navigation.html')}" format="xhtml"> <html xmlns="http://www.w3.org/1999/xhtml"> <xsl:call-template name="htmlHead"/> <body> <h2 style="margin-bottom: 5px;"> <xsl:value-of select="testng:getVariableSafe($testNgXslt.reportTitle, 'TestNG Results')"/> </h2> <div> <a href="overview.html" target="content" onclick="javscript:clearAllSelections();">Results overview </a> </div> <div> <a href="reporterOutput.html" target="content" onclick="javscript:clearAllSelections();">Reporter output </a> </div> <div> <xsl:for-each select="$suiteElements"> <xsl:variable name="testCaseElements" select="if (test/@url) then document(test/@url)/test else test"/> <table class="suiteMenuHeader" width="100%" cellpadding="0" cellspacing="0"> <tr> <td nowrap="true"> <b> <a href="{testng:suiteContentFileName(.)}" target="content" onclick="javscript:clearAllSelections();"> <xsl:value-of select="@name"/> </a> </b> <div style="margin: 3px 0 3px 0;"> <a href="{testng:suiteGroupsFileName(.)}" target="content" onclick="javscript:clearAllSelections();"> <xsl:value-of select="count (./groups/group)"/> Groups </a> </div> <span style="color: red;"> <xsl:value-of select="testng:suiteMethodsCount($testCaseElements, 'FAIL')"/> </span> / <span style="color: green;"> <xsl:value-of select="testng:suiteMethodsCount ($testCaseElements, 'PASS')"/> </span> / <span style="color: yellow;"> <xsl:value-of select="testng:suiteMethodsCount($testCaseElements, 'SKIP')"/> </span> / <span> <xsl:value-of select="testng:suiteMethodsCount($testCaseElements, '*')"/> </span> </td> <td style="font-weight: bold;"> <xsl:value-of select="format-number (testng:suiteMethodsCount($testCaseElements, 'PASS') div testng:suiteMethodsCount($testCaseElements, '*'), '###%')"/> </td> </tr> </table> <xsl:call-template name="suiteContentFile"> <xsl:with-param name="suiteElement" select="."/> </xsl:call-template> <xsl:call-template name="suiteGroupsFile"> <xsl:with-param name="suiteElement" select="."/> </xsl:call-template> <xsl:call-template name="suiteTestCasesLinks"> <xsl:with-param name="testCases" select="$testCaseElements"/> </xsl:call-template> <xsl:call-template name="suiteTestCasesContentFiles"> <xsl:with-param name="testCases" select="$testCaseElements"/> </xsl:call-template> </xsl:for-each> </div> </body> </html> </xsl:result-document> </xsl:template> <xsl:template name="suiteContentFile"> <xsl:param name="suiteElement"/> <xsl:variable name="testCaseElements" select="if (test/@url) then document(test/@url)/test else test"/> <xsl:result-document href="{testng:absolutePath(testng:suiteContentFileName($suiteElement))}" format="xhtml"> <html> <xsl:call-template name="htmlHead"/> <body> <table width="100%" style="font-size: 16px; margin-bottom: 10px;" cellspacing="1"> <tr> <td width="100%"> All methods in suite <b> <xsl:value-of select="./@name"/> </b> </td> <xsl:call-template name="percentageOverview"> <xsl:with-param name="failedCount" select="testng:suiteMethodsCount($testCaseElements, 'FAIL')"/> <xsl:with-param name="passedCount" select="testng:suiteMethodsCount ($testCaseElements, 'PASS')"/> <xsl:with-param name="skippedCount" select="testng:suiteMethodsCount($testCaseElements, 'SKIP')"/> <xsl:with-param name="totalCount" select="testng:suiteMethodsCount ($testCaseElements, '*')"/> <xsl:with-param name="totalDuration" select="testng:methodsDuration($testCaseElements/class/test-method)"/> </xsl:call-template> </tr> </table> <xsl:call-template name="testMethods"> <xsl:with-param name="classes" select="$testCaseElements/class"/> <xsl:with-param name="failedMethods" select="$testCaseElements/class/test-method[@status='FAIL']"/> <xsl:with-param name="passedMethods" select="$testCaseElements/class/test-method[@status='PASS']"/> <xsl:with-param name="skipedMethods" select="$testCaseElements/class/test-method[@status='SKIP']"/> </xsl:call-template> <xsl:call-template name="powered-by"/> </body> </html> </xsl:result-document> </xsl:template> <xsl:template name="suiteGroupsFile"> <xsl:param name="suiteElement"/> <xsl:result-document href="{testng:absolutePath(testng:suiteGroupsFileName($suiteElement))}" format="xhtml"> <html xmlns="http://www.w3.org/1999/xhtml"> <xsl:call-template name="htmlHead"/> <body> <h2> Groups for suite: <b> <xsl:value-of select="$suiteElement/@name"/> </b> </h2> <xsl:for-each select="$suiteElement/groups/group"> <xsl:sort order="ascending" select="@name"/> <table style="margin-bottom: 20px; font-size: 12px; width:100%;" cellpadding="3" cellspacing="1"> <tr> <td style="background-color: #f5f5f5;"> <div style="font-size: 18px;"> <xsl:value-of select="./@name"/> </div> </td> </tr> <xsl:for-each select="method"> <tr> <td style="background-color: #eaf0f7;"> <xsl:value-of select="@signature"/> </td> </tr> </xsl:for-each> </table> </xsl:for-each> <xsl:call-template name="powered-by"/> </body> </html> </xsl:result-document> </xsl:template> <xsl:template name="testMethods"> <xsl:param name="classes"/> <xsl:param name="failedMethods"/> <xsl:param name="passedMethods"/> <xsl:param name="skipedMethods"/> <xsl:param name="filePrefix"/> <div style="width: 200px;"> <label for="groupMethodsCheckBox" style="font-weight: bold; margin: 0;"> <input id="groupMethodsCheckBox" type="checkbox" onclick="switchTestMethodsView(this)"> <xsl:if test="testng:isFilterSelected('BY_CLASS') = 'true'"> <xsl:attribute name="checked" select="true"/> </xsl:if> </input> Group by class </label> <br/> <label for="methodsFilter_ALL" style="font-weight: bold; margin: 0;"> <input id="methodsFilter_ALL" type="checkbox" onclick="testMethodsFilterChanged(this, 'ALL')"> <xsl:if test="testng:isFilterSelected('FAIL') = 'true' and testng:isFilterSelected('PASS') = 'true' and testng:isFilterSelected ('SKIP') = 'true' and testng:isFilterSelected('CONF') = 'true'"> <xsl:attribute name="checked" select="true"/> </xsl:if> </input> All </label> </div> <label for="methodsFilter_FAIL" style="margin-left: 20px;"> <input id="methodsFilter_FAIL" type="checkbox" onclick="testMethodsFilterChanged(this, 'FAIL')"> <xsl:if test="testng:isFilterSelected('FAIL') = 'true'"> <xsl:attribute name="checked" select="true"/> </xsl:if> </input> Failed </label> <label for="methodsFilter_PASS"> <input id="methodsFilter_PASS" type="checkbox" onclick="testMethodsFilterChanged(this, 'PASS')"> <xsl:if test="testng:isFilterSelected('PASS') = 'true'"> <xsl:attribute name="checked" select="true"/> </xsl:if> </input> Passed </label> <label for="methodsFilter_SKIP"> <input id="methodsFilter_SKIP" type="checkbox" onclick="testMethodsFilterChanged(this, 'SKIP')"> <xsl:if test="testng:isFilterSelected('SKIP') = 'true'"> <xsl:attribute name="checked" select="true"/> </xsl:if> </input> Skipped </label> <label for="methodsFilter_CONF"> <input id="methodsFilter_CONF" type="checkbox" onclick="testMethodsFilterChanged(this, 'CONF')"> <xsl:if test="testng:isFilterSelected('CONF') = 'true'"> <xsl:attribute name="checked" select="true"/> </xsl:if> </input> Config </label> <br/> <!-- Display methods list grouped by status --> <div id="testMethodsByStatus"> <xsl:if test="testng:isFilterSelected('BY_CLASS') = 'true'"> <xsl:attribute name="style" select="'display: none;'"/> </xsl:if> <table class="testMethodsTable" cellpadding="0" cellspacing="0"> <tr class="methodsTableHeader"> <td width="100%">Name</td> <td nowrap="true">Started</td> <td nowrap="true">Duration</td> <td>Exception</td> </tr> <xsl:call-template name="testMethodsList"> <xsl:with-param name="methodList" select="$failedMethods"/> <xsl:with-param name="category" select="'byStatus_failed'"/> </xsl:call-template> <xsl:call-template name="testMethodsList"> <xsl:with-param name="methodList" select="$passedMethods"/> <xsl:with-param name="category" select="'byStatus_passed'"/> </xsl:call-template> <xsl:call-template name="testMethodsList"> <xsl:with-param name="methodList" select="$skipedMethods"/> <xsl:with-param name="category" select="'byStatus_skiped'"/> </xsl:call-template> </table> </div> <!-- Display methods list grouped by class --> <div id="testMethodsByClass"> <xsl:if test="testng:isFilterSelected('BY_CLASS') != 'true'"> <xsl:attribute name="style" select="'display: none;'"/> </xsl:if> <xsl:for-each select="$classes"> <xsl:sort order="ascending" select="@name"/> <table class="testMethodsTable" cellpadding="0" cellspacing="0"> <tr> <td colspan="4"> <h3 style="display: inline;"> <xsl:value-of select="./@name"/> </h3> </td> </tr> <tr class="methodsTableHeader"> <td width="100%">Name</td> <td nowrap="true">Started</td> <td nowrap="true">Duration</td> <td>Exception</td> </tr> <xsl:call-template name="testMethodsList"> <!--<xsl:with-param name="methodList" select="./test-method[not(@is-config)]"/>--> <xsl:with- param name="methodList" select="./test-method"/> <xsl:with-param name="category" select="'byClass'"/> <xsl:with-param name="sortByStartTime" select="'true'"/> </xsl:call-template> </table> <br/> </xsl:for-each> </div> </xsl:template> <xsl:template name="testMethodsList"> <xsl:param name="methodList"/> <xsl:param name="category"/> <xsl:param name="sortByStartTime"/> <xsl:for-each select="$methodList"> <xsl:sort order="ascending" select="if (compare($sortByStartTime, 'true') = 0) then @started-at else ''"/> <xsl:variable name="methodId" select="concat(../@name, '_', @name, '_', $category, '_', @status, position())"/> <xsl:variable name="detailsId" select="concat($methodId, '_details')"/> <xsl:variable name="exceptionDetailsId" select="concat($methodId, '_exception')"/> <tr id="{concat($methodId, '_row')}" class="{testng:testMethodStatus (.)}"> <xsl:if test="testng:isFilterSelected(@status) != 'true'"> <!--<xsl:attribute name="style" select="'display: none;'"/>--> </xsl:if> <td width="100%" class="firstMethodCell"> <a onclick="toggleDetailsVisibility('{$detailsId}')"> <xsl:value-of select="concat(@name, '(', testng:trim(testng:concatParams(./params/param)), ')')"/> </a> </td> <td nowrap="true"> <xsl:value-of select="substring(@started-at, 12, 8)"/> </td> <td nowrap="true" align="right"> <xsl:value-of select="testng:formatDuration(@duration-ms)"/> </td> <td nowrap="true"> <xsl:if test="./exception"> <a onclick="toggleDetailsVisibility('{$exceptionDetailsId}')"> <xsl:value-of select="concat(exception/@class, ': ', exception/message)"/> </a> </xsl:if>   </td> </tr> <tr> <td colspan="4" style="padding: 0; background-color: white; border-style: none; height: 0px;"> <div id="{$detailsId}" class="testMethodDetails"> <xsl:call-template name="formField"> <xsl:with-param name="label" select="'Name'"/> <xsl:with-param name="value" select="@name"/> </xsl:call-template> <xsl:call-template name="formField"> <xsl:with-param name="label" select="'Description'"/> <xsl:with-param name="value" select="@description"/> </xsl:call-template> <xsl:call-template name="formField"> <xsl:with-param name="label" select="'Signature'"/> <xsl:with-param name="value" select="@signature"/> </xsl:call-template> <xsl:if test="./params"> <xsl:call-template name="formField"> <xsl:with-param name="label" select="'Parameters'"/> <xsl:with-param name="value" select="testng:concatParams(./params/param)"/> </xsl:call- template> </xsl:if> <xsl:call-template name="formField"> <xsl:with-param name="label" select="'Start time'"/> <xsl:with-param name="value" select="substring(@started-at, 12, 8)"/> </xsl:call-template> <xsl:call- template name="formField"> <xsl:with-param name="label" select="'End time'"/> <xsl:with-param name="value" select="substring(@finished-at, 12, 8)"/> </xsl:call-template> <xsl:call-template name="formField"> <xsl:with-param name="label" select="'Duration'"/> <xsl:with-param name="value" select="testng:formatDuration(@duration- ms)"/> </xsl:call-template> <xsl:call-template name="formField"> <xsl:with-param name="label" select="'In groups:'"/> <xsl:with-param name="value" select="@groups"/> </xsl:call-template> <xsl:if test="@depends-on-methods"> <xsl:call-template name="formFieldList"> <xsl:with-param name="label" select="'Depends on methods'"/> <xsl:with-param name="value" select="tokenize(@depends-on-methods, ',')"/> </xsl:call-template> </xsl:if> <xsl:if test="@depends-on-groups"> <xsl:call-template name="formFieldList"> <xsl:with-param name="label" select="'Depends on groups'"/> <xsl:with-param name="value" select="tokenize(@depends-on-groups, ',')"/> </xsl:call-template> </xsl:if> </div> </td> </tr> <tr> <xsl:if test="exception"> <td colspan="4" style="padding: 0; background-color: white; border-style: none; height: 0px;"> <div id="{$exceptionDetailsId}" class="testMethodDetails"> <xsl:choose> <xsl:when test="exception/full-stacktrace"> <pre style="padding: 5px; margin: 0;"> <xsl:value-of select="testng:trim (exception/full-stacktrace)"/> </pre> </xsl:when> <xsl:when test="exception/short-stacktrace and not (exception/full-stacktrace)"> <pre style="padding: 5px; margin: 0;"> <xsl:value-of select="testng:trim(exception/short-stacktrace)"/> </pre> </xsl:when> <xsl:otherwise> <pre style="padding: 5px; margin: 0;"><No stacktrace information></pre> </xsl:otherwise> </xsl:choose> </div> </td> </xsl:if> </tr> </xsl:for-each> </xsl:template> <xsl:template name="suiteTestCasesLinks"> <xsl:param name="testCases"/> <xsl:for-each select="$testCases"> <xsl:sort order="ascending" select="if (compare ($testNgXslt.sortTestCaseLinks, 'true') = 0) then @name else ''"/> <div class="testCaseLink" onclick="javscript:selectTestCaseLink(this); parent.content.location='{testng:testCaseContentFileName(.)}'"> <div class="{if (count(./class/test-method[@status='FAIL']) > 0) then 'testCaseFail' else if ((count(./class/test-method[@status='FAIL']) = 0) and (count(./class/test-method [@status='PASS']) > 0)) then 'testCasePass' else 'testCaseSkip'}"> </div> <xsl:value-of select="@name"/> </div> </xsl:for- each> </xsl:template> <xsl:template name="suiteTestCasesContentFiles"> <xsl:param name="testCases"/> <xsl:for-each select="$testCases"> <xsl:result-document href="{testng:absolutePath (testng:testCaseContentFileName(.))}" format="xhtml"> <html> <xsl:call-template name="htmlHead"/> <body> <table width="100%" style="font-size: 16px; margin- bottom: 10px;" cellspacing="1"> <tr> <td width="100%"> Test case <b> <xsl:value-of select="./@name"/> </b> </td> <xsl:call-template name="percentageOverview"> <xsl:with-param name="failedCount" select="testng:testCaseMethodsCount(., 'FAIL')"/> <xsl:with-param name="passedCount" select="testng:testCaseMethodsCount(., 'PASS')"/> <xsl:with-param name="skippedCount" select="testng:testCaseMethodsCount(., 'SKIP')"/> <xsl:with-param name="totalCount" select="testng:testCaseMethodsCount(., '*')"/> <xsl:with-param name="totalDuration" select="testng:methodsDuration(./class/test-method)"/> </xsl:call-template> </tr> </table> <xsl:call-template name="testMethods"> <xsl:with-param name="classes" select="./class"/> <xsl:with-param name="failedMethods" select="./class/test-method[@status='FAIL']"/> <xsl:with-param name="passedMethods" select="./class/test-method[@status='PASS']"/> <xsl:with-param name="skipedMethods" select="./class/test-method[@status='SKIP']"/> </xsl:call-template> <xsl:call-template name="powered-by"/> </body> </html> </xsl:result-document> </xsl:for-each> </xsl:template> <xsl:template name="percentageOverview"> <xsl:param name="failedCount"/> <xsl:param name="passedCount"/> <xsl:param name="skippedCount"/> <xsl:param name="totalCount"/> <xsl:param name="totalDuration"/> <td style="background-color: #FFBBBB; padding: 3px 3px 3px 0;" align="center"> <div style="width: 50px;"> <xsl:value-of select="$failedCount"/> </div> </td> <td style="background-color: lightgreen; padding: 3px 3px 3px 0;" align="center"> <div style="width: 50px;"> <xsl:value-of select="$passedCount"/> </div> </td> <td style="background-color: #FFFFBB; padding: 3px 3px 3px 0;" align="center"> <div style="width: 50px;"> <xsl:value-of select="$skippedCount"/> </div> </td> <td align="center" style="background-color: #eaf0f7; padding: 3px 3px 3px 0;"> <div style="width: 50px;"> <xsl:value-of select="$totalCount"/> </div> </td> <td align="center" style="font-weight: bold; background-color: #eaf0f7; padding: 3px 3px 3px 0;"> <div style="width: 50px;"> <xsl:value-of select="if ($totalCount > 0) then format-number($passedCount div $totalCount, '###%') else '100%'"/> </div> </td> <xsl:if test="compare($testNgXslt.showRuntimeTotals, 'true') = 0"> <td style="background-color: #eaf0f7; padding: 3px 3px 3px 0;" align="center" nowrap="true"> <xsl:value-of select="$totalDuration"/> </td> </xsl:if> </xsl:template> <xsl:template name="powered-by"> <div style="margin-top: 15px; color: gray; text-align: center; font-size: 9px;"> Generated with <a href="http://code.google.com/p/testng-xslt/" style="color: #8888aa;" target="_blank"> TestNG XSLT </a> </div> </xsl:template> </xsl:stylesheet>
<div class="form-group"> <label class="col-sm-3 control-label">任务图标</label> <div class="col-sm-6"> l<input type="file" id="iconInput" class="image-input" style="display: none;"> <img id="previewIcon" class="preview-image" src="taskimg/task01.svg" alt="默认图片" width="50px" height="50px" style="cursor: pointer;" onclick="selectImage('iconInput', 'previewIcon')"> </div> </div> <div class="form-group"> <label class="col-sm-3 control-label">任务图片</label> <input type="file" id="imageInput1" class="image-input" style="display: none;"> <img id="previewImage1" class="preview-image" src="images/tianjia.png" alt="默认图片" width="150px" height="200px" style="cursor: pointer;" onclick="selectImage('imageInput1', 'previewImage1')"> <input type="file" id="imageInput2" class="image-input" style="display: none;"> <img id="previewImage2" class="preview-image" src="images/tianjia.png" alt="默认图片" width="150px" height="200px" style="cursor: pointer;" onclick="selectImage('imageInput2', 'previewImage2')"> <input type="file" id="imageInput3" class="image-input" style="display: none;"> <img id="previewImage3" class="preview-image" src="images/tianjia.png" alt="默认图片" width="150px" height="200px" style="cursor: pointer;" onclick="selectImage('imageInput3', 'previewImage3')"> </div> <div class="form-group"> <label class="col-sm-3 control-label">示例图片</label> <input type="file" id="imageInput1" class="image-input" style="display: none;"> <img id="previewImage1" class="preview-image" src="images/tianjia.png" alt="默认图片" width="150px" height="200px" style="cursor: pointer;" onclick="selectImage('imageInput1', 'previewImage1')"> <input type="file" id="imageInput2" class="image-input" style="display: none;"> <img id="previewImage2" class="preview-image" src="images/tianjia.png" alt="默认图片" width="150px" height="200px" style="cursor: pointer;" onclick="selectImage('imageInput2', 'previewImage2')"> <input type="file" id="imageInput3" class="image-input" style="display: none;"> <img id="previewImage3" class="preview-image" src="images/tianjia.png" alt="默认图片" width="150px" height="200px" style="cursor: pointer;" onclick="selectImage('imageInput3', 'previewImage3')"> </div> <script> function selectImage(inputId, imageId) { document.getElementById(inputId).click(); document.getElementById(inputId).onchange = function(event) { previewImage(event, imageId); } } function previewImage(event, imageId) { var input = event.target; var reader = new FileReader(); reader.onload = function() { var image = document.getElementById(imageId); image.src = reader.result; } reader.readAsDataURL(input.files[0]); } </script>请修正一下以上代码的问题,修改后点击每一个图片,可以选择本地图片并更换默认图片显示
07-09

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值