|
|
|
$(document).ready(function() {
|
|
|
|
/* code highlight */
|
|
|
|
$('pre code').each(function(i, block) {
|
|
|
|
hljs.highlightBlock(block);
|
|
|
|
});
|
|
|
|
|
|
|
|
/* zerobin / radio 'source' autoswitch */
|
|
|
|
$('#paste').on('change', function() {
|
|
|
|
$('input[name=source]').val(['form']);
|
|
|
|
});
|
|
|
|
$('#upload').on('change', function() {
|
|
|
|
$('input[name=source]').val(['file']);
|
|
|
|
});
|
|
|
|
|
|
|
|
/* comments */
|
|
|
|
$('#comments').load('/comments/get', function() {
|
|
|
|
// handle 'add comment' button click
|
|
|
|
$('a#cadd').click(function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
$(this).remove();
|
|
|
|
$('#comments').load('/comments/new', function() {
|
|
|
|
// form submit with ajax
|
|
|
|
$('#comments form').submit(function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
var url = document.createElement('a');
|
|
|
|
url.href = window.location;
|
|
|
|
var text = $('#comments textarea').val();
|
|
|
|
$.post('/comments/add', {
|
|
|
|
'pageid': escape(url.pathname),
|
|
|
|
'text': text,
|
|
|
|
}, function() {
|
|
|
|
location.reload();
|
|
|
|
});
|
|
|
|
}); // form submit
|
|
|
|
}); // on form load
|
|
|
|
}); // #cadd click
|
|
|
|
}); // #comments
|
|
|
|
}); // document ready
|