MediaWiki:Common.js: Perbedaan antara revisi
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 - ADVANCED STRUCTURED DATA SYSTEM ( | * MIPPEDIA DATA - ADVANCED STRUCTURED DATA SYSTEM (V10.0 FINAL) | ||
* ==================================================================== | * ==================================================================== | ||
*/ | */ | ||
| Baris 7: | Baris 7: | ||
'use strict'; | 'use strict'; | ||
function | function isEntityNamespacePage() { | ||
if (typeof mw === 'undefined' || !mw.config) return false; | if (typeof mw === 'undefined' || !mw.config) return false; | ||
var ns = mw.config.get('wgNamespaceNumber'); | var ns = mw.config.get('wgNamespaceNumber'); | ||
var pageName = mw.config.get('wgPageName') || ''; | var pageName = mw.config.get('wgPageName') || ''; | ||
var action = mw.config.get('wgAction') || 'view'; | var action = mw.config.get('wgAction') || 'view'; | ||
| Baris 16: | Baris 15: | ||
if (ns !== 0 || isMain || action !== 'view') return false; | if (ns !== 0 || isMain || action !== 'view') return false; | ||
if (/^(Istimewa|Special|MediaWiki|Berkas|File|Kategori|Category|Templat|Template|Modul|Module|Bantuan|Help|Proyek|Project):/i.test(pageName)) { | if (/^(Istimewa|Special|MediaWiki|Berkas|File|Kategori|Category|Templat|Template|Modul|Module|Bantuan|Help|Proyek|Project):/i.test(pageName)) { | ||
return false; | return false; | ||
} | } | ||
return true; | |||
} | |||
function isLoggedInUser() { | |||
if (typeof mw === 'undefined' || !mw.config) return false; | |||
return !!mw.config.get('wgUserName'); | |||
if ( | |||
} | } | ||
function | function isRedirectView() { | ||
if (typeof mw !== 'undefined' && mw.config && mw.config.get('wgIsRedirect')) return true; | if (typeof mw !== 'undefined' && mw.config && mw.config.get('wgIsRedirect')) return true; | ||
if ($('.redirectMsg, .mw-redirect-link').length > 0) return true; | if ($('.redirectMsg, .mw-redirect-link').length > 0) return true; | ||
| Baris 41: | Baris 33: | ||
} | } | ||
if (! | if (!isEntityNamespacePage()) return; | ||
mw.loader.using(['mediawiki.api', 'mediawiki.util']).then(function() { | mw.loader.using(['mediawiki.api', 'mediawiki.util']).then(function() { | ||
| Baris 47: | Baris 39: | ||
var pageName = mw.config.get('wgPageName'); | var pageName = mw.config.get('wgPageName'); | ||
var cleanPageTitle = pageName.replace(/_/g, ' '); | var cleanPageTitle = pageName.replace(/_/g, ' '); | ||
var | var isLoggedIn = isLoggedInUser(); | ||
var dataItems = []; | var dataItems = []; | ||
var isLocked = false; | var isLocked = false; | ||
| Baris 56: | Baris 48: | ||
var schemaMeta = { | var schemaMeta = { | ||
description: '', | description: '', | ||
articleUrl: '', | |||
creatorName: 'Para kontributor proyek Mippedia Community' | creatorName: 'Para kontributor proyek Mippedia Community' | ||
}; | }; | ||
| Baris 292: | Baris 285: | ||
function fetchAutoDescriptionForSchema() { | function fetchAutoDescriptionForSchema() { | ||
var | var cleanExtractStr = function(txt) { | ||
var s = (txt || '').replace(/\[\d+\]/g, '').replace(/\{\{[^}]+\}\}/g, '').replace(/\s+/g, ' ').trim(); | var s = (txt || '').replace(/\[\d+\]/g, '').replace(/\{\{[^}]+\}\}/g, '').replace(/\s+/g, ' ').trim(); | ||
if (s.length > 300) { | if (s.length > 300) { | ||
| Baris 317: | Baris 310: | ||
var idKey = pages ? Object.keys(pages)[0] : '-1'; | var idKey = pages ? Object.keys(pages)[0] : '-1'; | ||
if (idKey !== '-1' && pages[idKey] && pages[idKey].extract) { | if (idKey !== '-1' && pages[idKey] && pages[idKey].extract) { | ||
var extId = | var extId = cleanExtractStr(pages[idKey].extract); | ||
if (extId) { | if (extId) { | ||
schemaMeta.description = extId; | schemaMeta.description = extId; | ||
schemaMeta.articleUrl = 'https://id.mippedia.org/wiki/' + encodeURIComponent(cleanPageTitle.replace(/ /g, '_')); | |||
return; | return; | ||
} | } | ||
| Baris 360: | Baris 354: | ||
var enKey = enPages ? Object.keys(enPages)[0] : '-1'; | var enKey = enPages ? Object.keys(enPages)[0] : '-1'; | ||
if (enKey !== '-1' && enPages[enKey] && enPages[enKey].extract) { | if (enKey !== '-1' && enPages[enKey] && enPages[enKey].extract) { | ||
var extEn = | var extEn = cleanExtractStr(enPages[enKey].extract); | ||
if (extEn) schemaMeta.description = extEn; | if (extEn) { | ||
schemaMeta.description = extEn; | |||
schemaMeta.articleUrl = 'https://en.mippedia.org/wiki/' + encodeURIComponent(enTarget.replace(/ /g, '_')); | |||
} | |||
} | } | ||
}); | }); | ||
| Baris 370: | Baris 367: | ||
} | } | ||
// | // Schema.org JSON-LD: satu Dataset, isPartOf ke katalog data, sameAs otomatis dari media sosial & artikel ensiklopedia | ||
function updateJsonLdForSearchEngines() { | function updateJsonLdForSearchEngines() { | ||
if (! | if (!isEntityNamespacePage() || isRedirectView()) return; | ||
var sameAsSet = {}; | |||
if (schemaMeta.articleUrl) { | |||
sameAsSet[schemaMeta.articleUrl] = true; | |||
} | |||
var additionalProperties = []; | var additionalProperties = []; | ||
var citations = []; | var citations = []; | ||
| Baris 389: | Baris 390: | ||
} | } | ||
additionalProperties.push(propObj); | additionalProperties.push(propObj); | ||
// Deteksi URL media sosial langsung dari nilai data jika ada | |||
var urlMatches = (item.val || '').match(/https?:\/\/[^\s\]"'<>]+/gi) || []; | |||
urlMatches.forEach(function(u) { | |||
var safeU = ensureHttps(u); | |||
if (safeU && /(instagram\.com|tiktok\.com|youtube\.com|youtu\.be|x\.com|twitter\.com|threads\.net|facebook\.com|linkedin\.com|spotify\.com|music\.apple\.com|soundcloud\.com|bandcamp\.com|github\.com|pinterest\.com)/i.test(safeU)) { | |||
sameAsSet[safeU] = true; | |||
} | |||
}); | |||
} | } | ||
if ( | if (item.socials) { | ||
Object.keys(SOCIAL_PLATFORMS).forEach(function(k) { | Object.keys(SOCIAL_PLATFORMS).forEach(function(k) { | ||
var uname = item.socials[k]; | var uname = (item.socials[k] || '').trim(); | ||
if (uname) { | if (uname) { | ||
var cleanU = uname.replace(/^@/, ''); | |||
var fullSocialUrl = /^https?:\/\//i.test(cleanU) ? ensureHttps(cleanU) : (SOCIAL_PLATFORMS[k].base + cleanU); | |||
if (fullSocialUrl) sameAsSet[fullSocialUrl] = true; | |||
} | } | ||
}); | }); | ||
| Baris 412: | Baris 424: | ||
} | } | ||
}); | }); | ||
var sameAsList = Object.keys(sameAsSet); | |||
var finalDesc = schemaMeta.description; | var finalDesc = schemaMeta.description; | ||
| Baris 452: | Baris 466: | ||
if (citations.length > 0) ldJson.citation = citations; | if (citations.length > 0) ldJson.citation = citations; | ||
$('script[type="application/ld+json"]').each(function() { | $('script[type="application/ld+json"]').each(function() { | ||
if (this.id === 'mip-jsonld-schema') return; | if (this.id === 'mip-jsonld-schema') return; | ||
| Baris 731: | Baris 744: | ||
function saveData(actionType, $btnEl, originalContent, customSummary, isMinorEdit) { | function saveData(actionType, $btnEl, originalContent, customSummary, isMinorEdit) { | ||
if (!isLoggedIn) { | |||
showModal('Perlu Login Akun Terdaftar', 'Hanya pengguna terdaftar yang sudah login yang dapat menambah atau mengubah data terstruktur. Silakan masuk (login) terlebih dahulu.'); | |||
return; | |||
} | |||
if ($btnEl) $btnEl.addClass('is-loading').prop('disabled', true); | if ($btnEl) $btnEl.addClass('is-loading').prop('disabled', true); | ||
var summaryTxt = customSummary ? ('Mippedia Data: ' + customSummary) : ('Mippedia Data | var summaryTxt = customSummary ? ('Mippedia Data: ' + customSummary) : ('Mippedia Data V10.0: ' + actionType); | ||
var jsonStr = JSON.stringify({ locked: isLocked, items: dataItems }); | var jsonStr = JSON.stringify({ locked: isLocked, items: dataItems }); | ||
var wt = "<!-- MIPPEDIA_DATA_START | " + jsonStr + " -->\n"; | var wt = "<!-- MIPPEDIA_DATA_START | " + jsonStr + " -->\n"; | ||
| Baris 794: | Baris 811: | ||
// 7. BUILDER UI UTAMA | // 7. BUILDER UI UTAMA | ||
function buildUI(rawContent) { | function buildUI(rawContent) { | ||
if ( | if (isRedirectView()) return; | ||
updateJsonLdForSearchEngines(); | updateJsonLdForSearchEngines(); | ||
| Baris 807: | Baris 824: | ||
$actions.append($jsonBtn); | $actions.append($jsonBtn); | ||
if ( | if (!isLocked || isLoggedIn) { | ||
var $ | var $addBtn = $('<button class="md-btn-icon" title="Tambah Data Baru">' + svgEdit + ' Tambah</button>'); | ||
$ | $addBtn.on('click', function() { | ||
if (!isLoggedIn) { | |||
showModal('Login Diperlukan', 'Silakan masuk (login) dengan akun terdaftar untuk menambah data terstruktur baru.'); | |||
return; | |||
} | |||
showForm(-1, rawContent); | |||
}); | }); | ||
$actions.append($addBtn); | $actions.append($addBtn); | ||
} | } | ||
| Baris 968: | Baris 982: | ||
$row.append($info); | $row.append($info); | ||
if ( | if (!isLoggedIn) { | ||
var $ | var $loginEditBtn = $('<button class="md-btn-icon edit-btn" style="color:#4f46e5; border-color:#c7d2fe; background:#eef2ff;">' + svgEdit + ' Login untuk Edit</button>'); | ||
$ | $loginEditBtn.on('click', function() { | ||
showModal(' | showModal('Akun Terdaftar Diperlukan', 'Pengguna anonim tidak dapat mengedit data. Silakan login menggunakan akun terdaftar Anda untuk mengedit data terstruktur.'); | ||
}); | }); | ||
$row.append($ | $row.append($loginEditBtn); | ||
} else { | } else { | ||
var $editIcon = $('<button class="md-btn-icon edit-btn">' + svgEdit + ' Edit</button>'); | var $editIcon = $('<button class="md-btn-icon edit-btn">' + svgEdit + ' Edit</button>'); | ||
| Baris 1.034: | Baris 1.048: | ||
// 8. FORM EDIT & DRAFT LOGIC | // 8. FORM EDIT & DRAFT LOGIC | ||
function showForm(index, rawContent) { | function showForm(index, rawContent) { | ||
if (!isLoggedIn) { | |||
showModal('Akun Terdaftar Diperlukan', 'Silakan login menggunakan akun terdaftar untuk menambah atau mengedit data.'); | |||
return; | |||
} | |||
var $container = $('#md-form-container').empty(); | var $container = $('#md-form-container').empty(); | ||
var isNew = index === -1; | var isNew = index === -1; | ||
| Baris 1.114: | Baris 1.132: | ||
var $socialSec = $('<div class="md-form-group" style="margin-top:16px;"></div>'); | var $socialSec = $('<div class="md-form-group" style="margin-top:16px;"></div>'); | ||
var chkPerson = currentData.isPersonOrg ? 'checked' : ''; | var chkPerson = currentData.isPersonOrg ? 'checked' : ''; | ||
$socialSec.append('<label style="display:flex; align-items:center; gap:8px; cursor:pointer; background:#e0e7ff; padding:10px; border-radius:8px; font-weight:700; color:#3730a3; font-size:0.85rem;"><input type="checkbox" id="md-chk-person" ' + chkPerson + '> Simpan Profil Media Sosial (Akan muncul di paling atas) <span class="md-help-icon" data-help="Centang ini untuk mengisi data sosial media. Datanya akan dihimpun | $socialSec.append('<label style="display:flex; align-items:center; gap:8px; cursor:pointer; background:#e0e7ff; padding:10px; border-radius:8px; font-weight:700; color:#3730a3; font-size:0.85rem;"><input type="checkbox" id="md-chk-person" ' + chkPerson + '> Simpan Profil Media Sosial (Akan muncul di paling atas & masuk ke Schema sameAs) <span class="md-help-icon" data-help="Centang ini untuk mengisi data sosial media. Datanya akan dihimpun di kotak teratas dan otomatis masuk ke properti sameAs Schema.org.">' + svgHelp + '</span></label>'); | ||
var $socialGrid = $('<div class="md-social-grid" id="md-social-box" style="display:' + (currentData.isPersonOrg ? 'grid' : 'none') + '; margin-top:8px;"></div>'); | var $socialGrid = $('<div class="md-social-grid" id="md-social-box" style="display:' + (currentData.isPersonOrg ? 'grid' : 'none') + '; margin-top:8px;"></div>'); | ||
| Baris 1.126: | Baris 1.144: | ||
var $refArea = $('<div class="md-form-group" style="margin-top:20px;"></div>'); | var $refArea = $('<div class="md-form-group" style="margin-top:20px;"></div>'); | ||
$refArea.append('<label style="font-size:0.95rem; font-weight:800; color:#0f172a; margin-bottom:10px;">Sumber Referensi <span class="md-help-icon" data-help="Mohon berikan sumber referensi yang valid, kredibel, dan dapat dipertanggungjawabkan | $refArea.append('<label style="font-size:0.95rem; font-weight:800; color:#0f172a; margin-bottom:10px;">Sumber Referensi <span class="md-help-icon" data-help="Mohon berikan sumber referensi yang valid, kredibel, dan dapat dipertanggungjawabkan.">' + svgHelp + '</span></label>'); | ||
var $refGrid = $('<div class="md-ref-grid"></div>'); | var $refGrid = $('<div class="md-ref-grid"></div>'); | ||
| Baris 1.182: | Baris 1.200: | ||
'</div>' + | '</div>' + | ||
'<div class="md-edit-meta">' + | '<div class="md-edit-meta">' + | ||
'<label style="font-size:0.85rem; font-weight:700;">Ringkasan Suntingan <span class="md-help-icon" data-help="Jelaskan secara singkat apa yang Anda ubah atau tambahkan | '<label style="font-size:0.85rem; font-weight:700;">Ringkasan Suntingan <span class="md-help-icon" data-help="Jelaskan secara singkat apa yang Anda ubah atau tambahkan.">' + svgHelp + '</span></label>' + | ||
'<input type="text" id="md-edit-summary" class="md-input" placeholder="Jelaskan perubahan Anda secara singkat...">' + | '<input type="text" id="md-edit-summary" class="md-input" placeholder="Jelaskan perubahan Anda secara singkat...">' + | ||
'<label style="font-size:0.85rem; cursor:pointer; font-weight:700; margin-top:5px; display:inline-flex; align-items:center; gap:6px;"><input type="checkbox" id="md-minor-edit"> Ini adalah suntingan kecil (minor)</label>' + | '<label style="font-size:0.85rem; cursor:pointer; font-weight:700; margin-top:5px; display:inline-flex; align-items:center; gap:6px;"><input type="checkbox" id="md-minor-edit"> Ini adalah suntingan kecil (minor)</label>' + | ||
| Baris 1.325: | Baris 1.343: | ||
$btnCancel.on('click', function() { $container.empty(); }); | $btnCancel.on('click', function() { $container.empty(); }); | ||
$btnImport.on('click', function() { | $btnImport.on('click', function() { | ||
if (!isLoggedIn) { | |||
showModal('Akun Terdaftar Diperlukan', 'Silakan login menggunakan akun terdaftar untuk mengimpor dan menyimpan JSON.'); | |||
return; | |||
} | |||
try { | try { | ||
var parsed = JSON.parse($txt.val()); | var parsed = JSON.parse($txt.val()); | ||
| Baris 1.341: | Baris 1.363: | ||
// 10. EXECUTE | // 10. EXECUTE | ||
loadData().then(function(rawContent) { | loadData().then(function(rawContent) { | ||
if ( | if (isRedirectView()) return; | ||
var candidates = collectCandidateTitlesForLinks(); | var candidates = collectCandidateTitlesForLinks(); | ||
checkPagesExistBatch(candidates).always(function() { | checkPagesExistBatch(candidates).always(function() { | ||
| Baris 1.392: | Baris 1.414: | ||
/* ========================================================== | /* ========================================================== | ||
🧠 MIPPEDIA DATA - SMART CONTEXT + REDIRECT & HIDE ENGINE ( | 🧠 MIPPEDIA DATA - SMART CONTEXT + REDIRECT & HIDE ENGINE (V11.0) | ||
========================================================== */ | ========================================================== */ | ||
(function() { | (function() { | ||
function | function isValidEntityPage() { | ||
if (typeof mw === 'undefined' || !mw.config) return false; | if (typeof mw === 'undefined' || !mw.config) return false; | ||
var ns = mw.config.get('wgNamespaceNumber'); | var ns = mw.config.get('wgNamespaceNumber'); | ||
var pageName = mw.config.get('wgPageName') || ''; | var pageName = mw.config.get('wgPageName') || ''; | ||
var action = mw.config.get('wgAction') || 'view'; | var action = mw.config.get('wgAction') || 'view'; | ||
| Baris 1.404: | Baris 1.425: | ||
if (ns !== 0 || isMain || action !== 'view') return false; | if (ns !== 0 || isMain || action !== 'view') return false; | ||
if (/^(Istimewa|Special|MediaWiki|Berkas|File|Kategori|Category|Templat|Template|Modul|Module|Bantuan|Help|Proyek|Project):/i.test(pageName)) { | if (/^(Istimewa|Special|MediaWiki|Berkas|File|Kategori|Category|Templat|Template|Modul|Module|Bantuan|Help|Proyek|Project):/i.test(pageName)) { | ||
return false; | return false; | ||
} | } | ||
return true; | return true; | ||
} | } | ||
function enforceRobotsMeta(shouldNoIndex) { | function enforceRobotsMeta(shouldNoIndex) { | ||
if (! | if (!isValidEntityPage()) return; | ||
var contentVal = shouldNoIndex ? 'noindex, nofollow, noarchive' : 'index, follow'; | var contentVal = shouldNoIndex ? 'noindex, nofollow, noarchive' : 'index, follow'; | ||
var $metaRobots = $('meta[name="robots"]'); | var $metaRobots = $('meta[name="robots"]'); | ||
| Baris 1.448: | Baris 1.458: | ||
); | ); | ||
} | } | ||
} | |||
function detectRedirectDOM() { | |||
if (typeof mw !== 'undefined' && mw.config && mw.config.get('wgIsRedirect')) return true; | |||
if ($('.redirectMsg, .mw-redirect-link').length > 0) return true; | |||
var txt = ($('#mw-content-text').text() || '').trim(); | |||
return /^(#REDIRECT|#ALIH)\s*\[\[/i.test(txt); | |||
} | } | ||
$(document).ready(function() { | $(document).ready(function() { | ||
if (! | if (!isValidEntityPage()) return; | ||
var $descSection = $('#mip-desc-section'), $descBox = $('#mip-auto-description'), | var $descSection = $('#mip-desc-section'), $descBox = $('#mip-auto-description'), | ||
| Baris 1.460: | Baris 1.477: | ||
var pageTitle = mw.config.get('wgPageName').replace(/_/g, ' '), | var pageTitle = mw.config.get('wgPageName').replace(/_/g, ' '), | ||
cacheKey = ' | cacheKey = 'mip_smart_context_thumb_v110_' + pageTitle, | ||
currentYear = new Date().getFullYear(); | currentYear = new Date().getFullYear(); | ||
| Baris 1.583: | Baris 1.600: | ||
} | } | ||
function syncDescriptionIntoJsonLd(descText) { | function syncDescriptionIntoJsonLd(descText, articleLink) { | ||
var $ld = $('#mip-jsonld-schema'); | var $ld = $('#mip-jsonld-schema'); | ||
if ($ld.length) | if (!$ld.length) return; | ||
try { | |||
var parsed = JSON.parse($ld.text()); | |||
if (descText) { | |||
var cleaned = descText.replace(/\[\d+\]/g, '').replace(/\s+/g, ' ').trim(); | |||
if (cleaned.length > 300) cleaned = cleaned.substring(0, 297).replace(/\s+\S*$/, '') + '...'; | |||
parsed.description = cleaned; | parsed.description = cleaned; | ||
$ld.text(JSON.stringify(parsed, null, 2)); | } | ||
if (articleLink) { | |||
var existing = parsed.sameAs ? (Array.isArray(parsed.sameAs) ? parsed.sameAs : [parsed.sameAs]) : []; | |||
if (existing.indexOf(articleLink) === -1) existing.unshift(articleLink); | |||
parsed.sameAs = existing; | |||
} | |||
$ld.text(JSON.stringify(parsed, null, 2)); | |||
} catch (e) {} | |||
} | } | ||
// Khusus halaman pengalihan: sembunyikan data (bukan noindex) & pindahkan/hapus metadata ke target pengalihan | // Khusus halaman pengalihan: sembunyikan data (bukan noindex) & pindahkan/hapus metadata ke target pengalihan | ||
function | function handleRedirectHideAndMigrate(targetTitle) { | ||
$('body').addClass('mip-redirect-hidden').removeClass('mip-is-noindex'); | $('body').addClass('mip-redirect-hidden').removeClass('mip-is-noindex'); | ||
$('#mip-empty-state-notice').remove(); | $('#mip-empty-state-notice').remove(); | ||
$('#mippedia-data-app, #mip-desc-section, #mip-header, #mip-connector, #mip-footer, #desc-manager').hide(); | $('#mippedia-data-app, #mip-desc-section, #mip-header, #mip-connector, #mip-footer, #desc-manager').hide(); | ||
if (!isLoggedInUser() || !targetTitle) return; | |||
var api = new mw.Api(); | var api = new mw.Api(); | ||
| Baris 1.651: | Baris 1.671: | ||
} | } | ||
function | function checkRedirectStatus() { | ||
if (detectRedirectDOM()) { | |||
var domTargetMatch = ($('#mw-content-text').text() || '').match(/\[\[([^\]|#]+)/); | |||
handleRedirectHideAndMigrate(domTargetMatch ? domTargetMatch[1].trim() : ''); | |||
return $.Deferred().resolve(true).promise(); | |||
} | |||
var api = new mw.Api(); | var api = new mw.Api(); | ||
return api.get({ | return api.get({ | ||
| Baris 1.667: | Baris 1.693: | ||
if (pg.redirect || redMatch) { | if (pg.redirect || redMatch) { | ||
var target = redMatch ? redMatch[1].trim() : ''; | var target = redMatch ? redMatch[1].trim() : ''; | ||
handleRedirectHideAndMigrate(target); | |||
return true; | return true; | ||
} | } | ||
| Baris 1.677: | Baris 1.703: | ||
function toggleMippediaLayout(isEmpty) { | function toggleMippediaLayout(isEmpty) { | ||
if (! | if (!isValidEntityPage()) return; | ||
var $existingNotice = $('#mip-empty-state-notice'); | var $existingNotice = $('#mip-empty-state-notice'); | ||
var $wikiDataElements = $mainContent.children().not('#mip-empty-state-notice, #mip-desc-section, script, style, .printfooter'); | var $wikiDataElements = $mainContent.children().not('#mip-empty-state-notice, #mip-desc-section, script, style, .printfooter'); | ||
if (isEmpty) { | if (isEmpty) { | ||
| Baris 1.720: | Baris 1.742: | ||
$wikiDataElements.attr('style', function(i, s) { return (s || '') + '; display: none !important;'; }); | $wikiDataElements.attr('style', function(i, s) { return (s || '') + '; display: none !important;'; }); | ||
$descSection.attr('style', function(i, s) { return (s || '') + '; display: none !important;'; }); | $descSection.attr('style', function(i, s) { return (s || '') + '; display: none !important;'; }); | ||
} else { | } else { | ||
$('body').removeClass('mip-is-noindex').removeAttr('data-mip-noindex'); | $('body').removeClass('mip-is-noindex').removeAttr('data-mip-noindex'); | ||
| Baris 1.736: | Baris 1.748: | ||
$wikiDataElements.css('display', ''); | $wikiDataElements.css('display', ''); | ||
if ($descSection.length) $descSection.css('display', ''); | if ($descSection.length) $descSection.css('display', ''); | ||
enforceRobotsMeta(false); | enforceRobotsMeta(false); | ||
} | } | ||
| Baris 1.748: | Baris 1.756: | ||
function init() { | function init() { | ||
checkRedirectStatus().done(function(isRed) { | |||
if (isRed) return; | if (isRed) return; | ||
| Baris 1.859: | Baris 1.867: | ||
function renderAll(p, currentText, isTranslated, originalText, img, customUrl, enTitle) { | function renderAll(p, currentText, isTranslated, originalText, img, customUrl, enTitle) { | ||
syncDescriptionIntoJsonLd(currentText); | var targetLink = customUrl ? customUrl : p.base + encodeURIComponent(pageTitle); | ||
syncDescriptionIntoJsonLd(currentText, targetLink); | |||
if (!$descBox.length || !$sourceInfo.length) return; | if (!$descBox.length || !$sourceInfo.length) return; | ||
var processedText = applyAutoBold(applyDynamicContext(currentText)); | var processedText = applyAutoBold(applyDynamicContext(currentText)); | ||
| Baris 1.871: | Baris 1.880: | ||
$descBox.show().html(thumbHtml + applySummary(processedText) + '<div style="clear:both;"></div>'); | $descBox.show().html(thumbHtml + applySummary(processedText) + '<div style="clear:both;"></div>'); | ||
var footer = '<div style="font-size: 0.9em; color: #777;">Sumber : <a href="' + targetLink + '" target="_blank" style="color: #6a5acd; font-weight: bold; text-decoration: none;">' + p.name + '.</a>'; | var footer = '<div style="font-size: 0.9em; color: #777;">Sumber : <a href="' + targetLink + '" target="_blank" style="color: #6a5acd; font-weight: bold; text-decoration: none;">' + p.name + '.</a>'; | ||
if (isTranslated) { footer += '<br><span style="font-size: 0.85em; font-style: italic;">(Diterjemahkan secara otomatis)</span> <span id="mip-toggle-orig" style="color: #6a5acd; cursor: pointer; text-decoration: underline; margin-left: 5px;">Tampilkan versi asli</span>'; } | if (isTranslated) { footer += '<br><span style="font-size: 0.85em; font-style: italic;">(Diterjemahkan secara otomatis)</span> <span id="mip-toggle-orig" style="color: #6a5acd; cursor: pointer; text-decoration: underline; margin-left: 5px;">Tampilkan versi asli</span>'; } | ||
| Baris 1.892: | Baris 1.900: | ||
/* ========================================================== | /* ========================================================== | ||
🚀 MIPPEDIA DATA - CORE SYSTEM ( | 🚀 MIPPEDIA DATA - CORE SYSTEM (REGISTERED USER ACCESS) | ||
========================================================== */ | ========================================================== */ | ||
(function() { | (function() { | ||
| Baris 1.902: | Baris 1.910: | ||
var pageTitle = mw.config.get('wgPageName'); | var pageTitle = mw.config.get('wgPageName'); | ||
var dataPage = 'MediaWiki:Sitelinks-Data.json'; | var dataPage = 'MediaWiki:Sitelinks-Data.json'; | ||
var | var isRegisteredUser = !!mw.config.get('wgUserName'); | ||
var projects = { | var projects = { | ||
| Baris 1.981: | Baris 1.988: | ||
$(document).on('click', '#mip-save', function() { | $(document).on('click', '#mip-save', function() { | ||
if (! | if (!isRegisteredUser) { | ||
showBoxNotif(' | showBoxNotif('Login Diperlukan', 'Hanya <b>pengguna terdaftar yang sudah login</b> yang dapat mengubah ID Situs. Silakan masuk terlebih dahulu.', 'error'); | ||
return; | return; | ||
} | } | ||
| Baris 2.012: | Baris 2.019: | ||
api.postWithEditToken({ action: 'edit', title: dataPage, text: JSON.stringify(full, null, 2), summary: 'Sync Metadata: ' + pageTitle }) | api.postWithEditToken({ action: 'edit', title: dataPage, text: JSON.stringify(full, null, 2), summary: 'Sync Metadata: ' + pageTitle }) | ||
.done(function() { | .done(function() { | ||
showBoxNotif('Suntingan Anda berhasil diterbitkan!', ' | showBoxNotif('Suntingan Anda berhasil diterbitkan!', 'ID Situs berhasil disinkronisasi ke jaringan Mippedia.', 'success'); | ||
setTimeout(function() { location.reload(); }, 1500); | setTimeout(function() { location.reload(); }, 1500); | ||
}).fail(function(c) { | }).fail(function(c) { | ||
| Baris 2.022: | Baris 2.029: | ||
}); | }); | ||
$(document).on('click', '#mip-open-editor', function() { $('#mip-editor').slideToggle(); }); | $(document).on('click', '#mip-open-editor', function() { | ||
if (!isRegisteredUser) { | |||
showBoxNotif('Login Diperlukan', 'Silakan login menggunakan akun terdaftar untuk mengedit ID Situs.', 'error'); | |||
return; | |||
} | |||
$('#mip-editor').slideToggle(); | |||
}); | |||
loadLinks(); | loadLinks(); | ||
}); | }); | ||
| Baris 2.234: | Baris 2.247: | ||
/* ========================================================== | /* ========================================================== | ||
🌐 MIPPEDIA SHORTDESC - DATA CENTER ( | 🌐 MIPPEDIA SHORTDESC - DATA CENTER (REGISTERED USER ACCESS) | ||
========================================================== */ | ========================================================== */ | ||
(function($, mw) { | (function($, mw) { | ||
| Baris 2.243: | Baris 2.256: | ||
var pageTitle = mw.config.get('wgPageName'); | var pageTitle = mw.config.get('wgPageName'); | ||
var storagePage = 'MediaWiki:ShortDesc-Data.json'; | var storagePage = 'MediaWiki:ShortDesc-Data.json'; | ||
var | var isRegisteredUser = !!mw.config.get('wgUserName'); | ||
var langs = { | var langs = { | ||
| Baris 2.306: | Baris 2.319: | ||
} | } | ||
$(document).on('click', '#desc-open-editor', function() { $('#desc-editor').slideToggle(); }); | $(document).on('click', '#desc-open-editor', function() { | ||
if (!isRegisteredUser) { | |||
alert('Akses ditolak. Silakan login menggunakan akun terdaftar untuk mengedit Label Deskripsi.'); | |||
return; | |||
} | |||
$('#desc-editor').slideToggle(); | |||
}); | |||
$(document).on('click', '#desc-save', function() { | $(document).on('click', '#desc-save', function() { | ||
if (! | if (!isRegisteredUser) { alert('Akses ditolak. Silakan login menggunakan akun terdaftar.'); return; } | ||
var $btn = $(this).text('Proses Sinkronisasi...').css('opacity', '0.7'); | var $btn = $(this).text('Proses Sinkronisasi...').css('opacity', '0.7'); | ||
var api = new mw.Api(); | var api = new mw.Api(); | ||