📄 signature.js
字号:
<!--
var m_strPath = "";
var m_bDropped = false;
var m_vShape = null;
var m_nIndex = 0;
function getOwnerDIV(obj)
{
while(obj)
{
if (obj.tagName == "DIV")
return obj;
obj = obj.parentElement;
}
return null;
}
function getOwnerBody(obj)
{
while(obj)
{
if (obj.tagName == "BODY")
return obj;
obj = obj.parentElement;
}
return null;
}
function getRelativeX(obj, x)
{
var oBody = getOwnerBody(obj);
return x + oBody.scrollLeft;
}
function getRelativeY(obj, y)
{
var oBody = getOwnerBody(obj);
return y + oBody.scrollTop;
}
function appendPoint(strSrcPath, op, x, y)
{
var nEnd = strSrcPath.indexOf('e');
var strResult = strSrcPath;
if (nEnd != -1)
strResult = strSrcPath.substring(0, nEnd - 1);
strResult += " " + op + x + "," + y + " e";
return strResult;
}
function appendPath(strSrcPath, strAppendPath)
{
var eTag = -1;
for (var i = strSrcPath.length - 1; i >= 0; i++)
{
if (strSrcPath.substr(i, 1) == "e")
{
eTag = i;
break;
}
}
var strResult = "";
if (eTag >= 0)
strResult = strSrcPath.substring(0, eTag - 1);
strResult += " " + strAppendPath;
return strResult;
}
function onShapeMouseMove()
{
if (event.button == 1)
{
var oDiv = getOwnerDIV(event.srcElement);
if (m_bDropped)
{
var x = getRelativeX(oDiv, event.x);
var y = getRelativeY(oDiv, event.y);
if (x < oDiv.offsetWidth && y < oDiv.offsetHeight)
{
m_strPath = appendPoint(m_strPath, "l",
getRelativeX(oDiv, event.x), getRelativeY(oDiv, event.y));
m_vShape.path.value = m_strPath;
}
}
else
doFirstMoveMouse(oDiv);
}
}
function onSelectStart()
{
event.returnValue = false;
return false;
}
function createShapeElement(nWidth, nHeight)
{
var strHTML = "<v:shape style='position:absolute;" + "left:0px;top:0px;" +
"width:" + nWidth + "px;height:" + nHeight +
"px' filled='false' strokecolor='red' strokeweight='2px' " +
"coordorigin='0 0' coordsize='" + nWidth + " " + nHeight + "'>";
var shape = document.createElement(strHTML);
shape.tag = "AutoCreate";
shape.style.zIndex = "200";
return shape;
}
function doFirstMoveMouse(oDiv)
{
m_vShape = createShapeElement(200, 200);
if (typeof(oDiv.oid) != "undefined")
m_vShape.id = oDiv.oid + "_" + m_nIndex++;
var x = getRelativeX(oDiv, event.x);
var y = getRelativeY(oDiv, event.y);
if (x < oDiv.offsetWidth && y < oDiv.offsetHeight)
{
m_bDropped = true;
m_strPath = " m" + x + "," + y;
oDiv.appendChild(m_vShape);
}
}
function onShapeMouseDown()
{
if (event.button == 1)
{
var oDiv = getOwnerDIV(event.srcElement);
doFirstMoveMouse(oDiv);
}
}
function onShapeMouseUp()
{
m_bDropped = false;
}
function mergeShapes(oDiv)
{
var strResult = "";
var obj = oDiv.firstChild;
while (obj)
{
if (obj.tagName == "shape" && typeof(obj.tag) != "undefined")
{
if (typeof(obj.path.value) != "unknown")
strResult = appendPath(strResult, obj.path.value);
var oPrevious = obj.previousSibling;
oDiv.removeChild(obj);
obj = oPrevious;
}
if (obj)
obj = obj.nextSibling;
}
var shape = createShapeElement(200, 200);
shape.path = strResult;
shape.id = oDiv.oid;
oDiv.appendChild(shape);
}
//-->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -