diff --git a/static/js/marker.js b/static/js/marker.js index f23246f8..415ec533 100644 --- a/static/js/marker.js +++ b/static/js/marker.js @@ -15,27 +15,6 @@ var MarkerView = Backbone.View.extend({ this.$el.find("." + value).text(fields[field] + ": " + localization[field][this.model.get(value)]); } }, - localize_inv : function(field,value) { - // localizes involved data - if (this.model.has(value) && this.model.get(value)!="" && - inv_dict[field][this.model.get(value)]!=undefined) { - this.$el.find("." + value).text(fields[field] + ": " + inv_dict[field][this.model.get(value)]); - } - }, - localize_veh : function(field,value) { - // localizes vehicles data - if (this.model.has(value) && this.model.get(value)!="" && - veh_dict[field][this.model.get(value)]!=undefined) { - this.$el.find("." + value).text(fields[field] + ": " + veh_dict[field][this.model.get(value)]); - } - }, - localize_num : function(field,value) { - // localizes interger data values - if (this.model.has(value) && this.model.get(value)!="" && - fields[field]!=undefined) { - this.$el.find("." + value).text(fields[field] + ": " + this.model.get(value)); - } - }, render : function() { @@ -101,28 +80,6 @@ var MarkerView = Backbone.View.extend({ this.localize("OFEN_HAZIYA","cross_mode"); this.localize("MEKOM_HAZIYA","cross_location"); this.localize("KIVUN_HAZIYA","cross_direction"); - // Involved fields: TODO: add AJAX calls to get dictionary required fields (INVOLVED + VEHICLES) - this.localize_inv("SUG_MEORAV","involved_type"); - this.localize_num("SHNAT_HOZAA","license_aquiring_date"); - this.localize_num("KVUZA_GIL","age_group"); // Dictionary.csv - Table 92 - this.localize_inv("MIN","sex"); - this.localize_inv("SUG_REHEV_NASA_LMS","car_type"); - this.localize_inv("EMZAE_BETIHUT","safety_measures"); - this.localize_num("SEMEL_YISHUV_MEGURIM","home_city"); // Cities.csv - "SEMEL" - this.localize_inv("HUMRAT_PGIA","injured_severity"); - this.localize_inv("SUG_NIFGA_LMS","injured_type"); - this.localize_inv("PEULAT_NIFGA_LMS","injured_position"); - this.localize_num("KVUTZAT_OHLUSIYA_LMS","population_type"); // Dictionary.csv - Table 66 - // Vehicles fields: - this.localize_num("NEFAH","engine_volume"); // Dictionary.csv - Table 111 - this.localize_num("SHNAT_YITZUR","manufacturing_year"); - this.localize_num("KIVUNE_NESIA","driving_directions"); // Dictionary.csv - Table 28 - this.localize_veh("MATZAV_REHEV","vehicle_status"); - this.localize_veh("SHIYUH_REHEV_LMS","vehicle_attribution"); - this.localize_veh("SUG_REHEV_LMS","vehicle_type"); - this.localize_num("MEKOMOT_YESHIVA_LMS","seats"); // Dictionary.csv - Table 112 - this.localize_num("MISHKAL_KOLEL_LMS","total_weight"); - this.$el.find(".creation-date").text("תאריך: " + moment(this.model.get("created")).format("LLLL")); @@ -154,8 +111,59 @@ var MarkerView = Backbone.View.extend({ return "/?marker=" + this.model.get("id") + "&" + app.getCurrentUrlParams(); }, clickMarker : function() { + that = this; $.get("/markers/" + this.model.get("id"), function (data) { - //alert(data); + data = JSON.parse(data); + + var localize_data = function(field,value,dataType) { + if (dataType === "invs") { + if (inv_dict[field] != undefined && inv_dict[field][data[i][value]] != undefined) { + text_line = "

" + fields[field] + ": " + inv_dict[field][data[i][value]] + "

"; + that.$el.append(text_line); + } + }else if (dataType === "vehs"){ + if (veh_dict[field] != undefined && veh_dict[field][data[i][value]] != undefined) { + text_line = "

" + fields[field] + ": " + veh_dict[field][data[i][value]] + "

"; + that.$el.append(text_line); + } + }else if (dataType === "nums") { + if ([data[i][value]] != 0) { + text_line = "

" + fields[field] + ": " + data[i][value] + "

"; + that.$el.append(text_line); + } + } + } + var j = 1; + for (i in data) { + if (data[i]["sex"] != undefined) { + text_line = "

פרטי אדם מעורב" + " " + (i*1+1) + "

" + that.$el.append(text_line); + localize_data("SUG_MEORAV","involved_type","invs"); + localize_data("SHNAT_HOZAA","license_acquiring_date","nums"); + localize_data("KVUZA_GIL","age_group","nums"); + localize_data("MIN","sex","invs"); + localize_data("SUG_REHEV_NASA_LMS","car_type","invs"); + localize_data("EMZAE_BETIHUT","safety_measures","invs"); + localize_data("HUMRAT_PGIA","injured_severity","invs"); + localize_data("SUG_NIFGA_LMS","injured_type","invs"); + localize_data("PEULAT_NIFGA_LMS","injured_position","invs"); + localize_data("KVUTZAT_OHLUSIYA_LMS","population_type","nums"); + that.$el.append("

"); + }else{ + text_line = "

פרטי רכב מעורב" + " " + (j) + "

" + that.$el.append(text_line); + localize_data("SUG_REHEV_LMS","vehicle_type","vehs"); + localize_data("NEFAH","engine_volume","nums"); + localize_data("SHNAT_YITZUR","manufacturing_year","nums"); + localize_data("KIVUNE_NESIA","driving_directions","nums"); + localize_data("MATZAV_REHEV","vehicle_status","vehs"); + localize_data("SHIYUH_REHEV_LMS","vehicle_attribution","vehs"); + localize_data("MEKOMOT_YESHIVA_LMS","seats","nums"); + localize_data("MISHKAL_KOLEL_LMS","total_weight","nums"); + that.$el.append("

"); + j++; + } + } }); this.highlight(); app.closeInfoWindow(); diff --git a/templates/index.html b/templates/index.html index 226f9dbc..0909e4eb 100644 --- a/templates/index.html +++ b/templates/index.html @@ -272,26 +272,7 @@

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

-

- +

diff --git a/templates/sendemail.html b/templates/sendemail.html index 38214286..00992421 100644 --- a/templates/sendemail.html +++ b/templates/sendemail.html @@ -6,7 +6,7 @@ {% if current_user.is_authenticated() %}