diff --git a/fhem/www/codemirror/fhem_codemirror.js b/fhem/www/codemirror/fhem_codemirror.js index dda5ae96c..8b3cbd8da 100644 --- a/fhem/www/codemirror/fhem_codemirror.js +++ b/fhem/www/codemirror/fhem_codemirror.js @@ -57,6 +57,16 @@ var cm_attr = { }; function AddCodeMirror(e, cb) { + if(e instanceof jQuery) { + AddCodeMirror(e.get(0), cb); + return; + } + + if(e == undefined || e.editor) { + return; + } + e.editor = true; + if(cm_active && cm_loaded == cm_active) return cm_wait(e, cb); diff --git a/fhem/www/pgm2/fhemweb.js b/fhem/www/pgm2/fhemweb.js index 5daf49e3d..9584fc18c 100644 --- a/fhem/www/pgm2/fhemweb.js +++ b/fhem/www/pgm2/fhemweb.js @@ -644,10 +644,7 @@ FW_inlineModify() // Do not generate a new HTML page upon pressing modify if( typeof AddCodeMirror == 'function' ) { // init codemirror for FW_style edit textarea - var s = $('textarea[name="data"]'); - if( s.length && !s[0].editor ) { - s[0].editor = true; AddCodeMirror( s[0] ); - } + AddCodeMirror($('textarea[name="data"]')); } $('#DEFa').click(function(){ @@ -656,9 +653,7 @@ FW_inlineModify() // Do not generate a new HTML page upon pressing modify $('#disp').css('display', old=='none' ? 'none' : 'block'); if( typeof AddCodeMirror == 'function' ) { var s=document.getElementById("edit").getElementsByTagName("textarea"); - if(!s[0].editor) { - s[0].editor=true; AddCodeMirror(s[0], function(pcm) {cm = pcm;}); - } + AddCodeMirror(s[0], function(pcm) {cm = pcm;}); } }); @@ -722,31 +717,48 @@ FW_rawDef() $("#rawDef").remove(); return; } + var textAreaStyle = typeof AddCodeMirror == 'function'?'opacity:0':''; $("#content").append('
'+ - '