mirror of
https://github.com/claudehohl/Stikked.git
synced 2025-04-25 20:41:20 -05:00
autoloading
This commit is contained in:
parent
a8a2c631f9
commit
771a736c58
@ -142,12 +142,12 @@ class Main extends CI_Controller
|
||||
|
||||
//codemirror modes
|
||||
$cmm = array();
|
||||
foreach ($codemirror_languages as $l)
|
||||
foreach ($codemirror_languages as $geshi_name => $l)
|
||||
{
|
||||
|
||||
if (gettype($l) == 'array')
|
||||
{
|
||||
$cmm[] = $l['mode'];
|
||||
$cmm[$geshi_name] = $l['mode'];
|
||||
}
|
||||
}
|
||||
$data['codemirror_modes'] = $cmm;
|
||||
|
@ -1,5 +1,10 @@
|
||||
<?php $this->load->view('defaults/footer_message.php'); ?>
|
||||
<?php
|
||||
|
||||
//codemirror modes
|
||||
echo '<div style="display: none;" id="codemirror_modes">' . json_encode($codemirror_modes) . '</div>';
|
||||
|
||||
//stats
|
||||
$this->load->view('defaults/stats');
|
||||
|
||||
//Javascript
|
||||
@ -19,8 +24,6 @@ if(isset($codemirror_languages[$lang_set]) && gettype($codemirror_languages[$lan
|
||||
$this->carabiner->group('codemirror', $codemirror_specific);
|
||||
$this->carabiner->display('codemirror');
|
||||
|
||||
//codemirror modes
|
||||
echo '<div style="display: none;" id="codemirror_modes">' . json_encode($codemirror_modes) . '</div>';
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -1,16 +1,30 @@
|
||||
var CM = window.CM || {}
|
||||
|
||||
|
||||
CM.init = function() {
|
||||
//CM.editor.toTextArea();
|
||||
CM.modes = $.parseJSON($('#codemirror_modes').text());
|
||||
var lang = $('#lang').val();
|
||||
console.info(lang);
|
||||
mode = CM.modes[lang];
|
||||
|
||||
$.get(base_url + 'main/get_cm_js/' + lang,
|
||||
function(data) {
|
||||
if (data != '') {
|
||||
CM.set_syntax(mode);
|
||||
} else {
|
||||
CM.set_syntax(null);
|
||||
}
|
||||
},
|
||||
'script');
|
||||
};
|
||||
|
||||
CM.set_syntax = function(mode) {
|
||||
if (typeof CM.editor == 'undefined') {
|
||||
CM.editor = CodeMirror.fromTextArea(document.getElementById('code'), {
|
||||
mode: CM.mode,
|
||||
mode: mode,
|
||||
lineNumbers: true,
|
||||
lineWrapping: true,
|
||||
});
|
||||
} else {
|
||||
CM.editor.setOption('mode', mode);
|
||||
}
|
||||
};
|
||||
|
||||
@ -19,9 +33,9 @@ $(document).ready(function() {
|
||||
$enable_codemirror.click(function() {
|
||||
CM.init();
|
||||
$enable_codemirror.remove();
|
||||
$('#lang').change(function() {
|
||||
CM.init();
|
||||
});
|
||||
return false;
|
||||
});
|
||||
$('#lang').change(function() {
|
||||
CM.init();
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user