Menu enhancements and added find feature
This commit is contained in:
parent
f59191b770
commit
4d33d22e91
@ -1,14 +1,58 @@
|
||||
$(document).ready(function() {
|
||||
// Controls menu hide/show
|
||||
$('#hotdog').click(function(){
|
||||
$('#controls').toggleClass("active");
|
||||
});
|
||||
|
||||
// Reset view
|
||||
$('.reset-container').click(function(){ reset_view(); });
|
||||
$('#submitfindbyname').click( function() {
|
||||
var selected = $('#findbyselect option:selected').text();
|
||||
zoomfocus(selected);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function populateUserFields() {
|
||||
//Populate find by select dropdown
|
||||
var types = [];
|
||||
var checkboxes = document.getElementsByName("objtype");
|
||||
for (var type in checkboxes) {
|
||||
if(checkboxes[type].checked) {
|
||||
types[type] = checkboxes[type].value;
|
||||
}
|
||||
|
||||
}
|
||||
var option = '';
|
||||
for (var type in types){
|
||||
for ( var key in listobjects(types[type]) ){
|
||||
option += '<option value="'+ escapeHTML(key) + '">' + escapeHTML(key) + '</option>';
|
||||
}
|
||||
}
|
||||
|
||||
$('#findbyselect').html(option);
|
||||
}
|
||||
|
||||
function openTab(evt,tabName) {
|
||||
var i, x, tablinks;
|
||||
x = document.getElementsByClassName("tools");
|
||||
x = document.getElementsByClassName("wvg-tools");
|
||||
for (i = 0; i < x.length; i++) {
|
||||
x[i].style.display = "none";
|
||||
}
|
||||
tablinks = document.getElementsByClassName("tablink");
|
||||
tablinks = document.getElementsByClassName("wvg-tablink");
|
||||
for (i = 0; i < x.length; i++) {
|
||||
tablinks[i].className = tablinks[i].className.replace(" tab-active", "");
|
||||
tablinks[i].className = tablinks[i].className.replace(" wvg-tab-active", "");
|
||||
}
|
||||
document.getElementById(tabName).style.display = "block";
|
||||
evt.currentTarget.className += " tab-active";
|
||||
evt.currentTarget.className += " wvg-tab-active";
|
||||
}
|
||||
|
||||
function escapeHTML(text)
|
||||
{
|
||||
var chr = { '"': '"', '&': '&', '<': '[', '>': ']' };
|
||||
function abc(a)
|
||||
{
|
||||
return chr[a];
|
||||
}
|
||||
return text.replace(/[\"&<>]/g, abc);
|
||||
}
|
||||
|
@ -176,4 +176,41 @@ function render () {
|
||||
}
|
||||
|
||||
|
||||
function listobjects(type) {
|
||||
var objects = {};
|
||||
|
||||
for (var key in jsonEmpire) {
|
||||
area=jsonEmpire[key];
|
||||
for (var key2 in area[type]) {
|
||||
object = area[type][key2];
|
||||
objectname = object.name;
|
||||
objects[object.name] = object;
|
||||
|
||||
}
|
||||
}
|
||||
return objects;
|
||||
}
|
||||
|
||||
function zoomfocus(name) {
|
||||
|
||||
var types = ['planets','stations'];
|
||||
for (var type in types){
|
||||
var objects = listobjects(types[type]);
|
||||
for ( var key in objects ) {
|
||||
if (escapeHTML(key) == name) {
|
||||
var object = objects[key];
|
||||
controls.target.x = object.x;
|
||||
controls.target.y = object.y;
|
||||
controls.target.z = object.z;
|
||||
var focus = new THREE.Vector3( object.x, object.y, object.z );
|
||||
var vantage = new THREE.Vector3( 5, 60 , 150 );
|
||||
focus.add(vantage);
|
||||
camera.position.set(focus.x,focus.y,focus.z);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
118
webviewgl.htm
118
webviewgl.htm
@ -1,42 +1,116 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<script src="js/three.js"></script>
|
||||
<script src="js/OrbitControls.js"></script>
|
||||
<script src="js/three-text2d.js"></script>
|
||||
<script src="js/Detector.js"></script>
|
||||
<script src="js/mapviewgl.js"></script>
|
||||
<script src="js/GUI.Utils.js"></script>
|
||||
<link href="https://fonts.googleapis.com/css?family=Space+Mono" rel="stylesheet">
|
||||
<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s=" crossorigin="anonymous"></script>
|
||||
<script src="js/GUI.Utils.js"></script>
|
||||
<style type="text/css">
|
||||
body { margin: 0; }
|
||||
canvas { width: 75%; height: 100% ; }
|
||||
.reset-button {margin: 0; padding: 0; padding: 5px 5px; color: #67988A; }
|
||||
.reset-container { margin: 0; padding: 0; padding: 8px 10px; font-weight: bold; text-align: center; font-family: 'Space Mono', monospace; color:#67989A; float; right; width: auto; height: 100%; }
|
||||
#controls { position: fixed; left: 85%; height: 96%; width: 15%; background-color: #FFF; margin-top: 1%; }
|
||||
ul.navbar { height: 3vh; width: 100%; background-color: #003133; list-style-type: none; overflow: hidden; padding: 0; margin: 0; }
|
||||
ul.navbar li { width:auto; height: 100%; float: left; } .tablink { margin: 0; padding: 0; padding: 8px 10px; font-weight: bold; text-align: center; font-family: 'Space Mono', monospace; color:#67989A; }
|
||||
.tab-active { background-color: #0D4A4D; color: #003133; }
|
||||
div.tools { width: 100%; height: 98%; background: #333; display: none; }
|
||||
div.first { display: block; }
|
||||
body { margin: 0; overflow:hidden;}
|
||||
canvas { width: 75%; height: 100% ;}
|
||||
.reset-button {margin: 0; padding: 0; padding: 5px 5px; color: #AAA; }
|
||||
.menu-button { float: right; position: absolute; right: 0.1vw; top: 0; z-index: 5; color:white; background-color:#003133; padding: 0px; font-weight: bold; font-size:2.5vh; }
|
||||
.reset-container { margin: 0; padding: 0; padding: 8px; font-weight: bold; text-align: center; font-family: 'Space Mono', monospace; color:#67989A; background-color: maroon; width: 100%; height: 2vh; float:bottom; }
|
||||
.wvg-controls { position: fixed; left: 85%; height: 96%; width: 15%; margin-top: 0; display: none;}
|
||||
ul.wvg-navbar { height: 3vh; width: 100%; background-color: #003133; list-style-type: none; overflow: hidden; padding: 0; margin: 0; }
|
||||
ul.wvg-navbar li { width:auto; height: 100%; float: left; } .wvg-tablink { margin: 0; padding: 0; padding: 8px 10px; font-weight: bold; text-align: center; font-family: 'Space Mono', monospace; color:#67989A; }
|
||||
.wvg-tab-active { background-color: #0D4A4D; color: #003133; }
|
||||
.wvg-tools { width: 100%; height: 98%; background: #333; display: none; color: #AAA; padding-top: 2vh; padding-left:1vw; padding-right: 2.5vw;}
|
||||
.wvg-tools select {
|
||||
width: 75%;
|
||||
padding: 5px;
|
||||
font-size: 16px;
|
||||
line-height: 1;
|
||||
border: 1px solid #67878A;
|
||||
border-radius: 0;
|
||||
height: auto;
|
||||
-webkit-appearance: none;
|
||||
background: url('assets/select-arrow.png') no-repeat right center #333;
|
||||
color: #67989A;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.wvg-tools span { text-align: center; color: #FFF; font-family: 'Space Mono', monospace; margin: 0 auto;}
|
||||
.wvg-first { display: block; }
|
||||
#wrapper { height: inherit; width: 100%; }
|
||||
.active { display: block; }
|
||||
input[type=radio], input[type=checkbox] {
|
||||
display:none;
|
||||
}
|
||||
input[type=checkbox] + label:before {
|
||||
content: "";
|
||||
display: inline-block;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
vertical-align:middle;
|
||||
margin-right: 8px;
|
||||
background-color: #aaa;
|
||||
box-shadow: inset 0px 2px 2px rgba(0, 0, 0, .3);
|
||||
border-radius: 4px;
|
||||
}
|
||||
input[type=radio]:checked + label:before {
|
||||
content: "\2022"; /* Bullet */
|
||||
color:white;
|
||||
background-color: #666;
|
||||
font-size:1.8em;
|
||||
text-align:center;
|
||||
line-height:14px;
|
||||
text-shadow:0px 0px 3px #eee;
|
||||
}
|
||||
input[type=checkbox]:checked + label:before {
|
||||
content:"\2714"; /* Tick */
|
||||
color:white;
|
||||
background-color: #666;
|
||||
text-align:center;
|
||||
line-height:15px;
|
||||
text-shadow:0px 0px 3px #eee;
|
||||
}
|
||||
.btn {
|
||||
background: #67989A;
|
||||
-webkit-border-radius: 0;
|
||||
-moz-border-radius: 0;
|
||||
border-radius: 0px;
|
||||
font-family: 'Space Mono', monospace;
|
||||
color: #003133;
|
||||
font-size: 14px;
|
||||
width: 75%;
|
||||
height: 4vh;
|
||||
padding: 3px;
|
||||
border: solid #67878A 1px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
background: #0D4A4D;
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container"></div>
|
||||
<!-- <div id="reset-button" onClick="reset_view();"> Reset </div> -->
|
||||
<div id="controls">
|
||||
<ul class="navbar">
|
||||
<li><a class="tablink tab-active" href='#' onclick="openTab(event,'Find');">Find</a></li>
|
||||
<li><a class="tablink" href='#' onclick="openTab(event,'Info');">Info</a></li>
|
||||
<li class="reset-container"><a class="reset-button" href="#" onclick="reset_view();">Reset</a></li>
|
||||
<div class="menu-button" id="hotdog"> ☰ </div>
|
||||
<div id="controls" class="wvg-controls active">
|
||||
<div id="wrapper">
|
||||
<ul class="wvg-navbar">
|
||||
<li><a class="wvg-tablink wvg-tab-active" href='#' onclick="openTab(event,'Find');">Find</a></li>
|
||||
<li><a class="wvg-tablink" href='#' onclick="openTab(event,'Info');">Info</a></li>
|
||||
</ul>
|
||||
<div class="tools first" id="Find">
|
||||
Arg!
|
||||
<div class="wvg-tools wvg-first" id="Find">
|
||||
<span> Find Object By Name </span>
|
||||
<span> <select id="findbyselect">
|
||||
<option value=''></option>
|
||||
</select> </span>
|
||||
<br/ ><input type="checkbox" name="objtype" id="cbp" value="planets" onclick="populateUserFields();"><label for="cbp"> Planets</label> <input type="checkbox" name="objtype" id="cbs" value="stations" onclick="populateUserFields();"> <label for="cbs">Stations</label>
|
||||
<br><button id="submitfindbyname" class="btn">Find</button>
|
||||
</div>
|
||||
<div class="tools" id="Info">
|
||||
Info
|
||||
|
||||
<div class="wvg-tools" id="Info">
|
||||
<span> This tool was designed by Frey @ ATSMUSH. It is based on MapView for ATS with data used from the Navcomp MUSHClient plugin with permission. </span>
|
||||
</div>
|
||||
</div> <div class="reset-container"><span class="reset-button"> Reset </span></div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
|
Loading…
Reference in New Issue
Block a user