• 1.
    Contents of notifications.js
  • 2.
     
  • 3.
    $(document).ready(function() {
  • 4.
    // Remove notification on click.
  • 5.
    $('.notification').click( function() {
  • 6.
        $(this).fadeOut(1000);
  • 7.
    });
  • 8.
    });
  • 9.
     
  • 10.
    function updateNotification(json) {
  • 11.
    	var status = json.status;
  • 12.
    	var message = json.message;
  • 13.
    	$('.notification').css('display', 'block');
  • 14.
    	if(status == 'ok') {
  • 15.
    		$('.notification').removeClass('n-red').addClass('n-green').html(message);
  • 16.
    	}
  • 17.
    	
  • 18.
    	if(status == 'error') {
  • 19.
    		$('.notification').removeClass('n-green').addClass('n-red').html(message);
  • 20.
    	}
  • 21.
    }
  • 22.
     
  • 23.
    Relevant contents of install/index.php
  • 24.
     
  • 25.
    <head>
  • 26.
    // meta tags, style sheet and script includes here - yes, this isn't HTML comment but it's just for show :).
  • 27.
    </head>
  • 28.
    <body>
  • 29.
    // One or two elements
  • 30.
    <script type="text/javascript">
  • 31.
    $(document).ready( function() {
  • 32.
    	var json = {status : 'ok', message: 'Hello'};
  • 33.
    	updateNotification(json);
  • 34.
    });
  • 35.
    </script>
  • 36.
    // All other elements
  • 37.
    </body>
  • 38.
     
  • 39.
     
Contents of notifications.js $(document).ready(function() { // Remove notification on click. $('.notification').click( function() { $(this).fadeOut(1000); }); }); function updateNotification(json) { var status = json.status; var message = json.message; $('.notification').css('display', 'block'); if(status == 'ok') { $('.notification').removeClass('n-red').addClass('n-green').html(message); } if(status == 'error') { $('.notification').removeClass('n-green').addClass('n-red').html(message); } } Relevant contents of install/index.php <head> // meta tags, style sheet and script includes here - yes, this isn't HTML comment but it's just for show :). </head> <body> // One or two elements <script type="text/javascript"> $(document).ready( function() { var json = {status : 'ok', message: 'Hello'}; updateNotification(json); }); </script> // All other elements </body>

Copy Code to Clipboard Raw

Sign-in or Create a Free Account.

Snippi uses Twitter or Facebook to register and create accounts. Registration will enable you to keep track of your snippets. We never spam your timeline or wall. Ever.

Sign-in with Facebook Sign-in with Twitter