Added switch to image content

This commit is contained in:
fbsanchez 2016-10-14 11:27:54 +02:00
parent 41b03143a8
commit d0a83b5021
2 changed files with 117 additions and 104 deletions

View File

@ -2062,11 +2062,17 @@ function delete_dir($dir) {
return rmdir($dir);
}
/**
* Returns 1 if the data contains a codified image (base64)
*/
function is_image_data ($data) {
return (substr($data,0,10) == "data:image");
}
/**
* Returns 1 if this is Snapshot data, 0 otherwise
* Looks for two or more carriage returns.
*/
function is_snapshot_data ($data) {
// TODO IDEA: In the future, we can set a variable in setup
@ -2076,7 +2082,7 @@ function is_snapshot_data ($data) {
$temp = array();
$count = preg_match_all ("/\n/", $data, $temp);
if ($count > 2)
if ( ($count > 2) || (is_image_data($data) )
return 1;
else
return 0;

View File

@ -68,11 +68,15 @@ $label = get_parameter ("label");
echo $row["timestamp"];
echo "</h2>";
$datos = io_safe_output($row["datos"]);
$datos = preg_replace ('/\n/i','<br>',$datos);
$datos = preg_replace ('/\s/i','&nbsp;',$datos);
echo "<div id='result_div' style='width: 100%; height: 100%; overflow: scroll; padding: 10px; font-size: 14px; line-height: 16px; font-family: mono,monospace; text-align: left'>";
echo $datos;
echo "</div>";
if (is_image_data($datos)) {
echo '<img src="' . $datos . '" alt="image"/>';
}
else {
$datos = preg_replace ('/\n/i','<br>',$datos);
$datos = preg_replace ('/\s/i','&nbsp;',$datos);
echo "<div id='result_div' style='width: 100%; height: 100%; overflow: scroll; padding: 10px; font-size: 14px; line-height: 16px; font-family: mono,monospace; text-align: left'>";
echo $datos;
echo "</div>";
?>
<script type="text/javascript">
function getScrollbarWidth() {
@ -98,5 +102,8 @@ $label = get_parameter ("label");
$("#result_div").css("height", (height - getScrollbarWidth() - $("#title_snapshot_view").height() - 16) + "px");
});
</script>
<?php
}
?>
</body>
</html>