How to use getIntValue method in Testcafe

Best JavaScript code snippet using testcafe

FigureControlFun.js

Source:FigureControlFun.js Github

copy

Full Screen

1//FigureCntrol internal Functinos---------------------------------------------------------------2function InitFigureControl() //初始化控件参数3{4 this.m_fZoomNum=1; //图形放大倍数 5 this.m_cpCurrentPoint_cursor.x=0; //当前鼠标位置6 this.m_cpCurrentPoint_cursor.y=0;7 this.m_cpOriginalPoint_cursor.x=0; //最近一次鼠标左键点击的位置8 this.m_cpOriginalPoint_cursor.y=0;9 this.m_cpDistancePoint.x=0; //左键点击鼠标后偏移的位置10 this.m_cpDistancePoint.y=0;11 this.OriginalPoint_Bitmap.x=0;//50; //坐标原点位置12 this.OriginalPoint_Bitmap.y=0;//10; 13 this.m_MovePoint_cursor.x=0; //当前鼠标移动到的位置14 this.m_MovePoint_cursor.y=0; 15 this.b_SubFiguresMove=true; //是否移动图形形16 this.b_SubFiguresZoom=false; //释放缩放图形 17 this.b_LButtonDouC=false; //是否还处于左键双击状态18 this.m_CurrentDistance.x=0; //坐标平移距离19 this.m_CurrentDistance.y=0;20 this.m_nFigureCount=0; //图形个数21 this.m_nCursorInFigureId=0; //鼠标所在图形ID22 this.SelectFigureId=0;23 this.m_nNextFigureIndex=0;24 this.b_DrawCircle=false;25 this.b_DrawDoubleRect=false;26 this.b_DrawPoly=false;27 this.b_DrawRect=false;28 this.b_PreDrawRect=false; //准备绘制方框29 this.b_PreDrawCircle=false;30 this.b_PreDrawDoubleRect=false; 31 this.b_FigurePointSelect=false;32 this.m_nScrollRate=0;33 this.CurrentFigure.shift_x=0;34 this.CurrentFigure.shift_y=0;35 this.m_CurrentFillStyle=0;36 this.b_ChangeFigureValue=false; 37 this.m_PositionLabel.x=0;38 this.m_PositionLabel.y=0;39 this.b_InitShiftToCenter=true;40 this.b_ShowPositionLabel=false;41 this.b_LeftButtonDown=false;42 this.b_LoadData=false;43 this.b_ChangeFigureSize=true;44 this.b_ChooseDRectType=false;45 this.m_RectFigure.top=0;46 this.m_RectFigure.bottom=0;47 this.m_RectFigure.right=0;48 this.m_RectFigure.left=0; 49 this.m_ClientRect.top=0;50 this.m_ClientRect.bottom=0;51 this.m_ClientRect.left=0;52 this.m_ClientRect.right=0;53 this.x_Distance=0;54 this.y_Distance=0;55 this.b_ProcessImageFromDc=false;56 this.b_CursorInOutSide=true;57 this.m_bRGBBufferFill=false;58 this.b_ShowPointRect=true;59 this.b_MoveAllFigures=false;60 61 if (this.m_SelectSubFigureRectIdSet.m_nFigureRectCount>0)62 {63 this.m_SelectSubFigureRectIdSet.ClearFigureRectData();64 }65 if (this.m_TempLinesPointSet.nCPointCount>0)66 {67 this.m_TempLinesPointSet.ClearData();68 }69 if (this.m_FiguresSet.m_nFigureCount>0)70 {71 this.m_FiguresSet.ClearFigureSetData();72 }73 74 this.m_CurrentImageObject.m_pImgBuf=null; 75 this.m_TransparentBackgroundColor=0;76 this.m_nControlWidth=0;77 this.m_nControlHeight=0;78 this.FinishDrawNotice=null;79 this.m_csCurrentDrawFigureName="";80 this.m_OutsideLineColor="rgb(255,255,255)";81 this.b_ShowOutSideLine=false; 82 83 return true; 84} 85function RepaintControl() //控件重绘 CPaintDC*86{87 if(this.b_LoadData==false)88 {89 return;90 } 91 92 this.m_Context.clearRect(0,0,this.m_Canvas.width,this.m_Canvas.height);93 this.m_RectFigure.left=0;94 this.m_RectFigure.right=this.m_Image.width;95 this.m_RectFigure.top=0;96 this.m_RectFigure.bottom=this.m_Image.height; 97 this.m_Context.drawImage(this.m_Image,0,0,this.m_Image.width,this.m_Image.height,98 this.OriginalPoint_Bitmap.x,this.OriginalPoint_Bitmap.y,99 this.m_Image.width*this.m_fZoomNum,100 this.m_Image.height*this.m_fZoomNum);101//图像大小框102 this.DrawOutSideLine();103//此处显示图像上层的各种图形形 104 if (this.m_FiguresSet.m_nFigureCount>0)105 { 106 var FindIterator=new Figure ; 107 for(var index=0;index<this.m_FiguresSet.m_nFigureCount;index++)108 { 109 this.DrawFigure(this.m_FiguresSet.m_Figures[index]); 110 } 111 } 112//画实时正在画的线条 113 this.drawTempLines(); 114//显示其他图形信息115 this.ShowOtherFigures();116 117 118 119}120// FigureData121function ConnectLine(data) //有线组成的图形形连线122{123 var MovePoint=new CPoint(0,0);124 var In_OriginalPoint_cursor=new CPoint(0,0); 125 PointEqual(MovePoint,this.OriginalPoint_Bitmap); 126 var nCurrentPointIndex=0,nPointIndex=0;127//移动到起始点128 var FindIterator=new CPoint(0,0);129 if (data.figure_data.nCPointCount==0)130 {131 return;132 } 133 FindIterator=data.figure_data.m_CPoint[0];134 nCurrentPointIndex++;135 136 //显示第一个小方框137 if ((data.figure_id==this.m_nCursorInFigureId || data.figure_id== this.SelectFigureId) && this.b_ShowPointRect)138 {139 var point=new CPoint(0,0);140 point.x=GetIntValue(FindIterator.x*this.m_fZoomNum)+MovePoint.x+data.shift_x;141 point.y=GetIntValue(FindIterator.y*this.m_fZoomNum)+MovePoint.y+data.shift_y;142 this.DrawPointRect(point,0); 143 } 144 this.m_Context.strokeStyle =data.figure_color;145 this.m_Context.beginPath();146 this.m_Context.moveTo(GetIntValue(FindIterator.x*this.m_fZoomNum)+MovePoint.x+data.shift_x,GetIntValue(FindIterator.y*this.m_fZoomNum)+MovePoint.y+data.shift_y); 147 this.m_Context.stroke();148 149 if (data.figure_type==RectType)150 {151 data.figure_rect.left=FindIterator.x;152 data.figure_rect.top=FindIterator.y;153 }154//显示图形名155 var rect=new CRect(0,0,0,0);156 this.m_Context.strokeStyle =data.figure_color;157 158 rect.left=5+GetIntValue(FindIterator.x*this.m_fZoomNum)+MovePoint.x+data.shift_x;159 rect.right=rect.left+FigureControl_TextLength;160 rect.top=GetIntValue(FindIterator.y*this.m_fZoomNum)+MovePoint.y+data.shift_y;161 rect.bottom=rect.top+FigureControl_TextLength;162 163 164 this.m_Context.fillText(data.figure_name,rect.left,rect.top); 165 166//对所有点连线 167 nPointIndex++;168 var TempColorNum=0;169 for (nPointIndex;nPointIndex<data.figure_data.nCPointCount;nPointIndex++)170 { 171 FindIterator=data.figure_data.m_CPoint[nPointIndex];172 if (nCurrentPointIndex==3)173 {174 data.figure_rect.right=FindIterator.x; 175 data.figure_rect.bottom=FindIterator.y;176 }177 //连线178 this.m_Context.strokeStyle =data.figure_color;179 this.m_Context.lineTo(GetIntValue(FindIterator.x*this.m_fZoomNum)+MovePoint.x+data.shift_x,180 GetIntValue(FindIterator.y*this.m_fZoomNum)+MovePoint.y+data.shift_y);181 this.m_Context.stroke(); 182 }183 FindIterator=data.figure_data.m_CPoint[0]; 184 this.m_Context.strokeStyle =data.figure_color;185 this.m_Context.lineTo(GetIntValue(FindIterator.x*this.m_fZoomNum)+MovePoint.x+data.shift_x,186 GetIntValue(FindIterator.y*this.m_fZoomNum)+MovePoint.y+data.shift_y);187 this.m_Context.stroke();188 189 190 nPointIndex=1;191 //显示小方框 192 for (nPointIndex;nPointIndex<data.figure_data.nCPointCount;nPointIndex++)193 { 194 FindIterator=data.figure_data.m_CPoint[nPointIndex];195 nCurrentPointIndex++; 196 if (nCurrentPointIndex==3)197 {198 data.figure_rect.right=FindIterator.x; 199 data.figure_rect.bottom=FindIterator.y;200 } 201 if ((data.figure_id==this.m_nCursorInFigureId || data.figure_id== this.SelectFigureId) && this.b_ShowPointRect)202 { 203 var point=new CPoint(0,0);204 point.x=GetIntValue(FindIterator.x*this.m_fZoomNum)+MovePoint.x+data.shift_x;205 point.y=GetIntValue(FindIterator.y*this.m_fZoomNum)+MovePoint.y+data.shift_y;206 this.DrawPointRect(point,(++TempColorNum)%2);207 if (data.figure_type==RectType && !data.bShowSqure)208 {209 if (nCurrentPointIndex==2)210 {211 point.x=GetIntValue((FindIterator.x-data.figure_rect.Width()/2.0)*this.m_fZoomNum)+MovePoint.x+data.shift_x;212 point.y=GetIntValue(FindIterator.y*this.m_fZoomNum)+MovePoint.y+data.shift_y;213 this.DrawPointRect(point,2);214 }215 if (nCurrentPointIndex==3)216 {217 point.x=GetIntValue(FindIterator.x*this.m_fZoomNum)+MovePoint.x+data.shift_x;218 point.y=GetIntValue((FindIterator.y-data.figure_rect.Height()/2.0)*this.m_fZoomNum)+MovePoint.y+data.shift_y;219 this.DrawPointRect(point,2);220 } 221 222 if (nCurrentPointIndex==4)223 {224 point.x=GetIntValue((FindIterator.x+data.figure_rect.Width()/2.0)*this.m_fZoomNum)+MovePoint.x+data.shift_x;225 point.y=GetIntValue(FindIterator.y*this.m_fZoomNum)+MovePoint.y+data.shift_y;226 this.DrawPointRect(point,2);227 point.x=GetIntValue(FindIterator.x*this.m_fZoomNum)+MovePoint.x+data.shift_x;228 point.y=GetIntValue((FindIterator.y-data.figure_rect.Height()/2.0)*this.m_fZoomNum)+MovePoint.y+data.shift_y;229 this.DrawPointRect(point,2);230 }231 232 }233 } 234 }235 236 237 238 239 if ((data.figure_id==this.m_nCursorInFigureId || data.figure_id== this.SelectFigureId)240 && this.b_LeftButtonDown && data.figure_type==RectType && data.bShowSqure)241 {242 var pt=new CPoint(GetIntValue(data.figure_rect.right*this.m_fZoomNum+MovePoint.x+data.shift_x-243 (data.figure_rect.right-data.figure_rect.left)*this.m_fZoomNum/2.0),244 GetIntValue(data.figure_rect.bottom*this.m_fZoomNum+MovePoint.y+data.shift_y-245 (data.figure_rect.bottom-data.figure_rect.top)/2.0*this.m_fZoomNum));246 247 this.DrawPointRect(pt,2);248 } 249 250}251function DrawFigure(data)//绘制图形252{253 //填充图形254 this.FillFigureRect(data);255 //图形周边线条256 if (data.figure_type==CircleType)257 {258 this.DrawEllipseRect(data);259 }260 else if (data.figure_type==DrectType)261 {262 this.DrawDoubleRect(data);263 }264 else265 {266 this.ConnectLine(data); 267 }268}269function FillFigureRect(data) //填充图形 270{271 if (data.figure_fill.b_fill==true)272 { 273 //填充多边形274 if (data.figure_type==PolyType ||data.figure_type==RectType)275 {276 var PointCount=data.figure_data.m_nFigureRectCount();277 var points=new Array(PointCount);278 for(var n=0;n<PointCount;n++)279 points[n]=new CPoint(0,0);280 281 var FindIterator=new CPoint(0,0);282 var FindPointIndex=0;283 var i=0;284 for (;FindPointIndex < PointCount;FindPointIndex++)285 {286 FindIterator=data.figure_data.m_CPoint[FindPointIndex]287 288 points[i].x=GetIntValue(FindIterator.x*this.m_fZoomNum+this.OriginalPoint_Bitmap.x)+data.shift_x;289 points[i].y=GetIntValue(FindIterator.y*this.m_fZoomNum+this.OriginalPoint_Bitmap.y)+data.shift_y; 290 i++;291 }292 293 294 this.m_Context.fillStyle=data.figure_fill.figure_color;295 296 //int oldrop2=cdc.SetROP2(data.figure_fill.FillStyle);297 //cdc.Polygon(points,PointCount); 298 //cdc.SetROP2(oldrop2); 299 300 } 301 //填充圆形302 else if (data.figure_type==CircleType)303 { 304 var TempFillRect=new CRect(0,0,0,0);305 TempFillRect.left=GetIntValue(data.figure_rect.left*this.m_fZoomNum+this.OriginalPoint_Bitmap.x)+data.shift_x;306 TempFillRect.right=GetIntValue(data.figure_rect.right*this.m_fZoomNum+this.OriginalPoint_Bitmap.x)+data.shift_x;307 TempFillRect.top=GetIntValue(data.figure_rect.top*this.m_fZoomNum+this.OriginalPoint_Bitmap.y)+data.shift_y;308 TempFillRect.bottom=GetIntValue(data.figure_rect.bottom*this.m_fZoomNum+this.OriginalPoint_Bitmap.y)+data.shift_y;309 310 var xPostion=TempFillRect.left+(TempFillRect.right-TempFillRect.left)/2.0;311 var YPostion=TempFillRect.top+(TempFillRect.bottom-TempFillRect.top)/2.0;312 313 this.m_Context.fillStyle=data.figure_fill.figure_color; 314 315 this.m_Context.arc(GetIntValue(xPostion),GetIntValue(YPostion),316 GetIntValue((TempFillRect.right-TempFillRect.left)/2.0),317 0, Math.PI * 2,false); 318 319 } 320 else if (data.figure_type==DrectType)321 {322 var TempFillRect=new CRect(0,0,0,0);323 TempFillRect.left=GetIntValue(data.figure_rect.left*this.m_fZoomNum+this.OriginalPoint_Bitmap.x)+data.shift_x;324 TempFillRect.right=GetIntValue(data.figure_rect.right*this.m_fZoomNum+this.OriginalPoint_Bitmap.x)+data.shift_x;325 TempFillRect.top=GetIntValue(data.figure_rect.top*this.m_fZoomNum+this.OriginalPoint_Bitmap.y)+data.shift_y;326 TempFillRect.bottom=GetIntValue(data.figure_rect.bottom*this.m_fZoomNum+this.OriginalPoint_Bitmap.y)+data.shift_y;327 var points=new Array(4);328 for(var i=0;i<4;i++)329 points[i]=new CPoint(0,0);330 points[0].x=TempFillRect.left;331 points[0].y=TempFillRect.top;332 points[1].x=TempFillRect.right;333 points[1].y=TempFillRect.top;334 points[2].x=TempFillRect.right;335 points[2].y=TempFillRect.bottom;336 points[3].x=TempFillRect.left;337 points[3].y=TempFillRect.bottom;338 339 this.m_Context.fillStyle=data.figure_fill.figure_color;340 }341 } 342 return;343}344function drawTempLines() //实时显示正在画的线条345{346 if (this.m_TempLinesPointSet.nCPointCount==0)347 {348 return;349 } 350 //list<CPoint >::iterator FindIterator;351 var FindIterator=new CPoint(0,0);352 var FindPointIndex=0;353 354 FindIterator=this.m_TempLinesPointSet.m_CPoint[FindPointIndex];355 356 this.m_Context.beginPath();357 this.m_Context.fillStyle = "green";358 this.m_Context.arc(FindIterator.x,FindIterator.y,FigureControl_Radius,Math.PI * 2,false);359 this.m_Context.moveTo(FindIterator.x,FindIterator.y); 360 361 362 FindIterator=this.m_TempLinesPointSet.m_CPoint[++FindPointIndex];363 364 this.m_Context.fillStyle = "rgb(255,255,0)";365 366 for (FindPointIndex;FindPointIndex<this.m_TempLinesPointSet.nCPointCount;FindPointIndex++)367 {368 FindIterator=this.m_TempLinesPointSet.m_CPoint[FindPointIndex];369 370 this.m_Context.lineTo(FindIterator.x,FindIterator.y); 371 }372 this.m_Context.stroke();373}374function DrawOutSideLine() //图像外围框 375{}376function InSubFigureRect(point,beginPoint,endPoint)//点是否在直接指定范围内377{378 var k=0.0;//直线斜率379 if (endPoint.x-beginPoint.x!=0)380 {381 k=((endPoint.y-beginPoint.y)*1.0/(endPoint.x-beginPoint.x));382 }383 else384 k=0;385 var y=GetIntValue((k*(point.x-endPoint.x)))+endPoint.y;386 if ( y>=point.y && point.x>=minValue(endPoint.x,beginPoint.x) && point.x<maxValue(endPoint.x,beginPoint.x)) 387 {388 return true;389 } 390 else391 {392 return false;393 }394}395function InEllipseRect(rect,point)//点是否在圆区域内396{397 var a=0.0,b=0.0, x0=0.0,y0=0.0; 398 //椭圆焦点在X轴上399 if (rect.Width()>=rect.Height())400 {401 a=maxValue(GetIntValue(rect.Height()/2.0),GetIntValue(rect.Width()/2.0));402 b=minValue(GetIntValue(rect.Height()/2.0),GetIntValue(rect.Width()/2.0));403 x0=GetIntValue(rect.right-rect.Width()/2.0); 404 y0=GetIntValue(rect.bottom-rect.Height()/2.0); 405 var tempvalue=0.0;406 tempvalue=Math.pow(b,2)-Math.pow(b/a,2)*Math.pow((point.x-x0),2);407 if (tempvalue<0)408 {409 return false;410 }411 tempvalue=Math.pow(tempvalue,0.5);412 var y1=0.0,y2=0.0;413 y1=y0+tempvalue;414 y2=y0-tempvalue;415 if ((y1>=point.y&& y2<=point.y) || (y1<=point.y && y2>=point.y))416 {417 return true;418 }419 else420 {421 return false;422 }423 }424 else//椭圆焦点在Y轴上425 {426 a=maxValue(GetIntValue(rect.Height()/2.0),GetIntValue(rect.Width()/2.0));427 b=minValue(GetIntValue(rect.Height()/2.0),GetIntValue(rect.Width()/2.0));428 x0=GetIntValue((rect.right-rect.Width()/2.0)); 429 y0=GetIntValue((rect.bottom-rect.Height()/2.0)); 430 var tempvalue=0.0;431 tempvalue=Math.pow(a,2)-Math.pow(a/b,2)*Math.pow((point.x-x0),2);432 if (tempvalue<0)433 {434 return false;435 }436 tempvalue=Math.pow(tempvalue,0.5);437 var y1=0.0,y2=0.0;438 y1=y0+tempvalue;439 y2=y0-tempvalue;440 if ((y1>=point.y&& y2<=point.y) || (y1<=point.y && y2>=point.y))441 {442 return true;443 }444 else445 {446 return false;447 }448 }449}450function DrawRect(rect)//绘方框区域451{ 452 this.m_Context.beginPath();453 this.m_Context.moveTo(rect.left,rect.top);454 this.m_Context.lineTo(rect.right,rect.top);455 this.m_Context.lineTo(rect.right,rect.bottom);456 this.m_Context.lineTo(rect.left,rect.bottom);457 this.m_Context.lineTo(rect.left,rect.top); 458 this.m_Context.stroke();459}460function DrawEllipseRect(data)//绘圆461{462 var rect=new CRect(0,0,0,0);463 rect.left=GetIntValue(data.figure_rect.left*this.m_fZoomNum)+this.OriginalPoint_Bitmap.x+data.shift_x;464 rect.right=GetIntValue(data.figure_rect.right*this.m_fZoomNum)+this.OriginalPoint_Bitmap.x+data.shift_x;465 rect.top=GetIntValue(data.figure_rect.top*this.m_fZoomNum)+this.OriginalPoint_Bitmap.y+data.shift_y;466 rect.bottom=GetIntValue(data.figure_rect.bottom*this.m_fZoomNum)+this.OriginalPoint_Bitmap.y+data.shift_y;467 468 469 var x=rect.GetCenter().x;470 var y=rect.GetCenter().y;471 var a=rect.Width()/2.0;472 var b=rect.Height()/2.0;473 474 var r = (a > b) ? a : b;475 var ratioX = a / r;476 var ratioY = b / r;477 478 this.m_Context.save();479 this.m_Context.scale(ratioX, ratioY);480 this.m_Context.beginPath();481 this.m_Context.strokeStyle =data.figure_color;482 this.m_Context.arc(x / ratioX, y / ratioY, r, 0, 2 * Math.PI, false);483 this.m_Context.stroke();484 //this.m_Context.closePath();485 this.m_Context.restore();486 //this.m_Context.fill();487 488 //绘小方框489 if ((data.figure_id==this.m_nCursorInFigureId || data.figure_id== this.SelectFigureId)&& this.b_ShowPointRect)490 {491 var point=new CPoint(0,0);492 point.x=rect.left+GetIntValue((rect.right-rect.left)/2);493 point.y=rect.top;494 this.DrawPointRect(point,0); 495 point.x=rect.right;496 point.y=rect.top+GetIntValue((rect.bottom-rect.top)/2);497 this.DrawPointRect(point,1); 498 point.x=rect.left+GetIntValue((rect.right-rect.left)/2);499 point.y=rect.bottom;500 this.DrawPointRect(point,0); 501 point.x=rect.left;502 point.y=rect.top+GetIntValue((rect.bottom-rect.top)/2);503 this.DrawPointRect(point,1);504 }505 //显示图形名506 ///*507 var ShowNameRect=new CRect(0,0,0,0);508 ShowNameRect.left=rect.left+5;509 ShowNameRect.top=rect.top+GetIntValue((rect.bottom-rect.top)/2.0)-5;510 ShowNameRect.right= ShowNameRect.left+FigureControl_TextLength;511 ShowNameRect.bottom=ShowNameRect.top+FigureControl_TextLength;512 513 this.m_Context.fillText(data.figure_name,ShowNameRect,ShowNameRect.left,514 ShowNameRect.top);515}516function DrawDoubleRect(data)//绘双方框517{518 var rect=new CRect(0,0,0,0);519 var rect_outside=new CRect(0,0,0,0);520 rect.left=GetIntValue(data.figure_rect.left*this.m_fZoomNum)+this.OriginalPoint_Bitmap.x+data.shift_x;521 rect.right=GetIntValue(data.figure_rect.right*this.m_fZoomNum)+this.OriginalPoint_Bitmap.x+data.shift_x;522 rect.top=GetIntValue(data.figure_rect.top*this.m_fZoomNum)+this.OriginalPoint_Bitmap.y+data.shift_y;523 rect.bottom=GetIntValue(data.figure_rect.bottom*this.m_fZoomNum)+this.OriginalPoint_Bitmap.y+data.shift_y;524 rect_outside.left=GetIntValue(data.figure_rect_outside.left*this.m_fZoomNum)+this.OriginalPoint_Bitmap.x+data.shift_x;525 rect_outside.right=GetIntValue(data.figure_rect_outside.right*this.m_fZoomNum)+this.OriginalPoint_Bitmap.x+data.shift_x;526 rect_outside.top=GetIntValue(data.figure_rect_outside.top*this.m_fZoomNum)+this.OriginalPoint_Bitmap.y+data.shift_y;527 rect_outside.bottom=GetIntValue(data.figure_rect_outside.bottom*this.m_fZoomNum)+this.OriginalPoint_Bitmap.y+data.shift_y;528 529 this.m_Context.fillStyle = data.figure_color;530 this.DrawRect(rect);531 this.DrawRect(rect_outside); 532//显示小方框533 if ((data.figure_id==this.m_nCursorInFigureId || data.figure_id== this.SelectFigureId)&& this.b_ShowPointRect)534 {535 var point=new CPoint(0,0);536 point.x=rect.left;537 point.y=rect.top;538 this.DrawPointRect(point,0);539 point.x=rect.right;540 point.y=rect.top;541 this.DrawPointRect(point,1);542 point.x=rect.right;543 point.y=rect.bottom;544 this.DrawPointRect(point,0);545 point.x=rect.left;546 point.y=rect.bottom;547 this.DrawPointRect(point,1);548 point.x=rect_outside.left;549 point.y=rect_outside.top;550 this.DrawPointRect(point,1);551 point.x=rect_outside.right;552 point.y=rect_outside.top;553 this.DrawPointRect(point,0);554 point.x=rect_outside.right;555 point.y=rect_outside.bottom;556 this.DrawPointRect(point,1);557 point.x=rect_outside.left;558 point.y=rect_outside.bottom;559 this.DrawPointRect(point,0);560 } 561//显示图形名 562 rect.right=rect.left+FigureControl_TextLength; 563 rect.bottom=rect.top+FigureControl_TextLength;564 565 this.m_Context.fillText(data.figure_name,rect.left,rect.top); 566}567 568 function SelectSubFigureRectSet(pt) //确定当前点所在的区域范围集合 BOOL569{570 //此处显示图像上层的各种选择框 571 if (this.m_FiguresSet.m_nFigureCount==0)572 {573 return false;574 }575 var MovePoint=new CPoint(0,0);576 var In_OriginalPoint_cursor=new CPoint(0,0); 577 PointEqual(MovePoint,this.OriginalPoint_Bitmap); 578 PointEqual(In_OriginalPoint_cursor,this.m_cpOriginalPoint_cursor);579 var LinePointBegin=new CPoint(0,0);580 var LinePointEnd=new CPoint(0,0);581 var Iterator=new Figure;582 var FigureIndex=0; 583 for(FigureIndex;FigureIndex<this.m_FiguresSet.m_nFigureCount;FigureIndex++)584 { 585 Iterator=this.m_FiguresSet.m_Figures[FigureIndex];586 var PointInRect=0; 587 if (Iterator.figure_type==DrectType)588 {589 var rect=new CRect(0,0,0,0);590 var rect_outside=new CRect(0,0,0,0);591 rect.left=GetIntValue(Iterator.figure_rect.left*this.m_fZoomNum)+this.OriginalPoint_Bitmap.x+Iterator.shift_x;592 rect.right=GetIntValue(Iterator.figure_rect.right*this.m_fZoomNum)+this.OriginalPoint_Bitmap.x+Iterator.shift_x;593 rect.top=GetIntValue(Iterator.figure_rect.top*this.m_fZoomNum)+this.OriginalPoint_Bitmap.y+Iterator.shift_y;594 rect.bottom=GetIntValue(Iterator.figure_rect.bottom*this.m_fZoomNum)+this.OriginalPoint_Bitmap.y+Iterator.shift_y;595 rect_outside.left=GetIntValue(Iterator.figure_rect_outside.left*this.m_fZoomNum)+this.OriginalPoint_Bitmap.x+Iterator.shift_x;596 rect_outside.right=GetIntValue(Iterator.figure_rect_outside.right*this.m_fZoomNum)+this.OriginalPoint_Bitmap.x+Iterator.shift_x;597 rect_outside.top=GetIntValue(Iterator.figure_rect_outside.top*this.m_fZoomNum)+this.OriginalPoint_Bitmap.y+Iterator.shift_y;598 rect_outside.bottom=GetIntValue(Iterator.figure_rect_outside.bottom*this.m_fZoomNum)+this.OriginalPoint_Bitmap.y+Iterator.shift_y;599 600 if (In_OriginalPoint_cursor.x>=rect_outside.left 601 &&In_OriginalPoint_cursor.x<=rect_outside.right 602 && In_OriginalPoint_cursor.y>=rect_outside.top 603 && In_OriginalPoint_cursor.y<=rect_outside.bottom)604 {605 var CurrentFigure=new CFigureRect;606 CurrentFigure.m_nFigureID = Iterator.figure_id;607 CurrentFigure.m_FigureRect = Iterator.figure_rect_outside;608 this.m_SelectSubFigureRectIdSet.AddFiguretRect(CurrentFigure);609 } 610 var CornerPoint=new Array(8);611 for(var index=0;index<8;index++)612 CornerPoint[index]=new CPoint(0,0);613 CornerPoint[0].x=rect.left;614 CornerPoint[0].y=rect.top;615 CornerPoint[1].x=rect.right;616 CornerPoint[1].y=rect.top;617 CornerPoint[2].x=rect.right;618 CornerPoint[2].y=rect.bottom;619 CornerPoint[3].x=rect.left;620 CornerPoint[3].y=rect.bottom;621 CornerPoint[4].x=rect_outside.left;622 CornerPoint[4].y=rect_outside.top;623 CornerPoint[5].x=rect_outside.right;624 CornerPoint[5].y=rect_outside.top;625 CornerPoint[6].x=rect_outside.right;626 CornerPoint[6].y=rect_outside.bottom;627 CornerPoint[7].x=rect_outside.left;628 CornerPoint[7].y=rect_outside.bottom;629 for (var i=0;i<8;i++)630 {631 if (PointInPointRect(In_OriginalPoint_cursor,CornerPoint[i]))632 {633 var CurrentFigure=new CFigureRect;634 CurrentFigure.m_nFigureID = Iterator.figure_id;635 CurrentFigure.m_FigureRect = Iterator.figure_rect_outside;636 this.m_SelectSubFigureRectIdSet.AddFiguretRect(CurrentFigure);637 return true;638 //break;639 }640 }641 }642 else if (Iterator.figure_type==CircleType)643 {644 var rect=new CRect;645 rect.left=GetIntValue(Iterator.figure_rect.left*this.m_fZoomNum)+this.OriginalPoint_Bitmap.x+Iterator.shift_x;646 rect.right=GetIntValue(Iterator.figure_rect.right*this.m_fZoomNum)+this.OriginalPoint_Bitmap.x+Iterator.shift_x;647 rect.top=GetIntValue(Iterator.figure_rect.top*this.m_fZoomNum)+this.OriginalPoint_Bitmap.y+Iterator.shift_y;648 rect.bottom=GetIntValue(Iterator.figure_rect.bottom*this.m_fZoomNum)+this.OriginalPoint_Bitmap.y+Iterator.shift_y;649 if (InEllipseRect(rect,In_OriginalPoint_cursor))650 {651 var CurrentFigure=new CFigureRect;652 CurrentFigure.m_nFigureID = Iterator.figure_id;653 CurrentFigure.m_FigureRect = Iterator.figure_rect;654 this.m_SelectSubFigureRectIdSet.AddFiguretRect(CurrentFigure);655 }656 var CornerPoint=new Array(4);657 for(var index=0;index<4;index++)658 CornerPoint[index]=new CPoint(0,0);659 660 CornerPoint[0].x=rect.left+rect.Width()/2;661 CornerPoint[0].y=rect.top;662 CornerPoint[1].x=rect.right;663 CornerPoint[1].y=rect.top+rect.Height()/2;664 CornerPoint[2].x=rect.left+rect.Width()/2;665 CornerPoint[2].y=rect.bottom;666 CornerPoint[3].x=rect.left;667 CornerPoint[3].y=rect.top+rect.Height()/2;668 for (var i=0;i<4;i++)669 {670 if (PointInPointRect(In_OriginalPoint_cursor,CornerPoint[i]))671 {672 var CurrentFigure=new CFigureRect;673 CurrentFigure.m_nFigureID = Iterator.figure_id;674 CurrentFigure.m_FigureRect = Iterator.figure_rect;675 this.m_SelectSubFigureRectIdSet.AddFiguretRect(CurrentFigure);676 return true;677 //break;678 }679 }680 }681 else682 {683 684 if (Iterator.figure_data.nCPointCount>0) //只计算由点连接组成的图形685 { 686 var FindIterator=new CPoint(0,0);687 var FindIndex=0; 688 FindIterator=Iterator.figure_data.m_CPoint[FindIndex]; 689 LinePointBegin.x=GetIntValue(FindIterator.x*this.m_fZoomNum)+MovePoint.x+Iterator.shift_x;690 LinePointBegin.y=GetIntValue(FindIterator.y*this.m_fZoomNum)+MovePoint.y+Iterator. shift_y;691 var nCurrentPointIndex=0;692 var CenterPoint=new CPoint(0,0);693 for (FindIndex;FindIndex<Iterator.figure_data.nCPointCount;FindIndex++)694 {695 nCurrentPointIndex++;696 FindIterator=Iterator.figure_data.m_CPoint[FindIndex]; 697 //计算是否与投影相连698 LinePointEnd.x=GetIntValue(FindIterator.x*this.m_fZoomNum)+MovePoint.x+Iterator.shift_x;699 LinePointEnd.y=GetIntValue(FindIterator.y*this.m_fZoomNum)+MovePoint.y+Iterator.shift_y; 700 if (this.InSubFigureRect(In_OriginalPoint_cursor,LinePointBegin,LinePointEnd))701 {702 PointInRect++;703 } 704 LinePointBegin.x=LinePointEnd.x;705 LinePointBegin.y=LinePointEnd.y;706 var CornerPoint=new CPoint(0,0);707 CornerPoint.x=LinePointEnd.x;708 CornerPoint.y=LinePointEnd.y;709 710 if(Iterator.figure_type==RectType)711 {712 switch(nCurrentPointIndex)713 {714 case 1:715 CenterPoint.x=GetIntValue((FindIterator.x+Iterator.figure_rect.Width()/2.0)*this.m_fZoomNum)+716 MovePoint.x+Iterator.shift_x;717 CenterPoint.y=LinePointEnd.y;718 break;719 case 2:720 CenterPoint.x=LinePointEnd.x;721 CenterPoint.y=GetIntValue((FindIterator.y+Iterator.figure_rect.Height()/2.0)*this.m_fZoomNum)+MovePoint.y722 +Iterator.shift_y; 723 break;724 case 3:725 CenterPoint.x=GetIntValue((FindIterator.x-Iterator.figure_rect.Width()/2.0)*this.m_fZoomNum)+726 MovePoint.x+Iterator.shift_x; 727 CenterPoint.y=LinePointEnd.y;728 break;729 case 4:730 CenterPoint.x=LinePointEnd.x;731 CenterPoint.y=GetIntValue((FindIterator.y-Iterator.figure_rect.Height()/2.0)*this.m_fZoomNum)+MovePoint.y732 +Iterator.shift_y; 733 default:734 break;735 } 736 if (this.PointInPointRect(In_OriginalPoint_cursor,CenterPoint))737 {738 var CurrentFigure=new CFigureRect;739 CurrentFigure.m_nFigureID = Iterator.figure_id;740 this.GetFigureOutsideRect(CurrentFigure.m_FigureRect, Iterator);741 this.m_SelectSubFigureRectIdSet.AddFiguretRect(CurrentFigure);742 return true;743 //break;744 }745 }746 if (this.PointInPointRect(In_OriginalPoint_cursor,CornerPoint))747 {748 var CurrentFigure=new CFigureRect;749 CurrentFigure.m_nFigureID = Iterator.figure_id;750 this.GetFigureOutsideRect(CurrentFigure.m_FigureRect, Iterator);751 this.m_SelectSubFigureRectIdSet.AddFiguretRect(CurrentFigure);752 return true;753 //break;754 }755 }756 //最后一条边757 FindIterator=Iterator.figure_data.m_CPoint[0];758 LinePointEnd.x=GetIntValue(FindIterator.x*this.m_fZoomNum)+MovePoint.x+Iterator.shift_x;759 LinePointEnd.y=GetIntValue(FindIterator.y*this.m_fZoomNum)+MovePoint.y+Iterator.shift_y; 760 761 if (this.InSubFigureRect(In_OriginalPoint_cursor,LinePointBegin,LinePointEnd))762 {763 PointInRect++;764 } 765 //存入当前鼠标点所在区域的集合队列766 if (PointInRect%2==1)767 { 768 var CurrentFigure=new CFigureRect;769 CurrentFigure.m_nFigureID = Iterator.figure_id;770 this.GetFigureOutsideRect(CurrentFigure.m_FigureRect, Iterator);771 this.m_SelectSubFigureRectIdSet.AddFiguretRect(CurrentFigure);772 //break;773 } 774 var CornerPoint=new CPoint(0,0);775 CornerPoint.x=LinePointEnd.x;776 CornerPoint.y=LinePointEnd.y; 777 if (this.PointInPointRect(In_OriginalPoint_cursor,CornerPoint))778 {779 var CurrentFigure=new CFigureRect;780 CurrentFigure.m_nFigureID = Iterator.figure_id;781 this.GetFigureOutsideRect(CurrentFigure.m_FigureRect, Iterator);782 this.m_SelectSubFigureRectIdSet.AddFiguretRect(CurrentFigure);783 return true; 784 //break;785 }786 PointInRect=0;787 }788 } 789 }790 return true;791}792function DrawPointRect(point,ColorId) //绘点方框793{794 var rect=new CRect(0,0,0,0);795 rect.left=point.x-FigureControl_PointRectDistance;796 rect.right=point.x+FigureControl_PointRectDistance;797 rect.top=point.y-FigureControl_PointRectDistance;798 rect.bottom=point.y+FigureControl_PointRectDistance; 799 800 if (ColorId==0)801 {802 this.m_Context.fillStyle = "yellow";803 this.m_Context.strokeStyle = "yellow";804 }805 else if (ColorId==1)806 {807 this.m_Context.fillStyle = "red";808 this.m_Context.strokeStyle = "yellow";809 } 810 else if (ColorId==2)811 {812 this.m_Context.fillStyle = "white";813 this.m_Context.strokeStyle = "yellow";814 } 815 this.DrawRect(rect);816}817function PointGoOutSide(point) //当前点是否已经超出图片移动范围818{819 if(point.x<this.OriginalPoint_Bitmap.x || point.y<this.OriginalPoint_Bitmap.y)820 { 821 return true;822 }823 if ( point.x>this.OriginalPoint_Bitmap.x+this.m_RectFigure.Width()*this.m_fZoomNum 824 || point.y>this.OriginalPoint_Bitmap.y+this.m_RectFigure.Height()*this.m_fZoomNum)825 { 826 return true;827 } 828 return false;829}830function PointInPointRect(pt,rect_point) //A点是否在B点区域范围内831{832 var rect=new CRect(0,0,0,0);833 var RectSize=FigureControl_PointRectDistance;834 rect.left=rect_point.x-RectSize;835 rect.right=rect_point.x+RectSize;836 rect.top=rect_point.y-RectSize;837 rect.bottom=rect_point.y+RectSize;838 if (PointInRect(pt,rect))839 {840 return true;841 }842 else843 {844 return false;845 }846}847function PointInRect(point ,rect) //点是否在方框区域内848{849 if (point.x>=rect.left && point.x<=rect.right && point.y>=rect.top && point.y<=rect.bottom)850 {851 return true;852 } 853 else854 return false;855}856function PointInRectEdge(point,rect,num)// 点是否在方框边缘区域内857{858 if (point.x<=rect.left && point.y<=rect.top && num==LeftTop)859 {860 return true;861 }862 else if (point.x>=rect.right && point.y<=rect.top && num==RightTop)863 {864 return true;865 }866 else if (point.x>=rect.right && point.y>=rect.bottom && num==RightBottom)867 {868 return true;869 }870 else if (point.x<=rect.left && point.y>=rect.bottom&& num==LeftBottom)871 {872 return true;873 }874 else875 {876 return false;877 }878}879function LoadFromFile(BmpPath) //从文件导入880{}881function LoadFromBuffer(IMG_OBJ) // 从Buffer导入 882{}883function SearchPoint() //在图形集里面寻找当前鼠标点的近邻 884{885 var In_OriginalPoint_cursor=new CPoint(0,0); //当前鼠标所在位置886 PointEqual(In_OriginalPoint_cursor,this.m_cpOriginalPoint_cursor);887 var Iterator=new Figure;888 var nFigureIndex=0;889 for(nFigureIndex;nFigureIndex<this.m_FiguresSet.m_nFigureCount;nFigureIndex++)890 {891 //确定单签选中点892 Iterator=this.m_FiguresSet.m_Figures[nFigureIndex];893 if (Iterator.figure_id==this.m_nCursorInFigureId)894 {895 if (Iterator.figure_type==DrectType)896 {897 var rect=new CRect(0,0,0,0);898 var rect_outside=new CRect(0,0,0,0);899 rect.left=GetIntValue(Iterator.figure_rect.left*this.m_fZoomNum)+this.OriginalPoint_Bitmap.x+Iterator.shift_x;900 rect.right=GetIntValue(Iterator.figure_rect.right*this.m_fZoomNum)+this.OriginalPoint_Bitmap.x+Iterator.shift_x;901 rect.top=GetIntValue(Iterator.figure_rect.top*this.m_fZoomNum)+this.OriginalPoint_Bitmap.y+Iterator.shift_y;902 rect.bottom=GetIntValue(Iterator.figure_rect.bottom*this.m_fZoomNum)+this.OriginalPoint_Bitmap.y+Iterator.shift_y; 903 rect_outside.left=GetIntValue(Iterator.figure_rect_outside.left*this.m_fZoomNum)+this.OriginalPoint_Bitmap.x+Iterator.shift_x;904 rect_outside.right=GetIntValue(Iterator.figure_rect_outside.right*this.m_fZoomNum)+this.OriginalPoint_Bitmap.x+Iterator.shift_x;905 rect_outside.top=GetIntValue(Iterator.figure_rect_outside.top*this.m_fZoomNum)+this.OriginalPoint_Bitmap.y+Iterator.shift_y;906 rect_outside.bottom=GetIntValue(Iterator.figure_rect_outside.bottom*this.m_fZoomNum)+this.OriginalPoint_Bitmap.y+Iterator.shift_y; 907 var pt=new Array(9);908 for (var nPt=0;nPt<9;nPt++)909 pt[nPt]=new CPoint(0,0); 910 pt[1].x=rect.left;911 pt[1].y=rect.top;912 pt[2].x=rect.right;913 pt[2].y=rect.top;914 pt[3].x=rect.right;915 pt[3].y=rect.bottom;916 pt[4].x=rect.left;917 pt[4].y=rect.bottom;918 pt[5].x=rect_outside.left;919 pt[5].y=rect_outside.top;920 pt[6].x=rect_outside.right;921 pt[6].y=rect_outside.top;922 pt[7].x=rect_outside.right;923 pt[7].y=rect_outside.bottom;924 pt[8].x=rect_outside.left;925 pt[8].y=rect_outside.bottom; 926 for (var i=1;i<=8;i++)927 {928 if (this.PointInPointRect(In_OriginalPoint_cursor,pt[i]))929 {930 this.CurrentSelectPoint.Figure_id=Iterator.figure_id;931 this.CurrentSelectPoint.Figure_point.x=GetIntValue((pt[i].x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum);932 this.CurrentSelectPoint.Figure_point.y=GetIntValue((pt[i].y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum);933 this.CurrentSelectPoint.nPointIndex=i;934 //已经找到该点,返回 935 this.b_FigurePointSelect=true;936 return; 937 }938 else939 {940 this.b_FigurePointSelect=false;941 }942 } 943 }944 else if (Iterator.figure_type==CircleType)945 {946 var rect=new CRect(0,0,0,0);947 rect.left=GetIntValue(Iterator.figure_rect.left*this.m_fZoomNum)+this.OriginalPoint_Bitmap.x+Iterator.shift_x;948 rect.right=GetIntValue(Iterator.figure_rect.right*this.m_fZoomNum)+this.OriginalPoint_Bitmap.x+Iterator.shift_x;949 rect.top=GetIntValue(Iterator.figure_rect.top*this.m_fZoomNum)+this.OriginalPoint_Bitmap.y+Iterator.shift_y;950 rect.bottom=GetIntValue(Iterator.figure_rect.bottom*this.m_fZoomNum)+this.OriginalPoint_Bitmap.y+Iterator.shift_y; 951 var pt=new Array(5);952 for (var nPt=0;nPt<5;nPt++)953 pt[nPt]=new CPoint(0,0); 954 pt[1].x=rect.left+GetIntValue(((rect.right-rect.left)/2));955 pt[1].y=rect.top; 956 pt[2].x=rect.right;957 pt[2].y=rect.top+GetIntValue(((rect.bottom-rect.top)/2)); 958 pt[3].x=rect.left+GetIntValue(((rect.right-rect.left)/2));959 pt[3].y=rect.bottom; 960 pt[4].x=rect.left;961 pt[4].y=rect.top+GetIntValue(((rect.bottom-rect.top)/2)); 962 for (var i=1;i<=4;i++)963 {964 if (PointInPointRect(In_OriginalPoint_cursor,pt[i]))965 {966 this.CurrentSelectPoint.Figure_id=Iterator.figure_id;967 this.CurrentSelectPoint.Figure_point.x=GetIntValue((pt[i].x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum);968 this.CurrentSelectPoint.Figure_point.y=GetIntValue((pt[i].y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum); 969 //已经找到该点,返回 970 this.b_FigurePointSelect=true;971 this.CurrentSelectPoint.nPointIndex=i;972 return;973 }974 else975 {976 this.b_FigurePointSelect=false;977 }978 }979 }980 else if (Iterator.figure_type==PolyType || Iterator.figure_type==RectType)981 { 982 var FindIterator=new CPoint(0,0);983 var nPointIndex=0;984 var centerPoint=new CPoint(0,0);985 var nFindPointIndex=0;986 for (nFindPointIndex;nFindPointIndex<Iterator.figure_data.nCPointCount;nFindPointIndex++)987 {988 FindIterator=Iterator.figure_data.m_CPoint[nFindPointIndex];989 nPointIndex++;990 var pt=new CPoint(0,0); 991 992 pt.x=GetIntValue(FindIterator.x*this.m_fZoomNum)+this.OriginalPoint_Bitmap.x+Iterator.shift_x;993 pt.y=GetIntValue(FindIterator.y*this.m_fZoomNum)+this.OriginalPoint_Bitmap.y+Iterator.shift_y;994 centerPoint.x=pt.x;995 centerPoint.y=pt.y;996 if (nPointIndex<=4 && Iterator.figure_type==RectType)997 {998 switch(nPointIndex)999 {1000 case 1:1001 centerPoint.x=GetIntValue((FindIterator.x+Iterator.figure_rect.Width()/2.0)*this.m_fZoomNum)+this.OriginalPoint_Bitmap.x+Iterator.shift_x;1002 break;1003 case 2:1004 centerPoint.y=GetIntValue((FindIterator.y+Iterator.figure_rect.Height()/2.0)*this.m_fZoomNum)+this.OriginalPoint_Bitmap.y+Iterator.shift_y;1005 break;1006 case 3:1007 centerPoint.x=GetIntValue((FindIterator.x-Iterator.figure_rect.Width()/2.0)*this.m_fZoomNum)+this.OriginalPoint_Bitmap.x+Iterator.shift_x;1008 break;1009 case 4:1010 centerPoint.y=GetIntValue((FindIterator.y-Iterator.figure_rect.Height()/2.0)*this.m_fZoomNum)+this.OriginalPoint_Bitmap.y+Iterator.shift_y;1011 break;1012 default:1013 break;1014 }1015 if (this.PointInPointRect(In_OriginalPoint_cursor,centerPoint))1016 { 1017 this.CurrentSelectPoint.Figure_id=Iterator.figure_id;1018 this.CurrentSelectPoint.Figure_point.x=centerPoint.x;1019 this.CurrentSelectPoint.Figure_point.y=centerPoint.y;1020 this.CurrentSelectPoint.nPointIndex=nPointIndex+4;1021 this.b_FigurePointSelect=true;1022 //已经找到该点,返回1023 return; 1024 }1025 }1026 if (this.PointInPointRect(In_OriginalPoint_cursor,pt))1027 { 1028 this.CurrentSelectPoint.Figure_id=Iterator.figure_id;1029 this.CurrentSelectPoint.Figure_point.x=FindIterator.x;1030 this.CurrentSelectPoint.Figure_point.y=FindIterator.y;1031 this.b_FigurePointSelect=true;1032 this.CurrentSelectPoint.nPointIndex=nPointIndex;1033 //已经找到该点,返回1034 return; 1035 } 1036 else1037 {1038 this.b_FigurePointSelect=false;1039 }1040 }1041 }1042 }1043 else1044 {1045 this.b_FigurePointSelect=false;1046 }1047 }1048}1049function SetFillStyle(nIndex) //设置填充风格1050{}1051function GetFillStyle(nIndex) //获取填充风格;1052{}1053function ShowOtherFigures() //显示剩余的一些图形形1054{}1055function setInitZoomScale(num) // 初始缩放比率,放大的,为负数1056{1057 num=-num;1058 this.m_nScrollRate=GetIntValue(num*10);1059 if (num>0)1060 { //最大放大倍率1061 if (num<-60)1062 {1063 return false;1064 } 1065 this.m_fZoomNum= Math.pow(FigureControl_ScaleBot,this.m_nScrollRate); 1066 this.m_ImageHeight=this.m_ClientRect.height*this.m_fZoomNum;1067 this.m_ImageWeith=this.m_ClientRect.width*this.m_fZoomNum;1068 this.m_OldImageWeith=this.m_ClientRect.width*Math.pow(FigureControl_ScaleBot,this.m_nScrollRate+1);1069 this.m_OldImageHeight=this.m_ClientRect.height*Math.pow(FigureControl_ScaleBot,this.m_nScrollRate+1);1070 this.m_CurrentDistance.x=GetIntValue((this.m_ImageWeith-this.m_OldImageWeith)/2);1071 this.m_CurrentDistance.y=GetIntValue((this.m_ImageHeight-this.m_OldImageHeight)/2);1072 this.OriginalPoint_Bitmap.x=(this.OriginalPoint_Bitmap.x-this.m_CurrentDistance.x); 1073 this.OriginalPoint_Bitmap.y=(this.OriginalPoint_Bitmap.y-this.m_CurrentDistance.y);1074 } 1075 else 1076 { 1077 if (num>60)1078 {1079 return false;1080 } 1081 this.m_fZoomNum=Math.pow(FigureControl_ScaleBot,this.m_nScrollRate); 1082 this.m_ImageHeight=this.m_ClientRect.height*this.m_fZoomNum;1083 this.m_ImageWeith=this.m_ClientRect.width*this.m_fZoomNum; 1084 this.m_OldImageWeith=this.m_ClientRect.width*Math.pow(FigureControl_ScaleBot,this.m_nScrollRate-1);1085 this.m_OldImageHeight=this.m_ClientRect.height*Math.pow(FigureControl_ScaleBot,this.m_nScrollRate-1);1086 this.m_CurrentDistance.x=-GetIntValue((this.m_OldImageWeith-this.m_ImageWeith)/2);1087 this.m_CurrentDistance.y=-GetIntValue((this.m_OldImageHeight-this.m_ImageHeight)/2);1088 this.OriginalPoint_Bitmap.x=(this.OriginalPoint_Bitmap.x-this.m_CurrentDistance.x);1089 this.OriginalPoint_Bitmap.y=(this.OriginalPoint_Bitmap.y-this.m_CurrentDistance.y);1090 } 1091 this.RepaintControl(); 1092 return true;1093}1094function ProcessMaskImage(int ,int) //显示Mask图形 1095{}1096function ShiftImageToCenter() //初始图像居中 1097{1098 var temp_x=0,temp_y=0; 1099 temp_x=GetIntValue((this.m_ClientRect.width-this.m_Image.width*this.m_fZoomNum)/2);1100 temp_y=GetIntValue((this.m_ClientRect.height-this.m_Image.height*this.m_fZoomNum)/2);1101 this.OriginalPoint_Bitmap.x=temp_x;1102 this.OriginalPoint_Bitmap.y=temp_y; 1103 this.m_nControlWidth=temp_x;1104 this.m_nControlHeight=temp_y;1105 this.RepaintControl();1106}1107function FinishDraw(nIndex)1108{}1109function AlignWidthBytes(nBytes)1110{}1111function LButtonDown(point) //左键压下1112{1113 point.x-=this.x_Distance;1114 point.y-=this.y_Distance; 1115 if (!PointInCurrentRect(this.m_ClientRect,point))1116 {1117 return;1118 } 1119 PointEqual(m_cpOriginalPoint_cursor,point); 1120 this.b_LeftButtonDown=true;1121 //功能: 判断当前点有在哪个区域的点区域中1122 //清空上次左键选中区域集合1123 var nLastSelectFigure=this.m_nCursorInFigureId;1124 this.m_SelectSubFigureRectIdSet.ClearFigureRectData();1125 m_nCursorInFigureId=0; 1126 //判断当前点选中了哪些区域1127 this.SelectSubFigureRectSet(this.m_cpOriginalPoint_cursor); 1128 if (m_SelectSubFigureRectIdSet.m_nFigureRectCount>0 && this.b_LButtonDouC==false ) 1129 {1130 //list<CFigureRect>::iterator FindIterator;1131 var FindIterator=new CFigureRect;1132 var FindIndex=0;1133 FindIterator=this.m_SelectSubFigureRectIdSet.m_FigureRect[FindIndex];1134 var CFigureRect =new CFigureRect;1135 SelectFigure = FindIterator;1136 for (FindIndex;FindIndex<m_SelectSubFigureRectIdSet.m_nFigureRectCount;FindIndex++)1137 {1138 if(FindIterator.m_FigureRect.left > SelectFigure.m_FigureRect.left1139 || FindIterator.m_FigureRect.top > SelectFigure.m_FigureRect.top1140 || FindIterator.m_FigureRect.right < SelectFigure.m_FigureRect.right1141 || FindIterator.m_FigureRect.bottom < SelectFigure.m_FigureRect.bottom)1142 SelectFigure = FindIterator;1143 1144 FindIterator=this.m_SelectSubFigureRectIdSet.m_FigureRect[FindIndex];1145 }1146 m_nCursorInFigureId=SelectFigure.m_nFigureID; 1147 } 1148 if (this.m_nCursorInFigureId && this.b_ChangeFigureSize)1149 { 1150 this.SearchPoint();1151 } 1152 if (this.b_DrawRect || this.b_DrawDoubleRect || this.b_DrawCircle || this.b_DrawPoly || this.b_LButtonDouC)1153 { 1154 if (!this.PointGoOutSide(point))1155 {1156 //如果开始绘画方框1157 if (this.b_DrawRect )1158 { 1159 //如果开始绘画方框,点击了一个左键1160 if (this.b_PreDrawRect)1161 {1162 this.b_PreDrawRect=false;1163 //方框剩下的三个点1164 point.x-=this.OriginalPoint_Bitmap.x;1165 point.y-=this.OriginalPoint_Bitmap.y;1166 point.x=this.GetIntValue(point.x/m_fZoomNum);1167 point.y=this.GetIntValue(point.y/m_fZoomNum);1168 //list<CPoint >::iterator FindIterator;1169 var FindIterator =new CPoint(0,0);1170 var FindPointIndex=0;1171 FindIterator=CurrentFigure.figure_data.m_CPoint[FindPointIndex];1172 if(FindIterator.x > point.x)1173 {1174 var nTemp = FindIterator.x;1175 FindIterator.x = point.x;1176 point.x = nTemp;1177 }1178 if(FindIterator.y > point.y)1179 {1180 var nTemp = FindIterator.y;1181 FindIterator.y = point.y;1182 point.y = nTemp;1183 }1184 var p1=new CPoint(0,0);1185 var p2=new CPoint(0,0);1186 var p4=new CPoint(0,0);1187 p1.x=FindIterator.x;1188 p1.y=FindIterator.y;1189 p2.x=point.x;1190 p2.y=p1.y;1191 p4.x=p1.x;1192 p4.y=point.y;1193 //其余三个点存入到图像1194 this.CurrentFigure.figure_data.AddCPoint(p2);1195 this.CurrentFigure.figure_data.AddCPoint(point); 1196 this.CurrentFigure.figure_data.AddCPoint(p4);1197 this.CurrentFigure.figure_rect.left=p1.x;1198 this.CurrentFigure.figure_rect.top=p1.y;1199 this.CurrentFigure.figure_rect.right=point.x;1200 this.CurrentFigure.figure_rect.bottom=point.y;1201 this.m_nFigureCount++;1202 this.CurrentFigure.figure_color=this.m_FigureColor;1203 //CString figurename;1204 //figurename.Format(_T("%d"),m_nFigureCount);1205 this.CurrentFigure.figure_name=this.m_csCurrentDrawFigureName; 1206 this.m_csCurrentDrawFigureName="";1207 this.CurrentFigure.figure_id=this.m_nFigureCount; 1208 this.CurrentFigure.figure_type=RectType;1209 this.CurrentFigure.ReserverData=this.m_strDataReserved;1210 this.m_FiguresSet.AddFigure(CurrentFigure);1211 1212 1213 this.CurrentFigure.ClearFigureData(); 1214 this.b_DrawRect=false; 1215 }1216 else1217 { 1218 this.b_PreDrawRect=true; 1219 //每次只有一个图形在绘制1220 point.x-=this.OriginalPoint_Bitmap.x;1221 point.y-=this.OriginalPoint_Bitmap.y;1222 point.x=GetIntValue(point.x/this.m_fZoomNum);1223 point.y=GetIntValue(point.y/this.m_fZoomNum);1224 CurrentFigure.figure_data.AddCPoint(point); // 存入到图像 1225 }1226 }1227 else1228 this.b_PreDrawRect=false; 1229 //如果开始绘画双方框1230 if (this.b_DrawDoubleRect )1231 { 1232 //如果开始绘画双方框,点击了一个左键1233 if (this.b_PreDrawDoubleRect)1234 {1235 this.b_PreDrawDoubleRect=false;1236 //方框剩下的三个点1237 point.x-=this.OriginalPoint_Bitmap.x;1238 point.y-=this.OriginalPoint_Bitmap.y;1239 point.x=GetIntValue(point.x/this.m_fZoomNum);1240 point.y=GetIntValue(point.y/this.m_fZoomNum); 1241 this.CurrentFigure.figure_rect.right=point.x;1242 this.CurrentFigure.figure_rect.bottom=point.y; 1243 this.CurrentFigure.figure_rect_outside.right=point.x+GetIntValue(FigureControl_DoubleRectDistance/this.m_fZoomNum);1244 this.CurrentFigure.figure_rect_outside.bottom=point.y+GetIntValue(FigureControl_DoubleRectDistance/this.m_fZoomNum); 1245 //不允许画不规范的双方框1246 if ((this.CurrentFigure.figure_rect.right<=this.CurrentFigure.figure_rect.left) 1247 || (this.CurrentFigure.figure_rect.top>=this.CurrentFigure.figure_rect.bottom))1248 {1249 this.CurrentFigure.ClearFigureData();1250 }1251 else1252 {1253 this.m_nFigureCount++;1254 this.CurrentFigure.figure_color=this.m_FigureColor;1255 //CString figurename;1256 //figurename.Format(_T("%d"),m_nFigureCount);1257 this.CurrentFigure.figure_id=this.m_nFigureCount;1258 this.CurrentFigure.figure_name=this.m_csCurrentDrawFigureName; 1259 this.m_csCurrentDrawFigureName="";1260 this.CurrentFigure.figure_type=DrectType;1261 this.CurrentFigure.ReserverData=this.m_strDataReserved;1262 1263 //存入1264 m_FiguresSet.AddFigure(this.CurrentFigure); 1265 1266 //SetCurrentSelectFigure(CurrentFigure.figure_id);1267 this.b_DrawDoubleRect=false;1268 this.CurrentFigure.ClearFigureData();1269 }1270 }1271 else1272 {1273 this.b_PreDrawDoubleRect=true;1274 //每次只有一个图形在绘制1275 point.x-=this.OriginalPoint_Bitmap.x;1276 point.y-=this.OriginalPoint_Bitmap.y;1277 point.x=GetIntValue(point.x/this.m_fZoomNum);1278 point.y=GetIntValue(point.y/this.m_fZoomNum);1279 // 存入到图像1280 this.CurrentFigure.figure_rect.left=point.x;1281 this.CurrentFigure.figure_rect.top=point.y;1282 this.CurrentFigure.figure_rect_outside.left=point.x-GetIntValue(FigureControl_DoubleRectDistance/this.m_fZoomNum);1283 this.CurrentFigure.figure_rect_outside.top=point.y-GetIntValue(FigureControl_DoubleRectDistance/this.m_fZoomNum); 1284 }1285 }1286 else1287 {1288 this.b_PreDrawDoubleRect=false;1289 } 1290 //开始绘制圆1291 if(this.b_DrawCircle)1292 { 1293 if (this.b_PreDrawCircle)1294 {1295 this.b_PreDrawCircle=false;1296 point.x-=this.OriginalPoint_Bitmap.x;1297 point.y-=this.OriginalPoint_Bitmap.y;1298 point.x=GetIntValue(point.x/this.m_fZoomNum);1299 point.y=GetIntValue(point.y/this.m_fZoomNum);1300 this.CurrentFigure.figure_rect.right=point.x;1301 this.CurrentFigure.figure_rect.bottom=point.y;1302 this.m_nFigureCount++;1303 this.CurrentFigure.figure_color=this.m_FigureColor; 1304 //CString figurename;1305 //figurename.Format(_T("%d"),m_nFigureCount);1306 this.CurrentFigure.figure_name=this.m_csCurrentDrawFigureName;1307 this.m_csCurrentDrawFigureName="";1308 this.CurrentFigure.figure_id=this.m_nFigureCount;1309 this.CurrentFigure.figure_type=CircleType;1310 1311 this.CurrentFigure.ReserverData=this.m_strDataReserved;1312 this.m_FiguresSet.AddFigure(CurrentFigure); 1313 //FinishDraw(CurrentFigure.figure_id);1314 //SetCurrentSelectFigure(CurrentFigure.figure_id);1315 this.CurrentFigure.ClearFigureData();1316 this.b_DrawCircle=false;1317 }1318 else1319 { 1320 this.b_PreDrawCircle=true;1321 point.x-=this.OriginalPoint_Bitmap.x;1322 point.y-=this.OriginalPoint_Bitmap.y;1323 point.x=GetIntValue(point.x/this.m_fZoomNum);1324 point.y=GetIntValue(point.y/this.m_fZoomNum);1325 // 存入1326 this.CurrentFigure.figure_rect.left=point.x;1327 this.CurrentFigure.figure_rect.top=point.y; 1328 }1329 }1330 else1331 this.b_PreDrawCircle=false;1332 if (this.b_LButtonDouC==true && this.b_DrawPoly)1333 { 1334 this.m_TempLinesPointSet.AddCPoint(point); //画实时线条 1335 //将显示坐标转成真实坐标1336 point.x-=this.OriginalPoint_Bitmap.x;1337 point.y-=this.OriginalPoint_Bitmap.y;1338 point.x=GetIntValue(point.x/this.m_fZoomNum);1339 point.y=GetIntValue(point.y/this.m_fZoomNum);1340 thisCurrentFigure.figure_data.AddCPoint((point)); // 存入到图像1341 } 1342 } 1343 }1344 this.RepaintControl();1345}1346 1347 1348// External User Event Operations1349//外部消息响应 ,需要从外部传入给控件1350function MouseWheel(zDelta, pt) //滚动鼠标中建1351{1352 pt.x-=this.x_Distance;1353 pt.y-=this.y_Distance;1354 //理论上zDelta每次都是120或者-120 1355 1356 var zoomCount=(zDelta/120); 1357 var x1=0,x2=0,y1=0,y2=0;1358 var InImageWidth=0,InImageHight=0;1359 InImageWidth=(this.m_MovePoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum;1360 InImageHight=(this.m_MovePoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum;1361 if (zoomCount>0)1362 { //最大放大倍率 1363 if (this.m_nScrollRate<FigureControl_MaxZoomScale)1364 {1365 return false; 1366 }1367 this.m_nScrollRate--;1368 this.m_fZoomNum=Math.pow(FigureControl_ScaleBot,this.m_nScrollRate); 1369 var TestX=0,TestY=0;1370 TestX=InImageWidth*(this.m_fZoomNum-Math.pow(FigureControl_ScaleBot,this.m_nScrollRate+1));1371 TestY=InImageHight*(this.m_fZoomNum-Math.pow(FigureControl_ScaleBot,this.m_nScrollRate+1));1372 this.OriginalPoint_Bitmap.x=GetIntValue(this.OriginalPoint_Bitmap.x-TestX); 1373 this.OriginalPoint_Bitmap.y=GetIntValue(this.OriginalPoint_Bitmap.y-TestY);1374 } 1375 else1376 { 1377 if (this.m_nScrollRate>-2*FigureControl_MaxZoomScale)1378 {1379 return false;1380 }1381 this.m_nScrollRate++;1382 this.m_fZoomNum=Math.pow(FigureControl_ScaleBot,this.m_nScrollRate); 1383 var TestX=0,TestY=0;1384 TestX=(InImageWidth*(this.m_fZoomNum- Math.pow(FigureControl_ScaleBot,this.m_nScrollRate-1)));1385 TestY=(InImageHight*(this.m_fZoomNum- Math.pow(FigureControl_ScaleBot,this.m_nScrollRate-1)));1386 this.OriginalPoint_Bitmap.x=GetIntValue(this.OriginalPoint_Bitmap.x-TestX); 1387 this.OriginalPoint_Bitmap.y=GetIntValue(this.OriginalPoint_Bitmap.y-TestY);1388 } 1389 1390 this.RepaintControl(); 1391}1392 1393function LButtonDown(point) //左键压下1394{1395 point.x-=this.x_Distance;1396 point.y-=this.y_Distance; 1397 if (!PointInCurrentRect(this.m_ClientRect,point))1398 {1399 return;1400 } 1401 PointEqual(this.m_cpOriginalPoint_cursor,point); 1402 this.b_LeftButtonDown=true;1403 //功能: 判断当前点有在哪个区域的点区域中1404 //清空上次左键选中区域集合1405 var nLastSelectFigure=this.m_nCursorInFigureId;1406 this.m_SelectSubFigureRectIdSet.ClearFigureRectData();1407 this.m_nCursorInFigureId=0; 1408 //判断当前点选中了哪些区域1409 this.SelectSubFigureRectSet(this.m_cpOriginalPoint_cursor); 1410 var maxId=0;1411 if (this.m_SelectSubFigureRectIdSet.m_nFigureRectCount>0 && this.b_LButtonDouC==false ) 1412 {1413 var FindIterator=new CFigureRect ;1414 var FindIndex=0; 1415 for (FindIndex;FindIndex<this.m_SelectSubFigureRectIdSet.m_nFigureRectCount;FindIndex++)1416 {1417 FindIterator=this.m_SelectSubFigureRectIdSet.m_FigureRect[FindIndex];1418 if(FindIterator.m_nFigureID>maxId) //将最后一个图形ID传出1419 {1420 maxId=FindIterator.m_nFigureID;1421 }1422 }1423 this.m_nCursorInFigureId=maxId; 1424 } 1425 if (this.m_nCursorInFigureId && this.b_ChangeFigureSize)1426 { 1427 this.SearchPoint();1428 } 1429 if (this.b_DrawRect || this.b_DrawDoubleRect || this.b_DrawCircle || this.b_DrawPoly || this.b_LButtonDouC)1430 { 1431 if (!this.PointGoOutSide(point))1432 {1433 //如果开始绘画方框1434 if (this.b_DrawRect )1435 { 1436 //如果开始绘画方框,点击了一个左键1437 if (this.b_PreDrawRect)1438 {1439 this.b_PreDrawRect=false;1440 //方框剩下的三个点1441 point.x-=this.OriginalPoint_Bitmap.x;1442 point.y-=this.OriginalPoint_Bitmap.y;1443 point.x=GetIntValue(point.x/this.m_fZoomNum);1444 point.y=GetIntValue(point.y/this.m_fZoomNum);1445 var FindIterator=new CPoint(0,0);1446 var FindPointIndex=0;1447 FindIterator=this.CurrentFigure.figure_data.m_CPoint[FindPointIndex];1448 if(FindIterator.x > point.x)1449 {1450 var nTemp = FindIterator.x;1451 FindIterator.x = point.x;1452 point.x = nTemp;1453 }1454 if(FindIterator.y > point.y)1455 {1456 var nTemp = FindIterator.y;1457 FindIterator.y = point.y;1458 point.y = nTemp;1459 }1460 var p1=new CPoint(0,0);1461 var p2=new CPoint(0,0);1462 var p4=new CPoint(0,0);1463 p1.x=FindIterator.x;1464 p1.y=FindIterator.y;1465 p2.x=point.x;1466 p2.y=p1.y;1467 p4.x=p1.x;1468 p4.y=point.y;1469 //其余三个点存入到图像1470 this.CurrentFigure.figure_data.AddCPoint((p2));1471 this.CurrentFigure.figure_data.AddCPoint((point)); 1472 this.CurrentFigure.figure_data.AddCPoint((p4));1473 this.CurrentFigure.figure_rect.left=p1.x;1474 this.CurrentFigure.figure_rect.top=p1.y;1475 this.CurrentFigure.figure_rect.right=point.x;1476 this.CurrentFigure.figure_rect.bottom=point.y;1477 this.m_nFigureCount++;1478 this.CurrentFigure.figure_color=this.m_FigureColor;1479 1480 this.CurrentFigure.figure_name=this.m_csCurrentDrawFigureName; 1481 this.m_csCurrentDrawFigureName="";1482 this.CurrentFigure.figure_id=this.m_nFigureCount; 1483 this.CurrentFigure.figure_type=RectType;1484 this.CurrentFigure.ReserverData=this.m_strDataReserved;1485 this.m_FiguresSet.AddFigure(this.CurrentFigure);1486 //FinishDraw(CurrentFigure.figure_id);1487 this.CurrentFigure.ClearFigureData(); 1488 this.b_DrawRect=false; 1489 }1490 else1491 { 1492 this.b_PreDrawRect=true; 1493 //每次只有一个图形在绘制1494 point.x-=this.OriginalPoint_Bitmap.x;1495 point.y-=this.OriginalPoint_Bitmap.y;1496 point.x=GetIntValue(point.x/this.m_fZoomNum);1497 point.y=GetIntValue(point.y/this.m_fZoomNum);1498 this.CurrentFigure.figure_data.AddCPoint((point)); // 存入到图像 1499 }1500 }1501 else1502 this.b_PreDrawRect=false; 1503 //如果开始绘画双方框1504 if (this.b_DrawDoubleRect )1505 { 1506 //如果开始绘画双方框,点击了一个左键1507 if (this.b_PreDrawDoubleRect)1508 {1509 this.b_PreDrawDoubleRect=false;1510 //方框剩下的三个点1511 point.x-=this.OriginalPoint_Bitmap.x;1512 point.y-=this.OriginalPoint_Bitmap.y;1513 point.x=GetIntValue(point.x/this.m_fZoomNum);1514 point.y=GetIntValue(point.y/this.m_fZoomNum); 1515 this.CurrentFigure.figure_rect.right=point.x;1516 this.CurrentFigure.figure_rect.bottom=point.y; 1517 this.CurrentFigure.figure_rect_outside.right=point.x+GetIntValue(FigureControl_DoubleRectDistance/this.m_fZoomNum);1518 this.CurrentFigure.figure_rect_outside.bottom=point.y+GetIntValue(FigureControl_DoubleRectDistance/this.m_fZoomNum); 1519 //不允许画不规范的双方框1520 if ((this.CurrentFigure.figure_rect.right<=this.CurrentFigure.figure_rect.left) 1521 || (this.CurrentFigure.figure_rect.top>=this.CurrentFigure.figure_rect.bottom))1522 {1523 this.CurrentFigure.ClearFigureData();1524 }1525 else1526 {1527 this.m_nFigureCount++;1528 this.CurrentFigure.figure_color=this.m_FigureColor; 1529 this.CurrentFigure.figure_id=this.m_nFigureCount;1530 this.CurrentFigure.figure_name=this.m_csCurrentDrawFigureName; 1531 this.m_csCurrentDrawFigureName="";1532 this.CurrentFigure.figure_type=DrectType; 1533 this.CurrentFigure.ReserverData=this.m_strDataReserved;1534 //存入1535 this.m_FiguresSet.AddFigure(this.CurrentFigure); 1536 //FinishDraw(CurrentFigure.figure_id);1537 1538 this.b_DrawDoubleRect=false;1539 this.CurrentFigure.ClearFigureData();1540 }1541 }1542 else1543 {1544 this.b_PreDrawDoubleRect=true;1545 //每次只有一个图形在绘制1546 point.x-=this.OriginalPoint_Bitmap.x;1547 point.y-=this.OriginalPoint_Bitmap.y;1548 point.x=GetIntValue(point.x/this.m_fZoomNum);1549 point.y=GetIntValue(point.y/this.m_fZoomNum);1550 // 存入到图像1551 this.CurrentFigure.figure_rect.left=point.x;1552 this.CurrentFigure.figure_rect.top=point.y;1553 this.CurrentFigure.figure_rect_outside.left=point.x-GetIntValue(FigureControl_DoubleRectDistance/this.m_fZoomNum);1554 this.CurrentFigure.figure_rect_outside.top=point.y-GetIntValue(FigureControl_DoubleRectDistance/this.m_fZoomNum); 1555 }1556 }1557 else1558 {1559 this.b_PreDrawDoubleRect=false;1560 } 1561 //开始绘制圆1562 if(this.b_DrawCircle)1563 { 1564 if (this.b_PreDrawCircle)1565 {1566 this.b_PreDrawCircle=false;1567 point.x-=this.OriginalPoint_Bitmap.x;1568 point.y-=this.OriginalPoint_Bitmap.y;1569 point.x=GetIntValue(point.x/this.m_fZoomNum);1570 point.y=GetIntValue(point.y/this.m_fZoomNum);1571 this.CurrentFigure.figure_rect.right=point.x;1572 this.CurrentFigure.figure_rect.bottom=point.y;1573 this.m_nFigureCount++;1574 this.CurrentFigure.figure_color=this.m_FigureColor; 1575 1576 this.CurrentFigure.figure_name=this.m_csCurrentDrawFigureName;1577 this.m_csCurrentDrawFigureName="";1578 this.CurrentFigure.figure_id=this.m_nFigureCount;1579 this.CurrentFigure.figure_type=CircleType;1580 this.CurrentFigure.ReserverData=this.m_strDataReserved;1581 1582 this.m_FiguresSet.AddFigure(this.CurrentFigure); 1583 //FinishDraw(CurrentFigure.figure_id);1584 1585 this.CurrentFigure.ClearFigureData();1586 this.b_DrawCircle=false;1587 }1588 else1589 { 1590 this.b_PreDrawCircle=true;1591 point.x-=this.OriginalPoint_Bitmap.x;1592 point.y-=this.OriginalPoint_Bitmap.y;1593 point.x=GetIntValue(point.x/this.m_fZoomNum);1594 point.y=GetIntValue(point.y/this.m_fZoomNum);1595 // 存入1596 this.CurrentFigure.figure_rect.left=point.x;1597 this.CurrentFigure.figure_rect.top=point.y; 1598 }1599 }1600 else1601 this.b_PreDrawCircle=false;1602 if (this.b_LButtonDouC==true && this.b_DrawPoly==true)1603 { 1604 this.m_TempLinesPointSet.AddCPoint(point); //画实时线条 1605 //将显示坐标转成真实坐标1606 point.x-=this.OriginalPoint_Bitmap.x;1607 point.y-=this.OriginalPoint_Bitmap.y;1608 point.x=GetIntValue(point.x/this.m_fZoomNum);1609 point.y=GetIntValue(point.y/this.m_fZoomNum);1610 this.CurrentFigure.figure_data.AddCPoint((point)); // 存入到图像1611 } 1612 } 1613 }1614 this.RepaintControl();1615}1616function LButtonUp( point) //左键弹上1617{1618 this.b_LeftButtonDown=false;1619 var b_moveWindow=false;1620 1621 //停止移动图形,将平移距离计算进原来坐标1622 if (this.b_SubFiguresMove)1623 { 1624 //list<Figure>::iterator FindIterator; 1625 var FindIterator=new Figure;1626 var FindIndex=0;1627 FindIterator=this.m_FiguresSet.m_Figures[FindIndex];1628 1629 for(FindIndex;FindIndex<this.m_FiguresSet.m_nFigureCount;FindIndex++)1630 { 1631 1632 FindIterator=this.m_FiguresSet.m_Figures[FindIndex];1633 1634 if ((FindIterator.figure_id==this.m_nCursorInFigureId )1635 && this.m_SelectSubFigureRectIdSet.m_nFigureRectCount>0 && this.b_FigurePointSelect==false) 1636 { 1637 FindIterator.MoveFigure(this.m_cpDistancePoint.x,this.m_cpDistancePoint.y); // (m_cpDistancePoint.x>2 ||m_cpDistancePoint.y>2))//防止轻微的移动 1638 1639 if (FindIterator.figure_type==DrectType)1640 {1641 FindIterator.DistanceToData(this.m_fZoomNum,DrectType);1642 }1643 else if (FindIterator.figure_type==CircleType)1644 {1645 FindIterator.DistanceToData(this.m_fZoomNum,CircleType);1646 }1647 else if (FindIterator.figure_type==RectType)1648 {1649 FindIterator.DistanceToData (this.m_fZoomNum,RectType);1650 }1651 else1652 {1653 FindIterator.DistanceToData(this.m_fZoomNum,PolyType);1654 } 1655 } 1656 }1657 } 1658 //不在选择图形边缘点1659 this.b_FigurePointSelect=false; 1660 1661}1662 1663function LButtonDblClk(point) //左键双击1664{1665 point.x-=this.x_Distance;1666 point.y-=this.y_Distance; 1667 var tempPoint=new CPoint(0,0);1668 tempPoint.x=GetIntValue((point.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum);1669 tempPoint.y=GetIntValue((point.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum); 1670 if (!PointInCurrentRect(this.m_RectFigure,tempPoint))1671 {1672 return;1673 } 1674//删除多边形边缘点1675 //list<Figure>::iterator Iterator;1676 var Iterator=new Figure;1677 var IfFind=false;1678 var FindIndex=0;1679 Iterator=this.m_FiguresSet.m_Figures[FindIndex];1680 for(FindIndex;FindIndex<this.m_FiguresSet.m_nFigureCount;FindIndex++)1681 {1682 if (Iterator.figure_type==PolyType)1683 {1684 //std::list<CPoint>::iterator PointIterator;1685 var PointIterator=new CPoint(0,0);1686 var FindPointIndex=0;1687 var PointNum=1;1688 PointIterator=Iterator.figure_data.m_CPoint[FindPointIndex];1689 for (FindPointIndex;FindPointIndex<Iterator.figure_data.nCPointCount;FindPointIndex++)1690 {1691 PointNum++;1692 var pt=new CPoint(0,0);1693 pt.x=GetIntValue(PointIterator.x*this.m_fZoomNum)+this.OriginalPoint_Bitmap.x+Iterator.shift_x;1694 pt.y=GetIntValue(PointIterator.y*this.m_fZoomNum)+this.OriginalPoint_Bitmap.y+Iterator.shift_y;1695 if (PointInPointRect(this.m_cpOriginalPoint_cursor,pt))1696 { 1697 //删除一个边缘点1698 if (PointNum%2==0)1699 {1700 Iterator.figure_data.eraseCPoint(FindPointIndex); 1701 } 1702 else//添加一个边缘点1703 {1704 var BeginPoint=new CPoint(0,0);1705 var EndPoint=new CPoint(0,0);1706 var MidPoint=new CPoint(0,0);1707 BeginPoint=PointIterator;1708 var NextPoint=FindPointIndex+1;1709 PointIterator=Iterator.figure_data.m_CPointp[NextPoint];1710 1711 if (PointIterator==Iterator.figure_data.end())1712 {1713 break;1714 }1715 1716 EndPoint=PointIterator;1717 MidPoint.x=GetIntValue(((BeginPoint.x+EndPoint.x)/2.0));1718 MidPoint.y=GetIntValue(((BeginPoint.y+EndPoint.y)/2.0)); 1719 Iterator.figure_data.InsertPoint(FindPointIndex,MidPoint);1720 1721 } 1722 IfFind=true;1723 this.RepaintControl();1724 break;1725 }1726 }1727 }1728 if (IfFind==true)1729 {1730 break;1731 } 1732 }1733//对多边形的处理 1734 if (this.b_LButtonDouC==false && this.b_DrawPoly) //第一次双击,开始画图形1735 {1736 //给控件图形赋值,初始化1737 this.b_LButtonDouC=true; 1738 this.m_TempLinesPointSet.AddCPoint(point); //实时画时显示1739 //将显示坐标转成真实坐标1740 point.x-=this.OriginalPoint_Bitmap.x;1741 point.y-=this.OriginalPoint_Bitmap.y;1742 point.x=GetIntValue(point.x/this.m_fZoomNum);1743 point.y=GetIntValue(point.y/this.m_fZoomNum);1744 this.CurrentFigure.figure_data.AddCPoint((point)); //存入到列表中 1745 }1746 else if(this.b_LButtonDouC==true && this.b_DrawPoly) //又一次双击,结束画上次图形1747 {1748 this.b_LButtonDouC=false; 1749 //std::list<CPoint>::iterator PointIterator;1750 var PointIterator=new CPoint(0,0);1751 var BeginPoint=new CPoint(0,0);1752 var EndPoint=new CPoint(0,0);1753 var MidPoint=new CPoint(0,0);1754 var FindPointIndex=0;1755 PointIterator=this.CurrentFigure.figure_data.m_CPoint[FindPointIndex];1756 1757 for (FindPointIndex;FindPointIndex<this.CurrentFigure.figure_data.nCPointCount;FindPointIndex++)1758 {1759 PointIterator=this.CurrentFigure.figure_data.m_CPoint[FindPointIndex];1760 1761 /*BeginPoint=PointIterator;1762 var NextPoint=FindPointIndex+1;1763 PointIterator=this.CurrentFigure.figure_data.m_CPoint[NextPoint];1764 if (PointIterator==this.CurrentFigure.figure_data.m_CPoint[this.CurrentFigure.figure_data.nCPointCoun-1])1765 {1766 break;1767 }1768 EndPoint=PointIterator;1769 MidPoint.x=GetIntValue(((BeginPoint.x+EndPoint.x)/2.0));1770 MidPoint.y=GetIntValue(((BeginPoint.y+EndPoint.y)/2.0));1771 this.CurrentFigure.figure_data.InsertPoint(FindPointIndex,MidPoint);*/1772 1773 }1774 this.m_nFigureCount++;1775 this.CurrentFigure.figure_id=this.m_nFigureCount;1776 this.CurrentFigure.figure_color=this.m_FigureColor;1777 this.CurrentFigure.figure_type=PolyType; 1778 this.m_csCurrentDrawFigureName=this.m_nFigureCount;1779 1780 this.CurrentFigure.figure_name=this.m_csCurrentDrawFigureName;1781 this.CurrentFigure.ReserverData=this.m_strDataReserved;1782 this.m_csCurrentDrawFigureName="";1783 this.m_FiguresSet.AddFigure(this.CurrentFigure);1784 //FinishDraw(CurrentFigure.figure_id);1785 //SetCurrentSelectFigure(CurrentFigure.figure_id);1786 this.CurrentFigure.ClearFigureData(); 1787 this.m_TempLinesPointSet.ClearData();1788 this.b_DrawPoly=false;1789 this.RepaintControl();1790 1791 1792 } 1793}1794//External Operation Functions1795//功能: 显示菜单信息1796function ShowInfo(csInfo,poin) 1797{} 1798//回到初始位置 1799function BackToInitFigure() 1800{}1801//清除当前绘制状态1802function ClearDrawStatus() 1803{}1804//删除所有图形1805function ClearAllFigures() 1806{}1807//取消填充图形1808function CancelFillFigure(nId)1809{}1810//复制指定图形1811function CopyCurrentSelectFigureRect(nId) 1812{}1813//删除指定类型的图形1814function DeleteFigureType(nFigureType) 1815{}1816//删除最后一个图形1817function DeleteLastFigure() 1818{}1819//删除指定图形1820function DeleteSelectFigure(int) 1821{}1822//删除指定的图形区域,不包括双方框1823function DeleteFigureByName(csName) 1824{}1825//是否选中边缘点1826function BSelectFigurePoint() 1827{}1828//双方框对角位置是否同时拖动1829function SetDRectChooseType(bAllShift)1830{}1831//图形形是否能够移动1832function SetFigureMoveStatus(bStatus) 1833{1834 this.b_SubFiguresMove=bStatus;1835}1836//显示边小方框1837function ShowPointRect(bShow) 1838{}1839//是否允许改变图形大小1840function ChangeFigureSize(bChange) 1841{}1842/************************************************************************/1843/* 1844该组函数用来在控件中手动绘制图形1845csFigureName 图形名字1846strReservedData 保留字段1847*/1848/************************************************************************/1849function DrawRectFigure(csFigureName,strReservedDat)//绘制方框1850{1851 this.m_strDataReserved=strReservedDat;1852 this.m_csCurrentDrawFigureName=csFigureName;1853 this.b_DrawRect=true;1854 this.b_DrawDoubleRect=false;1855 this.b_DrawPoly=false;1856 this.b_DrawCircle=false; 1857 this.b_PreDrawRect=false;1858 this.b_PreDrawDoubleRect=false;1859 this.b_PreDrawCircle=false;1860 this.b_LButtonDouC=false;1861 this.CurrentFigure.ClearFigureData();1862 this.m_TempLinesPointSet.ClearData();1863 return this.b_DrawRect;1864}1865function DrawDoubleRectFigure(csFigureName,strReservedData) //绘制双方框1866{1867 this.m_strDataReserved=strReservedData;1868 this.m_csCurrentDrawFigureName=csFigureName;1869 this.b_DrawRect=false;1870 this.b_DrawDoubleRect=true;1871 this.b_DrawPoly=false;1872 this.b_DrawCircle=false; 1873 this.b_PreDrawRect=false;1874 this.b_PreDrawDoubleRect=false;1875 this.b_PreDrawCircle=false;1876 this.b_LButtonDouC=false;1877 this.CurrentFigure.ClearFigureData();1878 this.m_TempLinesPointSet.ClearData();1879 return this.b_DrawDoubleRect;1880}1881function DrawPolyFigure(csFigureName,strReservedData) //绘制多边形1882{1883 this.m_strDataReserved=strReservedData;1884 this.b_DrawRect=false;1885 this.b_DrawDoubleRect=false;1886 this.b_DrawPoly=true;1887 this.b_DrawCircle=false; 1888 this.b_PreDrawRect=false;1889 this.b_PreDrawDoubleRect=false;1890 this.b_PreDrawCircle=false;1891 this.b_LButtonDouC=false;1892 this.CurrentFigure.ClearFigureData();1893 this.m_TempLinesPointSet.ClearData();1894 return this.b_DrawPoly;1895}1896function DrawCircleFigure(csFigureName,strReservedData) //绘制圆形 1897{1898 this.m_strDataReserved=strReservedData;1899 this.b_DrawRect=false;1900 this.b_DrawDoubleRect=false;1901 this.b_DrawPoly=false;1902 this.b_DrawCircle=true; 1903 this.b_PreDrawRect=false;1904 this.b_PreDrawDoubleRect=false;1905 this.b_PreDrawCircle=false;1906 this.b_LButtonDouC=false;1907 this.CurrentFigure.ClearFigureData();1908 this.m_TempLinesPointSet.ClearData();1909 return this.b_DrawCircle;1910} 1911/************************************************************************/1912/* 1913获取图形数据内容1914需要获取所有图形数据内容时,可以调用while(GetNextFigures(Figure figureData)){}的形式1915*/1916/************************************************************************/1917//获取指定图形信息,返回一个指针可以修改Figure信息1918function GetFigure(figureData,nFigureId)1919{}1920//兼容原来的代码,获取一个Figure的拷贝1921function GetFigure1(figureData,nFigureId)1922{}1923//获取指定所有图形信息 1924function GetNextFigures(figureData)1925{}1926//获取控件内数据 CFigureControl *DesFigureControl1927function GetFigureData(DesFigureControl)1928{}1929function GetFigureCount()1930{}1931//获得给定图形类型1932function GetFigureType(id,type) 1933{}1934//获取指定图形点个数1935function GetFigurePointNum(nFigureId)1936{}1937//获取图形的点集合,点的坐标为相对于图像左上点而言的位置 1938//BOOL CPoint PointData[],int nPointNum)1939function GetFigurePoints(PointData,nPointNum) 1940{}1941//获得当前图像与(0,0)的偏移 如果返回为true获取成功,如果为false,超出图像范围1942//CPoint 1943function GetShiftDistance() 1944{}1945//获得当前鼠标在图像中的位置1946//BOOL PointData[MaxCPointCount]1947function GetCurrentCusorInImage(PointData) 1948{}1949//获得当前选中的图形ID集合1950//const int* int idNum1951function GetCurrentSelectFigureIdSet(idNum) 1952{}1953//获得当前的放大倍数1954//float 1955function GetZoomRate() 1956{}1957//设置当前缩放系数1958//float 1959function SetZoomRate(fRate) 1960{}1961//返回鼠标选中图形id1962//int 1963function GetCurrentSelectFigureId() 1964{}1965//返回鼠标选中图形id,id为设置选中的图形id1966//int int id1967function GetCurrentSelectFigureId(id) 1968{}1969//获得最后一个图形形ID1970//int 1971function GetLastFigureId() 1972{}1973//bool 1974function GetFigureDrawStatus()1975{}1976//设置当前绘图颜色1977function SetDrawFigureColor(COLORREF ) 1978{}1979//修改图形ID1980//BOOL 1981function SetFigureId(nOldFigureId,nNewFigureId)1982{}1983//控件与窗口的偏移 1984//BOOL 1985function setControlShiftDistance(nX,nY) 1986{}1987//设置指定图形移动距离1988//BOOL 1989function setFigureShiftDistance(nId,nX ,nY)1990{}1991//设置透明率 0-100 1992function setTransparentFigureRate(nRate,nFigureId) 1993{}1994//设置指定图形颜色1995function SetFigureColor(COLORREF,nFigureId) 1996{}1997//设置当前图形风格 1-16, bSetSingle表示是否只设置当前Figure1998function SetFigureStyle(nStyleType,nFigureId,bSetSingle) 1999{}2000//设置图形状态(ALLOWMOVE,ALLOWSIZE), bMode=TRUE 表示添加,bMode=FALSE表示删除2001function SetFigureStates(nStates,nFigureId, bMode)2002{}2003//设置图形的名称2004function SetFigureName(csName,FigureId)2005{}2006//设置指定图形的保留字段内容 void *ReservedData,int FigureId2007function SetFigureReservedData(ReservedData,FigureId)2008{}2009//指定当前选中的图形2010function SetCurrentSelectFigure(nId) 2011{}2012//显示蒙版效果 2013//BOOL 2014function ShowMaskingProcess(COLORREF,bMask)2015{}2016//设置初始背景颜色2017//bshowAlways 是否背景颜色一直显示2018function SetBackGroundColor(COLORREF ,bshowAlways) 2019{}2020//图像平移距离2021function SetFigureShiftDistance(nX ,nY)2022{}2023//移动所有图形2024function SetMoveAllFigures(bMove)2025{2026 this.b_MoveAllFigures=bMove;2027}2028//设置图像根据当前控件大小缩放2029function SetFitFillControl()2030{2031 var nImageWidth=this.m_Image.width;2032 var nImageHeight=this.m_Image.height;2033 var nWidth=this.m_ClientRect.width;2034 var nHeight=this.m_ClientRect.height;2035 var TempNum,fZoomNum=1; 2036 TempNum=(nHeight*1.0/nImageHeight);2037 fZoomNum=TempNum;2038 TempNum=(nWidth*1.0/nImageWidth);2039 if (fZoomNum>TempNum)2040 {2041 fZoomNum=TempNum;2042 }2043 var fMinValue=1.0;2044 for (var i=FigureControl_MaxZoomScale;i<FigureControl_MaxZoomScale*-1;i++)2045 {2046 if (Math.abs(Math.pow(FigureControl_ScaleBot,i)-fZoomNum)<fMinValue)2047 {2048 fMinValue=Math.abs(Math.pow(FigureControl_ScaleBot,i)-fZoomNum);2049 this.m_nScrollRate=i;2050 }2051 }2052 this.m_fZoomNum=Math.pow(FigureControl_ScaleBot,this.m_nScrollRate);2053 this.RepaintControl();2054}2055//填充当前图形 2056//int 2057function FillFigure(nFigureId,COLORREF)2058{}2059//设置是否显示外围图形框2060function SetShowFigureOutsideLine(bSHow,COLORREF)2061{}2062//添加禁止拖动图像id2063//BOOL 2064function AddForbiddenFigureId(nFigureId)2065{}2066//删除禁止拖动图像id2067//BOOL 2068function DeleteForbiddenFigureId(nFigureId) 2069{}2070//设置当前矩形为正方形2071//BOOL 2072function SetRectToSquare(FigureId)2073{}2074//旋转图形2075//BOOL 2076function RotateFigure(nAngle,CenterPoint,nFigureId)2077{}2078//缩放图形2079//BOOL 2080function ZoomFigure(fZoomRate,CenterPoint,nFigureId)2081{}2082//设置为插值模式2083function SetStretchModel(bInterpose)2084{}2085/************************************************************************/2086/* 2087设置标记点2088show 是否显示2089LabelPoint 屏幕坐标2090bOutSide 是否是外部坐标 2091*/2092/************************************************************************/2093function ShowPositionLabel(BOOL,point,BOOL) 2094{}2095//获取鼠标所在位置2096//void GetCursorPosition(CPoint); 2097/************************************************************************/2098/* 2099PointData 点数据2100nPointNum 点个数2101COLORREF 图形颜色2102CString 图形名字2103strReservedDat 保留数据2104返回值: 新建图形ID2105*/2106/************************************************************************/2107//外部传入多边形方框2108//int CPoint *PointData,int nPointNum,COLORREF,CString,void* strReservedData=NULL2109function O_DrawPolyFigure(PointData,nPointNum,COLORREF,strName,strReservedData)2110{}2111//int 2112function O_DrawPolyFigure1(PointData,nPointNum,COLORREF,strName,strReservedData)2113{}2114//外部传入方框 CPoint *PointData2115function O_DrawRectFigure(PointData,COLORREF,strName,strReservedData) 2116{}2117function O_DrawRectFigure1(OutSideRect,COLORREF,strName,strReservedData)2118{}2119//外部传入圆 2120//int CPoint *PointData2121function O_DrawCircleFigure(PointData,COLORREF,strName, strReservedDat) 2122{}2123//int 2124function O_DrawCirlceFigure1(CenterPoint,nRadius,FigureName,FiugreColor,strReservedDat)2125{}2126//外部传双方框 2127//int 2128function O_DrawDoubleRectFigure(InSidePointData,OutSidePointData,COLORREF,strName,strReservedDat) 2129{}2130//外部传双方框2131//int 2132function O_DrawDoubleRectFigure1(InsideRect,OutsideRect,FigureColor,FigureName,strReservedDat)2133{} 2134/************************************************************************/2135/* 用于修改控件内部图像数据内容 2136注:修改后数据无法还原2137所有通道的图像在控件内部都转换为RGBA处理,当需要修改单通道时,可以将RGB值都设为一样2138*/2139/************************************************************************/2140//修改图像单像素2141//BOOL 2142function SetImagePix(pt,nRValue,nGValue,nBValue) 2143{}2144//获取图像单像素内容2145//BOOL CPoint pt,int RValue,int nGValue,int nBValue2146function GetImagePix(pt,RValue,nGValue,nBValue) 2147{}2148//刷新控件2149function ReFreshControl()2150{} 2151//释放控件数据2152//BOOL 2153function FreeControl()2154{}2155//public: 2156/************************************************************************/2157/* 2158Imgobject IMG_OBJ *buffer2159Pt 控件在所在应用程序窗口的位置的左上角2160ImgColor 初始颜色2161ZoomData 初始放大倍数2162FilePath 图片路径2163pParent 控件所在窗口指针2164返回值:是否初始化成功2165*/2166/************************************************************************/2167//从buffer导入2168//BOOL IMG_OBJ *Imgobject,CWnd *pParent,COLORREF ImgColor=RGB(255,0,0),float ZoomData=0, bEnableEvent2169function InitFigureControlFromBuffer(Imgobject,pParent,ImgColor,ZoomData,bEnableEvent) 2170{2171}2172//从文件导入数据2173//BOOL LPCTSTR FilePath,CPoint pt,COLORREF ImgColor=RGB(255,0,0),float ZoomData=0, BOOL bEnableEvent=FALSE2174function InitFigureControlFromFile(context,canvas,ImageName,Control)2175{2176 this.m_Context=context;2177 this.m_Canvas=canvas; 2178 var Rect=getBrowserPosition(this.m_Canvas); 2179 this.x_Distance=Rect.left;2180 this.y_Distance=Rect.top;2181 2182 this.b_LoadData=true;2183 this.m_Image.onload=function(){ 2184 Control.SetFitFillControl();2185 Control.ShiftImageToCenter();2186 } 2187 2188 this.m_Image.src=ImageName; 2189 this.m_ClientRect=this.m_Canvas.getBoundingClientRect()2190 2191 2192 //鼠标缩放2193 this.m_Canvas.onmousewheel=this.m_Canvas.onwheel=function(event){2194 var pt=new CPoint(event.clientX,event.clientY);2195 Control.MouseWheel(event.wheelDelta,pt);2196 Control.RepaintControl();2197 } 2198 2199 //鼠标按下左键2200 this.m_Canvas.onmousedown=function(event){ 2201 2202 if(event.button==0)2203 {2204 var pt=new CPoint(event.clientX,event.clientY);2205 Control.m_bMouseClickFlag=true;2206 Control.LButtonDown(pt);2207 2208 //鼠标移动2209 Control.m_Canvas.onmousemove=function(event)2210 {2211 Control.m_Canvas.style.cursor="move";2212 var pt=new CPoint(event.clientX,event.clientY); 2213 Control.MouseMove(pt);2214 }2215 }2216 2217 //鼠标松开左键 2218 Control.m_Canvas.onmouseup=function(){2219 if(event.button==0)2220 {2221 Control.m_bMouseClickFlag=false;2222 var pt=new CPoint(event.clientX,event.clientY);2223 2224 Control.LButtonUp(pt);2225 Control.m_Canvas.onmousemove=null;2226 Control.m_Canvas.onmouseup=null;2227 Control.m_Canvas.style.cursor="default";2228 } 2229 } 2230 }2231 2232 //鼠标移动2233 this.m_Canvas.onmousemove=function(event)2234 {2235 var pt=new CPoint(event.clientX,event.clientY); 2236 Control.MouseMove(pt);2237 }2238 2239 //鼠标双击左键 2240 this.m_Canvas.ondblclick=function()2241 {2242 if(event.button==0)2243 {2244 var pt=new CPoint(event.clientX,event.clientY); 2245 Control.LButtonDblClk(pt);2246 } 2247 }2248}2249 2250//未初始化,用当前环境显示2251//BOOL IMG_OBJ*2252function LoadImageFromBuffer(fControl)2253{2254 //var imagedata_Org = this.m_Context.getImageData(0, 0,this.m_Image.width, this.m_Image.height);2255 var imagedata;//=mew Image;2256 //Image.2257 for(var i = 0, n = imagedata.data.length; i < n; i += 3) 2258 { 2259 imagedata.data[i + 0] = 255 - imagedata.data[i + 0]; //red;2260 imagedata.data[i + 1] = 255 - imagedata.data[i + 1]; //green2261 imagedata.data[i + 2] = 255 - imagedata.data[i + 2]; //blue2262 //imagedata.data[i + 3] = 255 - imagedata.data[i + 3]; //a2263 }2264 this.m_Context.putImageData(imagedata, 0, 0);2265} 2266//未初始化,用当前环境显示2267//BOOL LPCTSTR FilePath2268function LoadImageFromFile(ImageName,Control)2269{ 2270 this.m_Image.onload=function(){2271 Control.RepaintControl();2272 } 2273 2274 this.m_Image.src=ImageName; 2275 2276 //鼠标缩放2277 this.m_Canvas.onmousewheel=this.m_Canvas.onwheel=function(event){2278 var pt=new CPoint(event.clientX,event.clientY);2279 Control.MouseWheel(event.wheelDelta,pt);2280 Control.RepaintControl();2281 } 2282 2283 //鼠标按下左键2284 this.m_Canvas.onmousedown=function(event){ 2285 2286 if(event.button==0)2287 {2288 var pt=new CPoint(event.clientX,event.clientY);2289 Control.m_bMouseClickFlag=true;2290 Control.LButtonDown(pt);2291 2292 //鼠标移动2293 Control.m_Canvas.onmousemove=function(event)2294 {2295 Control.m_Canvas.style.cursor="move";2296 var pt=new CPoint(event.clientX,event.clientY); 2297 Control.MouseMove(pt);2298 }2299 }2300 2301 //鼠标松开左键 2302 Control.m_Canvas.onmouseup=function(){2303 if(event.button==0)2304 {2305 Control.m_bMouseClickFlag=false;2306 var pt=new CPoint(event.clientX,event.clientY);2307 2308 Control.LButtonUp(pt);2309 Control.m_Canvas.onmousemove=null;2310 Control.m_Canvas.onmouseup=null;2311 Control.m_Canvas.style.cursor="default";2312 } 2313 } 2314 }2315 2316 //鼠标移动2317 this.m_Canvas.onmousemove=function(event)2318 {2319 var pt=new CPoint(event.clientX,event.clientY); 2320 Control.MouseMove(pt);2321 }2322 2323 //鼠标双击左键 2324 this.m_Canvas.ondblclick=function()2325 {2326 if(event.button==0)2327 {2328 var pt=new CPoint(event.clientX,event.clientY); 2329 Control.LButtonDblClk(pt);2330 } 2331 }2332} 2333//回调函数,用来处理外部绘制要求2334//BOOL 2335//nType=1,3,42336//BOOL 2337function WriteBmpToFile(nType,csPath) 2338{} 2339//BOOL list<Figure>::iterator pFigure, int nShiftX, int nShiftY2340function CheckFigureGotoOutSide(pFigure, nShiftX,nShiftY)2341{}2342//CRect * pRect , list<Figure>::iterator Iterator2343function GetFigureOutsideRect(pRect,Iterator)2344{}2345function MouseMove(point) //移动鼠标2346{2347 var bInvalidate=0;2348 point.x-=this.x_Distance;2349 point.y-=this.y_Distance; 2350 var nSelectRectSize=GetIntValue(2+Math.abs(1/this.m_fZoomNum));2351 if (!PointInCurrentRect(this.m_ClientRect,point))2352 {2353 this.b_CursorInOutSide=true;2354 return;2355 } 2356 else2357 {2358 this.b_CursorInOutSide=false;2359 }2360 if (this.b_DrawRect || this.b_DrawPoly ||this.b_DrawCircle ||this.b_LeftButtonDown ||this.b_DrawDoubleRect)2361 {2362 bInvalidate++;2363 }2364 PointEqual(this.m_MovePoint_cursor,point); 2365 //如果画图形时,鼠标移动到对象图外2366 if ((this.b_DrawRect || this.b_DrawPoly ||this.b_DrawCircle) && this.PointGoOutSide(this.m_MovePoint_cursor))2367 {2368 return;2369 } 2370 var tempPoint=new CPoint(0,0);2371 tempPoint.x=this.m_MovePoint_cursor.x+FigureControl_DoubleRectDistance;2372 tempPoint.y=this.m_MovePoint_cursor.y+FigureControl_DoubleRectDistance;2373 if (this.PointGoOutSide(tempPoint) && this.b_DrawDoubleRect)2374 {2375 return;2376 }2377 if(this.m_bMouseClickFlag)2378 {2379 this.m_cpCurrentPoint_cursor.x=point.x;2380 this.m_cpCurrentPoint_cursor.y=point.y; 2381 2382 this.m_cpDistancePoint.x=this.m_cpCurrentPoint_cursor.x-this.m_cpOriginalPoint_cursor.x;2383 this.m_cpDistancePoint.y=this.m_cpCurrentPoint_cursor.y-this.m_cpOriginalPoint_cursor.y; 2384 var m_cpCurrentPoint_cursor=new CPoint(0,0);2385 PointEqual(m_cpCurrentPoint_cursor,point); 2386 2387 //拉动图形边缘点 2388 if (this.b_FigurePointSelect&& !this.PointGoOutSide(this.m_cpCurrentPoint_cursor))2389 {2390 var Index=0;2391 var Iterator=new Figure; 2392 for(Index;Index<this.m_FiguresSet.m_nFigureCount;Index++)2393 {2394 Iterator=this.m_FiguresSet.m_Figures[Index];2395 var b_find=0;2396 var b_RelativeWindow=false;2397 var distance=0;2398 varcurrentFigurePos=-1;2399 2400 if (Iterator.figure_id==this.CurrentSelectPoint.Figure_id)2401 { 2402 if ( Iterator.figure_type==RectType || Iterator.figure_type==PolyType)2403 { 2404 var FindIterator=new CPoint(0,0);2405 var FindIndex=0;2406 var pointNum=0 //当前移动到第几个点2407 var nSquredMoveDistance=0;2408 for(FindIndex;FindIndex<Iterator.figure_data.nCPointCount;FindIndex++)2409 {2410 pointNum++; 2411 FindIterator=Iterator.figure_data.m_CPoint[FindIndex];2412 2413 if ((FindIterator.x==this.CurrentSelectPoint.Figure_point.x && FindIterator.y==this.CurrentSelectPoint.Figure_point.y))2414 {2415 if (Iterator.figure_type==PolyType)2416 { 2417 FindIterator.x=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum);2418 FindIterator.y=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum);2419 2420 this.CurrentSelectPoint.Figure_point.x=FindIterator.x;2421 this.CurrentSelectPoint.Figure_point.y=FindIterator.y; 2422 }2423 if ( Iterator.figure_type==RectType)2424 { 2425 var nMoveDistance_x=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum)-FindIterator.x; 2426 var nMoveDistance_y=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum)-FindIterator.y; 2427 nSquredMoveDistance=nMoveDistance_x;2428 2429 switch (pointNum)2430 {2431 case 1: //第一个点2432 if (Iterator.bShowSqure)2433 { 2434 FindIterator.x+=nSquredMoveDistance;2435 FindIterator.y+=nSquredMoveDistance;2436 FindIterator=Iterator.figure_data.m_CPoint[1];2437 2438 FindIterator.x-=nSquredMoveDistance;2439 FindIterator.y+=nSquredMoveDistance;2440 FindIterator=Iterator.figure_data.m_CPoint[2];2441 FindIterator.x-=nSquredMoveDistance;2442 FindIterator.y-=nSquredMoveDistance;2443 FindIterator=Iterator.figure_data.m_CPoint[3];2444 FindIterator.x+=nSquredMoveDistance;2445 FindIterator.y-=nSquredMoveDistance; 2446 }2447 else2448 {2449 var pt=new CPoint(0,0); 2450 pt.x=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum);2451 pt.y=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum); 2452 2453 Iterator.figure_data.m_CPoint[0].x=pt.x;2454 Iterator.figure_data.m_CPoint[0].y=pt.y;2455 2456 Iterator.figure_data.m_CPoint[1].y=pt.y;2457 2458 Iterator.figure_data.m_CPoint[3].x=pt.x; 2459 } 2460 break; 2461 case 2:2462 if (Iterator.bShowSqure)2463 {2464 FindIterator=Iterator.figure_data.m_CPoint[0];2465 FindIterator.x-=nSquredMoveDistance;2466 FindIterator.y-=nSquredMoveDistance;2467 FindIterator=Iterator.figure_data.m_CPoint[1];2468 FindIterator.x+=nSquredMoveDistance;2469 FindIterator.y-=nSquredMoveDistance;2470 FindIterator=Iterator.figure_data.m_CPoint[2];2471 FindIterator.x+=nSquredMoveDistance;2472 FindIterator.y+=nSquredMoveDistance;2473 FindIterator=Iterator.figure_data.m_CPoint[3];2474 FindIterator.x-=nSquredMoveDistance;2475 FindIterator.y+=nSquredMoveDistance; 2476 }2477 else2478 {2479 var pt=new CPoint(0,0); 2480 pt.x=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum);2481 pt.y=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum); 2482 2483 Iterator.figure_data.m_CPoint[1].x=pt.x;2484 Iterator.figure_data.m_CPoint[1].y=pt.y;2485 2486 Iterator.figure_data.m_CPoint[0].y=pt.y;2487 2488 Iterator.figure_data.m_CPoint[2].x=pt.x; 2489 } 2490 break;2491 case 3:2492 if (Iterator.bShowSqure)2493 {2494 FindIterator=Iterator.figure_data.m_CPoint[0];2495 FindIterator.x-=nSquredMoveDistance;2496 FindIterator.y-=nSquredMoveDistance;2497 FindIterator=Iterator.figure_data.m_CPoint[1];2498 FindIterator.x+=nSquredMoveDistance;2499 FindIterator.y-=nSquredMoveDistance; 2500 FindIterator=Iterator.figure_data.m_CPoint[2];2501 FindIterator.x+=nSquredMoveDistance;2502 FindIterator.y+=nSquredMoveDistance;2503 FindIterator=Iterator.figure_data.m_CPoint[3];2504 }2505 else2506 {2507 var pt=new CPoint(0,0); 2508 pt.x=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum);2509 pt.y=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum); 2510 2511 Iterator.figure_data.m_CPoint[2].x=pt.x;2512 Iterator.figure_data.m_CPoint[2].y=pt.y;2513 2514 Iterator.figure_data.m_CPoint[1].x=pt.x;2515 2516 Iterator.figure_data.m_CPoint[3].y=pt.y; 2517 } 2518 break;2519 case 4:2520 if (Iterator.bShowSqure)2521 {2522 FindIterator.x+=nSquredMoveDistance;2523 FindIterator.y-=nSquredMoveDistance;2524 FindIterator=Iterator.figure_data.m_CPoint[2];2525 FindIterator.x-=nSquredMoveDistance;2526 FindIterator.y-=nSquredMoveDistance;2527 FindIterator=Iterator.figure_data.m_CPoint[1];2528 FindIterator.x-=nSquredMoveDistance;2529 FindIterator.y+=nSquredMoveDistance;2530 FindIterator=Iterator.figure_data.m_CPoint[0];2531 FindIterator.x+=nSquredMoveDistance;2532 FindIterator.y+=nSquredMoveDistance;2533 }2534 else2535 {2536 var pt=new CPoint(0,0); 2537 pt.x=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum);2538 pt.y=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum); 2539 2540 Iterator.figure_data.m_CPoint[3].x=pt.x;2541 Iterator.figure_data.m_CPoint[3].y=pt.y;2542 2543 Iterator.figure_data.m_CPoint[2].y=pt.y;2544 2545 Iterator.figure_data.m_CPoint[0].x=pt.x; 2546 } 2547 break;2548 default:2549 break;2550 } 2551 this.CurrentSelectPoint.Figure_point.x=FindIterator.x;2552 this.CurrentSelectPoint.Figure_point.y=FindIterator.y; 2553 b_find=1;2554 break; //找到该点后退出2555 }2556 } //end of list of point//*/2557 if ((Iterator.figure_type==RectType &&this.CurrentSelectPoint.nPointIndex>=5))2558 {2559 //中间点 2560 FindIterator=Iterator.figure_data.m_CPoint[0];2561 var pt=new CPoint(0,0); 2562 switch(this.CurrentSelectPoint.nPointIndex)2563 {2564 case 5: 2565 pt.y=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum);2566 FindIterator.y=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum);2567 FindIterator=Iterator.figure_data.m_CPoint[1];2568 FindIterator.y=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum);2569 break;2570 case 6: 2571 pt.x=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum); 2572 FindIterator=Iterator.figure_data.m_CPoint[1];2573 FindIterator.x=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum);2574 FindIterator=Iterator.figure_data.m_CPoint[2];2575 FindIterator.x=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum); 2576 break;2577 case 7: 2578 pt.y=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum); 2579 FindIterator=Iterator.figure_data.m_CPoint[2];2580 FindIterator.y=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum);2581 FindIterator=Iterator.figure_data.m_CPoint[3];2582 FindIterator.y=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum); 2583 break;2584 case 8: 2585 pt.x=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum);2586 FindIterator.x=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum);2587 FindIterator=Iterator.figure_data.m_CPoint[3];2588 FindIterator.x=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum); 2589 break;2590 default:2591 break;2592 } 2593 b_find=1;2594 //break; //找到该点后退出2595 }2596 } //end of recttype ,polytype2597 }2598 if(Iterator.figure_type==CircleType)2599 { 2600 var pt=new Array(5);2601 for(var index=0;index<5;index++)2602 pt[index]=new CPoint(0,0);2603 2604 pt[1].x=Iterator.figure_rect.left+GetIntValue((Iterator.figure_rect.right-Iterator.figure_rect.left)/2);2605 pt[1].y=Iterator.figure_rect.top; 2606 pt[2].x=Iterator.figure_rect.right;2607 pt[2].y=Iterator.figure_rect.top+GetIntValue((Iterator.figure_rect.bottom-Iterator.figure_rect.top)/2); 2608 pt[3].x=Iterator.figure_rect.left+GetIntValue((Iterator.figure_rect.right-Iterator.figure_rect.left)/2);2609 pt[3].y=Iterator.figure_rect.bottom; 2610 pt[4].x=Iterator.figure_rect.left;2611 pt[4].y=Iterator.figure_rect.top+GetIntValue((Iterator.figure_rect.bottom-Iterator.figure_rect.top)/2);2612 for (var i=1;i<=4;i++)2613 { 2614 if(Math.abs(pt[i].x-this.CurrentSelectPoint.Figure_point.x)<=nSelectRectSize 2615 && Math.abs(pt[i].y-this.CurrentSelectPoint.Figure_point.y)<=nSelectRectSize)2616 {2617 switch(i)2618 {2619 case 1:2620 Iterator.figure_rect.top=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum); //存入图像点2621 this.CurrentSelectPoint.Figure_point.y=Iterator.figure_rect.top; 2622 break;2623 case 2: 2624 Iterator.figure_rect.right=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum);2625 this.CurrentSelectPoint.Figure_point.x=Iterator.figure_rect.right;2626 break;2627 case 3:2628 Iterator.figure_rect.bottom=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum);2629 this.CurrentSelectPoint.Figure_point.y=Iterator.figure_rect.bottom; 2630 break;2631 case 4:2632 Iterator.figure_rect.left=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum);2633 this.CurrentSelectPoint.Figure_point.x=Iterator.figure_rect.left;2634 break;2635 default:2636 break; 2637 } 2638 b_find=1;2639 break;2640 }2641 }2642 }2643 if (Iterator.figure_type==DrectType)2644 {2645 var pt=new Array(9);2646 for(var index=0;index<9;index++)2647 pt[index]=new CPoint(0,0);2648 2649 pt[1].x=Iterator.figure_rect.left;2650 pt[1].y=Iterator.figure_rect.top;2651 pt[2].x=Iterator.figure_rect.right;2652 pt[2].y=Iterator.figure_rect.top;2653 pt[3].x=Iterator.figure_rect.right;2654 pt[3].y=Iterator.figure_rect.bottom;2655 pt[4].x=Iterator.figure_rect.left;2656 pt[4].y=Iterator.figure_rect.bottom;2657 pt[5].x=Iterator.figure_rect_outside.left;2658 pt[5].y=Iterator.figure_rect_outside.top;2659 pt[6].x=Iterator.figure_rect_outside.right;2660 pt[6].y=Iterator.figure_rect_outside.top;2661 pt[7].x=Iterator.figure_rect_outside.right;2662 pt[7].y=Iterator.figure_rect_outside.bottom;2663 pt[8].x=Iterator.figure_rect_outside.left;2664 pt[8].y=Iterator.figure_rect_outside.bottom; 2665 for (var i=1;i<=8;i++)2666 { 2667 if(Math.abs(pt[i].x-this.CurrentSelectPoint.Figure_point.x)<nSelectRectSize && Math.abs(pt[i].y-this.CurrentSelectPoint.Figure_point.y)<nSelectRectSize)2668 {2669 var MoveDistance_x=0,MoveDistance_y=0; 2670 var CurrentPointCursor=new CPoint(0,0);2671 CurrentPointCursor.x=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum); 2672 CurrentPointCursor.y=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum); 2673 switch(i)2674 {2675 case 1: 2676 if (CurrentPointCursor.x>=pt[2].x || CurrentPointCursor.y>=pt[4].y )2677 {2678 break;2679 }2680 else2681 {2682 MoveDistance_x=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum)-Iterator.figure_rect.left; 2683 MoveDistance_y=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum)-Iterator.figure_rect.top; 2684 Iterator.figure_rect.left=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum); 2685 Iterator.figure_rect.top=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum); 2686 if (Iterator.figure_rect_outside.left+MoveDistance_x<=0 || Iterator.figure_rect_outside.top+MoveDistance_y<=0)2687 {2688 break;2689 }2690 else2691 {2692 Iterator.figure_rect_outside.left+=MoveDistance_x;2693 Iterator.figure_rect_outside.top+=MoveDistance_y;2694 this.CurrentSelectPoint.Figure_point.x=Iterator.figure_rect.left;2695 this.CurrentSelectPoint.Figure_point.y=Iterator.figure_rect.top;2696 break;2697 } 2698 } 2699 case 2:2700 if (CurrentPointCursor.x<=pt[1].x || CurrentPointCursor.y>=pt[3].y)2701 {2702 break;2703 }2704 else2705 {2706 MoveDistance_x=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum)-Iterator.figure_rect.right; 2707 MoveDistance_y=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum)-Iterator.figure_rect.top; 2708 Iterator.figure_rect.right=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum); 2709 Iterator.figure_rect.top=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum); 2710 if (Iterator.figure_rect_outside.right+MoveDistance_x>=this.m_RectFigure.right || Iterator.figure_rect_outside.top+MoveDistance_y<=0)2711 {2712 break;2713 }2714 else2715 {2716 Iterator.figure_rect_outside.right+=MoveDistance_x;2717 Iterator.figure_rect_outside.top+=MoveDistance_y;2718 this.CurrentSelectPoint.Figure_point.x=Iterator.figure_rect.right;2719 this.CurrentSelectPoint.Figure_point.y=Iterator.figure_rect.top;2720 break;2721 } 2722 } 2723 case 3:2724 if (CurrentPointCursor.x<=pt[4].x || CurrentPointCursor.y<=pt[2].y)2725 {2726 break;2727 }2728 else2729 {2730 MoveDistance_x=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum)-Iterator.figure_rect.right; 2731 MoveDistance_y=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum)-Iterator.figure_rect.bottom; 2732 Iterator.figure_rect.right=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum); 2733 Iterator.figure_rect.bottom=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum); 2734 if (Iterator.figure_rect_outside.right+MoveDistance_x>=this.m_RectFigure.right || Iterator.figure_rect_outside.bottom+MoveDistance_y>=this.m_RectFigure.bottom)2735 {2736 break;2737 }2738 else2739 {2740 Iterator.figure_rect_outside.right+=MoveDistance_x;2741 Iterator.figure_rect_outside.bottom+=MoveDistance_y;2742 this.CurrentSelectPoint.Figure_point.x=Iterator.figure_rect.right;2743 this.CurrentSelectPoint.Figure_point.y=Iterator.figure_rect.bottom;2744 break;2745 } 2746 } 2747 case 4:2748 if (CurrentPointCursor.x>=pt[3].x || CurrentPointCursor.y<=pt[1].y)2749 {2750 break;2751 }2752 else2753 {2754 MoveDistance_x=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum)-Iterator.figure_rect.left; 2755 MoveDistance_y=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum)-Iterator.figure_rect.bottom; 2756 Iterator.figure_rect.left=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum); 2757 Iterator.figure_rect.bottom=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum); 2758 if (Iterator.figure_rect_outside.left+MoveDistance_x<=0 || Iterator.figure_rect_outside.bottom+MoveDistance_y>=this.m_RectFigure.bottom)2759 {2760 break;2761 }2762 else2763 {2764 Iterator.figure_rect_outside.left+=MoveDistance_x;2765 Iterator.figure_rect_outside.bottom+=MoveDistance_y;2766 this.CurrentSelectPoint.Figure_point.x=Iterator.figure_rect.left;2767 this.CurrentSelectPoint.Figure_point.y=Iterator.figure_rect.bottom;2768 break;2769 } 2770 } 2771 case 5: 2772 if (this.PointInRectEdge(CurrentPointCursor,Iterator.figure_rect,LeftTop))2773 {2774 if (this.b_ChooseDRectType)2775 {2776 MoveDistance_x=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum)-Iterator.figure_rect_outside.left; 2777 MoveDistance_y=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum)-Iterator.figure_rect_outside.top; 2778 if (Iterator.figure_rect_outside.right-MoveDistance_x>=this.m_RectFigure.right || Iterator.figure_rect_outside.bottom-MoveDistance_y>=this.m_RectFigure.bottom)2779 {2780 break;2781 }2782 else2783 {2784 Iterator.figure_rect_outside.left=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum); 2785 Iterator.figure_rect_outside.top=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum); 2786 //根据纪念币算法修改2787 Iterator.figure_rect_outside.right-=MoveDistance_x;2788 Iterator.figure_rect_outside.bottom-=MoveDistance_y;2789 this.CurrentSelectPoint.Figure_point.x=Iterator.figure_rect_outside.left;2790 this.CurrentSelectPoint.Figure_point.y=Iterator.figure_rect_outside.top;2791 } 2792 }2793 else2794 {2795 Iterator.figure_rect_outside.left=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum); 2796 Iterator.figure_rect_outside.top=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum); 2797 this.CurrentSelectPoint.Figure_point.x=Iterator.figure_rect_outside.left;2798 this.CurrentSelectPoint.Figure_point.y=Iterator.figure_rect_outside.top;2799 }2800 } 2801 break;2802 case 6: 2803 if (this.PointInRectEdge(CurrentPointCursor,Iterator.figure_rect,RightTop))2804 {2805 if (this.b_ChooseDRectType)2806 {2807 MoveDistance_x=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum)-Iterator.figure_rect_outside.right; 2808 MoveDistance_y=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum)-Iterator.figure_rect_outside.top; 2809 if (Iterator.figure_rect_outside.left-MoveDistance_x<=0 || Iterator.figure_rect_outside.bottom-MoveDistance_y>=this.m_RectFigure.bottom)2810 {2811 break;2812 }2813 else2814 {2815 Iterator.figure_rect_outside.right=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum); 2816 Iterator.figure_rect_outside.top=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum); 2817 //根据纪念币算法修改2818 Iterator.figure_rect_outside.left-=MoveDistance_x;2819 Iterator.figure_rect_outside.bottom-=MoveDistance_y; 2820 this.CurrentSelectPoint.Figure_point.x=Iterator.figure_rect_outside.right;2821 this.CurrentSelectPoint.Figure_point.y=Iterator.figure_rect_outside.top;2822 } 2823 }2824 else2825 {2826 Iterator.figure_rect_outside.right=GetIntValue((m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum); 2827 Iterator.figure_rect_outside.top=GetIntValue((m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum); 2828 this.CurrentSelectPoint.Figure_point.x=Iterator.figure_rect_outside.right;2829 this.CurrentSelectPoint.Figure_point.y=Iterator.figure_rect_outside.top;2830 }2831 } 2832 break;2833 case 7: 2834 if (this.PointInRectEdge(CurrentPointCursor,Iterator.figure_rect,RightBottom))2835 {2836 if (this.b_ChooseDRectType)2837 {2838 MoveDistance_x=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum)-Iterator.figure_rect_outside.right; 2839 MoveDistance_y=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum)-Iterator.figure_rect_outside.bottom; 2840 if (Iterator.figure_rect_outside.left-MoveDistance_x<=0 || Iterator.figure_rect_outside.top-MoveDistance_y<=0)2841 {2842 break;2843 }2844 else2845 {2846 Iterator.figure_rect_outside.right=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum); 2847 Iterator.figure_rect_outside.bottom=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum); 2848 //根据纪念币算法修改2849 Iterator.figure_rect_outside.left-=MoveDistance_x;2850 Iterator.figure_rect_outside.top-=MoveDistance_y;2851 this.CurrentSelectPoint.Figure_point.x=Iterator.figure_rect_outside.right;2852 this.CurrentSelectPoint.Figure_point.y=Iterator.figure_rect_outside.bottom;2853 }2854 }2855 else2856 {2857 Iterator.figure_rect_outside.right=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum); 2858 Iterator.figure_rect_outside.bottom=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum); 2859 this.CurrentSelectPoint.Figure_point.x=Iterator.figure_rect_outside.right;2860 this.CurrentSelectPoint.Figure_point.y=Iterator.figure_rect_outside.bottom;2861 }2862 } 2863 break;2864 case 8: 2865 if (this.PointInRectEdge(CurrentPointCursor,Iterator.figure_rect,LeftBottom))2866 {2867 if (this.b_ChooseDRectType)2868 {2869 MoveDistance_x=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/m_fZoomNum)-Iterator.figure_rect_outside.left; 2870 MoveDistance_y=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/m_fZoomNum)-Iterator.figure_rect_outside.bottom; 2871 if (Iterator.figure_rect_outside.right-MoveDistance_x>=m_RectFigure.right || Iterator.figure_rect_outside.top-MoveDistance_y<=0)2872 {2873 break;2874 }2875 else2876 {2877 Iterator.figure_rect_outside.left=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum); 2878 Iterator.figure_rect_outside.bottom=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum); 2879 //根据纪念币算法修改2880 Iterator.figure_rect_outside.right-=MoveDistance_x;2881 Iterator.figure_rect_outside.top-=MoveDistance_y; 2882 this.CurrentSelectPoint.Figure_point.x=Iterator.figure_rect_outside.left;2883 this.CurrentSelectPoint.Figure_point.y=Iterator.figure_rect_outside.bottom;2884 }2885 }2886 else2887 {2888 Iterator.figure_rect_outside.left=GetIntValue((this.m_cpCurrentPoint_cursor.x-this.OriginalPoint_Bitmap.x)/this.m_fZoomNum); 2889 Iterator.figure_rect_outside.bottom=GetIntValue((this.m_cpCurrentPoint_cursor.y-this.OriginalPoint_Bitmap.y)/this.m_fZoomNum); 2890 this.CurrentSelectPoint.Figure_point.x=Iterator.figure_rect_outside.left;2891 this.CurrentSelectPoint.Figure_point.y=Iterator.figure_rect_outside.bottom;2892 }2893 } 2894 break;2895 default:2896 break;2897 }2898 b_find=1;2899 break;2900 }2901 }2902 }2903 }2904 if (b_find==1)2905 { 2906 break;2907 }2908 }2909 bInvalidate++;2910 }2911 //平移所有图形2912 if (this.b_SubFiguresMove && this.b_FigurePointSelect==false && this.b_LeftButtonDown==true )2913 { 2914 var FindIterator=new Figure;2915 var FindIndex=0; 2916 for(FindIndex;FindIndex<this.m_FiguresSet.m_nFigureCount;FindIndex++)2917 { 2918 FindIterator=this.m_FiguresSet.m_Figures[FindIndex];2919 if ((FindIterator.figure_id==this.m_nCursorInFigureId && this.m_SelectSubFigureRectIdSet.m_nFigureRectCount>0)2920 || this.b_MoveAllFigures)2921 { 2922 FindIterator.MoveFigure(this.m_cpDistancePoint.x,this.m_cpDistancePoint.y);2923 var b_OutSide=false;2924 if (FindIterator.figure_type==DrectType)2925 {2926 var p1=new CPoint(0,0);2927 var p2=new CPoint(0,0); 2928 p1.x=GetIntValue(FindIterator.figure_rect_outside.left*this.m_fZoomNum)+this.OriginalPoint_Bitmap.x+FindIterator.shift_x;2929 p1.y=GetIntValue(FindIterator.figure_rect_outside.top*this.m_fZoomNum)+this.OriginalPoint_Bitmap.y+FindIterator.shift_y;2930 p2.x=GetIntValue(FindIterator.figure_rect_outside.right*this.m_fZoomNum)+this.OriginalPoint_Bitmap.x+FindIterator.shift_x; 2931 p2.y=GetIntValue(FindIterator.figure_rect_outside.bottom*this.m_fZoomNum)+this.OriginalPoint_Bitmap.y+FindIterator.shift_y;2932 if (this.PointGoOutSide(p1) || this.PointGoOutSide(p2))2933 {2934 b_OutSide=true;2935 }2936 if (b_OutSide)2937 {2938 FindIterator.MoveFigure(-1*m_cpDistancePoint.x,-1*m_cpDistancePoint.y);2939 }2940 }2941 else if(FindIterator.figure_type==CircleType)2942 {2943 var p1=new CPoint(0,0);2944 var p2=new CPoint(0,0); 2945 p1.x=GetIntValue(FindIterator.figure_rect.left*this.m_fZoomNum)+this.OriginalPoint_Bitmap.x+FindIterator.shift_x;2946 p1.y=GetIntValue(FindIterator.figure_rect.top*this.m_fZoomNum)+this.OriginalPoint_Bitmap.y+FindIterator.shift_y;2947 p2.x=GetIntValue(FindIterator.figure_rect.right*this.m_fZoomNum)+this.OriginalPoint_Bitmap.x+FindIterator.shift_x; 2948 p2.y=GetIntValue(FindIterator.figure_rect.bottom*this.m_fZoomNum)+this.OriginalPoint_Bitmap.y+FindIterator.shift_y;2949 if (this.PointGoOutSide(p1) || this.PointGoOutSide(p2))2950 {2951 b_OutSide=true;2952 }2953 if (b_OutSide)2954 {2955 FindIterator.MoveFigure(-1*this.m_cpDistancePoint.x,-1*this.m_cpDistancePoint.y);2956 } 2957 }2958 else //其它的为点组成的图形2959 { 2960 var PointIterator=new CPoint(0,0);2961 var nPointIndex=0;2962 var nFindPointIndex=0;2963 for (nFindPointIndex;nFindPointIndex<FindIterator.figure_data.nCPointCount;nFindPointIndex++)2964 {2965 PointIterator=FindIterator.figure_data.m_CPoint[nFindPointIndex];2966 var TempPoint=new CPoint(0,0);2967 TempPoint.x=GetIntValue(PointIterator.x*this.m_fZoomNum)+this.OriginalPoint_Bitmap.x+FindIterator.shift_x;2968 TempPoint.y=GetIntValue(PointIterator.y*this.m_fZoomNum)+this.OriginalPoint_Bitmap.y+FindIterator.shift_y;2969 if(this.PointGoOutSide((TempPoint)))2970 {2971 b_OutSide=true;2972 break;2973 } 2974 nPointIndex++; 2975 }2976 if (b_OutSide)2977 {2978 FindIterator.MoveFigure(-1*m_cpDistancePoint.x,-1*m_cpDistancePoint.y);2979 }2980 } 2981 } 2982 }2983 bInvalidate++;2984 } 2985 else if(this.b_SubFiguresMove==false && this.b_FigurePointSelect==false && this.b_LeftButtonDown==true && this.b_DrawPoly==false)2986 { 2987 this.OriginalPoint_Bitmap.x=this.m_cpDistancePoint.x+this.OriginalPoint_Bitmap.x;2988 this.OriginalPoint_Bitmap.y=this.m_cpDistancePoint.y+this.OriginalPoint_Bitmap.y; 2989 bInvalidate++;2990 } 2991 this.m_cpOriginalPoint_cursor.x=this.m_cpCurrentPoint_cursor.x;2992 this.m_cpOriginalPoint_cursor.y=this.m_cpCurrentPoint_cursor.y; 2993 } 2994 if (bInvalidate>0)2995 {2996 this.RepaintControl();2997 }2998}2999function PreTranslateMessage(msg)...

Full Screen

Full Screen

commonFun.js

Source:commonFun.js Github

copy

Full Screen

1function errorCallBack(response, error){2 trace(response); 3 trace(error); 4}5function timeDisplayHtml(prefix){6 var facet_range_prefix = ""+prefix+"_facet_range";7 var facet_created_at_html = "";8 facet_created_at_html += '<span class="rightalign"></span><span id="'+facet_range_prefix+'_timeselect_start">全部时间</span><span id="'+facet_range_prefix+'_splitmark" style="display:none;"> ~ </span><span id="'+facet_range_prefix+'_timeselect_end"></span>';9 facet_created_at_html += createRangeOnsiteFieldHtml(facet_range_prefix, true);10 $("#"+prefix+"_facet_range_html").empty().append(facet_created_at_html);11 //为时间控件绑定事件12 $("#"+facet_range_prefix+"_createdtime_start, #"+facet_range_prefix+"_createdtime_end").die("click");13 $("#"+facet_range_prefix+"_createdtime_start, #"+facet_range_prefix+"_createdtime_end").live("click", function() {14 WdatePicker({onpicked:function(){15 var cs = $("#"+facet_range_prefix+"_createdtime_start").val();16 var ce = $("#"+facet_range_prefix+"_createdtime_end").val();17 if(cs.length != 0 || ce.length != 0){18 $("input[target=createdtime]").attr("checked", false);19 $("#"+facet_range_prefix+"_timeselect_start").text(cs);20 $("#"+facet_range_prefix+"_timeselect_end").text(ce);21 isShowSplitmark("#"+facet_range_prefix+"_timeselect_start", "#"+facet_range_prefix+"_timeselect_end", "#"+facet_range_prefix+"_splitmark", true);22 $("#"+facet_range_prefix+"_createdtime_all").attr("checked", false);23 }24 },oncleared:function(){25 if($("#"+facet_range_prefix+"_createdtime_start").val().length == 0 && $("#"+facet_range_prefix+"_createdtime_end").val().length == 0){26 $("#"+facet_range_prefix+"_timeselect_start").text("全部时间");27 $("#"+facet_range_prefix+"_timeselect_end").text("");28 isShowSplitmark("#"+facet_range_prefix+"_timeselect_start", "#"+facet_range_prefix+"_timeselect_end", "#"+facet_range_prefix+"_splitmark");29 $("#"+facet_range_prefix+"_createdtime_all").attr("checked", true);30 }31 else{32 if($("input[name="+facet_range_prefix+"_createdtime_start]").val().length == 0){33 $("#"+facet_range_prefix+"_timeselect_start").text("");34 }35 if($("input[name="+facet_range_prefix+"_createdtime_end]").val().length == 0){36 $("#"+facet_range_prefix+"_timeselect_end").text("");37 }38 }39 },dateFmt:'yyyy-MM-dd HH:mm:ss'});40 });41 //为控件绑定颜色改变事件42 $("#"+prefix+"_facet_range_html div[timetype] input, #"+prefix+"_facet_range_html div[timetype] select").unbind("click");43 $("#"+prefix+"_facet_range_html div[timetype] input, #"+prefix+"_facet_range_html div[timetype] select").bind("click", function(){44 var tt = $(this).parent().attr("timetype");45 $("#"+prefix+"_facet_range_html").attr("checkedtimetype", tt); //最后一次选择的时间控件46 //_this.changeBorderColor(tt); 47 changeTimeBorderColor(prefix+"_facet_range_html", tt); 48 });49 //快捷按钮点击事件50 $("#"+prefix+"_facet_range_createdtime_all").bind("click", function(){51 if($(this).prop("checked")){52 $(this).attr("checked", true);53 setTimeSelectMsg(""+prefix+"_facet_range", "全部时间", ""); 54 }55 else{56 $(this).attr("checked", false);57 var cs = $("#"+prefix+"_facet_range_createdtime_start").val();58 var ce = $("#"+prefix+"_facet_range_createdtime_end").val();59 if(cs == "" && ce == ""){60 setTimeSelectMsg(""+prefix+"_facet_range", "请填写时间"); 61 }62 else if(cs == "" || cs == undefined){63 setTimeSelectMsg(""+prefix+"_facet_range", "", ce); 64 }65 else if(ce == "" || ce == undefined){66 setTimeSelectMsg(""+prefix+"_facet_range", cs, ""); 67 }68 }69 });70 //时间标签 当前时间和开始时间切换 并给 总标题赋值71 $("#"+prefix+"_facet_range_nearlytime_thistime").bind("click", function(){72 var timestate = $(this).attr("timestate");73 nearlytimeTagClick(""+prefix+"_facet_range", timestate);74 });75 //相对今天,快捷按钮点击事件76 $("#"+prefix+"_facet_range_nearlytime_div input[nearly]").bind("click", function(){77 var nearlytype = $(this).attr("nearly");78 nearlytimeShortCutBtnClick(""+prefix+"_facet_range", nearlytype);79 });80 $("#"+prefix+"_facet_range_nearlytime, #"+prefix+"_facet_range_nearlytime_gap").bind("change", function(){81 nearlytimeInputChange(""+prefix+"_facet_range");82 });83 //beforetime 控件 当前时间,开始时间标签点击事件84 $("#"+prefix+"_facet_range_beforetime_thistime").bind("click", function(){85 var timestate = $(this).attr("timestate");86 beforetimeTagTimeClick(""+prefix+"_facet_range", timestate);87 });88 $("#"+prefix+"_facet_range_beforetime_thisdate").bind("click", function(){89 var datestate = $(this).attr("datestate");90 beforetimeTagDateClick(""+prefix+"_facet_range", datestate);91 });92 //时间段 改变93 $("#"+prefix+"_facet_range_beforetime_start, #"+prefix+"_facet_range_beforetime_end, #"+prefix+"_facet_range_beforetime_end_gap").bind("change", function(){94 beforetimeInputChange(""+prefix+"_facet_range");95 });96 $("#"+prefix+"_facet_range_untiltime_div input[untiltime]").bind("click", function(){97 var type = $(this).attr("untiltime");98 var until= $(this).attr("until"+type+"");99 untiltimeShortCutBtnClick(""+prefix+"_facet_range", until, type);100 });101 //时间控件,下拉日期单位选择102 $.each(["start", "end"], function(k, item){103 //gap change104 $("#"+prefix+"_facet_range_untiltime_"+item+"_gap").bind("change", function(){105 var usgval = $(this).val();106 untiltimeGapChange(""+prefix+"_facet_range", usgval, item);107 untiltimeValueChange(""+prefix+"_facet_range");108 //_this.setUntilTimeChangeValue();109 });110 //this_gap change111 $("#"+prefix+"_facet_range_untiltime_"+item+"_this_gap").bind("change", function(){112 var ustgval = $(this).val();113 var unitArr = dateUnitDisplay(ustgval, "down");114 var opthtml = timeSelectOption(unitArr);115 $("#"+prefix+"_facet_range_untiltime_"+item+"_to_gap").empty().append(opthtml);116 //_this.setUntilTimeChangeValue();117 untiltimeValueChange(""+prefix+"_facet_range");118 });119 //to_gap change120 $("#"+prefix+"_facet_range_untiltime_"+item+"_to_gap").bind("change", function(){121 //_this.setUntilTimeChangeValue();122 untiltimeValueChange(""+prefix+"_facet_range");123 });124 //start change125 $("#"+prefix+"_facet_range_untiltime_"+item+"").bind("change", function(){126 untiltimeInputChange(""+prefix+"_facet_range", item);127 //_this.setUntilTimeChangeValue();128 untiltimeValueChange(""+prefix+"_facet_range");129 });130 //start to change131 $("#"+prefix+"_facet_range_untiltime_"+item+"_to").bind("change", function(){132 //_this.setUntilTimeChangeValue();133 untiltimeValueChange(""+prefix+"_facet_range");134 });135 });136 var measurehtml = "<option value='month'>月</option><option value='day'>天</option><option value='hour'>小时</option>";137 $("#"+prefix+"_facet_gap_measure").empty().append(measurehtml);138}139function createRangeOnsiteFieldHtml(prefix, pretitle){140 var html = "";141 //相对今天142 var nearlytimespan = "";143 if(pretitle){144 nearlytimespan = '<span class="rightalign">相对今天:</span>';145 }146 html += '<div style="margin:7px;" id="'+prefix+'_nearlytime_div" timetype="nearlytime">'+nearlytimespan+'<input type="radio" name="'+prefix+'_nearlytime_shortcut" id="'+prefix+'_nearlytime_day" class="outborder" nearly="1day" /><label for="'+prefix+'_nearlytime_day">近一天</label>&nbsp;&nbsp;<input type="radio" name="'+prefix+'_nearlytime_shortcut" id="'+prefix+'_nearlytime_week" class="outborder" nearly="1week" /><label for="'+prefix+'_nearlytime_week">近一周</label>&nbsp;&nbsp;<input type="radio" name="'+prefix+'_nearlytime_shortcut" id="'+prefix+'_nearlytime_month" class="outborder" nearly="1month" /><label for="'+prefix+'_nearlytime_month">近一月</label>&nbsp;&nbsp;<input type="radio" name="'+prefix+'_nearlytime_shortcut" id="'+prefix+'_nearlytime_year" class="outborder" nearly="1year" /><label for="'+prefix+'_nearlytime_year">近一年</label>&nbsp;&nbsp;近<input type="text" class="smallinput" style="border:1px solid #ccc;" id="'+prefix+'_nearlytime" name="'+prefix+'_nearlytime" /><select id="'+prefix+'_nearlytime_gap">'+timeSelectOption()+'</select>&nbsp;&nbsp;<a id="'+prefix+'_nearlytime_thistime" timestate="now" style="display:none;"></a></div>';147 //时间段148 var beforetimespan = "";149 if(pretitle){150 beforetimespan = '<span class="rightalign">时间段:</span>';151 }152 html += '<div style="margin:7px;" id="'+prefix+'_beforetime_div" timetype="beforetime">'+beforetimespan+' 前<input type="text" value="" id="'+prefix+'_beforetime_start" name="'+prefix+'_beforetime_start" class="smallinput" style="border:1px solid #ccc;"/>到前<input type="text" value="" class="smallinput" style="border:1px solid #ccc;" id="'+prefix+'_beforetime_end" name="'+prefix+'_beforetime_end" /><select id="'+prefix+'_beforetime_end_gap">'+timeSelectOption()+'</select>&nbsp;&nbsp; <a style="display:none;" id="'+prefix+'_beforetime_thisdate" datestate="now"></a> &nbsp;&nbsp; <a style="display:none;" id="'+prefix+'_beforetime_thistime" timestate="now"></a></div>';153 //绝对时间154 var createdtimespan = "";155 if(pretitle){156 createdtimespan = '<span class="rightalign">绝对时间:</span>';157 }158 html += "<div style='margin:7px;' id='"+prefix+"_createdtime_div' timetype='createdtime'>"+createdtimespan+"<input type='text' id='"+prefix+"_createdtime_start' name='"+prefix+"_createdtime_start' style='border:1px solid #ccc;'> 至 <input type='text' id='"+prefix+"_createdtime_end' name='"+prefix+"_createdtime_end' style='border:1px solid #ccc;'>&nbsp;&nbsp;<input type='checkbox' name='"+prefix+"_createdtime_all' id='"+prefix+"_createdtime_all' /><label for='"+prefix+"_createdtime_all'>全部</label></div>";159 //日历时间段160 var untiltimespan = "";161 html += '<div style="margin:7px;" id="'+prefix+'_untiltime_div" timetype="untiltime">';162 $.each(["start", "end"], function(k,v){163 if(pretitle && v == "start"){164 untiltimespan = '<span class="rightalign">日历时间段:</span>';165 }166 else if(pretitle && v == "end"){167 untiltimespan = '<span class="rightalign"></span>';168 }169 html+= ''+untiltimespan+'<input type="radio" name="'+prefix+'_untiltime_'+v+'_shortcut" id="'+prefix+'_untiltime_'+v+'_shortcut1" class="outborder" untiltime="'+v+'" until'+v+'="1day" /><label for="'+prefix+'_untiltime_'+v+'_shortcut1">昨天</label>&nbsp;&nbsp;<input type="radio" name="'+prefix+'_untiltime_'+v+'_shortcut" id="'+prefix+'_untiltime_'+v+'_shortcut2" class="outborder" untiltime="'+v+'" until'+v+'="1week" /><label for="'+prefix+'_untiltime_'+v+'_shortcut2">上周</label>&nbsp;&nbsp;<input type="radio" name="'+prefix+'_untiltime_'+v+'_shortcut" id="'+prefix+'_untiltime_'+v+'_shortcut3" class="outborder" untiltime="'+v+'" until'+v+'="1month" /><label for="'+prefix+'_untiltime_'+v+'_shortcut3">上个月</label>&nbsp;&nbsp;';170 html+='至今<input type="text" value="" class="smallinput" style="border:1px solid #ccc;" id="'+prefix+'_untiltime_'+v+'" name="'+prefix+'_untiltime_'+v+'" untiltime="'+v+'" /><select id="'+prefix+'_untiltime_'+v+'_gap" untiltime="'+v+'" >'+timeSelectOption()+'</select>该<select id="'+prefix+'_untiltime_'+v+'_this_gap">'+timeSelectOption()+'</select>的第<input type="text" value="" class="smallinput" style="border:1px solid #ccc;" id="'+prefix+'_untiltime_'+v+'_to" name="'+prefix+'_untiltime_'+v+'_to" untiltime="'+v+'" /><select id="'+prefix+'_untiltime_'+v+'_to_gap" untiltime="'+v+'" >'+timeSelectOption()+'</select><br/>';171 });172 html += '</div>';173 return html;174}175/**176 * 从模型的filtervalue数组 中获取指定名称的 filtervalue177 * @param filtername178 * @param filtervalueArr 179 * @returns filtervalue的数组180 */181function getFilterValue(filtername,filtervalueArr){182 var returnval = [];183 $.each(filtervalueArr,function(i,item){184 if(item.fieldname == filtername){185 returnval.push(item);186 }187 });188 return returnval;189}190/**191 * 生成模型的filtervalue对象192 * @param filtername193 * @param datatype 194 * @param value195 * @returns filtervalue对象196 */197function createFiltervalue(fieldname, datatype, value){198 var filtervalue = {};199 filtervalue.fieldname = fieldname;200 var fieldvalue = {};201 fieldvalue.datatype = datatype;202 fieldvalue.value = value;203 filtervalue.fieldvalue = fieldvalue;204 return filtervalue;205}206/*207 * 创建span标签208 * item 值标签span的class前缀 默认和fieldname相同209 * name 对应值的name string类型对应fieldvalue中的 value, value_text_object类型的存 text210 * code 对应值的code string类型不存在, 或 与name相同, value_text_object类型存 value211 * isnot 非range类型字段可以选择不包含某值, isnot 为 true时 添加"不"选择按钮 绑定点击事件212 * exclude isnot 为true时 为exclude赋值 是否排除213 * isfeature 特征分类 ,当选择特征分类时添加此属性214 * emotype 存情感值 可能不存在215 * marktype 微博标识和原创微博, 标记添加 的是id还是url216 * blurtype 兼容旧版本的 blur_value_objcet类型217 * canclename 删除按钮<a>标签的名称218 * */219function createFormConfigSpanHtml(item, name, code, isnot, exclude, isfeature, emotype, marktype, blurtype, canclename){220 //情感221 var emocode = "";222 if(emotype != undefined && emotype != ""){223 emocode = "emotype='"+emotype+"'";224 }225 //特征分类226 var fea = "";227 if(isfeature != undefined && isfeature != ""){228 fea = "isfeature='"+isfeature+"'";229 }230 var marktypeattr = "";231 if(marktype != undefined && marktype != ""){232 marktypeattr = "marktype='"+marktype+"'";233 }234 235 var blurtypeattr = "";236 if(blurtype != undefined && blurtype != ""){237 blurtypeattr = "blurtype='"+blurtype+"'";238 }239 var codeattr = "";240 if(code != undefined){241 code = commonFun.trim(code); 242 codeattr = "code='"+code+"'";243 }244 //默认值245 if(canclename == undefined || canclename == ""){246 canclename = "cancleselectedvaluetextobj";247 }248 //绑定删除事件249 $("a[name=cancleselectedvaluetextobj]").die("click");250 $("a[name=cancleselectedvaluetextobj]").live("click", function(){251 $(this).parent().remove();252 });253 name = commonFun.trim(name); //去除两端空格254 var spanhtml = "";255 spanhtml += "<span class='selwordsbox'>";256 var exattr = "";257 if(isnot){258 var exstyle = "";259 if(exclude != undefined && exclude != 0){260 exattr = "exclude='"+exclude+"'";261 exstyle = "style='color:#000000;'";262 }263 spanhtml += "<a class='excludeitem' onclick='excludeItemFun(this)' "+exstyle+" >不</a>";264 }265 spanhtml += "<span class='"+item+"item' "+codeattr+" "+exattr+" "+fea+" "+emocode+" "+marktypeattr+" "+blurtypeattr+" >"+name+"</span>";266 spanhtml += "<a name='"+canclename+"' value='"+item+"' class='cancleitem'>×</a>";267 spanhtml += "</span>";268 return spanhtml;269}270function checkSession(){271 $.ajax({url:config.phpPath+"checkuser.php",dataType:"json",type:"POST",data:{type:"existsession"},async:false,272 success:function(d){273 if(!d.result){274 location.href = config.sitePath+"login.shtml";275 }276 },277 error:function(){278 location.href = config.sitePath+"login.shtml";279 }280 });281}282function getSpiderAccountName(sourceid, accountid){283 var n = '';284 if(config.allSpiderAccount.length == 0){285 getSpiderAccount(function(data){286 if(data){287 config.allSpiderAccount = data;288 }289 });290 }291 $(config.allSpiderAccount).each(function(i,item){292 if(item.id == accountid && item.sourceid == sourceid ){293 n = item.username;294 return false;295 }296 });297 return n;298}299function getSpiderAccount(callback){300 $.ajax({url:config.phpPath+"taskmanager.php",async:false,data:{type:"getspideraccount"}, type:"post", dataType:"json",301 success:function(data){302 if(jQuery.isFunction(callback)){303 callback(data);304 }305 }});306}307//根据主机id获取别名308function getHostName(hostid){309 if(!hostid){310 return "默认主机";311 }312 var n = '';313 if(config.allDataHost.length == 0){314 getDataHost(function(data){315 if(data){316 config.allDataHost = data;317 }318 });319 }320 $(config.allDataHost).each(function(i,item){321 if(item.id == hostid){322 n = item.alias;323 return false;324 }325 });326 return n;327}328function getDataHost(callback){329 $.ajax({url:config.phpPath+"taskmanager.php",async:false,data:{type:"getdatahost"}, type:"post", dataType:"json",330 success:function(data){331 if(jQuery.isFunction(callback)){332 callback(data);333 }334 }});335}336function getTplOutfield(callback){337 var tploutfieldurl = config.phpPath+"spiderconfig_model.php";338 $.ajax({url:tploutfieldurl,async:false,data:{type:"selecttploutfield"}, type:"get", dataType:"json",339 success:function(data){340 if(jQuery.isFunction(callback)){341 callback(data);342 }343 }});344}345function getAccountSource(callback){346 $.ajax({347 url:config.phpPath+"taskmanager.php",348 async:false,349 data:{type:"getaccountsource"}, 350 type:"get", 351 dataType:"json",352 success:function(data){353 if(jQuery.isFunction(callback)){354 callback(data);355 }356 }357 });358}359//根据配置id获取名称360function getSpiderConfigName(configid){361 var n = '';362 if(config.allSpiderConfig.length == 0){363 getSpiderConfig(function(data){364 if(data){365 config.allSpiderConfig= data;366 }367 });368 }369 $(config.allSpiderConfig).each(function(i,item){370 if(item.id == configid){371 n = item.name;372 return false;373 }374 });375 return n;376}377/*378function getSpiderConfig(callback){379 var getspiderconfigurl = config.phpPath+"spiderconfig_model.php";380 $.ajax({url:getspiderconfigurl,async:false,data:{type:"selectspiderconfiginfo"}, type:"get", dataType:"json",381 success:function(data){382 if(jQuery.isFunction(callback)){383 callback(data);384 }385 }});386}387*/388//获取爬虫配置的id和名称389function getSpiderConfig(callback){390 $.ajax({url:config.phpPath+"taskmanager.php",async:false,data:{type:"getspiderconfig"}, type:"post", dataType:"json",391 success:function(data){392 if(jQuery.isFunction(callback)){393 callback(data);394 }395 }});396}397/*398//根据搜索引擎id获取名称399function getSearchEngineName(engineid){400 var n = '';401 if(config.allSearchEngine.length == 0){402 getSearchEngine(function(data){403 if(data){404 config.allSearchEngine = data;405 }406 });407 }408 $(config.allSearchEngine).each(function(i,item){409 if(item.id == engineid){410 n = item.name;411 return false;412 }413 });414 return n;415}416//获取搜索引擎的id和名称417function getSearchEngine(callback){418 $.ajax({419 url:config.phpPath+"taskmanager.php",420 async:false,421 data:{type:"getsearchenginelist"}, 422 type:"get", 423 dataType:"json",424 success:function(data){425 if(jQuery.isFunction(callback)){426 callback(data);427 }428 }429 });430}431//根据抓取站点id获取名称432function getSearchSiteName(siteid){433 var n = '';434 if(config.allSearchSite.length == 0){435 getSearchSite(function(data){436 if(data){437 config.allSearchSite = data;438 }439 });440 }441 $(config.allSearchSite).each(function(i,item){442 if(item.id == siteid){443 n = item.name;444 return false;445 }446 });447 return n;448}449//获取搜索引擎的id和名称450function getSearchSite(callback){451 $.ajax({452 url:config.phpPath+"taskmanager.php",453 async:false,454 data:{type:"getsearchsitelist"}, 455 type:"get", 456 dataType:"json",457 success:function(data){458 if(jQuery.isFunction(callback)){459 callback(data);460 }461 }462 });463}464*/465//获取用户类型的描述466function getUserTypeText(usertype){467 if(undefined == usertype || null == usertype ){468 return "全部";469 }470 else{471 return parseInt(usertype,10) == 1 ? "种子用户" : "普通用户";472 }473}474function _getintvalue(v){475 return (v == undefined || v == null) ? 0 : v;476}477function getTaskDetail(task){478 var v = task;479 if(v.taskparams.scene == undefined){480 v.taskparams.scene = {};481 }482 var infohtm = '';483 var ld = v.local == 1 ? "是":"否";484 infohtm += "本地:"+ld+"<br/>";485 var rd = v.remote == 1 ? "是":"否";486 infohtm += "远程:"+rd+"<br/>";487 var cdelay = v.conflictdelay == null ? "未设置" : v.conflictdelay+"秒";488 infohtm += "冲突延迟:"+cdelay+"<br/>";489 infohtm += "<hr>";490 /*491 //定时计划492 if(task.crontime != undefined){493 infohtm +="定时计划:"+getCrontimeDes(v.crontime)+"<br/>";494 }495 */496 var task_term = '';497 var exeinfo = "";498 var comitstr = "";499 if(v.taskparams.iscommit){500 comitstr += "立即更新"; 501 }502 else{503 comitstr += "完成时提交";504 }505 exeinfo +="处理方式:";506 if(v.taskparams.each_count){507 exeinfo +="每次提交"+v.taskparams.each_count+"条,"508 }509 exeinfo +=comitstr+"<br/>";510 //显示分词方案 用户配置则显示511 if(task.taskparams.dictionaryPlan != undefined){512 var data1=JSON.parse(task.taskparams.dictionaryPlan);513 var planHtml="";514 var count=1;515 $.each(data1,function(di, itemPlan){516 planHtml +="方案"+count+":(";517 var t2="";518 var count2=0;519 if(itemPlan!=undefined&&itemPlan.length==0){520 if(count2!=0)521 t2=t2+","+"默认方案";522 else523 t2="默认方案";524 count2++;525 }526 else{527 $.each(itemPlan, function (dj, itemCategory) {528 if(count2!=0)529 t2=t2+","+itemCategory.name;530 else531 t2=itemCategory.name;532 count2++;533 });534 }535 planHtml+=t2+")";536 count++;537 });538 infohtm += "分词方案:"+planHtml+"<br/>";539 }540 541 //542 if(task.task == config.TASK_REPOST_TREND){//分析转发脚本543 544 infohtm += exeinfo;545 var seedweibo = "";546 /*if(task.taskparams.orimid != undefined && task.taskparams.orimid.length > 0){547 seedweibo = task.taskparams.orimid.join("<br/>");548 infohtm += "种子微博(URL):<br/>"+seedweibo+"<br/>";549 }*/550 if(task.taskparams.forceupdate != undefined){551 infohtm += "强制抓取:"+(v.taskparams.forceupdate ? "是" : "否")+"<br/>";552 }553 if(task.taskparams.oristatus != undefined && task.taskparams.oristatus.length > 0){554 seedweibo = task.taskparams.oristatus.join("<br/>");555 infohtm += "种子微博("+task.taskparams.oristatus.length.toString()+"条):<br/>"+seedweibo+"<br/>";556 }557 if(task.taskparams.isseed != undefined){558 infohtm += "原创是否种子:"+(task.taskparams.isseed ? "是" : "否")+"<br/>";559 }560 if(task.taskparams.isrepostseed!= undefined){561 infohtm += "转发是否种子:"+(v.taskparams.isrepostseed ? "是" : "否")+"<br/>";562 }563 if(task.taskparams.iscalctrend!= undefined){564 infohtm += "是否计算轨迹:"+(task.taskparams.iscalctrend ? "是" : "否")+"<br/>";565 }566 if(task.taskparams.config != undefined){567 infohtm += "抓取配置:"+getSpiderConfigName(task.taskparams.config)+"<br/>";568 }569 if(task.taskparams.source != undefined){570 var sn = getSourceName(task.taskparams.source);571 var sourcename = sn;572 if(!sourcename){573 sourcename = task.taskparams.source;574 }575 infohtm += "数据来源:"+sourcename+"<br/>";576 }577 if(task.taskparams.accountid != undefined){578 var accountname = [];579 $.each(task.taskparams.accountid, function(i, item){580 var sn = getSpiderAccountName(task.taskparams.source, item);581 accountname.push(sn); 582 })583 infohtm += "抓取帐号:"+accountname.join(", ")+"<br/>";584 }585 if(task.taskparams.logoutfirst != undefined){586 infohtm += "任务开始前退出当前登录账号:"+(task.taskparams.logoutfirst ? "是" : "否")+"<br/>";587 }588 if(task.taskparams.duration != undefined){589 infohtm += "任务超时:"+task.taskparams.duration+"秒<br/>";590 }591 if("nodup" in task){592 infohtm += "允许重复任务:"+(task.nodup ? "是" : "否")+"<br/>";593 }594 /*if(task.taskparams.oristatus != undefined && task.taskparams.oristatus.length > 0){595 seedweibo += "ID: "+task.taskparams.oristatus.toString();596 }597 if(task.taskparams.orimid != undefined && task.taskparams.orimid.length > 0){598 seedweibo += " MID: "+task.taskparams.orimid.toString();599 }*/600 if(task.local == 1){601 if(task.taskparams.currorigurl){602 infohtm += "正在处理:"+task.taskparams.currorigurl+"<br/>";603 }604 var apicount = _getintvalue(task.taskparams.scene.repost_timeline_count) + _getintvalue(task.taskparams.scene.repost_timeline_ids_count) + _getintvalue(task.taskparams.scene.statuses_count_count);605 infohtm += "<b>统计条数:</b>总访问API次数"+apicount+",包括:repost_timeline:"+_getintvalue(task.taskparams.scene.repost_timeline_count)+", repost_timeline_ids:"+_getintvalue(task.taskparams.scene.repost_timeline_ids_count)+",statuses_count:"+_getintvalue(task.taskparams.scene.statuses_count_count);606 infohtm += "共出错"+_getintvalue(task.taskparams.scene.apierrorcount)+"次。 总抓取"+_getintvalue(task.taskparams.scene.spider_statuscount)+"条,被删除"+_getintvalue(task.taskparams.scene.deleted_weibocount)+"条,入库"+_getintvalue(task.taskparams.scene.insertsql_statuscount)+"条, 新增到solr失败"+_getintvalue(task.taskparams.scene.solrerrorcount)+"条,总新增用户"+_getintvalue(task.taskparams.scene.spider_usercount)+"个,更新solr总转发、总到达出错"+_getintvalue(task.taskparams.scene.calc_solrerrorcount)+"次<br/>";607 var get_seedweibo_time = _getintvalue(task.taskparams.scene.get_seedweibo_time);608 infohtm += "<b>获取种子微博总花费</b>"+get_seedweibo_time+",当前种子微博总转发数"+_getintvalue(task.taskparams.scene.current_seedweibo_reposts_count)+"<br/>";609 var get_origrepost_time = _getintvalue(task.taskparams.scene.get_origrepost_time);610 var repost_timeline_count = _getintvalue(task.taskparams.scene.repost_timeline_count);611 var repost_timeline_time = _getintvalue(task.taskparams.scene.repost_timeline_time);612 var analysistime = _getintvalue(task.taskparams.scene.analysistime);613 var storetime = _getintvalue(task.taskparams.scene.storetime);614 var insertsql_statustime = _getintvalue(task.taskparams.scene.insertsql_statustime);615 var insertsql_usertime = _getintvalue(task.taskparams.scene.insertsql_usertime);616 infohtm += "<b>抓取原创的转发总花费</b>"+get_origrepost_time+"。包括:访问API "+repost_timeline_count+" 次花费"+repost_timeline_time+",分析花费"+analysistime+",存储到solr花费"+storetime+",插入数据库花费"+insertsql_statustime+",插入用户花费"+insertsql_usertime+"<br/>";617 var set_repost_father_time = _getintvalue(task.taskparams.scene.set_repost_father_time);618 infohtm += "<b>分析父ID总花费</b>"+set_repost_father_time+",有二级转发的微博总数"+_getintvalue(task.taskparams.scene.all_secrepost_count)+"。包括:查询转发"+_getintvalue(task.taskparams.scene.select_repost_sqlcount)+"次(共"+_getintvalue(task.taskparams.scene.select_repost_count)+"条)花费"+_getintvalue(task.taskparams.scene.select_repost_time)+",";619 infohtm += "检查已存在的孩子数"+_getintvalue(task.taskparams.scene.check_repost_count)+"次花费"+_getintvalue(task.taskparams.scene.check_repost_time)+",访问API "+_getintvalue(task.taskparams.scene.repost_timeline_ids_count)+" 次花费"+_getintvalue(task.taskparams.scene.repost_timeline_ids_time)+",";620 infohtm += "更新fatherid、转发层级"+_getintvalue(task.taskparams.complete_repost_count)+"次花费"+_getintvalue(task.taskparams.scene.update_fatherid_time)+",更新内存数据中的转发层级"+_getintvalue(task.taskparams.scene.update_memory_count)+"次花费"+_getintvalue(task.taskparams.scene.update_memory_time)+"<br/>";621 var update_taskids_time = _getintvalue(task.taskparams.scene.update_taskids_time);622 infohtm += "<b>更新抓取进度状态(共"+_getintvalue(task.taskparams.scene.update_taskids_count)+"条)花费</b>"+update_taskids_time+"<br/>";623 var set_total_counts_time = _getintvalue(task.taskparams.scene.set_total_counts_time);624 infohtm += "<b>计算总转发数、总到达数并更新到solr总花费</b>"+set_total_counts_time+"。包括:查询转发"+_getintvalue(task.taskparams.scene.calc_select_repost_count)+"次花费"+_getintvalue(task.taskparams.scene.calc_select_repost_time)+",计算转发数"+_getintvalue(task.taskparams.scene.calc_counts_count)+"次花费"+_getintvalue(task.taskparams.scene.calc_counts_time)+",更新数据库"+_getintvalue(task.taskparams.scene.calc_updatecounts_count)+"次花费"+_getintvalue(task.taskparams.scene.calc_updatecounts_time)+",更新到solr"+_getintvalue(task.taskparams.scene.calc_select_repost_count)+"次(共"+_getintvalue(task.taskparams.scene.calc_updatesolr_count)+"条)花费"+_getintvalue(task.taskparams.scene.calc_updatesolr_time)+"<br/>";625 var all_time = get_seedweibo_time + get_origrepost_time + set_repost_father_time + update_taskids_time + set_total_counts_time;626 infohtm += "<b>总计</b>:总处理原创"+_getintvalue(task.taskparams.select_cursor)+"条,总处理转发"+_getintvalue(task.taskparams.complete_repost_count)+"条,当前正在处理的转发位置"+_getintvalue(task.taskparams.select_repost_cursor)+",总时间:"+all_time+"。";627 var fatalcount = _getintvalue(task.taskparams.scene.fatalcount);628 var manual_shutdowncount = _getintvalue(task.taskparams.scene.manual_shutdowncount);629 var queuecount = _getintvalue(task.taskparams.scene.queuecount);630 var allshutdown = fatalcount + manual_shutdowncount + queuecount;631 infohtm += "共停止"+allshutdown+"次,其中任务崩溃"+fatalcount+"次,人工停止"+manual_shutdowncount+"次,由于等待资源停止"+queuecount+"次,挂起"+_getintvalue(task.taskparams.scene.hangcount)+"次, 等待时间"+_getintvalue(task.taskparams.scene.waittime)+"<br/>";632 if(task.taskparams.scene.hangstate != undefined && task.taskparams.scene.hangstate != 0){633 var hangreason = task.taskparams.scene.hangreason == undefined ? "" : task.taskparams.scene.hangreason;634 infohtm += "任务挂起,原因:" + hangreason+"<br/>";635 }636 if(task.taskparams.scene.status_desp != undefined && task.taskparams.scene.status_desp != ""){637 infohtm += "任务状态描述:"+task.taskparams.scene.status_desp;638 }639 }640 else{641 if(task.taskparams.phase == 1){642 infohtm += "任务阶段:抓取原创转发<br/>";643 infohtm += "任务进度:已处理原创"+task.taskparams.select_cursor+"条";644 if(task.taskparams.currorigurl){645 infohtm += ",正在处理:"+task.taskparams.currorigurl;646 }647 if(task.taskparams.repost != undefined && task.taskparams.repost.length > 0){648 if(task.taskparams.select_cursor < task.taskparams.oristatus.length){649 var origprogress = task.taskparams.repost[task.taskparams.repost.length - 1].idnum;650 infohtm += ",已抓取当前原创转发"+origprogress+"条";651 }652 }653 infohtm += "<br/>";654 }655 else if(task.taskparams.phase == 2){656 infohtm += "任务阶段:抓取二级转发<br/>";657 infohtm += "任务进度:共有二级转发"+task.taskparams.repostcount+"条,已处理二级转发"+task.taskparams.repostdone+"条<br/>";658 }659 if(task.taskparams.repost != undefined){660 infohtm += "<b>转发数列表:</b><br/>";661 for(var i = 0; i < task.taskparams.repost.length; i++){662 infohtm += "原创:"+task.taskparams.repost[i].orig+",转发"+task.taskparams.repost[i].idnum+"条<br/>";663 }664 }665 if(task.taskparams.scene.stat != undefined){666 infohtm += "<b>任务统计信息:</b><br/>";667 infohtm += printStat(task.taskparams.scene.stat);668 }669 if(task.taskparams.scene.dropcount != undefined){670 infohtm += "放弃次数:"+task.taskparams.scene.dropcount+"<br/>";671 }672 }673 }674 else if(task.task == config.TASK_REPOSTPATH || task.task == config.TASK_COMMENTPATH){675 infohtm += exeinfo;676 if(task.taskparams.oriurls != undefined && task.taskparams.oriurls.length > 0){677 var seedweibo = task.taskparams.oriurls.join("<br/>");678 infohtm += "源链接("+task.taskparams.oriurls.length.toString()+"条):<br/>"+seedweibo+"<br/>";679 }680 if(task.taskparams.errorurl != undefined && task.taskparams.errorurl.length > 0){681 infohtm += "出错链接("+task.taskparams.errorurl.length.toString()+"条):<br/>";682 $.each(task.taskparams.errorurl, function(ei, eitem){683 infohtm += "链接:"+eitem.url+" 原因:"+eitem.msg+"<br/>";684 });685 }686 }687 else if(task.task == config.TASK_COMMENTS){//抓取评论688 infohtm += exeinfo;689 if(task.taskparams.forceupdate != undefined){690 infohtm += "强制抓取:"+(v.taskparams.forceupdate ? "是" : "否")+"<br/>";691 }692 if(task.taskparams.oristatus != undefined && task.taskparams.oristatus.length > 0){693 var seedweibo = task.taskparams.oristatus.join("<br/>");694 infohtm += "种子微博("+task.taskparams.oristatus.length.toString()+"条):<br/>"+seedweibo+"<br/>";695 }696 if(task.taskparams.isseed != undefined){697 infohtm += "是否种子:"+(task.taskparams.isseed ? "是" : "否")+"<br/>";698 }699 if(task.taskparams.config != undefined){700 infohtm += "抓取配置:"+getSpiderConfigName(task.taskparams.config)+"<br/>";701 }702 if(task.taskparams.source != undefined){703 var sn = getSourceName(task.taskparams.source);704 var sourcename = sn;705 if(!sourcename){706 sourcename = task.taskparams.source;707 }708 infohtm += "数据来源:"+sourcename+"<br/>";709 }710 if(task.taskparams.accountid != undefined){711 var accountname = [];712 $.each(task.taskparams.accountid, function(i, item){713 var sn = getSpiderAccountName(task.taskparams.source, item);714 accountname.push(sn); 715 })716 infohtm += "抓取帐号:"+accountname.join(", ")+"<br/>";717 }718 if(task.taskparams.logoutfirst != undefined){719 infohtm += "任务开始前退出当前登录账号:"+(task.taskparams.logoutfirst ? "是" : "否")+"<br/>";720 }721 if(task.taskparams.duration != undefined){722 infohtm += "任务超时:"+task.taskparams.duration+"秒<br/>";723 }724 if("nodup" in task){725 infohtm += "允许重复任务:"+(task.nodup ? "是" : "否")+"<br/>";726 }727 if(task.taskparams.iscalctrend!= undefined){728 infohtm += "是否计算轨迹:"+(task.taskparams.iscalctrend ? "是" : "否")+"<br/>";729 }730 if(task.local == 1){731 if(task.taskparams.currorigurl){732 infohtm += "正在处理:"+task.taskparams.currorigurl+"<br/>";733 }734 infohtm += "<b>统计条数:</b>已处理原创"+_getintvalue(task.taskparams.select_cursor)+"条,总抓取"+_getintvalue(task.taskparams.scene.spider_statuscount)+"条,入库"+_getintvalue(task.taskparams.scene.new_comments_count)+"条,新增用户"+_getintvalue(task.taskparams.scene.new_user_count)+"个。API共出错"+_getintvalue(task.taskparams.scene.apierrorcount)+"次,新增到solr失败"+_getintvalue(task.taskparams.scene.solrerrorcount)+"条,更新回复数失败"+_getintvalue(task.taskparams.scene.calc_solrerrorcount)+"条<br/>";735 infohtm += "<b>统计时间:</b>获取种子微博总花费"+_getintvalue(task.taskparams.scene.get_seedweibo_time)+",获取评论总花费"+_getintvalue(task.taskparams.scene.get_comments_time)+",入库总花费"+_getintvalue(task.taskparams.scene.insert_comments_time)+",更新回复数总花费"+_getintvalue(task.taskparams.scene.calc_comments_time)+"<br/>";736 if(task.taskparams.scene.status_desp != undefined && task.taskparams.scene.status_desp != ""){737 infohtm += "任务状态描述:"+task.taskparams.scene.status_desp;738 }739 }740 else{741 infohtm += "任务进度:已处理微博"+(task.taskparams.select_cursor ? task.taskparams.select_cursor : 0)+"条";742 if(task.taskparams.currorigurl){743 infohtm += ",正在处理:"+task.taskparams.currorigurl;744 }745 if(task.taskparams.comment != undefined && task.taskparams.comment.length > 0){746 if(task.taskparams.select_cursor < task.taskparams.oristatus.length){747 var origprogress = task.taskparams.comment[task.taskparams.comment.length - 1].idnum;748 infohtm += ",已抓取当前微博评论"+origprogress+"条";749 }750 }751 infohtm += "<br/>";752 if(task.taskparams.comment != undefined){753 infohtm += "<b>评论数列表:</b><br/>";754 for(var i = 0; i < task.taskparams.comment.length; i++){755 infohtm += "微博:"+task.taskparams.comment[i].orig+",评论"+task.taskparams.comment[i].idnum+"条<br/>";756 }757 }758 if(task.taskparams.scene.stat != undefined){759 infohtm += "<b>任务统计信息:</b><br/>";760 infohtm += printStat(task.taskparams.scene.stat);761 }762 if(task.taskparams.scene.dropcount != undefined){763 infohtm += "放弃次数:"+task.taskparams.scene.dropcount+"<br/>";764 }765 }766 }767 else if(task.task == config.TASK_KEYWORD){//抓取关键词768 infohtm += "抓取配置:"+getSpiderConfigName(task.taskparams.config)+"<br/>";769 if(task.taskparams.source != undefined){770 var sn = getSourceName(task.taskparams.source);771 var sourcename = sn;772 if(!sourcename){773 sourcename = task.taskparams.source;774 }775 infohtm += "数据来源:"+sourcename+"<br/>";776 }777 if(task.taskparams.accountid != undefined){778 var accountname = [];779 $.each(task.taskparams.accountid, function(i, item){780 var sn = getSpiderAccountName(task.taskparams.source, item);781 accountname.push(sn); 782 })783 infohtm += "抓取帐号:"+accountname.join(", ")+"<br/>";784 }785 if(task.taskparams.logoutfirst != undefined){786 infohtm += "任务开始前退出当前登录账号:"+(task.taskparams.logoutfirst ? "是" : "否")+"<br/>";787 }788 if(task.taskparams.isswitch != undefined){789 infohtm += "是否切换帐号:"+(task.taskparams.isswitch ? "是" : "否")+"<br/>";790 if(task.taskparams.isswitch){791 infohtm += "帐号切换策略:"+task.taskparams.switchpage+"页/"+task.taskparams.switchtime+"秒<br/>";792 }793 if(parseInt(task.taskparams.globalaccount,10)){794 infohtm += "使用全局帐号:"+(task.taskparams.isswitch ? "是" : "否")+"<br/>";795 }796 }797 if(task.taskparams.keywords != undefined){798 infohtm += "关键词:"+task.taskparams.keywords+"<br/>";799 }800 if(task.taskparams.username != undefined){801 infohtm += "用户昵称:"+task.taskparams.username+"<br/>";802 }803 infohtm += "是否种子:"+(task.taskparams.isseed ? "是" : "否")+"<br/>";804 if(task.taskparams.filterdup != undefined){805 infohtm += "去除重复:"+(task.taskparams.filterdup ? "是" : "否")+"<br/>";806 }807 if(task.taskparams.starttime != undefined){808 infohtm += "开始时间:"+timeToStr(task.taskparams.starttime)+"<br/>";809 }810 if(task.taskparams.endtime != undefined){811 infohtm += "结束时间:"+timeToStr(task.taskparams.endtime)+"<br/>";812 }813 if(task.relativestart!= undefined){814 var ttrs = task.relativestart;815 var rsstr = "";816 if(ttrs == "now"){817 rsstr = "创建时间";818 }819 else{820 var rs = task.relativestart.split(" ");821 var num = parseFloat(rs[0]);822 var gap = getGaptext(rs[1]);823 if(num > 0){824 rsstr = "后"+num+gap;825 }826 else{827 var tnum = -num;828 rsstr = "前"+tnum+gap;829 }830 }831 infohtm += "相对开始时间:"+rsstr+"<br/>";832 }833 if(task.relativeend != undefined){834 var ttre = task.relativeend;835 var restr = "";836 if(ttre == "now"){837 restr = "创建时间";838 }839 else{840 var rs = task.relativeend.split(" ");841 var num = parseFloat(rs[0]);842 var gap = getGaptext(rs[1]);843 if(num > 0){844 restr = "后"+num+gap;845 }846 else{847 var tnum = -num;848 restr = "前"+tnum+gap;849 }850 }851 infohtm += "相对结束时间:"+restr+"<br/>";852 }853 if(task.taskparams.step != undefined && task.taskparams.step.length > 0){854 infohtm += "步长:"+parseInt(task.taskparams.step, 10)+(task.taskparams.step.indexOf("h") > 0 ? "小时" : "天")+"<br/>";855 }856 infohtm += "任务超时:"+task.taskparams.duration+"秒<br/>";857 if("nodup" in task){858 infohtm += "允许重复任务:"+(task.nodup ? "是" : "否")+"<br/>";859 }860 if(task.taskparams.scene.dropcount != undefined){861 infohtm += "放弃次数:"+task.taskparams.scene.dropcount+"<br/>";862 }863 if(task.taskparams.scene.stat != undefined){864 infohtm += printStat(task.taskparams.scene.stat);865 }866 }867 else if(task.task == config.TASK_WEBPAGE){//论坛868 if(task.taskparams.searchengine != undefined){869 infohtm += "搜索引擎:"+getSearchEngineName(task.taskparams.searchengine)+"<br/>";870 }871 if(task.taskparams.crawlpage){872 infohtm += "抓取页数:"+task.taskparams.crawlpage+"<br/>";873 }874 if(task.taskparams.createdtimestart != undefined){875 infohtm += "主帖发表时间开始:"+timeToStr(task.taskparams.createdtimestart)+"<br/>";876 }877 if(task.taskparams.createdtimeend != undefined){878 infohtm += "主帖发表时间结束:"+timeToStr(task.taskparams.createdtimeend)+"<br/>";879 }880 if(task.taskparams.searchsite != undefined){881 infohtm += "抓取站点:"+getSearchSiteName(task.taskparams.searchsite)+"<br/>";882 }883 if(task.taskparams.source != undefined){884 var sn = getSourceName(task.taskparams.source);885 var sourcename = sn;886 if(!sourcename){887 sourcename = task.taskparams.source;888 }889 infohtm += "数据来源:"+sourcename+"<br/>";890 }891 if(task.taskparams.listurls){892 var u = task.taskparams.listurls;893 if(isArray(u)){894 var urlstr = "";895 $.each(u, function(ui, uitem){896 urlstr += "http:"+uitem.url+"<br/>";897 });898 infohtm += "抓取列表URL:"+urlstr+"<br/>";899 }900 else{901 u = u.toString().replace(/</g, "&lt;");902 u = u.toString().replace(/>/g, "&gt;");903 infohtm += "抓取列表URL:"+u+"<br/>";904 }905 }906 if(task.taskparams.texturls){907 var u = task.taskparams.texturls;908 if(isArray(u)){909 var urlstr = "";910 /*911 $.each(u, function(ui, uitem){912 urlstr += "http:"+uitem.url+"<br/>";913 });914 */915 infohtm += "抓取文章详情URL:"+urlstr+"<br/>";916 }917 else{918 u = u.toString().replace(/</g, "&lt;");919 u = u.toString().replace(/>/g, "&gt;");920 infohtm += "抓取文章详情URL:"+u+"<br/>";921 }922 }923 if(task.taskparams.importarticlecount){924 infohtm += "每个任务包含源文章数:"+task.taskparams.importarticlecount+"<br/>";925 }926 if(task.taskparams.lastrplytimestart != undefined){927 infohtm += "文章发表时间开始:"+timeToStr(task.taskparams.lastrplytimestart)+"<br/>";928 }929 if(task.taskparams.lastrplytimeend != undefined){930 infohtm += "文章发表时间结束:"+timeToStr(task.taskparams.lastrplytimeend)+"<br/>";931 }932 if(task.taskparams.userurls){933 var u = task.taskparams.userurls;934 if(isArray(u)){935 var urlstr = "";936 $.each(u, function(ui, uitem){937 urlstr += "http:"+uitem.url+"<br/>";938 });939 infohtm += "抓取用户URL:"+urlstr+"<br/>";940 }941 else{942 u = u.toString().replace(/</g, "&lt;");943 u = u.toString().replace(/>/g, "&gt;");944 infohtm += "抓取用户URL:"+u+"<br/>";945 }946 }947 if(task.taskparams.importusercount){948 infohtm += "每个任务包含用户数:"+task.taskparams.importusercount+"<br/>";949 }950 if(task.taskparams.userids){951 var userids = task.taskparams.userids;952 if(isArray(userids)){953 infohtm += "抓取用户id:"+userids.join(",")+"<br/>";954 }955 }956 if(task.taskparams.logoutfirst != undefined){957 infohtm += "任务开始前退出当前登录账号:"+(task.taskparams.logoutfirst ? "是" : "否")+"<br/>";958 }959 if(task.taskparams.iscalctrend!= undefined){960 infohtm += "是否计算轨迹:"+(task.taskparams.iscalctrend ? "是" : "否")+"<br/>";961 }962 if(task.taskparams.accountid != undefined){963 var accountname = [];964 $.each(task.taskparams.accountid, function(i, item){965 var sn = getSpiderAccountName(task.taskparams.source, item);966 accountname.push(sn); 967 })968 infohtm += "抓取帐号:"+accountname.join(", ")+"<br/>";969 }970 if(task.taskparams.isswitch != undefined){971 infohtm += "是否切换帐号:"+(task.taskparams.isswitch ? "是" : "否")+"<br/>";972 if(task.taskparams.isswitch){973 infohtm += "帐号切换策略:"+task.taskparams.switchpage+"页/"+task.taskparams.switchtime+"秒<br/>";974 }975 if(parseInt(task.taskparams.globalaccount,10)){976 infohtm += "使用全局帐号:"+(task.taskparams.isswitch ? "是" : "否")+"<br/>";977 }978 }979 if(task.taskparams.keywords != undefined){980 infohtm += "关键词:"+task.taskparams.keywords+"<br/>";981 }982 if(task.taskparams.username != undefined){983 infohtm += "用户昵称:"+task.taskparams.username+"<br/>";984 }985 if(task.taskparams.filterdup != undefined){986 infohtm += "去除重复:"+(task.taskparams.filterdup ? "是" : "否")+"<br/>";987 }988 if(task.taskparams.starttime != undefined){989 infohtm += "开始时间:"+timeToStr(task.taskparams.starttime)+"<br/>";990 }991 if(task.taskparams.endtime != undefined){992 infohtm += "结束时间:"+timeToStr(task.taskparams.endtime)+"<br/>";993 }994 if(task.relativestart!= undefined){995 var ttrs = task.relativestart;996 var rsstr = "";997 if(ttrs == "now"){998 rsstr = "创建时间";999 }1000 else{1001 var rs = task.relativestart.split(" ");1002 var num = parseFloat(rs[0]);1003 var gap = getGaptext(rs[1]);1004 if(num > 0){1005 rsstr = "后"+num+gap;1006 }1007 else{1008 var tnum = -num;1009 rsstr = "前"+tnum+gap;1010 }1011 }1012 infohtm += "相对开始时间:"+rsstr+"<br/>";1013 }1014 if(task.relativeend != undefined){1015 var ttre = task.relativeend;1016 var restr = "";1017 if(ttre == "now"){1018 restr = "创建时间";1019 }1020 else{1021 var rs = task.relativeend.split(" ");1022 var num = parseFloat(rs[0]);1023 var gap = getGaptext(rs[1]);1024 if(num > 0){1025 restr = "后"+num+gap;1026 }1027 else{1028 var tnum = -num;1029 restr = "前"+tnum+gap;1030 }1031 }1032 infohtm += "相对结束时间:"+restr+"<br/>";1033 }1034 if(task.taskparams.step != undefined && task.taskparams.step.length > 0){1035 infohtm += "步长:"+parseInt(task.taskparams.step, 10)+(task.taskparams.step.indexOf("h") > 0 ? "小时" : "天")+"<br/>";1036 }1037 infohtm += "任务超时:"+task.taskparams.duration+"秒<br/>";1038 if("nodup" in task){1039 infohtm += "允许重复任务:"+(task.nodup ? "是" : "否")+"<br/>";1040 }1041 if(task.taskparams.scene.dropcount != undefined){1042 infohtm += "放弃次数:"+task.taskparams.scene.dropcount+"<br/>";1043 }1044 if(task.taskparams.scene.stat != undefined){1045 infohtm += printStat(task.taskparams.scene.stat);1046 }1047 }1048 else if(task.task == config.TASK_FRIEND){//抓取关注1049 infohtm += "抓取配置:"+getSpiderConfigName(task.taskparams.config)+"<br/>";1050 if(task.taskparams.source != undefined){1051 var sn = getSourceName(task.taskparams.source);1052 var sourcename = sn;1053 if(!sourcename){1054 sourcename = task.taskparams.source;1055 }1056 infohtm += "数据来源:"+sourcename+"<br/>";1057 }1058 if(task.taskparams.unames != undefined){1059 infohtm += "用户:"+task.taskparams.unames+"<br/>";1060 }1061 else{1062 infohtm += "用户ID:"+task.taskparams.uids+"<br/>";1063 }1064 infohtm += "是否种子:"+(task.taskparams.isseed ? "是" : "否")+"<br/>";1065 infohtm += "任务超时:"+task.taskparams.duration+"秒<br/>";1066 if("nodup" in task){1067 infohtm += "允许重复任务:"+(task.nodup ? "是" : "否")+"<br/>";1068 }1069 if(task.taskparams.scene.dropcount != undefined){1070 infohtm += "放弃次数:"+task.taskparams.scene.dropcount+"<br/>";1071 }1072 if(task.taskparams.scene.stat != undefined){1073 infohtm += printStat(task.taskparams.scene.stat);1074 }1075 }1076 else if(task.task == config.TASK_MIGRATEDATA){//迁移数据1077 infohtm += "<b>配置信息</b><br/>";1078 infohtm += "源主机:"+getHostName(task.taskparams.srchost)+"<br/>";1079 var dsthosts = [];1080 if(task.taskparams.dsthost != undefined){1081 for(var i = 0; i < task.taskparams.dsthost.length; i++){1082 dsthosts.push(getHostName(task.taskparams.dsthost[i]));1083 }1084 infohtm += "目标主机:"+dsthosts.join(",")+"<br/>";1085 }1086 infohtm += "最大处理条数:";1087 if(task.taskparams.maxcount != undefined){1088 infohtm += task.taskparams.maxcount+"<br/>";1089 }1090 else{1091 infohtm += "全部<br/>";1092 }1093 if(task.taskparams.eachcount != undefined){1094 infohtm += "每次处理条数:"+task.taskparams.eachcount+"<br/>";1095 }1096 if(task.taskparams.keepsrc != undefined){1097 infohtm += "保留源数据:"+(task.taskparams.keepsrc ? "是" : "否")+"<br/>";1098 }1099 if(task.taskparams.delseedweibo != undefined){1100 infohtm += "删除种子微博:"+(task.taskparams.delseedweibo ? "是" : "否")+"<br/>";1101 }1102 if(task.taskparams.deluser != undefined){1103 infohtm += "删除用户:"+(task.taskparams.deluser ? "是" : "否")+"<br/>";1104 }1105 if(task.taskparams.delseeduser != undefined){1106 infohtm += "删除种子用户:"+(task.taskparams.delseeduser ? "是" : "否")+"<br/>";1107 }1108 if(task.taskparams.source != undefined){1109 var sn = getSourceName(task.taskparams.source);1110 var sourcename = sn;1111 if(!sourcename){1112 sourcename = task.taskparams.source;1113 }1114 infohtm += "数据来源:"+sourcename+"<br/>";1115 }1116 if(task.taskparams.cond_ge_created != undefined){1117 infohtm += "最小创建时间:"+timeToStr(task.taskparams.cond_ge_created)+"<br/>";1118 }1119 if(task.taskparams.cond_lt_created != undefined){1120 infohtm += "最大创建时间:"+timeToStr(task.taskparams.cond_lt_created)+"<br/>";1121 }1122 if(task.taskparams.cond_ex_text != undefined){1123 infohtm += "排除关键词:"+task.taskparams.cond_ex_text+"<br/>";1124 }1125 if(task.taskparams.cond_in_text != undefined){1126 infohtm += "包含关键词:"+task.taskparams.cond_in_text+"<br/>";1127 }1128 if(task.taskparams.cond_ex_name != undefined){1129 infohtm += "排除用户昵称:"+task.taskparams.cond_ex_name+"<br/>";1130 }1131 if(task.taskparams.cond_in_name != undefined){1132 infohtm += "包含用户昵称:"+task.taskparams.cond_in_name+"<br/>";1133 }1134 if("nodup" in task){1135 infohtm += "允许重复任务:"+(task.nodup ? "是" : "否")+"<br/>";1136 }1137 infohtm += "<b>统计信息</b><br/>";1138 if(!task.taskparams.keepsrc){1139 if(task.taskparams.select_cursor != undefined){1140 infohtm += "<span style='color:red;'>保留文章数:</span>"+task.taskparams.select_cursor+"<br/>";1141 }1142 }1143 if(task.taskparams.scene.delete_status_count != undefined){1144 infohtm += "删除文章数:"+task.taskparams.scene.delete_status_count+"<br/>";1145 }1146 if(task.taskparams.scene.delete_user_count != undefined){1147 infohtm += "删除用户数:"+task.taskparams.scene.delete_user_count+"<br/>";1148 }1149 if(task.taskparams.scene.alltime != undefined){1150 infohtm += "总花费时间:"+task.taskparams.scene.alltime+"<br/>";1151 }1152 if(task.taskparams.scene.solr_time != undefined){1153 infohtm += "源solr总时间:"+task.taskparams.scene.solr_time+"<br/>";1154 }1155 if(task.taskparams.scene.solr_query_time != undefined){1156 infohtm += "源solr查询时间:"+task.taskparams.scene.solr_query_time+"<br/>";1157 }1158 if(task.taskparams.scene.solr_retrieve_time != undefined){1159 infohtm += "源solr提取时间:"+task.taskparams.scene.solr_retrieve_time+"<br/>";1160 }1161 if(task.taskparams.scene.solr_delete_time != undefined){1162 infohtm += "源solr删除时间:"+task.taskparams.scene.solr_delete_time+"<br/>";1163 }1164 if(task.taskparams.scene.db_time != undefined){1165 infohtm += "源数据库总时间:"+task.taskparams.scene.db_time+"<br/>";1166 }1167 if(task.taskparams.scene.db_query_time != undefined){1168 infohtm += "源数据库查询时间:"+task.taskparams.scene.db_query_time+"<br/>";1169 }1170 if(task.taskparams.scene.db_retrieve_time != undefined){1171 infohtm += "源数据库提取时间:"+task.taskparams.scene.db_retrieve_time+"<br/>";1172 }1173 if(task.taskparams.scene.db_delete_time != undefined){1174 infohtm += "源数据库删除时间:"+task.taskparams.scene.db_delete_time+"<br/>";1175 }1176 if(task.taskparams.scene.dst != undefined){1177 for(var i = 0; i < task.taskparams.scene.dst.length; i++){1178 infohtm += "目标主机"+dsthosts[i]+"<br/>";1179 if(task.taskparams.scene.dst[i].insert_status_count != undefined){1180 infohtm += "插入文章数:"+task.taskparams.scene.dst[i].insert_status_count+"<br/>";1181 }1182 if(task.taskparams.scene.dst[i].update_status_count != undefined){1183 infohtm += "更新文章数:"+task.taskparams.scene.dst[i].update_status_count+"<br/>";1184 }1185 if(task.taskparams.scene.dst[i].insert_user_count != undefined){1186 infohtm += "插入用户数:"+task.taskparams.scene.dst[i].insert_user_count+"<br/>";1187 }1188 if(task.taskparams.scene.dst[i].update_user_count != undefined){1189 infohtm += "更新用户数:"+task.taskparams.scene.dst[i].update_user_count+"<br/>";1190 }1191 if(task.taskparams.scene.dst[i].solr_time != undefined){1192 infohtm += "solr总时间:"+task.taskparams.scene.dst[i].solr_time+"<br/>";1193 }1194 if(task.taskparams.scene.dst[i].solr_query_time != undefined){1195 infohtm += "solr查询时间:"+task.taskparams.scene.dst[i].solr_query_time+"<br/>";1196 }1197 if(task.taskparams.scene.dst[i].solr_insert_time != undefined){1198 infohtm += "solr插入时间:"+task.taskparams.scene.dst[i].solr_insert_time+"<br/>";1199 }1200 if(task.taskparams.scene.dst[i].solr_update_time != undefined){1201 infohtm += "solr更新时间:"+task.taskparams.scene.dst[i].solr_update_time+"<br/>";1202 }1203 if(task.taskparams.scene.dst[i].db_time != undefined){1204 infohtm += "数据库总时间:"+task.taskparams.scene.dst[i].db_time+"<br/>";1205 }1206 if(task.taskparams.scene.dst[i].db_query_time != undefined){1207 infohtm += "数据库查询时间:"+task.taskparams.scene.dst[i].db_query_time+"<br/>";1208 }1209 if(task.taskparams.scene.dst[i].db_insert_time != undefined){1210 infohtm += "数据库插入时间:"+task.taskparams.scene.dst[i].db_insert_time+"<br/>";1211 }1212 if(task.taskparams.scene.dst[i].db_update_time != undefined){1213 infohtm += "数据库更新时间:"+task.taskparams.scene.dst[i].db_update_time+"<br/>";1214 }1215 }1216 }1217 }1218 else if(task.task == config.TASK_SNAPSHOT || task.task == config.TASK_EVENTALERT){//更新快照1219 infohtm += "<b>配置信息</b><br/>";1220 infohtm += "实例ID:"+task.taskparams.instanceid+"<br/>";1221 if(task.taskparams.spawntime != undefined){1222 infohtm += "更新时间:"+timeToStr(task.taskparams.spawntime)+"<br/>";1223 }1224 if(task.taskparams.history_enable != undefined){1225 infohtm += "保存历史:"+(task.taskparams.history_enable ? "是" : "否")+"<br/>";1226 }1227 if(task.taskparams.history_count != undefined){1228 infohtm += "保存历史条数:"+task.taskparams.history_count+"<br/>";1229 }1230 if(task.taskparams.history_duration != undefined){1231 infohtm += "保存历史时间:"+task.taskparams.history_duration+"秒<br/>";1232 }1233 if("nodup" in task){1234 infohtm += "允许重复任务:"+(task.nodup ? "是" : "否")+"<br/>";1235 }1236 if(task.taskparams.eventlist!= undefined){1237 if(task.taskparams.eventlist.name){1238 infohtm += "事件名称:"+task.taskparams.eventlist.name+"<br/>";1239 }1240 if(task.taskparams.eventlist.remarks){1241 infohtm += "事件描述:"+task.taskparams.eventlist.remarks+"<br/>";1242 }1243 if(task.taskparams.eventlist.alarms){1244 var alarmArr = task.taskparams.eventlist.alarms;1245 var elecondition = {}1246 /*1247 if(!elecondition){1248 var elecondition = {}1249 elecondition.firstrequestData = ritem.snapshot;1250 elecondition.dataJson = ritem.content;1251 }1252 */1253 infohtm += "预警条件:<br/>";1254 $.each(alarmArr, function(ai, aitem){1255 var tmpnum = parseInt(ai, 10) + 1;1256 infohtm += "&nbsp;&nbsp;&nbsp;&nbsp;条件"+tmpnum+":"+getLogicExpDes(aitem.trigger, elecondition)+"<br/>";1257 });1258 }1259 }1260 else{1261 infohtm += "预警条件:无<br/>";1262 }1263 if(task.taskparams.scene.userid != undefined){1264 infohtm += "<b>统计信息</b><br/>";1265 infohtm += "用户ID:"+task.taskparams.scene.userid+"<br/>";1266 }1267 if(task.taskparams.scene.reqstat != undefined){1268 infohtm += "请求数:"+task.taskparams.scene.reqstat.length+"<br/>";1269 for(var i = 0; i < task.taskparams.scene.reqstat.length; i++){1270 infohtm += "请求"+i+"元素ID:"+task.taskparams.scene.reqstat[i].elementid+",时间:"+task.taskparams.scene.reqstat[i].reqtime+"秒<br/>";1271 }1272 }1273 if(task.taskparams.scene.alltime != undefined){1274 infohtm += "总时间:"+task.taskparams.scene.alltime+"秒<br/>";1275 }1276 }1277 else{1278 if(v.taskparams.source != undefined){1279 var sn = getSourceName(v.taskparams.source);1280 var sourcename = sn;1281 if(!sourcename){1282 sourcename = task.taskparams.source;1283 }1284 task_term += sourcename;1285 }1286 else{1287 task_term += '全部';1288 }1289 if(v.task == config.TASK_IMPORTWEIBOURL){//植入微博1290 var datatype = v.taskparams.datatype ? v.taskparams.datatype : v.taskparams.urltype;1291 var _data = v.taskparams.urls ? v.taskparams.urls : v.taskparams.data;1292 if(datatype == 'comment'){1293 task_term += ' 植入评论';1294 }1295 else if(datatype == 'weibo'){1296 task_term += ' 植入微博内容';1297 }1298 else if(datatype == 'url'){1299 task_term += ' 植入微博URL';1300 }1301 else{1302 task_term += ' 植入微博ID';1303 }1304 if(v.taskparams.isseed){1305 task_term += ' 种子微博';1306 }1307 else{1308 task_term += ' 非种子微博';1309 }1310 if(v.taskparams.addreposttask){1311 task_term += ' 同时添加转发任务';1312 }1313 task_term += '<br/>数据:<br/>';1314 for(var i=0; i<_data.length; i++){1315 var rd = '';1316 if(datatype == 'id' || datatype == 'url' || datatype == 'comment'){1317 rd = typeof(_data[i]) == 'object' ? _data[i][datatype] : _data[i];1318 }1319 else{1320 continue;//微博内容不显示1321 }1322 if(i == (_data.length -1)){1323 task_term += rd;1324 }1325 else{1326 task_term += rd+', ';1327 }1328 }1329 if(task_term != ''){1330 infohtm += '参数:'+task_term + '<br/>';1331 }1332 if(v.taskparams.depend != undefined){1333 infohtm += '依赖任务:'+v.taskparams.depend + '<br/>';1334 }1335 }1336 else if(v.task == config.TASK_IMPORTUSERID){//植入用户1337 var _data = v.taskparams.urls ? v.taskparams.urls : v.taskparams.data;1338 if(v.taskparams.datatype == 'id'){1339 task_term += ' 植入用户ID';1340 }1341 else{1342 task_term += ' 植入用户昵称';1343 }1344 if(v.taskparams.isseed){1345 task_term += ' 种子用户';1346 }1347 else{1348 task_term += ' 非种子用户';1349 }1350 if(v.taskparams.getfriends){1351 task_term += ' 立即抓取关注';1352 }1353 task_term += '<br/>数据:<br/>';1354 for(var i = 0; i < v.taskparams.data.length; i++){1355 if(i == (v.taskparams.data.length -1)){1356 task_term += v.taskparams.data[i];1357 }1358 else{1359 task_term += v.taskparams.data[i]+', ';1360 }1361 }1362 if(task_term != ''){1363 infohtm += '参数:'+task_term + '<br/>';1364 }1365 }1366 else{1367 /*1368 if(v.taskparams.maxanalysistime != undefined){1369 task_term += ' 时间早于 '+timeToStr(_getintvalue(v.taskparams.maxanalysistime))+' 的数据';1370 } 1371 */1372 if(v.taskparams.users != undefined){1373 if(v.taskparams.inputtype == 'id'){1374 task_term += ' 指定用户ID: ';1375 }1376 else{1377 task_term += ' 指定用户昵称: ';1378 }1379 task_term += v.taskparams.users.toString()+' ';1380 }1381 if(v.taskparams.usertype != undefined){1382 task_term += ' 用户类型: '+getUserTypeText(v.taskparams.usertype.toString())+' ';1383 }1384 if(v.taskparams.min_follower_count != undefined){1385 task_term += ' 粉丝数大于: '+_getintvalue(v.taskparams.min_follower_count)+'的 ';1386 }1387 if(task_term != ''){1388 infohtm += '数据范围:'+task_term + '<br/>';1389 }1390 if(v.taskparams.config != undefined){1391 infohtm += "抓取配置:"+getSpiderConfigName(v.taskparams.config)+"<br/>";1392 }1393 if(v.taskparams.isseed != undefined){1394 infohtm += "是否种子:"+(v.taskparams.isseed ? "是" : "否")+"<br/>";1395 }1396 if(v.taskparams.minanalysistime!= undefined){1397 infohtm += "文章分析开始时间:"+timeToStr(v.taskparams.minanalysistime)+"<br/>";1398 }1399 if(v.taskparams.maxanalysistime != undefined){1400 infohtm += "文章分析结束时间:"+timeToStr(v.taskparams.maxanalysistime)+"<br/>";1401 }1402 if(v.taskparams.min_created_time!= undefined){1403 infohtm += "开始时间:"+timeToStr(v.taskparams.min_created_time)+"<br/>";1404 }1405 if(v.taskparams.max_created_time != undefined){1406 infohtm += "结束时间:"+timeToStr(v.taskparams.max_created_time)+"<br/>";1407 }1408 if(v.taskparams.source_host){1409 infohtm += "分析数据来源:"+v.taskparams.source_host.join(",")+"<br/>";1410 }1411 if(v.taskparams.urls){1412 var u = v.taskparams.urls;1413 if(isArray(u)){1414 var urlstr = "";1415 $.each(u, function(ui, uitem){1416 urlstr += ""+uitem+"<br/>";1417 });1418 infohtm += "分析列表URL:"+urlstr+"<br/>";1419 }1420 }1421 if(v.taskparams.starttime != undefined){1422 infohtm += "开始时间:"+timeToStr(v.taskparams.starttime)+"<br/>";1423 }1424 if(v.taskparams.endtime != undefined){1425 infohtm += "结束时间:"+timeToStr(v.taskparams.endtime)+"<br/>";1426 }1427 if(task.relativestart!= undefined){1428 var ttrs = task.relativestart;1429 var rsstr = "";1430 if(ttrs == "now"){1431 rsstr = "创建时间";1432 }1433 else{1434 var rs = task.relativestart.split(" ");1435 var num = parseFloat(rs[0]);1436 var gap = getGaptext(rs[1]);1437 if(num > 0){1438 rsstr = "后"+num+gap;1439 }1440 else{1441 var tnum = -num;1442 rsstr = "前"+tnum+gap;1443 }1444 }1445 infohtm += "相对开始时间:"+rsstr+"<br/>";1446 }1447 if(task.relativeend != undefined){1448 var ttre = task.relativeend;1449 var restr = "";1450 if(ttre == "now"){1451 restr = "创建时间";1452 }1453 else{1454 var rs = task.relativeend.split(" ");1455 var num = parseFloat(rs[0]);1456 var gap = getGaptext(rs[1]);1457 if(num > 0){1458 restr = "后"+num+gap;1459 }1460 else{1461 var tnum = -num;1462 restr = "前"+tnum+gap;1463 }1464 }1465 infohtm += "相对结束时间:"+restr+"<br/>";1466 }1467 if(task.taskparams.logoutfirst != undefined){1468 infohtm += "任务开始前退出当前登录账号:"+(task.taskparams.logoutfirst ? "是" : "否")+"<br/>";1469 }1470 if(task.taskparams.accountid != undefined){1471 var accountname = [];1472 $.each(task.taskparams.accountid, function(i, item){1473 var sn = getSpiderAccountName(task.taskparams.source, item);1474 accountname.push(sn); 1475 })1476 infohtm += "抓取帐号:"+accountname.join(", ")+"<br/>";1477 }1478 if(task.taskparams.isswitch != undefined){1479 infohtm += "是否切换帐号:"+(task.taskparams.isswitch ? "是" : "否")+"<br/>";1480 if(task.taskparams.isswitch){1481 infohtm += "帐号切换策略:"+task.taskparams.switchpage+"页/"+task.taskparams.switchtime+"秒<br/>";1482 }1483 if(parseInt(task.taskparams.globalaccount,10)){1484 infohtm += "使用全局帐号:"+(task.taskparams.isswitch ? "是" : "否")+"<br/>";1485 }1486 }1487 if(v.taskparams.step != undefined && v.taskparams.step.length > 0){1488 infohtm += "步长:"+parseInt(v.taskparams.step, 10)+(v.taskparams.step.indexOf("h") > 0 ? "小时" : "天")+"<br/>";1489 }1490 if(v.taskparams.duration != undefined){1491 infohtm += "任务超时:"+v.taskparams.duration+"秒<br/>";1492 }1493 if("nodup" in task){1494 infohtm += "允许重复任务:"+(task.nodup ? "是" : "否")+"<br/>";1495 }1496 if(v.taskparams.scene.dropcount != undefined){1497 infohtm += "放弃次数:"+v.taskparams.scene.dropcount+"<br/>";1498 }1499 if(v.taskparams.scene.stat != undefined){1500 infohtm += printStat(v.taskparams.scene.stat);1501 }1502 if(v.taskparams.scene.users_notext != undefined && v.taskparams.scene.users_notext.length > 0){1503 var darr = [];1504 $.each(v.taskparams.scene.users_notext, function(vi, vitem){1505 var n = "";1506 n+=vitem;1507 if(v.taskparams.scene.users_notexistname != undefined && v.taskparams.scene.users_notexistname.length > 0){1508 n += "("+v.taskparams.scene.users_notexistname[vi]+")"; 1509 }1510 darr.push(n); 1511 });1512 if(darr.length > 0){1513 infohtm += "不存在的用户:"+darr.join(", ")+"<br/>";1514 }1515 else{1516 infohtm += "不存在的用户:"+v.taskparams.scene.users_notext.join(", ")+"<br/>";1517 }1518 }1519 if(v.taskparams.scene.users_change_screen_name != undefined && v.taskparams.scene.users_change_screen_name.length > 0){1520 infohtm += "更改昵称的用户:"+v.taskparams.scene.users_change_screen_name.join(", ")+"<br/>";1521 }1522 if(v.taskparams.scene.users_id2name != undefined && v.taskparams.scene.users_id2name.length > 0){1523 infohtm += "用户ID昵称映射:"+v.taskparams.scene.users_id2name.join(", ")+"<br/>";1524 }1525 }1526 var func = "";1527 var tokenize_fieldname = {text:"原文内容", verified_reason:"认证原因", description:"用户简介", post_title:"帖子标题"};1528 if(v.taskparams.tokenize_fields != undefined){1529 func += "重新分析:"1530 $.each(v.taskparams.tokenize_fields,function(tfi,tf){1531 var sp = ",";1532 if(tfi == v.taskparams.tokenize_fields.length -1){1533 sp="<br/>";1534 }1535 func += tokenize_fieldname[tf]+sp;1536 });1537 }1538 var other_fieldname = {area:"用户地区", reposts_count:"转发数", direct_reposts_count:"直接转发数",total_reposts_count:"总转发数",1539 followers_count:"直接到达数",total_reach_count:"总到达数",comments_count:"评论数",time:"时间"};1540 if(v.taskparams.other_fields != undefined){1541 func += "更新:"1542 $.each(v.taskparams.other_fields,function(tfi,tf){1543 var sp = ",";1544 if(tfi == v.taskparams.other_fields.length -1){1545 sp="<br/>";1546 }1547 func += other_fieldname[tf]+sp;1548 });1549 }1550 infohtm += func;1551 infohtm += exeinfo;1552 if(v.task == config.TASK_IMPORTUSERID){1553 if(v.taskparams.scene.alltime){1554 infohtm += '总花费时间:'+_getintvalue(v.taskparams.scene.alltime)+'<br/>';1555 }1556 if(v.taskparams.scene.solr_query_time){1557 infohtm += '查询用户花费时间:'+_getintvalue(v.taskparams.scene.solr_query_time)+'<br/>';1558 }1559 if(v.taskparams.scene.solr_update_time){1560 infohtm += '更新用户花费时间:'+_getintvalue(v.taskparams.scene.solr_update_time)+'<br/>';1561 }1562 }1563 if(!v.taskparams.scene.isremote){1564 if(v.taskparams.scene.execcount != undefined){1565 infohtm += '执行次数:'+_getintvalue(v.taskparams.scene.execcount)+'<br/>';1566 }1567 if(v.taskparams.scene.analysistime != undefined){1568 infohtm += '分析文档花费时间:'+_getintvalue(v.taskparams.scene.analysistime)+'<br/>';1569 }1570 if(v.taskparams.scene.storetime != undefined){1571 infohtm += '存储文档花费时间:'+_getintvalue(v.taskparams.scene.storetime)+'<br/>';1572 }1573 if(v.taskparams.scene.sqlquerytime != undefined){1574 infohtm += '查询数据花费时间:'+_getintvalue(v.taskparams.scene.sqlquerytime)+'<br/>';1575 }1576 if(v.taskparams.scene.sqlupdatetime != undefined){1577 infohtm += '更新分析状态花费时间:'+_getintvalue(v.taskparams.scene.sqlupdatetime)+'<br/>';1578 }1579 1580 if(v.taskparams.scene.apicount_usertimeline != undefined){1581 infohtm += '访问API(user_timeline)次数:'+v.taskparams.scene.apicount_usertimeline;1582 var errorcnt = v.taskparams.scene.apierrorcount_usertimeline ? v.taskparams.scene.apierrorcount_usertimeline : 0;1583 infohtm += ', 出错数:'+_getintvalue(v.taskparams.scene.apierrorcount_usertimeline);1584 infohtm += ', 花费时间:'+_getintvalue(v.taskparams.scene.apitime_usertimeline)+'<br/>';1585 }1586 if(v.taskparams.scene.spider_statuscount != undefined){1587 infohtm += '总抓取数:'+v.taskparams.scene.spider_statuscount;1588 infohtm += ', 总入库数:'+_getintvalue(v.taskparams.scene.insertsql_statuscount);1589 infohtm += ', 入库花费时间:'+_getintvalue(v.taskparams.scene.insertsql_statustime)+'<br/>';1590 }1591 if(v.taskparams.scene.spider_usercount != undefined){1592 infohtm += '新用户数:'+v.taskparams.scene.spider_usercount;1593 infohtm += ', 入库花费时间:'+_getintvalue(v.taskparams.scene.insertsql_usertime)+'<br/>';1594 }1595 if(v.taskparams.seedusercount != undefined){1596 infohtm += '总种子用户数:'+v.taskparams.seedusercount;1597 infohtm += ', 已处理:'+_getintvalue(v.taskparams.select_user_cursor);1598 infohtm += ', 总花费时间:'+_getintvalue(v.taskparams.scene.alltime);1599 }1600 1601 if(v.taskparams.scene.databasecount != undefined){1602 var dbcount = _getintvalue(v.taskparams.scene.databasecount);1603 infohtm += '全部数据数:'+dbcount+'';1604 var allcount = _getintvalue(v.taskparams.scene.alldatacount);1605 if(allcount){1606 infohtm += ', 过滤后的原创数据数:'+allcount+'';1607 }1608 infohtm += '<br/>';1609 }1610 if(v.taskparams.scene.totalanalysiscount != undefined){1611 var tas = _getintvalue(v.taskparams.scene.totalanalysiscount); 1612 infohtm += '需分析数据数:'+tas+'';1613 infohtm += '<br/>';1614 }1615 if(v.taskparams.scene.api_queryid_count){1616 infohtm += '访问API(queryid)'+_getintvalue(v.taskparams.scene.api_queryid_count)+'次, 出错'+_getintvalue(v.taskparams.scene.api_queryid_errorcount)+', 花费'+_getintvalue(v.taskparams.scene.api_queryid_time)+'<br/>';1617 }1618 if(v.taskparams.scene.api_showuser_count){1619 infohtm += '访问API(抓取用户show_user)'+_getintvalue(v.taskparams.scene.api_showuser_count)+'次, 出错'+_getintvalue(v.taskparams.scene.api_showuser_errorcount)+', 花费'+_getintvalue(v.taskparams.scene.api_showuser_time)+'<br/>';1620 }1621 if(v.taskparams.scene.api_showstatus_count){1622 infohtm += '访问API(抓取微博show_status)'+_getintvalue(v.taskparams.scene.api_showstatus_count)+'次, 出错'+_getintvalue(v.taskparams.scene.api_showstatus_errorcount)+', 花费'+_getintvalue(v.taskparams.scene.api_showstatus_time)+'<br/>';1623 }1624 if(v.taskparams.scene.api_friends_count){1625 infohtm += '访问API(抓取关注friends)'+_getintvalue(v.taskparams.scene.api_friends_count)+'次, 出错'+_getintvalue(v.taskparams.scene.api_friends_errorcount)+', 花费'+_getintvalue(v.taskparams.scene.api_friends_time)+'<br/>';1626 }1627 }1628 var solrerrorcount = v.taskparams.scene.solrerrorcount;//总失败条数1629 if(v.task == 8){1630 var allcount = v.taskparams.urls ? v.taskparams.urls.length : v.taskparams.data.length;1631 var datatype = v.taskparams.datatype ? v.taskparams.datatype : v.taskparams.urltype;1632 var str1 = ""; 1633 if(datatype == 'comment'){1634 str1 = '接收到评论ID';1635 }1636 else if(datatype == 'weibo'){1637 str1 = '接收到微博内容';1638 }1639 else if(datatype == 'url'){1640 str1 = '接收到微博URL';1641 }1642 else{1643 str1 = '接收到微博ID';1644 }1645 var dc = _getintvalue(v.taskparams.select_cursor);1646 if(datatype == 'comment'){1647 infohtm += str1+':'+allcount+ '条, 已处理:'+dc+'. 数据库存在'+_getintvalue(v.taskparams.scene.exists_weibocount)+'条.';1648 }1649 else{1650 infohtm += str1+':'+allcount+ '条, 已处理:'+dc+'. 数据库存在'+_getintvalue(v.taskparams.scene.exists_weibocount)+'条,';1651 infohtm += ' 已更新微博'+_getintvalue(v.taskparams.scene.update_weibocount)+'条. 数据库已存在'+_getintvalue(v.taskparams.scene.userexists_count)+'个用户,';1652 infohtm += ' 新增用户'+_getintvalue(v.taskparams.scene.insert_user_count)+'个, 更新用户'+_getintvalue(v.taskparams.scene.update_user_count)+'个.';1653 }1654 }1655 else if(v.task == config.TASK_IMPORTUSERID){1656 var allcount = v.taskparams.data.length;1657 var datatype = v.taskparams.datatype;1658 var str1 = ""; 1659 if(datatype == 'id'){1660 str1 = '接收到用户ID';1661 }1662 else{1663 str1 = '接收到用户昵称';1664 }1665 var dc = _getintvalue(v.taskparams.select_cursor);1666 infohtm += str1+':'+allcount+ '条, 已处理:'+dc+'条,';1667 infohtm += ' 新增用户'+_getintvalue(v.taskparams.scene.insert_user_count)+'个, 更新用户'+_getintvalue(v.taskparams.scene.update_user_count)+'个.';1668 }1669 else if(!v.taskparams.scene.isremote){1670 var datacount = v.datastatus ? v.datastatus : 0;1671 solrerrorcount = solrerrorcount ? solrerrorcount : 0;1672 var startindex = v.taskparams.startdataindex ? v.taskparams.startdataindex : 0;1673 var endindex = v.taskparams.enddataindex ? v.taskparams.enddataindex : 0;1674 var taskinfostr = (startindex == 0 && endindex == 0) ? "全部" : "起始:"+startindex+',结束:'+endindex;1675 infohtm += '任务需要处理的:'+taskinfostr+ ', 已处理:'+datacount+', 失败数:<span style="color:red">'+solrerrorcount+'</span>';1676 }1677 if(!v.taskparams.scene.isremote){1678 var resstr = "";1679 if(v.taskparams.scene.res_ip){1680 resstr += "IP:"+v.taskparams.scene.res_ip.resource;1681 resstr += ", appkey:"+v.taskparams.scene.res_ip.appkey;1682 }1683 if(v.taskparams.scene.res_acc){1684 resstr += ", 帐号:"+v.taskparams.scene.res_acc.resource;1685 }1686 if(resstr != ""){1687 infohtm += "<br/>当前资源:"+resstr;1688 }1689 }1690 if(v.taskparams.scene.status_desp != undefined && v.taskparams.scene.status_desp != ""){1691 infohtm += "<br/>任务状态描述:"+v.taskparams.scene.status_desp;1692 }1693 if(v.taskparams.scene.error_notext_datas != undefined && v.taskparams.scene.error_notext_datas.length > 0){1694 if(v.task == 9){1695 infohtm += '<br/><span style="color:red;">用户不存在的:</span><br/>';1696 }1697 else{1698 infohtm += '<br/><span style="color:red;">微博不存在的:</span><br/>';1699 }1700 for(var i=0; i< v.taskparams.scene.error_notext_datas.length; i++){1701 var fixstr = (i == v.taskparams.scene.error_notext_datas.length-1) ? "" : ", ";1702 infohtm += v.taskparams.scene.error_notext_datas[i] + fixstr;1703 }1704 }1705 if(v.taskparams.scene.error_other_datas != undefined && v.taskparams.scene.error_other_datas.length > 0){1706 infohtm += '<br/><span style="color:red;">发生其他错误的:</span><br/>';1707 for(var i=0; i< v.taskparams.scene.error_other_datas.length; i++){1708 var fixstr = (i == v.taskparams.scene.error_other_datas.length-1) ? "" : ", ";1709 infohtm += v.taskparams.scene.error_other_datas[i] + fixstr;1710 }1711 }1712 }1713 if("scene" in task){1714 infohtm += "<br/>运行结果:";1715 if(task.scene.duplicate != undefined){1716 infohtm += "重复任务个数:"+task.scene.duplicate+", ";1717 }1718 if(task.scene.taskadded != undefined){1719 infohtm += "新增任务个数:"+task.scene.taskadded+"<br/>";1720 }1721 }1722 return infohtm;1723}1724function printStat(stat)1725{1726 var statstr = "";1727 if(stat.count != undefined){1728 statstr += "抓取条数:"+stat.count+"<br/>";1729 }1730 if(stat.child != undefined){1731 statstr += "子任务数:"+stat.child+"<br/>";1732 }1733 if(stat.time != undefined){1734 statstr += "总时间:"+stat.time+"毫秒 ";1735 }1736 if(stat.avg_time != undefined){1737 statstr += "平均时间:"+stat.avg_time+"毫秒 ";1738 }1739 if(stat.min_time != undefined){1740 statstr += "最小时间:"+stat.min_time+"毫秒 ";1741 }1742 if(stat.max_time != undefined){1743 statstr += "最大时间:"+stat.max_time+"毫秒<br/>";1744 }1745 if(stat.svr_time != undefined){1746 statstr += "服务器总时间:"+stat.svr_time+"毫秒 ";1747 }1748 if(stat.avg_svr_time != undefined){1749 statstr += "服务器平均时间:"+stat.avg_svr_time+"毫秒 ";1750 }1751 if(stat.min_svr_time != undefined){1752 statstr += "服务器最小时间:"+stat.min_svr_time+"毫秒 ";1753 }1754 if(stat.max_svr_time != undefined){1755 statstr += "服务器最大时间:"+stat.max_svr_time+"毫秒<br/>";1756 }1757 return statstr;1758}1759var tenantArr = [];1760function getTenantName(tenantid){1761 var tenantname = "";1762 if(tenantid != null){1763 var find = false;1764 $.each(tenantArr, function(ti, titem){1765 if(titem.tenantid == tenantid){1766 tenantname = titem.tenantname;1767 find = true;1768 return false;1769 }1770 });1771 if(!find){1772 $.ajax({1773 type: "GET",1774 dataType: "json",1775 async:false,1776 url: config.modelUrl+"tenant_user_model.php",1777 data: {tid:tenantid, type:"gettenantbyid"},1778 success:function(data){1779 if(data.totalcount > 0){1780 $.each(data.children, function(di, ditem){1781 tenantArr.push({tenantid:ditem.tenantid,tenantname:ditem.tenantname});1782 tenantname = ditem.tenantname;1783 });1784 }1785 else{1786 tenantArr.push({tenantid:tenantid,tenantname:""});1787 }1788 }1789 });1790 }1791 }1792 return tenantname;1793}1794var userArr = [];1795function getUserName(userid){1796 var username = "";1797 if(userid != null){1798 var find = false;1799 $.each(userArr, function(ti, titem){1800 if(titem.userid == userid){1801 username = titem.username;1802 find = true;1803 return false;1804 }1805 });1806 if(!find){1807 $.ajax({1808 type: "GET",1809 dataType: "json",1810 async:false,1811 url: config.modelUrl+"user_model.php",1812 data: {uid:userid, type:"getuserbyid"},1813 success:function(data){1814 if(data.totalcount > 0){1815 $.each(data.children, function(di, ditem){1816 userArr.push({userid:ditem.userid,username:ditem.username});1817 username = ditem.username;1818 });1819 }1820 }1821 });1822 }1823 }1824 return username;...

Full Screen

Full Screen

engine.js

Source:engine.js Github

copy

Full Screen

...61 INPUT_BASE = 16;62}63function setBaseBinary() {64 for (var i = 0; i < 32; i++) {65 text = getIntValue("#r"+i,BASE)66 n = convertBase(text,2)67 $("#r"+i).text(n+"")68 }69 text = getIntValue("#ir",BASE)70 n = convertBase(text,2)71 $("#ir").text(n+"")72 text = getIntValue("#pc",BASE)73 n = convertBase(text,2)74 $("#pc").text(n+"")75 BASE = 2;76}77function setBaseOctal() {78 for (var i = 0; i < 32; i++) {79 text = getIntValue("#r"+i,BASE)80 n = convertBase(text,8)81 $("#r"+i).text(n+"")82 }83 text = getIntValue("#ir",BASE)84 n = convertBase(text,8)85 $("#ir").text(n+"")86 text = getIntValue("#pc",BASE)87 n = convertBase(text,8)88 $("#pc").text(n+"")89 BASE = 8;90}91function setBaseDecimal() {92 for (var i = 0; i < 32; i++) {93 text = getIntValue("#r"+i,BASE)94 n = convertBase(text,10)95 $("#r"+i).text(n+"")96 }97 text = getIntValue("#ir",BASE)98 n = convertBase(text,10)99 $("#ir").text(n+"")100 text = getIntValue("#pc",BASE)101 n = convertBase(text,10)102 $("#pc").text(n+"")103 BASE = 10;104}105function setBaseHex() {106 for (var i = 0; i < 32; i++) {107 text = getIntValue("#r"+i,BASE)108 n = convertBase(text,16)109 $("#r"+i).text(n+"")110 }111 text = getIntValue("#ir",BASE)112 n = convertBase(text,16)113 $("#ir").text(n+"")114 text = getIntValue("#pc",BASE)115 n = convertBase(text,16)116 $("#pc").text(n+"")117 BASE = 16;118}119var errorRaised = false;120var stopRaised = false;121var memory = {};122function executeAssembly() {123 errorRaised = false;124 stopRaised = false;125 changeRegister("#pc","1");126 var code = assemblyCode.getValue().split("\n");127 while(parseInt($('#pc').text(),BASE)-1<code.length){128 if(errorRaised){129 appendToOutput("ERROR!")130 appendToOutput("ABORTING EXECUTION!")131 break;132 }133 if(stopRaised){134 break;135 }136 handleCode(code[parseInt($('#pc').text(),BASE)-1]);137 }138 // changeRegister("#pc",1);139}140function getFinalCode(operation,operands) {141 opCode = convertBase(getOpCode(operation),2)142 cmd = pad(opCode,6);143 c = operands.length;144 for(var i=0;i<c;i++){145 k = operands[i].replace("r","")146 dat = parseInt(k,INPUT_BASE)147 cmd += pad(convertBase(dat,2),6)148 }149 cmd = padR(cmd,32);150 if(cmd.length>32)151 appendToOutput("Warning : IR exceeds 32 bits! the command wont run on real machine!")152 if(BASE == 2)153 return cmd154 csd = parseInt(cmd,2)155 return convertBase(csd,BASE)156}157function getOpCode(operation) {158 switch (operation.toLowerCase()) {159 case "ld" : return 1;160 case "ldr" : return 2;161 case "la" : return 5;162 case "lar" : return 6;163 case "st" : return 3;164 case "str" : return 4;165 case "br" : return 8;166 case "brl" : return 9;167 case "add" : return 12;168 case "sub" : return 14;169 case "neg" : return 15;170 case "addi" : return 13;171 case "and" : return 20;172 case "andi" : return 21;173 case "or" : return 22;174 case "ori" : return 23;175 case "not" : return 24;176 case "shr" : return 26;177 case "shra" : return 27;178 case "shl" : return 28;179 case "shc" : return 29;180 case "nop" : return 0;181 case "stop" : return 31;182 }183}184function handleCode(line) {185 incrementPC();186 if(VERBOSE)187 appendToOutput("Fetching PC...");188 part = line.split(" ");189 operation = part[0];190 if(part.length>1)191 p = part[1];192 else193 p = ""194 operandsMeta = p195 if(p.includes(";"))196 operandsMeta = part[1].substring(0, part[1].indexOf(';'));197 if(operandsMeta.includes(","))198 operands = operandsMeta.split(",");199 else200 operands = operandsMeta;201 if(operands.length > 3 && !operation.startsWith("brl")){202 raiseError("Unsupported more than 3 bit addressing...");203 }204 pc = $('#pc').text()205 changeRegister('#ir',getFinalCode(operation,operands));206 //everything seems okay so far...207 handleCommand(operation,operands);208}209function changeRegister(registerId,value) {210 try {211 str = registerId.trim().replace("#", "").toUpperCase() + " = " + value;212 $(registerId).text(value)213 if(VERBOSE)214 appendToOutput(str)215 }catch (e) {216 appendToOutput("Error trying to change "+registerId.replace("#", "").toUpperCase())217 }218}219function changeRegisterCustom(registerId,value,message) {220 try {221 str = message.trim().replace("#", "").toUpperCase();222 $(registerId).text(value)223 appendToOutput(str)224 }catch (e) {225 appendToOutput("Error trying to change "+registerId.replace("#", "").toUpperCase())226 }227}228function raiseError(errorInfo) {229 errorRaised = true;230 appendToOutput(errorInfo);231}232function appendToOutput(string){233 if(string.toLowerCase().includes("branching"))234 if(VERBOSE)235 outputCode.replaceRange(string+"\n", CodeMirror.Pos(outputCode.lastLine()))236 else{}237 else238 outputCode.replaceRange(string+"\n", CodeMirror.Pos(outputCode.lastLine()))239}240function incrementPC() {241 val = parseInt($('#pc').text(),BASE) + 1242 changeRegister('#pc',convertBase(val,BASE))243}244function malfunctionCommand() {245 raiseError('Command not supported. Please check the cheat sheat given below');246}247function registerNotFound() {248 raiseError('Required register was not found');249}250function registerExists(id) {251 if(id === "pc")252 return true;253 if(id === "ir")254 return true;255 for (var i=0;i<32;i++)256 if(id === "r"+i)257 return true;258 return false;259}260function getIntValue(registerId,base) {261 return parseInt($(registerId).text(),base);262}263function handleCommand(command,operands) {264 if(command.toLowerCase().includes("br")){265 brOperation(command.toLowerCase(),operands)266 return267 }268 switch (command.toLowerCase()) {269 case "add" :270 addOperation(operands);271 break;272 case "addi" :273 addIOperation(operands);274 break;275 case "neg":276 negOperation(operands);277 break;278 case "sub":279 subOperation(operands);280 break;281 case "and":282 andOperation(operands);283 break;284 case "andi":285 andIOperation(operands);286 break;287 case "or":288 orOperation(operands);289 break;290 case "ori":291 orIOperation(operands);292 break;293 case "not":294 notOperation(operands);295 break;296 case "shr":297 shrOperation(operands);298 break;299 case "shra":300 shraOperation(operands);301 break;302 case "shl":303 shlOperation(operands);304 break;305 case "shc":306 shcOperation(operands);307 break;308 case "nop;":309 case "nop":310 nopOperation(operands);311 break;312 case "stop;":313 case "stop":314 stopOperation(operands);315 break;316 case "ld":317 ldOperation(operands);318 break;319 case "ldr":320 ldOperation(operands);321 break;322 case "la":323 laOperation(operands);324 break;325 case "lar":326 larOperation(operands);327 break;328 case "st":329 stOperation(operands);330 break;331 case "str":332 strOperation(operands);333 break;334 default:malfunctionCommand();335 }336}337function ldrOperation(operands) {338 if (operands.length < 3) {339 if (registerExists(operands[0])) {340 sum = parseInt(operands[1],INPUT_BASE)341 pc = getIntValue('#pc',BASE);342 content = memory[sum+pc]343 if (typeof content === 'undefined'){344 changeRegisterCustom('#' + operands[0], 0, operands[0] + ' = M[' + operands[1] +"+PC] <-- 0")345 }346 else {347 changeRegisterCustom('#' + operands[0], convertBase(content,BASE), operands[0] + ' = M[' + operands[1] +"+PC] <-- " + convertBase(content,BASE))348 }349 } else350 registerNotFound();351 } else {352 malfunctionCommand();353 }354}355function brOperation(command,operands) {356 console.log("Called br")357 if (operands.length <= 4) {358 if(command.includes("brl")){359 handleLinked(command,operands);360 }361 else{362 handleBranch(command,operands);363 }364 } else {365 malfunctionCommand();366 }367}368function handleLinked(command,operands) {369 intPCval = getIntValue("#pc",BASE);370 basePCval = convertBase(intPCval,BASE);371 if(operands.length==4){ //its that C command so check for C =_=372 branchAddress = getIntValue("#"+operands[1],BASE);373 cond = getIntValue("#"+operands[2],BASE);374 test = parseInt(operands[3],INPUT_BASE);375 if(test >= 0 && test <=5){376 switch (test) {377 case 0:378 appendToOutput("branch never... should I do anything here??")379 break;380 case 1:381 changeRegister("#"+operands[0],basePCval)382 changeRegisterCustom("#pc",convertBase(branchAddress,BASE),"Branching to "+operands[1])383 break;384 case 2:385 if(cond==0) {386 changeRegister("#"+operands[0],basePCval)387 changeRegisterCustom("#pc", convertBase(branchAddress, BASE), "Branching to " + operands[1])388 }389 else390 appendToOutput("Not branching as the condition is not met")391 break;392 case 3:393 if(cond!=0) {394 changeRegister("#"+operands[0],basePCval)395 changeRegisterCustom("#pc", convertBase(branchAddress, BASE), "Branching to " + operands[1])396 }397 else398 appendToOutput("Not branching as the condition is not met")399 break;400 case 4:401 if(cond>=0 && cond<parseInt("10000000000000000000000000000000",2)) {402 changeRegister("#"+operands[0],basePCval)403 changeRegisterCustom("#pc", convertBase(branchAddress, BASE), "Branching to " + operands[1])404 }405 else406 appendToOutput("Not branching as the condition is not met")407 case 5:408 if(cond<0 || cond>=parseInt("10000000000000000000000000000000",2)) {409 changeRegister("#"+operands[0],basePCval)410 changeRegisterCustom("#pc", convertBase(branchAddress, BASE), "Branching to " + operands[1])411 }412 else413 appendToOutput("Not branching as the condition is not met")414 }415 }else{416 raiseError("condition not found!")417 }418 }else{419 //phew people are using real thing now...420 branchAddress = ""421 outputN = ""422 if(typeof(operands)==="string") {423 branchAddress = getIntValue("#" + operands, BASE);424 outputN = operands425 }426 else {427 branchAddress = getIntValue("#" + operands[1], BASE);428 outputN = operands[1]429 }430 if(command.includes("nv")){431 appendToOutput("branch never... should I do anything here??")432 }else if(command.includes("zr")){433 cond = getIntValue("#"+operands[2],BASE)434 if(cond==0) {435 changeRegister("#"+operands[0],basePCval)436 changeRegisterCustom("#pc", convertBase(branchAddress, BASE), "Branching to " + outputN)437 }438 else439 appendToOutput("Not branching as the condition is not met")440 }else if(command.includes("nz")){441 cond = getIntValue("#"+operands[2],BASE)442 if(cond!=0) {443 changeRegister("#"+operands[0],basePCval)444 changeRegisterCustom("#pc", convertBase(branchAddress, BASE), "Branching to " + outputN)445 }446 else447 appendToOutput("Not branching as the condition is not met")448 }else if(command.includes("pl")){449 cond = getIntValue("#"+operands[2],BASE)450 if(cond>=0 && cond<parseInt("10000000000000000000000000000000",2)) {451 changeRegister("#"+operands[0],basePCval)452 changeRegisterCustom("#pc", convertBase(branchAddress, BASE), "Branching to " + outputN)453 }454 else455 appendToOutput("Not branching as the condition is not met")456 }else if(command.includes("mi")){457 cond = getIntValue("#"+operands[2],BASE)458 if(cond<0 || cond>=parseInt("10000000000000000000000000000000",2)) {459 changeRegister("#"+operands[0],basePCval)460 changeRegisterCustom("#pc", convertBase(branchAddress, BASE), "Branching to " + outputN)461 }462 else463 appendToOutput("Not branching as the condition is not met")464 }else if(command.trim()==="brl"){465 changeRegister("#"+operands[0],basePCval)466 changeRegisterCustom("#pc",convertBase(branchAddress,BASE),"Branching to "+outputN)467 }468 }469}470function handleBranch(command,operands) {471 if(operands.length==3){ //its that C command so check for C =_=472 branchAddress = getIntValue("#"+operands[0],BASE);473 cond = getIntValue("#"+operands[1],BASE);474 test = parseInt(operands[2],INPUT_BASE);475 if(test >= 0 && test <=5){476 switch (test) {477 case 0:478 appendToOutput("branch never... should I do anything here??")479 break;480 case 1:481 changeRegisterCustom("#pc",convertBase(branchAddress,BASE),"Branching to "+operands[0])482 break;483 case 2:484 if(cond==0)485 changeRegisterCustom("#pc",convertBase(branchAddress,BASE),"Branching to "+operands[0])486 else487 appendToOutput("Not branching as the condition is not met")488 break;489 case 3:490 if(cond!=0)491 changeRegisterCustom("#pc",convertBase(branchAddress,BASE),"Branching to "+operands[0])492 else493 appendToOutput("Not branching as the condition is not met")494 break;495 case 4:496 if(cond>=0 && cond<parseInt("10000000000000000000000000000000",2))497 changeRegisterCustom("#pc",convertBase(branchAddress,BASE),"Branching to "+operands[0])498 else499 appendToOutput("Not branching as the condition is not met")500 case 5:501 if(cond<0 || cond>=parseInt("10000000000000000000000000000000",2))502 changeRegisterCustom("#pc",convertBase(branchAddress,BASE),"Branching to "+operands[0])503 else504 appendToOutput("Not branching as the condition is not met")505 }506 }else{507 raiseError("condition not found!")508 }509 }else{510 //phew people are using real thing now...511 branchAddress = ""512 outputN = ""513 if(typeof(operands)==="string") {514 branchAddress = getIntValue("#" + operands, BASE);515 outputN = operands516 }517 else {518 branchAddress = getIntValue("#" + operands[0], BASE);519 outputN = operands[0]520 }521 if(command.includes("nv")){522 appendToOutput("branch never... should I do anything here??")523 }else if(command.includes("zr")){524 cond = getIntValue("#"+operands[1],BASE)525 if(cond==0)526 changeRegisterCustom("#pc",convertBase(branchAddress,BASE),"Branching to "+outputN)527 else528 appendToOutput("Not branching as the condition is not met")529 }else if(command.includes("nz")){530 cond = getIntValue("#"+operands[1],BASE)531 if(cond!=0)532 changeRegisterCustom("#pc",convertBase(branchAddress,BASE),"Branching to "+outputN)533 else534 appendToOutput("Not branching as the condition is not met")535 }else if(command.includes("pl")){536 cond = getIntValue("#"+operands[1],BASE)537 if(cond>=0 && cond<parseInt("10000000000000000000000000000000",2))538 changeRegisterCustom("#pc",convertBase(branchAddress,BASE),"Branching to "+outputN)539 else540 appendToOutput("Not branching as the condition is not met")541 }else if(command.includes("mi")){542 cond = getIntValue("#"+operands[1],BASE)543 if(cond<0 || cond>=parseInt("10000000000000000000000000000000",2))544 changeRegisterCustom("#pc",convertBase(branchAddress,BASE),"Branching to "+outputN)545 else546 appendToOutput("Not branching as the condition is not met")547 }else if(command.trim()==="br"){548 changeRegisterCustom("#pc",convertBase(branchAddress,BASE),"Branching to "+outputN)549 }550 }551}552function laOperation(operands) {553 if (operands.length < 3) {554 if (registerExists(operands[0])) {555 sum = parseInt(operands[1],INPUT_BASE)556 content = sum557 changeRegisterCustom('#' + operands[0], convertBase(content,BASE), operands[0] + ' = ' + operands[1] +" <-- " + convertBase(content,BASE))558 } else559 registerNotFound();560 } else {561 malfunctionCommand();562 }563}564function strOperation(operands) {565 if (operands.length < 3) {566 if (registerExists(operands[0])) {567 sum = parseInt(operands[1],INPUT_BASE)568 pc = getIntValue("#pc",BASE)569 memory[sum+pc]=getIntValue("#"+operands[0],BASE)570 k = sum+pc571 appendToOutput("M["+convertBase(sum,BASE)+"+PC] = "+convertBase(getIntValue('#'+operands[0],BASE),BASE))572 } else573 registerNotFound();574 } else {575 malfunctionCommand();576 }577}578function stOperation(operands) {579 if (operands.length < 3) {580 if (registerExists(operands[0])) {581 if(operands[1].includes("(")){582 newOp = operands[1].replace("("," ");583 newOp = newOp.replace(")","");584 newOp = newOp.split(" ");585 sum = getIntValue('#'+newOp[1],BASE)586 k = sum+parseInt(newOp[0],INPUT_BASE)587 memory[k] = getIntValue("#"+operands[0],BASE)588 appendToOutput("M["+convertBase(k,BASE)+"] = "+convertBase(getIntValue('#'+operands[0],BASE),BASE))589 return;590 }591 sum = parseInt(operands[1],INPUT_BASE)592 memory[sum]= getIntValue('#'+operands[0],BASE)593 appendToOutput("M["+convertBase(sum,BASE)+"] = "+convertBase(getIntValue('#'+operands[0],BASE),BASE))594 } else595 registerNotFound();596 } else {597 malfunctionCommand();598 }599}600function ldOperation(operands) {601 if (operands.length < 3) {602 if (registerExists(operands[0])) {603 if(operands[1].includes("(")){604 newOp = operands[1].replace("("," ");605 newOp = newOp.replace(")","");606 newOp = newOp.split(" ");607 sum = getIntValue('#'+newOp[1],BASE)608 content = memory[sum+parseInt(newOp[0],INPUT_BASE)];609 if (typeof content === 'undefined'){610 changeRegisterCustom('#' + operands[0], 0, operands[0] + ' = M[' + newOp[0] +"+"+newOp[1]+"] <-- 0")611 }612 else {613 changeRegisterCustom('#' + operands[0], convertBase(content,BASE), operands[0] + ' = M[' + newOp[0] +"+"+newOp[1]+"] <-- " + convertBase(content,BASE))614 }615 return;616 }617 sum = parseInt(operands[1],INPUT_BASE)618 content = memory[sum]619 if (typeof content === 'undefined'){620 changeRegisterCustom('#' + operands[0], 0, operands[0] + ' = M[' + operands[1] +"] <-- 0")621 }622 else {623 changeRegisterCustom('#' + operands[0], convertBase(content,BASE), operands[0] + ' = M[' + operands[1] +"] <-- " + convertBase(content,BASE))624 }625 } else626 registerNotFound();627 } else {628 malfunctionCommand();629 }630}631function nopOperation(operands) {632 appendToOutput("NOP!!!")633}634function stopOperation(operands) {635 stopRaised = true;636 appendToOutput("Stop met, Abort the program");637}638function shcOperation(operands) {639 if (operands.length < 3) {640 malfunctionCommand();641 } else {642 if (registerExists(operands[0]) && registerExists(operands[1]) &&643 registerExists(operands[2])) {644 n = getIntValue('#' + operands[1],BASE);645 d = getIntValue('#' + operands[2],BASE);646 sum = (n << d)|(n >> (32 - d));647 changeRegisterCustom('#' + operands[0], convertBase(sum,BASE), operands[0] + ' = ' + operands[1] + '<<<>>>' + operands[2] + " <-- " + convertBase(sum,BASE))648 } else{649 p = parseInt(operands[2],BASE)650 if(!(typeof p == 'number')){651 registerNotFound();652 }653 else{654 n = getIntValue('#' + operands[1],BASE);655 d = p;656 sum = (n << d)|(n >> (32 - d));657 changeRegisterCustom('#' + operands[0], convertBase(sum,BASE), operands[0] + ' = ' + operands[1] + '<<<>>>' + operands[2] + " <-- " + convertBase(sum,BASE))658 }659 }660 }661}662function shrOperation(operands) {663 if (operands.length < 3) {664 malfunctionCommand();665 } else {666 if (registerExists(operands[0]) && registerExists(operands[1]) &&667 registerExists(operands[2])) {668 sum = getIntValue('#' + operands[1],BASE) >>> getIntValue('#' + operands[2],BASE)669 changeRegisterCustom('#' + operands[0], convertBase(sum,BASE), operands[0] + ' = ' + operands[1] + '>>>' + operands[2] + " <-- " + convertBase(sum,BASE))670 } else {671 p = parseInt(operands[2],BASE)672 if(!(typeof p == 'number')){673 registerNotFound();674 }675 else{676 sum = getIntValue('#' + operands[1],BASE) >>> p677 changeRegisterCustom('#' + operands[0], convertBase(sum,BASE), operands[0] + ' = ' + operands[1] + '>>>' + operands[2] + " <-- " + convertBase(sum,BASE))678 }679 }680 }681}682function shlOperation(operands) {683 if (operands.length < 3) {684 malfunctionCommand();685 } else {686 if (registerExists(operands[0]) && registerExists(operands[1]) &&687 registerExists(operands[2])) {688 sum = getIntValue('#' + operands[1],BASE) << getIntValue('#' + operands[2],BASE)689 changeRegisterCustom('#' + operands[0], convertBase(sum,BASE), operands[0] + ' = ' + operands[1] + '<<' + operands[2] + " <-- " + convertBase(sum,BASE))690 } else{691 p = parseInt(operands[2],BASE)692 if(!(typeof p == 'number')){693 registerNotFound();694 }695 else{696 sum = getIntValue('#' + operands[1],BASE) << p697 changeRegisterCustom('#' + operands[0], convertBase(sum,BASE), operands[0] + ' = ' + operands[1] + '<<' + operands[2] + " <-- " + convertBase(sum,BASE))698 }699 }700 }701}702function shraOperation(operands) {703 if (operands.length < 3) {704 malfunctionCommand();705 } else {706 if (registerExists(operands[0]) && registerExists(operands[1]) &&707 registerExists(operands[2])) {708 sum = getIntValue('#' + operands[1],BASE) >> getIntValue('#' + operands[2],BASE)709 changeRegisterCustom('#' + operands[0], convertBase(sum,BASE), operands[0] + ' = ' + operands[1] + '>>' + operands[2] + " <-- " + convertBase(sum,BASE))710 } else {711 p = parseInt(operands[2],BASE)712 if(!(typeof p == 'number')){713 registerNotFound();714 }715 else{716 sum = getIntValue('#' + operands[1],BASE) >> p717 changeRegisterCustom('#' + operands[0], convertBase(sum,BASE), operands[0] + ' = ' + operands[1] + '>>' + operands[2] + " <-- " + convertBase(sum,BASE))718 }719 }720 }721}722function orOperation(operands) {723 if (operands.length < 3) {724 malfunctionCommand();725 } else {726 if (registerExists(operands[0]) && registerExists(operands[1]) &&727 registerExists(operands[2])) {728 sum = getIntValue('#' + operands[1],BASE) | getIntValue('#' + operands[2],BASE)729 changeRegisterCustom('#' + operands[0], convertBase(sum,BASE), operands[0] + ' = ' + operands[1] + '|' + operands[2] + " <-- " + convertBase(sum,BASE))730 } else731 registerNotFound();732 }733}734function andOperation(operands) {735 if (operands.length < 3) {736 malfunctionCommand();737 } else {738 if (registerExists(operands[0]) && registerExists(operands[1]) &&739 registerExists(operands[2])) {740 sum = getIntValue('#' + operands[1],BASE) & getIntValue('#' + operands[2],BASE)741 changeRegisterCustom('#' + operands[0], convertBase(sum,BASE), operands[0] + ' = ' + operands[1] + '&' + operands[2] + " <-- " + convertBase(sum,BASE))742 } else743 registerNotFound();744 }745}746function andIOperation(operands) {747 if (operands.length < 3) {748 malfunctionCommand();749 } else {750 if (registerExists(operands[0]) && registerExists(operands[1])) {751 if(convertBase(parseInt(operands[2],INPUT_BASE),2).length>32752 || operands[2].length>32) {753 raiseError('Register/constant content exceed 32bits')754 return;755 }756 sum = getIntValue('#' + operands[1],BASE) & parseInt(operands[2],INPUT_BASE)757 changeRegisterCustom('#' + operands[0], convertBase(sum,BASE), operands[0] + ' = ' + operands[1] + '&' + operands[2] + " <-- " + convertBase(sum,BASE))758 } else759 registerNotFound();760 }761}762function orIOperation(operands) {763 if (operands.length < 3) {764 malfunctionCommand();765 } else {766 if (registerExists(operands[0]) && registerExists(operands[1])) {767 if(convertBase(parseInt(operands[2],INPUT_BASE),2).length>32768 || operands[2].length>32) {769 raiseError('Register/constant content exceed 32bits')770 return;771 }772 sum = getIntValue('#' + operands[1],BASE) | parseInt(operands[2],INPUT_BASE)773 changeRegisterCustom('#' + operands[0], convertBase(sum,BASE), operands[0] + ' = ' + operands[1] + '|' + operands[2] + " <-- " + convertBase(sum,BASE))774 } else775 registerNotFound();776 }777}778function negOperation(operands) {779 if (operands.length < 3) {780 if (registerExists(operands[0]) && registerExists(operands[1])) {781 sum = twosComplement('#' + operands[1],BASE)782 if(sum.toString(2).length<=32)783 changeRegisterCustom('#' + operands[0], sum, operands[0] + ' = -' + operands[1] +" <-- " + sum)784 else785 raiseError("Negation exceeds 32bits");786 } else787 registerNotFound();788 } else {789 malfunctionCommand();790 }791}792function notOperation(operands) {793 if (operands.length < 3) {794 if (registerExists(operands[0]) && registerExists(operands[1])) {795 sum = ~getIntValue('#'+operands[1],INPUT_BASE)796 console.log("SUM "+sum)797 console.log(convertBase(sum,BASE));798 changeRegisterCustom('#' + operands[0], convertBase(sum,BASE), operands[0] + ' = !' + operands[1] +" <-- " + convertBase(sum,BASE))799 } else800 registerNotFound();801 } else {802 malfunctionCommand();803 }804}805function twosComplement(registerId,base) {806 bin = pad($(registerId).text(),32);807 console.log("bin = "+bin)808 if(base === 2){}809 else{810 bin = convertBase(bin,2);811 }812 return (~parseInt(bin,2) + 1 >>> 0).toString(base)813 //(~0b11111111111111111111111111111111 + 1 >>> 0).toString(10)814}815function twosComplementSTR(numSTR,base) {816 bin = pad(numSTR,32);817 console.log("bin = "+bin)818 if(base === 2){}819 else{820 bin = convertBase(bin,2);821 }822 return (~parseInt(bin,2) + 1 >>> 0).toString(base)823 //(~0b11111111111111111111111111111111 + 1 >>> 0).toString(10)824}825function addOperation(operands) {826 if (operands.length < 3) {827 malfunctionCommand();828 } else {829 if (registerExists(operands[0]) && registerExists(operands[1]) &&830 registerExists(operands[2])) {831 sum = getIntValue('#' + operands[1],BASE) + getIntValue('#' + operands[2],BASE)832 if(sum.toString(2).length>32){833 raiseError("Sum exceeds 32bits");834 return;835 }836 changeRegisterCustom('#' + operands[0], convertBase(sum,BASE), operands[0] + ' = ' + operands[1] + '+' + operands[2] + " <-- " + convertBase(sum,BASE))837 } else838 registerNotFound();839 }840}841function addIOperation(operands) {842 if (operands.length < 3) {843 malfunctionCommand();844 } else {845 if (registerExists(operands[0]) && registerExists(operands[1])) {846 if(convertBase(getIntValue('#' + operands[1],BASE),2).length>32847 || convertBase(parseInt(operands[2],INPUT_BASE),2).length>32848 || operands[2].length>32) {849 raiseError('Register/constant content exceed 32bits')850 return;851 }852 sum = getIntValue('#' + operands[1],BASE) + parseInt(operands[2],INPUT_BASE)853 if(sum.toString(2).length>32){854 raiseError("Sum exceeds 32bits");855 return;856 }857 sum = convertBase(sum,BASE)858 console.log(sum)859 changeRegisterCustom('#' + operands[0], sum+"", operands[0] + ' = ' + operands[1] + '+' + operands[2] + " <-- " + sum)860 } else861 registerNotFound();862 }863}864function addBin(a, b) {865 var dec = Number(parseInt(a, 2)) + Number(parseInt(b, 2));866 return dec.toString(2);867}868function subOperation(operands) {869 if (operands.length < 3) {870 malfunctionCommand();871 } else {872 if (registerExists(operands[0]) && registerExists(operands[1]) &&873 registerExists(operands[2])) {874 var twosCompStr = twosComplement('#' + operands[2],BASE);875 var newComp = convertBase(parseInt(twosCompStr,BASE),2);876 a = pad(convertBase(getIntValue('#' + operands[1],BASE),2),32);877 sum = addBin(a, newComp);878 if(sum.length === 33){879 //result is positive.880 sum=sum.substring(1,33);881 sum = parseInt(sum,2)882 sum = convertBase(sum,BASE)883 changeRegisterCustom('#' + operands[0], sum, operands[0] + ' = ' + operands[1] + '-' + operands[2] + " <-- " + sum)884 }885 else{886 //result is negative887 sum = parseInt(sum,2)888 sum = convertBase(sum,BASE)889 changeRegisterCustom('#' + operands[0], sum, operands[0] + ' = ' + operands[1] + '-' + operands[2] + " <-- " +sum)890 }...

Full Screen

Full Screen

logger.js

Source:logger.js Github

copy

Full Screen

...11 Level.prototype.getName = function () {12 return this.name;13 };14 Level.prototype.getLevel = function (val) {15 if (Level.OFF.getIntValue() == val)16 return Level.OFF;17 else if (Level.SEVERE.getIntValue() == val)18 return Level.SEVERE;19 else if (Level.WARNING.getIntValue() == val)20 return Level.WARNING;21 else if (Level.INFO.getIntValue() == val)22 return Level.INFO;23 else if (Level.CONFIG.getIntValue() == val)24 return Level.CONFIG;25 else if (Level.FINE.getIntValue() == val)26 return Level.FINE;27 else if (Level.FINER.getIntValue() == val)28 return Level.FINER;29 else if (Level.FINEST.getIntValue() == val)30 return Level.FINEST;31 else if (Level.ALL.getIntValue() == val)32 return Level.ALL;33 };34 Level.OFF = new Level("OFF", 9999);35 Level.SEVERE = new Level("SEVERE", 1000);36 Level.WARNING = new Level("WARNING", 900);37 Level.INFO = new Level("INFO", 800);38 Level.CONFIG = new Level("CONFIG", 700);39 Level.FINE = new Level("FINE", 600);40 Level.FINER = new Level("FINER", 500);41 Level.FINEST = new Level("FINEST", 400);42 Level.ALL = new Level("ALL", 0);43 //2. Log Record44 function LogRecord(level, msg) {45 this._level = level;46 this._sequenceNumber;47 this._sourceClassName;48 this._sourceMethodName;49 this._message = msg;50 this._lineNumber;51 this._loggerName;52 }53 LogRecord.prototype.getMessage = function () {54 return this._message;55 }56 LogRecord.prototype.setMessage = function (msg) {57 this._message = msg;58 }59 LogRecord.prototype.getSourceClassName = function () {60 return this._sourceClassName;61 }62 LogRecord.prototype.setSourceClassName = function (msg) {63 this._sourceClassName = msg;64 }65 LogRecord.prototype.getSourceMethodName = function () {66 return this._sourceMethodName;67 }68 LogRecord.prototype.setSourceMethodName = function (msg) {69 this._sourceMethodName = msg;70 }71 LogRecord.prototype.getLineNumber = function () {72 return this._lineNumber;73 }74 LogRecord.prototype.setLineNumber = function (msg) {75 this._lineNumber = msg;76 }77 LogRecord.prototype.getLoggerName = function () {78 return this._loggerName;79 }80 LogRecord.prototype.setLoggerName = function (msg) {81 this._loggerName = msg;82 }83 LogRecord.prototype.getLevel = function () {84 return this._level;85 }86 //3.VLogFilter87 function VLogFilter() {88 if (VLogFilter.prototype.singleInstance) {89 return VLogFilter.prototype.singleInstance;90 }91 VLogFilter.prototype.singleInstance = this;92 };93 VLogFilter.prototype.singleInstance = null;94 VLogFilter.get = function () {95 if (VLogFilter.prototype.singleInstance) {96 return VLogFilter.prototype.singleInstance;97 }98 return new VLogFilter();99 }100 VLogFilter.prototype.getIsLoggable = function (record) {101 if (record.getLevel() === Level.SEVERE102 || record.getLevel() === Level.WARNING)103 return true;104 //105 var loggerName = record.getLoggerName();106 if (loggerName) {107 // if (loggerName.toLowerCase().indexOf("focus") != -1)108 // return true;109 if (loggerName.startsWith("System."))110 return false;111 }112 var className = record.sourceClassName;113 if (className) {114 if (className.startsWith("System."))115 return false;116 }117 return true;118 }119 //4.VLogFormatter120 function VLogFormatter() {121 if (VLogFormatter.prototype.singletonInstance) {122 return VLogFormatter.prototype.singletonInstance;123 }124 VLogFormatter.prototype.singletonInstance = this;125 }126 VLogFormatter.prototype.singletonInstance = null;127 /** New Line */128 VLogFormatter.prototype.NL = '/n';129 VLogFormatter.get = function () {130 if (VLogFormatter.prototype.singletonInstance) {131 return VLogFormatter.prototype.singletonInstance;132 }133 return new VLogFormatter();134 };135 VLogFormatter.prototype.format = function (record) {136 var sb = new StringBuilder();137 //time of execution138 var time = Date.now.toString("yyyy-MM-dd hh:mm:ss.ms");139 time = time + "00";140 /** Time/Error */141 if (record.getLevel() == Level.prototype.SEVERE) {142 // 12.12.12.123 143 sb.append("===========> ");144 sb.append(" (SEVERE) ");145 //if (VAdvantage.DataBase.Ini.IsClient())146 //System.Media.SystemSounds.Beep.Play();147 }148 else if (record.getLevel() == Level.WARNING) {149 // 12.12.12.123150 sb.append("-----------> ");151 sb.append(" (WARNING) ");152 }153 else {154 //123456789123456789155 sb.append(time.Substring(11, 23 - 11));156 var spaces = 11;157 if (record.getLevel() == Level.INFO)158 sb.append(" (INFO) ");159 else if (record.getLevel() == Level.CONFIG)160 sb.append(" (CONFIG) ");161 else if (record.getLevel() == Level.FINE)162 sb.append(" (FINE) ");163 else if (record.getLevel() == Level.FINER)164 sb.append(" (FINER) ");165 else if (record.getLevel() == Level.FINEST)166 sb.append(" (FINEST) ");167 //sb.Append(" ".Substring(0, spaces));168 }169 /** Class.method **/170 //if (!_shortFormat)171 // sb.append(GetClassMethod(record)).Append(": ");172 /** Message **/173 sb.append(record.message);174 //sb.Append(record.sourceClassName + "." + record.sourceMethodName + " > " + record.lineNumber + " > " + record.message);175 return sb.toString();176 };177 VLogFormatter.prototype.getHead = function () {178 //Assembly asm = Assembly.GetExecutingAssembly();179 var asmName = "ViennaAdvantage";180 var sb = new StringBuilder()181 .append("*** ")182 .append(DateTime.Now.ToString())183 .append(" VAdvantage Log ")184 .append(" ***")185 .append("\n").append(asmName);186 return sb.toString();187 };188 VLogFormatter.prototype.getTail = function () {189 var sb = new StringBuilder()190 .append("*** ")191 //.append(DateTime.Now.ToString())192 .append(" VAdvantage Log")193 .append(" ***");194 return sb.toString();195 };196 /**************************************************************************197 * Get Class Method from Log Record198 * @param record record199 * @return class.method200 */201 VLogFormatter.prototype.getClassMethod = function (record) {202 var sb = "";203 var className = record.getLoggerName();204 if (className == null205 || className.indexOf("default") != -1 // anonymous logger206 || className.indexOf("global") != -1) // global logger207 className = record.getSourceClassName();208 if (className != null) {209 var index = className.lastIndexOf('.');210 if (index != -1)211 sb += className.substring(index + 1);212 else213 sb += className;214 }215 else216 sb += (record.getLoggerName());217 if (record.getSourceMethodName() != null)218 sb += (".") + record.getSourceMethodName();219 var retValue = sb;220 if (retValue.equals("Trace.printStack"))221 return "";222 return retValue;223 }; // getCl224 VLogFormatter.prototype.getParameters = function (record) {225 var sb = "";226 var parameters = record.getParameters();227 if (parameters != null && parameters.length > 0) {228 for (var i = 0; i < parameters.length; i++) {229 if (i > 0)230 sb += ", ";231 sb += parameters[i];232 }233 }234 return sb;235 }; // getParameters236 /**237 * Get Log Exception238 * @param record log record239 * @return null if exists or string240 */241 VLogFormatter.prototype.getExceptionTrace = function (record) {242 try {243 }244 catch (ex) {245 }246 return "";247 } // getException248 //5. Handler249 function Handler() {250 this.offValue = Level.OFF.getIntValue();251 this.logLevel = Level.ALL;252 this.formatter;253 this.filter;254 }255 Handler.prototype.publish = function (record) {256 }257 Handler.prototype.close = function () {258 }259 Handler.prototype.flush = function () {260 }261 Handler.prototype.setLevel = function (newLevel) {262 if (newLevel == null) {263 throw new NullReferenceException("No Level");264 }265 this.logLevel = newLevel;266 }267 Handler.prototype.getLevel = function () {268 return this.logLevel;269 }270 Handler.prototype.getFilter = function () {271 return this.filter;272 }273 Handler.prototype.setFilter = function (newFilter) {274 this.filter = newFilter;275 }276 Handler.prototype.getIsLoggable = function (record) {277 var levelValue = this.getLevel().getIntValue();278 if (record.getLevel().getIntValue() < levelValue || levelValue == this.offValue) {279 return false;280 }281 var filter = this.getFilter();282 if (filter == null) {283 return true;284 }285 return filter.getIsLoggable(record);286 }287 Handler.prototype.getFormatter = function () {288 return this.formatter;289 }290 Handler.prototype.setFormatter = function (newFormatter) {291 this.formatter = newFormatter;292 }293 //6 Log Buffer294 function VLogErrorBuffer() {295 if (VLogErrorBuffer.prototype.singleInstance) {296 return VLogErrorBuffer.prototype.singleInstance;297 }298 // Foratting299 this.setFormatter(VLogFormatter.get());300 // Default Level301 this.setLevel(Level.INFO);302 // Filter303 this.setFilter(VLogFilter.get());304 /** Error Buffer Size */305 this.ERROR_SIZE = 20;306 /** The Error Buffer */307 this.m_errors = [];308 /** The Error Buffer History */309 this.m_history = [];310 /** Log Size */311 this.LOG_SIZE = 100;312 /** The Log Buffer */313 this.m_logs = [];314 /** Issue Error */315 this.m_issueError = true;316 VLogErrorBuffer.prototype.singleInstance = this;317 };318 VIS.Utility.inheritPrototype(VLogErrorBuffer, Handler);319 VLogErrorBuffer.prototype.singleInstance = null;320 VLogErrorBuffer.get = function (create) {321 if (VLogErrorBuffer.prototype.singleInstance)322 return VLogErrorBuffer.prototype.singleInstance;323 else if (create) {324 return new VLogErrorBuffer;325 }326 return null;327 }328 VLogErrorBuffer.prototype.setLevel = function (newLevel) {329 if (newLevel == null)330 return;331 if (newLevel == Level.OFF)332 this.$super.setLevel.call(this, Level.SEVERE);333 else if (newLevel == Level.ALL || newLevel == Level.FINEST || newLevel == Level.FINER)334 this.$super.setLevel.call(this, Level.FINE);335 else336 this.$super.setLevel.call(this, newLevel);337 }338 VLogErrorBuffer.prototype.publish = function (record) {339 if (!this.getIsLoggable(record) || this.m_logs == null)340 return;341 // Output342 if (this.m_logs.length >= this.LOG_SIZE)343 this.m_logs.shift();344 this.m_logs.push(record);345 // We have an error346 if (record.getLevel() == Level.SEVERE) {347 if (this.m_errors.length >= this.ERROR_SIZE) {348 this.m_errors.shift();349 this.m_history.shift();350 }351 // Add Error352 this.m_errors.push(record);353 var history = [];354 for (var i = 0; i < this.m_logs.length; i++) {355 var rec = this.m_logs[i];356 if (rec.getLevel() == Level.SEVERE) {357 if (history.length == 0)358 history.push(rec);359 else360 break; // don't incluse previous error361 }362 else {363 history.push(rec);364 if (history.length > 10)365 break; // no more then 10 history records366 }367 }368 this.m_history.push(history);369 // Issue Reporting370 if (this.m_issueError) {371 var loggerName = record.getLoggerName(); // class name 372 // String className = record.getSourceClassName(); // physical class373 var methodName = record.getSourceMethodName(); // 374 //if (methodName && !methodName.equals("SaveError")375 // && !methodName.equals("Get_Value")376 // && !methodName.equals("DataSave")377 // && loggerName.indexOf("Issue") == -1378 // && loggerName.indexOf("CConnection") == -1379 // ) {380 // //m_issueError = false;381 // //MIssue.create(record);382 // // m_issueError = true;383 //}384 }385 }386 console.log(record);387 }388 VLogErrorBuffer.prototype.close = function () {389 if (this.m_logs != null) {390 this.m_logs.length = 0;391 this.m_logs = null;392 }393 if (this.m_errors != null) {394 this.m_errors.length = 0;395 this.m_errors = null;396 }397 if (this.m_history != null) {398 this.m_history.length = 0;399 this.m_history = null;400 }401 }402 /**************************************************************************403 * Get ColumnNames of Log Entries404 * @param ctx context (not used)405 * @return string vector406 */407 VLogErrorBuffer.prototype.getColumnNames = function (ctx) {408 var colName = [4];409 colName[0] = "Time";410 colName[1] = "Level";411 colName[2] = "Class.Method";412 colName[3] = "Message";413 return colName;414 }; // getColumnNames415 /**416 * Get Array of events with most recent first417 * @param errorsOnly if true errors otherwise log418 * @return array of events 419 */420 VLogErrorBuffer.prototype.getRecords = function (errorsOnly) {421 var retValue = null;422 if (errorsOnly) {423 retValue = this.m_errors.slice();424 }425 else {426 retValue = this.m_logs.slice();427 }428 return retValue;429 }; // getEvents430 /**431 * Get Log Data432 * @param errorsOnly if true errors otherwise log433 * @return data array434 */435 VLogErrorBuffer.prototype.getLogData = function (errorsOnly) {436 var records = this.getRecords(errorsOnly);437 // System.out.println("getLogData - " + events.length);438 var rows = [];439 for (var i = 0, len = records.length; i < len; i++) {440 var record = records[i];441 var cols = [];442 //443 cols.push(new Date().toString());//.getMillis()));444 cols.push(record.getLevel().getName());445 //446 cols.push(VLogFormatter.get().getClassMethod(record));447 cols.push(record.getMessage());448 //449 //cols.push(VLogFormatter.get().getParameters(record));450 //cols.push(VLogFormatter.get().getExceptionTrace(record));451 //452 rows.push(cols);453 }454 return rows;455 }; // getData456 /**457 * Reset Error Buffer458 * @param errorsOnly if true errors otherwise log459 */460 VLogErrorBuffer.prototype.resetBuffer = function (errorsOnly) {461 {462 this.m_errors.length = 0;463 this.m_history.length = 0;464 }465 if (!errorsOnly) {466 this.m_logs.length = 0;467 }468 };469 // resetBuffer470//7 Logger 471function Logger(name) {472 this.levelValue = Level.INFO.getIntValue();473 this.name = name; //name of the logger474 this.levelObject; //level object475 this.handlers = []; //diffrent handlers (VLogFile)476 this.kids = [];477 this.manager = LogManager.getLogManager(); //initiate the logmanager class478 this.parent; // our nearest parent.479 this.offValue = Level.OFF.getIntValue();480 this.filter;481}482Logger.prototype.setFilter = function (newFilter) {483 this.filter = newFilter;484}485Logger.prototype.getFilter = function () {486 return this.filter;487}488Logger.prototype.log = function (level, msg, e) {489 var msg = msg;490 if (e) {491 if (e.message) {492 msg += " => " + e.message;493 }494 if (e.stack) {495 msg += " ===> " + e.stack;496 }497 }498 //check if msg is eligible to be logged or not499 if (level.getIntValue() < this.levelValue || this.levelValue == Level.OFF.getIntValue())500 return;501 var lr = new LogRecord(level, msg); //set the values into logrecord class502 lr.setLoggerName(this.name);503 //if (lr.getLevel().getIntValue() < this.levelValue || levelValue == offValue)504 // return;505 if (this.filter != null && !this.filter.getIsLoggable(lr)) {506 return;507 }508 // Post the LogRecord to all our Handlers, and then to509 // our parents' handlers, all the way up the tree.510 var logger = this;511 while (logger != null) {512 var targets = logger.getHandlers();513 if (targets != null)514 for (var i = 0; i < targets.length; i++) {515 //VLogFile.Publish (abstract method)516 targets[i].publish(lr);517 }518 logger = logger.getParent();519 }520}521Logger.prototype.getParent = function () {522 return this.parent;523}524Logger.prototype.getHandlers = function () {525 if (this.handlers == null) {526 //if handler is null, set the empty handler527 return emptyHandlers;528 }529 return this.handlers;530}531Logger.prototype.getName = function () {532 return this.name;533}534Logger.prototype.setLevel = function (level) {535 this.levelObject = level;536 this.levelValue = level.getIntValue();537 //UpdateEffectiveLevel();538}539Logger.prototype.getLevel = function () {540 return this.levelObject;541}542Logger.prototype.addHandler = function (handler) {543 if (this.handlers == null)544 handlers = [];545 this.handlers.push(handler);546}547Logger.prototype.removeHandler = function (handler) {548 if (handler == null) {549 return;550 }551 if (this.handlers == null) {552 return;553 }554 this.handlers.remove(handler);555}556Logger.getLogger = function (name) {557 var logm = LogManager.getLogManager();558 var result = logm.getLogger(name);559 if (result == null) {560 //if not found, add logger to the log manager561 result = new Logger(name);562 logm.addLogger(result);563 result = logm.getLogger(name);564 }565 return result;566}567Logger.prototype.setParent = function (logger) {568 //if (parent == null)569 // return;570 this.parent = logger;571 // DoSetParent(logger);572}573Logger.prototype.getIsLoggable = function (level) {574 if (level.getIntValue() < levelValue || levelValue == offValue) {575 return false;576 }577 return true;578}579Logger.prototype.fine = function (msg) {580 if (Level.FINE.getIntValue() < this.levelValue) {581 return;582 }583 this.log(Level.FINE, msg);584}585Logger.prototype.info = function (msg) {586 if (Level.INFO.getIntValue() < this.levelValue) {587 return;588 }589 this.log(Level.INFO, msg);590}591Logger.prototype.config = function (msg) {592 if (Level.CONFIG.getIntValue() < this.levelValue) {593 return;594 }595 this.log(Level.CONFIG, msg);596}597Logger.prototype.finer = function (msg) {598 if (Level.FINER.getIntValue() < this.levelValue) {599 return;600 }601 this.log(Level.FINER, msg);602}603Logger.prototype.finest = function (msg) {604 if (Level.FINEST.getIntValue() < this.levelValue) {605 return;606 }607 this.log(Level.FINEST, msg);608}609Logger.prototype.severe = function (msg) {610 if (Level.SEVERE.getIntValue() < this.levelValue) {611 return;612 }613 this.log(Level.SEVERE, msg);614}615Logger.prototype.warning = function (msg) {616 if (Level.WARNING.getIntValue() < this.levelValue) {617 return;618 }619 this.log(Level.WARNING, msg);620}621 //Added By Sarab622Logger.prototype.saveError = function (msg,err) {623 //_lastException = err;624 var issueError=true;625 return this.saveError(msg, err.message, issueError);626}627Logger.prototype.saveError = function (msg, err, issueError)628{629 // _lastError = new ValueNamePair(AD_Message, message);630 // print it631if (issueError)632 this.warning(msg+" "+err.message);633return true;634} // saveError635//-----------636Logger.prototype.getIsLevelFinest = function () {637 return VLogMgt.getIsLevelFinest();638}639//8/// RootLogger640function RootLogger() {641 Logger.call(this, "");642 this.setLevel(Level.INFO);643}644VIS.Utility.inheritPrototype(RootLogger, Logger);645//9.Log Manager646function LogManager() {647 if (LogManager.prototype.singleInstance) {648 return LogManager.prototype.singleInstance649 }650 // The global LogManager object651 this.emptyHandlers = [];652 // Table of known loggers. Maps names to Loggers.653 this.loggers = {};;654 this.defaultLevel = Level.INFO;655 this.rootLogger;656 LogManager.prototype.singleInstance = this;657 // Tree of known loggers658 //private LogNode root = new LogNode(null);659}660LogManager.prototype.singleInstance = null;661LogManager.prototype.addLogger = function (logger) {662 var name = logger.getName();663 var old = null;664 if (name in this.loggers)665 old = loggers[name];666 if (old != null)667 return false;668 // We're adding a new logger.669 // Note that we are creating a strong reference here that will670 // keep the Logger in existence indefinitely.671 // if (loggers.ContainsKey(name))672 this.loggers[name] = logger;673 if (logger instanceof RootLogger) {674 }675 else676 logger.setParent(this.rootLogger);677 // else678 // loggers.Add(name, logger);679 //Level level = Level.INFO;680 //logger.SetLevel(level);681 // Find the new node and its parent.682 //LogNode node = FindNode(name);683 //node.logger = logger;684 //Logger parent = null;685 //LogNode nodep = node.parent;686 //while (nodep != null)687 //{688 // if (nodep.logger != null)689 // {690 // parent = nodep.logger;691 // break;692 // }693 // nodep = nodep.parent;694 //}695 //if(parent != null)696 // DoSetParent(logger, parent);697 //node.WalkAndSetParent(logger);698 return true;699 //Level level = getLevelProperty(name + ".level", null);700}701LogManager.prototype.reset = function () {702 //ArrayList list = loggers.ToArray();703 for (var prop in this.loggers) {704 ResetLogger(prop);705 }706}707LogManager.prototype.resetLogger = function (name) {708 var logger = this.getLogger(name);709 if (logger == null) {710 return;711 }712 // Close all the Logger's handlers.713 var targets = logger.getHandlers();714 for (var i = 0; i < targets.length; i++) {715 var h = targets[i];716 logger.removeHandler(h);717 try {718 h.close();719 }720 catch (ex) {721 //Problems closing a handler? Keep going...722 }723 }724 if (name != null && name.equals("")) {725 // This is the root logger.726 logger.setLevel(this.defaultLevel);727 }728 else {729 logger.setLevel(null);730 }731}732LogManager.prototype.getLogger = function (name) {733 if (name in this.loggers)734 return this.loggers[name];735 else736 return null;737}738LogManager.getLogManager = function () {739 if (!LogManager.prototype.singleInstance) {740 new LogManager();741 var mgr = LogManager.prototype.singleInstance742 mgr.rootLogger = new RootLogger();743 mgr.addLogger(mgr.rootLogger);744 }745 return LogManager.prototype.singleInstance;746}747LogManager.prototype.getLoggerNames = function () {748 return this.loggers;749}750//10. VLogger751function VLogger(name) {752 Logger.call(this, name);753}754VIS.Utility.inheritPrototype(VLogger, Logger);755VLogger.getVLogger = function (className) {756 var manager = LogManager.getLogManager(); //get the current logmanager object757 if (!className)758 className = "";759 var result = manager.getLogger(className); //find if the logger already exist760 if (result != null && result instanceof VLogger) //if yes, return the object761 return result;762 //other, we will have to create new763 var newLogger = new VLogger(className);764 newLogger.setLevel(VIS.Logging.VLogMgt.getLevel());765 manager.addLogger(newLogger);766 return newLogger;767}768//11. VLogMgt769function VLogMgt() {770 var _handlers = null;771 /** Current Log Level */772 var _currentLevel = Level.INFO;773 /** LOG Levels */774 var LEVELS = [Level.OFF, Level.SEVERE, Level.WARNING, Level.INFO,775 Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST, Level.ALL];776 var addHandler = function (handler) {777 if (handler == null)778 return;779 var rootLogger = Logger.getLogger("");780 rootLogger.addHandler(handler);781 //782 _handlers.push(handler);783 } // addHandler784 var getIsLevelAll = function () {785 return Level.ALL.getIntValue() == _currentLevel.getIntValue();786 } // isLevelFinest787 var initialize = function (isClient) {788 if (_handlers != null)789 return;790 //create handler list791 _handlers = [];792 try {793 var rootLogger = Logger.getLogger("");794 var handlers = rootLogger.getHandlers();795 for (var i = 0; i < handlers.length; i++) {796 if (!_handlers.contains(handlers[i]))797 _handlers.Add(handlers[i]);798 }799 }800 catch (e) {801 }802 //check loggers803 if (VLogErrorBuffer.get(false) == null)804 addHandler(VLogErrorBuffer.get(true));805 setFormatter(VLogFormatter.get());806 setFilter(VLogFilter.get());807 }808 var setLevel = function (level) {809 if (level == null)810 return;811 if (_handlers == null)812 initialize(true);813 for (var i = 0; i < _handlers.length; i++) {814 var handler = _handlers[i];815 handler.setLevel(level);816 }817 if (level.getIntValue() != _currentLevel.getIntValue()) {818 setLoggerLevel(level, null);819 }820 _currentLevel = level;821 }822 var setLoggerLevel = function (level, loggerNamePart) {823 if (level == null)824 return;825 var mgr = LogManager.getLogManager();826 var en = mgr.getLoggerNames();827 for (var prop in en) {828 var name = prop;829 if (loggerNamePart == null || name.indexOf(loggerNamePart) != -1) {830 var lll = Logger.getLogger(name);831 lll.setLevel(level);832 //if (log.getParent() == lll)833 // log.SetLevel(level);834 }835 }836 }837 var setFormatter = function (formatter) {838 for (var i = 0; i < _handlers.length; i++) {839 var handler = _handlers[i];840 handler.setFormatter(formatter);841 }842 }843 var setFilter = function (filter) {844 for (var i = 0; i < _handlers.length; i++) {845 var handler = _handlers[i];846 handler.setFilter(filter);847 }848 } // setFilter849 var getLevel = function () {850 return _currentLevel;851 } // getLevel852 var setLevelByString = function (levelString) {853 if (!levelString)854 return;855 //856 for (var i = 0; i < LEVELS.length; i++) {857 if (LEVELS[i].getName().equals(levelString)) {858 setLevel(LEVELS[i]);859 return;860 }861 }862 } // 863 var getLevelAsInt = function () {864 return _currentLevel.getIntValue();865 } // getLevel866 var shutdown = function () {867 var mgr = LogManager.getLogManager();868 mgr.reset();869 }870 var enable = function (enableLogging) {871 if (enableLogging) {872 setLevel(_currentLevel);873 }874 else {875 var level = _currentLevel;876 setLevel(Level.OFF);877 _currentLevel = level;878 }879 }880 return {881 initialize: initialize,882 addHandler: addHandler,883 setLevel: setLevel,884 setLevelByString: setLevelByString,885 getLevel: getLevel,886 shutdown: shutdown,887 enable: enable,888 getIsLevelAll: function () {889 return Level.ALL.getIntValue() == _currentLevel.getIntValue();890 },891 getIsLevelFinest: function () {892 return Level.FINEST.getIntValue() >= _currentLevel.getIntValue();893 },894 getIsLevelFiner: function () {895 return Level.FINER.getIntValue() >= _currentLevel.getIntValue();896 },897 getIsLevelFine: function () {898 return Level.FINE.getIntValue() >= _currentLevel.getIntValue();899 },900 getIsLevelInfo: function () {901 return Level.INFO.IntValue() >= _currentLevel.IntValue();902 }903 }904};905VIS.Logging.Level = Level;906VIS.Logging.LogRecord = LogRecord;907VIS.Logging.VLogFilter = VLogFilter;908VIS.Logging.VLogFormatter = VLogFormatter;909VIS.Logging.VLogErrorBuffer = VLogErrorBuffer;910VIS.Logging.Logger = Logger;911VIS.Logging.VLogger = VLogger;912VIS.Logging.LogManager = LogManager;...

Full Screen

Full Screen

control.js

Source:control.js Github

copy

Full Screen

...138 if (val < 0 || isNaN(val))139 val = 0;140 141 if (id == 'throttleMin1') {142 var max = getIntValue("throttleMax1");143 if (val > max)144 val = max;145 } else if (id == 'throttleMax1') {146 var min = getIntValue("throttleMin1");147 if (val < min)148 val = min;149 } else if (id == 'throttleMin2') {150 var max = getIntValue("throttleMax2");151 if (val > max)152 val = max;153 } else if (id == 'throttleMax2') {154 var min = getIntValue("throttleMin2");155 if (val < min)156 val = min;157 } else if (id == 'throttleRegenMax') {158 var regen = getIntValue("throttleRegenMin");159 if (val > regen)160 val = regen;161 } else if (id == 'throttleRegenMin') {162 var regen = getIntValue("throttleRegenMax");163 var fwd = getIntValue("throttleFwd");164 if (val < regen)165 val = regen;166 if (val > fwd)167 val = fwd;168 } else if (id == 'throttleFwd') {169 var regen = getIntValue("throttleRegenMin");170 var map = getIntValue("throttleMap");171 if (val < regen)172 val = regen;173 if (val > map)174 val = map;175 } else if (id == 'throttleMap') {176 var map = getIntValue("throttleFwd");177 if (val < map)178 val = map;179 } else if (id == 'throttleMinRegen') {180 var regen = getIntValue("throttleMaxRegen");181 if (val > regen)182 val = regen;183 } else if (id == 'throttleMaxRegen') {184 var regen = getIntValue("throttleMinRegen");185 if (val < regen)186 val = regen;187 } else if (id == 'brakeMin') {188 var max = getIntValue("brakeMax");189 if (val > max)190 val = max;191 } else if (id == 'brakeMax') {192 var min = getIntValue("brakeMin");193 if (val < min)194 val = min;195 } else if (id == 'brakeMinRegen') {196 var max = getIntValue("brakeMaxRegen");197 if (val > max)198 val = max;199 } else if (id == 'brakeMaxRegen') {200 var min = getIntValue("brakeMinRegen");201 if (val < min)202 val = min;203 }204 205 document.getElementById(id).value = val;206 source.value = val;207 refreshThrottleVisualization();208}209function refreshThrottleVisualization() {210 if (!canvas) {211 canvas = new ThrottleSettingsCanvas();212 }213 canvas.draw();214 215 var throttleRegenMin = document.getElementById('throttleRegenMin');216 var throttleFwd = document.getElementById('throttleFwd');217 if ( throttleRegenMin && throttleFwd ) {218 //updateThrottleGaugeHighlights(throttleRegenMin.value, throttleFwd.value);219 }220}221function getIntValue(id) {222 var node = document.getElementById(id);223 if (node)224 return parseInt(node.value);225 return 0;226}227function generateRangeControls() {228 addRangeControl("throttleMin1", 0, 4095);229 addRangeControl("throttleMin2", 0, 4095);230 addRangeControl("throttleMax1", 0, 4095);231 addRangeControl("throttleMax2", 0, 4095);232 addRangeControl("throttleRegenMax", 0, 100);233 addRangeControl("throttleRegenMin", 0, 100);234 addRangeControl("throttleFwd", 0, 100);235 addRangeControl("throttleMap", 0, 100);...

Full Screen

Full Screen

settings.js

Source:settings.js Github

copy

Full Screen

...69 var val = parseInt(source.value);70 if (val < 0 || isNaN(val))71 val = 0;72 if (id == 'minimumLevel') {73 var max = getIntValue("maximumLevel");74 if (val > max)75 val = max;76 } else if (id == 'maximumLevel') {77 var min = getIntValue("minimumLevel");78 if (val < min)79 val = min;80 } else if (id == 'minimumLevel2') {81 var max = getIntValue("maximumLevel2");82 if (val > max)83 val = max;84 } else if (id == 'maximumLevel2') {85 var min = getIntValue("minimumLevel2");86 if (val < min)87 val = min;88 } else if (id == 'positionRegenMaximum') {89 var regen = getIntValue("positionRegenMinimum");90 if (val > regen)91 val = regen;92 } else if (id == 'positionRegenMinimum') {93 var regen = getIntValue("positionRegenMaximum");94 var fwd = getIntValue("positionForwardStart");95 if (val < regen)96 val = regen;97 if (val > fwd)98 val = fwd;99 } else if (id == 'positionForwardStart') {100 var regen = getIntValue("positionRegenMinimum");101 var half = getIntValue("positionHalfPower");102 if (val < regen)103 val = regen;104 if (val > half)105 val = half;106 } else if (id == 'positionHalfPower') {107 var half = getIntValue("positionForwardStart");108 if (val < half)109 val = half;110 } else if (id == 'minimumRegen') {111 var regen = getIntValue("maximumRegen");112 if (val > regen)113 val = regen;114 } else if (id == 'maximumRegen') {115 var regen = getIntValue("minimumRegen");116 if (val < regen)117 val = regen;118 } else if (id == 'brakeMinimumLevel') {119 var max = getIntValue("brakeMaximumLevel");120 if (val > max)121 val = max;122 } else if (id == 'brakeMaximumLevel') {123 var min = getIntValue("brakeMinimumLevel");124 if (val < min)125 val = min;126 } else if (id == 'brakeMinimumRegen') {127 var max = getIntValue("brakeMaximumRegen");128 if (val > max)129 val = max;130 } else if (id == 'brakeMaximumRegen') {131 var min = getIntValue("brakeMinimumRegen");132 if (val < min)133 val = min;134 }135 $('#' + id).val(val);136 source.value = val;137 refreshThrottleVisualization();138 }139 function refreshThrottleVisualization() {140 if (!throttleCanvas) {141 throttleCanvas = new ThrottleSettingsCanvas();142 }143 throttleCanvas.draw();144 }145 function getIntValue(id) {146 var value = $('#' + id).val();147 return value ? parseInt(value) : 0;148 }149 function generateRangeControls() {150 addRangeControl("minimumLevel", 0, 4095);151 addRangeControl("minimumLevel2", 0, 4095);152 addRangeControl("maximumLevel", 0, 4095);153 addRangeControl("maximumLevel2", 0, 4095);154 addRangeControl("positionRegenMaximum", 0, 100, "%");155 addRangeControl("positionRegenMinimum", 0, 100, "%");156 addRangeControl("positionForwardStart", 0, 100, "%");157 addRangeControl("positionHalfPower", 0, 100, "%");158 addRangeControl("minimumRegen", 0, 100, "%");159 addRangeControl("maximumRegen", 0, 100, "%");...

Full Screen

Full Screen

TT Library.js

Source:TT Library.js Github

copy

Full Screen

1module.exports = {2 BodyPartToArmorPart: function(str) {3 str = str.toLowerCase();4 switch (str) {5 case "head": return "Helmet"; 6 case "body": return "Cuirass"; 7 case "hand": return "Gauntlets"; 8 case "feet": return "Boots"; 9 default: return str;10 }11 },12 GetSetFromEditorID: function(str) {13 return GetTextBetween(str, '_');14 },15 GetBodyPartFromEditorID: function(str) {16 str = str.slice(str.indexOf('_') + 1);17 const bodyPart = GetTextBetween(str, '_');18 if (bodyPart === "") {19 return str.slice(str.indexOf('_') + 1);20 }21 return bodyPart;22 },23 GetArmorPart: function(armor) {24 if (xelib.HasKeyword(armor, "ArmorBoots")) {25 return "Boots";26 }27 else if (xelib.HasKeyword(armor, "ArmorCuirass")) {28 return "Cuirass";29 }30 else if (xelib.HasKeyword(armor, "ArmorGauntlets")) {31 return "Gauntlets";32 }33 else if (xelib.HasKeyword(armor, "ArmorHelmet")) {34 return "Helmet";35 }36 else if (xelib.HasKeyword(armor, "ArmorShield")) {37 return "Shield";38 }39 else {40 return "";41 }42 },43 GetRecord: function(file, formID) {44 const loadOrderFormID = (xelib.GetFileLoadOrder(file) << 24) + formID;45 return xelib.GetRecord(0, loadOrderFormID);46 },47 GetWeaponType: function(weapon) {48 if (xelib.HasKeyword(weapon, "WeapTypeBattleaxe")) {49 return "Battleaxe";50 }51 else if (xelib.HasKeyword(weapon, "WeapTypeBow")) {52 return "Bow";53 }54 else if (xelib.HasKeyword(weapon, "WeapTypeDagger")) {55 return "Dagger";56 }57 else if (xelib.HasKeyword(weapon, "WeapTypeGreatsword")) {58 return "Greatsword";59 }60 else if (xelib.HasKeyword(weapon, "WeapTypeMace")) {61 return "Mace";62 }63 else if (xelib.HasKeyword(weapon, "WeapTypeSword")) {64 return "Sword";65 }66 else if (xelib.HasKeyword(weapon, "WeapTypeWarAxe")) {67 return "WarAxe";68 }69 else if (xelib.HasKeyword(weapon, "WeapTypeWarhammer")) {70 return "Warhammer";71 }72 else {73 return "";74 }75 },76 GetCriticalDamage: function(record) {77 return xelib.GetUIntValue(record, "CRDT\\Damage");78 },79 SetCriticalDamage: function(record, value) {80 return xelib.SetUIntValue(record, "CRDT\\Damage", value);81 },82 GetWeaponSpeed: function(record) {83 return xelib.GetFloatValue(record, "DNAM\\Speed");84 },85 SetWeaponSpeed: function(record, value) {86 return xelib.SetFloatValue(record, "DNAM\\Speed", value);87 },88 GetWeaponReach: function(record) {89 return xelib.GetFloatValue(record, "DNAM\\Reach");90 },91 SetWeaponReach: function(record, value) {92 return xelib.SetFloatValue(record, "DNAM\\Reach", value);93 },94 GetWeaponStagger: function(record) {95 return xelib.GetFloatValue(record, "DNAM\\Stagger");96 },97 SetWeaponStagger: function(record, value) {98 return xelib.SetFloatValue(record, "DNAM\\Stagger", value);99 },100 GetActorSkill: function(npc, skill) {101 skill = skill.toLowerCase();102 switch (skill) {103 case "alchemy": return xelib.GetIntValue(npc, "DNAM\\Skill Values\\[10]");104 case "alteration": return xelib.GetIntValue(npc, "DNAM\\Skill Values\\[12]");105 case "block": return xelib.GetIntValue(npc, "DNAM\\Skill Values\\[3]");106 case "conjuration": return xelib.GetIntValue(npc, "DNAM\\Skill Values\\[13]");107 case "destruction": return xelib.GetIntValue(npc, "DNAM\\Skill Values\\[14]");108 case "enchanting": return xelib.GetIntValue(npc, "DNAM\\Skill Values\\[17]");109 case "light armor": return xelib.GetIntValue(npc, "DNAM\\Skill Values\\[6]");110 case "heavy armor": return xelib.GetIntValue(npc, "DNAM\\Skill Values\\[5]");111 case "illusion": return xelib.GetIntValue(npc, "DNAM\\Skill Values\\[15]");112 case "lockpicking": return xelib.GetIntValue(npc, "DNAM\\Skill Values\\[8]");113 case "archery": return xelib.GetIntValue(npc, "DNAM\\Skill Values\\[2]");114 case "one-handed": return xelib.GetIntValue(npc, "DNAM\\Skill Values\\[0]");115 case "pickpocket": return xelib.GetIntValue(npc, "DNAM\\Skill Values\\[7]");116 case "restoration": return xelib.GetIntValue(npc, "DNAM\\Skill Values\\[16]");117 case "smithing": return xelib.GetIntValue(npc, "DNAM\\Skill Values\\[4]");118 case "sneak": return xelib.GetIntValue(npc, "DNAM\\Skill Values\\[9]");119 case "speech": return xelib.GetIntValue(npc, "DNAM\\Skill Values\\[11]");120 case "two-handed": return xelib.GetIntValue(npc, "DNAM\\Skill Values\\[1]");121 default: return -1;122 }123 },124 GetPerkRequiredSkill: function(perk, skill) {125 // Assumes the perk has at most one base actor value condition126 // Should hold for any playable perk because the perk menu makes the same assumption127 const condition = xelib.GetCondition(perk, "GetBaseActorValue");128 if (condition === 0) {129 return 0;130 }131 if (xelib.GetValue(condition, "CTDA\\Actor Value") !== skill) {132 return -1;133 }134 if (xelib.GetValue(condition, "CTDA\\Type") !== "11000000") {135 return -1;136 }137 return xelib.GetIntValue(condition, "CTDA\\Comparison Value");138 },139 InheritsSpellList: function(npc) {140 return xelib.HasElement(npc, "TPLT - Template") && xelib.GetFlag(npc, "ACBS\\Template Flags", "Use Spell List");141 },142 IsPlayable: function(record) {143 if (xelib.Signature(record) === "ARMO") {144 return !xelib.GetRecordFlag(record, "Non-Playable") &&145 (!xelib.HasElement(record, "BODT\\General Flags") || !xelib.GetFlag(record, "BODT\\General Flags", "(ARMO)Non-Playable")) &&146 (!xelib.HasElement(record, "BOD2\\General Flags") || !xelib.GetFlag(record, "BOD2\\General Flags", "(ARMO)Non-Playable"));147 }148 else if (xelib.Signature(record === "WEAP")) {149 return !xelib.GetRecordFlag(record, "Non-Playable") && !xelib.GetFlag(record, "DNAM\\Flags", "Non-playable");150 }151 else {152 return !xelib.GetRecordFlag(record, "Non-Playable");153 }154 }155};156function GetTextBetween(str, delimiter) {157 let firstIndex = -1;158 let secondIndex = -1;159 for (let i = 0; i < str.length; i++) {160 if (str.charAt(i) === delimiter) {161 if (firstIndex === -1) {162 firstIndex = i;163 }164 else if (secondIndex === -1) {165 secondIndex = i;166 }167 }168 }169 if (firstIndex === -1 || secondIndex === -1) {170 return "";171 }172 return str.substring(firstIndex + 1, secondIndex);...

Full Screen

Full Screen

BukuWarung.js

Source:BukuWarung.js Github

copy

Full Screen

...58 WrapperInteger suffixSum = new WrapperInteger(0);59 WrapperInteger end = new WrapperInteger(-1);60 boolean isPrefixMagical = checkMagical(wrapperI, wrapperJ, prefixSum, list);61 boolean isSuffixMagical = checkMagical(wrapperJ, end, suffixSum, list);62 if (isPrefixMagical && isSuffixMagical && suffixSum.getIntValue() > prefixSum.getIntValue()) {63 StringBuilder stringBuilder = new StringBuilder();64 String tempStr = stringBuilder.append(binString.substring(0, wrapperI.getIntValue()))65 .append(binString.substring(wrapperJ.getIntValue(), end.getIntValue()))66 .append(binString.substring(wrapperI.getIntValue(), wrapperJ.getIntValue() - 1)).toString();67 if (end.getIntValue() < length) {68 tempStr = stringBuilder.append(binString.substring(end.getIntValue())).toString();69 }70 binString = tempStr;71 }72 }73 }74 return binString;75}76 77 private static boolean checkMagical(WrapperInteger start, WrapperInteger end,78 WrapperInteger sum,79 List < Integer > list){80 if (end.getIntValue() == -1) {81 for (int i = start.getIntValue() + 1; i < list.size(); i++) {82 WrapperInteger tempWrapper = new WrapperInteger(i);83 if (checkMagical(start, tempWrapper, sum, list)) {84 end.setIntValue(i);85 return true;86 }87 }88 return false;89 }90 int check = 0;91 int counter = end.getIntValue() - start.getIntValue();92 for (int i = start.getIntValue(); i < end.getIntValue(); i++) {93 check = check + list.get(i);94 if (list.get(i).equals(1)) {95 sum.setIntValue((int)(sum.getIntValue() + Math.pow(2, counter)));96 }97 counter--;98 if (check < 0) {99 return false;100 }101 }102 return check == 0;103}104private static class WrapperInteger {105 private int intValue;106 public WrapperInteger(int intValue) {107 this.intValue = intValue;108 }109 public int getIntValue() {110 return intValue;111 }112 public void setIntValue(int intValue) {113 this.intValue = intValue;114 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My first test', async t => {3 .typeText('#developer-name', 'John Smith')4 .click('#submit-button');5 const articleHeader = await Selector('.result-content').find('h1');6 let headerText = await articleHeader.innerText;7});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My first test', async t => {3 .typeText('#developer-name', 'John Smith')4 .click('#tried-test-cafe')5 .click(Selector('label').withText('JavaScript API'))6 .click('#submit-button');7});8import { Selector } from 'testcafe';9test('My first test', async t => {10 .typeText('#developer-name', 'John Smith')11 .click('#tried-test-cafe')12 .click(Selector('label').withText('JavaScript API'))13 .click('#submit-button');14});15import { Selector } from 'testcafe';16test('My first test', async t => {17 .typeText('#developer-name', 'John Smith')18 .click('#tried-test-cafe')19 .click(Selector('label').withText('JavaScript API'))20 .click('#submit-button');21});22import { Selector } from 'testcafe';23test('My first test', async t => {24 .typeText('#developer-name', 'John Smith')25 .click('#tried-test-cafe')26 .click(Selector('label').withText('JavaScript API'))27 .click('#submit-button');28});29import { Selector } from 'testcafe';30test('My first test', async t => {31 .typeText('#developer-name', 'John Smith')32 .click('#tried-test-cafe')33 .click(Selector('label').withText('JavaScript API'))34 .click('#submit-button');35});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { ClientFunction } from 'testcafe';2test('My first test', async t => {3 const getIntValue = ClientFunction(() => {4 return window.getIntValue();5 });6 const intValue = await getIntValue();7 .typeText('#developer-name', 'John Smith')8 .click('#windows')9 .click('#tried-test-cafe')10 .click(`[value="${intValue}"]`)11 .click('#submit-button');12});13 function getIntValue() {14 return 2;15 }16 window.getIntValue = getIntValue;

Full Screen

Using AI Code Generation

copy

Full Screen

1import { ClientFunction } from 'testcafe';2test('My test', async t => {3 const getIntValue = ClientFunction(() => {4 return 5;5 });6 const intValue = await getIntValue();7 console.log(intValue);8});9import { ClientFunction } from 'testcafe';10const getVarValue = ClientFunction(() => {11 return window.testVar;12});13const varValue = await getVarValue();14console.log(varValue);15test('My test', async t => {16 .click('#myButton')17 .click('#myButton');18});19Selector('div').withText('My text')20import { ClientFunction } from 'testcafe';21const getVarValue = ClientFunction(() => {22 return window.testVar;23});24const varValue = await getVarValue();25console.log(varValue);

Full Screen

Using AI Code Generation

copy

Full Screen

1import { ClientFunction } from 'testcafe';2const getIntValue = ClientFunction(() => {3 return window.getIntValue();4});5test('My first test', async t => {6 .expect(getIntValue()).eql(1);7});8 window.getIntValue = function() {9 return 1;10 };

Full Screen

Using AI Code Generation

copy

Full Screen

1const TestcafeHelper = require('testcafe-helper');2const testcafeHelper = new TestcafeHelper();3console.log(testcafeHelper.getIntValue('1234'));4console.log(testcafeHelper.getFloatValue('1234.56'));5console.log(testcafeHelper.getBooleanValue('true'));6console.log(testcafeHelper.getArrayValue('["a", "b", "c"]'));7console.log(testcafeHelper.getObjectValue('{"a": "b", "c": "d"}'));8console.log(testcafeHelper.getJsonValue('{"a": "b", "c": "d"}'));9console.log(testcafeHelper.getJsonValue('{"a": "b", "c": "d"}'));10console.log(testcafeHelper.getJsonValue('{"a": "b", "c": "d"}'));11console.log(testcafeHelper.getJsonValue('{"a": "b", "c": "d"}'));12console.log(testcafeHelper.getJsonValue('{"a": "b", "c": "d"}'));13console.log(testcafeHelper.getJsonValue('{"a": "b", "c": "d"}'));14console.log(testcafeHelper.getJsonValue('{"a": "b", "c": "d"}'));15console.log(testcafeHelper.getJsonValue('{"a": "b", "c": "d"}'));16console.log(testcafeHelper.getJsonValue('{"a": "b", "c": "d"}'));

Full Screen

Using AI Code Generation

copy

Full Screen

1var testcafe = require('testcafe');2var testcafeObj = new testcafe();3testcafeObj.getIntValue("1");4var Testcafe = function() {5 this.getIntValue = function(value) {6 return parseInt(value);7 }8}9module.exports = Testcafe;

Full Screen

Using AI Code Generation

copy

Full Screen

1I.seeInField(this.testcafeHelper.getIntValue(1), 1);2I.seeInField(this.testcafeHelper.getIntValue(2), 2);3I.seeInField(this.testcafeHelper.getFloatValue(1.1), 1.1);4I.seeInField(this.testcafeHelper.getFloatValue(2.2), 2.2);5I.seeInField(this.testcafeHelper.getDoubleValue(1.11), 1.11);6I.seeInField(this.testcafeHelper.getDoubleValue(2.22), 2.22);7I.seeInField(this.testcafeHelper.getLongValue(1111111111), 1111111111);8I.seeInField(this.testcafeHelper.getLongValue(2222222222), 2222222222);9I.seeInField(this.testcafeHelper.getBooleanValue(true), true);10I.seeInField(this.testcafeHelper.getBooleanValue(false), false);11I.seeInField(this.testcafeHelper.getJsonValue({a:1, b:2}), {a:1, b:2});12I.seeInField(this.testcafeHelper.getJsonValue({a:1, b:2, c:3}), {a:1, b:2, c:3});13I.seeInField(this.testcafeHelper.getArrayValue([1, 2, 3]), [1, 2, 3]);14I.seeInField(this.testcafeHelper.getArrayValue([1, 2, 3, 4]), [1, 2, 3, 4]);15I.seeInField(this.testcafeHelper.getDateTimeValue("2018-07-11T05:00:00.000Z"), "2018-07-11T05:00:00.000Z");16I.seeInField(this.testcafeHelper.getDateTimeValue

Full Screen

Using AI Code Generation

copy

Full Screen

1var Testcafe = require('testcafe');2var testcafe = new Testcafe();3testcafe.getIntValue(2, '1', function(err, result){4 if(err){5 console.log(err);6 }else{7 console.log(result);8 }9});10var Testcafe = require('./testcafe');11var Testcafe = require('./testcafe');12var Testcafe = require('./testcafe');13var Testcafe = require('./testcafe');14var Testcafe = require('./testcafe');15var Testcafe = require('./testcafe');16var Testcafe = require('./testcafe');17var Testcafe = require('./testcafe');18var Testcafe = require('./testcafe');

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Testcafe automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful