-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharchive_view.js
64 lines (56 loc) · 1.94 KB
/
archive_view.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
60
61
62
63
64
import { View } from "./view.js";
import { vkEntityUrl, vkPostUrl } from "./vk_url.js";
import { createAnchor } from "./utils.js";
import { __ } from "./gettext.js";
export class ArchiveView extends View {
constructor() {
super();
this._div = document.createElement('div');
this._backBtn = document.createElement('input');
this._backBtn.setAttribute('type', 'button');
this._backBtn.setAttribute('class', 'av-button-back');
this._backBtn.setAttribute('value', __('Back'));
this._backBtn.onclick = () => {
super._emitSignal('back');
return false;
};
this._div.appendChild(this._backBtn);
this._inner = null;
}
_setInner(inner) {
if (this._inner !== null)
this._inner.remove();
this._div.appendChild(inner);
this._inner = inner;
}
setData(data) {
const inner = document.createElement('div');
if (data.size === 0) {
inner.appendChild(document.createElement('hr'));
inner.append(__('Archive is empty.'));
} else {
for (const [entityId, postData] of data) {
inner.appendChild(document.createElement('hr'));
inner.append(__('Comments by '));
inner.appendChild(createAnchor(vkEntityUrl(entityId)));
inner.appendChild(document.createElement('br'));
const ul = document.createElement('ul');
for (const postDatum of postData) {
const li = document.createElement('li');
const a = createAnchor(vkPostUrl(postDatum.ownerId, postDatum.postId));
li.appendChild(a);
ul.appendChild(li);
}
inner.appendChild(ul);
}
}
this._setInner(inner);
}
get element() {
return this._div;
}
mount() {
}
unmount() {
}
}