'use strict';
var app = app || {};
var URLCENTRALE = "http://maildigit.ndda.fr";
if (location.href.indexOf('https:')>-1){
  URLCENTRALE='https://maildigit.ndda.fr';
}

app.test = function(){
    $('a.test').on('click',function(){
       logger.info('lance test pdf');
       $.ajax({
                url: "/pdf",
                type: "POST",
                data: {
                        tpl: 'tete',
                        info : 'tyty',
                       },
                cache: false,
                success: function(res) {
                       logger.info(res.success)
                       },
                error: function(res) {
                       },
        });

    });
};
$('.btncode').on('click',function(){

  var clair = $('.clair').val();
  var code  = $('.code').val();
  if (clair !='' && code!='') {
     $('p.msgcode').html("Vider un champs pour générer le codage")
   }
  if (code=='') {
    $('.code').val(window.btoa(unescape(encodeURIComponent( clair ))));
  };
  if (clair ==''){
    $('.clair').val(decodeURIComponent(escape(window.atob( code ))));
  }
  });

$(document).ready(function () {
  //permet d'afficher du code à copier coller du site
  $( 'code' ).each(function(){$(this).find('pre').text( $(this).html() )});
  //app.init()
  md.tg("&s=s0");
  $('form.formmaildigit').gestionform(URLCENTRALE);
  $('.loginprocess').initlogin();
  //app.sendform();
//  app.test();
   //pour tester
});
