remember the last language used on a particular pad

pull/1/head
ansuz 9 years ago
parent e84fbf0bc3
commit 446266a79b

@ -322,10 +322,12 @@ define([
}); });
$rightside.append($forgetPad); $rightside.append($forgetPad);
var lastLanguage = Cryptpad.getPadAttribute('language') || 'javascript';
/* Let the user select different syntax highlighting modes */ /* Let the user select different syntax highlighting modes */
var syntaxDropdown = '<select title="syntax highlighting" id="language-mode">\n' + var syntaxDropdown = '<select title="syntax highlighting" id="language-mode">\n' +
Modes.map(function (o) { Modes.map(function (o) {
var selected = o.mode === 'javascript'? ' selected="selected"' : ''; var selected = o.mode === lastLanguage? ' selected="selected"' : '';
return '<option value="' + o.mode + '"'+selected+'>' + o.language + '</option>'; return '<option value="' + o.mode + '"'+selected+'>' + o.language + '</option>';
}).join('\n') + }).join('\n') +
'</select>'; '</select>';
@ -347,6 +349,7 @@ define([
var $language = module.$language = $bar.find('#language-mode').on('change', function () { var $language = module.$language = $bar.find('#language-mode').on('change', function () {
var mode = $language.val(); var mode = $language.val();
setMode(mode); setMode(mode);
Cryptpad.setPadAttribute('language', mode);
}); });
$rightside.append(themeDropdown); $rightside.append(themeDropdown);

Loading…
Cancel
Save