如何与拉斐尔一起获取 paper.path NUMBER.js

how to get paper.path NUMBER with raphael.js

本文关键字:paper 获取 path NUMBER js 一起      更新时间:2023-09-26

我正在使用以下代码:

var current = null;
for ( var state in aus) {
    aus[state].color = Raphael.getColor();
    (function(st, state) {
        st[0].style.cursor = "pointer";
        st[0].onmouseover = function() {
            current && aus[current].animate({
                fill : "#333",
                stroke : "#666"
            }, 500) && (document.getElementById(current).style.display = "");
            st.animate({
                fill : st.color,
                stroke : "#ccc"
            }, 500);
            st.toFront();
            R.safari();
            document.getElementById(state).style.display = "block";
            current = state;
        };
        st[0].onmouseout = function() {
            st.animate({
                fill : "#333",
                stroke : "#666"
            }, 500);
            st.toFront();
            R.safari();
        };
        if (state == "nsw") {
            st[0].onmouseover();
        }
    })(aus[state], state);
}

从此页面: http://raphaeljs.com/australia.htm

我添加了这个:

st[0].onmousedown = function() {
    paper.print();
    var url = "index.php?cmd=2&sub=0";
    window.open(url, "popup");
};

进入 for 循环以打开由 PHP 脚本生成的弹出窗口。

"sub"请求参数将是与状态关联的文件夹对应的数值,但我不知道如何将数字与它相关联。

假设每个状态都是一个从 0 到状态数的数字。

为什么不为每个州创建 id:

var ids = {}, i = 0;
for (var state in aus) {
  ids[state] = i;
  i++;
}

然后:

var url = "index.php?cmd=2&sub=" + ids[state];