Html表图像重复

时间:2016-01-12 01:30:21

标签: javascript html mongodb steam

我是这个论坛的新手,我有一个问题我偶然发现,我有一个PHP积宝网站,用于在MongoDB和JavaScripts下运行的csgo,我尝试制作一个表格,其中脚本应该加载图像它存放的枪,但根据第一个表中的位置得到重复,就好像它的第7个它有6个重复,依此类推。

网站链接是csvulcan.com,因为我觉得分享代码感觉不舒服。我也尝试为某个表添加和删除规则,但它没有工作

javascript:

socketIO.on('0', function(data){
            var cont = _$('game'); 
            if (cont == null) {
                return;
            }

            $('.players-percent').removeClass('hidden');
            $('#start-game-advert').hide();
            $('#in-game-advert').show();

            var icount = parseInt($('#items-count-temp').text());
            icount++;
            $('#items-count-temp').text(icount);
            if (data.steamid == getSteamID()) {
                $('#chance-temp').text(data.chance.toFixed(2));
                $('#player-items-count').text(data.itemcounter);
            }

            // build deposite
            var deposite = ce('tr');

            var aclass = document.createAttribute('class');
            aclass.value = 'item-bg';

            var astyle = ca('style');
            astyle.value = 'color:' + data.color + '; background-color:'+data.background_color+';';

            deposite.setAttributeNode(aclass);
            deposite.setAttributeNode(astyle);

            // image 1 TD
            var image1td = ce('td');

            var aclass = document.createAttribute('class');
            aclass.value = 'col-ava';
            image1td.setAttributeNode(aclass);

            // prepare image
            var image = ce('img');

            var asrc = ca('src');
            asrc.value = data.ava;
            image.setAttributeNode(asrc);

            image1td.appendChild(image);

            deposite.appendChild(image1td);

            // text TD
            var texttd = ce('td');

            var aclass = document.createAttribute('class');
            aclass.value = 'col-text';
            texttd.setAttributeNode(aclass);

            // text
            var text = ce('p');
            //Билеты начало
            var ddk = lastticket+1;
            var ntk = (lastticket+Math.ceil(data.cost*1));
            lastticket = ntk;
            var tick = ntk-ddk;
            //Билеты конец
            text.innerHTML = data.user + " Deposited <br> <b>" + data.itemname + "</b> (~" + data.cost*0.01 + " " + currency + ") <br />Tickets from <b>#"+ddk+"</b> to <b>#"+ntk+"</b> <div class='bilet'><span>"+ "+" +tick+"</span></div>";
            texttd.appendChild(text);

            deposite.appendChild(texttd);

            // image 2 TD
                    socketIO.on('0', function(data){
            var contt = _$('itemspanel'); 
            if (contt == null) {
                return;
            }
                        var deposite = ce('tr');

            var aclass = document.createAttribute('class');
            aclass.value = 'item-bg';

            var astyle = ca('style');
            astyle.value = 'color:' + data.color + '; background-color:'+data.background_color+';';

            deposite.setAttributeNode(aclass);
            deposite.setAttributeNode(astyle);
            var image2td = ce('td');
            var deposite = ce('tr');
            var aclass = document.createAttribute('class');
            aclass.value = 'col-img';
            image2td.setAttributeNode(aclass);

            // image 2 
            image = ce('img');

            asrc = ca('src');
            asrc.value = "http://steamcommunity-a.akamaihd.net/economy/image/"+ data.image +"/96fx96f";
            image.setAttributeNode(asrc);

            image2td.appendChild(image);

            deposite.appendChild(image2td);         
            contt.insertBefore(deposite, contt.firstChild);

            contt.insertBefore(deposite, contt.firstChild);var addtd = ce('td');

            var aclass = document.createAttribute('class');
            aclass.value = 'col-add';
            addtd.setAttributeNode(aclass);

            deposite.appendChild(addtd);
                    });
            // add


            // insert deposite into list

            cont.insertBefore(deposite, cont.firstChild); 

HTML:

<div class="itemspanel" style="width: 241px; height: 400px; margin-left: 950px; color: #fff;">
                                                                    <table>
                                            <tbody id="itemspanel">
                                            </tbody>
                                            </table>
                                            </div>

0 个答案:

没有答案