diff --git a/.meteor/.gitignore b/.meteor/.gitignore
index 4083037..08150d0 100644
--- a/.meteor/.gitignore
+++ b/.meteor/.gitignore
@@ -1 +1,2 @@
local
+meteorite
diff --git a/.meteor/packages b/.meteor/packages
index f95eb97..8ee92a9 100644
--- a/.meteor/packages
+++ b/.meteor/packages
@@ -11,3 +11,5 @@ stylus
accounts-google
underscore
accounts-ui
+jquery-ui
+jquery-ui-bootstrap
diff --git a/.meteor/release b/.meteor/release
new file mode 100644
index 0000000..af7f6f3
--- /dev/null
+++ b/.meteor/release
@@ -0,0 +1 @@
+0.6.2.1
diff --git a/bicyclesim.js b/bicyclesim.js
index e6d9125..cd9254c 100644
--- a/bicyclesim.js
+++ b/bicyclesim.js
@@ -1,5 +1,5 @@
-var Routes = new Meteor.Collection('routes');
-var Points = new Meteor.Collection('points');
+Routes = new Meteor.Collection('routes');
+Points = new Meteor.Collection('points');
Routes.allow({
insert: function (userId, doc) {
diff --git a/client/bicyclesim-meteor.html b/client/bicyclesim-meteor.html
index bc76884..a6687a6 100644
--- a/client/bicyclesim-meteor.html
+++ b/client/bicyclesim-meteor.html
@@ -16,6 +16,7 @@
{{/if}}
{{#if sim}}
{{> sim}}
+
{{/if}}
{{#if frontpage}}
{{> frontpage}}
@@ -165,20 +166,9 @@
- {{km distance}} km
- {{kmh speed}} km/h
-
-
- {{distance}} km
-
-
- {{speed}} km/h
-
-
- {{calories}} cal
-
-
Points
diff --git a/client/bicyclesim-meteor.styl b/client/bicyclesim-meteor.styl
index 6874fe9..53c4861 100644
--- a/client/bicyclesim-meteor.styl
+++ b/client/bicyclesim-meteor.styl
@@ -115,17 +115,16 @@ a.thumbnail
height 250px
left 0
top 0
- opacity 0.8
- display none
+ opacity 0.0
.street
- filter(blur(4px))
+ // filter(blur(4px))
.show-map
.street
- filter(blur(0))
+ // filter(blur(0))
.map
- display block
+ opacity 0.8
.show-sidebar
.street, .map
@@ -138,7 +137,7 @@ a.thumbnail
bottom 42px
left 0
right 0
- background rgba(0, 0, 0, 0.5)
+ // background rgba(0, 0, 0, 0.5)
padding-top 30px
overflow-y auto
@@ -186,6 +185,13 @@ ol.points
font-weight bold
line-height 150%
+.speedSliderContainer
+ position absolute
+ bottom 100px
+ right 20px
+ .speedSlider
+ height 200px
+
::-webkit-scrollbar
background transparent
border none
diff --git a/client/edit.js b/client/edit.js
index b6f4095..be82906 100644
--- a/client/edit.js
+++ b/client/edit.js
@@ -118,14 +118,14 @@ Template.editing.owner = function () {
return user.profile.name;
};
-function init_edit() {
+init_edit = function init_edit() {
Meteor.autorun(function () {
if (Session.equals('page', 'edit') && Session.get('route')) {
debug('sivu tai route vaihtui, route: ' + Session.get('route'));
full_clear_required = true;
- Meteor.deps.isolate(function () {
+ Deps.nonreactive(function () {
var route = Routes.findOne({_id: Session.get('route')});
if (route) {
maps.travel(route.first, {route: true});
@@ -141,7 +141,7 @@ Meteor.autosubscribe(function () {
if (Session.equals('page', 'edit') && Session.get('route')) {
if (full_clear_required) {
- Meteor.deps.isolate(function () {
+ Deps.nonreactive(function () {
debug('full clear');
maps.lines.route.clear();
diff --git a/client/lib/helpers.js b/client/lib/helpers.js
index a1e13bc..569c2ac 100644
--- a/client/lib/helpers.js
+++ b/client/lib/helpers.js
@@ -10,12 +10,12 @@ helpers = {
}
};
-var activateInput = function (input) {
+activateInput = function (input) {
input.focus();
input.select();
};
-var okCancelEvents = function (selector, callbacks) {
+okCancelEvents = function (selector, callbacks) {
var ok = callbacks.ok || function () {};
var cancel = callbacks.cancel || function () {};
@@ -38,9 +38,3 @@ var okCancelEvents = function (selector, callbacks) {
};
return events;
};
-
-// From: https://github.com/tmeasday/meteor-deps-extensions
-Meteor.deps.isolate = function(fn) {
- var context = new Meteor.deps.Context();
- return context.run(fn);
-};
diff --git a/client/lib/maps.js b/client/lib/maps.js
index d0c86ee..b707ee5 100644
--- a/client/lib/maps.js
+++ b/client/lib/maps.js
@@ -1,4 +1,4 @@
-function maps_loaded() {
+maps_loaded = function maps_loaded() {
window.markers = []; // fuu
@@ -153,7 +153,7 @@ var Maps = function () {
var point = Points.findOne({_id: point_id});
if (point) {
- street.setPosition(glatlng(point.latlng));
+ street.setPosition(glatlng(point.latlng));
map.setCenter(glatlng(point.latlng));
if (point.heading) street.setPov({zoom: 1, pitch: 0, heading: point.heading});
@@ -170,7 +170,7 @@ $(document).ready(function () {
init_edit();
});
-}
+};
window.onload = function () {
var script = document.createElement("script");
diff --git a/client/main.js b/client/main.js
index 50e73ac..c10fcdf 100644
--- a/client/main.js
+++ b/client/main.js
@@ -164,7 +164,7 @@ Meteor.startup(function () {
Backbone.history.start({pushState: true});
});
-function init_main() {
+init_main = function init_main() {
Meteor.autosubscribe(function () {
// When changing page
@@ -182,4 +182,4 @@ function init_main() {
maps.mode('sim');
}
});
-}
+};
diff --git a/client/main.sim.js b/client/main.sim.js
index 0775842..6191371 100644
--- a/client/main.sim.js
+++ b/client/main.sim.js
@@ -1,30 +1,11 @@
window.point = null;
window.traveled = 0;
-var createRingBuffer = function (length){
- var pointer = 0, buffer = [], sum = 0;
+function move () {
+ if (!window.point) return;
- return {
- push: function (item) {
- if (buffer[pointer] > 0) {
- sum -= buffer[pointer];
- if (sum <= 0) sum = 0;
- }
- buffer[pointer] = item;
- sum += item;
- pointer = (length + pointer + 1) % length;
- },
- sum: function () {
- return sum;
- }
- };
-};
-
-var revs = 0;
-$(document).bind('keydown.space', function () {
- revs += 1;
-
- var dist = localStorage['multiplier'] * c();
+ // var dist = localStorage['multiplier'] * c();
+ var dist = localStorage['multiplier'] * 0.1 * Session.get('speed');
Session.set('distance', Session.get('distance') + dist);
window.traveled += dist;
@@ -39,22 +20,23 @@ $(document).bind('keydown.space', function () {
window.point = next;
}
}
+}
+
+setInterval(move, 100);
+
+var line = '';
+$(document).on('keydown', function (e) {
+ if (e.keyCode === 13) { // enter
+ if (line.length >= 1 && line[0] == 'S') {
+ var speed = Number(line.slice(1));
+ Session.set('speed', speed);
+ }
+ line = '';
+ } else {
+ line += String.fromCharCode(e.keyCode);
+ }
});
-// function speedo() {
-// speed_buffer.push(revs * c());
-// revs = 0;
-
-// Session.set('speed', speed_buffer.sum() / 5);
-// }
-
-// setInterval(speedo, 500);
-
-// 5sec, 2 values / sec.
-var speed_buffer = createRingBuffer(5 * 2);
-var speed_sum = 0;
-var speed_avg = 0;
-
Template.sim.speed = function () {
return Session.get('speed');
};
@@ -72,47 +54,7 @@ Template.sim.helpers({
}
});
-var sock = new SockJS("http://localhost:9999/speed");
-
-function init_sim() {
-
-
-sock.onopen = function() {
- console.log('open');
-};
-
-sock.onmessage = function(e) {
- if (Session.equals('page', 'sim') && window.point) {
- debug('message', e.data);
-
- var dist = parseInt(e.data, 10) * c();
- speed_buffer.push(dist);
-
- Session.set('speed', speed_buffer.sum() / 5);
-
- Session.set('distance', Session.get('distance') + 3 * dist);
- window.traveled += 3 * dist;
-
- if (window.traveled >= window.point.distance) {
- var next = Points.findOne({_id: window.point.next});
-
- // Stay on current point if no next point exists
- if (next) {
- window.traveled -= next.distance;
-
- maps.travel(next._id, {route: true});
- zoom = 1;
- zoom_target = 1;
- window.point = next;
- }
- }
- }
-
-};
-
-sock.onclose = function() {
- console.log('close');
-};
+init_sim = function init_sim() {
Meteor.autosubscribe(function () {
if (Session.equals('page', 'sim')) {
@@ -135,7 +77,18 @@ Meteor.autosubscribe(function () {
p = Points.findOne({_id: p.next});
}
}
+
+ $('.speedSlider').slider({
+ orientation: 'vertical',
+ range: 'min',
+ min: 0,
+ max: 22.2, // m/s
+ value: 0,
+ slide: function (event, ui) {
+ Session.set('speed', ui.value);
+ }
+ });
}
});
-}
+};
diff --git a/server/lib/maps.js b/server/lib/maps.js
index 9c55c45..a0660d5 100644
--- a/server/lib/maps.js
+++ b/server/lib/maps.js
@@ -15,13 +15,13 @@ if (typeof Number.prototype.toDeg == 'undefined') {
};
}
-function computeDistance(from, to) {
+computeDistance = function computeDistance(from, to) {
// Equirectangular approximation, should be enough as distances are small
var R = 6371000; // km
var x = (to[1].toRad() - from[1].toRad()) * Math.cos((from[0].toRad() + to[0].toRad()) / 2);
var y = (from[0].toRad() - to[0].toRad());
return Math.sqrt(x * x + y * y) * R;
-}
+};
function computeInitialBearing(from, to) {
var dLat = (to[0] - from[0]).toRad();
@@ -34,12 +34,12 @@ function computeInitialBearing(from, to) {
return (Math.atan2(y, x).toDeg() + 360) % 360;
}
-function computeFinalBearing(from, to) {
+computeFinalBearing = function computeFinalBearing(from, to) {
return (computeInitialBearing(to, from) + 180) % 360;
-}
+};
// Rest are copied from: https://github.com/moshen/node-googlemaps/blob/master/lib/googlemaps.js
-function createEncodedPolyline(points) {
+createEncodedPolyline = function createEncodedPolyline(points) {
// Dear maintainer:
//
// Once you are done trying to 'optimize' this routine,
@@ -70,7 +70,7 @@ function createEncodedPolyline(points) {
encoded_points += encodeSignedNumber(dlat) + encodeSignedNumber(dlng);
}
return encoded_points;
-}
+};
function encodeNumber(num) {
var encodeString = "";
diff --git a/smart.json b/smart.json
new file mode 100644
index 0000000..b34943f
--- /dev/null
+++ b/smart.json
@@ -0,0 +1,6 @@
+{
+ "packages": {
+ "jquery-ui": {},
+ "jquery-ui-bootstrap": {}
+ }
+}
diff --git a/smart.lock b/smart.lock
new file mode 100644
index 0000000..9f3cd21
--- /dev/null
+++ b/smart.lock
@@ -0,0 +1,25 @@
+{
+ "meteor": {
+ "git": "https://github.com/meteor/meteor.git",
+ "branch": "master",
+ "commit": "bfe4b72ebec4367eaddcdf0887fcf5e649d9dcb8"
+ },
+ "dependencies": {
+ "basePackages": {
+ "jquery-ui": {},
+ "jquery-ui-bootstrap": {}
+ },
+ "packages": {
+ "jquery-ui": {
+ "git": "https://github.com/TimHeckel/meteor-jquery-ui.git",
+ "tag": "v1.9.2",
+ "commit": "c437d45edcf1367df8d5ffa8bad2867758030bd2"
+ },
+ "jquery-ui-bootstrap": {
+ "git": "https://github.com/TimHeckel/meteor-jquery-ui-bootstrap.git",
+ "tag": "v0.1.2",
+ "commit": "fa742a85639307003e105898e15b631394b63509"
+ }
+ }
+ }
+}