Lompat ke isi

MediaWiki:Common.js: Perbedaan antara revisi

Dari Mippedia Data
Tidak ada ringkasan suntingan
Tanda: Suntingan perangkat seluler Suntingan peramban seluler
Tidak ada ringkasan suntingan
Tanda: Suntingan perangkat seluler Suntingan peramban seluler
Baris 1: Baris 1:
/* ==========================================================
/* ==========================================================
   🧠 MIPPEDIA DATA AUTO-DESCRIPTION (PURE & CLEAN)
   🧠 MIPPEDIA DATA AUTO-DESCRIPTION (SMART CHECK EDITION)
   ========================================================== */
   ========================================================== */
(function() {
(function() {
     $(document).ready(function() {
     $(document).ready(function() {
        var $descSection = $('#mip-desc-section');
         var $descBox = $('#mip-auto-description');
         var $descBox = $('#mip-auto-description');
          
          
Baris 21: Baris 22:
                     var pageId = Object.keys(pages)[0];
                     var pageId = Object.keys(pages)[0];
                      
                      
                    // JIKA ARTIKEL ADA (Bukan -1)
                     if (pageId != "-1") {
                     if (pageId != "-1") {
                         var extract = pages[pageId].extract;
                         var extract = pages[pageId].extract;


                         // PEMBERSIHAN TOTAL (Template, Kurung Kosong, Spasi Berantakan)
                         // PEMBERSIHAN TOTAL
                         extract = extract.replace(/\{\{[^}]+\}\}/g, '') // Hapus {{...}}
                         extract = extract.replace(/\{\{[^}]+\}\}/g, '')  
                                         .replace(/\(\s*\)/g, '')      // Hapus ( ) kosong
                                         .replace(/\(\s*\)/g, '')       
                                         .replace(/\s\s+/g, ' ')        // Hapus spasi renggang
                                         .replace(/\s\s+/g, ' ')         
                                         .trim();
                                         .trim();


                         var sourceLink = 'https://id.mippedia.org/wiki/' + encodeURIComponent(pageTitle);
                         if (extract !== "") {
                       
                            var sourceLink = 'https://id.mippedia.org/wiki/' + encodeURIComponent(pageTitle);
                        // Tampilkan teks utuh tanpa fitur lipat
                           
                        $descBox.html(
                            // Masukkan teks dan tampilkan section-nya
                            extract +  
                            $descBox.html(
                            ' <a href="' + sourceLink + '" target="_blank" style="color: #6a5acd; font-weight: bold; text-decoration: none;">Dari Mippedia.</a>'
                                extract +  
                        );
                                ' <a href="' + sourceLink + '" target="_blank" style="color: #6a5acd; font-weight: bold; text-decoration: none;">Dari Mippedia ↗️</a>'
                     }
                            );
                            $descSection.show(); // Munculin section kalau ada isinya
                        }
                     }  
                    // JIKA GAK ADA ARTIKEL: Section tetep sembunyi (display: none)
                 }
                 }
             });
             });

Revisi per 14 April 2026 22.21

/* ==========================================================
   🧠 MIPPEDIA DATA AUTO-DESCRIPTION (SMART CHECK EDITION)
   ========================================================== */
(function() {
    $(document).ready(function() {
        var $descSection = $('#mip-desc-section');
        var $descBox = $('#mip-auto-description');
        
        if ($descBox.length) {
            var pageTitle = mw.config.get('wgPageName');
            var apiUrl = 'https://id.mippedia.org/api.php';

            $.ajax({
                url: apiUrl,
                data: {
                    action: 'query', prop: 'extracts', exintro: true, explaintext: true,
                    titles: pageTitle, format: 'json', origin: '*'
                },
                dataType: 'json',
                success: function(data) {
                    var pages = data.query.pages;
                    var pageId = Object.keys(pages)[0];
                    
                    // JIKA ARTIKEL ADA (Bukan -1)
                    if (pageId != "-1") {
                        var extract = pages[pageId].extract;

                        // PEMBERSIHAN TOTAL
                        extract = extract.replace(/\{\{[^}]+\}\}/g, '') 
                                        .replace(/\(\s*\)/g, '')       
                                        .replace(/\s\s+/g, ' ')        
                                        .trim();

                        if (extract !== "") {
                            var sourceLink = 'https://id.mippedia.org/wiki/' + encodeURIComponent(pageTitle);
                            
                            // Masukkan teks dan tampilkan section-nya
                            $descBox.html(
                                extract + 
                                ' <a href="' + sourceLink + '" target="_blank" style="color: #6a5acd; font-weight: bold; text-decoration: none;">Dari Mippedia ↗️</a>'
                            );
                            $descSection.show(); // Munculin section kalau ada isinya
                        }
                    } 
                    // JIKA GAK ADA ARTIKEL: Section tetep sembunyi (display: none)
                }
            });
        }
    });
})();