waibu-maps 2.6.1 → 2.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -7,10 +7,14 @@ async function controlNewsticker () {
|
|
|
7
7
|
return class WmapsControlNewsticker extends WmapsControl {
|
|
8
8
|
static scripts = [
|
|
9
9
|
...super.scripts,
|
|
10
|
-
'
|
|
11
|
-
'
|
|
10
|
+
'bajo.virtual:/dayjs/dayjs.min.js',
|
|
11
|
+
'bajo.virtual:/dayjs/plugin/timezone.js',
|
|
12
|
+
'bajo.virtual:/dayjs/plugin/utc.js',
|
|
13
|
+
'waibuExtra.virtual:/acmeticker/acmeticker.min.js'
|
|
12
14
|
]
|
|
13
15
|
|
|
16
|
+
static inlineScript = 'dayjs.extend(dayjs_plugin_timezone); dayjs.extend(dayjs_plugin_utc)'
|
|
17
|
+
|
|
14
18
|
static css = [
|
|
15
19
|
...super.css,
|
|
16
20
|
'waibuMaps.asset:/css/control-news-ticker.css',
|
|
@@ -18,6 +22,14 @@ async function controlNewsticker () {
|
|
|
18
22
|
'waibuMaps.asset:/css/acmeticker.css'
|
|
19
23
|
]
|
|
20
24
|
|
|
25
|
+
static inlineCss = `
|
|
26
|
+
:root { --at-gtr: 0 }
|
|
27
|
+
.at-ticker-label { --at-bg-cl: #f00 }
|
|
28
|
+
.at-ticker-box { font-size: larger; padding-right: 10px }
|
|
29
|
+
.at-ticker-box ul { padding-top: 5px }
|
|
30
|
+
.text-content { max-height: calc(100vh - 600px); overflow-y: auto }
|
|
31
|
+
`
|
|
32
|
+
|
|
21
33
|
constructor (options) {
|
|
22
34
|
super(options)
|
|
23
35
|
this.params.noTag = true
|
|
@@ -26,29 +38,72 @@ async function controlNewsticker () {
|
|
|
26
38
|
build = async () => {
|
|
27
39
|
const { camelCase } = this.app.lib._
|
|
28
40
|
const { minify } = this.app.waibuMpa
|
|
29
|
-
const { getModel } = this.app.dobo
|
|
30
41
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
42
|
+
this.addBlock('nonReactive', `
|
|
43
|
+
this.posts = []
|
|
44
|
+
`)
|
|
34
45
|
|
|
35
46
|
this.addBlock('reactive', [`
|
|
36
47
|
async ${prefix}Click (id) {
|
|
37
|
-
const item =
|
|
38
|
-
const
|
|
48
|
+
const item = this.posts.find(p => p.id === id)
|
|
49
|
+
const att = item._attachments[0]
|
|
50
|
+
let rsc = ''
|
|
51
|
+
if (att) {
|
|
52
|
+
if (att.mimeType.startsWith('video')) {
|
|
53
|
+
rsc = '<iframe style="height:400px; width:100%" frameborder="0" allowfullscreen scrolling="no" allow="camera; microphone; fullscreen" src="' + att.url + '"></iframe>'
|
|
54
|
+
} else {
|
|
55
|
+
rsc = '<img style="height:400px" class="img-fluid" src="' + att.url + '">'
|
|
56
|
+
}
|
|
57
|
+
}
|
|
39
58
|
const html = '<div class="d-flex border-bottom justify-content-center">' +
|
|
40
|
-
|
|
41
|
-
'</div><div class="px-3 py-2"><h5>' + item.title + '</h5>' +
|
|
59
|
+
rsc +
|
|
60
|
+
'</div><div class="px-3 py-2"><h5>' + item.title + '</h5><div class="text-content">' +
|
|
42
61
|
item.content.replaceAll('\\n', '<br>') +
|
|
43
|
-
'</div>'
|
|
62
|
+
'</div></div>'
|
|
44
63
|
|
|
45
|
-
smaps.showDetails(html)
|
|
64
|
+
smaps.showDetails(html, { title: item.category })
|
|
46
65
|
const el = document.querySelector('.maplibregl-ctrl-newsticker .content')
|
|
47
66
|
if (!el) return
|
|
48
67
|
}
|
|
68
|
+
`, `
|
|
69
|
+
newstickerDt () {
|
|
70
|
+
const el = document.querySelector('.maplibregl-ctrl-newsticker .datetime h5')
|
|
71
|
+
el.textContent = dayjs().tz('Asia/Jakarta').format('HH:mm [WIB]')
|
|
72
|
+
}
|
|
73
|
+
`, `
|
|
74
|
+
async getPosts () {
|
|
75
|
+
if (window.newsticker) window.newsticker.destroy()
|
|
76
|
+
const el = document.querySelector('.maplibregl-ctrl-newsticker .content')
|
|
77
|
+
el.innerHTML = ''
|
|
78
|
+
this.posts = await wmpa.fetchApi('/cms/post', { headers: { 'X-Attachments': 'true' } }, { limit: 1 })
|
|
79
|
+
this.posts.forEach(post => {
|
|
80
|
+
const li = document.createElement('li')
|
|
81
|
+
const a = document.createElement('a')
|
|
82
|
+
a.href = '#'
|
|
83
|
+
a.classList.add('text-decoration-none')
|
|
84
|
+
a.classList.add('text-truncate')
|
|
85
|
+
a.classList.add('d-inline-block')
|
|
86
|
+
a.style.width = '460px'
|
|
87
|
+
a.textContent = post.title.toUpperCase()
|
|
88
|
+
a.addEventListener('click', () => this.${prefix}Click(post.id))
|
|
89
|
+
li.appendChild(a)
|
|
90
|
+
el.appendChild(li)
|
|
91
|
+
})
|
|
92
|
+
window.newsticker = new window.AcmeTicker(el, {
|
|
93
|
+
type: 'vertical',
|
|
94
|
+
direction: 'down',
|
|
95
|
+
speed: 600,
|
|
96
|
+
autoplay: 4000000000
|
|
97
|
+
})
|
|
98
|
+
}
|
|
49
99
|
`])
|
|
50
100
|
|
|
51
|
-
|
|
101
|
+
this.addBlock('run', `
|
|
102
|
+
this.newstickerDt()
|
|
103
|
+
setInterval(this.newstickerDt, 1000)
|
|
104
|
+
await this.getPosts()
|
|
105
|
+
setInterval(this.getPosts, 5 * 60 * 1000)
|
|
106
|
+
`)
|
|
52
107
|
|
|
53
108
|
const ui = await minify(await this.component.buildSentence(`
|
|
54
109
|
<c:div class="childmap maplibregl-ctrl-newsticker" x-data>
|
|
@@ -56,10 +111,9 @@ async function controlNewsticker () {
|
|
|
56
111
|
<c:div class="wrapper maplibregl-ctrl-group">
|
|
57
112
|
<div class="at-ctnr">
|
|
58
113
|
<div class="at-ticker at-flx at-pos at-h at-bdr at-bg-cl">
|
|
59
|
-
<div class="at-ticker-label at-bg-cl at-cl at-p at-flx-srnk-0"
|
|
114
|
+
<div class="at-ticker-label at-bg-cl at-cl at-p at-flx-srnk-0 datetime"><h5></h5></div>
|
|
60
115
|
<c:div class="at-ticker-box at-h at-ovf at-p at-flx-grw-1" margin="start-2">
|
|
61
116
|
<ul class="content">
|
|
62
|
-
${content}
|
|
63
117
|
</ul>
|
|
64
118
|
</c:div>
|
|
65
119
|
</div>
|
package/package.json
CHANGED
package/wiki/CHANGES.md
CHANGED