Add syntax highlighting

Syntax highlighting is done with the use of the library:

http://code.google.com/p/google-code-prettify/

Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
This commit is contained in:
Alexey Gladkov 2012-04-29 20:27:00 +04:00
parent 241c75a5d5
commit 0057045f51
5 changed files with 1550 additions and 2 deletions

View file

@ -109,12 +109,15 @@ function displayMessages(key, comments) {
var cleartext = zeroDecipher(key, comments[0].data);
} catch(err) {
$('div#cleartext').hide();
$('div#prettymessage').hide();
$('button#clonebutton').hide();
showError('Could not decrypt data (Wrong key ?)');
return;
}
setElementText($('div#cleartext'), cleartext);
setElementText($('pre#prettyprint'), cleartext);
urls2links($('div#cleartext')); // Convert URLs to clickable links.
prettyPrint();
// Display paste expiration.
if (comments[0].meta.expire_date) $('div#remainingtime').removeClass('foryoureyesonly').text('This document will expire in '+secondsToHuman(comments[0].meta.remaining_time)+'.').show();
@ -257,8 +260,10 @@ function send_data() {
showStatus('');
$('div#pastelink').html('Your paste is <a href="' + url + '">' + url + '</a>').show();
setElementText($('div#cleartext'), $('textarea#message').val());
setElementText($('pre#prettyprint'), $('textarea#message').val());
urls2links($('div#cleartext'));
showStatus('');
prettyPrint();
}
else if (data.status==1) {
showError('Could not create paste: '+data.message);
@ -287,6 +292,7 @@ function stateNewPaste() {
$('div#cleartext').hide();
$('div#message').focus();
$('div#discussion').hide();
$('div#prettymessage').hide();
}
/**
@ -310,7 +316,8 @@ function stateExistingPaste() {
$('button#newbutton').show();
$('div#pastelink').hide();
$('textarea#message').hide();
$('div#cleartext').show();
$('div#cleartext').hide();
$('div#prettymessage').show();
}
/**