<commit_before>/* global require */

var $ = require('jquery'),
  pryv = require('pryv');

var defaultPermissions = [{
  streamId : 'diary',
  defaultName : 'Journal',
  level : 'read'
}];

/**
 * Initialize access page
 */
window.onload = function () {
  var $masterToken = $('#masterToken');
  permissionsAreaState(false);
  $('#registerUrlText').text(pryv.utility.urls.parseClientURL().parseQuery()['pryv-reg'] ||
    pryv.Auth.config.registerURL.host);
  $masterToken.prop('checked', false);
  $('#permissionsArea').val(JSON.stringify(defaultPermissions, null, '  '));
  $masterToken.click(masterTokenManagement);
  $('#addPermission').click(addPermission);
  $('#submitButton').click(requestAccess);
  $('#clearPermissionArea').click(clearPermissions);

  // Toggle dev options
  toggleDevOptions();
  $('#toggleDev').click(toggleDevOptions);
};

/**
 * Change view and permissions to fit a master token app access
 */
function masterTokenManagement() {
  var $permissionsViewInactive = $('#permissionsViewInactive'),
    $permissionsArea = $('#permissionsArea'),
    masterTokenPermissions = [{
      streamId: '*',
      level: 'manage'
    }];

  if ($('#masterToken:checked').length === 1) {
    try {
      defaultPermissions = JSON.parse($permissionsArea.val());
      $permissionsArea.val(JSON.stringify(masterTokenPermissions, null, '  '));
      permissionsAreaState(true);
      $permissionsViewInactive.css({'display': 'unset'});
    } catch (err) {
      logToConsole(err);
    }<commit_msg>Automatic load of return url<commit_after>/* global require */

var $ = require('jquery'),
  pryv = require('pryv');

var defaultPermissions = [{
  streamId : 'diary',
  defaultName : 'Journal',
  level : 'read'
}];

/**
 * Initialize access page
 */
window.onload = function () {
  var $masterToken = $('#masterToken');
  permissionsAreaState(false);
  $('#registerUrlText').text(pryv.utility.urls.parseClientURL().parseQuery()['pryv-reg'] ||
    pryv.Auth.config.registerURL.host);
  $masterToken.prop('checked', false);
  $('#permissionsArea').val(JSON.stringify(defaultPermissions, null, '  '));
  $masterToken.click(masterTokenManagement);
  $('#addPermission').click(addPermission);
  $('#submitButton').click(requestAccess);
  $('#clearPermissionArea').click(clearPermissions);

  // Toggle dev options
  toggleDevOptions();
  $('#toggleDev').click(toggleDevOptions);

  requestAccess();
};

/**
 * Change view and permissions to fit a master token app access
 */
function masterTokenManagement() {
  var $permissionsViewInactive = $('#permissionsViewInactive'),
    $permissionsArea = $('#permissionsArea'),
    masterTokenPermissions = [{
      streamId: '*',
      level: 'manage'
    }];

  if ($('#masterToken:checked').length === 1) {
    try {
      defaultPermissions = JSON.parse($permissionsArea.val());
      $permissionsArea.val(JSON.stringify(masterTokenPermissions, null, '  '));
      permissionsAreaState(true);
      $permissionsViewInactive.css({'display': 'unset'});
    } catch (err) {
      logToConsole(err);
    }
{'fraction_non_alphanumeric': 0.1753523434939364, 'fraction_numerical': 0.0006555227794165847, 'mean_word_length': 4.641404805914973, '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': '1141434', 'n_tokens_mistral': 906, 'n_tokens_neox': 919, 'n_words': 155}