PluginProbe ʕ •ᴥ•ʔ
Flex Import / 1.9
Flex Import v1.9
2.9 trunk 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8
flex-import / assets / js / dashboard-posts.js
flex-import / assets / js Last commit date
admin-script.js 11 months ago dashboard-posts.js 11 months ago front-script.js 11 months ago jquery.notify.min.js 11 months ago license_script.js 11 months ago plugin-admin.js 11 months ago template-admin.js 11 months ago
dashboard-posts.js
57 lines
1 document.addEventListener('DOMContentLoaded', function() {
2 const dashpostsApiEndpoint = fleximp_dashposts_ajax_object.apiEndpoint;
3 let isFetching = false;
4
5 //new above
6 function fetchPosts() {
7 if (isFetching) return;
8 isFetching = true;
9
10 fetch(dashpostsApiEndpoint, {
11 method: 'POST',
12 headers: {
13 'Content-Type': 'application/json'
14 },
15 body: JSON.stringify({
16 action: 'getLatestPosts'
17 })
18 })
19 .then(response => response.json())
20 .then(data => {
21 if (data.code == 200 && Array.isArray(data.data)) {
22 displayPosts(data.data);
23 } else {
24 console.error('Error fetching plugins:', data);
25 }
26 })
27 .catch(error => {
28 console.error('Error:', error);
29 })
30 .finally(() => {
31 isFetching = false;
32 });
33 }
34
35 // display posts
36 function displayPosts(posts) {
37 const dashPostContainer = document.getElementById('dashboard-list');
38 dashPostContainer.innerHTML = '';
39 // const latestPosts = posts.slice(0, 3);
40 const latestPosts = posts.slice(-3);
41
42 latestPosts.forEach(post => {
43 const postHTML = `
44 <div class="plugin-item">
45 <a href="${post.url}" class="plugin-posts" target="_blank">
46 <div class="flex-imp-sidebar-image-box">
47 <img src="${post.image}" alt="img" style="max-height:75px; max-width:75px;" class="video-img mt-1">
48 </div>
49 <h3 class="plugin-post-title">${post.title}</h3>
50 </a>
51 </div>`;
52 dashPostContainer.innerHTML += postHTML;
53 });
54 }
55 fetchPosts();
56 });
57