MediaWiki:Common.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */
(function () {
// If there are no DP links on the page, don't load anything.
if (!document.querySelector('a[href*="divine-pride.net/database/item/"]')) return;
var s = document.createElement('script');
s.src = 'https://www.divine-pride.net/scripts/tooltip.js';
s.async = true;
document.head.appendChild(s);
})();
(function () {
function loadScriptOnce(src, id) {
return new Promise(function (resolve, reject) {
if (document.getElementById(id)) return resolve();
var s = document.createElement('script');
s.id = id;
s.src = src;
s.async = true;
s.onload = resolve;
s.onerror = reject;
document.head.appendChild(s);
});
}
var RO_API_JS = '/robrowser/api.js';
function ensureROBrowser() {
return loadScriptOnce(RO_API_JS, 'robrowser-api').then(function () {
if (!window.ROBrowser) throw new Error('ROBrowser not available after loading api.js');
});
}
function openPopupFromLink(a) {
var sprite = a.getAttribute('data-sprite') || a.getAttribute('data-accessory') || '';
var jobId = parseInt(a.getAttribute('data-jobid') || '0', 10) || 0;
var job = a.getAttribute('data-job') || '';
var robe = a.getAttribute('data-robe') || '';
if (!sprite) return;
var ro = new window.ROBrowser({
application: window.ROBrowser.APP.MODELVIEWER,
type: window.ROBrowser.TYPE.POPUP,
width: 820,
height: 520,
development: true,
remoteClient: 'https://grf.robrowser.com/',
skipIntro: true,
skipServerList: true,
accessory: sprite,
jobId: jobId,
job: job,
robe: robe
});
ro.start();
}
document.addEventListener('click', function (e) {
var a = e.target.closest && e.target.closest('a.dp-modelviewer');
if (!a) return;
e.preventDefault();
e.stopPropagation();
ensureROBrowser()
.then(function () { openPopupFromLink(a); })
.catch(function (err) { console.error('ModelViewer popup error:', err); });
});
})();