<commit_before>/*Copyright (C) 2009-2014 :
     <NAME>, <EMAIL>
     <NAME>, <EMAIL>
     <NAME>, <EMAIL>
     <NAME>, <EMAIL>
     <NAME>, <EMAIL>
     <NAME>, <EMAIL>

 This file is part of Shinken.

 Shinken is free software: you can redistribute it and/or modify
 it under the terms of the GNU Affero General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 Shinken is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU Affero General Public License for more details.

 You should have received a copy of the GNU Affero General Public License
 along with Shinken.  If not, see <http://www.gnu.org/licenses/>.
*/

var layout_logs=false;

/*
 * To load on run some additional js or css files.
*/
function loadjscssfile(filename, filetype){
   if (filetype=="js") {
      if (layout_logs) console.debug('Loading Js file: ', filename);
      $.ajax({
         url: filename,
         dataType: "script",
         error: function () {
            console.error('Shinken script error, not loaded: ', filename);
         }
      });
   } else if (filetype=="css") {
      if (layout_logs) console.debug('Loading Css file: ', filename);
      $('<link>')
         .appendTo('head')
         .attr({type : 'text/css', rel : 'stylesheet'})
         .attr('href', filename);
   }
}


/**
 * Save current user preference value: 
 * - key / value
 * - callback function called after data are posted
**/
function save_user_preference(key, value, callback) {
   callback = (typeof callback !== 'undefined') ? callback : function() {
      console.debug('No callback function');
   };
   
   $.post("/user/save_pref", { 'key' : key, 'value' : value}, function() {
      if (layout_logs) console.debug('User preference saved: ', key, value);
      raise_message_ok("User parameter "+key+" saved");
      try {
         window[callback]();
      }
      catch(err) {
         // console.error('Callback function does not exist!', callback);
      }
   });
}

/**
 * Save common preference value
 * - key / value
 * - callback function called after data are posted
**/
function save_common_preference(key, value, callback) {
   callback = (typeof callback !== 'undefined') ? callback : function() {
      console.debug('No callback function');
   };
   
   $.post("/user/save_common_pref", { 'key' : key, 'value' : value}, function() {
      if (layout_logs) console.debug('Common preference saved: ', key, value);
      raise_message_ok("Common parameter "+key+" set to "+value);
      try {
         window[callback]();
      }
      catch(err) {
         // console.error('Callback function does not exist!', callback);
      }
   });
}

   
/**
 *  Actions bar related code
 */
function hide_actions(){
   if (layout_logs) console.debug('Hiding actions bar');
   $('#actions').hide();
}

function show_actions(){
   if (layout_logs) console.debug('Showing actions bar');
   $('#actions').show();
}


/**
 * Display the layout modal form
 */
function display_form(form) {
   if (layout_logs) console.debug('Displaying form: ', form);
   stop_refresh();
   $('#modal').modal({
      keyboard: true,
      show: true,
      backdrop: 'static',
      remote: form
   });
}

$(document).ready(function(){
   // When modal box is hidden ...
   $('#modal').on('hidden.bs.modal', function () {
      // Show sidebar menu ...
      $('.sidebar').show();
      if (selected_elements.length > 0) {
         // Show actions bar ...
         $('.actionbar').show();
      }
      
      // Clean modal box content ...
      $(this).removeData('bs.modal');
   });<commit_msg>Fix actions bar not always displayed when modal disappears<commit_after>/*Copyright (C) 2009-2014 :
     <NAME>, <EMAIL>
     <NAME>, <EMAIL>
     <NAME>, <EMAIL>
     <NAME>, <EMAIL>
     <NAME>, <EMAIL>
     <NAME>, <EMAIL>

 This file is part of Shinken.

 Shinken is free software: you can redistribute it and/or modify
 it under the terms of the GNU Affero General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 Shinken is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU Affero General Public License for more details.

 You should have received a copy of the GNU Affero General Public License
 along with Shinken.  If not, see <http://www.gnu.org/licenses/>.
*/

var layout_logs=false;

/*
 * To load on run some additional js or css files.
*/
function loadjscssfile(filename, filetype){
   if (filetype=="js") {
      if (layout_logs) console.debug('Loading Js file: ', filename);
      $.ajax({
         url: filename,
         dataType: "script",
         error: function () {
            console.error('Shinken script error, not loaded: ', filename);
         }
      });
   } else if (filetype=="css") {
      if (layout_logs) console.debug('Loading Css file: ', filename);
      $('<link>')
         .appendTo('head')
         .attr({type : 'text/css', rel : 'stylesheet'})
         .attr('href', filename);
   }
}


/**
 * Save current user preference value: 
 * - key / value
 * - callback function called after data are posted
**/
function save_user_preference(key, value, callback) {
   callback = (typeof callback !== 'undefined') ? callback : function() {
      console.debug('No callback function');
   };
   
   $.post("/user/save_pref", { 'key' : key, 'value' : value}, function() {
      if (layout_logs) console.debug('User preference saved: ', key, value);
      raise_message_ok("User parameter "+key+" saved");
      try {
         window[callback]();
      }
      catch(err) {
         // console.error('Callback function does not exist!', callback);
      }
   });
}

/**
 * Save common preference value
 * - key / value
 * - callback function called after data are posted
**/
function save_common_preference(key, value, callback) {
   callback = (typeof callback !== 'undefined') ? callback : function() {
      console.debug('No callback function');
   };
   
   $.post("/user/save_common_pref", { 'key' : key, 'value' : value}, function() {
      if (layout_logs) console.debug('Common preference saved: ', key, value);
      raise_message_ok("Common parameter "+key+" set to "+value);
      try {
         window[callback]();
      }
      catch(err) {
         // console.error('Callback function does not exist!', callback);
      }
   });
}

   
/**
 *  Actions bar related code
 */
function hide_actions(){
   if (layout_logs) console.debug('Hiding actions bar');
   $('#actions').hide();
}

function show_actions(){
   if (layout_logs) console.debug('Showing actions bar');
   $('#actions').show();
}


/**
 * Display the layout modal form
 */
function display_form(form) {
   if (layout_logs) console.debug('Displaying form: ', form);
   stop_refresh();
   $('#modal').modal({
      keyboard: true,
      show: true,
      backdrop: 'static',
      remote: form
   });
}

$(document).ready(function(){
   // When modal box is hidden ...
   $('#modal').on('hidden.bs.modal', function () {
      // Show sidebar menu ...
      $('.sidebar').show();
      // Show actions bar ...
      $('.actionbar').show();
      
      // Clean modal box content ...
      $(this).removeData('bs.modal');
   });
{'fraction_non_alphanumeric': 0.1480792237139439, 'fraction_numerical': 0.002525588196198325, 'mean_word_length': 2.8076923076923075, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 32, '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': '954017', 'n_tokens_mistral': 2169, 'n_tokens_neox': 2142, 'n_words': 697}