more work on highlighting modes in codemirror

* style the select menu
* add more modes
* preset language selection to 'javascript'
* don't prompt the user with a silly hash when changing their name
pull/1/head
ansuz 9 years ago
parent a89511985f
commit 1a5905d9fd

@ -30,8 +30,7 @@ define([
var andThen = function (CMeditor) { var andThen = function (CMeditor) {
var CodeMirror = module.CodeMirror = CMeditor; var CodeMirror = module.CodeMirror = CMeditor;
CodeMirror.modeURL = "/code/codemirror-5.13.2/mode/%N/%N.js"; CodeMirror.modeURL = "/code/CodeMirror-5.16.0/mode/%N/%N.js";
var $pad = $('#pad-iframe'); var $pad = $('#pad-iframe');
var $textarea = $pad.contents().find('#editor1'); var $textarea = $pad.contents().find('#editor1');
@ -126,7 +125,7 @@ define([
var createChangeName = function(id, $container) { var createChangeName = function(id, $container) {
var buttonElmt = $container.find('#'+id)[0]; var buttonElmt = $container.find('#'+id)[0];
buttonElmt.addEventListener("click", function() { buttonElmt.addEventListener("click", function() {
var newName = window.prompt("Change your name :", myUserName); var newName = window.prompt("Change your name :");
if (newName && newName.trim()) { if (newName && newName.trim()) {
var myUserNameTemp = newName.trim(); var myUserNameTemp = newName.trim();
if(newName.trim().length > 32) { if(newName.trim().length > 32) {
@ -163,7 +162,8 @@ define([
var dropdown = '<select id="language-mode">\n' + var dropdown = '<select id="language-mode">\n' +
Modes.map(function (o) { Modes.map(function (o) {
return '<option value="' + o.mode + '">' + o.language + '</option>'; var selected = o.mode === 'javascript'? ' selected="selected"' : '';
return '<option value="' + o.mode + '"'+selected+'>' + o.language + '</option>';
}).join('\n') + }).join('\n') +
'</select>'; '</select>';

@ -1,8 +1,124 @@
define(function () { define(function () {
return [ return [
"Javascript javascript", "apl apl",
"Python python", "asciiarmor asciiarmor",
"Mixed_HTML htmlmixed", "asn.1 asn.1",
"asterisk asterisk",
"brainfuck brainfuck",
"clike clike",
"clojure clojure",
"cmake cmake",
"cobol cobol",
"coffeescript coffeescript",
"commonlisp commonlisp",
"crystal crystal",
"css css",
"cypher cypher",
"d d",
"dart dart",
"diff diff",
"django django",
"dockerfile dockerfile",
"dtd dtd",
"dylan dylan",
"ebnf ebnf",
"ecl ecl",
"eiffel eiffel",
"elm elm",
"erlang erlang",
"factor factor",
"fcl fcl",
"forth forth",
"fortran fortran",
"gas gas",
"gfm gfm",
"gherkin gherkin",
"go go",
"groovy groovy",
"haml haml",
"handlebars handlebars",
"haskell haskell",
"haskell-literate haskell-literate",
"haxe haxe",
"htmlembedded htmlembedded",
"htmlmixed htmlmixed",
"http http",
"idl idl",
"index.html index.html",
"jade jade",
"javascript javascript",
"jinja2 jinja2",
"jsx jsx",
"julia julia",
"livescript livescript",
"loadmode.js loadmode.js",
"lua lua",
"markdown markdown",
"mathematica mathematica",
"meta.js meta.js",
"mirc mirc",
"mllike mllike",
"modelica modelica",
"mscgen mscgen",
"mumps mumps",
"nginx nginx",
"nsis nsis",
"ntriples ntriples",
"octave octave",
"oz oz",
"pascal pascal",
"pegjs pegjs",
"perl perl",
"php php",
"pig pig",
"properties properties",
"protobuf protobuf",
"puppet puppet",
"python python",
"q q",
"r r",
"rpm rpm",
"rst rst",
"ruby ruby",
"rust rust",
"sass sass",
"scheme scheme",
"shell shell",
"sieve sieve",
"slim slim",
"smalltalk smalltalk",
"smarty smarty",
"solr solr",
"soy soy",
"sparql sparql",
"spreadsheet spreadsheet",
"sql sql",
"stex stex",
"stylus stylus",
"swift swift",
"tcl tcl",
"textile textile",
"tiddlywiki tiddlywiki",
"tiki tiki",
"toml toml",
"tornado tornado",
"troff troff",
"ttcn ttcn",
"ttcn-cfg ttcn-cfg",
"turtle turtle",
"twig twig",
"vb vb",
"vbscript vbscript",
"velocity velocity",
"verilog verilog",
"vhdl vhdl",
"vue vue",
"xml xml",
//"xwiki xwiki21",
"xquery xquery",
"yaml yaml",
"yaml-frontmatter yaml-frontmatter",
"z80 z80"
].map(function (line) { ].map(function (line) {
var kv = line.split(/\s/); var kv = line.split(/\s/);
return { return {

@ -129,6 +129,13 @@ define([
.{{TOOLBAR_CLS}} .{{LOAD_ELEMENT_CLS}}:after { .{{TOOLBAR_CLS}} .{{LOAD_ELEMENT_CLS}}:after {
content: 'IMPORT'; content: 'IMPORT';
} }
.{{TOOLBAR_CLS}} select {
border: 0px;
margin-left: 5px;
margin-right: 5px;
padding-left: 5px;
}
</style> </style>
*/}.toString().slice(14,-3), { */}.toString().slice(14,-3), {
TOOLBAR_CLS: TOOLBAR_CLS, TOOLBAR_CLS: TOOLBAR_CLS,

Loading…
Cancel
Save