<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ca">
	<id>https://cacauet.org/wiki/index.php?action=history&amp;feed=atom&amp;title=LocalStorage_en_Javascript</id>
	<title>LocalStorage en Javascript - Historial de revisió</title>
	<link rel="self" type="application/atom+xml" href="https://cacauet.org/wiki/index.php?action=history&amp;feed=atom&amp;title=LocalStorage_en_Javascript"/>
	<link rel="alternate" type="text/html" href="https://cacauet.org/wiki/index.php?title=LocalStorage_en_Javascript&amp;action=history"/>
	<updated>2026-05-07T08:47:45Z</updated>
	<subtitle>Historial de revisió per a aquesta pàgina del wiki</subtitle>
	<generator>MediaWiki 1.34.0</generator>
	<entry>
		<id>https://cacauet.org/wiki/index.php?title=LocalStorage_en_Javascript&amp;diff=2658&amp;oldid=prev</id>
		<title>Enric a 18:18, 4 maig 2015</title>
		<link rel="alternate" type="text/html" href="https://cacauet.org/wiki/index.php?title=LocalStorage_en_Javascript&amp;diff=2658&amp;oldid=prev"/>
		<updated>2015-05-04T18:18:39Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ca&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Versió més antiga&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revisió del 18:18, 4 maig 2015&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l3&quot; &gt;Línia 3:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Línia 3:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Alguna referència: http://www.w3schools.com/Html/html5_webstorage.asp&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Alguna referència: http://www.w3schools.com/Html/html5_webstorage.asp&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Funcions típiques:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Funcions típiques &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;(funciona similar a un diccionari)&lt;/ins&gt;:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  window.localStorage.addItem( key, val )&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  window.localStorage.addItem( key, val )&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  window.localStorage.removeItem( key )&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  window.localStorage.removeItem( key )&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  window.localStorage.getItem( key )&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  window.localStorage.getItem( key )&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; window.localStorage.length&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Podem utilitzar &amp;lt;code&amp;gt;localStorage.length&amp;lt;/code&amp;gt; per recórrer tots els elements de la memòria interna.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Una BBDD key/value només ens permet guardar estructures simples (strings, int, float). Si volem podem emmagatzemar un array o un diccionari (JS object) cal utilitzar la llibreria JSON per serialitzar-ho.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Una BBDD key/value només ens permet guardar estructures simples (strings, int, float). Si volem podem emmagatzemar un array o un diccionari (JS object) cal utilitzar la llibreria JSON per serialitzar-ho.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Enric</name></author>
		
	</entry>
	<entry>
		<id>https://cacauet.org/wiki/index.php?title=LocalStorage_en_Javascript&amp;diff=2657&amp;oldid=prev</id>
		<title>Enric: Es crea la pàgina amb «localStorage és una '''base de dades tipus key/value interna dels navegadors''' (oju, en altres entorns no existeix o pot funcionar diferent) i que permet emmagatzema...».</title>
		<link rel="alternate" type="text/html" href="https://cacauet.org/wiki/index.php?title=LocalStorage_en_Javascript&amp;diff=2657&amp;oldid=prev"/>
		<updated>2015-05-04T17:45:37Z</updated>

		<summary type="html">&lt;p&gt;Es crea la pàgina amb «localStorage és una &amp;#039;&amp;#039;&amp;#039;base de dades tipus key/value interna dels navegadors&amp;#039;&amp;#039;&amp;#039; (oju, en altres entorns no existeix o pot funcionar diferent) i que permet emmagatzema...».&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Pàgina nova&lt;/b&gt;&lt;/p&gt;&lt;div&gt;localStorage és una '''base de dades tipus key/value interna dels navegadors''' (oju, en altres entorns no existeix o pot funcionar diferent) i que permet emmagatzemar variables internes a les aplicacions en [Javascript].&lt;br /&gt;
&lt;br /&gt;
Alguna referència: http://www.w3schools.com/Html/html5_webstorage.asp&lt;br /&gt;
&lt;br /&gt;
Funcions típiques:&lt;br /&gt;
 window.localStorage.addItem( key, val )&lt;br /&gt;
 window.localStorage.removeItem( key )&lt;br /&gt;
 window.localStorage.getItem( key )&lt;br /&gt;
&lt;br /&gt;
Una BBDD key/value només ens permet guardar estructures simples (strings, int, float). Si volem podem emmagatzemar un array o un diccionari (JS object) cal utilitzar la llibreria JSON per serialitzar-ho.&lt;br /&gt;
 JSON.stringify( objecte )&lt;br /&gt;
 JSON.parse( string )&lt;br /&gt;
&lt;br /&gt;
Codi d'exemple:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
        var tasques = []&lt;br /&gt;
        /* init */&lt;br /&gt;
        var ts = window.localStorage.getItem(&amp;quot;tasques&amp;quot;)&lt;br /&gt;
        if( ts )&lt;br /&gt;
            // carreguem dades inicials&lt;br /&gt;
            tasques = JSON.parse( ts )&lt;br /&gt;
        else&lt;br /&gt;
            // inicialitzem array tasques (nomes primer cop)&lt;br /&gt;
            window.localStorage.setItem( &amp;quot;tasques&amp;quot;, JSON.stringify(tasques) )&lt;br /&gt;
        &lt;br /&gt;
        function grava() {&lt;br /&gt;
            var task = document.forms[0][&amp;quot;task&amp;quot;].value&lt;br /&gt;
            tasques.push( task )&lt;br /&gt;
            // no podem entrar un array per les bones. cal codificar-lo en JSON&lt;br /&gt;
            window.localStorage.setItem( &amp;quot;tasques&amp;quot;, JSON.stringify(tasques) )&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        function carrega() {&lt;br /&gt;
            var llista = document.getElementById(&amp;quot;llista&amp;quot;)&lt;br /&gt;
            llista.innerHTML = &amp;quot;&amp;quot; //buidem llista&lt;br /&gt;
            tasques = JSON.parse( window.localStorage.getItem(&amp;quot;tasques&amp;quot;,tasques) )&lt;br /&gt;
            for( var i in tasques ) {&lt;br /&gt;
                var elem = document.createElement(&amp;quot;li&amp;quot;)&lt;br /&gt;
                elem.innerHTML = tasques[i]&lt;br /&gt;
                llista.appendChild( elem )&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        function esborra_tot() {&lt;br /&gt;
            tasques = []&lt;br /&gt;
            window.localStorage.setItem( &amp;quot;tasques&amp;quot;, JSON.stringify(tasques) )&lt;br /&gt;
        }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;script&amp;gt;//...script anterior...&lt;br /&gt;
    &amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;body onload=&amp;quot;carrega()&amp;quot; &amp;gt;&lt;br /&gt;
    &amp;lt;form onsubmit=&amp;quot;return false;&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;h2&amp;gt;Todo list&amp;lt;/h2&amp;gt;&lt;br /&gt;
        New task:&lt;br /&gt;
        &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;task&amp;quot; /&amp;gt;&lt;br /&gt;
        &amp;lt;input type=&amp;quot;submit&amp;quot; onclick=&amp;quot;grava();carrega();return false;&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;/form&amp;gt;&lt;br /&gt;
    &amp;lt;button onclick=&amp;quot;esborra_tot();carrega()&amp;quot;&amp;gt;Esborra-ho tot&amp;lt;/button&amp;gt;&lt;br /&gt;
    &amp;lt;h3&amp;gt;Tasks to do:&amp;lt;/h3&amp;gt;&lt;br /&gt;
    &amp;lt;ul id=&amp;quot;llista&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;/ul&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Enric</name></author>
		
	</entry>
</feed>