<commit_before>var Promise = require('es6-promise').Promise;
var flickr = require('./flickr');
var photosTemplate = require('./views/photos.hbs');

require('./libs/cachedb');

// force https
if ((!location.port || location.port == "80") && location.protocol != 'https:') {
  location.protocol = 'https:';
}

var photosEl = document.querySelector('.photos');
var refreshButton = document.querySelector('button.refresh');
var errorEl = document.querySelector('.error-container');

if ('serviceWorker' in navigator) {
  navigator.serviceWorker.register('/trained-to-thrill/static/js/sw.js', {
    scope: '/trained-to-thrill/'
  }).then(function(reg) {
    console.log('◕‿◕', reg);
  }, function(err) {
    console.log('ಠ_ಠ', err);
  });
}

function showSpinner(data) {
  refreshButton.classList.add('loading');
}

function hideSpinner(data) {
  refreshButton.classList.remove('loading');
}

function updatePage(data) {
  photosEl.innerHTML = photosTemplate(data);
}

function getTrainPhotoData() {
  return flickr.search('train station', {
    headers: {}
  });
}

function getCachedTrainPhotoData() {
  if ('serviceWorker' in navigator && navigator.serviceWorker.controller) {
    return flickr.search('train station', {
      headers: {'x-use-cache': 'true'}
    });
  }
  else {
    return Promise.reject(Error("No current serviceWorker"));
  }
}

function showConnectionError() {
  errorEl.style.display = 'block';<commit_msg>Using basic header to avoid OPTIONS<commit_after>var Promise = require('es6-promise').Promise;
var flickr = require('./flickr');
var photosTemplate = require('./views/photos.hbs');

// force https
if ((!location.port || location.port == "80") && location.protocol != 'https:') {
  location.protocol = 'https:';
}

var photosEl = document.querySelector('.photos');
var refreshButton = document.querySelector('button.refresh');
var errorEl = document.querySelector('.error-container');

if ('serviceWorker' in navigator) {
  navigator.serviceWorker.register('/trained-to-thrill/static/js/sw.js', {
    scope: '/trained-to-thrill/'
  }).then(function(reg) {
    console.log('◕‿◕', reg);
  }, function(err) {
    console.log('ಠ_ಠ', err);
  });
}

function showSpinner(data) {
  refreshButton.classList.add('loading');
}

function hideSpinner(data) {
  refreshButton.classList.remove('loading');
}

function updatePage(data) {
  photosEl.innerHTML = photosTemplate(data);
}

function getTrainPhotoData() {
  return flickr.search('train station', {
    headers: {}
  });
}

function getCachedTrainPhotoData() {
  if ('serviceWorker' in navigator && navigator.serviceWorker.controller) {
    return flickr.search('train station', {
      headers: {'Accept': 'x-cache/only'}
    });
  }
  else {
    return Promise.reject(Error("No current serviceWorker"));
  }
}

function showConnectionError() {
  errorEl.style.display = 'block';
{'fraction_non_alphanumeric': 0.17327253595229744, 'fraction_numerical': 0.002104524728165556, 'mean_word_length': 4.669980119284294, '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': '2462366', 'n_tokens_mistral': 902, 'n_tokens_neox': 891, 'n_words': 163}