Optimisation de l'interface pour le localStorage avec plusieurs 'dataset' et la sérialisation JSON

This commit is contained in:
xdrm-brackets 2016-04-22 14:58:32 +02:00
parent a2de78f80e
commit 91c7acfc0f
11 changed files with 50 additions and 56 deletions

View File

@ -1,3 +1,3 @@
function localStorageInterface(){} function localStorageInterface(){}
localStorageInterface.prototype={dataset:[],dataset_keys:[],set:function(a,b,d){var c=this.dataset.indexOf(a);if(-1==c)return!1;this.dataset_keys[c].push(b);localStorage.setItem(a,this.dataset_keys[c].join(","));localStorage.setItem(a+"_"+b,d);return!0},get:function(a,b){return-1==this.dataset.indexOf(a)?!1:localStorage.getItem(a+"_"+b)},setObject:function(a,b){if(-1==this.dataset.indexOf(a))return!1;for(var d in b)this.set(a,d,b[d]);return!0},getObject:function(a){var b=this.dataset.indexOf(a);if(-1== localStorageInterface.prototype={dataset:[],dataset_keys:[],set:function(a,b,d){var c=this.dataset.indexOf(a);if(-1==c)return!1;this.dataset_keys[c].push(b);localStorage.setItem(a,JSON.stringify(this.dataset_keys[c]));localStorage.setItem(a+"_"+b,JSON.stringify(d));return!0},get:function(a,b){return-1==this.dataset.indexOf(a)?!1:JSON.parse(localStorage.getItem(a+"_"+b))},createDataset:function(a){if(null==a||"string"!=typeof a)return!1;if(-1<this.dataset.indexOf(a))return!0;var b=localStorage.getItem(a);
b)return!1;for(var d={},c=0;c<this.dataset_keys[b].length;c++)d[this.dataset_keys[b][c]]=this.get(a,this.dataset_keys[b][c]);return d},createDataset:function(a){if(null==a||"string"!=typeof a)return!1;if(-1<this.dataset.indexOf(a))return!0;var b=localStorage.getItem(a);null!=b?(this.dataset.push(a),this.dataset_keys.push(b.split(","))):(this.dataset.push(a),this.dataset_keys.push([]),localStorage.setItem(a,""));return!0}};var lsi=new localStorageInterface; null!=b?(this.dataset.push(a),this.dataset_keys.push(JSON.parse(b))):(this.dataset.push(a),this.dataset_keys.push([]),localStorage.setItem(a,""));return!0},keys:function(a){a=this.dataset.indexOf(a);return-1==a?!1:this.dataset_keys[a]}};var lsi=new localStorageInterface;

View File

@ -23,10 +23,10 @@ localStorageInterface.prototype = {
/* (2) On enregistre la nouvelle clé */ /* (2) On enregistre la nouvelle clé */
this.dataset_keys[index].push(key); this.dataset_keys[index].push(key);
localStorage.setItem(dataset_name, this.dataset_keys[index].join(',')); localStorage.setItem(dataset_name, JSON.stringify(this.dataset_keys[index]));
/* (3) On propage au 'localStorage' */ /* (3) On propage au 'localStorage' */
localStorage.setItem(dataset_name+'_'+key, value); localStorage.setItem(dataset_name+'_'+key, JSON.stringify(value) );
return true; return true;
}, },
@ -44,38 +44,7 @@ localStorageInterface.prototype = {
if( this.dataset.indexOf(dataset_name) == -1 ) return false; // erreur if( this.dataset.indexOf(dataset_name) == -1 ) return false; // erreur
/* (2) On propage au 'localStorage' */ /* (2) On propage au 'localStorage' */
return localStorage.getItem(dataset_name+'_'+key); return JSON.parse( localStorage.getItem(dataset_name+'_'+key) );
},
setObject: function(dataset_name, object){
/* (1) Si le 'dataset' n'existe pas */
var index = this.dataset.indexOf(dataset_name);
if( index == -1 ) return false; // erreur
/* (2) On met toutes les valeurs de l'objet dans le 'localStorage' */
for( var key in object )
this.set(dataset_name, key, object[key]);
/* (3) On retourne que tout s'est bien passé */
return true
},
getObject: function(dataset_name){
/* (1) Si le 'dataset' n'existe pas */
var index = this.dataset.indexOf(dataset_name);
if( index == -1 ) return false; // erreur
/* (2) On récupère toutes les valeurs dans un objet */
var obj = {};
for( var i = 0 ; i < this.dataset_keys[index].length ; i++ )
obj[this.dataset_keys[index][i]] = this.get(dataset_name, this.dataset_keys[index][i]);
/* (3) On retourne l'objet */
return obj;
}, },
@ -99,7 +68,7 @@ localStorageInterface.prototype = {
if( storedDataset != null ){ // Si le dataset existe, on charge les données if( storedDataset != null ){ // Si le dataset existe, on charge les données
this.dataset.push(name); this.dataset.push(name);
this.dataset_keys.push( storedDataset.split(',') ); this.dataset_keys.push( JSON.parse(storedDataset) );
/* (4) Sinon, on le crée 'dataset' */ /* (4) Sinon, on le crée 'dataset' */
}else{ }else{
@ -111,6 +80,16 @@ localStorageInterface.prototype = {
} }
return true; return true;
},
keys: function(dataset_name){
/* (1) Si le 'dataset' n'existe pas */
var index = this.dataset.indexOf(dataset_name);
if( index == -1 ) return false; // erreur
/* (2) On retourne la liste des clés pour ce dataset */
return this.dataset_keys[index];
} }

View File

@ -645,7 +645,7 @@
<span class="warning"><strong>Dead Code</strong></span> <span class="warning"><strong>Dead Code</strong></span>
</p> </p>
<p> <p>
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 2.1.7</a> using <a href="http://php.net/" target="_top">PHP 5.6.11-1ubuntu3.1</a> and <a href="http://phpunit.de/">PHPUnit 4.7.6</a> at Thu Apr 21 9:25:55 UTC 2016.</small> <small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 2.1.7</a> using <a href="http://php.net/" target="_top">PHP 5.6.11-1ubuntu3.1</a> and <a href="http://phpunit.de/">PHPUnit 4.7.6</a> at Fri Apr 22 12:58:04 UTC 2016.</small>
</p> </p>
<a title="Back to the top" id="toplink" href="#"><span class="glyphicon glyphicon-arrow-up"></span></a> <a title="Back to the top" id="toplink" href="#"><span class="glyphicon glyphicon-arrow-up"></span></a>
</footer> </footer>

View File

@ -251,7 +251,7 @@
<span class="warning"><strong>Dead Code</strong></span> <span class="warning"><strong>Dead Code</strong></span>
</p> </p>
<p> <p>
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 2.1.7</a> using <a href="http://php.net/" target="_top">PHP 5.6.11-1ubuntu3.1</a> and <a href="http://phpunit.de/">PHPUnit 4.7.6</a> at Thu Apr 21 9:25:55 UTC 2016.</small> <small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 2.1.7</a> using <a href="http://php.net/" target="_top">PHP 5.6.11-1ubuntu3.1</a> and <a href="http://phpunit.de/">PHPUnit 4.7.6</a> at Fri Apr 22 12:58:04 UTC 2016.</small>
</p> </p>
<a title="Back to the top" id="toplink" href="#"><span class="glyphicon glyphicon-arrow-up"></span></a> <a title="Back to the top" id="toplink" href="#"><span class="glyphicon glyphicon-arrow-up"></span></a>
</footer> </footer>

View File

@ -517,7 +517,7 @@
<span class="warning"><strong>Dead Code</strong></span> <span class="warning"><strong>Dead Code</strong></span>
</p> </p>
<p> <p>
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 2.1.7</a> using <a href="http://php.net/" target="_top">PHP 5.6.11-1ubuntu3.1</a> and <a href="http://phpunit.de/">PHPUnit 4.7.6</a> at Thu Apr 21 9:25:55 UTC 2016.</small> <small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 2.1.7</a> using <a href="http://php.net/" target="_top">PHP 5.6.11-1ubuntu3.1</a> and <a href="http://phpunit.de/">PHPUnit 4.7.6</a> at Fri Apr 22 12:58:04 UTC 2016.</small>
</p> </p>
<a title="Back to the top" id="toplink" href="#"><span class="glyphicon glyphicon-arrow-up"></span></a> <a title="Back to the top" id="toplink" href="#"><span class="glyphicon glyphicon-arrow-up"></span></a>
</footer> </footer>

View File

@ -160,7 +160,7 @@
<tr><td><div align="right"><a name="20"></a><a href="#20">20</a></div></td><td class="codeLine"></td></tr> <tr><td><div align="right"><a name="20"></a><a href="#20">20</a></div></td><td class="codeLine"></td></tr>
<tr><td><div align="right"><a name="21"></a><a href="#21">21</a></div></td><td class="codeLine"></td></tr> <tr><td><div align="right"><a name="21"></a><a href="#21">21</a></div></td><td class="codeLine"></td></tr>
<tr><td><div align="right"><a name="22"></a><a href="#22">22</a></div></td><td class="codeLine"></td></tr> <tr><td><div align="right"><a name="22"></a><a href="#22">22</a></div></td><td class="codeLine"></td></tr>
<tr><td><div align="right"><a name="23"></a><a href="#23">23</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr> <tr><td><div align="right"><a name="23"></a><a href="#23">23</a></div></td><td class="codeLine"></td></tr>
<tr><td><div align="right"><a name="24"></a><a href="#24">24</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">/*&nbsp;AUTOLOADER</span></td></tr> <tr><td><div align="right"><a name="24"></a><a href="#24">24</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">/*&nbsp;AUTOLOADER</span></td></tr>
<tr><td><div align="right"><a name="25"></a><a href="#25">25</a></div></td><td class="codeLine"><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;*</span></td></tr> <tr><td><div align="right"><a name="25"></a><a href="#25">25</a></div></td><td class="codeLine"><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;*</span></td></tr>
<tr><td><div align="right"><a name="26"></a><a href="#26">26</a></div></td><td class="codeLine"><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@className&lt;String&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Nom&nbsp;de&nbsp;la&nbsp;classe&nbsp;appelee</span></td></tr> <tr><td><div align="right"><a name="26"></a><a href="#26">26</a></div></td><td class="codeLine"><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@className&lt;String&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Nom&nbsp;de&nbsp;la&nbsp;classe&nbsp;appelee</span></td></tr>
@ -180,7 +180,7 @@
<tr class="covered-by-large-tests popin" data-title="13 tests cover line 40" data-content="&lt;ul&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_check::testIdSizeInfCorrect&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_check::testIdSizeInfIncorrect&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_check::testMailSizeEqCorrect&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_check::testMailSizeSupCorrect&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_check::testPasswordContentIncorrect&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_construct::testGetInstanceWithNoSERVER&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_construct::testInstancePersistence&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_construct::testInstancePersistenceRefutation&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_delNumeric::testGlobal2Dim&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\ManagerError::testErrorSuccess&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\ModuleRequest::testConstructCorrectPath&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\ModuleRequest::testConstructInvalidTokenValue&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\ModuleRequest::testConstructParamOrdered&lt;/li&gt;&lt;/ul&gt;" data-placement="bottom" data-html="true"><td><div align="right"><a name="40"></a><a href="#40">40</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">require_once</span><span class="default">&nbsp;</span><span class="default">$path</span><span class="keyword">;</span><span class="default">&nbsp;</span><span class="comment">//&nbsp;on&nbsp;inclue&nbsp;le&nbsp;fichier</span></td></tr> <tr class="covered-by-large-tests popin" data-title="13 tests cover line 40" data-content="&lt;ul&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_check::testIdSizeInfCorrect&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_check::testIdSizeInfIncorrect&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_check::testMailSizeEqCorrect&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_check::testMailSizeSupCorrect&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_check::testPasswordContentIncorrect&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_construct::testGetInstanceWithNoSERVER&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_construct::testInstancePersistence&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_construct::testInstancePersistenceRefutation&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_delNumeric::testGlobal2Dim&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\ManagerError::testErrorSuccess&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\ModuleRequest::testConstructCorrectPath&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\ModuleRequest::testConstructInvalidTokenValue&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\ModuleRequest::testConstructParamOrdered&lt;/li&gt;&lt;/ul&gt;" data-placement="bottom" data-html="true"><td><div align="right"><a name="40"></a><a href="#40">40</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">require_once</span><span class="default">&nbsp;</span><span class="default">$path</span><span class="keyword">;</span><span class="default">&nbsp;</span><span class="comment">//&nbsp;on&nbsp;inclue&nbsp;le&nbsp;fichier</span></td></tr>
<tr><td><div align="right"><a name="41"></a><a href="#41">41</a></div></td><td class="codeLine"></td></tr> <tr><td><div align="right"><a name="41"></a><a href="#41">41</a></div></td><td class="codeLine"></td></tr>
<tr class="covered-by-large-tests popin" data-title="13 tests cover line 42" data-content="&lt;ul&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_check::testIdSizeInfCorrect&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_check::testIdSizeInfIncorrect&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_check::testMailSizeEqCorrect&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_check::testMailSizeSupCorrect&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_check::testPasswordContentIncorrect&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_construct::testGetInstanceWithNoSERVER&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_construct::testInstancePersistence&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_construct::testInstancePersistenceRefutation&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_delNumeric::testGlobal2Dim&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\ManagerError::testErrorSuccess&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\ModuleRequest::testConstructCorrectPath&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\ModuleRequest::testConstructInvalidTokenValue&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\ModuleRequest::testConstructParamOrdered&lt;/li&gt;&lt;/ul&gt;" data-placement="bottom" data-html="true"><td><div align="right"><a name="42"></a><a href="#42">42</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span></td></tr> <tr class="covered-by-large-tests popin" data-title="13 tests cover line 42" data-content="&lt;ul&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_check::testIdSizeInfCorrect&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_check::testIdSizeInfIncorrect&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_check::testMailSizeEqCorrect&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_check::testMailSizeSupCorrect&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_check::testPasswordContentIncorrect&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_construct::testGetInstanceWithNoSERVER&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_construct::testInstancePersistence&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_construct::testInstancePersistenceRefutation&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\Database_delNumeric::testGlobal2Dim&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\ManagerError::testErrorSuccess&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\ModuleRequest::testConstructCorrectPath&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\ModuleRequest::testConstructInvalidTokenValue&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;phpunit\ModuleRequest::testConstructParamOrdered&lt;/li&gt;&lt;/ul&gt;" data-placement="bottom" data-html="true"><td><div align="right"><a name="42"></a><a href="#42">42</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span></td></tr>
<tr><td><div align="right"><a name="43"></a><a href="#43">43</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr> <tr><td><div align="right"><a name="43"></a><a href="#43">43</a></div></td><td class="codeLine"></td></tr>
<tr><td><div align="right"><a name="44"></a><a href="#44">44</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;On&nbsp;definit&nbsp;l'autoloader&nbsp;comme&nbsp;autoloader&nbsp;(obvious)</span></td></tr> <tr><td><div align="right"><a name="44"></a><a href="#44">44</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;On&nbsp;definit&nbsp;l'autoloader&nbsp;comme&nbsp;autoloader&nbsp;(obvious)</span></td></tr>
<tr><td><div align="right"><a name="45"></a><a href="#45">45</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">spl_autoload_register</span><span class="keyword">(</span><span class="default">'autoloader'</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">false</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">true</span><span class="keyword">)</span><span class="keyword">;</span></td></tr> <tr><td><div align="right"><a name="45"></a><a href="#45">45</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">spl_autoload_register</span><span class="keyword">(</span><span class="default">'autoloader'</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">false</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">true</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
<tr><td><div align="right"><a name="46"></a><a href="#46">46</a></div></td><td class="codeLine"></td></tr> <tr><td><div align="right"><a name="46"></a><a href="#46">46</a></div></td><td class="codeLine"></td></tr>
@ -214,7 +214,7 @@
<span class="warning"><strong>Dead Code</strong></span> <span class="warning"><strong>Dead Code</strong></span>
</p> </p>
<p> <p>
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 2.1.7</a> using <a href="http://php.net/" target="_top">PHP 5.6.11-1ubuntu3.1</a> and <a href="http://phpunit.de/">PHPUnit 4.7.6</a> at Thu Apr 21 9:25:55 UTC 2016.</small> <small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 2.1.7</a> using <a href="http://php.net/" target="_top">PHP 5.6.11-1ubuntu3.1</a> and <a href="http://phpunit.de/">PHPUnit 4.7.6</a> at Fri Apr 22 12:58:04 UTC 2016.</small>
</p> </p>
<a title="Back to the top" id="toplink" href="#"><span class="glyphicon glyphicon-arrow-up"></span></a> <a title="Back to the top" id="toplink" href="#"><span class="glyphicon glyphicon-arrow-up"></span></a>
</footer> </footer>

View File

@ -350,7 +350,7 @@
<span class="success"><strong>High</strong>: 90% to 100%</span> <span class="success"><strong>High</strong>: 90% to 100%</span>
</p> </p>
<p> <p>
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 2.1.7</a> using <a href="http://php.net/" target="_top">PHP 5.6.11-1ubuntu3.1</a> and <a href="http://phpunit.de/">PHPUnit 4.7.6</a> at Thu Apr 21 9:25:55 UTC 2016.</small> <small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 2.1.7</a> using <a href="http://php.net/" target="_top">PHP 5.6.11-1ubuntu3.1</a> and <a href="http://phpunit.de/">PHPUnit 4.7.6</a> at Fri Apr 22 12:58:04 UTC 2016.</small>
</p> </p>
</footer> </footer>
</div> </div>

View File

@ -315,7 +315,7 @@
<span class="warning"><strong>Dead Code</strong></span> <span class="warning"><strong>Dead Code</strong></span>
</p> </p>
<p> <p>
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 2.1.7</a> using <a href="http://php.net/" target="_top">PHP 5.6.11-1ubuntu3.1</a> and <a href="http://phpunit.de/">PHPUnit 4.7.6</a> at Thu Apr 21 9:25:55 UTC 2016.</small> <small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 2.1.7</a> using <a href="http://php.net/" target="_top">PHP 5.6.11-1ubuntu3.1</a> and <a href="http://phpunit.de/">PHPUnit 4.7.6</a> at Fri Apr 22 12:58:04 UTC 2016.</small>
</p> </p>
<a title="Back to the top" id="toplink" href="#"><span class="glyphicon glyphicon-arrow-up"></span></a> <a title="Back to the top" id="toplink" href="#"><span class="glyphicon glyphicon-arrow-up"></span></a>
</footer> </footer>

View File

@ -69,7 +69,7 @@
<input type='text' data-name='lastname' placeholder='Nom'> <input type='text' data-name='lastname' placeholder='Nom'>
<input type='submit' class='primary sub-number' data-store value='Enregistrer'> <input type='submit' class='primary sub-number' data-store value='Enregistrer'>
</h4> </h4>
<h4 data-icon='+' class='add-contact line' style='cursor: pointer;'>Ajouter un contact</h4> <h4 data-icon='+' class='add-contact' style='cursor: pointer;'>Ajouter un contact</h4>
<!-- <span data-tag='ET'></span> --> <!-- <span data-tag='ET'></span> -->
</article> </article>

View File

@ -1,4 +1,5 @@
function newContactHTMLBuilder(){var a=document.createElement("h4");a.dataset.icon="p";a.className="new-contact";a.innerHTML="<input type='text' data-name='number' placeholder='Num\u00e9ro de t\u00e9l\u00e9phone'> ";a.innerHTML+="<input type='text' data-name='username' placeholder='Pseudo'> ";a.innerHTML+="<input type='text' data-name='firstname' placeholder='Pr\u00e9nom'> ";a.innerHTML+="<input type='text' data-name='lastname' placeholder='Nom'> ";a.innerHTML+="<input type='submit' class='primary sub-number' value='Enregistrer'>"; function newContactHTMLBuilder(a,b,c,d){var e=document.createElement("h4");e.dataset.icon="p";e.className="new-contact";a="<input type='text' data-name='number' placeholder='Num\u00e9ro de t\u00e9l\u00e9phone' value='"+("undefined"!=typeof a?a:"")+"'> ";a+="<input type='text' data-name='username' placeholder='Pseudo' value='";a+="undefined"!=typeof b?b:"";a+="'> ";a+="<input type='text' data-name='firstname' placeholder='Pr\u00e9nom' value='";a+="undefined"!=typeof c?c:"";a+="'> ";a+="<input type='text' data-name='lastname' placeholder='Nom' value='";
return a}var ficheRelationHTML="";function updateListener(a,b,c,d){a.removeEventListener(b,c);d.addEventListener(b,c);return d}var ic=new inputChecker,FormDeflaterP={tags:["input"],attr:["data-name"]},importCallLog=$('input#call_log-import[type="file"]'),contactDeflaters=[];function contactForms(){var a=$$("h4.new-contact");contactDeflaters=[];for(var b=0;b<a.length;b++)contactDeflaters.push(new FormDeflater(a[b],FormDeflaterP.tags,FormDeflaterP.attr));return a} a+="undefined"!=typeof d?d:"";a+="'> ";a+="<input type='submit' class='primary sub-number' value='Enregistrer'>";e.innerHTML=a;return e}var ficheRelationHTML="";function updateListener(a,b,c,d){a.removeEventListener(b,c);d.addEventListener(b,c);return d}var ic=new inputChecker,FormDeflaterP={tags:["input"],attr:["data-name"]},importCallLog=$('input#call_log-import[type="file"]'),contactDeflaters=[];
var addContact=$("h4.add-contact"),contactContainer=$("article.contact-panel");function addNewContact(){console.log("adding New Contact");console.log(contactContainer.children);contactContainer.removeChild(addContact);contactContainer.appendChild(newContactHTMLBuilder());contactContainer.appendChild(addContact)}addContact.addEventListener("click",addNewContact,!1);var relationDeflaters=[]; function contactForms(){var a=$$("h4.new-contact");contactDeflaters=[];for(var b=0;b<a.length;b++)contactDeflaters.push(new FormDeflater(a[b],FormDeflaterP.tags,FormDeflaterP.attr));return a}var addContact=$("h4.add-contact"),contactContainer=$("article.contact-panel");
function addNewContact(){console.log("adding New Contact");console.log(contactContainer.children);contactContainer.removeChild(addContact);contactContainer.appendChild(newContactHTMLBuilder());contactContainer.appendChild(addContact)}addContact.addEventListener("click",addNewContact,!1);var relationDeflaters=[];
function relationForms(){var a=$$("h4.fiche-relation");relationDeflaters=[];for(var b=0;b<a.length;b++)relationDeflaters.push(new FormDeflater(a[b],FormDeflaterP.tags,FormDeflaterP.attr));return a}importCallLog.addEventListener("change",function(a){api.send({path:"upload/call_log",file:importCallLog.files[0]},function(a){console.log(a);0==a.ModuleError&&importCallLog.addClass("active")})},!1); function relationForms(){var a=$$("h4.fiche-relation");relationDeflaters=[];for(var b=0;b<a.length;b++)relationDeflaters.push(new FormDeflater(a[b],FormDeflaterP.tags,FormDeflaterP.attr));return a}importCallLog.addEventListener("change",function(a){api.send({path:"upload/call_log",file:importCallLog.files[0]},function(a){console.log(a);0==a.ModuleError&&importCallLog.addClass("active")})},!1);

View File

@ -1,5 +1,5 @@
// STRUCTURE DU localStorage // STRUCTURE DU localStorage
// subject-data -> contient // subject-data -> contient
// contacts-data // contacts-data
// fiches-relation // fiches-relation
@ -22,16 +22,30 @@
/* [0] Gestion des constantes et fonctions /* [0] Gestion des constantes et fonctions
=========================================================*/ =========================================================*/
/* (1) Contiendra le formulaire d'ajout de contact (numéro, pseudo, prénom, nom, submit) */ /* (1) Contiendra le formulaire d'ajout de contact (numéro, pseudo, prénom, nom, submit) */
function newContactHTMLBuilder(){ function newContactHTMLBuilder(number, username, firstname, lastname){
var root = document.createElement('h4'); var root = document.createElement('h4');
root.dataset.icon = 'p'; root.dataset.icon = 'p';
root.className = 'new-contact'; root.className = 'new-contact';
root.innerHTML = "<input type='text' data-name='number' placeholder='Numéro de téléphone'> "; var contentHTML = "<input type='text' data-name='number' placeholder='Numéro de téléphone' value='";
root.innerHTML += "<input type='text' data-name='username' placeholder='Pseudo'> "; contentHTML += (typeof number != 'undefined') ? number : '';
root.innerHTML += "<input type='text' data-name='firstname' placeholder='Prénom'> "; contentHTML += "'> ";
root.innerHTML += "<input type='text' data-name='lastname' placeholder='Nom'> ";
root.innerHTML += "<input type='submit' class='primary sub-number' value='Enregistrer'>"; contentHTML += "<input type='text' data-name='username' placeholder='Pseudo' value='";
contentHTML += (typeof username != 'undefined') ? username : '';
contentHTML += "'> ";
contentHTML += "<input type='text' data-name='firstname' placeholder='Prénom' value='";
contentHTML += (typeof firstname != 'undefined') ? firstname : '';
contentHTML += "'> ";
contentHTML += "<input type='text' data-name='lastname' placeholder='Nom' value='";
contentHTML += (typeof lastname != 'undefined') ? lastname : '';
contentHTML += "'> ";
contentHTML += "<input type='submit' class='primary sub-number' value='Enregistrer'>";
root.innerHTML = contentHTML;
return root; return root;
} }