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