node.js - Possible to evaluate an if block to more than just true or false in meteor -


i have helper function meteor template , ideally have 3 different outcomes appear. 1 correct outcome inccorect outcome , 1 if user denies access browser access location, see below:

template.header.created = function() { navigator.geolocation.getcurrentposition(success_callback,error_callback);  function success_callback(p){     // building latitude = 51.522206     // building longitude = -0.078305     var lat = parsefloat(p.coords.latitude);     var lon = parsefloat(p.coords.longitude);    if( lat >= 51.521606 && lat <= 51.522606 && lon >= -0.078805  && lon <=  -0.077705 ) {     session.set("locationcheck",true);   } else {     session.set("locationcheck",false);   } }  function error_callback(p){      session.set("locationcheck",false); } } 

as can see depends on whether callback successful or not.

if trying pass more boolean logic function, should use string or number return. can acheived by:

template.header.created = function() { navigator.geolocation.getcurrentposition(success_callback,error_callback);  function success_callback(p){ // building latitude = 51.522206 // building longitude = -0.078305 var lat = parsefloat(p.coords.latitude); var lon = parsefloat(p.coords.longitude);  if( lat >= 51.521606 && lat <= 51.522606 && lon >= -0.078805  && lon <=  -0.077705 ) { session.set("locationcheck",0); } else { session.set("locationcheck",1); } }  function error_callback(p){  session.set("locationcheck",2); } } 

and work there.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -