| 1 |
<!DOCTYPE html> |
| 2 |
<html lang="en"> |
| 3 |
<head> |
| 4 |
<meta charset="UTF-8"> |
| 5 |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
| 6 |
<title>ACE Editor Modelist Demo</title> |
| 7 |
<style type="text/css" media="screen"> |
| 8 |
body { |
| 9 |
overflow: hidden; |
| 10 |
} |
| 11 |
|
| 12 |
#editor { |
| 13 |
margin: 0; |
| 14 |
position: absolute; |
| 15 |
top: 0; |
| 16 |
bottom: 0; |
| 17 |
left: 0; |
| 18 |
right: 0; |
| 19 |
} |
| 20 |
</style> |
| 21 |
</head> |
| 22 |
<body> |
| 23 |
|
| 24 |
<pre id="editor"></pre> |
| 25 |
|
| 26 |
<script src="kitchen-sink/require.js"></script> |
| 27 |
<script> |
| 28 |
// setup paths |
| 29 |
require.config({paths: { "ace" : "../src"}}); |
| 30 |
// load ace and extensions |
| 31 |
require(["ace/ace", "ace/ext/modelist"], function(ace) { |
| 32 |
var editor = ace.edit("editor"); |
| 33 |
editor.setTheme("ace/theme/twilight"); |
| 34 |
(function () { |
| 35 |
var modelist = require("ace/ext/modelist"); |
| 36 |
// the file path could come from an xmlhttp request, a drop event, |
| 37 |
// or any other scriptable file loading process. |
| 38 |
// Extensions could consume the modelist and use it to dynamically |
| 39 |
// set the editor mode. Webmasters could use it in their scripts |
| 40 |
// for site specific purposes as well. |
| 41 |
var filePath = "blahblah/weee/some.js"; |
| 42 |
var mode = modelist.getModeForPath(filePath).mode; |
| 43 |
console.log(mode); |
| 44 |
editor.session.setMode(mode); |
| 45 |
}()); |
| 46 |
}) |
| 47 |
</script> |
| 48 |
|
| 49 |
<script src="./show_own_source.js"></script> |
| 50 |
</body> |
| 51 |
</html> |