<commit_before>/*
 * Radio Paradise player
 * Copyright (c) 2014 <NAME> <<EMAIL>>
 * MIT License [http://www.opensource.org/licenses/mit-license.php]
 */

/*global chrome */
/*global storage, update_field */

'use strict';

chrome.alarms.onAlarm.addListener(function (alarm) {
  var name = alarm.name;
  var act;
  if (name.substr(0, 6) === 'alarm_') {
    act = name.substr(12);
    update_field('last_alarm');
    storage.set({last_alarm_name: name});
    storage.set({playing: act === 'on'});
  }
});
<commit_msg>alarms: left alarms from the past<commit_after>/*
 * Radio Paradise player
 * Copyright (c) 2014 <NAME> <<EMAIL>>
 * MIT License [http://www.opensource.org/licenses/mit-license.php]
 */

/*global chrome */
/*global storage, update_field */

'use strict';

chrome.alarms.onAlarm.addListener(function (alarm) {
  var name = alarm.name;
  var act, t;
  if (name.substr(0, 6) === 'alarm_') {
    t = new Date(new Date().getTime() - 30 * 1000).getTime(); // -30s
    if (alarm.scheduledTime > t) {
      act = name.substr(12);
      update_field('last_alarm');
      storage.set({last_alarm_name: name});
      storage.set({playing: act === 'on'});
    }
    // we left all alarms from the past;
    // they can be raised on the first moment Chrome started;
    // note: there are alarms-at-chrome-startup bugs 236684, 305925 etc.
    // has been fixed in Chrome 31 only.
  }
});

{'fraction_non_alphanumeric': 0.16966211358734723, 'fraction_numerical': 0.027318475916606758, 'mean_word_length': 3.2699386503067487, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1066226', 'n_tokens_mistral': 515, 'n_tokens_neox': 474, 'n_words': 124}