01_FHEMWEB.pm: add links to the get dialog (Forum #37670)
git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@8667 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -626,13 +626,17 @@ FW_answerCall($)
|
|||||||
if($FW_XHR || $FW_jsonp) {
|
if($FW_XHR || $FW_jsonp) {
|
||||||
$FW_cmdret = $docmd ? FW_fC($cmd, $cmddev) : "";
|
$FW_cmdret = $docmd ? FW_fC($cmd, $cmddev) : "";
|
||||||
$FW_RETTYPE = "text/plain; charset=$FW_encoding";
|
$FW_RETTYPE = "text/plain; charset=$FW_encoding";
|
||||||
|
|
||||||
if($FW_jsonp) {
|
if($FW_jsonp) {
|
||||||
$FW_cmdret =~ s/'/\\'/g;
|
$FW_cmdret =~ s/'/\\'/g;
|
||||||
# Escape newlines in JavaScript string
|
# Escape newlines in JavaScript string
|
||||||
$FW_cmdret =~ s/\n/\\\n/g;
|
$FW_cmdret =~ s/\n/\\\n/g;
|
||||||
FW_pO "$FW_jsonp('$FW_cmdret');";
|
FW_pO "$FW_jsonp('$FW_cmdret');";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
$FW_cmdret = FW_addLinks($FW_cmdret) if($FW_webArgs{addLinks});
|
||||||
FW_pO $FW_cmdret;
|
FW_pO $FW_cmdret;
|
||||||
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -661,7 +665,7 @@ FW_answerCall($)
|
|||||||
if($cmd =~ m/^define +([^ ]+) /) { # "redirect" after define to details
|
if($cmd =~ m/^define +([^ ]+) /) { # "redirect" after define to details
|
||||||
$FW_detail = $1;
|
$FW_detail = $1;
|
||||||
}
|
}
|
||||||
elsif($cmd =~ m/^copy +([^ ]+) +([^ ]+)/) { # "redirect" after define to details
|
elsif($cmd =~ m/^copy +([^ ]+) +([^ ]+)/) { # redirect define to details
|
||||||
$FW_detail = $2;
|
$FW_detail = $2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -770,19 +774,7 @@ FW_answerCall($)
|
|||||||
$FW_cmdret = $1;
|
$FW_cmdret = $1;
|
||||||
|
|
||||||
} else { # "linkify" output (e.g. for list)
|
} else { # "linkify" output (e.g. for list)
|
||||||
$FW_cmdret = FW_htmlEscape($FW_cmdret);
|
$FW_cmdret = FW_addLinks(FW_htmlEscape($FW_cmdret));
|
||||||
|
|
||||||
my @lines = split( /\n/, $FW_cmdret ); # Adding links
|
|
||||||
$FW_cmdret = "";
|
|
||||||
foreach my $line (@lines) {
|
|
||||||
$FW_cmdret .= "\n" if( $FW_cmdret );
|
|
||||||
foreach my $word ( split( / /, $line ) ) {
|
|
||||||
$word = "<a href=\"$FW_ME$FW_subdir?detail=$word$FW_CSRF\">$word</a>"
|
|
||||||
if( $defs{$word} );
|
|
||||||
$FW_cmdret .= "$word ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$FW_cmdret =~ s/:\S+//g if($FW_cmdret =~ m/unknown.*choose one of/i);
|
$FW_cmdret =~ s/:\S+//g if($FW_cmdret =~ m/unknown.*choose one of/i);
|
||||||
$FW_cmdret = "<pre>$FW_cmdret</pre>" if($FW_cmdret =~ m/\n/);
|
$FW_cmdret = "<pre>$FW_cmdret</pre>" if($FW_cmdret =~ m/\n/);
|
||||||
}
|
}
|
||||||
@@ -826,6 +818,22 @@ FW_answerCall($)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
FW_addLinks($)
|
||||||
|
{
|
||||||
|
my @lines = split( /\n/, shift); # Adding links
|
||||||
|
my $ret = "";
|
||||||
|
foreach my $line (@lines) {
|
||||||
|
$ret .= "\n" if( $ret );
|
||||||
|
foreach my $word ( split( / /, $line ) ) {
|
||||||
|
$word = "<a href=\"$FW_ME$FW_subdir?detail=$word$FW_CSRF\">$word</a>"
|
||||||
|
if( $defs{$word} );
|
||||||
|
$ret .= "$word ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
# Digest CGI parameters
|
# Digest CGI parameters
|
||||||
@@ -2615,6 +2623,7 @@ FW_htmlEscape($)
|
|||||||
$txt =~ s/&/&/g;
|
$txt =~ s/&/&/g;
|
||||||
$txt =~ s/</</g;
|
$txt =~ s/</</g;
|
||||||
$txt =~ s/>/>/g;
|
$txt =~ s/>/>/g;
|
||||||
|
$txt =~ s/\n/<br>/g;
|
||||||
return $txt;
|
return $txt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ FW_jqueryReadyFn()
|
|||||||
$(el).parent().find("input,[name]").each(function() {
|
$(el).parent().find("input,[name]").each(function() {
|
||||||
cmd += (cmd?"&":"")+$(this).attr("name")+"="+$(this).val();
|
cmd += (cmd?"&":"")+$(this).attr("name")+"="+$(this).val();
|
||||||
});
|
});
|
||||||
FW_cmd(FW_root+"?"+cmd+"&XHR=1", function(data) {
|
FW_cmd(FW_root+"?"+cmd+"&XHR=1&addLinks=1", function(data) {
|
||||||
FW_okDialog('<pre>'+data+'</pre>', el);
|
FW_okDialog('<pre>'+data+'</pre>', el);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user