-
Notifications
You must be signed in to change notification settings - Fork 3
/
example.js
35 lines (30 loc) · 965 Bytes
/
example.js
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
document.addEvent('domready', function(){
var iStore = new iStorage();
function storeValues() {
//STORE KEYS WITH DIFFERENT DATA TYPES
iStore.set('mynum', 125);
iStore.set('mybool', true);
iStore.set('mystring', 'hello world');
iStore.set('list', ['dog', 'cat', 'sheep']);
iStore.set('myobj', {
'color': 'red',
'shape': 'circle',
'height': 100,
'width': 200
});
}
$('save-data').addEvent('click', storeValues);
$('clear').addEvent('click', iStore.clear);
if(iStore.get('mystring')) {
$$('h2').set('html', iStore.get('mystring'));
}
if(iStore.get('list')) {
var list = $('list');
var listItems = iStore.get('list');
listItems.each(function(item){
list.adopt(new Element('li', {
'html': item
}));
});
}
});