Dashwood / JVPSmileys

// ==UserScript==
// @name         JVPSmileys
// @version      1.4.2
// @description  Remplace les smileys JVC par leur version JVP
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// @author       Electron
// @match        http://www.jeuxvideo.com/forums/*
// @updateUrl    https://openuserjs.org/src/scripts/Dashwood/JVPSmileys.meta.js
// @downloadUrl  https://openuserjs.org/src/scripts/Dashwood/JVPSmileys.user.js
// @license MIT
// ==/UserScript==

'use strict';

const version = '1.4.2';
let k = true;
let l = true;

let style = `
#btn-script-disabled{
    pointer-events: none;
    float: right;
    background-color: #A1A1A1;
    color: white;
    border: none;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 0.84rem;
    margin-bottom: 0;
    margin-top: 0.9375rem;
}
#btn-script{
    float: right;
    background-color: #064663;
    border: none;
    color: white;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 0.84rem;
    margin-bottom: 0;
    margin-top: 0.9375rem;
}
#checkbox-script{
    margin: 0;
}
.nostalgy-mode{
    margin-top: 0.9375rem;
    margin-bottom: 0;
}
`;

RegExp.escape = function (string) {
  return string.replace(/[-\/\\^$*+?.()[\]{}]/g, '\\$&');
};

let display = localStorage.getItem('JVPS-displayMode');
let undisplay = localStorage.getItem('JVPS-undisplayMode');
let nostalgy = localStorage.getItem('JVPS-nostalgyMode');
let prefix = '[JVPSmileys ' + version + '] ';
if (display == null || undisplay == null || nostalgy == null) {
  localStorage.setItem('JVPS-displayMode', 'JVP');
  localStorage.setItem('JVPS-undisplayMode', 'JVC-JVP');
  localStorage.setItem('JVPS-nostalgyMode', '0');
  display = localStorage.getItem('JVPS-displayMode');
  undisplay = localStorage.getItem('JVPS-undisplayMode');
  nostalgy = localStorage.getItem('JVPS-nostalgyMode');
}
console.info(prefix + 'Initializing JVPSmileys');

const smileys = {
  jvcVersion: [
    'http://image.jeuxvideo.com/smileys_img/1.gif',
    'http://image.jeuxvideo.com/smileys_img/20.gif',
    'http://image.jeuxvideo.com/smileys_img/17.gif',
    'http://image.jeuxvideo.com/smileys_img/3.gif',
    'http://image.jeuxvideo.com/smileys_img/46.gif',
    'http://image.jeuxvideo.com/smileys_img/13.gif',
    'http://image.jeuxvideo.com/smileys_img/69.gif',
    'http://image.jeuxvideo.com/smileys_img/4.gif',
    'http://image.jeuxvideo.com/smileys_img/18.gif',
    'http://image.jeuxvideo.com/smileys_img/22.gif',
    'http://image.jeuxvideo.com/smileys_img/9.gif',
    'http://image.jeuxvideo.com/smileys_img/5.gif',
    '<img src="https://i.imgur.com/2tYuhWF.png" alt=":-)" class="smiley-script" id=":-)" title=":-)">))|<img src="http://image.jeuxvideo.com/smileys_img/23.gif" alt=":-)))" data-code=":-)))" title=":-)))">', // Correction du bug ':-)))' de JVP
    'http://image.jeuxvideo.com/smileys_img/57.gif',
    'http://image.jeuxvideo.com/smileys_img/10.gif',
    'http://image.jeuxvideo.com/smileys_img/nyu.gif',
    'http://image.jeuxvideo.com/smileys_img/24.gif',
    'http://image.jeuxvideo.com/smileys_img/7.gif',
    'http://image.jeuxvideo.com/smileys_img/31.gif',
    'http://image.jeuxvideo.com/smileys_img/11.gif',
    'http://image.jeuxvideo.com/smileys_img/37.gif',
    'http://image.jeuxvideo.com/smileys_img/45.gif',
    'http://image.jeuxvideo.com/smileys_img/47.gif',
    'http://image.jeuxvideo.com/smileys_img/2.gif',
    'http://image.jeuxvideo.com/smileys_img/26.gif',
    'http://image.jeuxvideo.com/smileys_img/14.gif',
    'http://image.jeuxvideo.com/smileys_img/54.gif',
    'http://image.jeuxvideo.com/smileys_img/21.gif',
    'http://image.jeuxvideo.com/smileys_img/39.gif',
    '<img src="https://i.imgur.com/Jbib383.png" alt=":-(" class="smiley-script" id=":-(" title=":-(">(|<img src="http://image.jeuxvideo.com/smileys_img/15.gif" alt=":-((" data-code=":-((" title=":-((">', // Correction du bug ':-((' de JVP
    'http://image.jeuxvideo.com/smileys_img/50.gif',
    'http://image.jeuxvideo.com/smileys_img/27.gif',
    'http://image.jeuxvideo.com/smileys_img/40.gif',
    'http://image.jeuxvideo.com/smileys_img/25.gif',
    'http://image.jeuxvideo.com/smileys_img/53.gif',
    'http://image.jeuxvideo.com/smileys_img/30.gif',
    'http://image.jeuxvideo.com/smileys_img/41.gif',
    'http://image.jeuxvideo.com/smileys_img/33.gif',
    'http://image.jeuxvideo.com/smileys_img/43.gif',
    'http://image.jeuxvideo.com/smileys_img/34.gif',
    'http://image.jeuxvideo.com/smileys_img/12.gif',
    'http://image.jeuxvideo.com/smileys_img/19.gif',
    'http://image.jeuxvideo.com/smileys_img/28.gif',
    'http://image.jeuxvideo.com/smileys_img/55.gif',
    'http://image.jeuxvideo.com/smileys_img/36.gif',
    'http://image.jeuxvideo.com/smileys_img/35.gif',
    'http://image.jeuxvideo.com/smileys_img/8.gif',
    'http://image.jeuxvideo.com/smileys_img/66.gif',
    'http://image.jeuxvideo.com/smileys_img/67.gif',
    'http://image.jeuxvideo.com/smileys_img/68.gif',
    'http://image.jeuxvideo.com/smileys_img/60.gif',
    'http://image.jeuxvideo.com/smileys_img/61.gif',
    'http://image.jeuxvideo.com/smileys_img/62.gif',
    'http://image.jeuxvideo.com/smileys_img/play.gif',
    'http://image.jeuxvideo.com/smileys_img/65.gif',
    'http://image.jeuxvideo.com/smileys_img/63.gif',
    'http://image.jeuxvideo.com/smileys_img/58.gif',
    'http://image.jeuxvideo.com/smileys_img/59.gif',
    'http://image.jeuxvideo.com/smileys_img/56.gif',
    'http://image.jeuxvideo.com/smileys_img/42.gif',
    'http://image.jeuxvideo.com/smileys_img/38.gif',
    'http://image.jeuxvideo.com/smileys_img/29.gif',
    'http://image.jeuxvideo.com/smileys_img/44.gif',
    'http://image.jeuxvideo.com/smileys_img/48.gif',
    'http://image.jeuxvideo.com/smileys_img/51.gif',
    'http://image.jeuxvideo.com/smileys_img/32.gif',
    'http://image.jeuxvideo.com/smileys_img/49.gif',
    'http://image.jeuxvideo.com/smileys_img/52.gif',
    'http://image.jeuxvideo.com/smileys_img/64.gif',
    'http://image.jeuxvideo.com/smileys_img/70.gif',
    'http://image.jeuxvideo.com/smileys_img/71.gif',
    'http://image.jeuxvideo.com/smileys_img/pf.gif',
    'http://image.jeuxvideo.com/smileys_img/cimer.gif',
    'http://image.jeuxvideo.com/smileys_img/ddb.gif',
    'http://image.jeuxvideo.com/smileys_img/pave.gif',
    'http://image.jeuxvideo.com/smileys_img/objection.gif',
    'http://image.jeuxvideo.com/smileys_img/siffle.gif'
  ],
  jvpVersion: [
    'https://i.imgur.com/uZUsavy.png', // :)
    'https://i.imgur.com/B8g6MpR.png',
    'https://i.imgur.com/2S2EUYW.png',
    'https://i.imgur.com/N8rdTjN.png',
    'https://i.imgur.com/zvHOnNE.png', // :-)
    'https://i.imgur.com/xPB49si.png',
    'https://i.imgur.com/VqxC9ub.gif',
    'https://i.imgur.com/7os0e8A.png',
    'https://i.imgur.com/rMUFfiU.png', // :hap:
    'https://i.imgur.com/oM6W9gy.gif',
    'https://i.imgur.com/OCxZ2tc.png',
    'https://i.imgur.com/vJJhBj0.png',
    '<img class="smiley-script" id=":-)))" src="https://i.imgur.com/rtb0Lir.gif" width="16" height="16" alt="">', // :-)))
    'https://i.imgur.com/bNWayUF.png',
    'https://i.imgur.com/cnSSt9f.png',
    'https://i.imgur.com/q9vPUrO.gif',
    'https://i.imgur.com/jfmlfjf.gif', // :content:
    'https://i.imgur.com/em7cuYw.png',
    'https://i.imgur.com/qxqt6Uo.gif',
    'https://i.imgur.com/jx56www.png',
    'https://i.imgur.com/zeOTze3.gif', // :oui:
    'https://i.imgur.com/xkjqmLw.png',
    'https://i.imgur.com/db8Zxhz.png',
    'https://i.imgur.com/Fmumncp.png',
    'https://i.imgur.com/0zJCack.gif', // :cool:
    'https://i.imgur.com/Jbib383.png',
    'https://i.imgur.com/ZKcWTHk.png',
    'https://i.imgur.com/ShEk6RC.png',
    'https://i.imgur.com/n32iMcR.gif', // :rire:
    '<img class="smiley-script" id=":-((" src="https://i.imgur.com/aC99EcU.png" width="16" height="16" alt="">',
    'https://i.imgur.com/v9i5woF.png',
    'https://i.imgur.com/hl4Drvw.gif',
    'https://i.imgur.com/1HtYDcI.png', // :-D
    'https://i.imgur.com/Wntuu0m.gif',
    'https://i.imgur.com/GTkMF6g.png',
    'https://i.imgur.com/mA4lXMj.gif',
    'https://i.imgur.com/xAKeWBU.gif', // :rire2:
    'https://i.imgur.com/W3umnXO.gif',
    'https://i.imgur.com/KS7qZIh.gif',
    'https://i.imgur.com/BthZDRm.gif',
    'https://i.imgur.com/j5jhuZI.png', // :o))
    'https://i.imgur.com/bGGQPQw.png',
    'https://i.imgur.com/ULvez05.gif',
    'https://i.imgur.com/ilaonlV.png',
    'https://i.imgur.com/3X0LSjj.png', // :ok:
    'https://i.imgur.com/IakFW2B.gif',
    'https://i.imgur.com/m4vNjFE.png',
    'https://i.imgur.com/4Ws3fmu.gif',
    'https://i.imgur.com/OYr4OUF.png', // :sournois:
    'https://i.imgur.com/Sq0YVIR.png',
    'https://i.imgur.com/m07LQbo.png',
    'https://i.imgur.com/ujBTBAp.png',
    'https://i.imgur.com/ZxU54gl.png', // :gni:
    'https://i.imgur.com/dT6X2p1.gif',
    'https://i.imgur.com/SIJE5JH.png',
    'https://i.imgur.com/kJzL0nt.png',
    'https://i.imgur.com/aMZ7PWu.png', // :merci:
    'https://i.imgur.com/nMKWUR9.png',
    'https://i.imgur.com/V2awUQ7.png',
    'https://i.imgur.com/OMyemx5.png',
    'https://i.imgur.com/DK1sEqi.png', // :rechercher:
    'https://i.imgur.com/Uwhc6YO.png',
    'https://i.imgur.com/Xab2p7Y.png',
    'https://i.imgur.com/R38d9qb.png',
    'https://i.imgur.com/2uSX1AJ.png', // :gne:
    'https://i.imgur.com/euqlnIx.gif',
    'https://i.imgur.com/jrRfucd.png',
    'https://i.imgur.com/hpb3aeD.png',
    'https://i.imgur.com/JmcXYcf.png', // :hs:
    'https://i.imgur.com/7LHv36j.gif',
    'https://i.imgur.com/muYcTkb.gif',
    'https://i.imgur.com/U5REFBn.png',
    'https://i.imgur.com/QYO35Am.gif', // :cimer:
    'https://i.imgur.com/kdTHV1O.png',
    'https://i.imgur.com/KPkYniX.png',
    'https://i.imgur.com/IKOKrc1.png',
    'https://i.imgur.com/7pDLnuI.png' // :siffle:
  ],
  dataCodes: [
    ':)',
    ':snif:',
    ':gba:',
    ':g)',
    ':-)',
    ':snif2:',
    ':bravo:',
    ':d)',
    ':hap:',
    ':ouch:',
    ':pacg:',
    ':cd:',
    ':-)))',
    ':ouch2:',
    ':pacd:',
    ':cute:',
    ':content:',
    ':p)',
    ':-p',
    ':noel:',
    ':oui:',
    ':(',
    ':peur:',
    ':question:',
    ':cool:',
    ':-(',
    ':coeur:',
    ':mort:',
    ':rire:',
    ':-((',
    ':fou:',
    ':sleep:',
    ':-D',
    ':nonnon:',
    ':fier:',
    ':honte:',
    ':rire2:',
    ':non2:',
    ':sarcastic:',
    ':monoeil:',
    ':o))',
    ':nah:',
    ':doute:',
    ':rouge:',
    ':ok:',
    ':non:',
    ':malade:',
    ':fete:',
    ':sournois:',
    ':hum:',
    ':ange:',
    ':diable:',
    ':gni:',
    ':play:',
    ':desole:',
    ':spoiler:',
    ':merci:',
    ':svp:',
    ':sors:',
    ':salut:',
    ':rechercher:',
    ':hello:',
    ':up:',
    ':bye:',
    ':gne:',
    ':lol:',
    ':dpdr:',
    ':dehors:',
    ':hs:',
    ':banzai:',
    ':bave:',
    ':pf:',
    ':cimer:',
    ':ddb:',
    ':pave:',
    ':objection:',
    ':siffle:'
  ]
};

const listeners = {
  modalRpc: function () {
    $('.btn-jv-editor-toolbar').click(function () {
      if ($(this).attr('title') === 'Smileys' && k === true) {
        setTimeout(function () {
          if (nostalgy === '1') {
            modalFunc.modalRpcNostalgy();
          }
          else if (nostalgy === '0') {
            modalFunc.modalRpc();
          }
        }, 500);
        k = false;
      }
    });
  },
  modalApd: function () {
    $('.btn-jv-editor-toolbar').click(function () {
      if ($(this).attr('title') === 'Smileys' && l === true) {
        setTimeout(function () {
          modalFunc.modalApd();
        }, 500);
        l = false;
      }
    });
  },
  smiley: function () {
    $('.smiley-script').click(function () {
      let $textarea = $('#message_topic');
      let caretPos = $textarea[0].selectionStart;
      let textAreaTxt = $textarea.val();
      let smiley = $(this).attr('id');
      $('#jv-smileys').attr('class', 'modal-generic');
      $('#jv-smileys').css('display', 'none');
      $('.modal-generic-overflow').removeClass('active');
      $('.modal-generic-overflow').css('display', 'none');
      $('html').removeClass('modal-generic-mode');
      $textarea.val(textAreaTxt.substring(0, caretPos) + smiley + textAreaTxt.substring(caretPos));
      $textarea.focus();
    });
  },
  btn: function () {
    $('#btn-script').click(function () {
      if (display === 'JVP' && undisplay === 'JVC-JVP') {
        localStorage.setItem('JVPS-displayMode', 'JVC-JVP');
        localStorage.setItem('JVPS-undisplayMode', 'JVP');
        location.reload();
      }
      else if (display === 'JVC-JVP' && undisplay === 'JVP') {
        localStorage.setItem('JVPS-displayMode', 'JVP');
        localStorage.setItem('JVPS-undisplayMode', 'JVC-JVP');
        location.reload();
      }
    });
  },
  checkbox: function () {
    $('#checkbox-script').click(function () {
      if (nostalgy === '0') {
        localStorage.setItem('JVPS-nostalgyMode', '1');
        location.reload();
      }
      else if (nostalgy === '1') {
        localStorage.setItem('JVPS-nostalgyMode', '0');
        location.reload();
      }
    });
  }
};

const modalFunc = {
  modalApd: function () {
    $('.modal-generic-content').append('<p style="float:left;margin-bottom: 0;margin-top: 0.9375rem;font-size: 0.84rem;">JVPSmileys ' + version + '</p>');
    $('.modal-generic-content').append('<style>' + style + '</style>');
    if (display === 'JVP') {
      $('.modal-generic-content').append('<button id="btn-script-disabled">JVP</button>');
      $('.modal-generic-content').append('<button id="btn-script">JVP-JVC</button>');
    }
    else if (display === 'JVC-JVP') {
      $('.modal-generic-content').append('<button id="btn-script">JVP</button>');
      $('.modal-generic-content').append('<button id="btn-script-disabled">JVP-JVC</button>');
    }
    if (nostalgy === '1') {
      $('.modal-generic-content').append('<p class="nostalgy-mode"><input id="checkbox-script" type="checkbox" checked> Mode hap&noel</p>');
    }
    else if (nostalgy === '0') {
      $('.modal-generic-content').append('<p class="nostalgy-mode"><input id="checkbox-script" type="checkbox"> Mode hap&noel</p>');
    }
    listeners.btn();
    listeners.checkbox();
  },

  modalRpc: function () {
    let e;
    let re;
    let reg;
    let str;
    e = $('.modal-generic-content td:even');

    e.each(function (i) {
      str = $(this).html();
      if (smileys.jvcVersion[i] === undefined) {
        return;
      }
      else if (i === 12 || i === 29) {
        $(this).html(smileys.jvpVersion[i]);
      }
      else {
        l = smileys.jvcVersion[i].split('http:');
        re = new RegExp(RegExp.escape(l[1]), 'g');
        reg = new RegExp(RegExp.escape('data-code="' + smileys.dataCodes[i] + '"'), 'g');

        str = str.replace(re, smileys.jvpVersion[i]);
        str = str.replace(reg, 'class="smiley-script" id="' + smileys.dataCodes[i] + '"');
        $(this).html(str);
      };
    });
    listeners.smiley();
  },

  modalRpcNostalgy: function () {
    let e;
    if (getPageType() === 'liste_topics_n5' || getPageType() === 'topicn5') {
      e = $('.modal-generic-content tr');
      e.remove();
      e = $('.modal-generic-content table');
      e.append('<tr><td></td><td></td><td></td><td></td></tr>');
      e = $('.modal-generic-content td:even');
      e.eq(0).append('<img class="smiley-script" id=":hap:" src="https://i.imgur.com/pJym5AL.png" width="16" height="16" alt=":hap:">');
      e.eq(1).append('<img class="smiley-script" id=":noel:" src="https://i.imgur.com/jx56www.png" width="16" height="16" alt=":noel:">');
      e.css('width', '65px');
      e = $('.modal-generic-content td:odd');
      e.eq(0).append(':hap:');
      e.eq(1).append(':noel:');
      e.css('width', '70px');
      listeners.smiley();
    }
    else if (getPageType() === 'liste_topics' || getPageType() === 'topicjvc') {
      e = $('.modal-generic-content tr');
      e.remove();
      e = $('.modal-generic-content table');
      e.append('<tr><td></td><td></td><td></td><td></td></tr>');
      e = $('.modal-generic-content td:even');
      e.eq(0).append('<img data-code=":hap:" src="//image.jeuxvideo.com/smileys_img/18.gif" width="16" height="16" alt=":hap:">');
      e.eq(1).append('<img data-code=":noel:" src="//image.jeuxvideo.com/smileys_img/11.gif" width="16" height="16" alt=":noel:">');
      e.css('width', '65px');
      e = $('.modal-generic-content td:odd');
      e.eq(0).append(':hap:');
      e.eq(1).append(':noel:');
      e.css('width', '70px');
      listeners.smiley();
    }
  }
};

const postFunc = {
  postRpc: function () {
    let e;
    let re;
    let reg;
    let str;
    if (window.location.href.indexOf('#ppp') > -1) {
      e = $('.txt-msg');
    }
    else {
      e = $('.bloc-contenu');
    }

    e.each(function () {
      str = $(this).html();
      for (let h = 0; h < smileys.jvcVersion.length; h++) {
        re = new RegExp(RegExp.escape(smileys.jvcVersion[h]), 'g');
        reg = new RegExp(RegExp.escape('data-code="' + smileys.dataCodes[h] + '"'), 'g');
        str = str.replace(re, smileys.jvpVersion[h]);
        str = str.replace(reg, 'class="smiley-script" id="' + smileys.dataCodes[h] + '"');
        $(this).html(str);
      }
    });
  },

  postRpcNostalgy: function () {
    let e;
    let re;
    let reg;
    let str;
    if (window.location.href.indexOf('#ppp') > -1) {
      e = $('.txt-msg');
      e.each(function () {
        str = $(this).html();
        re = new RegExp('<img src="http:\/\/image\.jeuxvideo\.com\/smileys_img\/((?!18|11).*?)\.gif" alt=":.*?" data-code=".*?" title=".*?">', 'g');
        str = str.replace(re, '');
        re = new RegExp('<img src="http:\/\/image\.jeuxvideo\.com\/smileys_img\/18\.gif" alt=":hap:" data-code=":hap:" title=":hap:">', 'g');
        reg = new RegExp('<img src="http:\/\/image\.jeuxvideo\.com\/smileys_img\/11\.gif" alt=":noel:" data-code=":noel:" title=":noel:">', 'g');
        str = str.replace(re, '<img class="smiley-script" id=":hap:" src="https://i.imgur.com/pJym5AL.png" width="16" height="16" alt=":hap:">');
        str = str.replace(reg, '<img class="smiley-script" id=":noel:" src="https://i.imgur.com/jx56www.png" width="16" height="16" alt=":noel:">');
        $(this).html(str);
      });
    }
    else {
      e = $('.bloc-contenu');
      e.each(function () {
        str = $(this).html();
        re = new RegExp('<img src="http:\/\/image\.jeuxvideo\.com\/smileys_img\/((?!18|11).*?)\.gif" alt=":.*?" data-code=".*?" title=".*?">', 'g');
        str = str.replace(re, '');
        re = new RegExp('<img src="http:\/\/image\.jeuxvideo\.com\/smileys_img\/18\.gif" alt=":hap:" data-code=":hap:" title=":hap:">', 'g');
        reg = new RegExp('<img src="http:\/\/image\.jeuxvideo\.com\/smileys_img\/11\.gif" alt=":noel:" data-code=":noel:" title=":noel:">', 'g');
        str = str.replace(re, '<img class="smiley-script" id=":hap:" src="https://i.imgur.com/pJym5AL.png" width="16" height="16" alt=":hap:">');
        str = str.replace(reg, '<img class="smiley-script" id=":noel:" src="https://i.imgur.com/jx56www.png" width="16" height="16" alt=":noel:">');
        $(this).html(str);
      });
    }
  }
};

function reStyle() {
  if ($('body').css('background-color') === 'rgb(18, 18, 18)') {
    $('.txt-msg').children().not('blockquote').css('color', '#B8B8AA');
    $('blockquote p').css('color', '#7e8081');
  }
}

function getPageType() {
  let url = window.location.href;
  return url.match(/^https?:\/\/(?:www\.)?jeuxvideo\.com\/forums\/[1-9]+\-/) ? 'topicjvc' : (
    url.match(/^https?:\/\/(?:www\.)?jeuxvideo\.com\/forums\/0\-[^#]+#pppf/) ? 'liste_topics_n5' : (
      url.match(/^https?:\/\/(?:www\.)?jeuxvideo\.com\/forums\/0\-[^#]+#ppp?/) ? 'topicn5' : (
        url.match(/^https?:\/\/(?:www\.)?jeuxvideo\.com\/forums\/0\-/) ? 'liste_topics' : (
          null))));
}

$(document).on('ppploaded', function () {
  if (nostalgy == '1') {
    if (display == 'JVP') {
      if (getPageType() == 'liste_topics_n5') {
        listeners.modalApd();
        listeners.modalRpc();
      }
      else if (getPageType() == 'topicn5') {
        reStyle();
        listeners.modalApd();
        listeners.modalRpc();
        postFunc.postReplaceNostalgy();
      }
      else if (getPageType() == 'liste_topics') {
        listeners.modalApd();
      }
      else if (getPageType() == 'topicjvc') {
        listeners.modalApd();
      }
    }
    else if (display == 'JVC-JVP') {
      if (getPageType() == 'liste_topics_n5') {
        listeners.modalApd();
        listeners.modalRpc();
      }
      else if (getPageType() == 'topicn5') {
        reStyle();
        listeners.modalApd();
        listeners.modalRpc();
        postFunc.postReplaceNostalgy();
      }
      else if (getPageType() == 'liste_topics') {
        listeners.modalApd();
        listeners.modalRpc();
      }
      else if (getPageType() == 'topicjvc') {
        listeners.modalApd();
        listeners.modalRpc();
        postFunc.postReplaceNostalgy();
      }
    }
  }
  else if (nostalgy == '0') {
    if (display == 'JVP') {
      if (getPageType() == 'liste_topics_n5') {
        listeners.modalApd();
        listeners.modalRpc();
      }
      else if (getPageType() == 'topicn5') {
        reStyle();
        listeners.modalApd();
        listeners.modalRpc();
        postFunc.postRpc();
      }
      else if (getPageType() == 'liste_topics') {
        listeners.modalApd();
      }
      else if (getPageType() == 'topicjvc') {
        listeners.modalApd();
      }
    }
    else if (display == 'JVC-JVP') {
      if (getPageType() == 'liste_topics_n5') {
        listeners.modalApd();
        listeners.modalRpc();
      }
      else if (getPageType() == 'topicn5') {
        reStyle();
        listeners.modalApd();
        listeners.modalRpc();
        postFunc.postRpc();
      }
      else if (getPageType() == 'liste_topics') {
        listeners.modalApd();
        listeners.modalRpc();
      }
      else if (getPageType() == 'topicjvc') {
        listeners.modalApd();
        listeners.modalRpc();
        postFunc.postRpc();
        postFunc.postRpc();
      }
    }
  }
});