Snippi
A super awesome snippet tool.
- 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.