2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

fhemweb.js: CodeMirror/perlSyntaxCheck fixes by rapster (Forum #52379)

git-svn-id: https://svn.fhem.de/fhem/trunk@11280 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2016-04-18 18:58:28 +00:00
parent 3165d5707d
commit 0d46dbf45b
2 changed files with 17 additions and 5 deletions

View File

@ -2405,11 +2405,8 @@ FW_makeEdit($$$)
# Toggle Edit-Window visibility script.
my $psc = AttrVal("global", "perlSyntaxCheck", ($featurelevel>5.7) ? 1 : 0);
my $pgm = "var old = \$('#edit').css('display');".
"\$('#edit').css('display', old=='none' ? 'block' : 'none');".
"\$('#disp').css('display', old=='none' ? 'none' : 'block');";
FW_pO "<td>";
FW_pO "<a onClick=\"$pgm\" style=\"cursor:pointer\">$n</a>";
FW_pO "<a id=\"DEFa\" style=\"cursor:pointer\">$n</a>";
FW_pO "</td>";
$val =~ s,\\\n,\n,g;

View File

@ -473,9 +473,24 @@ FW_replaceLink(el)
function
FW_inlineModify() // Do not generate a new HTML page upon pressing modify
{
var cm;
$('#DEFa').click(function(){
var old = $('#edit').css('display');
$('#edit').css('display', old=='none' ? 'block' : 'none');
$('#disp').css('display', old=='none' ? 'none' : 'block');
if( typeof AddCodeMirror == 'function' ) {
var s=document.getElementById("edit").getElementsByTagName("textarea");
if(!s[0].editor) {
s[0].editor=true; AddCodeMirror(s[0], function(pcm) {cm = pcm;});
}
}
});
$("div input.psc[type=submit]").click(function(e){
e.preventDefault();
var newDef = $(this).closest("form").find("textarea").val();
var newDef = typeof cm !== 'undefined' ? cm.getValue()
: $(this).closest("form").find("textarea").val();
var cmd = $(this).attr("name")+"="+$(this).attr("value")+" "+newDef;
if( newDef == undefined ) {