<commit_before>import "dart:html";
import "dart:convert";
import 'package:bootjack/bootjack.dart';
import 'package:js/js.dart' as js;

import 'spaces.dart';
import "forms.dart";

SpacesLayout layout;

void main() {
  layout = new SpacesLayout.withWestSpace(180,70,50);
  
  querySelector(".search-form-btn").onClick.listen((e) {
    submitRequest();
  });  
}

void submitRequest(){
  HttpRequest request = new HttpRequest();

  layout.startLoading();
  request.onReadyStateChange.listen((_) {
    if (request.readyState == HttpRequest.DONE ) {
      displaySearchResults(request);
    }
  });
  sendSearchRequest(request);
  removeResults(".search-default-results");
  removeResults(".search-results");
}

void displaySearchResults(HttpRequest request){
  SearchForm form = new SearchForm.fromMap(JSON.decode(request.responseText));
  
  Element searchResultRow=  querySelector("#search-result-row");
  Element searchResultBody=  querySelector("#search-result-body");
  if (form.results != null && form.results.isNotEmpty){
    
    js.context.removeAllMarkers();
    form.results.forEach((ligthTrace){
      Element searchResultCurrentRow = searchResultRow.clone(true) ;
      searchResultCurrentRow.className = "search-results" ;
      searchResultCurrentRow.children[0].innerHtml = ligthTrace.creator;
      searchResultCurrentRow.children[1].innerHtml = ligthTrace.title;
      searchResultCurrentRow.children[2].innerHtml = ligthTrace.activities;
      searchResultCurrentRow.children[3].innerHtml = ligthTrace.length;
      searchResultCurrentRow.children[4].innerHtml = ligthTrace.up;
      searchResultCurrentRow.children[5].innerHtml = ligthTrace.upperPointElevetion;
      searchResultCurrentRow.children[6].innerHtml = ligthTrace.inclinationUp;
      searchResultCurrentRow.children[7].innerHtml = ligthTrace.difficulty;
      searchResultBody.append(searchResultCurrentRow);
      
      js.context.addMarkerToMap( ligthTrace.keyJsSafe,  ligthTrace.titleJsSafe, ligthTrace.startPointLatitude,ligthTrace.startPointLongitude );
    });
  }
  layout.stopLoading();
}

void sendSearchRequest(HttpRequest request){
  request.open("POST",  "/trace.as_search", async: true);
  SearchForm form =  new  SearchForm( );
  form.search = (querySelector(".search-form-input-text") as InputElement ).value ;
  querySelectorAll(".search-form-input-activity").forEach((e){
    CheckboxInputElement  activity= e as CheckboxInputElement;
    if (activity.checked){
      form.addActivity(activity.name.substring("activity-".length, activity.name.length));
    }
  }) ;

  form.lengthGt              = (querySelector(".search-form-input-length-gt") as InputElement ).value ;  <commit_msg>display markers on map after search - fix<commit_after>import "dart:html";
import "dart:convert";
import 'package:bootjack/bootjack.dart';
import 'package:js/js.dart' as js;

import 'spaces.dart';
import "forms.dart";

SpacesLayout layout;

void main() {
  layout = new SpacesLayout.withWestSpace(180,70,50);
  
  querySelector(".search-form-btn").onClick.listen((e) {
    submitRequest();
  });  
}

void submitRequest(){
  HttpRequest request = new HttpRequest();

  layout.startLoading();
  request.onReadyStateChange.listen((_) {
    if (request.readyState == HttpRequest.DONE ) {
      displaySearchResults(request);
    }
  });
  sendSearchRequest(request);
  removeResults(".search-default-results");
  removeResults(".search-results");
}

void displaySearchResults(HttpRequest request){
  SearchForm form = new SearchForm.fromMap(JSON.decode(request.responseText));
  
  Element searchResultRow=  querySelector("#search-result-row");
  Element searchResultBody=  querySelector("#search-result-body");
  js.context.removeAllMarkers();
  if (form.results != null && form.results.isNotEmpty){
    
    form.results.forEach((ligthTrace){
      Element searchResultCurrentRow = searchResultRow.clone(true) ;
      searchResultCurrentRow.className = "search-results" ;
      searchResultCurrentRow.children[0].innerHtml = ligthTrace.creator;
      searchResultCurrentRow.children[1].innerHtml = ligthTrace.title;
      searchResultCurrentRow.children[2].innerHtml = ligthTrace.activities;
      searchResultCurrentRow.children[3].innerHtml = ligthTrace.length;
      searchResultCurrentRow.children[4].innerHtml = ligthTrace.up;
      searchResultCurrentRow.children[5].innerHtml = ligthTrace.upperPointElevetion;
      searchResultCurrentRow.children[6].innerHtml = ligthTrace.inclinationUp;
      searchResultCurrentRow.children[7].innerHtml = ligthTrace.difficulty;
      searchResultBody.append(searchResultCurrentRow);
      
      js.context.addMarkerToMap( ligthTrace.keyJsSafe,  ligthTrace.titleJsSafe, ligthTrace.startPointLatitude,ligthTrace.startPointLongitude );
    });
  }
  layout.stopLoading();
}

void sendSearchRequest(HttpRequest request){
  request.open("POST",  "/trace.as_search", async: true);
  SearchForm form =  new  SearchForm( );
  form.search = (querySelector(".search-form-input-text") as InputElement ).value ;
  querySelectorAll(".search-form-input-activity").forEach((e){
    CheckboxInputElement  activity= e as CheckboxInputElement;
    if (activity.checked){
      form.addActivity(activity.name.substring("activity-".length, activity.name.length));
    }
  }) ;

  form.lengthGt              = (querySelector(".search-form-input-length-gt") as InputElement ).value ;  
{'fraction_non_alphanumeric': 0.1271343726800297, 'fraction_numerical': 0.005567928730512249, 'mean_word_length': 4.7026455026455025, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5601520', 'n_tokens_mistral': 1601, 'n_tokens_neox': 1587, 'n_words': 236}