Spiderjjr45 (talk | contribs) No edit summary Tag: Manual revert |
Spiderjjr45 (talk | contribs) No edit summary |
||
| (14 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
/** |
|||
*Makes credits closable |
|||
*/ |
|||
mw.loader.using(['jquery'], function () { |
|||
$(document).on('click', '#worldbuildercredits .close-btn', function() { |
|||
$('#worldbuildercredits').hide(); |
|||
}); |
|||
}); |
|||
/** |
|||
* Adds an AI Artwork button to the image uploader page |
|||
*/ |
|||
$(function() { |
|||
if (mw.config.get('wgCanonicalSpecialPageName') === 'Upload') { |
|||
// checkbox element |
|||
var checkboxHtml = '<td class="mw-label"><label for="aiCheckbox">AI Artwork?: </label></td>' |
|||
+ '<td class="mw-input"><input type="checkbox" id="aiCheckbox"></td>'; |
|||
// Insert the checkbox element after the Licensing row |
|||
$('td.mw-label label[for="wpLicense"]').closest('tr').after('<tr>' + checkboxHtml + '</tr>'); |
|||
// Update the destination filename when the checkbox value changes |
|||
$('#aiCheckbox').change(function() { |
|||
var destFileInput = $('#wpDestFile'); |
|||
var currentFilename = destFileInput.val(); |
|||
if ($(this).prop('checked')) { |
|||
// Prepend "-ai-" if checkbox is checked |
|||
if (!currentFilename.startsWith("-ai-")) { |
|||
destFileInput.val("-ai-" + currentFilename); |
|||
} |
|||
} else { |
|||
// Remove "-ai-" prefix if checkbox is unchecked |
|||
if (currentFilename.startsWith("-ai-")) { |
|||
destFileInput.val(currentFilename.replace("-ai-", "")); |
|||
} |
|||
} |
|||
}); |
|||
} |
|||
}); |
|||
/** |
/** |
||
* Adds CSS classes to the body tag based on the categories this page belongs to. Used for CR/Astral page theming. |
* Adds CSS classes to the body tag based on the categories this page belongs to. Used for CR/Astral page theming. |
||
| Line 44: | Line 82: | ||
//Images can be renamed to have "-ai-" anywhere in their name and automatically get a watermark |
//Images can be renamed to have "-ai-" anywhere in their name and automatically get a watermark |
||
$(document).ready(function() { |
$(document).ready(function() { |
||
// Define the watermark image URL |
// Define the watermark image URL |
||
var watermarkURL = 'https://quelmarwiki.com/wiki/images/b/b8/Aiwatermark.png'; |
var watermarkURL = 'https://quelmarwiki.com/wiki/images/b/b8/Aiwatermark.png'; |
||
// Loop through images on the page |
// Loop through images on the page |
||
| Line 58: | Line 96: | ||
'overflow': 'hidden', |
'overflow': 'hidden', |
||
'width': img.width(), |
'width': img.width(), |
||
'height': img.height |
'height': img.height, |
||
'pointer-events': 'none' |
|||
}); |
|||
//Generate the watermark |
//Generate the watermark |
||
var watermark = $('<img>').attr('src', watermarkURL).css({ |
var watermark = $('<img>').attr('src', watermarkURL).css({ |
||
| Line 65: | Line 104: | ||
'bottom': '0', |
'bottom': '0', |
||
'right': '0', |
'right': '0', |
||
'max-width': ' |
'max-width': '20%', // Adjust size if needed |
||
'max-height': ' |
'max-height': '20%', // Adjust size if needed |
||
'pointer-events': 'none', // Ensure it doesn't interfere with any interactions |
'pointer-events': 'none', // Ensure it doesn't interfere with any interactions |
||
'opacity': '0.5' // Adjust opacity if needed |
'opacity': '0.5' // Adjust opacity if needed |
||
| Line 75: | Line 114: | ||
} |
} |
||
}); |
}); |
||
}); |
|||
/* |
|||
If URL hash component's target has any collapsed ancestor(s), expands them |
|||
(Propogation is stopped by '.disable-hash-expand' on target or on any ancestor) |
|||
*/ |
|||
$(function() { |
|||
var hash = window.location.hash; |
|||
if (!hash) return; |
|||
var id; |
|||
try { |
|||
id = decodeURIComponent(hash.slice(1)); |
|||
} catch (e) { |
|||
return; |
|||
} |
|||
var target = document.getElementById(id); |
|||
if (!target) return; |
|||
// give MediaWiki time to set up its collapsible widget |
|||
setTimeout(function() { |
|||
var $node = $(target); |
|||
// repeatedly find the *nearest* collapsed ancestor… |
|||
while ($node.length) { |
|||
var $coll = $node.closest('.mw-collapsible.mw-collapsed'); |
|||
// stop if there isn't one, or author opted out |
|||
if (!$coll.length || $coll.hasClass('disable-hash-expand')) { |
|||
break; |
|||
} |
|||
// click its toggle |
|||
$coll.find('.mw-collapsible-toggle').first().click(); |
|||
// then continue from just outside that container |
|||
$node = $coll.parent(); |
|||
} |
|||
// finally scroll the target into view |
|||
setTimeout(function() { |
|||
if (typeof target.scrollIntoView === 'function') { |
|||
target.scrollIntoView({ behavior: 'smooth', block: 'center' }); |
|||
} |
|||
}, 200); |
|||
}, 0); |
|||
}); |
}); |
||
Latest revision as of 04:04, 24 July 2025
/**
*Makes credits closable
*/
mw.loader.using(['jquery'], function () {
$(document).on('click', '#worldbuildercredits .close-btn', function() {
$('#worldbuildercredits').hide();
});
});
/**
* Adds an AI Artwork button to the image uploader page
*/
$(function() {
if (mw.config.get('wgCanonicalSpecialPageName') === 'Upload') {
// checkbox element
var checkboxHtml = '<td class="mw-label"><label for="aiCheckbox">AI Artwork?: </label></td>'
+ '<td class="mw-input"><input type="checkbox" id="aiCheckbox"></td>';
// Insert the checkbox element after the Licensing row
$('td.mw-label label[for="wpLicense"]').closest('tr').after('<tr>' + checkboxHtml + '</tr>');
// Update the destination filename when the checkbox value changes
$('#aiCheckbox').change(function() {
var destFileInput = $('#wpDestFile');
var currentFilename = destFileInput.val();
if ($(this).prop('checked')) {
// Prepend "-ai-" if checkbox is checked
if (!currentFilename.startsWith("-ai-")) {
destFileInput.val("-ai-" + currentFilename);
}
} else {
// Remove "-ai-" prefix if checkbox is unchecked
if (currentFilename.startsWith("-ai-")) {
destFileInput.val(currentFilename.replace("-ai-", ""));
}
}
});
}
});
/**
* Adds CSS classes to the body tag based on the categories this page belongs to. Used for CR/Astral page theming.
*
* @source https://www.mediawiki.org/wiki/Snippets/Style_pages_based_on_categories
* @revision 2016-01-18
*/
(function($, mw) {
var fn = function() {
var cats = mw.config.get('wgCategories'), newClasses;
if (cats) {
newClasses = $.map(cats, function(el) {
return 'cat-' + encodeURIComponent(el.replace(/[ .]/g, '_')).replace(/%/g, '_');
}).join(' ');
$(document.body).addClass(newClasses);
}
};
if (document.body) {
fn();
} else {
$(fn);
}
})(jQuery, mw);
//Deprecated code: Used for autoplaying theme songs
//function Bebop(){
// console.log("OK 3 2 1 Let's Jam");
// var x = document.getElementById("myaudio");
// x.play();
//}
//
//setTimeout(Bebop, 2000);
// START HOTCAT
/*
This imports the latest version of HotCat from Commons.
HotCat is a gadget to make changes to categories much easier.
Full documentation can be found at http://commons.wikimedia.org/wiki/Help:Gadget-HotCat
*/
window.hotcat_translations_from_commons = true;
mw.loader.load( 'https://commons.wikimedia.org/w/index.php?title=MediaWiki:Gadget-HotCat.js&action=raw&ctype=text/javascript' );
// END HOTCAT
//Watermark AI Image
//Images can be renamed to have "-ai-" anywhere in their name and automatically get a watermark
$(document).ready(function() {
// Define the watermark image URL
var watermarkURL = 'https://quelmarwiki.com/wiki/images/b/b8/Aiwatermark.png';
// Loop through images on the page
$('img').each(function() {
var img = $(this); // Reference to the current img tag in the loop
var src = img.attr('src'); // Get the src attribute
// Check if image name contains '-ai'
if (src.includes('-ai')) {
// Create a div to contain the image and its watermark
var container = $('<div>').css({
'position': 'relative',
'display': 'inline-block',
'overflow': 'hidden',
'width': img.width(),
'height': img.height,
'pointer-events': 'none'
});
//Generate the watermark
var watermark = $('<img>').attr('src', watermarkURL).css({
'position': 'absolute',
'bottom': '0',
'right': '0',
'max-width': '20%', // Adjust size if needed
'max-height': '20%', // Adjust size if needed
'pointer-events': 'none', // Ensure it doesn't interfere with any interactions
'opacity': '0.5' // Adjust opacity if needed
});
// Insert the container before the original image, then move the original image and watermark inside the container
img.before(container).appendTo(container);
container.append(watermark);
}
});
});
/*
If URL hash component's target has any collapsed ancestor(s), expands them
(Propogation is stopped by '.disable-hash-expand' on target or on any ancestor)
*/
$(function() {
var hash = window.location.hash;
if (!hash) return;
var id;
try {
id = decodeURIComponent(hash.slice(1));
} catch (e) {
return;
}
var target = document.getElementById(id);
if (!target) return;
// give MediaWiki time to set up its collapsible widget
setTimeout(function() {
var $node = $(target);
// repeatedly find the *nearest* collapsed ancestor…
while ($node.length) {
var $coll = $node.closest('.mw-collapsible.mw-collapsed');
// stop if there isn't one, or author opted out
if (!$coll.length || $coll.hasClass('disable-hash-expand')) {
break;
}
// click its toggle
$coll.find('.mw-collapsible-toggle').first().click();
// then continue from just outside that container
$node = $coll.parent();
}
// finally scroll the target into view
setTimeout(function() {
if (typeof target.scrollIntoView === 'function') {
target.scrollIntoView({ behavior: 'smooth', block: 'center' });
}
}, 200);
}, 0);
});
