JSFiddle - React, Tailwind, and code Playground

by sonali_moholkar

HTML

<html>
    <input type='button' name='sonali_saver' value='Save'/>
<input type='button' name='sonali_bug' value='Bug'/>
<input type='button' name='sonali_cancel' value='Cancel'/>
    <input type='button' name='sonali_son1' value='son'/>
<input type='text' name='textt' value=''/>
    <span> </span>
<script>
    var Sonali = {};
 $( document ).ready( function() {
  Sonali.setup();
    });
    
    Sonali.setup = function() 
    {
    Sonali.setup_buttons();
    Sonali.setup_listeners();
    };
    
 Sonali.setup_buttons = function() {
    var buttons = Sonali.get_buttons();
    console.log( 'BUTTONS', Sonali.state );
};

Sonali.get_buttons = function() {
    return { 'saver': 'click', 'cancel': 'click', 'text': 'change', 'bug': 'click' , 'son': 'click' };  
}
    
    Sonali.setup_listeners = function() 
    {
    var buttons = Sonali.get_buttons();
    var x = '';
    for ( x in buttons ) {        
        $( 'input[name="sonali_' + x + '"]' ).bind( buttons[ x ], function( e ) {
    Sonali.display_text( $( e.target ).val() );
} );
    }
};
    Sonali.display_text = function( text_to_alert )
    {
    alert( text_to_alert );   
     $("span").text("Validated...").show();
    
    
};
    /* Local Store Wrapper */

/* Since the code below works with any key, and we just want the "status_data" key, we write a "wrapper" that always invokes the local store getters/setters with our key */

Sonali.getStatus = function() {
    Sonali.datastore.get( 'status_data' );
};


Sonali.setStatus = function( status_data ) {
    Sonali.datastore.set( 'status_data', status_data );
};

/* Local Store */

Sonali.datastore = {};

Sonali.datastore.get = function(key) {
    return JSON.parse(localStorage.getItem(key));
};

/* sets or updates a value for a key */
Sonali.datastore.set = function(key, val) {
    localStorage.setItem(key, JSON.stringify(val));
};

/* returns true if value is set, else false */
Sonali.datastore.isSet = function(key) {
    var val = Sonali.datastore.get(key);
 ...