Skip to content

Commit

Permalink
Update public.js
Browse files Browse the repository at this point in the history
  • Loading branch information
midoks committed Dec 13, 2024
1 parent fdf2e38 commit cce3102
Showing 1 changed file with 40 additions and 24 deletions.
64 changes: 40 additions & 24 deletions web/static/app/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -2243,6 +2243,12 @@ function pluginConfigTpl(_name, version, func, config_tpl_func, read_config_tpl_
return f
}

var editor;
function saveDataFunc(){
$("#textBody").text(editor.getValue());
pluginConfigSave(fileName,save_callback_func);
}

var fileName = '';
$.post('/plugins/run',{name:_name, func:_config_tpl_func,version:version}, function(data){
var rdata = $.parseJSON(data.data);
Expand All @@ -2256,6 +2262,7 @@ function pluginConfigTpl(_name, version, func, config_tpl_func, read_config_tpl_
var loadT = layer.msg('配置模版获取中...',{icon:16,time:0,shade: [0.3, '#000']});

var _args = JSON.stringify({file:selected});

$.post('/plugins/run', {name:_name, func:_read_config_tpl_func,version:version,args:_args}, function(data){
layer.close(loadT);
var rdata = $.parseJSON(data.data);
Expand All @@ -2266,15 +2273,17 @@ function pluginConfigTpl(_name, version, func, config_tpl_func, read_config_tpl_

$("#textBody").empty().text(rdata.data);
$(".CodeMirror").remove();
var editor = CodeMirror.fromTextArea(document.getElementById("textBody"), {
editor = CodeMirror.fromTextArea(document.getElementById("textBody"), {
extraKeys: {
"Ctrl-Space": "autocomplete",
"Ctrl-F": "findPersistent",
"Ctrl-H": "replaceAll",
"Ctrl-S": function() {
$("#textBody").text(editor.getValue());
pluginConfigSave(fileName,save_callback_func);
}
saveDataFunc();
},
"Cmd-S":function() {
saveDataFunc();
}
},
lineNumbers: true,
matchBrackets:true,
Expand All @@ -2283,8 +2292,7 @@ function pluginConfigTpl(_name, version, func, config_tpl_func, read_config_tpl_
$(".CodeMirror-scroll").css({"height":"300px","margin":0,"padding":0});
$("#onlineEditFileBtn").unbind('click');
$("#onlineEditFileBtn").click(function(){
$("#textBody").text(editor.getValue());
pluginConfigSave(fileName, save_callback_func);
saveDataFunc()
});
},'json');
}
Expand Down Expand Up @@ -2312,18 +2320,19 @@ function pluginConfigTpl(_name, version, func, config_tpl_func, read_config_tpl_
"Ctrl-F": "findPersistent",
"Ctrl-H": "replaceAll",
"Ctrl-S": function() {
$("#textBody").text(editor.getValue());
pluginConfigSave(fileName,save_callback_func);
}
saveDataFunc();
},
"Cmd-S":function() {
saveDataFunc();
}
},
lineNumbers: true,
matchBrackets:true,
});
editor.focus();
$(".CodeMirror-scroll").css({"height":"300px","margin":0,"padding":0});
$("#onlineEditFileBtn").click(function(){
$("#textBody").text(editor.getValue());
pluginConfigSave(fileName,save_callback_func);
saveDataFunc();
});
},'json');
},'json');
Expand Down Expand Up @@ -2361,6 +2370,12 @@ function pluginConfigListTpl(_name, version, config_tpl_func, read_config_tpl_fu
return f
}

var editor;
function saveDataFunc(){
$("#textBody").text(editor.getValue());
pluginConfigSave(fileName);
}

function loadTextBody(fileName){
$.post('/files/get_body', 'path=' + fileName, function(rdata) {
if (!rdata.status){
Expand All @@ -2369,14 +2384,16 @@ function pluginConfigListTpl(_name, version, config_tpl_func, read_config_tpl_fu
}
$("#textBody").empty().text(rdata.data.data);
$(".CodeMirror").remove();
var editor = CodeMirror.fromTextArea(document.getElementById("textBody"), {
editor = CodeMirror.fromTextArea(document.getElementById("textBody"), {
extraKeys: {
"Ctrl-Space": "autocomplete",
"Ctrl-F": "findPersistent",
"Ctrl-H": "replaceAll",
"Ctrl-S": function() {
$("#textBody").text(editor.getValue());
pluginConfigSave(fileName);
saveDataFunc();
},
"Cmd-S": function() {
saveDataFunc();
}
},
lineNumbers: true,
Expand All @@ -2385,8 +2402,7 @@ function pluginConfigListTpl(_name, version, config_tpl_func, read_config_tpl_fu
editor.focus();
$(".CodeMirror-scroll").css({"height":"300px","margin":0,"padding":0});
$("#onlineEditFileBtn").click(function(){
$("#textBody").text(editor.getValue());
pluginConfigSave(fileName);
saveDataFunc();
});
},'json');
}
Expand Down Expand Up @@ -2421,25 +2437,25 @@ function pluginConfigListTpl(_name, version, config_tpl_func, read_config_tpl_fu

$("#textBody").empty().text(rdata.data);
$(".CodeMirror").remove();
var editor = CodeMirror.fromTextArea(document.getElementById("textBody"), {
editor = CodeMirror.fromTextArea(document.getElementById("textBody"), {
extraKeys: {
"Ctrl-Space": "autocomplete",
"Ctrl-F": "findPersistent",
"Ctrl-H": "replaceAll",
"Ctrl-S": function() {
$("#textBody").text(editor.getValue());
pluginConfigSave(fileName);
}
saveDataFunc();
},
"Cmd-S":function() {
saveDataFunc();
}
},
lineNumbers: true,
matchBrackets:true,
});
editor.focus();
$(".CodeMirror-scroll").css({"height":"300px","margin":0,"padding":0});
$("#onlineEditFileBtn").unbind('click');
$("#onlineEditFileBtn").click(function(){
$("#textBody").text(editor.getValue());
pluginConfigSave(fileName);
$("#onlineEditFileBtn").unbind('click').click(function(){
saveDataFunc();
});
},'json');

Expand Down

0 comments on commit cce3102

Please sign in to comment.