Newer
Older
$local = (isset($_REQUEST['cdn']) || $_SERVER['SERVER_NAME']=='mac3d.elettra.eu')? false: true; // true = use only locally installed modules, false = use cdn
$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('panther.php'=>'', 'index.php'=>'')).'simulator.php?lattice&machine='.$machine: $machine.'_lattice.json');
$lattice = json_decode($l, true);
$modules = '';
if (!empty($lattice['conf']['modules'])) foreach ($lattice['conf']['modules'] as $m) {
$modules .= ",\n \"$m\": \"./$m.js\"";
}
$mode = isset($_REQUEST['fast'])? 'fast': (isset($_REQUEST['premium'])? 'premium': (isset($_REQUEST['plus'])? 'plus': ''));
$threejs = empty($_REQUEST['threejs'])? 'threejs': 'threejs'.$_REQUEST['threejs'];
file_put_contents('./logs'.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);
?>
<!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">
<!--
Firefox seems to not like having scripts that come in before the importmap
https://discourse.threejs.org/t/solved-importmaps-broken-on-firefox-which-now-supports-importmaps/48413/5
-->
<script type="importmap">
{
"imports": {
"three": "<?php echo ($local? "./$threejs": 'https://cdn.jsdelivr.net/npm/three@0.161.0/build');?>/three.module.js",
"three/addons/": "<?php echo ($local? "./$threejs/": 'https://cdn.jsdelivr.net/npm/three@0.161.0/examples/jsm/');?>",
"bundle": "./components/bundle_<?php echo $simulator? 'simulator': $machine.$mode;?>.js"<?php echo $modules;?>
}
}
</script>
<style>
body {
background-color: #333333;
color: #000;
margin: 0px;
}
a {
color: #f00;
}
#c {
width: 100%;
height: 100%;
display: block;
}
.blm {
display: none;
}
.blmVal {
background-color: white;
padding: 2px;
color: black;
border-radius: 5px;
}
</style>
<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>
<script>;
const client = '<?php echo gethostbyaddr($_SERVER['REMOTE_ADDR']);?>'.split('.')[0];
const fermi = ['do','re','mi','fa','sol','la','si'].indexOf(client)>-1 && document.location.search.indexOf('machine=elettra')==-1? '?machine=fermi': '';
if (navigator.userAgent.indexOf('Firefox/63')>-1) {
document.location = './ff63/'+fermi;
}
if (document.location.pathname.indexOf('ff63')>-1) {
$('#tooltip').css('left', '5px');
$('#tooltip').css('top', '5px');
}
</script>
</head>
<body style="overflow: hidden;">
<canvas id="c" style="margin-top: -15px;"></canvas>
<div id="demo" style="position: absolute; display: none; top: 0px; right: -8px; z-index: 10000;" <?php
if ($_REQUEST['machine']=='elettra2') echo 'title="click me for Lattice source" onClick="document.location=\'https://drive.elettra.eu/group/268/\';"'; ?>>
<svg width="150px" height="150px" viewBox="0 0 100 100" class="icon" version="1.1" xmlns="http://www.w3.org/2000/svg">
<path d="M0 0 h70 l30 30 v70 z" stroke="black" stroke-width="2" fill="red"></path>
<text transform="rotate(45)" x="43" y="-30" font-weight="bold" fill="white">DEMO</text>
<text transform="rotate(45)" x="14" y="-6" font-size="70%" fill="white"> all numbers are random</text>
</svg>
</div>
<script type="module" src="./panther<?php echo empty($_REQUEST['threejs'])? '': $_REQUEST['threejs'];?>.js"></script>
<div id='tooltip' style='position:absolute; display:none; z-index: 100000000;'>
<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;'><button id='compdb'>find component <span id='compname'/> on components DB</button></div>
<iframe id='tooltipFrame' style="border:0; position:absolute; background:transparent; " width="240px" height="220px" src=''></iframe>
</div>
<div id='application' style='display:none; position:absolute; left:0; top:0; bottom:0; width:340px; max-width:340px; z-index: 10000;'>
<iframe id='applicationFrame' style="border:0; position:absolute; width: 100%; height: 800px;" src='' data-src="https://puma-01.elettra.eu/knob/tunefb.php"></iframe>
</div>
<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/'>https://drive.elettra.eu/group/268/</a>
</div>
</body>