-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocals-verification-localstorage.html
79 lines (64 loc) · 1.68 KB
/
locals-verification-localstorage.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/iron-localstorage/iron-localstorage.html">
<dom-module id="locals-verification-localstorage">
<template>
<iron-localstorage
name="lsverifications"
value="{{localstoragevalue}}"
on-iron-localstorage-load-empty="init">
</iron-localstorage>
</template>
<script>
Polymer({
is: 'locals-verification-localstorage',
properties: {
localstoragevalue: {
type: String,
observer: '_localstorage'
},
data: {
type: Object,
notify: true,
value: {},
observer: '_data'
},
nrofitems: {
type: Number,
notify: true,
observer: '_nrofitems'
}
},
ready: function(){
console.log('hello from kf');
},
init: function(){
this.localstoragevalue = JSON.stringify(this.data);
},
_localstorage: function(){
this.data = JSON.parse(this.localstoragevalue);
if (this.data){
this.nrofitems = Object.keys(this.data).length;
console.log('WAITING: ',this.nrofitems);
this.fire('ls-changed', this.data);
}
},
_nrofitems: function(){
console.log('nrofitems changed', this.nrofitems);
this.fire('items-changed', this.nrofitems);
},
_data: function(){
},
save: function(){
if (this.data){
this.localstoragevalue = JSON.stringify(this.data);
this.fire('items-changed', Object.keys(this.data).length);
this.nrofitems = Object.keys(this.data).length;
console.log('saving ls');
}
},
read: function(){
this.save();
}
});
</script>
</dom-module>