MediaWiki:Common.js: Difference between revisions
From The Jadnix Codex
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
/* ============================================================ | /* ============================================================ | ||
JADNIX CODEX: CORE SCRIPTS | JADNIX CODEX: CORE SCRIPTS (Logos + Themes + Calculator) | ||
============================================================ */ | ============================================================ */ | ||
$(function() { | $(function() { | ||
// 1. DEFINE LOGOS | /* --- PART A: LOGO & THEME SYSTEM --- */ | ||
// 1. DEFINE LOGOS (PASTE YOUR URLs HERE) | |||
const logos = { | const logos = { | ||
still: 'https://files.catbox.moe/0cmhjh.png', | still: 'https://files.catbox.moe/0cmhjh.png', | ||
dealer: 'https://files.catbox.moe/73m0cp.png', | dealer: 'https://files.catbox.moe/73m0cp.png', | ||
skipper: 'https://files.catbox.moe/ | skipper: 'https://files.catbox.moe/8gs8n5.png' // <--- UPDATE THIS | ||
}; | }; | ||
// 2. HELPER | // 2. HELPER: FORCE LOGO SWAP | ||
function swapLogo(url) { | function swapLogo(url) { | ||
$('.mw-logo-icon').attr('src', url); | $('.mw-logo-icon').attr('src', url); | ||
$('.citizen-header__logo img').attr('src', url); | $('.citizen-header__logo img').attr('src', url); | ||
$('.citizen-footer__logo img').attr('src', url); | $('.citizen-footer__logo img').attr('src', url); | ||
$('.citizen-drawer__logo img').attr('src', url); | $('.citizen-drawer__logo img').attr('src', url); | ||
} | } | ||
// 3. APPLY | // 3. DETECT FACTION -> APPLY CLASS & LOGO | ||
if ($('.faction-dealer').length) { | if ($('.faction-dealer').length) { | ||
$('body').addClass('theme-dealer'); | $('body').addClass('theme-dealer'); | ||
swapLogo(logos.dealer); | swapLogo(logos.dealer); | ||
} | } | ||
else if ($('.faction-skipper').length) { | else if ($('.faction-skipper').length) { | ||
$('body').addClass('theme-skipper'); | $('body').addClass('theme-skipper'); | ||
swapLogo(logos.skipper); | swapLogo(logos.skipper); | ||
} | } | ||
else if ($('.faction-still').length) { | else if ($('.faction-still').length) { | ||
$('body').addClass('theme-still'); | $('body').addClass('theme-still'); | ||
swapLogo(logos.still); | swapLogo(logos.still); | ||
} | } | ||
/* --- PART B: CRDD CALCULATOR LOGIC --- */ | |||
// | // Only run if calculator is present | ||
if ($('#crdd-interface').length) { | if ($('#crdd-interface').length) { | ||
// Update number displays instantly | |||
$('.crdd-range').on('input', function() { | $('.crdd-range').on('input', function() { | ||
$(this).next('.crdd-value-display').text($(this).val()); | $(this).next('.crdd-value-display').text($(this).val()); | ||
}); | }); | ||
// ( | // The Calculation Function | ||
// | function updateCRDD() { | ||
let totalScore = 0; | |||
let activeMaxScore = 0; | |||
let criticalOverride = false; | |||
// SECTION 1: SUBJECT | |||
let subjSkip = $('#skip-subject').is(':checked'); | |||
if (!subjSkip) { | |||
let s1 = parseInt($('#s-strength').val()) || 0; | |||
let s2 = parseInt($('#s-durability').val()) || 0; | |||
let s3 = parseInt($('#s-mobility').val()) || 0; | |||
let s4 = parseInt($('#s-intel').val()) || 0; | |||
let s5 = parseInt($('#s-stamina').val()) || 0; | |||
let s6 = parseInt($('#s-threat').val()) || 0; | |||
let s7 = parseInt($('#s-swarm').val()) || 0; | |||
if (s6 > 24) criticalOverride = true; | |||
let avg = (s1+s2+s3+s4+s5+s6+s7) / 7; | |||
totalScore += avg; | |||
activeMaxScore += 33; | |||
let rating = "DOCILE"; | |||
if (avg > 8) rating = "NEUTRAL"; | |||
if (avg > 16) rating = "HOSTILE"; | |||
if (avg > 24) rating = "VILE"; | |||
$('#result-subject').text(avg.toFixed(1) + " (" + rating + ")"); | |||
if (avg > 24) criticalOverride = true; | |||
} else { | |||
$('#result-subject').text("SKIPPED"); | |||
} | |||
// SECTION 2: ITEM | |||
let itemSkip = $('#skip-item').is(':checked'); | |||
if (!itemSkip) { | |||
let i1 = parseInt($('#i-entropy').val()) || 0; | |||
let i2 = parseInt($('#i-instability').val()) || 0; | |||
let i3 = parseInt($('#i-radiation').val()) || 0; | |||
let i4 = parseInt($('#i-corrupt').val()) || 0; | |||
let i5 = parseInt($('#i-volatility').val()) || 0; | |||
let i6 = parseInt($('#i-unport').val()) || 0; | |||
let i7 = parseInt($('#i-anomalous').val()) || 0; | |||
let i8 = parseInt($('#i-qty').val()) || 0; | |||
if (i7 > 24) criticalOverride = true; | |||
let avg = (i1+i2+i3+i4+i5+i6+i7+i8) / 8; | |||
totalScore += avg; | |||
activeMaxScore += 33; | |||
let rating = "FUNCTIONAL"; | |||
if (avg > 8) rating = "ALTERED"; | |||
if (avg > 16) rating = "UNSTABLE"; | |||
if (avg > 24) rating = "VOID"; | |||
$('#result-item').text(avg.toFixed(1) + " (" + rating + ")"); | |||
} else { | |||
$('#result-item').text("SKIPPED"); | |||
} | |||
// SECTION 3: SEAM | |||
let seamSkip = $('#skip-seam').is(':checked'); | |||
if (!seamSkip) { | |||
let m1 = parseInt($('#m-instability').val()) || 0; | |||
let m2 = parseInt($('#m-leakage').val()) || 0; | |||
let m3 = parseInt($('#m-geo').val()) || 0; | |||
let m4 = parseInt($('#m-atmo').val()) || 0; | |||
let m5 = parseInt($('#m-topo').val()) || 0; | |||
let m6 = parseInt($('#m-dead').val()) || 0; | |||
let m7 = parseInt($('#m-laws').val()) || 0; | |||
if (m3 > 24 || m4 > 24 || m6 > 24 || m7 > 24) criticalOverride = true; | |||
let avg = (m1+m2+m3+m4+m5+m6+m7) / 7; | |||
totalScore += avg; | |||
activeMaxScore += 33; | |||
let rating = "ANCHORED"; | |||
if (avg > 8) rating = "VOLATILE"; | |||
if (avg > 16) rating = "FRACTURED"; | |||
if (avg > 24) rating = "NULL"; | |||
$('#result-seam').text(avg.toFixed(1) + " (" + rating + ")"); | |||
if (avg > 24) criticalOverride = true; | |||
} else { | |||
$('#result-seam').text("SKIPPED"); | |||
} | |||
// FINAL RESULT | |||
let finalBox = $('#crdd-final-output'); | |||
let finalLabel = $('#crdd-final-label'); | |||
if (activeMaxScore === 0) { | |||
finalBox.text("ERROR: NO DATA"); | |||
finalBox.css('color', 'red'); | |||
return; | |||
} | |||
let percent = (totalScore / activeMaxScore) * 100; | |||
if (criticalOverride) { | |||
finalLabel.text("CRITICAL THREAT DETECTED"); | |||
finalBox.text("NULL (LEAVE NOW)"); | |||
finalBox.css({ | |||
'color': '#000000', | |||
'background': '#fff', | |||
'text-shadow': '0 0 10px red' | |||
}); | |||
} else { | |||
let finalRating = "ANCHORED"; | |||
let finalColor = "#00ff9f"; | |||
let finalMsg = "YOU ARE SAFE"; | |||
if (percent > 25) { finalRating = "VOLATILE"; finalColor = "#ffd700"; finalMsg = "PROCEED WITH CAUTION"; } | |||
if (percent > 50) { finalRating = "FRACTURED"; finalColor = "#ff4500"; finalMsg = "YOU ARE IN DANGER"; } | |||
if (percent > 75) { finalRating = "NULL"; finalColor = "#555"; finalMsg = "LEAVE NOW"; } | |||
finalLabel.text(finalMsg); | |||
finalBox.text(finalRating + " (" + percent.toFixed(1) + "%)"); | |||
finalBox.css({ | |||
'color': finalColor, | |||
'background': 'transparent', | |||
'text-shadow': '0 0 10px ' + finalColor | |||
}); | |||
} | |||
} | |||
// Trigger update on any change | |||
$('.crdd-range, input[type=checkbox]').on('input change', updateCRDD); | |||
} | } | ||
}); | }); | ||
Revision as of 16:01, 9 February 2026
/* ============================================================
JADNIX CODEX: CORE SCRIPTS (Logos + Themes + Calculator)
============================================================ */
$(function() {
/* --- PART A: LOGO & THEME SYSTEM --- */
// 1. DEFINE LOGOS (PASTE YOUR URLs HERE)
const logos = {
still: 'https://files.catbox.moe/0cmhjh.png',
dealer: 'https://files.catbox.moe/73m0cp.png',
skipper: 'https://files.catbox.moe/8gs8n5.png' // <--- UPDATE THIS
};
// 2. HELPER: FORCE LOGO SWAP
function swapLogo(url) {
$('.mw-logo-icon').attr('src', url);
$('.citizen-header__logo img').attr('src', url);
$('.citizen-footer__logo img').attr('src', url);
$('.citizen-drawer__logo img').attr('src', url);
}
// 3. DETECT FACTION -> APPLY CLASS & LOGO
if ($('.faction-dealer').length) {
$('body').addClass('theme-dealer');
swapLogo(logos.dealer);
}
else if ($('.faction-skipper').length) {
$('body').addClass('theme-skipper');
swapLogo(logos.skipper);
}
else if ($('.faction-still').length) {
$('body').addClass('theme-still');
swapLogo(logos.still);
}
/* --- PART B: CRDD CALCULATOR LOGIC --- */
// Only run if calculator is present
if ($('#crdd-interface').length) {
// Update number displays instantly
$('.crdd-range').on('input', function() {
$(this).next('.crdd-value-display').text($(this).val());
});
// The Calculation Function
function updateCRDD() {
let totalScore = 0;
let activeMaxScore = 0;
let criticalOverride = false;
// SECTION 1: SUBJECT
let subjSkip = $('#skip-subject').is(':checked');
if (!subjSkip) {
let s1 = parseInt($('#s-strength').val()) || 0;
let s2 = parseInt($('#s-durability').val()) || 0;
let s3 = parseInt($('#s-mobility').val()) || 0;
let s4 = parseInt($('#s-intel').val()) || 0;
let s5 = parseInt($('#s-stamina').val()) || 0;
let s6 = parseInt($('#s-threat').val()) || 0;
let s7 = parseInt($('#s-swarm').val()) || 0;
if (s6 > 24) criticalOverride = true;
let avg = (s1+s2+s3+s4+s5+s6+s7) / 7;
totalScore += avg;
activeMaxScore += 33;
let rating = "DOCILE";
if (avg > 8) rating = "NEUTRAL";
if (avg > 16) rating = "HOSTILE";
if (avg > 24) rating = "VILE";
$('#result-subject').text(avg.toFixed(1) + " (" + rating + ")");
if (avg > 24) criticalOverride = true;
} else {
$('#result-subject').text("SKIPPED");
}
// SECTION 2: ITEM
let itemSkip = $('#skip-item').is(':checked');
if (!itemSkip) {
let i1 = parseInt($('#i-entropy').val()) || 0;
let i2 = parseInt($('#i-instability').val()) || 0;
let i3 = parseInt($('#i-radiation').val()) || 0;
let i4 = parseInt($('#i-corrupt').val()) || 0;
let i5 = parseInt($('#i-volatility').val()) || 0;
let i6 = parseInt($('#i-unport').val()) || 0;
let i7 = parseInt($('#i-anomalous').val()) || 0;
let i8 = parseInt($('#i-qty').val()) || 0;
if (i7 > 24) criticalOverride = true;
let avg = (i1+i2+i3+i4+i5+i6+i7+i8) / 8;
totalScore += avg;
activeMaxScore += 33;
let rating = "FUNCTIONAL";
if (avg > 8) rating = "ALTERED";
if (avg > 16) rating = "UNSTABLE";
if (avg > 24) rating = "VOID";
$('#result-item').text(avg.toFixed(1) + " (" + rating + ")");
} else {
$('#result-item').text("SKIPPED");
}
// SECTION 3: SEAM
let seamSkip = $('#skip-seam').is(':checked');
if (!seamSkip) {
let m1 = parseInt($('#m-instability').val()) || 0;
let m2 = parseInt($('#m-leakage').val()) || 0;
let m3 = parseInt($('#m-geo').val()) || 0;
let m4 = parseInt($('#m-atmo').val()) || 0;
let m5 = parseInt($('#m-topo').val()) || 0;
let m6 = parseInt($('#m-dead').val()) || 0;
let m7 = parseInt($('#m-laws').val()) || 0;
if (m3 > 24 || m4 > 24 || m6 > 24 || m7 > 24) criticalOverride = true;
let avg = (m1+m2+m3+m4+m5+m6+m7) / 7;
totalScore += avg;
activeMaxScore += 33;
let rating = "ANCHORED";
if (avg > 8) rating = "VOLATILE";
if (avg > 16) rating = "FRACTURED";
if (avg > 24) rating = "NULL";
$('#result-seam').text(avg.toFixed(1) + " (" + rating + ")");
if (avg > 24) criticalOverride = true;
} else {
$('#result-seam').text("SKIPPED");
}
// FINAL RESULT
let finalBox = $('#crdd-final-output');
let finalLabel = $('#crdd-final-label');
if (activeMaxScore === 0) {
finalBox.text("ERROR: NO DATA");
finalBox.css('color', 'red');
return;
}
let percent = (totalScore / activeMaxScore) * 100;
if (criticalOverride) {
finalLabel.text("CRITICAL THREAT DETECTED");
finalBox.text("NULL (LEAVE NOW)");
finalBox.css({
'color': '#000000',
'background': '#fff',
'text-shadow': '0 0 10px red'
});
} else {
let finalRating = "ANCHORED";
let finalColor = "#00ff9f";
let finalMsg = "YOU ARE SAFE";
if (percent > 25) { finalRating = "VOLATILE"; finalColor = "#ffd700"; finalMsg = "PROCEED WITH CAUTION"; }
if (percent > 50) { finalRating = "FRACTURED"; finalColor = "#ff4500"; finalMsg = "YOU ARE IN DANGER"; }
if (percent > 75) { finalRating = "NULL"; finalColor = "#555"; finalMsg = "LEAVE NOW"; }
finalLabel.text(finalMsg);
finalBox.text(finalRating + " (" + percent.toFixed(1) + "%)");
finalBox.css({
'color': finalColor,
'background': 'transparent',
'text-shadow': '0 0 10px ' + finalColor
});
}
}
// Trigger update on any change
$('.crdd-range, input[type=checkbox]').on('input change', updateCRDD);
}
});