Best Python code snippet using playwright-python
tiled_map.js
Source:tiled_map.js
1__resources__["/__builtin__/tiled_map.js"] = {meta: {mimetype: "application/javascript"}, data: function(exports, require, module, __filename, __dirname) {2var xmlLoad = require('xmlload').xmlLoad;3var gzip = require('gzip');4var helper = require("helper");567function buildMap(filename)8{9 var xmlDoc = xmlLoad(filename);10 if(xmlDoc != null)11 return node2Map(filename, xmlDoc.documentElement);12}1314function node2Map(filename, node)15{16 var i, tmp, filepath;17 18 if(node == null || node.tagName != "map" || node.attributes == null)19 {20 return;21 }22 var map = new Map();23 i = filename.lastIndexOf('/');24 if(i > 0)25 {26 map.filepath = filename.substr(0, i + 1);27 }28 for(i = 0; i < node.attributes.length; ++i)29 {30 switch(node.attributes[i].name)31 {32 case 'width':33 case 'height':34 case 'tilewidth':35 case 'tileheight':36 tmp = parseInt(node.attributes[i].nodeValue);37 if(isNaN(tmp))38 return;39 map[node.attributes[i].name] = tmp;40 break;41 case 'version':42 case 'orientation': 43 map[node.attributes[i].name] = node.attributes[i].nodeValue;44 break;45 default:46 break;47 }48 }49 50 var sibs = node.firstChild;51 52 for(; sibs!= null; sibs = sibs.nextSibling)53 {54 if(sibs.nodeType != 1)55 continue;56 if(sibs.tagName == "properties")57 {58 tmp = node2Props(sibs);59 if(tmp != null)60 {61 map.properties = tmp;62 }63 }64 if(sibs.tagName == "tileset")65 {66 tmp = node2Tileset(sibs, map);67 if(tmp != null)68 {69 map.tilesets.push(tmp);70 }71 }72 else if(sibs.tagName == "layer")73 {74 tmp = node2Layer(sibs, map);75 if(tmp != null)76 {77 map.layers.push(tmp);78 }79 }80 else if(sibs.tagName == "objectgroup")81 {82 tmp = node2Objectgroup(sibs);83 if(tmp != null)84 {85 map.objectgroups.push(tmp);86 }87 }88 }89 90 if(map.orientation == "orthogonal")91 {92 map.widthPx = map.width * map.tilewidth;93 map.heightPx = map.height * map.tileheight;94 }95 else if(map.orientation == "isometric")96 {97 map.widthPx = (map.width + map.height) * map.tilewidth / 2;98 map.heightPx = (map.width + map.height) * map.tileheight / 2;99 }100 else101 return;102 103 tmp = map.width * map.height;104 map.drawImagetiles = new Array(tmp);105 for(i = 0; i < tmp; ++i)106 {107 map.drawImagetiles[i] = new Array();108 }109 110 return map;111}112113function getProperty(name)114{115 return this[name];116}117118function getExtendedProperty(name)119{120 if(null == this.properties)121 return;122 return this.properties[name];123}124125function getExtendedPropertyLength()126{127 if(null == this.properties)128 return;129 return this.properties.length;130}131132function Map()133{134 this.width;135 this.height;136 this.tileWidth;137 this.tileHeight;138 this.filepath='';139 this.version;140 this.orientation;141 this.tilesets = new Array();142 this.maxTilewidth = 0;143 this.maxTileheight = 0;144 this.layers = new Array();145 this.objectgroups = new Array();146 this.tiles = new Array();147 /*Ӱ��ÿ��maptile���Ƶ�image tiles. 148 drawImagetiles �Ǹ�array������ÿ���ŵĶ��� PaintTile array.*/149 this.drawImagetiles;150}151152function PaintTile(layerIndex, row, col, tile)153{154 this.layerIndex = layerIndex;155 this.row = row;156 this.col = col;157 this.tile = tile;158}159160PaintTile.prototype.paint = function (context, paintCanvasStartX, paintCanvasStartY, paintCanvasW, paintCanvasH,161 mapStartX, mapStartY)162{163 var tile = this.tile, map = this.tile.tileset.map;164 var tileTopLeftX, tileTopLeftY;165 var tileCanvasX, tileCanvasY;166 var paintTileTopLeftX, paintTileTopLeftY,paintTileBottomRightX, paintTileBottomRightY;167168 tileTopLeftX = this.col * map.tilewidth;169 tileTopLeftY = this.row * map.tileheight - (tile.tileset.tileheight - map.tileheight);170 //��map����ϵ�ϵ�����ת����canvas����ϵ������171 tileCanvasX = tileTopLeftX - mapStartX + paintCanvasStartX;172 tileCanvasY = tileTopLeftY - mapStartY + paintCanvasStartY;173 //�ж�tile�ľ��������Ƿ������ƾ��������ཻ174 paintTileTopLeftX = Math.max(tileCanvasX, paintCanvasStartX);175 paintTileTopLeftY = Math.max(tileCanvasY, paintCanvasStartY);176 paintTileBottomRightX = Math.min(tileCanvasX + tile.tileset.tilewidth, paintCanvasStartX + map.rectWidth);177 paintTileBottomRightY = Math.min(tileCanvasY + tile.tileset.tileheight, paintCanvasStartY + map.rectHeight);178 if(paintTileTopLeftX < paintTileBottomRightX && paintTileTopLeftY < paintTileBottomRightY)179 {180 //�����ཻ181 tileOffsetX = paintTileTopLeftX - tileCanvasX;182 tileOffsetY = paintTileTopLeftY - tileCanvasY;183 tile.draw(context, paintTileTopLeftX, paintTileTopLeftY, paintTileBottomRightX - paintTileTopLeftX,184 paintTileBottomRightY - paintTileTopLeftY, tileOffsetX, tileOffsetY);185 }186}187188PaintTile.prototype.paintIso = function (context, paintCanvasStartX, paintCanvasStartY, paintCanvasW, paintCanvasH,189 mapStartX, mapStartY)190{191 var tile = this.tile;192193 tileTopLeftX = row * map.tilewidth;194 tileTopLeftY = mapRowStartY - (tile.tileset.tileheight - map.tileheight);195 //��map����ϵ�ϵ�����ת����canvas����ϵ������196 tileCanvasX = tileTopLeftX - map.mapStartX + map.canvasStartX;197 tileCanvasY = tileTopLeftY - map.mapStartY + map.canvasStartY;198 //�ж�tile�ľ��������Ƿ������ƾ��������ཻ199 paintTileTopLeftX = Math.max(tileCanvasX, map.canvasStartX);200 paintTileTopLeftY = Math.max(tileCanvasY, map.canvasStartY);201 paintTileBottomRightX = Math.min(tileCanvasX + tile.tileset.tilewidth, map.canvasStartX + map.rectWidth);202 paintTileBottomRightY = Math.min(tileCanvasY + tile.tileset.tileheight, map.canvasStartY + map.rectHeight);203 if(paintTileTopLeftX < paintTileBottomRightX && paintTileTopLeftY < paintTileBottomRightY)204 {205 //�����ཻ206 tileOffsetX = paintTileTopLeftX - tileCanvasX;207 tileOffsetY = paintTileTopLeftY - tileCanvasY;208 tile.draw(context, paintTileTopLeftX, paintTileTopLeftY, paintTileBottomRightX - paintTileTopLeftX,209 paintTileBottomRightY - paintTileTopLeftY, tileOffsetX, tileOffsetY);210 }211}212213/*214Map.prototype.paint = function (context, mapStartX, mapStartY)215{216 if(null == context)217 return;218219 this.mapStartX = mapStartX;220 this.mapStartY = mapStartY;221 this.canvasStartX = 0;222 this.canvasStartY = 0;223 this.paintEx(context, 0, 0, context.width, context.height,224 mapStartX, mapStartY, this.widthPx - mapStartX, this.heightPx - mapStartY);225}226*/227228229Map.prototype.paint = function (context, canvasStartX, canvasStartY, paintCanvasWidth, paintCanvasHeight,230 mapStartX, mapStartY, paintMapWidth, paintMapHeight)231{232 233 if(null == context)234 return;235 if(paintCanvasWidth < 0 || paintCanvasHeight < 0)236 return;237 if(mapStartX >= this.widthPx || mapStartY >= this.heightPx)238 return;239 240 this.canvasStartX = canvasStartX;241 this.canvasStartY = canvasStartY;242 this.mapStartX = mapStartX;243 this.mapStartY = mapStartY;244 if(canvasStartX + paintCanvasWidth >= context.width)245 this.paintCanvasWidth = context.width - canvasStartX;246 else247 this.paintCanvasWidth = paintCanvasWidth;248 if(canvasStartY + paintCanvasHeight >= context.height)249 this.paintCanvasHeight = context.height - canvasStartY;250 else251 this.paintCanvasHeight = paintCanvasHeight;252 if(paintMapWidth + mapStartX >= this.widthPx)253 this.paintMapWidth = this.widthPx - mapStartX;254 else255 this.paintMapWidth = paintMapWidth;256 if(paintMapHeight + mapStartY >= this.heightPx)257 this.paintMapHeight = this.heightPx - mapStartY;258 else259 this.paintMapHeight = paintMapHeight;260 this.rectWidth = Math.min(this.paintCanvasWidth, this.paintMapWidth);261 this.rectHeight = Math.min(this.paintCanvasHeight, this.paintMapHeight);262 263 this.rePaint(context);264}265266Map.prototype.rePaint = function(context)267{268 var i, layer, context;269 270 if(null == context)271 return;272 273 for(i = 0; i < this.layers.length; ++i)274 {275 layer = this.layers[i];276 if(null == layer)277 return;278 if(layer.visible)279 {280 if(this.orientation == "orthogonal")281 {282 layer.paint(context);283 }284 else if(this.orientation == "isometric")285 {286 layer.paintIso(context);287 }288 else289 return;290 }291 }292}293294Map.prototype.scanPaintTile = function ()295{296 var i;297 /*298 if()299 for(i = 0; i < this.layers.length; ++i)300 {301 302 }*/303}304305/*306 �ƶ�����paintcanvas��paintmap��307 �� paintmap �ĸ߿����� paintcanvas �ĸ߿�ʱ��paintmap�����ƶ���mapStartPointX += dx�� mapStartPointY += dy��308 �� paintmap �ĸ߿�С�� paintcanvas �ĸ߿�ʱ������paintmap��paintcanvas�ڲ��ƶ���309*/310Map.prototype.move = function (context, dx, dy)311{312 var canvasStartX, canvasStartY;313 var mapStartX, mapStartY;314 var startX, startY;315 var prePaintCanvasH = this.paintCanvasWidth, prePaintCanvasW = this.paintCanvasHeight;316 317 if(null == context)318 return;319 320 if(isNaN(dx))321 dx = 0;322 if(isNaN(dy))323 dy = 0;324 325 function getMovePoint(move, start, smallLen, largeLen, isCanvasLarger)326 {327 if(isCanvasLarger)328 {329 if(move < 0)330 {331 return -Math.min(Math.abs(move), start);332 }333 else if(move > 0)334 {335 if(largeLen - smallLen - start >= move)336 return move;337 else if(largeLen - smallLen - start > 0)338 return largeLen - smallLen - start 339 }340 }341 else342 {343 if(move > 0)344 {345 return Math.min(move, start);346 }347 else if(move < 0)348 {349 if(largeLen - smallLen - start > Math.abs(move))350 return move;351 else352 return -(largeLen - smallLen - start);353 }354 }355 return 0;356 }357 //����x y�߽�ֵ�������������ı��ƶ����߽�ʱ���������ơ�358 if(this.widthPx >= this.paintCanvasWidth)359 dx = getMovePoint(dx, this.mapStartX, this.paintCanvasWidth, this.widthPx, false);360 else361 dx = getMovePoint(dx, this.canvasStartX, this.widthPx, this.paintCanvasWidth, true);362 363 if(this.heightPx >= this.paintCanvasHeight)364 dy = getMovePoint(dy, this.mapStartY, this.paintCanvasHeight, this.heightPx, false);365 else366 dy = getMovePoint(dy, this.canvasStartY, this.heightPx, this.paintCanvasHeight, true);367 368 if(dx == 0 && dy == 0)369 return;370 371 /////////////////////////////////////////////////////372373 if(this.widthPx >= this.paintCanvasWidth)374 {375 canvasStartX = this.canvasStartX;376 mapStartX = this.mapStartX - dx;377 }378 else379 {380 canvasStartX = this.canvasStartX + dx;381 mapStartX = this.mapStartX;382 }383 if(this.heightPx >= this.paintCanvasHeight)384 {385 canvasStartY = this.canvasStartY;386 mapStartY = this.mapStartY - dy;387 }388 else389 {390 canvasStartY = this.canvasStartY + dy;391 mapStartY = this.mapStartY;392 }393 394 this.paint(context, canvasStartX, canvasStartY, this.paintCanvasWidth, this.paintCanvasHeight,395 mapStartX, mapStartY, this.paintCanvasWidth, this.paintCanvasHeight);396 397 this.mapStartX = mapStartX;398 this.mapStartY = mapStartY;399 this.canvasStartX = canvasStartX;400 this.canvasStartY = canvasStartY;401 this.paintCanvasWidth = prePaintCanvasH;402 this.paintCanvasHeight = prePaintCanvasW;403 404 /////////////////////////////////////////////////////405 406 /*407 var absX, absY;408 //var tileOffsetX, tileOffsetY;409 410 absX = Math.abs(x);411 absY = Math.abs(y);412 //tileOffsetX = mapStartX - this.tilewidth * parseInt(mapStartX / this.tilewidth);413 //tileOffsetY = mapStartY - this.tileheight * parseInt(mapStartY / this.tileheight);414 if(absX < this.paintCanvasWidth && absY < this.paintCanvasHeight)415 {416 var input;417 var getW, getH;418 var preMapStartX, preMapStartY;419 var preCanvasStartX, canvasStartY;420 var prePaintCanvasW, prePaintCanvasH;421 422 canvasStartX = x < 0 ? this.canvasStartX + absX : this.canvasStartX;423 canvasStartY = y < 0 ? this.canvasStartY + absY : this.canvasStartY;424 cutW = this.paintCanvasWidth - absX;425 cutH = this.paintCanvasHeight - absY;426 input = context.getImageData(canvasStartX, canvasStartY, cutW, cutH);427 canvasStartX = x > 0 ? this.canvasStartX + x : this.canvasStartX;428 canvasStartY = y > 0 ? this.canvasStartY + y : this.canvasStartY;429 context.putImageData(input, canvasStartX, canvasStartY);430431 if( x != 0)432 {433 if(this.widthPx > this.paintCanvasWidth)434 {435 preMapStartX = this.mapStartX;436 preMapStartY = this.mapStartY;437 preCanvasStartX = this.canvasStartX;438 preCanvasStartY = this.canvasStartY;439 prePaintCanvasW = this.paintCanvasWidth;440 prePaintCanvasH = this.paintCanvasHeight;441 canvasStartY = this.canvasStartY;442 if(x > 0)443 {444 canvasStartX = this.canvasStartX;445 mapStartX = this.mapStartX - x;446 }447 else448 {449 canvasStartX = this.paintCanvasWidth + this.canvasStartX + x;450 mapStartX = this.mapStartX + this.paintCanvasWidth;451 }452 this.paintEx(canvas, canvasStartX, canvasStartY, absX, this.paintCanvasHeight,453 mapStartX, this.mapStartY, absX, this.paintCanvasHeight);454 this.mapStartX = preMapStartX - x;455 this.mapStartY = preMapStartY;456 this.canvasStartX = preCanvasStartX;457 this.canvasStartY = preCanvasStartY;458 this.paintCanvasWidth = prePaintCanvasW;459 this.paintCanvasHeight = prePaintCanvasH;460 }461 else if(this.widthPx < this.paintCanvasWidth)462 {463 this.canvasStartX += x;464 }465 }466 if(y != 0)467 {468 if(this.heightPx > this.paintCanvasHeight)469 {470 preMapStartX = this.mapStartX;471 preMapStartY = this.mapStartY;472 preCanvasStartX = this.canvasStartX;473 preCanvasStartY = this.canvasStartY;474 prePaintCanvasW = this.paintCanvasWidth;475 prePaintCanvasH = this.paintCanvasHeight;476 canvasStartX = x > 0 ? this.canvasStartX + x : this.canvasStartX;477 if(y > 0)478 {479 canvasStartY = this.canvasStartY;480 mapStartY = this.mapStartY - y;481 }482 else483 {484 canvasStartY = this.paintCanvasHeight + this.canvasStartY + y;485 mapStartY = this.mapStartY + this.paintCanvasHeight;486 }487 488 this.paintEx(canvas, canvasStartX, canvasStartY, this.paintCanvasWidth - absX, absY,489 this.mapStartX, mapStartY, this.paintCanvasWidth - absX, absY);490 this.mapStartX = preMapStartX;491 this.mapStartY = preMapStartY - y;492 this.canvasStartX = preCanvasStartX;493 this.canvasStartY = preCanvasStartY;494 this.paintCanvasWidth = prePaintCanvasW;495 this.paintCanvasHeight = prePaintCanvasH;496 }497 else if(this.heightPx < this.paintCanvasHeight)498 {499 this.canvasStartY += y;500 }501 }502 }*/503}504505Map.prototype.getProperty = getProperty;506Map.prototype.getExtendedProperty = getExtendedProperty;507Map.prototype.getExtendedPropertyLength = getExtendedPropertyLength;508509Map.prototype.getTilesetByIndex = function (index)510{511 return this.tilesets[index];512}513Map.prototype.getTilesetByName = function (name)514{515 for(var i = 0; i < this.tilesets.length; ++i)516 if(this.tilesets[i].name == name)517 return this.tilesets[i];518}519Map.prototype.getTilesetLength = function ()520{521 return this.tilesets.length;522}523Map.prototype.getTileByGlobalId = function (id)524{525 return this.tiles[id-1];526}527Map.prototype.getTileByLayerIndexAndPoint = function (layerIndex, x, y)528{529 var layer = this.getLayerByIndex(layerIndex);530 531 if(null == layer)532 return;533 return layer.getTileByPoint(x, y);534}535Map.prototype.getTilePropertiesByLayerIndexAndPoint = function (layerIndex, x, y)536{537 var layer = this.getLayerByIndex(layerIndex);538 var tile;539 540 if(null == layer)541 return;542 tile = layer.getTileByPoint(x, y);543 if(null == tile)544 return;545 return tile.properties;546}547Map.prototype.getTileRowColByPoint = function (x, y)548{549 var row, col;550 var rx, ry;551 552 if(this.orientation == "orthogonal")553 {554 row = Math.floor(x / this.tilewidth);555 col = Math.floor(y / this.tileheight);556 }557 else if(this.orientation == "isometric")558 {559 /*560 (rx, ry) ����x��y�����ڵ�ͼ����������ֵ��561 */562 rx = x - (this.height*this.tilewidth/2);563 ry = y;564 row = rx/this.tilewidth + ry/this.tileheight;565 col = -rx/this.tilewidth + ry/this.tileheight;566 }567 if(row >= 0 && col >= 0 && row < this.width && col < this.height)568 {569 row = Math.ceil(row);570 col = Math.ceil(col);571 return {row:row, col:col};572 }573}574Map.prototype.getTileByLayerIndexAndRowCol = function (layerIndex, row, col)575{576 var layer = this.getLayerByIndex(layerIndex);577 578 if(null == layer)579 return;580 return layer.getTileByRowCol(row, col);581}582Map.prototype.getLayerByIndex = function (index)583{584 if(index < 0 || index >= this.layers.length)585 return;586 587 return this.layers[index];588}589Map.prototype.getLayerByName = function (name)590{591 for(var i = 0; i < this.layers.length; ++i)592 if(this.layers[i].name == name)593 return this.layers[i];594}595Map.prototype.getLayerLength = function ()596{597 return this.layers.length;598}599 600Map.prototype.getObjectgroupByIndex = function (index)601{602 return this.objectgroups[index];603}604Map.prototype.getObjectgroupByName = function (name)605{606 for(var i = 0; i < this.objectgroups.length; ++i)607 if(this.objectgroups[i].name == name)608 return this.objectgroups[i];609}610Map.prototype.getObjectgroupLength = function ()611{612 return this.objectgroups.length;613}614Map.prototype.isReady = function ()615{616 var i;617 618 for(i = 0; i < this.tilesets.length; ++i)619 {620 if(this.tilesets[i].image.docImage.loaded == false || this.tilesets[i].image.docImage.loaded == null)621 return false;622 }623 return true;624}625626function node2Tileset(node, map)627{628 var i = 0;629 var tileset, tmp;630 631 if(node == null || node.attributes == null)632 {633 return;634 }635 636 tileset = new Tileset(map);637 638 for(; i < node.attributes.length; ++i)639 {640 switch(node.attributes[i].name)641 {642 case 'firstgid':643 case 'tilewidth':644 case 'tileheight':645 case 'spacing':646 case 'margin':647 tmp = parseInt(node.attributes[i].nodeValue);648 if(isNaN(tmp))649 return;650 tileset[node.attributes[i].name] = tmp;651 if(node.attributes[i].name == 'tilewidth')652 {653 if(tmp > map.maxTileheight)654 map.maxTilewidth = tmp;655 }656 if(node.attributes[i].name == 'tileheight')657 {658 if(tmp > map.maxTileheight)659 map.maxTileheight = tmp;660 }661 break;662 case 'name':663 tileset.name = node.attributes[i].nodeValue;664 break;665 default:666 break;667 }668 }669 670 var children = node.childNodes;671 672 if(children == null)673 return;674 675 for(i = 0; i < children.length; ++i)676 {677 node = children[i];678 if(node.nodeType != 1)679 continue;680 if(node.tagName == 'image')681 {682 if(tileset.image != null)683 return;684 tmp = node2Image(tileset, node);685 if(tmp == null)686 return;687 tileset.image = tmp;688 tileset.xTileLength = Math.floor(tileset.image.width / tileset.tilewidth);689 tileset.yTileLength = Math.floor(tileset.image.height/ tileset.tileheight);690 }691 else if(node.tagName == 'tile')692 {693 tmp = node2Tile(node, tileset);694 if(null == tmp)695 return;696 tileset.tiles.push(tmp);697 }698 }699 700 var preTileLen = map.tiles.length;701 702 tmp = Math.floor((tileset.image.width - tileset.margin)/ (tileset.tilewidth + tileset.spacing)) * Math.floor((tileset.image.height-tileset.margin) / (tileset.tileheight + tileset.spacing));703 if(tmp < 1)704 return;705706 for(i = 0; i < tmp; ++i)707 {708 map.tiles[preTileLen + i] = new Tile(tileset);709 map.tiles[preTileLen + i].id = i;710 }711 712 for(i = 0; i < tileset.tiles.length; ++i)713 map.tiles[tileset.tiles[i].getGlobalId()-1] = tileset.tiles[i];714 715 return tileset;716}717718function Tileset(map)719{720 this.map = map;721 this.image;722 this.firstGid;723 this.name;724 this.tileWidth;725 this.tileHeight;726 this.spacing = 0;727 this.margin = 0;728 this.tiles = new Array();729}730Tileset.prototype.getProperty = getProperty;731Tileset.prototype.getExtendedProperty = getExtendedProperty;732Tileset.prototype.getExtendedPropertyLength = getExtendedPropertyLength;733Tileset.prototype.getImage = function ()734{735 return this.image;736}737Tileset.prototype.getTileByGlobalId = function (id)738{739 return this.map.tiles[id-1];740}741742function node2Layer(node, map)743{744 var i = 0;745 var layer, tmp;746 747 if(node == null || node.attributes == null)748 {749 return;750 }751 752 layer = new Layer(map);753 for(; i < node.attributes.length; ++i)754 {755 switch(node.attributes[i].name)756 {757 case 'name':758 layer.name = node.attributes[i].nodeValue;759 break;760 case 'width':761 case 'height':762 case 'visible':763 tmp = parseInt(node.attributes[i].nodeValue);764 if(isNaN(tmp))765 return;766 layer[node.attributes[i].name] = tmp;767 break;768 default:769 break;770 }771 }772 773 var children = node.childNodes;774 775 if(children == null)776 return;777778 for(i = 0; i < children.length; ++i)779 {780 node = children[i];781 if(node.nodeType != 1)782 continue;783 if(node.tagName == 'properties')784 {785 layer.properties = node2Props(node);786 }787 else if(node.tagName == 'data')788 {789 tmp = node2Data(node, layer);790 if(null == tmp)791 return;792 layer.data = tmp;793 }794 }795 796 return layer;797}798799function Layer(map)800{801 this.map = map;802 this.name;803 this.width;804 this.height;805 this.visible = true;806 //data object807 this.data;808}809Layer.prototype.getProperty = getProperty;810Layer.prototype.getExtendedProperty = getExtendedProperty;811Layer.prototype.getExtendedPropertyLength = getExtendedPropertyLength;812Layer.prototype.getTileByPoint = function (x, y)813{814 var row, col;815 var map = this.map;816 var index = map.getTileRowColByPoint(x, y);817 818 if(index != null)819 {820 row = index.row;821 col = index.col;822 if(this.data.reldata[row + col * this.width] > 0)823 return map.tiles[this.data.reldata[row + col * this.width]-1];824 }825}826Layer.prototype.getTileByRowCol = function (row, col)827{828 var map = this.map;829 830 if(this.data.reldata[row + col * this.width] > 0)831 return map.tiles[this.data.reldata[row + col * this.width]-1];832}833834Layer.prototype.paint = function(context)835{836 var map = this.map;837 var data = this.data.reldata;838 var tile, tileOffsetY, tileOffsetX;839 840 //map ����ϵ841 var row, col, startRow, startCol, endRow, endCol;842 var mapRowStartX = 0, mapRowStartY = 0;843 var tileTopLeftX, tileTopLeftY;844 845 //canvas ����ϵ846 var tileCanvasX, tileCanvasY;847 var paintTileTopLeftX, paintTileTopLeftY;848 var paintTileBottomRightX, paintTileBottomRightY;849 850 var tmp;851852/*853Ŀǰ��ͼ�ƶ�������canvas��transform���ã����Ʋ��������������ܲ������á�854�������жϲ�׼ȷ����Ϊcanvas����ϵ�Ѿ�transform���ˣ����Ե������㲻��ȷ����855��ΪĿǰֻ��������ͼȫ�����ơ�856*/ 857/* 858 startRow = Math.floor(map.mapStartX / this.map.tilewidth);859 startCol = Math.floor(map.mapStartY / this.map.tileheight);860 endRow = Math.ceil((map.mapStartX + map.rectWidth) / this.map.tilewidth);861 endCol = Math.ceil((map.mapStartY + map.rectHeight) / this.map.tileheight);862 if(map.maxTilewidth > map.tilewidth)863 {864 tmp = Math.ceil((map.maxTilewidth - map.tilewidth) / map.tilewidth);865 endRow += tmp;866 if(endRow > map.width - 1)867 endRow = map.width - 1;868 }869 if(map.maxTileheight > map.tileheight)870 {871 tmp = Math.ceil((map.maxTileheight - map.tileheight) / map.tileheight);872 startCol -= tmp;873 if(startCol < 0)874 startCol = 0;875 }876 877/*878 for(col = startCol; col <= endCol; ++col)879 {880 mapRowStartY = col * map.tileheight;881 var offset = col * this.width;882 for(row = startRow; row <= endRow; ++row)883 {884 tile = map.tiles[data[row + offset]-1];885 if(null != tile)886 {887 tileTopLeftX = row * map.tilewidth;888 tileTopLeftY = mapRowStartY - (tile.tileset.tileheight - map.tileheight);889 //��map����ϵ�ϵ�����ת����canvas����ϵ������890 tileCanvasX = tileTopLeftX - map.mapStartX + map.canvasStartX;891 tileCanvasY = tileTopLeftY - map.mapStartY + map.canvasStartY;892 //�ж�tile�ľ��������Ƿ������ƾ��������ཻ893 paintTileTopLeftX = Math.max(tileCanvasX, map.canvasStartX);894 paintTileTopLeftY = Math.max(tileCanvasY, map.canvasStartY);895 paintTileBottomRightX = Math.min(tileCanvasX + tile.tileset.tilewidth, map.canvasStartX + map.rectWidth);896 paintTileBottomRightY = Math.min(tileCanvasY + tile.tileset.tileheight, map.canvasStartY + map.rectHeight);897 if(paintTileTopLeftX < paintTileBottomRightX && paintTileTopLeftY < paintTileBottomRightY)898 {899 //�����ཻ900 tileOffsetX = paintTileTopLeftX - tileCanvasX;901 tileOffsetY = paintTileTopLeftY - tileCanvasY;902 tile.draw(context, paintTileTopLeftX, paintTileTopLeftY, paintTileBottomRightX - paintTileTopLeftX,903 paintTileBottomRightY - paintTileTopLeftY, tileOffsetX, tileOffsetY);904 }905 }906 }907 }908*/909 910 for(col = 0; col < map.height ; ++col)911 {912 mapRowStartY = col * map.tileheight;913 var offset = col * this.width;914 for(row = 0; row < map.width; ++row)915 {916 tile = map.tiles[data[row + offset]-1];917 if(null != tile)918 {919 tileTopLeftX = row * map.tilewidth;920 tileTopLeftY = mapRowStartY - (tile.tileset.tileheight - map.tileheight);921 //��map����ϵ�ϵ�����ת����canvas����ϵ������922 tileCanvasX = tileTopLeftX - map.mapStartX + map.canvasStartX;923 tileCanvasY = tileTopLeftY - map.mapStartY + map.canvasStartY;924 925 tile.draw(context, tileCanvasX, tileCanvasY, map.tilewidth, map.tileheight, 0, 0);926 }927 }928 }929}930931Layer.prototype.paintIso = function (context)932{933 var map = this.map;934 var data = this.data.reldata;935 var tile, tileOffsetY, tileOffsetX;936 937 //map ����ϵ938 var row, col/*, startRow, startCol, endRow, endCol*/;939 var mapTopX, mapTopY;940 var mapRowStartX, mapRowStartY;941 var tileTopLeftX, tileTopLeftY;942 943 //canvas ����ϵ944 var tileCanvasX, tileCanvasY;945 var paintTileTopLeftX, paintTileTopLeftY;946 var paintTileBottomRightX, paintTileBottomRightY;947 948/* 949 var tmp;950 951 //startRow ���Ͻǣ�startCol���Ͻǣ�endRow���½ǣ�endCol���½�952 startRow = Math.ceil((map.mapStartX - map.height*map.tilewidth/)/map.tilewidth + map.mapStartY/map.tileheight);953 startCol = Math.ceil((map.height*map.tilewidth/2 - (map.mapStartX + map.rectWidth))/map.tilewidth + map.mapStartY/map.tileheight);954 endRow = Math.ceil(((map.mapStartX + map.rectWidth) - map.height*map.tilewidth/)/map.tilewidth + (map.mapStartY+map.rectHeight)/map.tileheight);955 endCol = Math.ceil((map.height*map.tilewidth/2 - map.mapStartX)/map.tilewidth + (map.mapStartY + map.rectHeight)/map.tileheight);956 if(map.maxTilewidth > map.tilewidth)957 {958 tmp = Math.ceil((map.maxTilewidth - map.tilewidth) / map.tilewidth);959 startRow = startRow - tmp;960 }961 if(map.maxTileheight > map.tileheight)962 {963 tmp = Math.ceil((map.maxTileheight - map.tileheight) / map.tileheight);964 endCol = endCol + tmp;965 }966 */ 967 mapTopX = (this.height - 1) * map.tilewidth / 2;968 mapTopY = 0;969 970 /*971 for(col = 0; col < map.height; ++col)972 {973 mapRowStartX = mapTopX - col * map.tilewidth / 2;974 mapRowStartY = mapTopY + col * map.tileheight / 2;975 for(row = 0; row < map.width; ++row)976 {977 tile = map.tiles[data[row + col * this.width]-1];978 if(null != tile)979 {980 tileTopLeftX = mapRowStartX + row * map.tilewidth / 2;981 tileTopLeftY = mapRowStartY + row * map.tileheight / 2 - (tile.tileset.tileheight - map.tileheight);982 //��map����ϵ�ϵ�����ת����canvas����ϵ������983 tileCanvasX = tileTopLeftX - map.mapStartX + map.canvasStartX;984 tileCanvasY = tileTopLeftY - map.mapStartY + map.canvasStartY;985 //�ж�tile�ľ��������Ƿ������ƾ��������ཻ986 paintTileTopLeftX = Math.max(tileCanvasX, map.canvasStartX);987 paintTileTopLeftY = Math.max(tileCanvasY, map.canvasStartY);988 paintTileBottomRightX = Math.min(tileCanvasX + tile.tileset.tilewidth, map.canvasStartX + map.rectWidth);989 paintTileBottomRightY = Math.min(tileCanvasY + tile.tileset.tileheight, map.canvasStartY + map.rectHeight);990 if(paintTileTopLeftX < paintTileBottomRightX && paintTileTopLeftY < paintTileBottomRightY)991 {992 //�����ཻ993 tileOffsetX = paintTileTopLeftX - tileCanvasX;994 tileOffsetY = paintTileTopLeftY - tileCanvasY;995 tile.draw(context, paintTileTopLeftX, paintTileTopLeftY, paintTileBottomRightX - paintTileTopLeftX,996 paintTileBottomRightY - paintTileTopLeftY, tileOffsetX, tileOffsetY);997 }998 }999 }1000 }1001 */1002 for(col = 0; col < map.height; ++col)1003 {1004 mapRowStartX = mapTopX - col * map.tilewidth / 2;1005 mapRowStartY = mapTopY + col * map.tileheight / 2;1006 for(row = 0; row < map.width; ++row)1007 {1008 tile = map.tiles[data[row + col * this.width]-1];1009 if(null != tile)1010 {1011 tileTopLeftX = mapRowStartX + row * map.tilewidth / 2;1012 tileTopLeftY = mapRowStartY + row * map.tileheight / 2 - (tile.tileset.tileheight - map.tileheight);1013 //��map����ϵ�ϵ�����ת����canvas����ϵ������1014 tileCanvasX = tileTopLeftX - map.mapStartX + map.canvasStartX;1015 tileCanvasY = tileTopLeftY - map.mapStartY + map.canvasStartY;10161017 tileOffsetX = paintTileTopLeftX - tileCanvasX;1018 tileOffsetY = paintTileTopLeftY - tileCanvasY;1019 tile.draw(context, tileCanvasX, tileCanvasY, map.tilewidth, map.tileheight, 0, 0);1020 }1021 }1022 }1023}10241025Layer.prototype.scan = function (layerIndex)1026{1027 var map = this.map;1028 var idarray = this.data.reldata;1029 var i, j, tile, tileset;1030 var start, tmp;10311032 for(i = 0; i < map.height; ++i)1033 {1034 for(j = 0; j < map.width; ++j)1035 {1036 tile = map.getTileByGlobalId(idarray[i * map.width + j]);1037 tileset = tile.tileset;1038 map.drawImagetiles[i * map.width + j].push(new PaintTile(layerIndex, i, j, tile));1039 if(tileset.tilewidth > map.tilewidth)1040 {1041 tmp = Math.ceil((tileset.tilewidth - map.tilewidth) / map.tilewidth);1042 end = Math.min(j + tmp + 1, map.width);1043 for(w = j + 1; w <= end; ++w)1044 {1045 map.drawImagetiles[i * map.width + w].push(new PaintTile(layerIndex, i, w, tile));1046 }1047 }1048 if(tileset.tileheight > map.tileheight)1049 {1050 tmp = Math.ceil((tileset.tileheight - map.tileheight) / map.tileheight);1051 end = Math.max(i - tmp, 0);1052 for(w = i - 1; w >= end; --w)1053 {1054 map.drawImagetiles[w * map.width + j].push(new PaintTile(layerIndex, w, j, tile));1055 }1056 }1057 }1058 }1059}10601061Layer.prototype.scanIso = function (layerIndex)1062{1063 var map = this.map;1064 var i, j;1065 1066 for(i = 0; i < map.height; ++i)1067 {1068 for(j = 0; j < map.width; ++j)1069 {1070 }1071 }1072}107310741075function node2Objectgroup(node)1076{1077 var children = node.childNodes;1078 var tmp, i;1079 1080 if(children == null)1081 return;1082 1083 var objGroup = new Objectgroup();10841085 for(i = 0; i < node.attributes.length; ++i)1086 {1087 switch(node.attributes[i].name)1088 {1089 case 'name':1090 case 'color':1091 objGroup[node.attributes[i].name] = node.attributes[i].nodeValue;1092 break;1093 case 'width':1094 case 'height':1095 tmp = parseInt(node.attributes[i].nodeValue);1096 if(isNaN(tmp))1097 return;1098 objGroup[node.attributes[i].name] = tmp;1099 break;1100 default:1101 break;1102 }1103 }1104 1105 for(i = 0; i < children.length; ++i)1106 {1107 node = children[i];1108 if(node.nodeType != 1)1109 continue;1110 if(node.tagName == 'properties')1111 {1112 objGroup.properties = node2Props(node);1113 }1114 else if(node.tagName == 'object')1115 {1116 tmp = node2Object(node);1117 if(null == tmp)1118 return;1119 objGroup.objects.push(tmp);1120 }1121 }1122 1123 return objGroup;1124}11251126function Objectgroup()1127{1128 this.name;1129 this.width;1130 this.height;1131 this.visible;1132 this.objects = new Array();1133}1134Objectgroup.prototype.getProperty = getProperty;1135Objectgroup.prototype.getExtendedProperty = getExtendedProperty;1136Objectgroup.prototype.getExtendedPropertyLength = getExtendedPropertyLength;1137Objectgroup.prototype.getObjectByIndex = function (index)1138{1139 return this.objects[index];1140}1141Objectgroup.prototype.getObjectLength = function ()1142{1143 return this.objects.length;1144}11451146function node2Image(tileset, node)1147{1148 var attrs = node.attributes;1149 var tmp;1150 var i = 0;1151 var img = new TilesetImage();1152 1153 if(attrs.length < 1)1154 return;11551156 for(; i < attrs.length; ++i)1157 {1158 switch(attrs[i].name)1159 {1160 case 'source':1161 img[attrs[i].name] = tileset.map.filepath + attrs[i].nodeValue;1162 break;1163 case 'trans':1164 img[attrs[i].name] = attrs[i].nodeValue;1165 break;1166 case 'width':1167 case 'height':1168 tmp = parseInt(attrs[i].nodeValue);1169 if(isNaN(tmp))1170 return;1171 img[attrs[i].name] = tmp;1172 break;1173 default:1174 break;1175 }1176 }1177 1178 img.docImage = helper.loadImage(img.source);1179 if(img.width == null)1180 img.width = img.docImage.width;1181 if(img.height == null)1182 img.height = img.docImage.height;1183 return img;1184}118511861187function TilesetImage()1188{1189 this.source;1190 this.trans;1191 this.width;1192 this.height;1193 this.docImage;1194}1195TilesetImage.prototype.getProperty = getProperty;119611971198function node2Tile(node, tileset)1199{1200 var tile = new Tile(tileset);1201 var tmp;1202 1203 tmp = parseInt(node.getAttribute("id"));1204 if(isNaN(tmp))1205 return; 1206 tile.id = tmp;1207 1208 var children = node.childNodes;1209 1210 for(var i = 0; i < children.length; ++i)1211 {1212 node = children[i];1213 if(node.nodeType != 1)1214 continue;1215 if(node.tagName == 'properties')1216 {1217 tmp = node2Props(node);1218 if(null == tmp)1219 return;1220 tile.properties = tmp;1221 break;1222 }1223 }12241225 return tile;1226}12271228function Tile(tileset)1229{1230 this.id;1231 this.tileset = tileset;1232}1233Tile.prototype.getProperty = getProperty;1234Tile.prototype.getExtendedProperty = getExtendedProperty;1235Tile.prototype.getExtendedPropertyLength = getExtendedPropertyLength;1236Tile.prototype.getGlobalId = function ()1237{1238 return this.id + this.tileset.firstgid;1239}1240Tile.prototype.getTileset = function ()1241{1242 return this.tileset;1243}12441245Tile.prototype.draw = function (context, drawCanvasStartX, drawCanvasStartY, drawW, drawH, tileOffsetX, tileOffsetY)1246{1247 var tileset = this.tileset;1248 var sX, sY;1249 //point(xTile, yTile): image tile ������ͼƬ�ϵĿ�ʼ����1250 var xTile, yTile;1251 var col = Math.floor(this.id/ tileset.xTileLength);12521253 if(this.xTile == null || this.yTile == null)1254 {1255 //this.xTile = Math.round((tmp - Math.floor(tmp)) * tileset.xTileLength * (tileset.tilewidth + tileset.spacing)) + tileset.margin;1256 this.xTile =(this.id % tileset.xTileLength * (tileset.tilewidth + tileset.spacing)) + tileset.margin;1257 this.yTile = ((tileset.tileheight+tileset.spacing) * col) + tileset.margin;1258 }1259 1260 sX = this.xTile + tileOffsetX;1261 sY = this.yTile + tileOffsetY;12621263 /*1264 var imgTileSrc;1265 if(tileOffsetX == 0 && tileOffsetY == 0 && drawW == tileset.tilewidth && drawH == tileset.tileheight)1266 {1267 if(this.imgTileSrc == null)1268 this.imgTileSrc = tileset.image.docImage.get(sX, sY, drawW, drawH);1269 imgTileSrc = this.imgTileSrc;1270 }1271 else1272 {1273 imgTileSrc = tileset.image.docImage.get(sX, sY, drawW, drawH);1274 }1275 context.image(imgTileSrc, drawCanvasStartX, drawCanvasStartY, drawW, drawH);1276 */1277 //context.imageEx(tileset.image.docImage, sX, sY, drawW, drawH, drawCanvasStartX, drawCanvasStartY , drawW, drawH);1278 context.drawImage(tileset.image.docImage.sourceImg, sX, sY, drawW, drawH, drawCanvasStartX, drawCanvasStartY, drawW, drawH);1279 //context.externals.context.fillStyle = "white";1280 //context.externals.context.fillRect(drawCanvasStartX, drawCanvasStartY, 32.9, 32.9);1281}12821283function node2Object(node)1284{1285 var attrs = node.attributes, tmp;1286 var i = 0;1287 var obj = new Logicobject();1288 1289 if(attrs.length < 1)1290 return;12911292 for(; i < attrs.length; ++i)1293 {1294 switch(attrs[i].name)1295 {1296 case 'x':1297 case 'y':1298 case 'width':1299 case 'height':1300 tmp = parseInt(attrs[i].nodeValue);1301 if(isNaN(tmp))1302 return;1303 obj[attrs[i].name] = tmp;1304 break;1305 case 'name':1306 case 'type':1307 obj[attrs[i].name] = attrs[i].nodeValue;1308 default:1309 break;1310 }1311 }1312 1313 var children = node.childNodes;1314 1315 for(i = 0; i < children.length; ++i)1316 {1317 node = children[i];1318 if(node.nodeType != 1)1319 continue;1320 if(node.tagName == 'properties')1321 {1322 tmp = node2Props(node);1323 if(null == tmp)1324 return;1325 obj.properties = tmp;1326 break;1327 }1328 }1329 1330 return obj;1331}13321333function Logicobject()1334{1335 this.x;1336 this.y;1337 this.width;1338 this.height;1339 //name��type���Կ���û��1340 this.name;1341 this.type;1342}1343Logicobject.prototype.getProperty = getProperty;1344Logicobject.prototype.getExtendedProperty = getExtendedProperty;1345Logicobject.prototype.getExtendedPropertyLength = getExtendedPropertyLength;1346Logicobject.prototype.isInSide = function (x, y)1347{1348 if(x >= this.x && y >= this.y && x <= (this.x + this.width) && y < (this.y + height))1349 return true;1350 return false;1351}1352Logicobject.prototype.getStartPoint = function ()1353{1354 return {x:this.x, y:this.y};1355}1356Logicobject.prototype.getEndPoint = function ()1357{1358 return {x:(this.x + this.width), y:(this.y + this.height)};1359}13601361function node2Data(node, layer)1362{1363 var data = new Data(layer);1364 var children = node.childNodes;1365 var i= 0, index = 0, id;1366 var txt = "";1367 var ary = new Array(layer.width * layer.height);1368 //the start position and the end position of each number1369 var start = 0, end = 0;1370 1371 while(i < children.length)1372 {1373 txt += children[i].data;1374 ++i;1375 }1376 1377 data.encoding = node.getAttribute("encoding");1378 data.compression = node.getAttribute("compression");1379 1380 if(data.encoding == "csv")1381 {1382 id = parseInt(txt);1383 if(isNaN(id))1384 return;1385 ary[index++] = id;1386 start = end = txt.indexOf(",");1387 if(start < 0)1388 return;1389 i = start + 1;1390 while(i < txt.length)1391 {1392 if(txt.charAt(i) == ",")1393 {1394 start = end;1395 end = i;1396 id = parseInt(txt.slice(start + 1, end))1397 if(isNaN(id))1398 return;1399 ary[index++] = id;1400 }1401 ++i;1402 }1403 id = parseInt(txt.slice(end + 1, txt.length))1404 if(isNaN(id))1405 return;1406 ary[index++] = id;1407 if(index != ary.length)1408 return;1409 data.reldata = ary;1410 }1411 else if(data.encoding == "base64")1412 {1413 var aryData = gzip.unzipBase64AsArray(txt, 4);1414 1415 if(null == aryData)1416 return;1417 data.reldata = aryData;1418 }1419 1420 return data;1421}14221423function Data(layer)1424{1425 this.encoding;1426 this.compression;1427 this.reldata = new Array;1428 this.layer = layer;1429}14301431function Properties()1432{1433 this.length = 0;1434 Properties.prototype.addProperty = function (name, value)1435 {1436 if(name == null)1437 return;1438 ++this.length;1439 this[name] = value;1440 }1441}14421443function node2Props(node)1444{1445 var i;1446 var children, curNode;1447 var props = new Properties();1448 1449 if(node == null)1450 return;1451 1452 children = node.childNodes;1453 if(children == null)1454 return;1455 1456 for(i = 0; i < children.length; ++i)1457 {1458 curNode = children[i];1459 if(curNode.nodeType != 1)1460 continue;1461 if(curNode.tagName == "property")1462 props.addProperty(curNode.getAttribute("name"), curNode.getAttribute("value"));1463 }1464 return props;1465}14661467module.exports.buildMap = buildMap;1468module.exports.Map = Map;
...
fckw3crange.js
Source:fckw3crange.js
1/*2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net3 * Copyright (C) 2003-2010 Frederico Caldeira Knabben4 *5 * == BEGIN LICENSE ==6 *7 * Licensed under the terms of any of the following licenses at your8 * choice:9 *10 * - GNU General Public License Version 2 or later (the "GPL")11 * http://www.gnu.org/licenses/gpl.html12 *13 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")14 * http://www.gnu.org/licenses/lgpl.html15 *16 * - Mozilla Public License Version 1.1 or later (the "MPL")17 * http://www.mozilla.org/MPL/MPL-1.1.html18 *19 * == END LICENSE ==20 *21 * This class partially implements the W3C DOM Range for browser that don't22 * support the standards (like IE):23 * http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html24 */2526var FCKW3CRange = function( parentDocument )27{28 this._Document = parentDocument ;2930 this.startContainer = null ;31 this.startOffset = null ;32 this.endContainer = null ;33 this.endOffset = null ;34 this.collapsed = true ;35}3637FCKW3CRange.CreateRange = function( parentDocument )38{39 // We could opt to use the Range implementation of the browsers. The problem40 // is that every browser have different bugs on their implementations,41 // mostly related to different interpretations of the W3C specifications.42 // So, for now, let's use our implementation and pray for browsers fixings43 // soon. Otherwise will go crazy on trying to find out workarounds.44 /*45 // Get the browser implementation of the range, if available.46 if ( parentDocument.createRange )47 {48 var range = parentDocument.createRange() ;49 if ( typeof( range.startContainer ) != 'undefined' )50 return range ;51 }52 */53 return new FCKW3CRange( parentDocument ) ;54}5556FCKW3CRange.CreateFromRange = function( parentDocument, sourceRange )57{58 var range = FCKW3CRange.CreateRange( parentDocument ) ;59 range.setStart( sourceRange.startContainer, sourceRange.startOffset ) ;60 range.setEnd( sourceRange.endContainer, sourceRange.endOffset ) ;61 return range ;62}6364FCKW3CRange.prototype =65{6667 _UpdateCollapsed : function()68 {69 this.collapsed = ( this.startContainer == this.endContainer && this.startOffset == this.endOffset ) ;70 },7172 // W3C requires a check for the new position. If it is after the end73 // boundary, the range should be collapsed to the new start. It seams we74 // will not need this check for our use of this class so we can ignore it for now.75 setStart : function( refNode, offset )76 {77 this.startContainer = refNode ;78 this.startOffset = offset ;7980 if ( !this.endContainer )81 {82 this.endContainer = refNode ;83 this.endOffset = offset ;84 }8586 this._UpdateCollapsed() ;87 },8889 // W3C requires a check for the new position. If it is before the start90 // boundary, the range should be collapsed to the new end. It seams we91 // will not need this check for our use of this class so we can ignore it for now.92 setEnd : function( refNode, offset )93 {94 this.endContainer = refNode ;95 this.endOffset = offset ;9697 if ( !this.startContainer )98 {99 this.startContainer = refNode ;100 this.startOffset = offset ;101 }102103 this._UpdateCollapsed() ;104 },105106 setStartAfter : function( refNode )107 {108 this.setStart( refNode.parentNode, FCKDomTools.GetIndexOf( refNode ) + 1 ) ;109 },110111 setStartBefore : function( refNode )112 {113 this.setStart( refNode.parentNode, FCKDomTools.GetIndexOf( refNode ) ) ;114 },115116 setEndAfter : function( refNode )117 {118 this.setEnd( refNode.parentNode, FCKDomTools.GetIndexOf( refNode ) + 1 ) ;119 },120121 setEndBefore : function( refNode )122 {123 this.setEnd( refNode.parentNode, FCKDomTools.GetIndexOf( refNode ) ) ;124 },125126 collapse : function( toStart )127 {128 if ( toStart )129 {130 this.endContainer = this.startContainer ;131 this.endOffset = this.startOffset ;132 }133 else134 {135 this.startContainer = this.endContainer ;136 this.startOffset = this.endOffset ;137 }138139 this.collapsed = true ;140 },141142 selectNodeContents : function( refNode )143 {144 this.setStart( refNode, 0 ) ;145 this.setEnd( refNode, refNode.nodeType == 3 ? refNode.data.length : refNode.childNodes.length ) ;146 },147148 insertNode : function( newNode )149 {150 var startContainer = this.startContainer ;151 var startOffset = this.startOffset ;152153 // If we are in a text node.154 if ( startContainer.nodeType == 3 )155 {156 startContainer.splitText( startOffset ) ;157158 // Check if it is necessary to update the end boundary.159 if ( startContainer == this.endContainer )160 this.setEnd( startContainer.nextSibling, this.endOffset - this.startOffset ) ;161162 // Insert the new node it after the text node.163 FCKDomTools.InsertAfterNode( startContainer, newNode ) ;164165 return ;166 }167 else168 {169 // Simply insert the new node before the current start node.170 startContainer.insertBefore( newNode, startContainer.childNodes[ startOffset ] || null ) ;171172 // Check if it is necessary to update the end boundary.173 if ( startContainer == this.endContainer )174 {175 this.endOffset++ ;176 this.collapsed = false ;177 }178 }179 },180181 deleteContents : function()182 {183 if ( this.collapsed )184 return ;185186 this._ExecContentsAction( 0 ) ;187 },188189 extractContents : function()190 {191 var docFrag = new FCKDocumentFragment( this._Document ) ;192193 if ( !this.collapsed )194 this._ExecContentsAction( 1, docFrag ) ;195196 return docFrag ;197 },198199 // The selection may be lost when cloning (due to the splitText() call).200 cloneContents : function()201 {202 var docFrag = new FCKDocumentFragment( this._Document ) ;203204 if ( !this.collapsed )205 this._ExecContentsAction( 2, docFrag ) ;206207 return docFrag ;208 },209210 _ExecContentsAction : function( action, docFrag )211 {212 var startNode = this.startContainer ;213 var endNode = this.endContainer ;214215 var startOffset = this.startOffset ;216 var endOffset = this.endOffset ;217218 var removeStartNode = false ;219 var removeEndNode = false ;220221 // Check the start and end nodes and make the necessary removals or changes.222223 // Start from the end, otherwise DOM mutations (splitText) made in the224 // start boundary may interfere on the results here.225226 // For text containers, we must simply split the node and point to the227 // second part. The removal will be handled by the rest of the code .228 if ( endNode.nodeType == 3 )229 endNode = endNode.splitText( endOffset ) ;230 else231 {232 // If the end container has children and the offset is pointing233 // to a child, then we should start from it.234 if ( endNode.childNodes.length > 0 )235 {236 // If the offset points after the last node.237 if ( endOffset > endNode.childNodes.length - 1 )238 {239 // Let's create a temporary node and mark it for removal.240 endNode = FCKDomTools.InsertAfterNode( endNode.lastChild, this._Document.createTextNode('') ) ;241 removeEndNode = true ;242 }243 else244 endNode = endNode.childNodes[ endOffset ] ;245 }246 }247248 // For text containers, we must simply split the node. The removal will249 // be handled by the rest of the code .250 if ( startNode.nodeType == 3 )251 {252 startNode.splitText( startOffset ) ;253254 // In cases the end node is the same as the start node, the above255 // splitting will also split the end, so me must move the end to256 // the second part of the split.257 if ( startNode == endNode )258 endNode = startNode.nextSibling ;259 }260 else261 {262 // If the start container has children and the offset is pointing263 // to a child, then we should start from its previous sibling.264265 // If the offset points to the first node, we don't have a266 // sibling, so let's use the first one, but mark it for removal.267 if ( startOffset == 0 )268 {269 // Let's create a temporary node and mark it for removal.270 startNode = startNode.insertBefore( this._Document.createTextNode(''), startNode.firstChild ) ;271 removeStartNode = true ;272 }273 else if ( startOffset > startNode.childNodes.length - 1 )274 {275 // Let's create a temporary node and mark it for removal.276 startNode = startNode.appendChild( this._Document.createTextNode('') ) ;277 removeStartNode = true ;278 }279 else280 startNode = startNode.childNodes[ startOffset ].previousSibling ;281 }282283 // Get the parent nodes tree for the start and end boundaries.284 var startParents = FCKDomTools.GetParents( startNode ) ;285 var endParents = FCKDomTools.GetParents( endNode ) ;286287 // Compare them, to find the top most siblings.288 var i, topStart, topEnd ;289290 for ( i = 0 ; i < startParents.length ; i++ )291 {292 topStart = startParents[i] ;293 topEnd = endParents[i] ;294295 // The compared nodes will match until we find the top most296 // siblings (different nodes that have the same parent).297 // "i" will hold the index in the parents array for the top298 // most element.299 if ( topStart != topEnd )300 break ;301 }302303 var clone, levelStartNode, levelClone, currentNode, currentSibling ;304305 if ( docFrag )306 clone = docFrag.RootNode ;307308 // Remove all successive sibling nodes for every node in the309 // startParents tree.310 for ( var j = i ; j < startParents.length ; j++ )311 {312 levelStartNode = startParents[j] ;313314 // For Extract and Clone, we must clone this level.315 if ( clone && levelStartNode != startNode ) // action = 0 = Delete316 levelClone = clone.appendChild( levelStartNode.cloneNode( levelStartNode == startNode ) ) ;317318 currentNode = levelStartNode.nextSibling ;319320 while( currentNode )321 {322 // Stop processing when the current node matches a node in the323 // endParents tree or if it is the endNode.324 if ( currentNode == endParents[j] || currentNode == endNode )325 break ;326327 // Cache the next sibling.328 currentSibling = currentNode.nextSibling ;329330 // If cloning, just clone it.331 if ( action == 2 ) // 2 = Clone332 clone.appendChild( currentNode.cloneNode( true ) ) ;333 else334 {335 // Both Delete and Extract will remove the node.336 currentNode.parentNode.removeChild( currentNode ) ;337338 // When Extracting, move the removed node to the docFrag.339 if ( action == 1 ) // 1 = Extract340 clone.appendChild( currentNode ) ;341 }342343 currentNode = currentSibling ;344 }345346 if ( clone )347 clone = levelClone ;348 }349350 if ( docFrag )351 clone = docFrag.RootNode ;352353 // Remove all previous sibling nodes for every node in the354 // endParents tree.355 for ( var k = i ; k < endParents.length ; k++ )356 {357 levelStartNode = endParents[k] ;358359 // For Extract and Clone, we must clone this level.360 if ( action > 0 && levelStartNode != endNode ) // action = 0 = Delete361 levelClone = clone.appendChild( levelStartNode.cloneNode( levelStartNode == endNode ) ) ;362363 // The processing of siblings may have already been done by the parent.364 if ( !startParents[k] || levelStartNode.parentNode != startParents[k].parentNode )365 {366 currentNode = levelStartNode.previousSibling ;367368 while( currentNode )369 {370 // Stop processing when the current node matches a node in the371 // startParents tree or if it is the startNode.372 if ( currentNode == startParents[k] || currentNode == startNode )373 break ;374375 // Cache the next sibling.376 currentSibling = currentNode.previousSibling ;377378 // If cloning, just clone it.379 if ( action == 2 ) // 2 = Clone380 clone.insertBefore( currentNode.cloneNode( true ), clone.firstChild ) ;381 else382 {383 // Both Delete and Extract will remove the node.384 currentNode.parentNode.removeChild( currentNode ) ;385386 // When Extracting, mode the removed node to the docFrag.387 if ( action == 1 ) // 1 = Extract388 clone.insertBefore( currentNode, clone.firstChild ) ;389 }390391 currentNode = currentSibling ;392 }393 }394395 if ( clone )396 clone = levelClone ;397 }398399 if ( action == 2 ) // 2 = Clone.400 {401 // No changes in the DOM should be done, so fix the split text (if any).402403 var startTextNode = this.startContainer ;404 if ( startTextNode.nodeType == 3 )405 {406 startTextNode.data += startTextNode.nextSibling.data ;407 startTextNode.parentNode.removeChild( startTextNode.nextSibling ) ;408 }409410 var endTextNode = this.endContainer ;411 if ( endTextNode.nodeType == 3 && endTextNode.nextSibling )412 {413 endTextNode.data += endTextNode.nextSibling.data ;414 endTextNode.parentNode.removeChild( endTextNode.nextSibling ) ;415 }416 }417 else418 {419 // Collapse the range.420421 // If a node has been partially selected, collapse the range between422 // topStart and topEnd. Otherwise, simply collapse it to the start. (W3C specs).423 if ( topStart && topEnd && ( startNode.parentNode != topStart.parentNode || endNode.parentNode != topEnd.parentNode ) )424 {425 var endIndex = FCKDomTools.GetIndexOf( topEnd ) ;426427 // If the start node is to be removed, we must correct the428 // index to reflect the removal.429 if ( removeStartNode && topEnd.parentNode == startNode.parentNode )430 endIndex-- ;431432 this.setStart( topEnd.parentNode, endIndex ) ;433 }434435 // Collapse it to the start.436 this.collapse( true ) ;437 }438439 // Cleanup any marked node.440 if( removeStartNode )441 startNode.parentNode.removeChild( startNode ) ;442443 if( removeEndNode && endNode.parentNode )444 endNode.parentNode.removeChild( endNode ) ;445 },446447 cloneRange : function()448 {449 return FCKW3CRange.CreateFromRange( this._Document, this ) ;450 }
...
moreskins.js
Source:moreskins.js
1CoolClock.config.skins = {2 swissRail: {3 outerBorder: { lineWidth: 2, radius: 95, color: "black", alpha: 1 },4 smallIndicator: { lineWidth: 2, startAt: 88, endAt: 92, color: "black", alpha: 1 },5 largeIndicator: { lineWidth: 4, startAt: 79, endAt: 92, color: "black", alpha: 1 },6 hourHand: { lineWidth: 8, startAt: -15, endAt: 50, color: "black", alpha: 1 },7 minuteHand: { lineWidth: 7, startAt: -15, endAt: 75, color: "black", alpha: 1 },8 secondHand: { lineWidth: 1, startAt: -20, endAt: 85, color: "red", alpha: 1 },9 secondDecoration: { lineWidth: 1, startAt: 70, radius: 4, fillColor: "red", color: "red", alpha: 1 }10 },11 chunkySwiss: {12 outerBorder: { lineWidth: 4, radius: 97, color: "black", alpha: 1 },13 smallIndicator: { lineWidth: 4, startAt: 89, endAt: 93, color: "black", alpha: 1 },14 largeIndicator: { lineWidth: 8, startAt: 80, endAt: 93, color: "black", alpha: 1 },15 hourHand: { lineWidth: 12, startAt: -15, endAt: 60, color: "black", alpha: 1 },16 minuteHand: { lineWidth: 10, startAt: -15, endAt: 85, color: "black", alpha: 1 },17 secondHand: { lineWidth: 4, startAt: -20, endAt: 85, color: "red", alpha: 1 },18 secondDecoration: { lineWidth: 2, startAt: 70, radius: 8, fillColor: "red", color: "red", alpha: 1 }19 },20 chunkySwissOnBlack: {21 outerBorder: { lineWidth: 4, radius: 97, color: "white", alpha: 1 },22 smallIndicator: { lineWidth: 4, startAt: 89, endAt: 93, color: "white", alpha: 1 },23 largeIndicator: { lineWidth: 8, startAt: 80, endAt: 93, color: "white", alpha: 1 },24 hourHand: { lineWidth: 12, startAt: -15, endAt: 60, color: "white", alpha: 1 },25 minuteHand: { lineWidth: 10, startAt: -15, endAt: 85, color: "white", alpha: 1 },26 secondHand: { lineWidth: 4, startAt: -20, endAt: 85, color: "red", alpha: 1 },27 secondDecoration: { lineWidth: 2, startAt: 70, radius: 8, fillColor: "red", color: "red", alpha: 1 }28 },29 fancy: {30 outerBorder: { lineWidth: 5, radius: 95, color: "green", alpha: 0.7 },31 smallIndicator: { lineWidth: 1, startAt: 80, endAt: 93, color: "black", alpha: 0.4 },32 largeIndicator: { lineWidth: 1, startAt: 30, endAt: 93, color: "black", alpha: 0.5 },33 hourHand: { lineWidth: 8, startAt: -15, endAt: 50, color: "blue", alpha: 0.7 },34 minuteHand: { lineWidth: 7, startAt: -15, endAt: 92, color: "red", alpha: 0.7 },35 secondHand: { lineWidth: 10, startAt: 80, endAt: 85, color: "blue", alpha: 0.3 },36 secondDecoration: { lineWidth: 1, startAt: 30, radius: 50, fillColor: "blue", color: "red", alpha: 0.15 }37 },38 machine: {39 outerBorder: { lineWidth: 60, radius: 55, color: "#dd6655", alpha: 1 },40 smallIndicator: { lineWidth: 4, startAt: 80, endAt: 95, color: "white", alpha: 1 },41 largeIndicator: { lineWidth: 14, startAt: 77, endAt: 92, color: "#dd6655", alpha: 1 },42 hourHand: { lineWidth: 18, startAt: -15, endAt: 40, color: "white", alpha: 1 },43 minuteHand: { lineWidth: 14, startAt: 24, endAt: 100, color: "#771100", alpha: 0.5 },44 secondHand: { lineWidth: 3, startAt: 22, endAt: 83, color: "green", alpha: 0 },45 secondDecoration: { lineWidth: 1, startAt: 52, radius: 26, fillColor: "#ffcccc", color: "red", alpha: 0.5 }46 },47 simonbaird_com: {48 hourHand: { lineWidth: 80, startAt: -15, endAt: 35, color: 'magenta', alpha: 0.5 },49 minuteHand: { lineWidth: 80, startAt: -15, endAt: 65, color: 'cyan', alpha: 0.5 },50 secondDecoration: { lineWidth: 1, startAt: 40, radius: 40, color: "#fff", fillColor: 'yellow', alpha: 0.5 }51 },52 // by bonstio, http://bonstio.net53 classic/*was gIG*/: {54 outerBorder: { lineWidth: 185, radius: 1, color: "#E5ECF9", alpha: 1 },55 smallIndicator: { lineWidth: 2, startAt: 89, endAt: 94, color: "#3366CC", alpha: 1 },56 largeIndicator: { lineWidth: 4, startAt: 83, endAt: 94, color: "#3366CC", alpha: 1 },57 hourHand: { lineWidth: 5, startAt: 0, endAt: 60, color: "black", alpha: 1 },58 minuteHand: { lineWidth: 4, startAt: 0, endAt: 80, color: "black", alpha: 1 },59 secondHand: { lineWidth: 1, startAt: -20, endAt: 85, color: "red", alpha: .85 },60 secondDecoration: { lineWidth: 3, startAt: 0, radius: 2, fillColor: "black", color: "black", alpha: 1 }61 },62 modern/*was gIG2*/: {63 outerBorder: { lineWidth: 185, radius: 1, color: "#E5ECF9", alpha: 1 },64 smallIndicator: { lineWidth: 5, startAt: 88, endAt: 94, color: "#3366CC", alpha: 1 },65 largeIndicator: { lineWidth: 5, startAt: 88, endAt: 94, color: "#3366CC", alpha: 1 },66 hourHand: { lineWidth: 8, startAt: 0, endAt: 60, color: "black", alpha: 1 },67 minuteHand: { lineWidth: 8, startAt: 0, endAt: 80, color: "black", alpha: 1 },68 secondHand: { lineWidth: 5, startAt: 80, endAt: 85, color: "red", alpha: .85 },69 secondDecoration: { lineWidth: 3, startAt: 0, radius: 4, fillColor: "black", color: "black", alpha: 1 }70 },71 simple/*was gIG3*/: {72 outerBorder: { lineWidth: 185, radius: 1, color: "#E5ECF9", alpha: 1 },73 smallIndicator: { lineWidth: 10, startAt: 90, endAt: 94, color: "#3366CC", alpha: 1 },74 largeIndicator: { lineWidth: 10, startAt: 90, endAt: 94, color: "#3366CC", alpha: 1 },75 hourHand: { lineWidth: 8, startAt: 0, endAt: 60, color: "black", alpha: 1 },76 minuteHand: { lineWidth: 8, startAt: 0, endAt: 80, color: "black", alpha: 1 },77 secondHand: { lineWidth: 5, startAt: 80, endAt: 85, color: "red", alpha: .85 },78 secondDecoration: { lineWidth: 3, startAt: 0, radius: 4, fillColor: "black", color: "black", alpha: 1 }79 },80 // by securephp81 securephp: {82 outerBorder: { lineWidth: 100, radius: 0.45, color: "#669900", alpha: 0.3 },83 smallIndicator: { lineWidth: 2, startAt: 80, endAt: 90 , color: "green", alpha: 1 },84 largeIndicator: { lineWidth: 8.5, startAt: 20, endAt: 40 , color: "green", alpha: 0.4 },85 hourHand: { lineWidth: 3, startAt: 0, endAt: 60, color: "black", alpha: 1 },86 minuteHand: { lineWidth: 2, startAt: 0, endAt: 75, color: "black", alpha: 1 },87 secondHand: { lineWidth: 1, startAt: -10, endAt: 80, color: "blue", alpha: 0.8 },88 secondDecoration: { lineWidth: 1, startAt: 70, radius: 4, fillColor: "blue", color: "red", alpha: 1 }89 },90 Tes2: {91 outerBorder: { lineWidth: 4, radius: 95, color: "black", alpha: 0.5 },92 smallIndicator: { lineWidth: 1, startAt: 10, endAt: 50 , color: "#66CCFF", alpha: 1 },93 largeIndicator: { lineWidth: 8.5, startAt: 60, endAt: 70, color: "#6699FF", alpha: 1 },94 hourHand: { lineWidth: 5, startAt: -15, endAt: 60, color: "black", alpha: 0.7 },95 minuteHand: { lineWidth: 3, startAt: -25, endAt: 75, color: "black", alpha: 0.7 },96 secondHand: { lineWidth: 1.5, startAt: -20, endAt: 88, color: "red", alpha: 1 },97 secondDecoration: { lineWidth: 1, startAt: 20, radius: 4, fillColor: "blue", color: "red", alpha: 1 }98 },99 Lev: {100 outerBorder: { lineWidth: 10, radius: 95, color: "#CCFF33", alpha: 0.65 },101 smallIndicator: { lineWidth: 5, startAt: 84, endAt: 90, color: "#996600", alpha: 1 },102 largeIndicator: { lineWidth: 40, startAt: 25, endAt: 95, color: "#336600", alpha: 0.55 },103 hourHand: { lineWidth: 4, startAt: 0, endAt: 65, color: "black", alpha: 0.9 },104 minuteHand: { lineWidth: 3, startAt: 0, endAt: 80, color: "black", alpha: 0.85 },105 secondHand: { lineWidth: 1, startAt: 0, endAt: 85, color: "black", alpha: 1 },106 secondDecoration: { lineWidth: 2, startAt: 5, radius: 10, fillColor: "black", color: "black", alpha: 1 }107 },108 Sand: {109 outerBorder: { lineWidth: 1, radius: 70, color: "black", alpha: 0.5 },110 smallIndicator: { lineWidth: 3, startAt: 50, endAt: 70, color: "#0066FF", alpha: 0.5 },111 largeIndicator: { lineWidth: 200, startAt: 80, endAt: 95, color: "#996600", alpha: 0.75 },112 hourHand: { lineWidth: 4, startAt: 0, endAt: 65, color: "black", alpha: 0.9 },113 minuteHand: { lineWidth: 3, startAt: 0, endAt: 80, color: "black", alpha: 0.85 },114 secondHand: { lineWidth: 1, startAt: 0, endAt: 85, color: "black", alpha: 1 },115 secondDecoration: { lineWidth: 2, startAt: 5, radius: 10, fillColor: "black", color: "black", alpha: 1 }116 },117 Sun: {118 outerBorder: { lineWidth: 100, radius: 140, color: "#99FFFF", alpha: 0.2 },119 smallIndicator: { lineWidth: 300, startAt: 50, endAt: 70, color: "black", alpha: 0.1 },120 largeIndicator: { lineWidth: 5, startAt: 80, endAt: 95, color: "black", alpha: 0.65 },121 hourHand: { lineWidth: 4, startAt: 0, endAt: 65, color: "black", alpha: 0.9 },122 minuteHand: { lineWidth: 3, startAt: 0, endAt: 80, color: "black", alpha: 0.85 },123 secondHand: { lineWidth: 1, startAt: 0, endAt: 90, color: "black", alpha: 1 },124 secondDecoration: { lineWidth: 2, startAt: 5, radius: 10, fillColor: "black", color: "black", alpha: 1 }125 },126 Tor: {127 outerBorder: { lineWidth: 10, radius: 88, color: "#996600", alpha: 0.9 },128 smallIndicator: { lineWidth: 6, startAt: -10, endAt: 73, color: "green", alpha: 0.3 },129 largeIndicator: { lineWidth: 6, startAt: 73, endAt: 100, color: "black", alpha: 0.65 },130 hourHand: { lineWidth: 4, startAt: 0, endAt: 65, color: "black", alpha: 1 },131 minuteHand: { lineWidth: 3, startAt: 0, endAt: 80, color: "black", alpha: 1 },132 secondHand: { lineWidth: 1, startAt: -73, endAt: 73, color: "black", alpha: 0.8 },133 secondDecoration: { lineWidth: 2, startAt: 5, radius: 10, fillColor: "black", color: "black", alpha: 1 }134 },135 Cold: {136 outerBorder: { lineWidth: 15, radius: 90, color: "black", alpha: 0.3 },137 smallIndicator: { lineWidth: 15, startAt: -10, endAt: 95, color: "blue", alpha: 0.1 },138 largeIndicator: { lineWidth: 3, startAt: 80, endAt: 95, color: "blue", alpha: 0.65 },139 hourHand: { lineWidth: 4, startAt: 0, endAt: 65, color: "black", alpha: 1 },140 minuteHand: { lineWidth: 3, startAt: 0, endAt: 80, color: "black", alpha: 1 },141 secondHand: { lineWidth: 1, startAt: 0, endAt: 85, color: "black", alpha: 0.8 },142 secondDecoration: { lineWidth: 5, startAt: 30, radius: 10, fillColor: "black", color: "black", alpha: 1 }143 },144 Babosa: {145 outerBorder: { lineWidth: 100, radius: 25, color: "blue", alpha: 0.25 },146 smallIndicator: { lineWidth: 3, startAt: 90, endAt: 95, color: "#3366CC", alpha: 1 },147 largeIndicator: { lineWidth: 4, startAt: 75, endAt: 95, color: "#3366CC", alpha: 1 },148 hourHand: { lineWidth: 4, startAt: 0, endAt: 60, color: "black", alpha: 1 },149 minuteHand: { lineWidth: 3, startAt: 0, endAt: 85, color: "black", alpha: 1 },150 secondHand: { lineWidth: 12, startAt: 75, endAt: 90, color: "red", alpha: 0.8 },151 secondDecoration: { lineWidth: 3, startAt: 0, radius: 4, fillColor: "black", color: "black", alpha: 1 }152 },153 Tumb: {154 outerBorder: { lineWidth: 105, radius: 5, color: "green", alpha: 0.4 },155 smallIndicator: { lineWidth: 1, startAt: 93, endAt: 98, color: "green", alpha: 1 },156 largeIndicator: { lineWidth: 50, startAt: 0, endAt: 89, color: "red", alpha: 0.14 },157 hourHand: { lineWidth: 4, startAt: 0, endAt: 65, color: "black", alpha: 1 },158 minuteHand: { lineWidth: 3, startAt: 0, endAt: 80, color: "black", alpha: 1 },159 secondHand: { lineWidth: 1, startAt: 0, endAt: 85, color: "black", alpha: 0.8 },160 secondDecoration: { lineWidth: 5, startAt: 50, radius: 90, fillColor: "black", color: "black", alpha: 0.05 }161 },162 Stone: {163 outerBorder: { lineWidth: 15, radius: 80, color: "#339933", alpha: 0.5 },164 smallIndicator: { lineWidth: 2, startAt: 70, endAt: 90, color: "#FF3300", alpha: 0.7 },165 largeIndicator: { lineWidth: 15, startAt: 0, endAt: 29, color: "#FF6600", alpha: 0.3 },166 hourHand: { lineWidth: 4, startAt: 0, endAt: 65, color: "black", alpha: 1 },167 minuteHand: { lineWidth: 3, startAt: 0, endAt: 75, color: "black", alpha: 1 },168 secondHand: { lineWidth: 1, startAt: 0, endAt: 85, color: "black", alpha: 0.8 },169 secondDecoration: { lineWidth: 5, startAt: 50, radius: 90, fillColor: "black", color: "black", alpha: 0.05 }170 },171 Disc: {172 outerBorder: { lineWidth: 105, radius: 1, color: "#666600", alpha: 0.2 },173 smallIndicator: { lineWidth: 1, startAt: 58, endAt: 95, color: "#669900", alpha: 0.8 },174 largeIndicator: { lineWidth: 6, startAt: 25, endAt: 35, color: "#666600", alpha: 1 },175 hourHand: { lineWidth: 4, startAt: 0, endAt: 65, color: "black", alpha: 1 },176 minuteHand: { lineWidth: 3, startAt: 0, endAt: 75, color: "black", alpha: 1 },177 secondHand: { lineWidth: 1, startAt: -75, endAt: 75, color: "#99CC00", alpha: 0.8 },178 secondDecoration: { lineWidth: 5, startAt: 50, radius: 90, fillColor: "#00FF00", color: "green", alpha: 0.05 }179 },180 // By Yoo Nhe181 watermelon: {182 outerBorder: { lineWidth: 100, radius: 1.7, color: "#d93d04", alpha: 5 },183 smallIndicator: { lineWidth: 2, startAt: 50, endAt: 70, color: "#d93d04", alpha: 5 },184 largeIndicator: { lineWidth: 2, startAt: 45, endAt: 94, color: "#a9bf04", alpha: 1 },185 hourHand: { lineWidth: 5, startAt: -20, endAt: 80, color: "#8c0d17", alpha: 1 },186 minuteHand: { lineWidth: 2, startAt: -20, endAt: 80, color: "#7c8c03", alpha: .9 },187 secondHand: { lineWidth: 2, startAt: 70, endAt: 94, color: "#d93d04", alpha: .85 },188 secondDecoration: { lineWidth: 1, startAt: 70, radius: 3, fillColor: "red", color: "black", alpha: .7 }189 }...
geochrono.js
Source:geochrono.js
1/*==================================================2 * Geochrono3 *==================================================4 */5Timeline.Geochrono = new Object();6Timeline.Geochrono.eons = [7 { name: "Proterozoic",8 start: 2500.0009 },10 { name: "Phanerozoic",11 start: 542.00012 }13];14Timeline.Geochrono.eras = [15 { name: "Paleoarchean",16 start: 3600.00017 },18 { name: "Mesoarchean",19 start: 3200.00020 },21 { name: "Neoarchean",22 start: 2800.00023 },24 { name: "Paleoproterozoic",25 start: 2500.00026 },27 { name: "Mesoproterozoic",28 start: 1600.00029 },30 { name: "Neoproterozoic",31 start: 1000.00032 },33 { name: "Paleozoic",34 start: 542.00035 },36 { name: "Mesozoic",37 start: 251.00038 },39 { name: "Cenozoic",40 start: 65.50041 }42];43Timeline.Geochrono.periods = [44 { name: "Siderian",45 start: 2500.00046 },47 { name: "Rhyacian",48 start: 2300.00049 },50 { name: "Orosirian",51 start: 2050.00052 },53 { name: "Statherian",54 start: 1800.00055 },56 { name: "Calymmian",57 start: 1600.00058 },59 { name: "Ectasian",60 start: 1400.00061 },62 { name: "Stenian",63 start: 1200.00064 },65 { name: "Tonian",66 start: 1000.00067 },68 { name: "Cryogenian",69 start: 850.00070 },71 { name: "Ediacaran",72 start: 600.00073 },74 { name: "Cambrian",75 start: 542.00076 },77 { name: "Ordovician",78 start: 488.30079 },80 { name: "Silurian",81 start: 443.70082 },83 { name: "Devonian",84 start: 416.00085 },86 { name: "Carboniferous",87 start: 359.20088 },89 { name: "Permian",90 start: 299.00091 },92 { name: "Triassic",93 start: 251.00094 },95 { name: "Jurassic",96 start: 199.60097 },98 { name: "Cretaceous",99 start: 145.500100 },101 { name: "Paleogene",102 start: 65.500103 },104 { name: "Neogene",105 start: 23.030106 }107];108Timeline.Geochrono.epoches = [109 { name: "Lower Cambrian",110 start: 542.000111 },112 { name: "Middle Cambrian",113 start: 513.000114 },115 { name: "Furongian",116 start: 501.000117 },118 { name: "Lower Ordovician",119 start: 488.300120 },121 { name: "Middle Ordovician",122 start: 471.800123 },124 { name: "Upper Ordovician",125 start: 460.900126 },127 { name: "Llandovery",128 start: 443.700129 },130 { name: "Wenlock",131 start: 428.200132 },133 { name: "Ludlow",134 start: 422.900135 },136 { name: "Pridoli",137 start: 418.700138 },139 { name: "Lower Devonian",140 start: 416.000141 },142 { name: "Middle Devonian",143 start: 397.500144 },145 { name: "Upper Devonian",146 start: 385.300147 },148 { name: "Mississippian",149 start: 359.200150 },151 { name: "Pennsylvanian",152 start: 318.100153 },154 { name: "Cisuralian",155 start: 299.000156 },157 { name: "Guadalupian",158 start: 270.600159 },160 { name: "Lopingian",161 start: 260.400162 },163 { name: "Lower Triassic",164 start: 251.000165 },166 { name: "Middle Triassic",167 start: 245.000168 },169 { name: "Upper Triassic",170 start: 228.000171 },172 { name: "Lower Jurassic",173 start: 199.600174 },175 { name: "Middle Jurassic",176 start: 175.600177 },178 { name: "Upper Jurassic",179 start: 161.200180 },181 { name: "Lower Cretaceous",182 start: 145.500183 },184 { name: "Upper Cretaceous",185 start: 99.600186 },187 { name: "Paleocene",188 start: 65.500189 },190 { name: "Eocene",191 start: 55.800192 },193 { name: "Oligocene",194 start: 33.900195 },196 { name: "Miocene",197 start: 23.030198 },199 { name: "Pliocene",200 start: 5.332201 },202 { name: "Pleistocene",203 start: 1.806204 },205 { name: "Holocene",206 start: 0.012207 }208];209Timeline.Geochrono.ages = [210 { name: "-",211 start: 542.000212 },213 { name: "-",214 start: 513.000215 },216 { name: "Paibian",217 start: 501.000218 },219 { name: "Tremadocian",220 start: 488.300221 },222 { name: "-",223 start: 478.600224 },225 { name: "-",226 start: 471.800227 },228 { name: "Darriwilian",229 start: 468.100230 },231 { name: "-",232 start: 460.900233 },234 { name: "-",235 start: 455.800236 },237 { name: "Hirnantian",238 start: 445.600239 },240 { name: "Rhuddanian",241 start: 443.700242 },243 { name: "Aeronian",244 start: 439.000245 },246 { name: "Telychian",247 start: 436.100248 },249 { name: "Sheinwoodian",250 start: 428.200251 },252 { name: "Homerian",253 start: 426.200254 },255 { name: "Gorstian",256 start: 422.900257 },258 { name: "Ludfordian",259 start: 421.300260 },261 { name: "-",262 start: 418.700263 },264 { name: "Lochkovian",265 start: 416.000266 },267 { name: "Pragian",268 start: 411.200269 },270 { name: "Emsian",271 start: 407.000272 },273 { name: "Eifelian",274 start: 397.500275 },276 { name: "Givetian",277 start: 391.800278 },279 { name: "Frasnian",280 start: 385.300281 },282 { name: "Famennian",283 start: 374.500284 },285 { name: "Tournaisian",286 start: 359.200287 },288 { name: "Visean",289 start: 345.300290 },291 { name: "Serpukhovian",292 start: 326.400293 },294 { name: "Bashkirian",295 start: 318.100296 },297 { name: "Moscovian",298 start: 311.700299 },300 { name: "Kazimovian",301 start: 306.500302 },303 { name: "Gzhelian",304 start: 303.900305 },306 { name: "Asselian",307 start: 299.000308 },309 { name: "Sakmarian",310 start: 294.600311 },312 { name: "Artinskian",313 start: 284.400314 },315 { name: "Kungurian",316 start: 275.600317 },318 { name: "Roadian",319 start: 270.600320 },321 { name: "Wordian",322 start: 268.000323 },324 { name: "Capitanian",325 start: 265.800326 },327 { name: "Wuchiapingian",328 start: 260.400329 },330 { name: "Changhsingian",331 start: 253.800332 },333 { name: "Induan",334 start: 251.000335 },336 { name: "Olenekian",337 start: 249.700338 },339 { name: "Anisian",340 start: 245.000341 },342 { name: "Ladinian",343 start: 237.000344 },345 { name: "Carnian",346 start: 228.000347 },348 { name: "Norian",349 start: 216.500350 },351 { name: "Rhaetian",352 start: 203.600353 },354 { name: "Hettangian",355 start: 199.600356 },357 { name: "Sinemurian",358 start: 196.500359 },360 { name: "Pliensbachian",361 start: 189.600362 },363 { name: "Toarcian",364 start: 183.000365 },366 { name: "Aalenian",367 start: 175.600368 },369 { name: "Bajocian",370 start: 171.600371 },372 { name: "Bathonian",373 start: 167.700374 },375 { name: "Callovian",376 start: 164.700377 },378 { name: "Oxfordian",379 start: 161.200380 },381 { name: "Kimmeridgian",382 start: 155.000383 },384 { name: "Tithonian",385 start: 150.800386 },387 { name: "Berriasian",388 start: 145.500389 },390 { name: "Valanginian",391 start: 140.200392 },393 { name: "Hauterivian",394 start: 136.400395 },396 { name: "Barremian",397 start: 130.000398 },399 { name: "Aptian",400 start: 125.000401 },402 { name: "Albian",403 start: 112.000404 },405 { name: "Cenomanian",406 start: 99.600407 },408 { name: "Turonian",409 start: 93.500410 },411 { name: "Coniacian",412 start: 89.300413 },414 { name: "Santonian",415 start: 85.800416 },417 { name: "Campanian",418 start: 83.500419 },420 { name: "Maastrichtian",421 start: 70.600422 },423 { name: "Danian",424 start: 65.500425 },426 { name: "Selandian",427 start: 61.700428 },429 { name: "Thanetian",430 start: 58.700431 },432 { name: "Ypresian",433 start: 55.800434 },435 { name: "Lutetian",436 start: 48.600437 },438 { name: "Bartonian",439 start: 40.400440 },441 { name: "Priabonian",442 start: 37.200443 },444 { name: "Rupelian",445 start: 33.900446 },447 { name: "Chattian",448 start: 28.400449 },450 { name: "Aquitanian",451 start: 23.030452 },453 { name: "Burdigalian",454 start: 20.430455 },456 { name: "Langhian",457 start: 15.970458 },459 { name: "Serravallian",460 start: 13.650461 },462 { name: "Tortonian",463 start: 11.608464 },465 { name: "Messinian",466 start: 7.246467 },468 { name: "Zanclean",469 start: 5.332470 },471 { name: "Piacenzian",472 start: 3.600473 },474 { name: "Gelasian",475 start: 2.588476 }477];478Timeline.Geochrono.createBandInfo = function(params) {479 var theme = ("theme" in params) ? params.theme : Timeline.getDefaultTheme();480 481 var eventSource = ("eventSource" in params) ? params.eventSource : null;482 483 var ether = new Timeline.LinearEther({ 484 centersOn: ("date" in params) ? params.date : Timeline.GeochronoUnit.makeDefaultValue(),485 interval: 1,486 pixelsPerInterval: params.intervalPixels487 });488 489 var etherPainter = new Timeline.GeochronoEtherPainter({490 intervalUnit: params.intervalUnit, 491 multiple: ("multiple" in params) ? params.multiple : 1,492 align: params.align,493 theme: theme 494 });495 496 var layout = new Timeline.StaticTrackBasedLayout({497 eventSource: eventSource,498 ether: ether,499 showText: ("showEventText" in params) ? params.showEventText : true,500 theme: theme501 });502 503 var eventPainterParams = {504 showText: ("showEventText" in params) ? params.showEventText : true,505 layout: layout,506 theme: theme507 };508 if ("trackHeight" in params) {509 eventPainterParams.trackHeight = params.trackHeight;510 }511 if ("trackGap" in params) {512 eventPainterParams.trackGap = params.trackGap;513 }514 var eventPainter = new Timeline.DurationEventPainter(eventPainterParams);515 516 return { 517 width: params.width,518 eventSource: eventSource,519 timeZone: ("timeZone" in params) ? params.timeZone : 0,520 ether: ether,521 etherPainter: etherPainter,522 eventPainter: eventPainter523 };...
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!