map_coordinates = function(obj){ var g,l,t,s,v,h,rv, //size = 91.14378277661477, //side = 50, left_h = 46.48512749037782, top_h = 39.8443949917523, left_step_h = 69.585127490378, top_step_h = 39.84439499, left_v = 37.5992809922301, top_v = 43.8658278242683, left_step_v = 37.5992809922301, top_step_v = 66.9658278242677; if(!_.has(obj,'remove') && !_.isFunction(obj.remove) ){ return {c:0, r:0, g: 'unknown', valid: false}; } s = function(d){ return ~~((d/70) - 0.5) + 1; }; v = function(d,sd,sv){ return ( ~~d === ~~sd ) ? 1 : ~~((d-sd)/sv ) + 1; }; h = function(d,sd,sv){ return Math.round( (d-sd)/sv) + 1; }; g = getObj('page',obj.get('pageid')).get('grid_type'); l = obj.get('left'); t = obj.get('top'); rv = ('square' === g ) ? {c: s(l), r: s(t), g :g, valid: true} : ('hex' === g ) ? {c: v(l,left_v,left_step_v), r: v(t,top_v,top_step_v), g: g, valid: true} : ('hexr' === g ) ? {c: h(l,left_h,left_step_h), r: h(t,top_h,top_step_h), g: g, valid: true} : {c:0, r:0, g: 'unknown', valid: false}; return rv; }