<commit_before>define(['jquery', 'jqvalidate', 'backbone', 'chrome', 'locator', 'text!apps/report/templates/report-tpl.html', 'gmaps', 'support'], function ($, Validate, Backbone, Chrome, Locator, Templates, GMaps, Support) {
  'use strict';
  Templates = $('<div>').html(Templates);
    
  var View = Backbone.View.extend({
    el: $('body'),
    // current position of user
    position: null,
    // poi lat, lng
    poi_lat:null,
    poi_lng:null, 

    initialize: function(info) {   
      var that = this;

      // Store poi location
      this.poi_lat = info.lat || null;
      this.poi_lng = info.lng || null;

      // Store user location
      Locator.location(function(pos, success) {
        that.position = pos;
      });    
      //_.bindAll(this, 'render');
    },

    template: _.template(Templates.find('#ReportPageTemplate').html()),

    events: {
      'click #submitReport': 'handleFormSubmission',
      'click #mapPosAbort': 'mapPosAbort',
      'click #mapPosCurrent': 'mapPosCurrent',
      'click #mapPosFetch': 'mapPosFetch',
      'click #mapButtonDone': 'mapButtonDone',
      'click #mapButtonAbort': 'mapButtonAbort',
    },

    mapLoad: function() {
      GMaps.loadInto( $('#mapCanvas').get(0) );

      // If user has location disabled, set default (pildammsparken)
      var pildammsparken = {lat: 55.58979331443427, lng: 12.992362976074219};
      this.position = this.position ? this.position : pildammsparken;
      
      // Set marker on user position
      var markers = [];
      markers.push( {
          name: "Din position",
          link: '',
          lat: this.position.lat, 
          lng: this.position.lng, 
          image: "images/pin.png"
        });

      GMaps.drawPoints( markers, false );

      var that = this;
      GMaps.addEvent( "click", function (event) {
        that.position = { lat: event.latLng.lat(), lng: event.latLng.lng() };
        var markers = [];
        markers.push( {
            name: "<NAME>",
            link: '',
            lat: that.position.lat, 
            lng: that.position.lng, 
            image: "images/pin.png"
          });

        GMaps.drawPoints( markers, false );        
      });
      
      return this;
    },

    mapButtonDone: function () {
      $("#formWrapper").show();
      $("#mapWrapper").hide();

      var that = this;
      Locator.location(function(pos, success) {
        that.position = pos;
      });

      // Set values of our hidden lat/lng input fields
      if( this.position != null ) {
        $("#latitude").val(this.position.lat);
        $("#longitude").val(this.position.lng);
      } else {
        $("#latitude").val("Ej angiven");
        $("#longitude").val("Ej angiven");
      }
      
      $("#errorReportForm").submit();
    },

    mapButtonAbort: function () {
      $("#formWrapper").show();
      $("#mapWrapper").hide();
    },

    mapPosFetch: function () {
      $("#formWrapper").hide();
      $("#mapWrapper").show();

      this.mapLoad();
      
      $("#mapCanvas").css({
          height: $(window).height() - $(this).find('[data-role="header"]').height()
        } );
      
      $('#whichPosition').popup("close");
      
    },

    mapPosCurrent: function () {
      // Fetch and set user current location
      var that = this;
      Locator.location(function(pos, success) {
        that.position = pos;
      })

      $('#whichPosition').popup("close");
      
      // Set values of our hidden lat/lng input fields
      if( this.position != null ) {
        $("#latitude").val(this.position.lat);
        $("#longitude").val(this.position.lng);
      } else {
        $("#latitude").val("Ej angiven");
        $("#longitude").val("Ej angiven");
      }
      
      $("#errorReportForm").submit();
    },

    mapPosAbort: function () {<commit_msg>Attempt to fix buttons missing on map during error reporting<commit_after>define(['jquery', 'jqvalidate', 'backbone', 'chrome', 'locator', 'text!apps/report/templates/report-tpl.html', 'gmaps', 'support'], function ($, Validate, Backbone, Chrome, Locator, Templates, GMaps, Support) {
  'use strict';
  Templates = $('<div>').html(Templates);
    
  var View = Backbone.View.extend({
    el: $('body'),
    // current position of user
    position: null,
    // poi lat, lng
    poi_lat:null,
    poi_lng:null, 

    initialize: function(info) {   
      var that = this;

      // Store poi location
      this.poi_lat = info.lat || null;
      this.poi_lng = info.lng || null;

      // Store user location
      Locator.location(function(pos, success) {
        that.position = pos;
      });    
      //_.bindAll(this, 'render');
    },

    template: _.template(Templates.find('#ReportPageTemplate').html()),

    events: {
      'click #submitReport': 'handleFormSubmission',
      'click #mapPosAbort': 'mapPosAbort',
      'click #mapPosCurrent': 'mapPosCurrent',
      'click #mapPosFetch': 'mapPosFetch',
      'click #mapButtonDone': 'mapButtonDone',
      'click #mapButtonAbort': 'mapButtonAbort',
    },

    mapLoad: function() {
      GMaps.loadInto( $('#mapCanvas').get(0) );

      // If user has location disabled, set default (pildammsparken)
      var pildammsparken = {lat: 55.58979331443427, lng: 12.992362976074219};
      this.position = this.position ? this.position : pildammsparken;
      
      // Set marker on user position
      var markers = [];
      markers.push( {
          name: "<NAME>",
          link: '',
          lat: this.position.lat, 
          lng: this.position.lng, 
          image: "images/pin.png"
        });

      GMaps.drawPoints( markers, false );

      var that = this;
      GMaps.addEvent( "click", function (event) {
        that.position = { lat: event.latLng.lat(), lng: event.latLng.lng() };
        var markers = [];
        markers.push( {
            name: "<NAME>",
            link: '',
            lat: that.position.lat, 
            lng: that.position.lng, 
            image: "images/pin.png"
          });

        GMaps.drawPoints( markers, false );        
      });
      
      return this;
    },

    mapButtonDone: function () {
      $("#formWrapper").show();
      $("#mapWrapper").hide();

      var that = this;
      Locator.location(function(pos, success) {
        that.position = pos;
      });

      // Set values of our hidden lat/lng input fields
      if( this.position != null ) {
        $("#latitude").val(this.position.lat);
        $("#longitude").val(this.position.lng);
      } else {
        $("#latitude").val("Ej angiven");
        $("#longitude").val("Ej angiven");
      }
      
      $("#errorReportForm").submit();
    },

    mapButtonAbort: function () {
      $("#formWrapper").show();
      $("#mapWrapper").hide();
    },

    mapPosFetch: function () {
      $("#formWrapper").hide();
      $("#mapWrapper").show();
      $('#report').trigger( "pagecreate" );


      this.mapLoad();
      
      $("#mapCanvas").css({
          height: $(window).height() - $(this).find('[data-role="header"]').height()
        } );
      
      $('#whichPosition').popup("close");

      $('#mapWrapper').trigger( "pagecreate" );
    },

    mapPosCurrent: function () {
      // Fetch and set user current location
      var that = this;
      Locator.location(function(pos, success) {
        that.position = pos;
      })

      $('#whichPosition').popup("close");
      
      // Set values of our hidden lat/lng input fields
      if( this.position != null ) {
        $("#latitude").val(this.position.lat);
        $("#longitude").val(this.position.lng);
      } else {
        $("#latitude").val("Ej angiven");
        $("#longitude").val("Ej angiven");
      }
      
      $("#errorReportForm").submit();
    },

    mapPosAbort: function () {
{'fraction_non_alphanumeric': 0.17244924184014393, 'fraction_numerical': 0.008738113595476741, 'mean_word_length': 2.197617091207888, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6937457', 'n_tokens_mistral': 2424, 'n_tokens_neox': 2370, 'n_words': 478}