aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/api/idbindex/locale/index.html
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/fr/web/api/idbindex/locale/index.html
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/fr/web/api/idbindex/locale/index.html')
-rw-r--r--files/fr/web/api/idbindex/locale/index.html133
1 files changed, 133 insertions, 0 deletions
diff --git a/files/fr/web/api/idbindex/locale/index.html b/files/fr/web/api/idbindex/locale/index.html
new file mode 100644
index 0000000000..722e8e547d
--- /dev/null
+++ b/files/fr/web/api/idbindex/locale/index.html
@@ -0,0 +1,133 @@
+---
+title: IDBIndex.locale
+slug: Web/API/IDBIndex/locale
+translation_of: Web/API/IDBIndex/locale
+---
+<div>{{APIRef("IndexedDB")}}{{SeeCompatTable}}</div>
+
+<p>La propriété <strong><code>locale</code></strong> de l'interface {{domxref("IDBIndex")}} renvoie la localisation de l'index (par exemple fr, ou <code>en-US</code>) <code>si la localisation à été spécifie lors de la mise en place de l'index</code> (voir les paramètres {{domxref("IDBObjectStore.createIndex")}}).</p>
+
+<p>{{note("Cette propriété renvoie la localisation utilisé par l'index. En d'autres termes, elle ne renverras jamais 'auto'.")}}</p>
+
+<h2 id="Syntaxe">Syntaxe</h2>
+
+<pre class="brush: js">var indexLocalisation = myIndex.locale;</pre>
+
+<h2 id="Valeur">Valeur</h2>
+
+<p>Une {{domxref("DOMString","chaîne de caractère")}} représentant la localisation courante de l'index.</p>
+
+<h2 id="Exemple">Exemple</h2>
+
+<p>Dans l'exemple suivant on ouvre une transaction puis un magasin d'objet et enfin l'index <code>lName</code>.</p>
+
+<p>La valeur de la propriété <code>Locale</code> est affichée sur la console.</p>
+
+<p>Finalement, On itère sur tous les enregistrements pour en insérer les données dans un tableau HTML. En utilisant la méthode {{domxref("IDBIndex.openCursor")}} qui travaille de la même façon que la méthode {{domxref("IDBObjectStore.openCursor")}} de l'{{domxref("IDBObjectStore","accès")}} au magasin d'objet sauf que les enregistrements sont renvoyés dans l'ordre de l'index et non celui du magasin d'objet.</p>
+
+<pre class="brush:js">function displayDataByIndex() {
+ tableEntry.innerHTML = '';
+
+ //ouvre un transaction
+ var transaction = db.transaction(['contactsList'], 'readonly');
+ //accés au magasin d'objet
+ var objectStore = transaction.objectStore('contactsList');
+
+ //on récupère l'index
+ var myIndex = objectStore.index('lName');
+ //on affiche la propriété locale sur la console
+ console.log(myIndex.locale);
+
+ //un curseur qui itère sur l'index
+ myIndex.openCursor().onsuccess = function(event) {
+ var cursor = event.target.result;
+ if(cursor) {
+ var tableRow = document.createElement('tr');
+ tableRow.innerHTML = '&lt;td&gt;' + cursor.value.id + '&lt;/td&gt;'
+ + '&lt;td&gt;' + cursor.value.lName + '&lt;/td&gt;'
+ + '&lt;td&gt;' + cursor.value.fName + '&lt;/td&gt;'
+ + '&lt;td&gt;' + cursor.value.jTitle + '&lt;/td&gt;'
+ + '&lt;td&gt;' + cursor.value.company + '&lt;/td&gt;'
+ + '&lt;td&gt;' + cursor.value.eMail + '&lt;/td&gt;'
+ + '&lt;td&gt;' + cursor.value.phone + '&lt;/td&gt;'
+ + '&lt;td&gt;' + cursor.value.age + '&lt;/td&gt;';
+ tableEntry.appendChild(tableRow);
+
+ cursor.continue();
+ } else {
+ console.log('Tous les enregistrements ont été affichés.');
+ }
+ };
+};</pre>
+
+<p class="note">Pour un exemple de travail complet, voir notre <a href="https://github.com/mdn/to-do-notifications/">To-do Notifications</a> app (<a href="http://mdn.github.io/to-do-notifications/">view example live</a>).</p>
+
+<h2 id="Spécification">Spécification</h2>
+
+<p>Ne fait actuellement partie d'aucune spécification.</p>
+
+<h2 id="Compatibilité_avec_les_navigateurs">Compatibilité avec les navigateurs</h2>
+
+<div>{{CompatibilityTable}}</div>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Fonctionnalité</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari (WebKit)</th>
+ </tr>
+ <tr>
+ <td>Support basique</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatGeckoDesktop("43.0")}}<sup>[1]</sup></td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Fonctionnalité</th>
+ <th>Android</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>Firefox OS</th>
+ <th>IE Phone</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ </tr>
+ <tr>
+ <td>Support basique</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatGeckoMobile("43.0")}}<sup>[1]</sup></td>
+ <td>2.5<sup>[1]</sup></td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<p>[1] Pour accédé à cette fonctionnalité il faut activé <code>dom.indexedDB.experimental</code> dans <code>about:config</code>.</p>
+
+<h2 id="Voir_aussi">Voir aussi</h2>
+
+<ul>
+ <li>{{domxref("IndexedDB_API.Using_IndexedDB","Utiliser IndexedDB")}}</li>
+ <li>{{domxref("IDBDatabase","Débuter une connexion")}}</li>
+ <li>{{domxref("IDBTransaction","Utilisé les transactions")}}</li>
+ <li>{{domxref("IDBKeyRange","Définir l'intervalle des clés")}}</li>
+ <li>{{domxref("IDBObjectStore","Accès aux magasins d'objets")}}</li>
+ <li>{{domxref("IDBCursor","Utiliser les curseur")}}</li>
+ <li>Exemple de référence: <a class="external" href="https://github.com/mdn/to-do-notifications/tree/gh-pages">To-do Notifications</a> (<a class="external" href="http://mdn.github.io/to-do-notifications/">view example live</a>.)</li>
+</ul>