Welcome to the navigation

Pariatur, elit, amet, laboris do dolore laborum, minim fugiat id velit mollit ex dolor nisi sint eiusmod deserunt sunt magna consequat, aliqua, adipisicing tempor labore. Nulla voluptate tempor minim consequat, ullamco nostrud do pariatur, elit, sunt qui fugiat ut est commodo duis ad anim labore consectetur dolore excepteur occaecat adipisicing

Yeah, this will be replaced... But please enjoy the search!

Overriding the default window.prompt using Apprise

I've been using Apprise for quite a long time now, the V2 actually made it harder working with callbacks and similar, hence this post.

Replacing methods in Javascript

Replacing methods in Javascript can be simple, in this example I've replaced the prompt() method

// Replace the prompt with an alert
window.prompt = function() {
    alert("The prompt method is overridden");
}

Replacing the window.prompt with an apprise call

// Define new prompt method
window.prompt = function(text, callback) {
    // Setup Apprise
    var options = {
        buttons: {
            confirm: {
                text: 'Send',
                action: function(e) {
                    callback(e.input);
                    Apprise('close');
                }
            },
        },
        input: true
    };

    // Call Apprise
    Apprise(text, options);
};

// Call the prompt method
prompt("Say something", function(returnValue) {
    // Handle the returnValue here
    console.log(returnValue);
});

The dialog

 

The call and result in a console

  

Please note that this portal is a BETA site , I will continuously improve all functionality and performance during the coming weeks / the author