<commit_before>/*
 * geo-tales-mobile
 *
 * Copyright (c) 2015 <NAME> <<EMAIL>>
 *
 * @license MIT
 */
/*global window*/
'use strict';

var fs = require('fs');
var hyperglue = require('hyperglue');
var marked = require('marked');
var locatify = require('locatify');
var screen = require('./screen');
var screenNavigate = require('./screen-navigate');

var html = fs.readFileSync(__dirname + '/screen-start.html', 'utf8');


function render(parent, shape, tracker, next) {
  var screenElement = hyperglue(html, {
    '.text': {
      _html: marked('## Go to start location\n\n- Latitude: `'
        + shape.center.latitude + '`\n- Longitude: `' + shape.center.longitude
        + '`')
    }
  });
  var footerElement = screenElement.querySelector('.footer');
  var elements = [screenElement.querySelector('.text'), footerElement];
  footerElement.querySelector('.next').onclick = function () {
    tracker.destroy();
    screen.hide(elements, function () {
      parent.innerHTML = '';
      window.scrollTo(0, 0);
      screenNavigate.create(parent, shape, {}, next);
    });
  };
  parent.appendChild(screenElement);
  screen.show(elements);
}


exports.create = function (parent, shape, next) {
  var rendered = false;
  var tracker = locatify.create(parent);
  tracker.on('position', function (pos) {
    if (pos.accuracy < 20 && shape.within(pos)) {
      tracker.destroy();<commit_msg>Show error message if location tracking does not work<commit_after>/*
 * geo-tales-mobile
 *
 * Copyright (c) 2015 <NAME> <<EMAIL>>
 *
 * @license MIT
 */
/*global window*/
'use strict';

var fs = require('fs');
var hyperglue = require('hyperglue');
var marked = require('marked');
var locatify = require('locatify');
var message = require('./message');
var screen = require('./screen');
var screenNavigate = require('./screen-navigate');

var html = fs.readFileSync(__dirname + '/screen-start.html', 'utf8');

var errorMessage;

function destroyErrorMessage() {
  if (errorMessage) {
    errorMessage.destroy();
    errorMessage = null;
  }
}

function render(parent, shape, tracker, next) {
  var screenElement = hyperglue(html, {
    '.text': {
      _html: marked('## Go to start location\n\n- Latitude: `'
        + shape.center.latitude + '`\n- Longitude: `' + shape.center.longitude
        + '`')
    }
  });
  var footerElement = screenElement.querySelector('.footer');
  var elements = [screenElement.querySelector('.text'), footerElement];
  footerElement.querySelector('.next').onclick = function () {
    tracker.destroy();
    destroyErrorMessage();
    screen.hide(elements, function () {
      parent.innerHTML = '';
      window.scrollTo(0, 0);
      screenNavigate.create(parent, shape, {}, next);
    });
  };
  parent.appendChild(screenElement);
  screen.show(elements);
}


exports.create = function (parent, shape, next) {
  var rendered = false;
  var tracker = locatify.create(parent);
  tracker.on('error', function (err) {
    if (!errorMessage) {
      errorMessage = message.create(parent, err.message, 'warning');
    }
  });
  tracker.on('position', function (pos) {
    destroyErrorMessage();
    if (pos.accuracy < 20 && shape.within(pos)) {
      tracker.destroy();
{'fraction_non_alphanumeric': 0.16969887076537013, 'fraction_numerical': 0.0056461731493099125, 'mean_word_length': 3.7597014925373133, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, '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': '2838545', 'n_tokens_mistral': 1001, 'n_tokens_neox': 973, 'n_words': 220}