Make CodeMirror usage optional. update email address

This commit is contained in:
Joshua Bell 2012-06-20 12:13:06 -04:00
parent d7b3a08957
commit 895bd172d8
3 changed files with 30 additions and 10 deletions

View File

@ -111,7 +111,7 @@ By <a href="mailto:inexorabletash@hotmail.com">Joshua Bell</a>
<!-- Source code editor inserted here -->
<div id="editorframe"></div>
<form id="submission" method="post" enctype="text/plain" action="mailto:inexorabletash@hotmail.com?subject=Applesoft%20Sample%20Submission">
<form id="submission" method="post" enctype="text/plain" action="mailto:inexorabletash@gmail.com?subject=Applesoft%20Sample%20Submission">
<textarea name="source" id="source" style="display: none;">
</textarea>
<input type="submit" id="btn_share" value="Share your sample!">
@ -164,7 +164,7 @@ By <a href="mailto:inexorabletash@hotmail.com">Joshua Bell</a>
<h3 id="history">History</h3>
<div id="feed"></div>
<!-- CodeMirror syntax highlighting - this is optional -->
<script src="cm2/lib/codemirror.js"></script>
<link rel="stylesheet" href="cm2/lib/codemirror.css">
<script src="cm2/mode/basic/basic.js"></script>

View File

@ -42,13 +42,34 @@ window.onload = function () {
};
var pdl = [0, 0, 0, 0];
// Lexical highlighting
var editor = new CodeMirror($('#editorframe'), {
mode: 'basic',
tabMode: 'default',
content: $('#source').value,
height: '100%'
});
// Lexical highlighting, if available
var editor;
if (typeof CodeMirror === 'function') {
editor = new CodeMirror($('#editorframe'), {
mode: 'basic',
tabMode: 'default',
content: $('#source').value,
height: '100%'
});
} else {
editor = (function () {
var textArea = document.createElement('textarea');
$('#editorframe').appendChild(textArea);
textArea.style.width = '598px';
textArea.style.height = '384px';
return {
getValue: function () {
return textArea.value;
},
setValue: function (value) {
textArea.value = value;
},
setCursor: function (line, column) {
// TODO: Implement me!
}
};
}());
}
$('#btn_share').onclick = function () {
// Load up the hidden text area with the current source

View File

@ -1,4 +1,3 @@
body { background-color: #EEEACD; }
h1, h2, h3, p { margin-bottom: 6pt; margin-top: 6pt; }
td { vertical-align: top; }