MyBB Community Forums

Full Version: Use CodeMirror code highlighter for MyBB 1.6
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In the name of God.

in this thread you are learning how to use CodeMirror for MyBB 1.6.x
author: http://my-bb.ir
1) upload this attachment in MyBB_ROOT and then extract this.
[attachment=30458]
2) edit admin/jscripts/codepress/codepress.js and replace codes with:
CodePress = function(obj) {

}

CodePress.languages = {    
}


CodePress.run = function() {
    var editor = CodeMirror.fromTextArea(document.getElementsByClassName("codepress")[0], {
                    lineNumbers: true,
                    lineWrapping: true,
                    tabMode: "indent",
                    theme: "mybb"
                });
}
document.write('<link href="./jscripts/codemirror/lib/codemirror.css" rel="stylesheet">\
<link href="./jscripts/codemirror/theme/mybb.css" rel="stylesheet">\
<script src="./jscripts/codemirror/lib/codemirror.js"></script>\
<script src="./jscripts/codemirror/mode/css/css.js"></script>\
<style>.codepress { width:auto !important} </style>');
if(window.attachEvent) window.attachEvent('onload',CodePress.run);
else window.addEventListener('DOMContentLoaded',CodePress.run,false); 

3) go to ACP -> Preferences -> Turn on CodePress
Never mind doesn't work... Sad
^ well, I'd tested it (a few months back) & it worked for MyBB 1.6.10 and it should work for MyBB 1.6.12
I followed the steps exactly and the result was, nothing in the textbox, normally with codepress you get the syntax highlighting and line numbers, but now nothing as if codepress was disabled (it was enabled in options). So I reverted back.