More actions
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)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */
mw.loader.using( [ 'mediawiki.util' ] ).done( function() {
/* Trigger search box when click on the fake search button on main page */
if ($.inArray("Dynamic header", mw.config.get("wgCategories")) > -1) {
document.getElementById( 'skin-citizen-search-trigger' ).addEventListener( 'click', function() {
var event = new Event( 'input', { bubbles: true, composed: true } ),
checkbox = document.getElementById( 'citizen-search__checkbox' );
checkbox.checked = true;
checkbox.dispatchEvent( event );
} );
}
} );
//Show a badge for featured projects
$(document).ready( function () {
if ($.inArray("Featured projects", mw.config.get("wgCategories")) > -1) {
$('.mw-indicators').append($('<div class="mw-ui-icon-featured" title="This is a featured community project on Prism Party"></div>'));
}
});
//Get player counts of Minecraft server
$.getJSON("https://mcapi.us/server/status?ip=play.prismparty.net", function(json) {
if (json.status !== "error") {
$(".online").html(json.players.now);
} else {
$(".online").html(0);
}
});
//Display Discord widget
$( '#discord-widget' ).html( '<iframe class="responsive-iframe" src="https://discord.com/widget?id=614592231428587522&theme=dark" allowtransparency="true" frameborder="0" sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"></iframe>' );
//live countdown
$(document).ready( function () {
if ($.inArray("Pages with a countdown", mw.config.get("wgCategories")) > -1) {
var spanDate = document.getElementById("get-time").innerText;
var countDownDate = new Date(spanDate).getTime();
// Update the count down every 1 second
var x = setInterval(function() {
// Get today's date and time
var now = new Date().getTime();
// Find the distance between now and the count down date
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Display the result in the element with id="live-countdown"
document.getElementById("live-countdown").innerHTML = days + "d " + hours + "h "
+ minutes + "m " + seconds + "s ";
// If the count down is finished, write some text
if (distance < 0 ) {
clearInterval(x);
document.getElementById("live-countdown").innerHTML = "This event has ended!";
}
}, 1000);
}});
// Click to search, dynHeader
/* Any JavaScript here will be loaded for all users on every page load. */
mw.loader.using( [ 'mediawiki.util' ] ).done( function() {
/* Trigger search box when click on the fake search button on main page */
if ($.inArray("Dynamic header", mw.config.get("wgCategories")) > -1) {
document.getElementById( 'skin-citizen-search-trigger' ).addEventListener( 'click', function() {
var event = new Event( 'input', { bubbles: true, composed: true } ),
checkbox = document.getElementById( 'citizen-search__checkbox' );
checkbox.checked = true;
checkbox.dispatchEvent( event );
} );
}
} );
//Copy element contents on click - can we replace this?
"use strict";
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
var copy = document.querySelectorAll(".copy");
var _iterator = _createForOfIteratorHelper(copy),
_step;
try {
var _loop = function _loop() {
var copied = _step.value;
copied.onclick = function () {
document.execCommand("copy");
};
copied.addEventListener("copy", function (event) {
event.preventDefault();
if (event.clipboardData) {
event.clipboardData.setData("text/plain", copied.textContent);
console.log(event.clipboardData.getData("text"));
}
;
});
};
for (_iterator.s(); !(_step = _iterator.n()).done;) {
_loop();
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
;
// Simple calculator
$(document).ready(function () {
// Check if the current page belongs to the desired category
if ($.inArray("Pages with dynamic calculator", mw.config.get("wgCategories")) === -1) {
return; // Exit if the condition is not met
}
// Create the input elements and replace the corresponding span elements
for (var index = 1; index <= 3; index++) {
var spanElement = document.getElementById('simple-calc__rinput' + index);
// Create the input element
var inputElement = document.createElement('input');
inputElement.type = 'text';
inputElement.placeholder = 'Enter a value';
inputElement.id = 'simple-calc__input' + index;
// Replace the span element with the input element
spanElement.parentNode.replaceChild(inputElement, spanElement);
}
// Get the span element to be replaced with the button
var spanElement = document.getElementById('simple-calc__rcalculate');
// Create the button element
var calculateButton = document.createElement('button');
calculateButton.id = 'calculate-btn';
calculateButton.textContent = 'Calculate';
// Add click event listener to the button
calculateButton.addEventListener('click', function () {
// Get the input values
var inputValue1 = parseFloat(document.getElementById('simple-calc__input1').value);
var inputValue2 = parseFloat(document.getElementById('simple-calc__input2').value);
var inputValue3 = parseFloat(document.getElementById('simple-calc__input3').value);
// Perform calculations
var i = inputValue1;
var l = inputValue2;
var j = inputValue3;
// Calculate k based on the seed value
var seedValue = parseFloat(document.getElementById('simple-calc__seed').textContent);
// Output the results
console.log('i = ' + i);
console.log('l = ' + l);
console.log('j = ' + j);
console.log('k = ' + seedValue);
// Calculate the answer based on the simplified equation
var answer = i + (i * (l - seedValue) * 0.01) - ((i + (i * (l - 2) * 0.01)) * (j - 1) * 0.09);
// Round the answer to two decimal places using toFixed
answer = answer.toFixed(2);
// Output the answer
console.log('Your answer is (' + answer + ')');
// Replace the answer element with the calculated answer
var answerElement = document.getElementById('simple-calc__answer');
answerElement.textContent = '₲' + answer;
});
// Replace the span element with the button
spanElement.parentNode.replaceChild(calculateButton, spanElement);
});