¿Cómo recordar si la casilla está marcada o no? (Al hacer clic) con localstorage y también guardar un valor?

Aquí está el jsfiddle:http://jsfiddle.net/nng6L/7/

Entonces, lo que quiero hacer es lo siguiente:

Quiero establecer un valor en localstorage, de1 si la casilla está marcada, o0 si la casilla no está marcadaCuando se recarga la página, si se marcó la casilla, se mantiene marcada, habiendo obtenido el valor de localstorageQuiero poder mostrar una1 o un0 en texto plano, habiendo obtenido el valor mencionado anteriormente de localstorage.

Aquí está mi código, pero no funciona (cuando se recarga la página, la casilla no está marcada; ynull se devuelve en lugar de un1 o un0):

script.js

    // here is to set item in localstorage when you click the check box.
    vvvvvvv = document.getElementById('xxxx');      
    vvvvvvv.onclick = function() {
        if(document.getElementById('xxxx').checked=true) {
            localStorage.setItem('yyyyyyy', "1");
        } else {
            localStorage.setItem('yyyyyyy', "0");
        }
    }

    // here is to fetch the item stored in local storage, and use that value
    // to check or uncheck the box based on localstorage value.
    zzzzzzz = localStorage.getItem('yyyyyyy');
    if (zzzzzzz === null) {
            localStorage.setItem('yyyyyyy', "0");
            document.getElementById("xxxx").checked=false;
        }
        else {
            if (zzzzzzz === "1") {
                document.getElementById("xxxx").checked=true;
            } else if (zzzzzzz === "0") {
                document.getElementById("xxxx").checked=false;
            }
        }

output.js

    // here is to output the value to the web page so we can know 
    // what value is stored in localstorage.
    wwwwwwww = localStorage.getItem('yyyyyyy');
    document.write(wwwwwwww);

page.html

<!-- here is the check box for which the scripts above are based from -->
<input type="checkbox" id="xxxx">Do you like summer?
<br><br>

<!-- here is where it will display the value from localstorage -->
<script src="output.js">

Respuestas a la pregunta(2)

Su respuesta a la pregunta