2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-21 01:46:08 +00:00

fhemweb.js: fix RawDef/Probably assoc. with & codeMirror (Forum #81595)

git-svn-id: https://svn.fhem.de/fhem/trunk@15701 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2017-12-27 08:45:48 +00:00
parent 60601c3235
commit 9cdc24caa8
2 changed files with 15 additions and 7 deletions

View File

@ -235,6 +235,8 @@ FW_Define($$)
return "Usage: define <name> FHEMWEB [IPV6:]<tcp-portnr> [global]" return "Usage: define <name> FHEMWEB [IPV6:]<tcp-portnr> [global]"
if($port !~ m/^(IPV6:)?\d+$/ || ($global && $global ne "global")); if($port !~ m/^(IPV6:)?\d+$/ || ($global && $global ne "global"));
FW_Undef($hash) if($hash->{OLDDEF}); # modify
foreach my $pe ("fhemSVG", "openautomation", "default") { foreach my $pe ("fhemSVG", "openautomation", "default") {
FW_readIcons($pe); FW_readIcons($pe);
} }

View File

@ -720,15 +720,18 @@ FW_rawDef()
var textAreaStyle = typeof AddCodeMirror == 'function'?'opacity:0':''; var textAreaStyle = typeof AddCodeMirror == 'function'?'opacity:0':'';
$("#content").append('<div id="rawDef">'+ $("#content").append('<div id="rawDef">'+
'<textarea id="td_rawDef" rows="25" cols="60" style="width:99%; '+textAreaStyle+'"/>'+ '<textarea id="td_rawDef" rows="25" cols="60" style="width:99%; '+
textAreaStyle+'"/>'+
'<button>Execute commands</button>'+ '<button>Execute commands</button>'+
' Dump "Probably associated with" too <input type="checkbox">'+ ' Dump "Probably associated with" too <input type="checkbox">'+
'<br><br></div>'); '<br><br></div>');
var cmVar;
function function
fillData(opt) fillData(opt)
{ {
var s = $('#rawDef textarea'); var s = $('#rawDef textarea');
FW_cmd(FW_root+"?cmd=list "+opt+" "+dev+"&XHR=1", function(data) { FW_cmd(FW_root+"?cmd=list "+opt+" "+dev+"&XHR=1", function(data) {
var re = new RegExp("^define", "gm"); var re = new RegExp("^define", "gm");
@ -749,12 +752,15 @@ FW_rawDef()
s.bind('input propertychange', propertychange); s.bind('input propertychange', propertychange);
if( typeof AddCodeMirror == 'function') { if(cmVar) {
$('#rawDef textarea + .CodeMirror').remove(); cmVar.setValue(data);
} else if(typeof AddCodeMirror == 'function') {
AddCodeMirror(s, function(cm) { AddCodeMirror(s, function(cm) {
cmVar = cm;
cm.on("change", function() { cm.on("change", function() {
s.val(cm.getValue()); s.val(cm.getValue());
propertychange(); propertychange();
}) })
}); });
} }