Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit feeb9bc

Browse files
committedFeb 29, 2016
Initial Commit
0 parents  commit feeb9bc

File tree

4 files changed

+291
-0
lines changed

4 files changed

+291
-0
lines changed
 

‎app.js

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
app = angular.module("rare_helper_app", [
2+
"ui.bootstrap",
3+
])
4+
5+
app.controller("main", [
6+
"$scope",
7+
"systems",
8+
"$timeout",
9+
10+
11+
function ($scope, systems, $timeout){
12+
$scope.me = {
13+
x: 0.0,
14+
y: 0.0,
15+
z: 0.0,
16+
}
17+
18+
// systems.get_rare_systems($scope.me).then(function (obj){
19+
// $scope.rare_systems = obj;
20+
// });
21+
22+
$scope.$watch("me", function (oldVal, newVal){
23+
// if (oldVal == newVal)
24+
// return;
25+
26+
$scope.recalculate_distances();
27+
}, true);
28+
29+
$scope.recalculate_distances = function (){
30+
systems.get_rare_systems($scope.me).then(function (obj){
31+
$scope.rare_systems = obj;
32+
});
33+
};
34+
35+
36+
37+
38+
}
39+
]);
40+
41+
app.service("rest_data", [
42+
"$http",
43+
function ($http){
44+
var self = this;
45+
self.get_rare_systems = function (){
46+
return $http.get("/rare_systems.csv");
47+
}
48+
}
49+
]);
50+
51+
app.service("systems", [
52+
"rest_data",
53+
"$q",
54+
55+
function (rest_data, $q){
56+
var self = this;
57+
58+
self.get_rare_systems = function (me){
59+
// debugger;
60+
if (typeof self.rare_systems == 'undefined'){
61+
return self._load_rare_systems().then(function (obj){
62+
self.rare_systems = obj;
63+
self.rare_systems = self.calculate_euclidean_distance(me, self.rare_systems);
64+
console.log(obj);
65+
return self.rare_systems;
66+
})
67+
}else {
68+
return $q(function (resolve, reject){
69+
self.rare_systems = self.calculate_euclidean_distance(me, self.rare_systems);
70+
resolve(self.rare_systems);
71+
})
72+
}
73+
};
74+
// This function will calcualte distance
75+
// distance = sqrt((x1-x2)**2 + (y1-y2)**2 + (z1-z2)**2)
76+
self.calculate_euclidean_distance = function (me, obj){
77+
_x2 = parseFloat(me.x);
78+
_y2 = parseFloat(me.y);
79+
_z2 = parseFloat(me.z);
80+
81+
for (var i=0;i<obj.length;i++){
82+
_x1 = parseFloat(obj[i].x);
83+
_y1 = parseFloat(obj[i].y);
84+
_z1 = parseFloat(obj[i].z);
85+
obj[i].distance = Math.sqrt(Math.pow(_x1-_x2, 2)+Math.pow(_y1-_y2, 2)+Math.pow(_z1-_z2, 2))
86+
}
87+
return obj;
88+
};
89+
90+
self._load_rare_systems = function (){
91+
return rest_data.get_rare_systems().then(function (response){
92+
// parse csv
93+
var obj = [];
94+
var lines = response.data.split("\n");
95+
96+
for (var i=0;i<lines.length;i++) {
97+
line = lines[i].split(",");
98+
99+
obj.push({
100+
x: line[0],
101+
y: line[1],
102+
z: line[2],
103+
name: line[3],
104+
})
105+
}
106+
return obj;
107+
});
108+
};
109+
110+
self.init = function (){
111+
112+
};
113+
114+
self.init();
115+
}
116+
]);

‎index.html

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<!DOCTYPE html>
2+
<html ng-app="rare_helper_app">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>ED Rare Trading Helper</title>
6+
<!-- <link rel='stylesheet' href='//fonts.googleapis.com/css?family=font1|font2|etc' type='text/css'> -->
7+
8+
<script src="//yastatic.net/jquery/2.2.0/jquery.js" type="text/javascript"></script>
9+
10+
<script src="//yastatic.net/angularjs/1.4.8/angular.js" type="text/javascript"></script>
11+
<script src="//yastatic.net/bootstrap/3.3.6/js/bootstrap.min.js" type="text/javascript"></script>
12+
<link rel="stylesheet" href="//yastatic.net/bootstrap/3.3.6/css/bootstrap.min.css" type="text/css"></style>
13+
14+
15+
<!-- <script src="//cdnjs.cloudflare.com/ajax/libs/modernizr/2.5.3/modernizr.min.js" type="text/javascript"></script> -->
16+
<script src="app.js" type="text/javascript"></script>
17+
<script src="ui-bootstrap-1.2.1.min.js" type="text/javascript"></script>
18+
<style type="text/css">
19+
20+
</style>
21+
</head>
22+
<body ng-controller="main">
23+
24+
<div>
25+
<input ng-model="me.x" type="number"></input>
26+
<input ng-model="me.y" type="number"></input>
27+
<input ng-model="me.z" type="number"></input>
28+
<button ng-click="recalculate_distances();">Update</button>
29+
</div>
30+
31+
<div style="width: 640px;">
32+
<table class="table table-hover table-bordered">
33+
<thead>
34+
<tr>
35+
<td>X</td>
36+
<td>Y</td>
37+
<td>Z</td>
38+
<td>Name</td>
39+
<td>Distance</td>
40+
</tr>
41+
</thead>
42+
<tbody>
43+
<tr ng-repeat="system in rare_systems | orderBy: 'distance'">
44+
<td>{{ system.x | number: 2}}</td>
45+
<td>{{ system.y | number: 2}}</td>
46+
<td>{{ system.z | number: 2}}</td>
47+
<td>{{ system.name }}</td>
48+
<td>{{ system.distance | number: 2 }}</td>
49+
</tr>
50+
</tbody>
51+
</table>
52+
</div>
53+
54+
</body>
55+
</html>

‎rare_systems.csv

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
-28.72,-35.72,-61.44,LDS 883
2+
-7.03,-12.88,-56.38,Geras
3+
-7.31,-20.28,-50.91,39 Tauri
4+
-6.03,-30.38,-59.03,Fujin
5+
-49.75,-19.03,-45.00,Terra Mater
6+
-34.94,-44.16,-77.34,Momus Reach
7+
-56.00,-25.13,-44.28,Hecate
8+
-13.25,-52.06,-65.88,Witchhaul
9+
-36.47,16.16,-34.94,Bast
10+
-19.81,-3.25,-14.28,Zeessze
11+
-12.09,-16.00,-14.22,George Pantazis
12+
-40.53,4.18,-124.25,Damna
13+
-90.69,8.13,-79.53,Thrutis
14+
-95.22,9.88,-74.13,Uzumoku
15+
19.66,26.84,-38.09,AZ Cancri
16+
-11.03,-79.22,-92.31,Jotun (permit)
17+
3.03,-0.09,3.16,Alpha Centauri
18+
-21.91,8.13,9.00,Vega (permit)
19+
1.69,-77.88,-30.09,Tanmark
20+
-64.75,57.22,-82.63,Rusani
21+
12.47,-66.72,-22.91,Kappa Fornacis
22+
-12.31,-2.75,11.00,Altair
23+
3.13,-8.88,7.13,Epsilon Indi
24+
-45.78,-93.00,-83.91,HIP 10175
25+
-13.13,-81.00,-20.28,Tarach Tor
26+
-22.84,36.53,-1.19,Eranin
27+
46.91,23.63,-59.75,Aegaeon
28+
49.53,15.75,-91.72,Banki
29+
-45.47,18.56,12.59,LFT 1421
30+
-88.75,-76.75,-39.63,Havasupai
31+
-30.03,72.34,-23.81,Ethgreze
32+
-44.94,36.94,13.47,V1090 Herculis
33+
-8.16,74.81,-105.13,HIP 41181
34+
26.28,-51.75,4.63,Chi Eridani
35+
9.53,59.31,-13.22,LP 375-25
36+
-11.56,43.81,11.63,Aganippe
37+
-107.88,29.56,-20.94,Esuseku
38+
10.50,-34.78,25.06,Tiolce
39+
-19.81,-35.38,34.00,Xihe
40+
-14.13,-116.97,-32.53,47 Ceti
41+
-14.13,-116.97,-32.53,47 Ceti
42+
6.25,-5.78,35.94,Mulachi
43+
67.03,39.59,-70.09,Mechucos
44+
-0.16,-102.75,-5.56,Utgaroar
45+
75.44,2.63,-30.88,Neritus
46+
-142.03,-13.34,-43.91,Haiden
47+
5.19,84.53,-16.75,Cherbones
48+
12.78,4.81,39.34,Medb
49+
-77.28,-57.437,30.53,Alya
50+
-126.09,-83.09,-85.56,Wulpa
51+
-12.16,62.63,29.72,Dea Motrona
52+
-139.06,-2.31,-6.66,Ochoeng
53+
-104.16,82.72,-32.38,Kongga
54+
52.09,-112.09,-40.78,Quechua
55+
55.72,17.59,27.16,Shinrarta Dezhra (permit)
56+
20.75,-82.25,33.59,Coquim
57+
-105.38,-73.34,27.75,Kachirigin
58+
-122.78,-102.53,-22.56,Nguna
59+
81.63,-94.88,-58.56,Belalans
60+
73.44,58.34,-0.22,Mokojing
61+
39.53,21.28,56.63,Jaradharre
62+
36.53,100.06,-135.72,Volkhab
63+
104.97,-6.53,-4.41,Arouca
64+
-101.59,93.78,9.91,HIP 80364
65+
67.88,-21.50,51.16,CD-75 661
66+
44.28,-82.97,52.50,Phiagre
67+
-23.19,80.03,61.84,Helvetitj
68+
-123.88,-81.59,45.19,Kamorin
69+
81.03,52.84,31.50,Korro Kung
70+
85.16,-56.31,40.34,Baltah'Sine
71+
53.91,-130.69,14.66,Delta Phoenicis
72+
-76.97,71.91,69.19,Heike
73+
-50.94,90.22,65.81,Vidavanta
74+
137.31,3.84,-35.91,Deuringas
75+
-147.47,-64.13,46.09,Mukusubii
76+
100.75,-102.63,8.41,Aerial
77+
125.66,-1.72,14.09,Any Na
78+
-88.50,-12.31,98.84,Vanayequi
79+
4.94,-175.91,-0.91,Yaso Kondi
80+
-29.66,32.69,104.84,Eleu
81+
72.75,48.75,68.25,Leesti
82+
72.75,48.75,68.25,Leesti
83+
58.69,-170.97,-41.97,Holva
84+
72.16,48.75,70.75,Diso
85+
-125.59,44.03,78.41,Karetii
86+
68.84,48.75,74.75,Uszaa
87+
-32.41,169.53,-49.44,Alacarakmo
88+
75.75,48.75,70.75,Lave
89+
68.84,48.75,76.75,Orrere
90+
-96.94,143.44,4.63,Rajukru
91+
58.53,-55.81,91.25,HR 7221
92+
80.75,48.75,69.25,Zaonce
93+
124.63,2.5,61.25,Anduliga
94+
94.16,-167.38,-23.19,Rapa Bao
95+
122.97,-9.06,69.00,HIP 59533
96+
62.75,-74.19,109.50,Ngadandari
97+
68.31,-190.03,12.38,Wuthielo Ku
98+
5.53,-183.41,63.84,Kamitra
99+
-67.41,-7.41,150.06,Kinago
100+
155.09,-12.41,61.06,Toxandji
101+
157.53,-110.53,28.25,Jaroua
102+
140.72,-96.97,67.78,Irukama
103+
8.88,-205.44,64.38,Njangari
104+
153.44,61.44,79.03,Sanuma
105+
22.50,23.78,171.06,Geawen
106+
169.50,-42.34,87.06,Ngurii
107+
150.88,-173.78,25.28,Goman
108+
134.03,-163.59,71.06,Karsuki Ti
109+
120.78,-247.19,-16.44,Eshu
110+
145.13,-140.06,131.97,Wheemete

‎ui-bootstrap-1.2.1.min.js

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.