bep40 commited on
Commit
a044cc0
·
verified ·
1 Parent(s): b34facb

Upload static/hot_multi.js

Browse files
Files changed (1) hide show
  1. static/hot_multi.js +21 -2
static/hot_multi.js CHANGED
@@ -13,9 +13,28 @@ async function loadHotTopics(){
13
  const topicText=t.topic||t.label.replace(/^#/,'');
14
  return`<button class="hot-chip" onclick="searchTopic('${topicText.replace(/'/g,"\\'")}')">${esc(t.label)}</button>`;
15
  }).join('');
16
- // Load tin HOT = tổng hợp từ TOP 5 hashtag nóng nhất (có AI Thế Giới & AI Việt Nam)
17
  if(topics.length>=2){
18
- loadMultiHashtag(topics.slice(0,5).map(t=>t.topic||t.label.replace(/^#/,'')));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  }else if(topics.length){
20
  searchTopic(topics[0].topic||topics[0].label.replace(/^#/,''));
21
  }
 
13
  const topicText=t.topic||t.label.replace(/^#/,'');
14
  return`<button class="hot-chip" onclick="searchTopic('${topicText.replace(/'/g,"\\'")}')">${esc(t.label)}</button>`;
15
  }).join('');
16
+ // Load tin HOT = tổng hợp từ 5 chủ đề: 3 chủ đề hot nhất + 2 chủ đề AI (AI Thế Giới, AI Việt Nam)
17
  if(topics.length>=2){
18
+ // Ép 2 chủ đề AI vào top 5
19
+ const forcedAI = ['AI Thế Giới', 'AI Việt Nam'];
20
+ const selected = [];
21
+ // Lấy các chủ đề trending đầu tiên (bỏ qua forced AI để tránh trùng)
22
+ for(let i=0; i<topics.length && selected.length < 3; i++){
23
+ const t = topics[i].topic||topics[i].label.replace(/^#/,'');
24
+ if(!forcedAI.some(ai => t.toLowerCase() === ai.toLowerCase())){
25
+ selected.push(t);
26
+ }
27
+ }
28
+ // Thêm 2 chủ đề AI
29
+ forcedAI.forEach(ai => {
30
+ if(selected.length < 5){
31
+ // Tìm trong topics list
32
+ const found = topics.find(t => (t.topic||t.label.replace(/^#/,'')).toLowerCase() === ai.toLowerCase());
33
+ if(found) selected.push(found.topic||found.label.replace(/^#/,''));
34
+ else selected.push(ai);
35
+ }
36
+ });
37
+ loadMultiHashtag(selected);
38
  }else if(topics.length){
39
  searchTopic(topics[0].topic||topics[0].label.replace(/^#/,''));
40
  }