todo. proof of concept, dynamic loading of various languages #codemirror --> WORKS!

This commit is contained in:
Claude 2012-04-22 20:46:50 +02:00
parent 3fe74f810e
commit cd4d2b676e

View File

@ -1,18 +1,30 @@
var CM = window.CM || {} var CM = window.CM || {}
CM.on = false;
CM.mode = 'php';
CM.init = function() { CM.init = function() {
var editor = CodeMirror.fromTextArea(document.getElementById('code'), { if (CM.on) {
mode: $('#codemirror_mode').text(), CM.editor.toTextArea();
CM.on = false;
} else {
CM.editor = CodeMirror.fromTextArea(document.getElementById('code'), {
mode: CM.mode, //$('#codemirror_mode').text(),
lineNumbers: true, lineNumbers: true,
lineWrapping: true, lineWrapping: true,
}); });
CM.on = true;
if (CM.mode == 'php') {
CM.mode = 'javascript';
}
}
}; };
$(document).ready(function() { $(document).ready(function() {
$enable_codemirror = $('#enable_codemirror'); $enable_codemirror = $('#enable_codemirror');
$enable_codemirror.click(function() { $enable_codemirror.click(function() {
CM.init(); CM.init();
$enable_codemirror.remove(); //$enable_codemirror.remove();
return false; return false;
}); });
}); });