Application that get the Sum from previously running application
<p>I have a dice function that multiply the sum of the dices, stores the sum in a variable, and print the sum out. No problem, but when i run the application twice. The second application influence the sum of the first one.</p>

<p>I tried with the localStorage, but nothing worked. This is the closest i have come to show different results in the two application</p>

<p>I want to be able to have multiply application running but not leaking information.
Any tips ?</p>

<p>A jsFiddle <a href="http://jsfiddle.net/dymond/gUL9U/" rel="nofollow">http://jsfiddle.net/dymond/gUL9U/</a> &lt;-- run the application twice and you see the problem.</p>

<pre><code>function dicesides_func(nr){
    // go to dice-window-wrapper again
    // this could be put in a seporate functon
    var elementToAddDice=" dice-window-wrapper ",
    obj=this, // using this here that's why it's called wiht
    dice,i=0,total=0; // all the dice in this dice window
    // dicesides_func.call to set the right this context
    if(nr)
    {
        while((" "+obj.className+" ").indexOf(elementToAddDice)==-1){
            obj=obj.parentNode;
        }
        obj=obj.getElementsByTagName("ul")[2];
        var dicessides = createElementWithClass('li',nr);
        obj.appendChild(dicessides);
        // calculate total (can do in a seporate function)

        dice = obj.getElementsByTagName("li");
    }
    else
    {
        dice = document.getElementsByClassName("dice");   
    }
    for(i=0;i&lt;dice.length;i++){
        total=total+getNumberForClass(dice[i].className);
    }
    //alert(total);

    var wrapper = document.getElementsByClassName("dice-toolbar-counter-wrapper")[0];

    while (wrapper.hasChildNodes()) {
        wrapper.removeChild(wrapper.lastChild);
    }

    var ttl = total.toString();
    var arr = [];
    for (var i = 0;i&lt;ttl.length;i++) {
        var digit = ttl[i];
        var newelem = createElementWithClass('li',"side-" + ttl[i]);
        //alert(dice_toolbar_counter_wrapper_Li)
        wrapper.appendChild(newelem);
    } 

}
</code></pre>
