<commit_before>// Setup service worker and notiication services
//   Adapted from the code in https://codelabs.developers.google.com/codelabs/push-notifications/#0

// VAPID key
const applicationServerPublicKey = '<KEY>'

let pushButton = null;

console.log('Setting isSubscribed to false')
var isSubscribed = false;
var permStatus = 'denied'
var swRegistration = null;

// Register service worker and check for push support
if ('serviceWorker' in navigator && 'PushManager' in window) {
  console.log('Service Worker and Push is supported');

  navigator.serviceWorker.register('sw.js')
  .then(function(swReg) {
    console.log('Service Worker is registered', swReg);
    swRegistration = swReg
    //initializeUI()
  })
  .catch(function(error) {
    console.error('Service Worker Error', error);
  });
} else {
  console.warn('Push messaging is not supported');
  pushButton.textContent = 'Push Not Supported';
}

// Called after service worker installation
function initializeUI() {
  /* Fix button stuff later
  pushButton = document.querySelector('.js-push-btn');
  pushButton.addEventListener('click', function() {
    pushButton.disabled = true;
    if (isSubscribed) {
      unsubscribeUser();
    } else {
      subscribeUser();
    }
  });
  */

  Notification.requestPermission(function(status) {
    permStatus = status;
    console.log('Notification permission status:', status);
  });

  // Set the initial subscription value
  navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) {
    swRegistration.pushManager.getSubscription()
    .then(function(subscription) {
      console.log('Service worker got subscription')
      isSubscribed = !(subscription === null);
      console.log('And found it to be ' + isSubscribed)
      })
    })

    // Tell server about sub
    // updateSubscriptionOnServer(subscription);

    if (isSubscribed) {
      console.log('WTF? ' + JSON.stringify(subscription))
      console.log('User IS subscribed.');
    } else {
      console.log('User is NOT subscribed.');
    }
    // updateBtn();
}<commit_msg>removed some dead code<commit_after>// Setup service worker and notiication services
//   Adapted from the code in https://codelabs.developers.google.com/codelabs/push-notifications/#0

// VAPID key
const applicationServerPublicKey = '<KEY>'

let pushButton = null;

console.log('Setting isSubscribed to false')
var isSubscribed = false;
var permStatus = 'denied'
var swRegistration = null;

// Register service worker and check for push support
if ('serviceWorker' in navigator && 'PushManager' in window) {
  console.log('Service Worker and Push is supported');

  navigator.serviceWorker.register('sw.js')
  .then(function(swReg) {
    console.log('Service Worker is registered', swReg);
    swRegistration = swReg

  })
  .catch(function(error) {
    console.error('Service Worker Error', error);
  });
} else {
  console.warn('Push messaging is not supported');
  pushButton.textContent = 'Push Not Supported';
}

// Called after service worker installation
function initializeUI() {


  Notification.requestPermission(function(status) {
    permStatus = status;
    console.log('Notification permission status:', status);
  });

  // Set the initial subscription value
  navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) {
    swRegistration.pushManager.getSubscription()
    .then(function(subscription) {
      console.log('Service worker got subscription')
      isSubscribed = !(subscription === null);
      console.log('And found it to be ' + isSubscribed)
      })
    })

    // Tell server about sub
    // updateSubscriptionOnServer(subscription);

    if (isSubscribed) {
      console.log('WTF? ' + JSON.stringify(subscription))
      console.log('User IS subscribed.');
    } else {
      console.log('User is NOT subscribed.');
    }
    
}
{'fraction_non_alphanumeric': 0.12110995850622407, 'fraction_numerical': 0.0005186721991701245, 'mean_word_length': 3.791304347826087, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '7183823', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1075, 'n_words': 282}