Skip to content
Snippets Groups Projects
panther2d.php 5.96 KiB
Newer Older
Lucio Zambon's avatar
Lucio Zambon committed
<?php
Lucio Zambon's avatar
Lucio Zambon committed
	$local = (isset($_REQUEST['cdn']) || $_SERVER['SERVER_NAME']=='mac3d.elettra.eu')? false: true; // true = use only locally installed modules, false = use cdn
Lucio Zambon's avatar
Lucio Zambon committed
	$machine = empty($_REQUEST['machine'])? 'elettra': strtolower($_REQUEST['machine']);
	$simulator = false;
	if (strpos($machine, 'simulator_')!==false) {$simulator = true; list($trash, $machine) = explode('_', $machine, 2);}
	$l = file_get_contents($simulator? 'http://'.$_SERVER["HTTP_HOST"].strtr($_SERVER["PHP_SELF"], array('panther2d.php'=>'')).'simulator.php?lattice&machine='.$machine: $machine.'_lattice.json');
	$lattice = json_decode($l, true);
	// die(json_encode($lattice));
	$modules = '';
	if (!empty($lattice['conf']['modules'])) foreach ($lattice['conf']['modules'] as $m) {
		$modules .= "		<script type='text/javascript' src='./{$m}2d.js'></script>\n";
	}
Lucio Zambon's avatar
Lucio Zambon committed
?>
Lucio Zambon's avatar
Lucio Zambon committed
<!DOCTYPE html>
<html lang="en">
	<head>
		<title>PAnTHer</title>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
Lucio Zambon's avatar
Lucio Zambon committed
		<link rel="stylesheet" href="<?php echo ($local? '../lib/jquery/jquery-ui.min.css': 'https://code.jquery.com/ui/1.13.3/themes/base/jquery-ui.css');?>">
		<script src="<?php echo ($local? '../lib/jquery/jquery.min.js': 'https://cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js');?>" type="text/javascript"></script>
		<script src="<?php echo ($local? '../lib/jquery/jquery-ui.min.js': 'https://cdn.jsdelivr.net/npm/jquery-ui@1.13.3/dist/jquery-ui.min.js');?>" type="text/javascript"></script>
Lucio Zambon's avatar
Lucio Zambon committed
		<script src="<?php echo ($local? '../lib/node_modules/three/examples/jsm/libs/lil-gui-0.19.min.js': 'https://cdn.jsdelivr.net/npm/lil-gui@0.19.1/dist/lil-gui.umd.min.js');?>" type="text/javascript"></script>
Lucio Zambon's avatar
Lucio Zambon committed
	</head>
	<body style="overflow: hidden; background-color: #333333;">
		<style>
			.vlv {fill: white;}
			.bst {fill: white;}
			.blm {display: none;}
			.lil-gui.autoPlace {z-index: 1 !important;}
		</style>
Lucio Zambon's avatar
Lucio Zambon committed
		<!--div id='pin' style='position:absolute; display:none;'></div-->
Lucio Zambon's avatar
Lucio Zambon committed
		<div id='tooltip' style='position:absolute; display:none;'>
Lucio Zambon's avatar
Lucio Zambon committed
			<div style='width: 490px; background-color: white; padding:5px; border-width: 3px; border-color: blue; border-top-left-radius: 5px; border-top-right-radius: 5px;'><table><tr><td>search in <b>components</b> DB </td><td><span id='compdb'></span></td></tr></table></div>
Lucio Zambon's avatar
Lucio Zambon committed
			<iframe id='tooltipFrame' style="border:0; position:absolute; background:transparent; " width="500px" height="220px" src=''></iframe>
		</div>
Lucio Zambon's avatar
Lucio Zambon committed
		<div id='main' onClick="hideTooltip()">
Lucio Zambon's avatar
Lucio Zambon committed
		<?php
Lucio Zambon's avatar
Lucio Zambon committed
			list($bundle, $trash) = explode('_', $machine, 2);
			if ($simulator) $bundle = 'simulator';
Lucio Zambon's avatar
Lucio Zambon committed
			file_put_contents('./logs2d'.date('Y').'.txt', date('Y-m-d H:i:s').' '.$_SERVER['REMOTE_ADDR'].'_'.$_SERVER['HTTP_X_FORWARDED_FOR'].' - '.$_SERVER['QUERY_STRING'].PHP_EOL , FILE_APPEND | LOCK_EX);
			$f = file_get_contents("./panther_conf.js");
			echo "\n<script>\n".strtr($f, array('export '=>''))."</script>\n";
Lucio Zambon's avatar
Lucio Zambon committed
			$f = file_get_contents("./components/bundle_{$bundle}2d.svg");
Lucio Zambon's avatar
Lucio Zambon committed
			$backgroundColor = isset($_REQUEST['backgroundColor']) && $_REQUEST['backgroundColor']=='black'? 'black': '#333';
Lucio Zambon's avatar
Lucio Zambon committed
			$replace = array('</svg>'=>'    <filter x="0" y="0" width="1" height="1" id="solid">
Lucio Zambon's avatar
Lucio Zambon committed
      <feFlood flood-color="'.$backgroundColor.'" flood-padding="20" result="bg" />
Lucio Zambon's avatar
Lucio Zambon committed
      <feMerge>
        <feMergeNode in="bg"/>
        <feMergeNode in="SourceGraphic"/>
      </feMerge>
    </filter>
</svg>');
			if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox/63') !== false) $replace['fill="url(#Pattern)"']='fill="#a6a4c9"';
			echo strtr($f, $replace);
Lucio Zambon's avatar
Lucio Zambon committed
		?>
		</div>
Lucio Zambon's avatar
Lucio Zambon committed
		<div id='measurement' style='display:none; position:absolute; left:5px; top:5px; max-width:600px; z-index: 10000;'>
			<input id='pos' size='10'> <input id='stright' size='3' style='background-color: yellow;'> <input id='bm' size='3' style='background-color: limegreen;'> <span style='font-size: 80%; background-color: white;padding: 3px;'>[m]</span>
		</div>
Lucio Zambon's avatar
Lucio Zambon committed
		<div id='notice' style='display:<?php echo $_REQUEST['machine']=='elettra2'? 'block': 'none';?>; position:absolute; right:5px; bottom:5px; max-width:600px; z-index: 10000;'>
			Data source <a href='https://drive.elettra.eu/group/268/' target="_blank">https://drive.elettra.eu/group/268/</a>
		</div>
Lucio Zambon's avatar
Lucio Zambon committed
		<div id='application' style='display:none; position:absolute; left:0; top:0; bottom:0; width:340px; max-width:340px; z-index: 10000;'>
			<div id='applicationReference' style='display:none;'>
				<div style='width:100%; padding:5px; color: yellow; margin-top: 3px;'>
					<table>
					<tr><td style="valign: middle; width: 33%">Reference</td>
					<td style="width: 65%"><table><tr><td style="color:red;font-weight: bold;">H</td><td>
					<button id='hor_set' onClick="myreference('hor_set')" style="width: 4em; margin-left:10px;" title="save actual values as reference in local storage"> Set </button>  
					<button onClick="myreference('hor_clear')" style="width: 5em;"> Clear </button></td><tr>
					<tr><td style="color:green;font-weight: bold;">V</td><td><button id='ver_set' onClick="myreference('ver_set')" style="width: 4em; margin-left:10px;" title="save actual values as reference in local storage"> Set </button>  
					<button onClick="myreference('ver_clear')" style="width: 5em;"> Clear </button></td><tr></table></td><tr></table>
				</div>
			</div>
			<iframe id='applicationFrame' style="border:0; position:absolute; width: 100%; height: 800px;" src='' data-src='https://<?php echo $_SERVER['SERVER_NAME'];?>/knob/tunefb.php'></iframe>
		</div>
Lucio Zambon's avatar
Lucio Zambon committed
		<script type="text/javascript" src="./svg-pan-zoom.min.js"></script>
Lucio Zambon's avatar
Lucio Zambon committed
		<!--script type="text/javascript" src="./svg-pan-zoom-rotate.js"></script-->
Lucio Zambon's avatar
Lucio Zambon committed
		<script type="text/javascript" src="<?php echo ($local? '../spa/js/hammer.min.js': 'https://cdnjs.cloudflare.com/ajax/libs/hammer.js/2.0.8/hammer.min.js');?>"></script>
Lucio Zambon's avatar
Lucio Zambon committed
		<script type="text/javascript" src="./blm2d.js"></script>
		<script type="text/javascript" src="./bpm2d.js"></script>
		<script type="text/javascript" src="./panther2d.js"></script>
Lucio Zambon's avatar
Lucio Zambon committed
		<?php echo trim($modules);?>
Lucio Zambon's avatar
Lucio Zambon committed
	</body>
</html>