mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-22 23:28:40 +00:00
96d4a3ecf7
Due to historical reasons, the code is in subfolder "1". With SVN removal, we place the code back and remove the annoying "1" folder.
36 lines
824 B
JavaScript
36 lines
824 B
JavaScript
(function() {
|
|
$.fn.slide_editor = function() {
|
|
return this.each(function() {
|
|
var name = this.id;
|
|
var this_form = this.form;
|
|
|
|
$(this).replaceWith($('<div id="' + name + '-slide-editor" class="slide-editor"></div>')
|
|
.append($(this).clone())
|
|
);
|
|
|
|
var codeeditor = CodeMirror.fromTextArea($('#' + name)[0], {
|
|
mode: 'plain',
|
|
lineNumbers: true,
|
|
matchBrackets: true,
|
|
lineWrapping: true,
|
|
styleActiveLine: true,
|
|
theme: 'default'
|
|
});
|
|
|
|
if (this_form) {
|
|
var changed = false;
|
|
codeeditor.on('change', function() {
|
|
before_window_unload_message = '您所编辑的内容尚未保存';
|
|
changed = true;
|
|
});
|
|
$(this_form).submit(function() {
|
|
if (changed) {
|
|
before_window_unload_message = null;
|
|
}
|
|
changed = false;
|
|
});
|
|
}
|
|
});
|
|
};
|
|
})()
|