1818
1919editor = null ;
2020
21- $ ( function ( ) {
21+ $ ( function ( ) {
2222 $ ( '#md_browseScriptFile, #md_editScriptFile' ) . removeClass ( 'hidden' )
2323} )
2424
@@ -33,20 +33,20 @@ $("#md_browseScriptFile").dialog({
3333$ ( "#table_cmd tbody" ) . delegate ( ".cmdAttr[data-l1key=configuration][data-l2key=requestType]" , 'change' , function ( event ) {
3434 $ ( this ) . closest ( 'tr' ) . find ( '.requestTypeConfig' ) . hide ( ) ;
3535 $ ( this ) . closest ( 'tr' ) . find ( '.requestTypeConfig[data-type=' + $ ( this ) . value ( ) + ']' ) . show ( ) ;
36- if ( $ ( this ) . value ( ) == 'script' ) {
36+ if ( $ ( this ) . value ( ) == 'script' ) {
3737 $ ( this ) . closest ( 'tr' ) . find ( '.browseScriptFile' ) . show ( ) ;
3838 $ ( this ) . closest ( 'tr' ) . find ( '.editScriptFile' ) . show ( ) ;
3939 $ ( this ) . closest ( 'tr' ) . find ( '.removeScriptFile' ) . show ( ) ;
4040 $ ( this ) . closest ( 'tr' ) . find ( '.newScriptFile' ) . show ( ) ;
41-
41+
4242 $ ( this ) . closest ( 'tr' ) . find ( '.tdRequest' ) . attr ( 'colspan' , '2' ) ;
4343 $ ( this ) . closest ( 'tr' ) . find ( '.tdOptions' ) . hide ( ) ;
44- } else {
44+ } else {
4545 $ ( this ) . closest ( 'tr' ) . find ( '.browseScriptFile' ) . hide ( ) ;
4646 $ ( this ) . closest ( 'tr' ) . find ( '.editScriptFile' ) . hide ( ) ;
4747 $ ( this ) . closest ( 'tr' ) . find ( '.removeScriptFile' ) . hide ( ) ;
4848 $ ( this ) . closest ( 'tr' ) . find ( '.newScriptFile' ) . hide ( ) ;
49-
49+
5050 $ ( this ) . closest ( 'tr' ) . find ( '.tdRequest' ) . attr ( 'colspan' , '1' ) ;
5151 $ ( this ) . closest ( 'tr' ) . find ( '.tdOptions' ) . show ( ) ;
5252 }
@@ -61,14 +61,14 @@ $("#table_cmd tbody").delegate(".browseScriptFile", 'click', function (event) {
6161 folderEvent : 'click'
6262 } , function ( file ) {
6363 $ ( "#md_browseScriptFile" ) . dialog ( 'close' ) ;
64- if ( userScriptDir . slice ( - 1 ) == '/' && file . slice ( 0 , 1 ) == '/' ) {
64+ if ( userScriptDir . slice ( - 1 ) == '/' && file . slice ( 0 , 1 ) == '/' ) {
6565 file = file . slice ( 1 ) ;
6666 }
67- tr . find ( '.cmdAttr[data-l1key=configuration][data-l2key=request]' ) . value ( userScriptDir + file ) ;
67+ tr . find ( '.cmdAttr[data-l1key=configuration][data-l2key=request]' ) . value ( userScriptDir + file ) ;
6868 } ) ;
6969} ) ;
7070
71- $ ( "#table_cmd" ) . sortable ( { axis : "y" , cursor : "move" , items : ".cmd" , placeholder : "ui-state-highlight" , tolerance : "intersect" , forcePlaceholderSize : true } ) ;
71+ $ ( "#table_cmd" ) . sortable ( { axis : "y" , cursor : "move" , items : ".cmd" , placeholder : "ui-state-highlight" , tolerance : "intersect" , forcePlaceholderSize : true } ) ;
7272
7373$ ( "#md_editScriptFile" ) . dialog ( {
7474 autoOpen : false ,
@@ -78,8 +78,8 @@ $("#md_editScriptFile").dialog({
7878 closeText : ''
7979} ) ;
8080
81- $ ( '#bt_cronGenerator' ) . on ( 'click' , function ( ) {
82- jeedom . getCronSelectModal ( { } , function ( result ) {
81+ $ ( '#bt_cronGenerator' ) . on ( 'click' , function ( ) {
82+ jeedom . getCronSelectModal ( { } , function ( result ) {
8383 $ ( '.eqLogicAttr[data-l1key=configuration][data-l2key=autorefresh]' ) . value ( result . value ) ;
8484 } ) ;
8585} ) ;
@@ -94,7 +94,7 @@ $("#table_cmd tbody").delegate(".editScriptFile", 'click', function (event) {
9494 if ( data === false ) {
9595 return ;
9696 }
97-
97+
9898 if ( editor != null ) {
9999 editor . getDoc ( ) . setValue ( data . content ) ;
100100 editor . setOption ( "mode" , data . mode ) ;
@@ -119,22 +119,22 @@ $("#table_cmd tbody").delegate(".editScriptFile", 'click', function (event) {
119119 "Ctrl-Y" : cm => CodeMirror . commands . foldAll ( cm ) ,
120120 "Ctrl-I" : cm => CodeMirror . commands . unfoldAll ( cm )
121121 } )
122-
122+
123123 $ ( '.ui-dialog[aria-describedby="md_editScriptFile"] .CodeMirror-wrap' ) . css ( "height" , $ ( window ) . height ( ) - 80 )
124-
124+
125125 editor . refresh ( ) ;
126-
127- $ ( '.ui-dialog[aria-describedby="md_editScriptFile"]' ) . resize ( function ( ) {
126+
127+ $ ( '.ui-dialog[aria-describedby="md_editScriptFile"]' ) . resize ( function ( ) {
128128 editor . getWrapperElement ( ) . style . height = ( $ ( '#md_editScriptFile' ) . height ( ) ) + 'px' ;
129129 editor . refresh ( )
130130 } )
131-
131+
132132 if ( foldOnStart == "1" ) {
133133 CodeMirror . commands . foldAll ( editor )
134134 }
135135 } , 1 ) ;
136136 }
137-
137+
138138 $ ( "#md_editScriptFile" ) . dialog ( 'option' , 'buttons' , {
139139 "Annuler" : function ( ) {
140140 $ ( this ) . dialog ( "close" ) ;
@@ -179,7 +179,7 @@ $("#table_cmd tbody").delegate(".removeScriptFile", 'click', function (event) {
179179 } ) ;
180180} ) ;
181181
182- $ ( "#table_cmd" ) . sortable ( { axis : "y" , cursor : "move" , items : ".cmd" , placeholder : "ui-state-highlight" , tolerance : "intersect" , forcePlaceholderSize : true } ) ;
182+ $ ( "#table_cmd" ) . sortable ( { axis : "y" , cursor : "move" , items : ".cmd" , placeholder : "ui-state-highlight" , tolerance : "intersect" , forcePlaceholderSize : true } ) ;
183183
184184function addCmdToTable ( _cmd ) {
185185 if ( ! isset ( _cmd ) ) {
@@ -191,17 +191,17 @@ function addCmdToTable(_cmd) {
191191 if ( init ( _cmd . logicalId ) == 'refresh' ) {
192192 return ;
193193 }
194-
194+
195195 var selRequestType = '<select style="width : 90px;" class="cmdAttr form-control input-sm" data-l1key="configuration" data-l2key="requestType">' ;
196196 selRequestType += '<option value="script">{{Script}}</option>' ;
197197 selRequestType += '<option value="http">{{HTTP}}</option>' ;
198198 selRequestType += '<option value="html">{{HTML}}</option>' ;
199199 selRequestType += '<option value="xml">{{XML}}</option>' ;
200200 selRequestType += '<option value="json">{{JSON}}</option>' ;
201201 selRequestType += '</select>' ;
202-
202+
203203 var tr = '<tr class="cmd" data-cmd_id="' + init ( _cmd . id ) + '">' ;
204-
204+
205205 tr += '<td>' ;
206206 tr += '<input class="cmdAttr form-control input-sm" data-l1key="id" style="display : none;">' ;
207207 tr += '<div class="row">' ;
@@ -223,6 +223,7 @@ function addCmdToTable(_cmd) {
223223 tr += '<span class="type" type="' + init ( _cmd . type ) + '">' + jeedom . cmd . availableType ( ) + '</span>' ;
224224 tr += '<span class="subType" subType="' + init ( _cmd . subType ) + '"></span>' ;
225225 tr += '</td>' ;
226+
226227 tr += '<td class="tdRequest">' ;
227228 tr += '<div class="btn-group" role="group">' ;
228229 tr += '<span class="input-group" style="margin-top : 5px;">' ;
@@ -234,8 +235,8 @@ function addCmdToTable(_cmd) {
234235 tr += '</div>' ;
235236 tr += '<textarea style="height : 95px;margin-top:5px;" class="cmdAttr form-control input-sm" data-l1key="configuration" data-l2key="request"></textarea>' ;
236237 tr += '</td>' ;
238+
237239 tr += '<td class="tdOptions">' ;
238-
239240 tr += '<div class="requestTypeConfig" data-type="http">' ;
240241 tr += '<center>' ;
241242 tr += '<input type="checkbox" class="cmdAttr" data-l1key="configuration" data-l2key="noSslCheck" />{{Vérifier SSL}} ' ;
@@ -254,7 +255,7 @@ function addCmdToTable(_cmd) {
254255 tr += '</div>' ;
255256 tr += '</div>' ;
256257 tr += '</div>' ;
257-
258+
258259 tr += '<div class="requestTypeConfig" data-type="xml" style="display : none;">' ;
259260 tr += '<input class="cmdAttr form-control input-sm" data-l1key="configuration" data-l2key="urlXml" placeholder="URL du fichier XML"/>' ;
260261 tr += '<center class="btn-sm">' ;
@@ -271,7 +272,7 @@ function addCmdToTable(_cmd) {
271272 tr += '</div>' ;
272273 tr += '</div>' ;
273274 tr += '</div>' ;
274-
275+
275276 tr += '<div class="requestTypeConfig" data-type="html" style="display : none;">' ;
276277 tr += '<input class="cmdAttr form-control input-sm" data-l1key="configuration" data-l2key="urlHtml" placeholder="URL du HTML"/>' ;
277278 tr += '<span><label class="checkbox-inline"><input type="checkbox" class="cmdAttr" data-l1key="configuration" data-l2key="htmlNoSslCheck"/>{{Vérifier SSL}}</label></span> ' ;
@@ -286,7 +287,7 @@ function addCmdToTable(_cmd) {
286287 tr += '</div>' ;
287288 tr += '</div>' ;
288289 tr += '</div>' ;
289-
290+
290291 tr += '<div class="requestTypeConfig" data-type="json" style="display : none;">' ;
291292 tr += '<input class="cmdAttr form-control input-sm" data-l1key="configuration" data-l2key="urlJson" placeholder="URL du fichier JSON"/>' ;
292293 tr += '<center class="btn-sm">' ;
@@ -304,54 +305,53 @@ function addCmdToTable(_cmd) {
304305 tr += '</div>' ;
305306 tr += '</div>' ;
306307 tr += '</td>' ;
307- tr += '<td>' ;
308- tr += '<input class="cmdAttr form-control input-sm" data-l1key="unite" style="width : 100px;" placeholder="{{Unité}}" title="{{Unité}}" >' ;
309- tr += '<input class="tooltips cmdAttr form-control input-sm" data-l1key="configuration" data-l2key="minValue" placeholder="{{Min}}" title="{{Min}} style="margin-top : 3px;"> ' ;
310- tr += '<input class="tooltips cmdAttr form-control input-sm" data-l1key="configuration" data-l2key="maxValue" placeholder="{{Max}}" title="{{Max}} style="margin-top : 3px;">' ;
308+
309+ tr += '<td>'
310+ tr += '<label class="checkbox-inline"><input type="checkbox" class="cmdAttr" data-l1key="isVisible" checked/>{{Afficher}}</label> '
311+ tr += '<label class="checkbox-inline"><input type="checkbox" class="cmdAttr" data-l1key="isHistorized" checked/>{{Historiser}}</label> '
312+ tr += '<label class="checkbox-inline"><input type="checkbox" class="cmdAttr" data-l1key="display" data-l2key="invertBinary"/>{{Inverser}}</label> '
313+ tr += '<div style="margin-top:7px;">'
314+ tr += '<input class="tooltips cmdAttr form-control input-sm" data-l1key="configuration" data-l2key="minValue" placeholder="{{Min}}" title="{{Min}}" style="width:30%;max-width:80px;display:inline-block;margin-right:2px;">'
315+ tr += '<input class="tooltips cmdAttr form-control input-sm" data-l1key="configuration" data-l2key="maxValue" placeholder="{{Max}}" title="{{Max}}" style="width:30%;max-width:80px;display:inline-block;margin-right:2px;">'
316+ tr += '<input class="tooltips cmdAttr form-control input-sm" data-l1key="unite" placeholder="Unité" title="{{Unité}}" style="width:30%;max-width:80px;display:inline-block;margin-right:2px;">'
317+ tr += '<input class="tooltips cmdAttr form-control input-sm" data-l1key="configuration" data-l2key="listValue" placeholder="{{Liste de valeur|texte séparé par ;}}" title="{{Liste}}" style="margin-top : 5px;">' ;
318+ tr += '</div>'
319+
311320 tr += '<select class="cmdAttr form-control input-sm" data-l1key="configuration" data-l2key="updateCmdId" style="display : none;margin-top : 5px;" title="{{Commande d\'information à mettre à jour}}">' ;
312321 tr += '<option value="">{{Aucune}}</option>' ;
313322 tr += '</select>' ;
314323 tr += '<input class="tooltips cmdAttr form-control input-sm" data-l1key="configuration" data-l2key="updateCmdToValue" placeholder="{{Valeur de l\'information}}" style="display : none;margin-top : 3px;">' ;
315324 tr += '</td>' ;
325+
316326 tr += '<td>' ;
317- tr += '<center>' ;
318- tr += '<input class="tooltips cmdAttr form-control input-sm" data-l1key="configuration" data-l2key="listValue" placeholder="{{Liste de valeur|texte séparé par ;}}" title="{{Liste}}" style="margin-top : 5px;">' ;
319- tr += '<span><label class="checkbox-inline"><input type="checkbox" class="cmdAttr checkbox-inline" data-l1key="isVisible" checked/>{{Afficher}}</label><span> ' ;
320- tr += '<span><label class="checkbox-inline"><input type="checkbox" class="cmdAttr checkbox-inline" data-l1key="isHistorized" checked/>{{Historiser}}</label></span> ' ;
321- tr += '<span><label class="checkbox-inline"><input type="checkbox" class="cmdAttr" data-l1key="display" data-l2key="invertBinary"/>{{Inverser}}</label></span> ' ;
322- tr += '</center>' ;
323- tr += '</td>' ;
324- tr += '<td>' ;
325- tr += '<span class="cmdAttr" data-l1key="htmlstate"></span>' ;
327+ tr += '<span class="cmdAttr" data-l1key="htmlstate"></span>' ;
326328 tr += '</td>' ;
327329 tr += '<td>' ;
328330 if ( is_numeric ( _cmd . id ) ) {
329- tr += '<a class="btn btn-default btn-xs cmdAction" data-action="configure" title="{{Configuration de la commande}}""><i class="fas fa-cogs"></i></a> ' ;
330- if ( init ( _cmd . type ) == 'action' ) {
331- tr += '<a class="btn btn-default btn-xs cmdAction" data-action="test"><i class="fas fa-rss"></i> {{Tester}}</a>' ;
332- }
331+ tr += '<a class="btn btn-default btn-xs cmdAction" data-action="configure"><i class="fas fa-cogs"></i></a> '
332+ tr += '<a class="btn btn-default btn-xs cmdAction" data-action="test"><i class="fas fa-rss"></i> Tester</a>'
333333 }
334334 tr += ' <a class="btn btn-default btn-xs cmdAction" data-action="copy" title="Dupliquer"><i class="far fa-clone"></i></a> ' ;
335335 tr += '<i class="fas fa-minus-circle pull-right cmdAction cursor" data-action="remove"></i></td>' ;
336336 tr += '</tr>' ;
337-
337+
338338 $ ( '#table_cmd tbody' ) . append ( tr ) ;
339339 $ ( '#table_cmd tbody tr:last' ) . setValues ( _cmd , '.cmdAttr' ) ;
340-
340+
341341 if ( isset ( _cmd . configuration . requestType ) ) {
342342 $ ( '#table_cmd tbody tr:last .cmdAttr[data-l1key=configuration][data-l2key=requestType]' ) . value ( init ( _cmd . configuration . requestType ) ) ;
343343 $ ( '#table_cmd tbody tr:last .cmdAttr[data-l1key=configuration][data-l2key=requestType]' ) . trigger ( 'change' ) ;
344344 }
345-
345+
346346 if ( isset ( _cmd . type ) ) {
347347 $ ( '#table_cmd tbody tr:last .cmdAttr[data-l1key=type]' ) . value ( init ( _cmd . type ) ) ;
348348 }
349349 var tr = $ ( '#table_cmd tbody tr:last' ) ;
350350 jeedom . eqLogic . builSelectCmd ( {
351- id : $ ( '.eqLogicAttr[data-l1key=id]' ) . value ( ) ,
352- filter : { type : 'info' } ,
351+ id : $ ( '.eqLogicAttr[data-l1key=id]' ) . value ( ) ,
352+ filter : { type : 'info' } ,
353353 error : function ( error ) {
354- $ ( '#div_alert' ) . showAlert ( { message : error . message , level : 'danger' } ) ;
354+ $ ( '#div_alert' ) . showAlert ( { message : error . message , level : 'danger' } ) ;
355355 } ,
356356 success : function ( result ) {
357357 tr . find ( '.cmdAttr[data-l1key=value]' ) . append ( result ) ;
@@ -393,29 +393,29 @@ function loadScriptFile(_path) {
393393 } ,
394394 success : function ( data ) {
395395 if ( data . state != 'ok' ) {
396- $ ( '#div_alert' ) . showAlert ( { message : data . result , level : 'danger' } ) ;
396+ $ ( '#div_alert' ) . showAlert ( { message : data . result , level : 'danger' } ) ;
397397 return false ;
398398 }
399399 result = data . result ;
400400 switch ( result . extension ) {
401- case 'php' :
402- result . mode = 'text/x-php' ;
403- break ;
404- case 'sh' :
405- result . mode = 'shell' ;
406- break ;
407- case 'pl' :
408- result . mode = 'text/x-php' ;
409- break ;
410- case 'py' :
411- result . mode = 'text/x-python' ;
412- break ;
413- case 'rb' :
414- result . mode = 'text/x-ruby' ;
415- break ;
416- default :
417- result . mode = 'text/x-php' ;
418- break ;
401+ case 'php' :
402+ result . mode = 'text/x-php' ;
403+ break ;
404+ case 'sh' :
405+ result . mode = 'shell' ;
406+ break ;
407+ case 'pl' :
408+ result . mode = 'text/x-php' ;
409+ break ;
410+ case 'py' :
411+ result . mode = 'text/x-python' ;
412+ break ;
413+ case 'rb' :
414+ result . mode = 'text/x-ruby' ;
415+ break ;
416+ default :
417+ result . mode = 'text/x-php' ;
418+ break ;
419419 }
420420 }
421421 } ) ;
@@ -440,11 +440,11 @@ function saveScriptFile(_path, _content) {
440440 } ,
441441 success : function ( data ) {
442442 if ( data . state != 'ok' ) {
443- $ ( '#div_editScriptFileAlert' ) . showAlert ( { message : data . result , level : 'danger' } ) ;
443+ $ ( '#div_editScriptFileAlert' ) . showAlert ( { message : data . result , level : 'danger' } ) ;
444444 return ;
445445 }
446446 success = true ;
447- $ ( '#div_editScriptFileAlert' ) . showAlert ( { message : 'Script sauvegardé' , level : 'success' } ) ;
447+ $ ( '#div_editScriptFileAlert' ) . showAlert ( { message : 'Script sauvegardé' , level : 'success' } ) ;
448448 }
449449 } ) ;
450450 return success ;
@@ -467,7 +467,7 @@ function addUserScript(_name) {
467467 } ,
468468 success : function ( data ) {
469469 if ( data . state != 'ok' ) {
470- $ ( '#div_newUserScriptAlert' ) . showAlert ( { message : data . result , level : 'danger' } ) ;
470+ $ ( '#div_newUserScriptAlert' ) . showAlert ( { message : data . result , level : 'danger' } ) ;
471471 return ;
472472 }
473473 success = data . result ;
@@ -493,10 +493,10 @@ function removeScript(_path) {
493493 } ,
494494 success : function ( data ) { // si l'appel a bien fonctionné
495495 if ( data . state != 'ok' ) {
496- $ ( '#div_newUserScriptAlert' ) . showAlert ( { message : data . result , level : 'danger' } ) ;
496+ $ ( '#div_newUserScriptAlert' ) . showAlert ( { message : data . result , level : 'danger' } ) ;
497497 return ;
498498 }
499- $ ( '#div_alert' ) . showAlert ( { message : 'Script supprimé' , level : 'success' } ) ;
499+ $ ( '#div_alert' ) . showAlert ( { message : 'Script supprimé' , level : 'success' } ) ;
500500 success = true ;
501501 }
502502 } ) ;
0 commit comments