Stom moving after leaving sim page.

This commit is contained in:
Juho Teperi
2013-05-07 12:22:13 +03:00
parent 55cc20ec96
commit 9c414d8389
4 changed files with 10 additions and 8 deletions

View File

@@ -129,7 +129,7 @@ Template.editing.owner = function () {
return user.profile.name;
};
init_edit = function init_edit() {
window.init_edit = function init_edit() {
Meteor.autorun(function () {
if (Session.equals('page', 'edit') && Session.get('route')) {

View File

@@ -1,4 +1,4 @@
maps_loaded = function maps_loaded() {
window.maps_loaded = function maps_loaded() {
window.markers = []; // fuu

View File

@@ -161,7 +161,7 @@ Meteor.startup(function () {
Backbone.history.start({pushState: true});
});
init_main = function init_main() {
window.init_main = function init_main() {
Meteor.autosubscribe(function () {
// When changing page

View File

@@ -2,8 +2,6 @@ window.point = null;
window.traveled = 0;
function move () {
if (!window.point) return;
// var dist = localStorage['multiplier'] * c();
var dist = localStorage['multiplier'] * 0.1 * Session.get('speed');
Session.set('distance', Session.get('distance') + dist);
@@ -22,14 +20,13 @@ function move () {
}
}
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);
$('.speedSlider').slider('value', speed);
}
line = '';
} else {
@@ -54,8 +51,9 @@ Template.sim.helpers({
}
});
init_sim = function init_sim() {
window.init_sim = function init_sim() {
var i;
Meteor.autosubscribe(function () {
if (Session.equals('page', 'sim')) {
var route = Routes.findOne({_id: Session.get('route')});
@@ -76,6 +74,8 @@ Meteor.autosubscribe(function () {
maps.lines.route.add(p.latlng);
p = Points.findOne({_id: p.next});
}
i = setInterval(move, 100);
}
$('.speedSlider').slider({
@@ -88,6 +88,8 @@ Meteor.autosubscribe(function () {
Session.set('speed', ui.value);
}
});
} else {
i = clearInterval(i);
}
});