`

自己写的装备叠加效果(类似于JavaScript数组唯一的方法)

阅读更多
var teams = ["hiWeapon", "hiChest", "hiFeet", "hiNeck", "hiHead", "hiBack", "hiCore"];
        for (var m = 0; m < teams.length; m++) {
            var hiWeapon = document.getElementById(teams[m]);
            var tagLi = hiWeapon.getElementsByTagName("li");
            var items = {};
var itemsdel = new Array();
var itemscomplex = new Array();
var delArray = new Array();
var complexArray = new Array();
            for (var i = 0; i < tagLi.length; i++) {
                itemdata = tagLi[i].getAttribute("itemdata");
                evalItemdata = $.eval(itemdata);
                var str = evalItemdata.iid + "_" + evalItemdata.star + "_" + evalItemdata.rty;
                if (items[str] == null) {
                    items[str] = new Array();
                    itemscomplex.push(str);
                    complexArray.push(i);

                } else {
                    delArray.push(tagLi[i]);

                    itemsdel.push(str);
                }

            }
            var arra = new Array();
            for (var a = 0; a < itemscomplex.length; a++) {
                var arr = 1;
                for (var c = 0; c < itemsdel.length; c++) {
                    if (itemscomplex[a] == itemsdel[c]) {
                        arr++;
                    }

                }
                arra.push(arr);
            }

            for (var j = 0; j < complexArray.length; j++) {
                var h3 = tagLi[complexArray[j]].getElementsByTagName("h3")[0];
                var thehtml = h3.innerHTML;
                h3.innerHTML = thehtml + "[" + arra[j] + "]";

            }
            var theUl = hiWeapon.getElementsByTagName("ul")[0];
            for (var i = 0; i < delArray.length; i++) {
                //alert(delArray[i].toString());
                theUl.removeChild(delArray[i]);
            }

        }

N多年后我就看不懂了,总觉得还有更好的办法。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics