<commit_before>/*
This file is part of the VROOM project
released under the MIT licence
Copyright 2014 Firewall Services
*/


// Default notifications
$.notify.defaults( { globalPosition: 'bottom left' } );
// Enable tooltip on required elements
$('.help').tooltip({container: 'body'});

// Strings we need translated
var locale = {
  ERROR_MAIL_INVALID: '',
  ERROR_OCCURED: '',
  CANT_SHARE_SCREEN: '',
  SCREEN_SHARING_ONLY_FOR_CHROME: '',
  SCREEN_SHARING_CANCELLED: '',
  EVERYONE_CAN_SEE_YOUR_SCREEN: '',
  SCREEN_UNSHARED: '',
  MIC_MUTED: '',
  MIC_UNMUTED: '',
  CAM_SUSPENDED: '',
  CAM_RESUMED: '',
  SET_YOUR_NAME_TO_CHAT: '',
  ONE_OF_THE_PEERS: '',
  ROOM_LOCKED_BY_s: '',
  ROOM_UNLOCKED_BY_s: '',
  PASSWORD_PROTECT_ON_BY_s: '',
  PASSWORD_PROTECT_OFF_BY_s: '',
  OWNER_PASSWORD_CHANGED_BY_s: '',
  OWNER_PASSWORD_REMOVED_BY_s: '',
  CANT_SEND_TO_s: '',
  SCREEN_s: '',
  TO_INVITE_SHARE_THIS_URL: '',
  NO_SOUND_DETECTED: '',
  DISPLAY_NAME_TOO_LONG: '',
  s_IS_MUTING_YOU: '',
  s_IS_MUTING_s: '',
  s_IS_UNMUTING_YOU: '',
  s_IS_UNMUTING_s: '',
  s_IS_SUSPENDING_YOU: '',
  s_IS_SUSPENDING_s: '',
  s_IS_RESUMING_YOU: '',
  s_IS_RESUMING_s: '',
  s_IS_KICKING_s: '',
  MUTE_PEER: '',
  SUSPEND_PEER: '',
  KICK_PEER: '',
  YOU_HAVE_MUTED_s: '',
  YOU_HAVE_UNMUTED_s: '',
  CANT_MUTE_OWNER: '',
  YOU_HAVE_SUSPENDED_s: '',
  YOU_HAVE_RESUMED_s: '',
  CANT_SUSPEND_OWNER: '',
  YOU_HAVE_KICKED_s: '',
  CANT_KICK_OWNER: '',
  REMOVE_THIS_ADDRESS: '',
  DISPLAY_NAME_REQUIRED: ''
};

// Localize the strings we need
$.ajax({
  url: rootUrl + 'localize',
  type: 'POST',
  dataType: 'json',
  data: {
    strings: JSON.stringify(locale),
  },
  success: function(data) {
    locale = data;
  }
});

// Popup with the URL to share
function inviteUrlPopup(){
  window.prompt(locale.TO_INVITE_SHARE_THIS_URL, window.location.href);
  return false;
}

// Add a new email address to be notified whn someone joins
function addNotifiedEmail(email){
  var id = email.replace('@', '_AT_').replace('.', '_DOT_');
  $('<li></li>').html(email + '  <a href="javascript:void(0);" onclick="removeNotifiedEmail(\'' + email + '\');" title="' + locale.REMOVE_THIS_ADDRESS + '">' +
                              '    <span class="glyphicon glyphicon-remove-circle"></span>' +
                              '  </a>')
   .attr('id', 'emailNotification_' + id)
   .appendTo('#emailNotificationList');
}

// Remove the address from the list
function removeNotifiedEmail(email){
  var id = email.replace('@', '_AT_').replace('.', '_DOT_');
  $.ajax({
    data: {
      action: 'emailNotification',
      type: 'remove',
      email: email,
      room: roomName
    },
    error: function() {
      $.notify(locale.ERROR_OCCURED, 'error');
    },
    success: function(data) {
      if (data.status == 'success'){
        $.notify(data.msg, 'success');
        $('#emailNotification_' + id).remove();
        webrtc.sendToAll('notif_change', {});
      }
      else{
        $.notify(data.msg, 'error');
      }
    }
  });
}

// Escape entities
function stringEscape(string){
  string = string.replace(/[\u00A0-\u99999<>\&]/gim, function(i) {
    return '&#' + i.charCodeAt(0) + ';';<commit_msg>Correctly escape chars in email addresses Without this, some email address with strange chars were not removable<commit_after>/*
This file is part of the VROOM project
released under the MIT licence
Copyright 2014 Firewall Services
*/


// Default notifications
$.notify.defaults( { globalPosition: 'bottom left' } );
// Enable tooltip on required elements
$('.help').tooltip({container: 'body'});

// Strings we need translated
var locale = {
  ERROR_MAIL_INVALID: '',
  ERROR_OCCURED: '',
  CANT_SHARE_SCREEN: '',
  SCREEN_SHARING_ONLY_FOR_CHROME: '',
  SCREEN_SHARING_CANCELLED: '',
  EVERYONE_CAN_SEE_YOUR_SCREEN: '',
  SCREEN_UNSHARED: '',
  MIC_MUTED: '',
  MIC_UNMUTED: '',
  CAM_SUSPENDED: '',
  CAM_RESUMED: '',
  SET_YOUR_NAME_TO_CHAT: '',
  ONE_OF_THE_PEERS: '',
  ROOM_LOCKED_BY_s: '',
  ROOM_UNLOCKED_BY_s: '',
  PASSWORD_PROTECT_ON_BY_s: '',
  PASSWORD_PROTECT_OFF_BY_s: '',
  OWNER_PASSWORD_CHANGED_BY_s: '',
  OWNER_PASSWORD_REMOVED_BY_s: '',
  CANT_SEND_TO_s: '',
  SCREEN_s: '',
  TO_INVITE_SHARE_THIS_URL: '',
  NO_SOUND_DETECTED: '',
  DISPLAY_NAME_TOO_LONG: '',
  s_IS_MUTING_YOU: '',
  s_IS_MUTING_s: '',
  s_IS_UNMUTING_YOU: '',
  s_IS_UNMUTING_s: '',
  s_IS_SUSPENDING_YOU: '',
  s_IS_SUSPENDING_s: '',
  s_IS_RESUMING_YOU: '',
  s_IS_RESUMING_s: '',
  s_IS_KICKING_s: '',
  MUTE_PEER: '',
  SUSPEND_PEER: '',
  KICK_PEER: '',
  YOU_HAVE_MUTED_s: '',
  YOU_HAVE_UNMUTED_s: '',
  CANT_MUTE_OWNER: '',
  YOU_HAVE_SUSPENDED_s: '',
  YOU_HAVE_RESUMED_s: '',
  CANT_SUSPEND_OWNER: '',
  YOU_HAVE_KICKED_s: '',
  CANT_KICK_OWNER: '',
  REMOVE_THIS_ADDRESS: '',
  DISPLAY_NAME_REQUIRED: ''
};

// Localize the strings we need
$.ajax({
  url: rootUrl + 'localize',
  type: 'POST',
  dataType: 'json',
  data: {
    strings: JSON.stringify(locale),
  },
  success: function(data) {
    locale = data;
  }
});

// Popup with the URL to share
function inviteUrlPopup(){
  window.prompt(locale.TO_INVITE_SHARE_THIS_URL, window.location.href);
  return false;
}

// Add a new email address to be notified whn someone joins
function addNotifiedEmail(email){
  var id = email.replace(/['"]/g, '_');
  $('<li></li>').html(email + '  <a href="javascript:void(0);" onclick="removeNotifiedEmail(\'' + email.replace('\'', '\\\'') + '\');" title="' + locale.REMOVE_THIS_ADDRESS + '">' +
                              '    <span class="glyphicon glyphicon-remove-circle"></span>' +
                              '  </a>')
   .attr('id', 'emailNotification_' + id)
   .appendTo('#emailNotificationList');
}

// Remove the address from the list
function removeNotifiedEmail(email){
  var id = escapeJqSelector(email.replace(/['"]/, '_').replace('\\\'', '\''));
  $.ajax({
    data: {
      action: 'emailNotification',
      type: 'remove',
      email: email,
      room: roomName
    },
    error: function() {
      $.notify(locale.ERROR_OCCURED, 'error');
    },
    success: function(data) {
      if (data.status == 'success'){
        $.notify(data.msg, 'success');
        $('#emailNotification_' + id).remove();
        webrtc.sendToAll('notif_change', {});
      }
      else{
        $.notify(data.msg, 'error');
      }
    }
  });
}

// Taken from http://totaldev.com/content/escaping-characters-get-valid-jquery-id
function escapeJqSelector(string){
  return string.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g, '\\$1');
}

// Escape entities
function stringEscape(string){
  string = string.replace(/[\u00A0-\u99999<>\&]/gim, function(i) {
    return '&#' + i.charCodeAt(0) + ';';
{'fraction_non_alphanumeric': 0.17439425665569847, 'fraction_numerical': 0.0043374214777146276, 'mean_word_length': 3.640527411519778, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4075096', 'n_tokens_mistral': 2668, 'n_tokens_neox': 2571, 'n_words': 415}