Remember checked boxes in localStorage
This commit is contained in:
parent
0610edbe0a
commit
343440a936
10
index.html
10
index.html
@ -76,7 +76,6 @@
|
|||||||
<label v-bind:for="localeId">{{ country }}</label>
|
<label v-bind:for="localeId">{{ country }}</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- TODO: Remember checkboxes status -->
|
|
||||||
<p>
|
<p>
|
||||||
<input type="submit" value="Search"/>
|
<input type="submit" value="Search"/>
|
||||||
</p>
|
</p>
|
||||||
@ -102,6 +101,11 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var JUSTWATCH_API_DOMAIN = 'https://apis.justwatch.com';
|
var JUSTWATCH_API_DOMAIN = 'https://apis.justwatch.com';
|
||||||
|
|
||||||
|
var checkedLocales = JSON.parse(localStorage.getItem('checkedLocales'));
|
||||||
|
if (!checkedLocales) {
|
||||||
|
checkedLocales = ['fr_FR', 'en_AU', 'en_CA', 'de_DE', 'pl_PL', 'en_SG', 'en_UK'];
|
||||||
|
}
|
||||||
|
|
||||||
var app = new Vue({
|
var app = new Vue({
|
||||||
el: '#app',
|
el: '#app',
|
||||||
computed: {
|
computed: {
|
||||||
@ -114,7 +118,7 @@ var app = new Vue({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
checkedLocales: ['fr_FR', 'en_AU', 'en_CA', 'de_DE', 'pl_PL', 'en_SG', 'en_UK'],
|
checkedLocales: checkedLocales,
|
||||||
availableCountries: {
|
availableCountries: {
|
||||||
"Afghanistan": "ps_AF",
|
"Afghanistan": "ps_AF",
|
||||||
"Albania": "sq_AL",
|
"Albania": "sq_AL",
|
||||||
@ -289,6 +293,8 @@ var app = new Vue({
|
|||||||
} else {
|
} else {
|
||||||
this.checkedLocales.push(localeId);
|
this.checkedLocales.push(localeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
localStorage.setItem('checkedLocales', JSON.stringify(this.checkedLocales));
|
||||||
},
|
},
|
||||||
loadItem(index) {
|
loadItem(index) {
|
||||||
this.offers = {};
|
this.offers = {};
|
||||||
|
Loading…
Reference in New Issue
Block a user