Difference between revisions of "MediaWiki:PageSpecific.js"

From Tycoon Gaming
(Created page with "$( document ).ready(function() { if (mw.config.get('wgPageName') === ('User:Donald/Testing')) { // Create the search form HTML var searchFormHTML = '<form action="/wiki...")
 
m (console.log)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
$( document ).ready(function() {
 
$( document ).ready(function() {
 
if (mw.config.get('wgPageName') === ('User:Donald/Testing')) {
 
if (mw.config.get('wgPageName') === ('User:Donald/Testing')) {
// Create the search form HTML
+
 +
 +
// Create the search form HTML
 
     var searchFormHTML = '<form action="/wiki/index.php" method="get">' +
 
     var searchFormHTML = '<form action="/wiki/index.php" method="get">' +
 
                         '<input type="hidden" name="title" value="Special:Search">' +
 
                         '<input type="hidden" name="title" value="Special:Search">' +
Line 15: Line 17:
 
         pageElement.innerHTML = searchFormHTML;
 
         pageElement.innerHTML = searchFormHTML;
 
     }
 
     }
 +
 +
 +
//////////////////////////////////////////////////////////////
 +
//////////////////////////////////////////////////////////////
 +
//////////////////////////////////////////////////////////////
 +
//////////////////////////////////////////////////////////////
 +
//////////////////////////////////////////////////////////////
 +
//////////////////////////////////////////////////////////////
 +
 +
 +
// Define the location where you want to inject the checkbox
 +
        var injectionPoint = $('#inputcheckboxtest'); // Replace with a suitable ID or selector
 +
 +
        // Create the checkbox and label elements
 +
        var checkbox = $('<input>', { type: 'checkbox', id: 'myCheckbox' });
 +
        var label = $('<label>', { 'for': 'myCheckbox' }).text(' Remember Me');
 +
 +
        // Append the checkbox and label to the injection point
 +
        injectionPoint.append(checkbox, label);
 +
 +
        // Load the saved state from LocalStorage
 +
        checkbox.prop('checked', localStorage.getItem('checkboxState') === 'true');
 +
 +
        // Save the state to LocalStorage when changed
 +
        checkbox.change(function() {
 +
            localStorage.setItem('checkboxState', checkbox.is(':checked'));
 +
        });
 +
       
 +
        Console.log("Wiki: Checkboxstate: " + localStorage.getItem('checkboxState'))
 
}
 
}
 
});
 
});

Latest revision as of 13:59, 18 December 2023

$( document ).ready(function() {
	if (mw.config.get('wgPageName') === ('User:Donald/Testing')) {
		
		
		// Create the search form HTML
    	var searchFormHTML = '<form action="/wiki/index.php" method="get">' +
                         '<input type="hidden" name="title" value="Special:Search">' +
                         '<input type="text" name="search" placeholder="Search the wiki" />' +
                         '<input type="submit" value="Go" />' +
                         '</form>';

    	// Identify the element where you want to add the search form
    	var pageElement = document.getElementById('testaddsearchbar'); // Replace 'someElementID' with the actual ID

    	// Insert the search form HTML into the identified element
    	if (pageElement) {
        	pageElement.innerHTML = searchFormHTML;
    	}


		//////////////////////////////////////////////////////////////
		//////////////////////////////////////////////////////////////
		//////////////////////////////////////////////////////////////
		//////////////////////////////////////////////////////////////
		//////////////////////////////////////////////////////////////
		//////////////////////////////////////////////////////////////
		

		// Define the location where you want to inject the checkbox
        var injectionPoint = $('#inputcheckboxtest'); // Replace with a suitable ID or selector

        // Create the checkbox and label elements
        var checkbox = $('<input>', { type: 'checkbox', id: 'myCheckbox' });
        var label = $('<label>', { 'for': 'myCheckbox' }).text(' Remember Me');

        // Append the checkbox and label to the injection point
        injectionPoint.append(checkbox, label);

        // Load the saved state from LocalStorage
        checkbox.prop('checked', localStorage.getItem('checkboxState') === 'true');

        // Save the state to LocalStorage when changed
        checkbox.change(function() {
            localStorage.setItem('checkboxState', checkbox.is(':checked'));
        });
        
        Console.log("Wiki: Checkboxstate: " + localStorage.getItem('checkboxState'))
	}
});