<commit_before>// Copyright (c) 2013 Intel Corporation. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

var tizen = tizen || {};

(function() {
  // FIXME(cmarcelo): Needed?
  var postedNotifications = [];
  var statusNotificationNextId = 0;

  var postMessage = function(msg) {
    xwalk.postMessage("tizen.notifications", JSON.stringify(msg));
  };

  xwalk.setMessageListener('tizen.notifications', function(msg) {
    var m = JSON.parse(msg);
    if (m.cmd == "NotificationRemoved") {
      for (var i = 0; i < postedNotifications.length; i++) {
        if (postedNotifications[i].id === m.id) {
          postedNotifications.splice(i, 1);
          break;
        }
      }
    }
  });

  tizen.StatusNotification = function(statusType, title, dict) {
    this.title = title;
    this.id = (statusNotificationNextId++).toString();
    this.type = "STATUS";
    if (dict) {
      this.content = dict.content;
    }
  }

  var copyStatusNotification = function(notification) {
    var copy = new tizen.StatusNotification(notification.type, notification.title, { content: notification.content });
    statusNotificationNextId--;  // Roll next id back since we are copying.
    copy.id = notification.id;
    return copy;
  }

  tizen.notification = {};
  tizen.notification.post = function(notification) {
    if (!(notification instanceof tizen.StatusNotification)) {
      console.log("tizen.notification.post(): argument of invalid type " + typeof(notification));
      return;
    }
    postMessage({
      "cmd": "NotificationPost",
      "id": notification.id,
      "title": notification.title,
      "content": notification.content,
    });
    postedNotifications.push(notification);
  }

  tizen.notification.remove = function(notificationId) {
    postMessage({
      "cmd": "NotificationRemove",
      "id": notificationId,
    });
  }

  tizen.notification.getAll = function() {
    var result = [];
    var i;<commit_msg>Avoid posting the same notification repeatdly.<commit_after>// Copyright (c) 2013 Intel Corporation. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

var tizen = tizen || {};

(function() {
  // FIXME(cmarcelo): Needed?
  var postedNotifications = [];
  var statusNotificationNextId = 0;

  var postMessage = function(msg) {
    xwalk.postMessage("tizen.notifications", JSON.stringify(msg));
  };

  xwalk.setMessageListener('tizen.notifications', function(msg) {
    var m = JSON.parse(msg);
    if (m.cmd == "NotificationRemoved") {
      for (var i = 0; i < postedNotifications.length; i++) {
        if (postedNotifications[i].id === m.id) {
          postedNotifications.splice(i, 1);
          break;
        }
      }
    }
  });

  tizen.StatusNotification = function(statusType, title, dict) {
    this.title = title;
    this.id = (statusNotificationNextId++).toString();
    this.type = "STATUS";
    if (dict) {
      this.content = dict.content;
    }
  }

  var copyStatusNotification = function(notification) {
    var copy = new tizen.StatusNotification(notification.type, notification.title, { content: notification.content });
    statusNotificationNextId--;  // Roll next id back since we are copying.
    copy.id = notification.id;
    return copy;
  }

  tizen.notification = {};
  tizen.notification.post = function(notification) {
    if (!(notification instanceof tizen.StatusNotification)) {
      console.log("tizen.notification.post(): argument of invalid type " + typeof(notification));
      return;
    } else if (postedNotifications.indexOf(notification) != -1) {
      console.log("tizen.notification.post(): notification " + notification.id + " already posted.");
      return;
    }
    postMessage({
      "cmd": "NotificationPost",
      "id": notification.id,
      "title": notification.title,
      "content": notification.content,
    });
    postedNotifications.push(notification);
  }

  tizen.notification.remove = function(notificationId) {
    postMessage({
      "cmd": "NotificationRemove",
      "id": notificationId,
    });
  }

  tizen.notification.getAll = function() {
    var result = [];
    var i;
{'fraction_non_alphanumeric': 0.13356890459363957, 'fraction_numerical': 0.0035335689045936395, 'mean_word_length': 3.142439024390244, 'pattern_counts': {'":': 12, '<': 5, '<?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': '4018552', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1206, 'n_words': 292}