如何编写在特定HTML标记之前运行的JavaScript Hook?

时间:2019-07-16 07:54:13

标签: javascript

我需要一个在特定标签之前运行自定义功能的JS挂钩。我在互联网上搜索,但找不到任何解决方案。

for arc in arcs:
    if arc.dxf.color == 4:
        if arc.dxf.center[1] > centerPoint[1]:
            modelspace.add_arc( (arc.dxf.center), (arc.dxf.radius + offset), (arc.dxf.start_angle), (arc.dxf.end_angle), dxfattribs=newBoundaryLineAttribs )
        else:
            modelspace.add_arc((arc.dxf.center), (arc.dxf.radius - offset), (arc.dxf.start_angle),
                               (arc.dxf.end_angle), dxfattribs=newBoundaryLineAttribs)

    if arc.dxf.color == 1:
        arcPoints = ezdxf.math.arc_to_bulge(arc.dxf.center, arc.dxf.start_angle, arc.dxf.end_angle, arc.dxf.radius)
        if arcPoints[0][0] < centerPoint[0]:
            startPointX = arcPoints[0][0] - 3
        else:
            startPointX = arcPoints[0][0] + 3

        if arcPoints[0][1] < centerPoint[1]:
            startPointY = arcPoints[0][1] - 3
        else:
            startPointY = arcPoints[0][0] + 3

        if arcPoints[1][0] < centerPoint[0]:
            endPointX = arcPoints[1][0] - 3
        else:
            endPointX = arcPoints[1][0] + 3

        if arcPoints[1][1] < centerPoint[1]:
            endPointY = arcPoints[1][1] - 3
        else:
            endPointY = arcPoints[1][1] + 3

        newStartPoint = [startPointX, startPointY]
        newEndPoint = [endPointX, endPointY]

        newArc = ezdxf.math.bulge_to_arc(newStartPoint, newEndPoint, arcPoints[2])

        arc.dxf.start_angle = newArc[1]
        arc.dxf.end_angle = newArc[2]
  1. 介绍用于创建JavaScript钩子的文档。
  2. 显示一个简单的钩子。在带有id = myTest1的标签之前和之后运行customFunction()。

0 个答案:

没有答案