forked from TechieBoy/Volatile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.js
59 lines (47 loc) · 1.88 KB
/
profile.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
window.onload = getinfo;
async function getinfo() {
let curr_user = await getCurrentUser();
$('#username').text("Hi " + curr_user + "!");
let store = new IdbKvStore(DB_NAME);
let allUserImages = await store.get(curr_user);
console.log(allUserImages);
let ulElement = document.getElementById('slides');
for (let image of allUserImages) {
var liElement = document.createElement('li');
// create the image element
var imageElement = document.createElement('img');
imageElement.setAttribute('src', URL.createObjectURL(image));
imageElement.onload = () => { URL.revokeObjectURL(image.src); }
// append the element to the container
liElement.appendChild(imageElement);
ulElement.appendChild(liElement);
setTimeout(function () {
var elems = document.querySelectorAll('.slider');
var instances = M.Slider.init(elems, { height: 250, interval: 1500, duration: 500 });
var instance = M.Slider.getInstance(elems[0]);
instance.start();
// instance.next();
}, 50);
}
console.log(allUserImages);
let doc = new IdbKvStore(USER_FILES_DB);
let docs_from_db = await doc.get(curr_user);
let alldocs = Object.keys(docs_from_db);
var br = document.createElement('br');
var divElement = document.getElementById('docsList');
divElement.appendChild(br);
let doclist = document.getElementById('docsList');
for (let doc of alldocs) {
var li = document.createElement('li');
var text = document.createTextNode(doc);
li.appendChild(text);
li.classList.add("collection-item");
doclist.appendChild(li);
}
}
async function goToIndex() {
await CURRENT_USER_STORE.clear();
window.open("index.html", "_self");
}
var logout = document.getElementById('logout');
logout.onclick = goToIndex;