User:Sur/common.js: Difference between revisions

From Deadlock Wiki
Jump to navigation Jump to search
Sur (talk | contribs)
mNo edit summary
Sur (talk | contribs)
mNo edit summary
Line 1: Line 1:
function storeValue() {
        // Get the input value
        var inputValue = document.getElementById('inputValue').value;


        // Use JavaScript to dynamically update the #var (normally handled by PHP in the wiki environment)
function storeInput() {
        mw.loader.using('mediawiki.util', function () {
    // Get the user's input
            var updatedText = '{{#vardefine:storedValue|' + inputValue + '}}';
    var userInput = prompt("Please enter your input:");
            mw.util.addCSS(updatedText);
        });


         // Optional: Reload the page to reflect the new stored value in the displayed content
    // Set the #var with the user's input by embedding it back into the page
         location.reload();
    if (userInput !== null) {
        var variableSyntax = '{{#vardefine: userInput | ' + userInput + '}}';
       
         // Update the HTML element to reflect the user's input
        document.getElementById('display').innerHTML = variableSyntax;
 
        // To show what is stored
         alert("Stored in #var: " + userInput);
     }
     }
}

Revision as of 00:08, 23 September 2024

function storeInput() {
    // Get the user's input
    var userInput = prompt("Please enter your input:");

    // Set the #var with the user's input by embedding it back into the page
    if (userInput !== null) {
        var variableSyntax = '{{#vardefine: userInput | ' + userInput + '}}';
        
        // Update the HTML element to reflect the user's input
        document.getElementById('display').innerHTML = variableSyntax;

        // To show what is stored
        alert("Stored in #var: " + userInput);
    }
}