From d6a42edd1bfd813d2863259197e76a89ce62b0b3 Mon Sep 17 00:00:00 2001 From: rudolfkoenig Date: Tue, 26 Dec 2017 13:47:50 +0000 Subject: [PATCH] fhem_codemirror.js/fhemweb.js: enable codemirror in rawdefinition (Forum #81595) git-svn-id: https://svn.fhem.de/fhem/trunk@15695 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/www/codemirror/fhem_codemirror.js | 10 +++++++ fhem/www/pgm2/fhemweb.js | 41 ++++++++++++++++---------- 2 files changed, 36 insertions(+), 15 deletions(-) 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('
'+ - '