$(document).ready(function () {
  $('[texteditor="true"]').each(function () {
    var editor = CodeMirror.fromTextArea(this, {
      lineNumbers: false,
      lineWrapping: false,
      mode: 'default'
    });

    $('[containerdetailbutton]').click(function()
    {
      editor.refresh();
    });
  });

  $('[codeeditor="true"]').each(function () {

    var currentTheme = $(this).attr('theme');
    if(currentTheme == undefined){
      currentTheme = 'dracula';
    }

    var currentLanguage = $(this).attr('language');
    if(currentLanguage == undefined){
      currentLanguage = 'manticore';
    }

    var editor = CodeMirror.fromTextArea(this, {
      lineNumbers: true,
      lineWrapping: false,
      theme: currentTheme,
      mode: currentLanguage
    });

    $('[containerdetailbutton]').click(function()
    {
      editor.refresh();
    });

  });
});
