From af3ba41c7e3b4ebf32f1aebbf0fdc8827eca8e3b Mon Sep 17 00:00:00 2001 From: rudolfkoenig Date: Tue, 19 Apr 2016 15:55:25 +0000 Subject: [PATCH] fhemweb.js: CodeMirror patch from rapster (Forum #52379) git-svn-id: https://svn.fhem.de/fhem/trunk@11287 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/www/pgm2/fhemweb.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/fhem/www/pgm2/fhemweb.js b/fhem/www/pgm2/fhemweb.js index 5ce6bb15c..28286a3e5 100644 --- a/fhem/www/pgm2/fhemweb.js +++ b/fhem/www/pgm2/fhemweb.js @@ -475,6 +475,14 @@ FW_inlineModify() // Do not generate a new HTML page upon pressing modify { var cm; + 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] ); + } + } + $('#DEFa').click(function(){ var old = $('#edit').css('display'); $('#edit').css('display', old=='none' ? 'block' : 'none'); @@ -810,8 +818,10 @@ FW_createTextField(elName, devName, vArr, currVal, set, params, cmd) $("#td_longText").val(txt); var cm; - if( typeof AddCodeMirror == 'function' ) + if( typeof AddCodeMirror == 'function' && !$("#td_longText").get(0).editor) { + $("#td_longText").get(0).editor = true; AddCodeMirror($("#td_longText").get(0), function(pcm) {cm = pcm;}); + } $('#editdlg').dialog( { modal:true, closeOnEscape:true, width:$(window).width()*3/4,