UNPKG

153 kBHTMLView Raw
1<!--
2 Copyright 2013,2014 bluefox<bluefox@ccu.io>.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15-->
16
17<script type="text/x-red" data-template-name="ioBroker in">
18 <div class="form-row">
19 <label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label>
20 <input type="text" id="node-input-topic" placeholder="Topic" style="width:60%"><input type="button" id="node-input-topic-button" style="display:inline-block;width:10%" value="."/>
21 </div>
22 <div id="dialog-select-member" style="display:none"></div>
23 <div class="form-row">
24 <label for="node-input-payloadType"><i class="fa fa-envelope"></i> Payload</label>
25 <select id="node-input-payloadType" style="width:125px !important">
26 <option value="value">value</option>
27 <option value="object">object</option>
28 </select>
29 </div>
30 <div class="form-row">
31 <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
32 <input type="text" id="node-input-name" placeholder="Name">
33 </div>
34 <div class="form-row">
35 <label>&nbsp;</label>
36 <input type="checkbox" id="node-input-onlyack" style="display: inline-block; width: auto; vertical-align: top;">
37 <label for="node-input-onlyack" style="width: 70%;">Send only on then ack==true</label>
38 </div>
39 <div class="form-row">
40 <label for="node-input-func"><i class="fa fa-wrench"></i> Mode</label>
41 <select type="text" id="node-input-func" style="width:74%;">
42 <option value="all">Send all events</option>
43 <option value="rbe">block unless value changes</option>
44 <option value="deadband">block unless changes by more than</option>
45 </select>
46 </div>
47 <div class="form-row" id="node-bandgap">
48 <label for="node-input-gap">&nbsp;</label>
49 <input type="text" id="node-input-gap" placeholder="e.g. 10 or 5%" style="width:71%;">
50 </div>
51</script>
52
53<script type="text/x-red" data-help-name="ioBroker in">
54 <p>ioBroker input node. Connects to a ioBroker and subscribes to the specified topic. The topic may contain redis wildcards (*).</p>
55 <p>Outputs an object called <b>msg</b> containing <b>msg.topic, msg.payload, msg.timestamp, msg.lastchange and msg.acknowledged.</p>
56 <p>The checkbox determines whether only States with ack == true or all events are forwarded.</p>
57 <p>The select box Mode offers further filtering options. The options are the same as for the RBE node.</p>
58
59</script>
60<style type="text/css">
61 /* --------------------------- ui.fancytree.min.css ----------------------------------------------------- */
62 /*!
63 * Fancytree "Win7" skin.
64 *
65 * DON'T EDIT THE CSS FILE DIRECTLY, since it is automatically generated from
66 * the LESS templates.
67 */
68 .ui-helper-hidden{display:none}ul.fancytree-container{font-family:tahoma,arial,helvetica;font-size:10pt;white-space:nowrap;padding:3px;margin:0;background-color:#fff;border:1px dotted gray;overflow:auto;min-height:0;position:relative}ul.fancytree-container ul{padding:0 0 0 16px;margin:0}ul.fancytree-container li{list-style-image:none;list-style-position:outside;list-style-type:none;-moz-background-clip:border;-moz-background-inline-policy:continuous;-moz-background-origin:padding;background-attachment:scroll;background-color:transparent;background-position:0 0;background-repeat:repeat-y;background-image:none;margin:0;padding:1px 0 0}ul.fancytree-container li.fancytree-lastsib,ul.fancytree-no-connector>li{background-image:none}.ui-fancytree-disabled ul.fancytree-container{opacity:.5;background-color:silver}#fancytree-drop-marker,span.fancytree-checkbox,span.fancytree-drag-helper-img,span.fancytree-empty,span.fancytree-expander,span.fancytree-icon,span.fancytree-radio,span.fancytree-vline{width:16px;height:16px;display:inline-block;vertical-align:top;background-repeat:no-repeat;background-image:url(icons.gif);background-position:0 0}span.fancytree-checkbox,span.fancytree-custom-icon,span.fancytree-icon,span.fancytree-radio{margin-top:1px}span.fancytree-custom-icon{display:inline-block}img.fancytree-icon{width:16px;height:16px;margin-left:3px;margin-top:1px;vertical-align:top;border-style:none}span.fancytree-expander{cursor:pointer}.fancytree-exp-n span.fancytree-expander,.fancytree-exp-nl span.fancytree-expander{background-image:none;cursor:default}.fancytree-exp-n span.fancytree-expander,.fancytree-exp-n span.fancytree-expander:hover{background-position:0 -64px}.fancytree-exp-nl span.fancytree-expander,.fancytree-exp-nl span.fancytree-expander:hover{background-position:-16px -64px}.fancytree-exp-c span.fancytree-expander{background-position:0 -80px}.fancytree-exp-c span.fancytree-expander:hover{background-position:-16px -80px}.fancytree-exp-cl span.fancytree-expander{background-position:0 -96px}.fancytree-exp-cl span.fancytree-expander:hover{background-position:-16px -96px}.fancytree-exp-cd span.fancytree-expander{background-position:-64px -80px}.fancytree-exp-cd span.fancytree-expander:hover{background-position:-80px -80px}.fancytree-exp-cdl span.fancytree-expander{background-position:-64px -96px}.fancytree-exp-cdl span.fancytree-expander:hover{background-position:-80px -96px}.fancytree-exp-e span.fancytree-expander,.fancytree-exp-ed span.fancytree-expander{background-position:-32px -80px}.fancytree-exp-e span.fancytree-expander:hover,.fancytree-exp-ed span.fancytree-expander:hover{background-position:-48px -80px}.fancytree-exp-edl span.fancytree-expander,.fancytree-exp-el span.fancytree-expander{background-position:-32px -96px}.fancytree-exp-edl span.fancytree-expander:hover,.fancytree-exp-el span.fancytree-expander:hover{background-position:-48px -96px}span.fancytree-checkbox{margin-left:3px;background-position:0 -32px}span.fancytree-checkbox:hover{background-position:-16px -32px}.fancytree-partsel span.fancytree-checkbox{background-position:-64px -32px}.fancytree-partsel span.fancytree-checkbox:hover{background-position:-80px -32px}.fancytree-selected span.fancytree-checkbox{background-position:-32px -32px}.fancytree-selected span.fancytree-checkbox:hover{background-position:-48px -32px}.fancytree-unselectable span.fancytree-checkbox,.fancytree-unselectable span.fancytree-checkbox:hover{opacity:.4;filter:alpha(opacity=40);background-position:0 -32px}.fancytree-radio span.fancytree-checkbox{background-position:0 -48px}.fancytree-radio span.fancytree-checkbox:hover{background-position:-16px -48px}.fancytree-radio .fancytree-partsel span.fancytree-checkbox{background-position:-64px -48px}.fancytree-radio .fancytree-partsel span.fancytree-checkbox:hover{background-position:-80px -48px}.fancytree-radio .fancytree-selected span.fancytree-checkbox{background-position:-32px -48px}.fancytree-radio .fancytree-selected span.fancytree-checkbox:hover{background-position:-48px -48px}.fancytree-radio .fancytree-unselectable span.fancytree-checkbox,.fancytree-radio .fancytree-unselectable span.fancytree-checkbox:hover{background-position:0 -48px}span.fancytree-icon{margin-left:3px;background-position:0 0}.fancytree-ico-c span.fancytree-icon:hover{background-position:-16px 0}.fancytree-has-children.fancytree-ico-c span.fancytree-icon{background-position:-32px 0}.fancytree-has-children.fancytree-ico-c span.fancytree-icon:hover{background-position:-48px 0}.fancytree-ico-e span.fancytree-icon{background-position:-64px 0}.fancytree-ico-e span.fancytree-icon:hover{background-position:-80px 0}.fancytree-ico-cf span.fancytree-icon{background-position:0 -16px}.fancytree-ico-cf span.fancytree-icon:hover{background-position:-16px -16px}.fancytree-has-children.fancytree-ico-cf span.fancytree-icon{background-position:-32px -16px}.fancytree-has-children.fancytree-ico-cf span.fancytree-icon:hover{background-position:-48px -16px}.fancytree-ico-ef span.fancytree-icon{background-position:-64px -16px}.fancytree-ico-ef span.fancytree-icon:hover{background-position:-80px -16px}.fancytree-loading span.fancytree-expander,.fancytree-loading span.fancytree-expander:hover,.fancytree-statusnode-wait span.fancytree-icon,.fancytree-statusnode-wait span.fancytree-icon:hover{background-image:url(loading.gif);background-position:0 0}.fancytree-statusnode-error span.fancytree-icon,.fancytree-statusnode-error span.fancytree-icon:hover{background-position:0 -112px}span.fancytree-node{display:inherit;width:100%;border:solid rgba(0,0,0,0) 1px}span.fancytree-title{display:inline-block;padding-left:3px;padding-right:3px;color:#000;vertical-align:top;margin:0;margin-left:3px;cursor:pointer}span.fancytree-node.fancytree-error span.fancytree-title{color:red}div.fancytree-drag-helper a{border:1px solid gray;background-color:#fff;padding-left:5px;padding-right:5px;opacity:.8}div.fancytree-drag-helper.fancytree-drop-reject{border-color:red}div.fancytree-drop-accept span.fancytree-drag-helper-img{background-position:-32px -112px}div.fancytree-drop-reject span.fancytree-drag-helper-img{background-position:-16px -112px}#fancytree-drop-marker{width:32px;position:absolute;background-position:0 -128px;margin:0}#fancytree-drop-marker.fancytree-drop-after,#fancytree-drop-marker.fancytree-drop-before{width:64px;background-position:0 -144px}#fancytree-drop-marker.fancytree-drop-copy{background-position:-64px -128px}#fancytree-drop-marker.fancytree-drop-move{background-position:-32px -128px}span.fancytree-drag-source{background-color:#e0e0e0}span.fancytree-drag-source span.fancytree.title{color:gray}span.fancytree-drop-target.fancytree-drop-accept a{background-color:#3169C6!important;color:#fff!important;text-decoration:none}table.fancytree-ext-table{border-collapse:collapse}table.fancytree-ext-table span.fancytree-node{display:inline-block}table.fancytree-ext-columnview tbody tr td{position:relative;border:1px solid gray;vertical-align:top;overflow:auto}table.fancytree-ext-columnview tbody tr td>ul{padding:0}table.fancytree-ext-columnview tbody tr td>ul li{list-style-image:none;list-style-position:outside;list-style-type:none;-moz-background-clip:border;-moz-background-inline-policy:continuous;-moz-background-origin:padding;background-attachment:scroll;background-color:transparent;background-position:0 0;background-repeat:repeat-y;background-image:none;margin:0;padding:1px 0 0}table.fancytree-ext-columnview span.fancytree-node{position:relative;display:inline-block}table.fancytree-ext-columnview span.fancytree-node.fancytree-expanded{background-color:#CBE8F6}table.fancytree-ext-columnview .fancytree-has-children span.fancytree-cv-right{position:absolute;right:3px;background-position:0 -80px}table.fancytree-ext-columnview .fancytree-has-children span.fancytree-cv-right:hover{background-position:-16px -80px}.fancytree-ext-filter-dimm span.fancytree-node span.fancytree-title{color:silver;font-weight:lighter}.fancytree-ext-filter-dimm span.fancytree-node.fancytree-submatch span.fancytree-title,.fancytree-ext-filter-dimm tr.fancytree-submatch span.fancytree-title{color:#000;font-weight:400}.fancytree-ext-filter-dimm span.fancytree-node.fancytree-match span.fancytree-title,.fancytree-ext-filter-dimm tr.fancytree-match span.fancytree-title{color:#000;font-weight:700}.fancytree-ext-filter-hide span.fancytree-node.fancytree-hide,.fancytree-ext-filter-hide tr.fancytree-hide{display:none}.fancytree-ext-filter-hide span.fancytree-node.fancytree-submatch span.fancytree-title,.fancytree-ext-filter-hide tr.fancytree-submatch span.fancytree-title{color:silver;font-weight:lighter}.fancytree-ext-filter-hide span.fancytree-node.fancytree-match span.fancytree-title,.fancytree-ext-filter-hide tr.fancytree-match span.fancytree-title{color:#000;font-weight:400}ul.fancytree-ext-wide span.fancytree-node>span{position:relative;z-index:2}ul.fancytree-ext-wide span.fancytree-node span.fancytree-title{position:relative;z-index:1;width:100%;padding-left:503px;margin-left:-500px}span.fancytree-title{border:1px solid transparent;border-radius:3px}span.fancytree-title:hover{border-color:#d8f0fa;color:inherit;background:-moz-linear-gradient(top,#f8fcfe 0,#eff9fe 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#f8fcfe),color-stop(100%,#eff9fe));background:-webkit-linear-gradient(top,#f8fcfe 0,#eff9fe 100%);background:-o-linear-gradient(top,#f8fcfe 0,#eff9fe 100%);background:-ms-linear-gradient(top,#f8fcfe 0,#eff9fe 100%);background:linear-gradient(to bottom,#f8fcfe 0,#eff9fe 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f8fcfe', endColorstr='#eff9fe', GradientType=0)}span.fancytree-focused span.fancytree-title{outline:1px dotted #000}span.fancytree-active .fancytree-title{border-color:#d9d9d9;color:inherit;background:-moz-linear-gradient(top,#fafafb 0,#e5e5e5 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#fafafb),color-stop(100%,#e5e5e5));background:-webkit-linear-gradient(top,#fafafb 0,#e5e5e5 100%);background:-o-linear-gradient(top,#fafafb 0,#e5e5e5 100%);background:-ms-linear-gradient(top,#fafafb 0,#e5e5e5 100%);background:linear-gradient(to bottom,#fafafb 0,#e5e5e5 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fafafb', endColorstr='#e5e5e5', GradientType=0)}.fancytree-treefocus span.fancytree-active .fancytree-title,span.fancytree-selected .fancytree-title{border-color:#99defd;color:inherit;background:-moz-linear-gradient(top,#f6fbfd 0,#d5effc 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#f6fbfd),color-stop(100%,#d5effc));background:-webkit-linear-gradient(top,#f6fbfd 0,#d5effc 100%);background:-o-linear-gradient(top,#f6fbfd 0,#d5effc 100%);background:-ms-linear-gradient(top,#f6fbfd 0,#d5effc 100%);background:linear-gradient(to bottom,#f6fbfd 0,#d5effc 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f6fbfd', endColorstr='#d5effc', GradientType=0)}span.fancytree-active .fancytree-title:hover,span.fancytree-active.fancytree-focused .fancytree-title,span.fancytree-selected .fancytree-title:hover,span.fancytree-selected.fancytree-focused .fancytree-title{border-color:#b6e6fb;color:inherit;background:-moz-linear-gradient(top,#f2f9fd 0,#c4e8fa 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#f2f9fd),color-stop(100%,#c4e8fa));background:-webkit-linear-gradient(top,#f2f9fd 0,#c4e8fa 100%);background:-o-linear-gradient(top,#f2f9fd 0,#c4e8fa 100%);background:-ms-linear-gradient(top,#f2f9fd 0,#c4e8fa 100%);background:linear-gradient(to bottom,#f2f9fd 0,#c4e8fa 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f2f9fd', endColorstr='#c4e8fa', GradientType=0)}.fancytree-selected .fancytree-title{font-style:italic}table.fancytree-ext-table tbody tr td{border:1px solid #EDEDED}table.fancytree-ext-table tbody tr:hover{border-color:inherit;color:inherit;background:-moz-linear-gradient(top,#f8fcfe 0,#eff9fe 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#f8fcfe),color-stop(100%,#eff9fe));background:-webkit-linear-gradient(top,#f8fcfe 0,#eff9fe 100%);background:-o-linear-gradient(top,#f8fcfe 0,#eff9fe 100%);background:-ms-linear-gradient(top,#f8fcfe 0,#eff9fe 100%);background:linear-gradient(to bottom,#f8fcfe 0,#eff9fe 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f8fcfe', endColorstr='#eff9fe', GradientType=0);outline:1px solid #D8F0FA}table.fancytree-ext-table tbody tr.fancytree-focused{outline:1px dotted #090402}table.fancytree-ext-table tbody span.fancytree-focused span.fancytree-title{outline:solid dotted #000}table.fancytree-ext-table tbody span.fancytree-title:hover{border:1px solid transparent;background:inherit;background:0 0;background:0 0;filter:none}table.fancytree-ext-table tbody tr.fancytree-active:hover,table.fancytree-ext-table tbody tr.fancytree-selected:hover{border-color:inherit;color:inherit;background:-moz-linear-gradient(top,#f2f9fd 0,#c4e8fa 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#f2f9fd),color-stop(100%,#c4e8fa));background:-webkit-linear-gradient(top,#f2f9fd 0,#c4e8fa 100%);background:-o-linear-gradient(top,#f2f9fd 0,#c4e8fa 100%);background:-ms-linear-gradient(top,#f2f9fd 0,#c4e8fa 100%);background:linear-gradient(to bottom,#f2f9fd 0,#c4e8fa 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f2f9fd', endColorstr='#c4e8fa', GradientType=0);outline:1px solid #B6E6FB}table.fancytree-ext-table tbody tr.fancytree-active,table.fancytree-ext-table tbody tr.fancytree-selected{border-color:inherit;color:inherit;background:-moz-linear-gradient(top,#f6fbfd 0,#d5effc 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#f6fbfd),color-stop(100%,#d5effc));background:-webkit-linear-gradient(top,#f6fbfd 0,#d5effc 100%);background:-o-linear-gradient(top,#f6fbfd 0,#d5effc 100%);background:-ms-linear-gradient(top,#f6fbfd 0,#d5effc 100%);background:linear-gradient(to bottom,#f6fbfd 0,#d5effc 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f6fbfd', endColorstr='#d5effc', GradientType=0);outline:1px solid #99DEFD}
69</style>
70<script type="text/javascript">
71
72// ------------------------- START jquery.fancytree-all.min.js -----------------------------------
73/*! jQuery Fancytree Plugin - 2.6.0 - 2014-11-29T08:33
74 * https://github.com/mar10/fancytree
75 * Copyright (c) 2014 Martin Wendt; Licensed MIT */
76(function( factory ) {
77 if (jQuery.fn.fancytree) return;
78 // this does not work in node-red
79 if ( false && typeof define === "function" && define.amd ) {
80 define( [ "jquery" ], factory );
81 } else {
82 factory( jQuery );
83 }
84}(function( $ ) {
85 !function(a,b,c,d){"use strict";function e(b,c){b||(c=c?": "+c:"",a.error("Fancytree assertion failed"+c))}function f(a,c){var d,e,f=b.console?b.console[a]:null;if(f)try{f.apply(b.console,c)}catch(g){for(e="",d=0;d<c.length;d++)e+=c[d];f(e)}}function g(a){return!(!a.tree||a.statusNodeType===d)}function h(b){var c,d,e,f=a.map(a.trim(b).split("."),function(a){return parseInt(a,10)}),g=a.map(Array.prototype.slice.call(arguments,1),function(a){return parseInt(a,10)});for(c=0;c<g.length;c++)if(d=f[c]||0,e=g[c]||0,d!==e)return d>e;return!0}function i(a,b,c,d,e){var f=function(){var c=b[a],f=d[a],g=b.ext[e],h=function(){return c.apply(b,arguments)};return function(){var a=b._local,c=b._super;try{return b._local=g,b._super=h,f.apply(b,arguments)}finally{b._local=a,b._super=c}}}();return f}function j(b,c,d,e){for(var f in d)"function"==typeof d[f]?"function"==typeof b[f]?b[f]=i(f,b,c,d,e):"_"===f.charAt(0)?b.ext[e][f]=i(f,b,c,d,e):a.error("Could not override tree."+f+". Use prefix '_' to create tree."+e+"._"+f):"options"!==f&&(b.ext[e][f]=d[f])}function k(b,c){return b===d?a.Deferred(function(){this.resolve()}).promise():a.Deferred(function(){this.resolveWith(b,c)}).promise()}function l(b,c){return b===d?a.Deferred(function(){this.reject()}).promise():a.Deferred(function(){this.rejectWith(b,c)}).promise()}function m(a,b){return function(){a.resolveWith(b)}}function n(b){var c=a.extend({},b.data()),d=c.json;return delete c.fancytree,d&&(delete c.json,c=a.extend(c,d)),c}function o(a){return a=a.toLowerCase(),function(b){return b.title.toLowerCase().indexOf(a)>=0}}function p(a){var b=new RegExp("^"+a,"i");return function(a){return b.test(a.title)}}function q(b,c){var d,f,g,h;for(this.parent=b,this.tree=b.tree,this.ul=null,this.li=null,this.statusNodeType=null,this._isLoading=!1,this._error=null,this.data={},d=0,f=x.length;f>d;d++)g=x[d],this[g]=c[g];c.data&&a.extend(this.data,c.data);for(g in c)y[g]||a.isFunction(c[g])||z[g]||(this.data[g]=c[g]);null==this.key?this.tree.options.defaultKey?(this.key=this.tree.options.defaultKey(this),e(this.key,"defaultKey() must return a unique key")):this.key="_"+t._nextNodeKey++:this.key=""+this.key,c.active&&(e(null===this.tree.activeNode,"only one active node allowed"),this.tree.activeNode=this),c.selected&&(this.tree.lastSelectedNode=this),this.children=null,h=c.children,h&&h.length&&this._setChildren(h),this.tree._callHook("treeRegisterNode",this.tree,!0,this)}function r(b){this.widget=b,this.$div=b.element,this.options=b.options,this.options&&a.isFunction(this.options.lazyload)&&(a.isFunction(this.options.lazyLoad)||(this.options.lazyLoad=function(){t.warn("The 'lazyload' event is deprecated since 2014-02-25. Use 'lazyLoad' (with uppercase L) instead."),b.options.lazyload.apply(this,arguments)})),this.options&&a.isFunction(this.options.loaderror)&&a.error("The 'loaderror' event was renamed since 2014-07-03. Use 'loadError' (with uppercase E) instead."),this.ext={},this.data=n(this.$div),this._id=a.ui.fancytree._nextId++,this._ns=".fancytree-"+this._id,this.activeNode=null,this.focusNode=null,this._hasFocus=null,this.lastSelectedNode=null,this.systemFocusElement=null,this.lastQuicksearchTerm="",this.lastQuicksearchTime=0,this.statusClassPropName="span",this.ariaPropName="li",this.nodeContainerAttrName="li",this.$div.find(">ul.fancytree-container").remove();var c,d={tree:this};this.rootNode=new q(d,{title:"root",key:"root_"+this._id,children:null,expanded:!0}),this.rootNode.parent=null,c=a("<ul>",{"class":"ui-fancytree fancytree-container"}).appendTo(this.$div),this.$container=c,this.rootNode.ul=c[0],null==this.options.debugLevel&&(this.options.debugLevel=t.debugLevel),this.$container.attr("tabindex",this.options.tabbable?"0":"-1"),this.options.aria&&this.$container.attr("role","tree").attr("aria-multiselectable",!0)}if(a.ui&&a.ui.fancytree)return void a.ui.fancytree.warn("Fancytree: ignored duplicate include");e(a.ui,"Fancytree requires jQuery UI (http://jqueryui.com)");var s,t=null,u={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"},v="active expanded focus folder hideCheckbox lazy selected unselectable".split(" "),w={},x="expanded extraClasses folder hideCheckbox key lazy refKey selected title tooltip unselectable".split(" "),y={},z={active:!0,children:!0,data:!0,focus:!0};for(s=0;s<v.length;s++)w[v[s]]=!0;for(s=0;s<x.length;s++)y[x[s]]=!0;q.prototype={_findDirectChild:function(a){var b,c,d=this.children;if(d)if("string"==typeof a){for(b=0,c=d.length;c>b;b++)if(d[b].key===a)return d[b]}else{if("number"==typeof a)return this.children[a];if(a.parent===this)return a}return null},_setChildren:function(a){e(a&&(!this.children||0===this.children.length),"only init supported"),this.children=[];for(var b=0,c=a.length;c>b;b++)this.children.push(new q(this,a[b]))},addChildren:function(b,c){var d,f,g,h=null,i=[];for(a.isPlainObject(b)&&(b=[b]),this.children||(this.children=[]),d=0,f=b.length;f>d;d++)i.push(new q(this,b[d]));return h=i[0],null==c?this.children=this.children.concat(i):(c=this._findDirectChild(c),g=a.inArray(c,this.children),e(g>=0,"insertBefore must be an existing child"),this.children.splice.apply(this.children,[g,0].concat(i))),(!this.parent||this.parent.ul||this.tr)&&this.render(),3===this.tree.options.selectMode&&this.fixSelection3FromEndNodes(),h},addNode:function(a,b){switch((b===d||"over"===b)&&(b="child"),b){case"after":return this.getParent().addChildren(a,this.getNextSibling());case"before":return this.getParent().addChildren(a,this);case"firstChild":var c=this.children?this.children[0]:null;return this.addChildren(a,c);case"child":case"over":return this.addChildren(a)}e(!1,"Invalid mode: "+b)},appendSibling:function(a){return this.addNode(a,"after")},applyPatch:function(b){if(null===b)return this.remove(),k(this);var c,d,e,f={children:!0,expanded:!0,parent:!0};for(c in b)e=b[c],f[c]||a.isFunction(e)||(y[c]?this[c]=e:this.data[c]=e);return b.hasOwnProperty("children")&&(this.removeChildren(),b.children&&this._setChildren(b.children)),this.isVisible()&&(this.renderTitle(),this.renderStatus()),d=b.hasOwnProperty("expanded")?this.setExpanded(b.expanded):k(this)},collapseSiblings:function(){return this.tree._callHook("nodeCollapseSiblings",this)},copyTo:function(a,b,c){return a.addNode(this.toDict(!0,c),b)},countChildren:function(a){var b,c,d,e=this.children;if(!e)return 0;if(d=e.length,a!==!1)for(b=0,c=d;c>b;b++)d+=e[b].countChildren();return d},debug:function(){this.tree.options.debugLevel>=2&&(Array.prototype.unshift.call(arguments,this.toString()),f("log",arguments))},discard:function(){return this.warn("FancytreeNode.discard() is deprecated since 2014-02-16. Use .resetLazy() instead."),this.resetLazy()},findAll:function(b){b=a.isFunction(b)?b:o(b);var c=[];return this.visit(function(a){b(a)&&c.push(a)}),c},findFirst:function(b){b=a.isFunction(b)?b:o(b);var c=null;return this.visit(function(a){return b(a)?(c=a,!1):void 0}),c},_changeSelectStatusAttrs:function(a){var b=!1;switch(a){case!1:b=this.selected||this.partsel,this.selected=!1,this.partsel=!1;break;case!0:b=!this.selected||!this.partsel,this.selected=!0,this.partsel=!0;break;case d:b=this.selected||!this.partsel,this.selected=!1,this.partsel=!0;break;default:e(!1,"invalid state: "+a)}return b&&this.renderStatus(),b},fixSelection3AfterClick:function(){var a=this.isSelected();this.visit(function(b){b._changeSelectStatusAttrs(a)}),this.fixSelection3FromEndNodes()},fixSelection3FromEndNodes:function(){function a(b){var c,e,f,g,h,i,j,k=b.children;if(k&&k.length){for(i=!0,j=!1,c=0,e=k.length;e>c;c++)f=k[c],g=a(f),g!==!1&&(j=!0),g!==!0&&(i=!1);h=i?!0:j?d:!1}else h=!!b.selected;return b._changeSelectStatusAttrs(h),h}e(3===this.tree.options.selectMode,"expected selectMode 3"),a(this),this.visitParents(function(a){var b,c,e,f,g=a.children,h=!0,i=!1;for(b=0,c=g.length;c>b;b++)e=g[b],(e.selected||e.partsel)&&(i=!0),e.unselectable||e.selected||(h=!1);f=h?!0:i?d:!1,a._changeSelectStatusAttrs(f)})},fromDict:function(b){for(var c in b)y[c]?this[c]=b[c]:"data"===c?a.extend(this.data,b.data):a.isFunction(b[c])||z[c]||(this.data[c]=b[c]);b.children&&(this.removeChildren(),this.addChildren(b.children)),this.renderTitle()},getChildren:function(){return this.hasChildren()===d?d:this.children},getFirstChild:function(){return this.children?this.children[0]:null},getIndex:function(){return a.inArray(this,this.parent.children)},getIndexHier:function(b){b=b||".";var c=[];return a.each(this.getParentList(!1,!0),function(a,b){c.push(b.getIndex()+1)}),c.join(b)},getKeyPath:function(a){var b=[],c=this.tree.options.keyPathSeparator;return this.visitParents(function(a){a.parent&&b.unshift(a.key)},!a),c+b.join(c)},getLastChild:function(){return this.children?this.children[this.children.length-1]:null},getLevel:function(){for(var a=0,b=this.parent;b;)a++,b=b.parent;return a},getNextSibling:function(){if(this.parent){var a,b,c=this.parent.children;for(a=0,b=c.length-1;b>a;a++)if(c[a]===this)return c[a+1]}return null},getParent:function(){return this.parent},getParentList:function(a,b){for(var c=[],d=b?this:this.parent;d;)(a||d.parent)&&c.unshift(d),d=d.parent;return c},getPrevSibling:function(){if(this.parent){var a,b,c=this.parent.children;for(a=1,b=c.length;b>a;a++)if(c[a]===this)return c[a-1]}return null},hasChildren:function(){return this.lazy?null==this.children?d:0===this.children.length?!1:1===this.children.length&&this.children[0].isStatusNode()?d:!0:!(!this.children||!this.children.length)},hasFocus:function(){return this.tree.hasFocus()&&this.tree.focusNode===this},info:function(){this.tree.options.debugLevel>=1&&(Array.prototype.unshift.call(arguments,this.toString()),f("info",arguments))},isActive:function(){return this.tree.activeNode===this},isChildOf:function(a){return this.parent&&this.parent===a},isDescendantOf:function(a){if(!a||a.tree!==this.tree)return!1;for(var b=this.parent;b;){if(b===a)return!0;b=b.parent}return!1},isExpanded:function(){return!!this.expanded},isFirstSibling:function(){var a=this.parent;return!a||a.children[0]===this},isFolder:function(){return!!this.folder},isLastSibling:function(){var a=this.parent;return!a||a.children[a.children.length-1]===this},isLazy:function(){return!!this.lazy},isLoaded:function(){return!this.lazy||this.hasChildren()!==d},isLoading:function(){return!!this._isLoading},isRoot:function(){return this.isRootNode()},isRootNode:function(){return this.tree.rootNode===this},isSelected:function(){return!!this.selected},isStatusNode:function(){return!!this.statusNodeType},isTopLevel:function(){return this.tree.rootNode===this.parent},isUndefined:function(){return this.hasChildren()===d},isVisible:function(){var a,b,c=this.getParentList(!1,!1);for(a=0,b=c.length;b>a;a++)if(!c[a].expanded)return!1;return!0},lazyLoad:function(a){return this.warn("FancytreeNode.lazyLoad() is deprecated since 2014-02-16. Use .load() instead."),this.load(a)},load:function(a){var b,c,d=this;return e(this.isLazy(),"load() requires a lazy node"),a||this.isUndefined()?(this.isLoaded()&&this.resetLazy(),c=this.tree._triggerNodeEvent("lazyLoad",this),c===!1?k(this):(e("boolean"!=typeof c,"lazyLoad event must return source in data.result"),b=this.tree._callHook("nodeLoadChildren",this,c),this.expanded&&b.always(function(){d.render()}),b)):k(this)},makeVisible:function(b){var c,d=this,e=[],f=new a.Deferred,g=this.getParentList(!1,!1),h=g.length,i=!(b&&b.noAnimation===!0),j=!(b&&b.scrollIntoView===!1);for(c=h-1;c>=0;c--)e.push(g[c].setExpanded(!0,b));return a.when.apply(a,e).done(function(){j?d.scrollIntoView(i).done(function(){f.resolve()}):f.resolve()}),f.promise()},moveTo:function(b,c,f){(c===d||"over"===c)&&(c="child");var g,h=this.parent,i="child"===c?b:b.parent;if(this!==b){if(!this.parent)throw"Cannot move system root";if(i.isDescendantOf(this))throw"Cannot move a node to its own descendant";if(1===this.parent.children.length){if(this.parent===i)return;this.parent.children=this.parent.lazy?[]:null,this.parent.expanded=!1}else g=a.inArray(this,this.parent.children),e(g>=0),this.parent.children.splice(g,1);if(this.parent=i,i.hasChildren())switch(c){case"child":i.children.push(this);break;case"before":g=a.inArray(b,i.children),e(g>=0),i.children.splice(g,0,this);break;case"after":g=a.inArray(b,i.children),e(g>=0),i.children.splice(g+1,0,this);break;default:throw"Invalid mode "+c}else i.children=[this];f&&b.visit(f,!0),this.tree!==b.tree&&(this.warn("Cross-tree moveTo is experimantal!"),this.visit(function(a){a.tree=b.tree},!0)),h.isDescendantOf(i)||h.render(),i.isDescendantOf(h)||i===h||i.render()}},navigate:function(b,c){function d(d){if(d){try{d.makeVisible()}catch(e){}return a(d.span).is(":visible")?c===!1?d.setFocus():d.setActive():(d.debug("Navigate: skipping hidden node"),void d.navigate(b,c))}}var e,f,g=!0,h=a.ui.keyCode,i=null;switch(b){case h.BACKSPACE:this.parent&&this.parent.parent&&d(this.parent);break;case h.LEFT:this.expanded?(this.setExpanded(!1),d(this)):this.parent&&this.parent.parent&&d(this.parent);break;case h.RIGHT:this.expanded||!this.children&&!this.lazy?this.children&&this.children.length&&d(this.children[0]):(this.setExpanded(),d(this));break;case h.UP:for(i=this.getPrevSibling();i&&!a(i.span).is(":visible");)i=i.getPrevSibling();for(;i&&i.expanded&&i.children&&i.children.length;)i=i.children[i.children.length-1];!i&&this.parent&&this.parent.parent&&(i=this.parent),d(i);break;case h.DOWN:if(this.expanded&&this.children&&this.children.length)i=this.children[0];else for(f=this.getParentList(!1,!0),e=f.length-1;e>=0;e--){for(i=f[e].getNextSibling();i&&!a(i.span).is(":visible");)i=i.getNextSibling();if(i)break}d(i);break;default:g=!1}},remove:function(){return this.parent.removeChild(this)},removeChild:function(a){return this.tree._callHook("nodeRemoveChild",this,a)},removeChildren:function(){return this.tree._callHook("nodeRemoveChildren",this)},render:function(a,b){return this.tree._callHook("nodeRender",this,a,b)},renderTitle:function(){return this.tree._callHook("nodeRenderTitle",this)},renderStatus:function(){return this.tree._callHook("nodeRenderStatus",this)},resetLazy:function(){this.removeChildren(),this.expanded=!1,this.lazy=!0,this.children=d,this.renderStatus()},scheduleAction:function(a,b){this.tree.timer&&clearTimeout(this.tree.timer),this.tree.timer=null;var c=this;switch(a){case"cancel":break;case"expand":this.tree.timer=setTimeout(function(){c.tree.debug("setTimeout: trigger expand"),c.setExpanded(!0)},b);break;case"activate":this.tree.timer=setTimeout(function(){c.tree.debug("setTimeout: trigger activate"),c.setActive(!0)},b);break;default:throw"Invalid mode "+a}},scrollIntoView:function(f,h){h!==d&&g(h)&&(this.warn("scrollIntoView() with 'topNode' option is deprecated since 2014-05-08. Use 'options.topNode' instead."),h={topNode:h});var i,j,k,l,m=a.extend({effects:f===!0?{duration:200,queue:!1}:f,scrollOfs:this.tree.options.scrollOfs,scrollParent:this.tree.options.scrollParent||this.tree.$container,topNode:null},h),n=new a.Deferred,o=this,p=a(this.span).height(),q=a(m.scrollParent),r=m.scrollOfs.top||0,s=m.scrollOfs.bottom||0,t=q.height(),u=q.scrollTop(),v=q,w=q[0]===b,x=m.topNode||null,y=null;return e(a(this.span).is(":visible"),"scrollIntoView node is invisible"),w?(j=a(this.span).offset().top,i=x&&x.span?a(x.span).offset().top:0,v=a("html,body")):(e(q[0]!==c&&q[0]!==c.body,"scrollParent should be an simple element or `window`, not document or body."),l=q.offset().top,j=a(this.span).offset().top-l+u,i=x?a(x.span).offset().top-l+u:0,k=Math.max(0,q.innerHeight()-q[0].clientHeight),t-=k),u+r>j?y=j-r:j+p>u+t-s&&(y=j+p-t+s,x&&(e(x.isRoot()||a(x.span).is(":visible"),"topNode must be visible"),y>i&&(y=i-r))),null!==y?m.effects?(m.effects.complete=function(){n.resolveWith(o)},v.stop(!0).animate({scrollTop:y},m.effects)):(v[0].scrollTop=y,n.resolveWith(this)):n.resolveWith(this),n.promise()},setActive:function(a,b){return this.tree._callHook("nodeSetActive",this,a,b)},setExpanded:function(a,b){return this.tree._callHook("nodeSetExpanded",this,a,b)},setFocus:function(a){return this.tree._callHook("nodeSetFocus",this,a)},setSelected:function(a){return this.tree._callHook("nodeSetSelected",this,a)},setStatus:function(a,b,c){return this.tree._callHook("nodeSetStatus",this,a,b,c)},setTitle:function(a){this.title=a,this.renderTitle()},sortChildren:function(a,b){var c,d,e=this.children;if(e){if(a=a||function(a,b){var c=a.title.toLowerCase(),d=b.title.toLowerCase();return c===d?0:c>d?1:-1},e.sort(a),b)for(c=0,d=e.length;d>c;c++)e[c].children&&e[c].sortChildren(a,"$norender$");"$norender$"!==b&&this.render()}},toDict:function(b,c){var d,e,f,g={},h=this;if(a.each(x,function(a,b){(h[b]||h[b]===!1)&&(g[b]=h[b])}),a.isEmptyObject(this.data)||(g.data=a.extend({},this.data),a.isEmptyObject(g.data)&&delete g.data),c&&c(g),b&&this.hasChildren())for(g.children=[],d=0,e=this.children.length;e>d;d++)f=this.children[d],f.isStatusNode()||g.children.push(f.toDict(!0,c));return g},toggleExpanded:function(){return this.tree._callHook("nodeToggleExpanded",this)},toggleSelected:function(){return this.tree._callHook("nodeToggleSelected",this)},toString:function(){return"<FancytreeNode(#"+this.key+", '"+this.title+"')>"},visit:function(a,b){var c,d,e=!0,f=this.children;if(b===!0&&(e=a(this),e===!1||"skip"===e))return e;if(f)for(c=0,d=f.length;d>c&&(e=f[c].visit(a,!0),e!==!1);c++);return e},visitAndLoad:function(b,c,d){var e,f,g,h=this;return b&&c===!0&&(f=b(h),f===!1||"skip"===f)?d?f:k():h.children||h.lazy?(e=new a.Deferred,g=[],h.load().done(function(){for(var c=0,d=h.children.length;d>c;c++){if(f=h.children[c].visitAndLoad(b,!0,!0),f===!1){e.reject();break}"skip"!==f&&g.push(f)}a.when.apply(this,g).then(function(){e.resolve()})}),e.promise()):k()},visitParents:function(a,b){if(b&&a(this)===!1)return!1;for(var c=this.parent;c;){if(a(c)===!1)return!1;c=c.parent}return!0},warn:function(){Array.prototype.unshift.call(arguments,this.toString()),f("warn",arguments)}},r.prototype={_makeHookContext:function(b,c,e){var f,g;return b.node!==d?(c&&b.originalEvent!==c&&a.error("invalid args"),f=b):b.tree?(g=b.tree,f={node:b,tree:g,widget:g.widget,options:g.widget.options,originalEvent:c}):b.widget?f={node:null,tree:b,widget:b.widget,options:b.widget.options,originalEvent:c}:a.error("invalid args"),e&&a.extend(f,e),f},_callHook:function(b,c){var d=this._makeHookContext(c),e=this[b],f=Array.prototype.slice.call(arguments,2);return a.isFunction(e)||a.error("_callHook('"+b+"') is not a function"),f.unshift(d),e.apply(this,f)},_requireExtension:function(b,c,d,f){d=!!d;var g=this._local.name,h=this.options.extensions,i=a.inArray(b,h)<a.inArray(g,h),j=c&&null==this.ext[b],k=!j&&null!=d&&d!==i;return e(g&&g!==b),j||k?(f||(j||c?(f="'"+g+"' extension requires '"+b+"'",k&&(f+=" to be registered "+(d?"before":"after")+" itself")):f="If used together, `"+b+"` must be registered "+(d?"before":"after")+" `"+g+"`"),a.error(f),!1):!0},activateKey:function(a){var b=this.getNodeByKey(a);return b?b.setActive():this.activeNode&&this.activeNode.setActive(!1),b},applyPatch:function(b){var c,d,f,g,h,i,j=b.length,k=[];for(d=0;j>d;d++)f=b[d],e(2===f.length,"patchList must be an array of length-2-arrays"),g=f[0],h=f[1],i=null===g?this.rootNode:this.getNodeByKey(g),i?(c=new a.Deferred,k.push(c),i.applyPatch(h).always(m(c,i))):this.warn("could not find node with key '"+g+"'");return a.when.apply(a,k).promise()},count:function(){return this.rootNode.countChildren()},debug:function(){this.options.debugLevel>=2&&(Array.prototype.unshift.call(arguments,this.toString()),f("log",arguments))},findNextNode:function(b,c){var d=null,e=c.parent.children,f=null,g=function(a,b,c){var d,e,f=a.children,h=f.length,i=f[b];if(i&&c(i)===!1)return!1;if(i&&i.children&&i.expanded&&g(i,0,c)===!1)return!1;for(d=b+1;h>d;d++)if(g(a,d,c)===!1)return!1;return e=a.parent,e?g(e,e.children.indexOf(a)+1,c):g(a,0,c)};return b="string"==typeof b?p(b):b,c=c||this.getFirstChild(),g(c.parent,e.indexOf(c),function(e){return e===d?!1:(d=d||e,a(e.span).is(":visible")?b(e)&&(f=e,f!==c)?!1:void 0:void e.debug("quicksearch: skipping hidden node"))}),f},generateFormElements:function(b,c){var d,e=b!==!1?"ft_"+this._id+"[]":b,f=c!==!1?"ft_"+this._id+"_active":c,g="fancytree_result_"+this._id,h=a("#"+g);h.length?h.empty():h=a("<div>",{id:g}).hide().insertAfter(this.$container),e&&(d=this.getSelectedNodes(3===this.options.selectMode),a.each(d,function(b,c){h.append(a("<input>",{type:"checkbox",name:e,value:c.key,checked:!0}))})),f&&this.activeNode&&h.append(a("<input>",{type:"radio",name:f,value:this.activeNode.key,checked:!0}))},getActiveNode:function(){return this.activeNode},getFirstChild:function(){return this.rootNode.getFirstChild()},getFocusNode:function(){return this.focusNode},getNodeByKey:function(a,b){var d,e;return!b&&(d=c.getElementById(this.options.idPrefix+a))?d.ftnode?d.ftnode:null:(b=b||this.rootNode,e=null,b.visit(function(b){return b.key===a?(e=b,!1):void 0},!0),e)},getRootNode:function(){return this.rootNode},getSelectedNodes:function(a){var b=[];return this.rootNode.visit(function(c){return c.selected&&(b.push(c),a===!0)?"skip":void 0}),b},hasFocus:function(){return!!this._hasFocus},info:function(){this.options.debugLevel>=1&&(Array.prototype.unshift.call(arguments,this.toString()),f("info",arguments))},loadKeyPath:function(b,c,e){function f(a,b,d){c.call(r,b,"loading"),b.load().done(function(){r.loadKeyPath.call(r,l[a],c,b).always(m(d,r))}).fail(function(){r.warn("loadKeyPath: error loading: "+a+" (parent: "+o+")"),c.call(r,b,"error"),d.reject()})}var g,h,i,j,k,l,n,o,p,q=this.options.keyPathSeparator,r=this;for(a.isArray(b)||(b=[b]),l={},i=0;i<b.length;i++)for(o=e||this.rootNode,j=b[i],j.charAt(0)===q&&(j=j.substr(1)),p=j.split(q);p.length;){if(k=p.shift(),n=o._findDirectChild(k),!n){this.warn("loadKeyPath: key not found: "+k+" (parent: "+o+")"),c.call(this,k,"error");break}if(0===p.length){c.call(this,n,"ok");break}if(n.lazy&&n.hasChildren()===d){c.call(this,n,"loaded"),l[k]?l[k].push(p.join(q)):l[k]=[p.join(q)];break}c.call(this,n,"loaded"),o=n}g=[];for(k in l)n=o._findDirectChild(k),h=new a.Deferred,g.push(h),f(k,n,h);return a.when.apply(a,g).promise()},reactivate:function(a){var b=this.activeNode;b&&(this.activeNode=null,b.setActive(),a&&b.setFocus())},reload:function(a){return this._callHook("treeClear",this),this._callHook("treeLoad",this,a)},render:function(a,b){return this.rootNode.render(a,b)},setFocus:function(a){return this._callHook("treeSetFocus",this,a)},toDict:function(a,b){var c=this.rootNode.toDict(!0,b);return a?c:c.children},toString:function(){return"<Fancytree(#"+this._id+")>"},_triggerNodeEvent:function(a,b,c,e){var f=this._makeHookContext(b,c,e),g=this.widget._trigger(a,c,f);return g!==!1&&f.result!==d?f.result:g},_triggerTreeEvent:function(a,b,c){var e=this._makeHookContext(this,b,c),f=this.widget._trigger(a,b,e);return f!==!1&&e.result!==d?e.result:f},visit:function(a){return this.rootNode.visit(a,!1)},warn:function(){Array.prototype.unshift.call(arguments,this.toString()),f("warn",arguments)}},a.extend(r.prototype,{nodeClick:function(a){var b,c,d=a.targetType,e=a.node;if("expander"===d)this._callHook("nodeToggleExpanded",a);else if("checkbox"===d)this._callHook("nodeToggleSelected",a),a.options.focusOnSelect&&this._callHook("nodeSetFocus",a,!0);else{if(c=!1,b=!0,e.folder)switch(a.options.clickFolderMode){case 2:c=!0,b=!1;break;case 3:b=!0,c=!0}b&&(this.nodeSetFocus(a),this._callHook("nodeSetActive",a,!0)),c&&this._callHook("nodeToggleExpanded",a)}},nodeCollapseSiblings:function(a,b){var c,d,e,f=a.node;if(f.parent)for(c=f.parent.children,d=0,e=c.length;e>d;d++)c[d]!==f&&c[d].expanded&&this._callHook("nodeSetExpanded",c[d],!1,b)},nodeDblclick:function(a){"title"===a.targetType&&4===a.options.clickFolderMode&&this._callHook("nodeToggleExpanded",a),"title"===a.targetType&&a.originalEvent.preventDefault()},nodeKeydown:function(b){var c,d,e,f=b.originalEvent,g=b.node,h=b.tree,i=b.options,j=f.which,k=String.fromCharCode(j),l=!(f.altKey||f.ctrlKey||f.metaKey||f.shiftKey),m=a(f.target),n=!0,o=!(f.ctrlKey||!i.autoActivate),p=a.ui.keyCode;if(g||(this.getFirstChild().setFocus(),g=b.node=this.focusNode,g.debug("Keydown force focus on first node")),i.quicksearch&&l&&/\w/.test(k)&&!m.is(":input:enabled"))return d=(new Date).getTime(),d-h.lastQuicksearchTime>500&&(h.lastQuicksearchTerm=""),h.lastQuicksearchTime=d,h.lastQuicksearchTerm+=k,c=h.findNextNode(h.lastQuicksearchTerm,h.getActiveNode()),c&&c.setActive(),void f.preventDefault();switch(j){case p.NUMPAD_ADD:case 187:h.nodeSetExpanded(b,!0);break;case p.NUMPAD_SUBTRACT:case 189:h.nodeSetExpanded(b,!1);break;case p.SPACE:i.checkbox?h.nodeToggleSelected(b):h.nodeSetActive(b,!0);break;case p.ENTER:h.nodeSetActive(b,!0);break;case p.BACKSPACE:case p.LEFT:case p.RIGHT:case p.UP:case p.DOWN:e=g.navigate(f.which,o);break;default:n=!1}n&&f.preventDefault()},nodeLoadChildren:function(b,c){var d,f,g,h=b.tree,i=b.node;return a.isFunction(c)&&(c=c()),c.url&&(d=a.extend({},b.options.ajax,c),d.debugDelay?(f=d.debugDelay,a.isArray(f)&&(f=f[0]+Math.random()*(f[1]-f[0])),i.debug("nodeLoadChildren waiting debug delay "+Math.round(f)+"ms"),d.debugDelay=!1,g=a.Deferred(function(b){setTimeout(function(){a.ajax(d).done(function(){b.resolveWith(this,arguments)}).fail(function(){b.rejectWith(this,arguments)})},f)})):g=a.ajax(d),c=new a.Deferred,g.done(function(d){var e,f;if("string"==typeof d&&a.error("Ajax request returned a string (did you get the JSON dataType wrong?)."),b.options.postProcess){if(f=h._triggerNodeEvent("postProcess",b,b.originalEvent,{response:d,error:null,dataType:this.dataType}),f.error)return e=a.isPlainObject(f.error)?f.error:{message:f.error},e=h._makeHookContext(i,null,e),void c.rejectWith(this,[e]);d=a.isArray(f)?f:d}else d&&d.hasOwnProperty("d")&&b.options.enableAspx&&(d="string"==typeof d.d?a.parseJSON(d.d):d.d);c.resolveWith(this,[d])}).fail(function(a,b,d){var e=h._makeHookContext(i,null,{error:a,args:Array.prototype.slice.call(arguments),message:d,details:a.status+": "+d});c.rejectWith(this,[e])})),a.isFunction(c.promise)&&(e(!i.isLoading()),h.nodeSetStatus(b,"loading"),c.done(function(){h.nodeSetStatus(b,"ok")}).fail(function(a){var c;c=a.node&&a.error&&a.message?a:h._makeHookContext(i,null,{error:a,args:Array.prototype.slice.call(arguments),message:a?a.message||a.toString():""}),h._triggerNodeEvent("loadError",c,null)!==!1&&h.nodeSetStatus(b,"error",c.message,c.details)})),a.when(c).done(function(b){var c;a.isPlainObject(b)&&(e(a.isArray(b.children),"source must contain (or be) an array of children"),e(i.isRoot(),"source may only be an object for root nodes"),c=b,b=b.children,delete c.children,a.extend(h.data,c)),e(a.isArray(b),"expected array of children"),i._setChildren(b),h._triggerNodeEvent("loadChildren",i)})},nodeLoadKeyPath:function(){},nodeRemoveChild:function(b,c){var d,f=b.node,g=b.options,h=a.extend({},b,{node:c}),i=f.children;return 1===i.length?(e(c===i[0]),this.nodeRemoveChildren(b)):(this.activeNode&&(c===this.activeNode||this.activeNode.isDescendantOf(c))&&this.activeNode.setActive(!1),this.focusNode&&(c===this.focusNode||this.focusNode.isDescendantOf(c))&&(this.focusNode=null),this.nodeRemoveMarkup(h),this.nodeRemoveChildren(h),d=a.inArray(c,i),e(d>=0),c.visit(function(a){a.parent=null},!0),this._callHook("treeRegisterNode",this,!1,c),g.removeNode&&g.removeNode.call(b.tree,{type:"removeNode"},h),void i.splice(d,1))},nodeRemoveChildMarkup:function(b){var c=b.node;c.ul&&(c.isRoot()?a(c.ul).empty():(a(c.ul).remove(),c.ul=null),c.visit(function(a){a.li=a.ul=null}))},nodeRemoveChildren:function(b){var c,d=b.tree,e=b.node,f=e.children,g=b.options;f&&(this.activeNode&&this.activeNode.isDescendantOf(e)&&this.activeNode.setActive(!1),this.focusNode&&this.focusNode.isDescendantOf(e)&&(this.focusNode=null),this.nodeRemoveChildMarkup(b),c=a.extend({},b),e.visit(function(a){a.parent=null,d._callHook("treeRegisterNode",d,!1,a),g.removeNode&&(c.node=a,g.removeNode.call(b.tree,{type:"removeNode"},c))}),e.children=e.lazy?[]:null,this.nodeRenderStatus(b))},nodeRemoveMarkup:function(b){var c=b.node;c.li&&(a(c.li).remove(),c.li=null),this.nodeRemoveChildMarkup(b)},nodeRender:function(b,d,f,g,h){var i,j,k,l,m,n,o,p=b.node,q=b.tree,r=b.options,s=r.aria,t=!1,u=p.parent,v=!u,w=p.children;if(v||u.ul){if(e(v||u.ul,"parent UL must exist"),v||(p.li&&(d||p.li.parentNode!==p.parent.ul)&&(p.li.parentNode!==p.parent.ul&&this.warn("unlink "+p+" (must be child of "+p.parent+")"),this.nodeRemoveMarkup(b)),p.li?this.nodeRenderStatus(b):(t=!0,p.li=c.createElement("li"),p.li.ftnode=p,p.key&&r.generateIds&&(p.li.id=r.idPrefix+p.key),p.span=c.createElement("span"),p.span.className="fancytree-node",s&&a(p.span).attr("aria-labelledby","ftal_"+p.key),p.li.appendChild(p.span),this.nodeRenderTitle(b),r.createNode&&r.createNode.call(q,{type:"createNode"},b)),r.renderNode&&r.renderNode.call(q,{type:"renderNode"},b)),w){if(v||p.expanded||f===!0){for(p.ul||(p.ul=c.createElement("ul"),(g===!0&&!h||!p.expanded)&&(p.ul.style.display="none"),s&&a(p.ul).attr("role","group"),p.li?p.li.appendChild(p.ul):p.tree.$div.append(p.ul)),l=0,m=w.length;m>l;l++)o=a.extend({},b,{node:w[l]}),this.nodeRender(o,d,f,!1,!0);for(i=p.ul.firstChild;i;)k=i.ftnode,k&&k.parent!==p?(p.debug("_fixParent: remove missing "+k,i),n=i.nextSibling,i.parentNode.removeChild(i),i=n):i=i.nextSibling;for(i=p.ul.firstChild,l=0,m=w.length-1;m>l;l++)j=w[l],k=i.ftnode,j!==k?p.ul.insertBefore(j.li,k.li):i=i.nextSibling}}else p.ul&&(this.warn("remove child markup for "+p),this.nodeRemoveChildMarkup(b));v||t&&u.ul.appendChild(p.li)}},nodeRenderTitle:function(a,b){var c,e,f,g,h,i,j=a.node,k=a.tree,l=a.options,m=l.aria,n=j.getLevel(),o=[],p=j.data.icon;b!==d&&(j.title=b),j.span&&(n<l.minExpandLevel?(j.lazy||(j.expanded=!0),n>1&&o.push(m?"<span role='button' class='fancytree-expander fancytree-expander-fixed'></span>":"<span class='fancytree-expander fancytree-expander-fixed''></span>")):o.push(m?"<span role='button' class='fancytree-expander'></span>":"<span class='fancytree-expander'></span>"),l.checkbox&&j.hideCheckbox!==!0&&!j.isStatusNode()&&o.push(m?"<span role='checkbox' class='fancytree-checkbox'></span>":"<span class='fancytree-checkbox'></span>"),g=m?" role='img'":"",(p===!0||p!==!1&&l.icons!==!1)&&(p&&"string"==typeof p?(p="/"===p.charAt(0)?p:(l.imagePath||"")+p,o.push("<img src='"+p+"' class='fancytree-icon' alt='' />")):(e=l.iconClass&&l.iconClass.call(k,j,a)||j.data.iconclass||null,o.push(e?"<span "+g+" class='fancytree-custom-icon "+e+"'></span>":"<span "+g+" class='fancytree-icon'></span>"))),f="",l.renderTitle&&(f=l.renderTitle.call(k,{type:"renderTitle"},a)||""),f||(i=j.tooltip?" title='"+t.escapeHtml(j.tooltip)+"'":"",c=m?" id='ftal_"+j.key+"'":"",g=m?" role='treeitem'":"",h=l.titlesTabbable?" tabindex='0'":"",f="<span "+g+" class='fancytree-title'"+c+i+h+">"+j.title+"</span>"),o.push(f),j.span.innerHTML=o.join(""),this.nodeRenderStatus(a))},nodeRenderStatus:function(b){var c=b.node,d=b.tree,e=b.options,f=c.hasChildren(),g=c.isLastSibling(),h=e.aria,i=a(c.span).find(".fancytree-title"),j=e._classNames,k=[],l=c[d.statusClassPropName];l&&(k.push(j.node),d.activeNode===c&&k.push(j.active),d.focusNode===c?(k.push(j.focused),h&&i.attr("aria-activedescendant",!0)):h&&i.removeAttr("aria-activedescendant"),c.expanded?(k.push(j.expanded),h&&i.attr("aria-expanded",!0)):h&&i.removeAttr("aria-expanded"),c.folder&&k.push(j.folder),f!==!1&&k.push(j.hasChildren),g&&k.push(j.lastsib),c.lazy&&null==c.children&&k.push(j.lazy),c.partsel&&k.push(j.partsel),c.unselectable&&k.push(j.unselectable),c._isLoading&&k.push(j.loading),c._error&&k.push(j.error),c.selected?(k.push(j.selected),h&&i.attr("aria-selected",!0)):h&&i.attr("aria-selected",!1),c.extraClasses&&k.push(c.extraClasses),k.push(f===!1?j.combinedExpanderPrefix+"n"+(g?"l":""):j.combinedExpanderPrefix+(c.expanded?"e":"c")+(c.lazy&&null==c.children?"d":"")+(g?"l":"")),k.push(j.combinedIconPrefix+(c.expanded?"e":"c")+(c.folder?"f":"")),l.className=k.join(" "),c.li&&(c.li.className=g?j.lastsib:""))
86 },nodeSetActive:function(b,c,d){d=d||{};var f,g=b.node,h=b.tree,i=b.options,j=d.noEvents===!0,m=g===h.activeNode;return c=c!==!1,m===c?k(g):c&&!j&&this._triggerNodeEvent("beforeActivate",g,b.originalEvent)===!1?l(g,["rejected"]):void(c?(h.activeNode&&(e(h.activeNode!==g,"node was active (inconsistency)"),f=a.extend({},b,{node:h.activeNode}),h.nodeSetActive(f,!1),e(null===h.activeNode,"deactivate was out of sync?")),i.activeVisible&&g.makeVisible({scrollIntoView:!1}),h.activeNode=g,h.nodeRenderStatus(b),h.nodeSetFocus(b),j||h._triggerNodeEvent("activate",g,b.originalEvent)):(e(h.activeNode===g,"node was not active (inconsistency)"),h.activeNode=null,this.nodeRenderStatus(b),j||b.tree._triggerNodeEvent("deactivate",g,b.originalEvent)))},nodeSetExpanded:function(b,c,e){e=e||{};var f,g,h,i,j,m,n=b.node,o=b.tree,p=b.options,q=e.noAnimation===!0,r=e.noEvents===!0;if(c=c!==!1,n.expanded&&c||!n.expanded&&!c)return k(n);if(c&&!n.lazy&&!n.hasChildren())return k(n);if(!c&&n.getLevel()<p.minExpandLevel)return l(n,["locked"]);if(!r&&this._triggerNodeEvent("beforeExpand",n,b.originalEvent)===!1)return l(n,["rejected"]);if(q||n.isVisible()||(q=e.noAnimation=!0),g=new a.Deferred,c&&!n.expanded&&p.autoCollapse){j=n.getParentList(!1,!0),m=p.autoCollapse;try{for(p.autoCollapse=!1,h=0,i=j.length;i>h;h++)this._callHook("nodeCollapseSiblings",j[h],e)}finally{p.autoCollapse=m}}return g.done(function(){c&&p.autoScroll&&!q?n.getLastChild().scrollIntoView(!0,{topNode:n}).always(function(){r||b.tree._triggerNodeEvent(c?"expand":"collapse",b)}):r||b.tree._triggerNodeEvent(c?"expand":"collapse",b)}),f=function(d){var e,f,g,h;if(n.expanded=c,o._callHook("nodeRender",b,!1,!1,!0),n.ul)if(g="none"!==n.ul.style.display,h=!!n.expanded,g===h)n.warn("nodeSetExpanded: UL.style.display already set");else{if(p.fx&&!q)return e=p.fx.duration||200,f=p.fx.easing,void a(n.ul).animate(p.fx,e,f,function(){d()});n.ul.style.display=n.expanded||!parent?"":"none"}d()},c&&n.lazy&&n.hasChildren()===d?n.load().done(function(){g.notifyWith&&g.notifyWith(n,["loaded"]),f(function(){g.resolveWith(n)})}).fail(function(a){f(function(){g.rejectWith(n,["load failed ("+a+")"])})}):f(function(){g.resolveWith(n)}),g.promise()},nodeSetFocus:function(b,c){var d,e=b.tree,f=b.node;if(c=c!==!1,e.focusNode){if(e.focusNode===f&&c)return;d=a.extend({},b,{node:e.focusNode}),e.focusNode=null,this._triggerNodeEvent("blur",d),this._callHook("nodeRenderStatus",d)}c&&(this.hasFocus()||(f.debug("nodeSetFocus: forcing container focus"),this._callHook("treeSetFocus",b,!0,!0)),f.makeVisible({scrollIntoView:!1}),e.focusNode=f,this._triggerNodeEvent("focus",b),b.options.autoScroll&&f.scrollIntoView(),this._callHook("nodeRenderStatus",b))},nodeSetSelected:function(a,b){var c=a.node,d=a.tree,e=a.options;if(b=b!==!1,c.debug("nodeSetSelected("+b+")",a),!c.unselectable){if(c.selected&&b||!c.selected&&!b)return!!c.selected;if(this._triggerNodeEvent("beforeSelect",c,a.originalEvent)===!1)return!!c.selected;b&&1===e.selectMode?d.lastSelectedNode&&d.lastSelectedNode.setSelected(!1):3===e.selectMode&&(c.selected=b,c.fixSelection3AfterClick()),c.selected=b,this.nodeRenderStatus(a),d.lastSelectedNode=b?c:null,d._triggerNodeEvent("select",a)}},nodeSetStatus:function(b,c,d,e){function f(){var a=h.children?h.children[0]:null;if(a&&a.isStatusNode()){try{h.ul&&(h.ul.removeChild(a.li),a.li=null)}catch(b){}1===h.children.length?h.children=[]:h.children.shift()}}function g(b,c){var d=h.children?h.children[0]:null;return d&&d.isStatusNode()?(a.extend(d,b),i._callHook("nodeRenderTitle",d)):(b.key="_statusNode",h._setChildren([b]),h.children[0].statusNodeType=c,i.render()),h.children[0]}var h=b.node,i=b.tree;switch(c){case"ok":f(),h._isLoading=!1,h._error=null,h.renderStatus();break;case"loading":h.parent||g({title:i.options.strings.loading+(d?" ("+d+") ":""),tooltip:e,extraClasses:"fancytree-statusnode-wait"},c),h._isLoading=!0,h._error=null,h.renderStatus();break;case"error":g({title:i.options.strings.loadError+(d?" ("+d+") ":""),tooltip:e,extraClasses:"fancytree-statusnode-error"},c),h._isLoading=!1,h._error={message:d,details:e},h.renderStatus();break;default:a.error("invalid node status "+c)}},nodeToggleExpanded:function(a){return this.nodeSetExpanded(a,!a.node.expanded)},nodeToggleSelected:function(a){return this.nodeSetSelected(a,!a.node.selected)},treeClear:function(a){var b=a.tree;b.activeNode=null,b.focusNode=null,b.$div.find(">ul.fancytree-container").empty(),b.rootNode.children=null},treeCreate:function(){},treeDestroy:function(){},treeInit:function(a){this.treeLoad(a)},treeLoad:function(b,c){var d,e,f,g=b.tree,h=b.widget.element,i=a.extend({},b,{node:this.rootNode});if(g.rootNode.children&&this.treeClear(b),c=c||this.options.source)"string"==typeof c&&a.error("Not implemented");else switch(d=h.data("type")||"html"){case"html":e=h.find(">ul:first"),e.addClass("ui-fancytree-source ui-helper-hidden"),c=a.ui.fancytree.parseHtml(e),this.data=a.extend(this.data,n(e));break;case"json":c=a.parseJSON(h.text()),c.children&&(c.title&&(g.title=c.title),c=c.children);break;default:a.error("Invalid data-type: "+d)}return f=this.nodeLoadChildren(i,c).done(function(){g.render(),3===b.options.selectMode&&g.rootNode.fixSelection3FromEndNodes(),g._triggerTreeEvent("init",null,{status:!0})}).fail(function(){g.render(),g._triggerTreeEvent("init",null,{status:!1})})},treeRegisterNode:function(){},treeSetFocus:function(a,b){b=b!==!1,b!==this.hasFocus()&&(this._hasFocus=b,this.$container.toggleClass("fancytree-treefocus",b),this._triggerTreeEvent(b?"focusTree":"blurTree"))}}),a.widget("ui.fancytree",{options:{activeVisible:!0,ajax:{type:"GET",cache:!1,dataType:"json"},aria:!1,autoActivate:!0,autoCollapse:!1,autoScroll:!1,checkbox:!1,clickFolderMode:4,debugLevel:null,disabled:!1,enableAspx:!0,extensions:[],fx:{height:"toggle",duration:200},generateIds:!1,icons:!0,idPrefix:"ft_",focusOnSelect:!1,keyboard:!0,keyPathSeparator:"/",minExpandLevel:1,quicksearch:!1,scrollOfs:{top:0,bottom:0},scrollParent:null,selectMode:2,strings:{loading:"Loading&#8230;",loadError:"Load error!"},tabbable:!0,titlesTabbable:!1,_classNames:{node:"fancytree-node",folder:"fancytree-folder",combinedExpanderPrefix:"fancytree-exp-",combinedIconPrefix:"fancytree-ico-",hasChildren:"fancytree-has-children",active:"fancytree-active",selected:"fancytree-selected",expanded:"fancytree-expanded",lazy:"fancytree-lazy",focused:"fancytree-focused",partsel:"fancytree-partsel",unselectable:"fancytree-unselectable",lastsib:"fancytree-lastsib",loading:"fancytree-loading",error:"fancytree-error"},lazyLoad:null,postProcess:null},_create:function(){this.tree=new r(this),this.$source=this.source||"json"===this.element.data("type")?this.element:this.element.find(">ul:first");var b,c,f,g=this.options.extensions,h=this.tree;for(f=0;f<g.length;f++)c=g[f],b=a.ui.fancytree._extensions[c],b||a.error("Could not apply extension '"+c+"' (it is not registered, did you forget to include it?)"),this.tree.options[c]=a.extend(!0,{},b.options,this.tree.options[c]),e(this.tree.ext[c]===d,"Extension name must not exist as Fancytree.ext attribute: '"+c+"'"),this.tree.ext[c]={},j(this.tree,h,b,c),h=b;this.tree._callHook("treeCreate",this.tree)},_init:function(){this.tree._callHook("treeInit",this.tree),this._bind()},_setOption:function(b,c){var d=!0,e=!1;switch(b){case"aria":case"checkbox":case"icons":case"minExpandLevel":case"tabbable":this.tree._callHook("treeCreate",this.tree),e=!0;break;case"source":d=!1,this.tree._callHook("treeLoad",this.tree,c)}this.tree.debug("set option "+b+"="+c+" <"+typeof c+">"),d&&a.Widget.prototype._setOption.apply(this,arguments),e&&this.tree.render(!0,!1)},destroy:function(){this._unbind(),this.tree._callHook("treeDestroy",this.tree),this.tree.$div.find(">ul.fancytree-container").remove(),this.$source&&this.$source.removeClass("ui-helper-hidden"),a.Widget.prototype.destroy.call(this)},_unbind:function(){var b=this.tree._ns;this.element.unbind(b),this.tree.$container.unbind(b),a(c).unbind(b)},_bind:function(){var a=this,b=this.options,c=this.tree,d=c._ns;this._unbind(),c.$container.on("focusin"+d+" focusout"+d,function(a){var b=t.getNode(a),d="focusin"===a.type;b?c._callHook("nodeSetFocus",b,d):c._callHook("treeSetFocus",c,d)}).on("selectstart"+d,"span.fancytree-title",function(a){a.preventDefault()}).on("keydown"+d,function(a){if(b.disabled||b.keyboard===!1)return!0;var d,e=c.focusNode,f=c._makeHookContext(e||c,a),g=c.phase;try{return c.phase="userEvent",d=e?c._triggerNodeEvent("keydown",e,a):c._triggerTreeEvent("keydown",a),"preventNav"===d?d=!0:d!==!1&&(d=c._callHook("nodeKeydown",f)),d}finally{c.phase=g}}).on("click"+d+" dblclick"+d,function(c){if(b.disabled)return!0;var d,e=t.getEventTarget(c),f=e.node,g=a.tree,h=g.phase;if(!f)return!0;d=g._makeHookContext(f,c);try{switch(g.phase="userEvent",c.type){case"click":return d.targetType=e.type,g._triggerNodeEvent("click",d,c)===!1?!1:g._callHook("nodeClick",d);case"dblclick":return d.targetType=e.type,g._triggerNodeEvent("dblclick",d,c)===!1?!1:g._callHook("nodeDblclick",d)}}finally{g.phase=h}})},getActiveNode:function(){return this.tree.activeNode},getNodeByKey:function(a){return this.tree.getNodeByKey(a)},getRootNode:function(){return this.tree.rootNode},getTree:function(){return this.tree}}),t=a.ui.fancytree,a.extend(a.ui.fancytree,{version:"2.6.0",buildType: "production",debugLevel: 1,_nextId:1,_nextNodeKey:1,_extensions:{},_FancytreeClass:r,_FancytreeNodeClass:q,jquerySupports:{positionMyOfs:h(a.ui.version,1,9)},assert:function(a,b){return e(a,b)},debounce:function(a,b,c,d){var e;return 3===arguments.length&&"boolean"!=typeof c&&(d=c,c=!1),function(){var f=arguments;d=d||this,c&&!e&&b.apply(d,f),clearTimeout(e),e=setTimeout(function(){c||b.apply(d,f),e=null},a)}},debug:function(){a.ui.fancytree.debugLevel>=2&&f("log",arguments)},error:function(){f("error",arguments)},escapeHtml:function(a){return(""+a).replace(/[&<>"'\/]/g,function(a){return u[a]})},unescapeHtml:function(a){var b=c.createElement("div");return b.innerHTML=a,0===b.childNodes.length?"":b.childNodes[0].nodeValue},getEventTargetType:function(a){return this.getEventTarget(a).type},getEventTarget:function(b){var c=b&&b.target?b.target.className:"",e={node:this.getNode(b.target),type:d};return/\bfancytree-title\b/.test(c)?e.type="title":/\bfancytree-expander\b/.test(c)?e.type=e.node.hasChildren()===!1?"prefix":"expander":/\bfancytree-checkbox\b/.test(c)||/\bfancytree-radio\b/.test(c)?e.type="checkbox":/\bfancytree-icon\b/.test(c)?e.type="icon":/\bfancytree-node\b/.test(c)?e.type="title":b&&b.target&&a(b.target).closest(".fancytree-title").length&&(e.type="title"),e},getNode:function(a){if(a instanceof q)return a;for(a.selector!==d?a=a[0]:a.originalEvent!==d&&(a=a.target);a;){if(a.ftnode)return a.ftnode;a=a.parentNode}return null},info:function(){a.ui.fancytree.debugLevel>=1&&f("info",arguments)},parseHtml:function(b){var c,e,f,g,h,i,j,k,l=b.find(">li"),m=[];return l.each(function(){var l,o=a(this),p=o.find(">span:first",this),q=p.length?null:o.find(">a:first"),r={tooltip:null,data:{}};for(p.length?r.title=p.html():q&&q.length?(r.title=q.html(),r.data.href=q.attr("href"),r.data.target=q.attr("target"),r.tooltip=q.attr("title")):(r.title=o.html(),g=r.title.search(/<ul/i),g>=0&&(r.title=r.title.substring(0,g))),r.title=a.trim(r.title),e=0,f=v.length;f>e;e++)r[v[e]]=d;for(j=this.className.split(" "),c=[],e=0,f=j.length;f>e;e++)k=j[e],w[k]?r[k]=!0:c.push(k);if(r.extraClasses=c.join(" "),h=o.attr("title"),h&&(r.tooltip=h),h=o.attr("id"),h&&(r.key=h),l=n(o),l&&!a.isEmptyObject(l)){for(e=0,f=x.length;f>e;e++)h=x[e],i=l[h],null!=i&&(delete l[h],r[h]=i);a.extend(r.data,l)}b=o.find(">ul:first"),r.children=b.length?a.ui.fancytree.parseHtml(b):r.lazy?d:null,m.push(r)}),m},registerExtension:function(b){e(null!=b.name,"extensions must have a `name` property."),e(null!=b.version,"extensions must have a `version` property."),a.ui.fancytree._extensions[b.name]=b},warn:function(){f("warn",arguments)}})}(jQuery,window,document);
87
88 /*! Extension 'jquery.fancytree.filter.min.js' */
89 !function(a){"use strict";function b(a){return(a+"").replace(/([.?*+\^\$\[\]\\(){}|-])/g,"\\$1")}a.ui.fancytree._FancytreeClass.prototype._applyFilterImpl=function(a,c,d){var e,f,g=0,h="hide"===this.options.filter.mode;return d=!!d&&!c,"string"==typeof a&&(e=b(a),f=new RegExp(".*"+e+".*","i"),a=function(a){return!!f.exec(a.title)}),this.enableFilter=!0,this.lastFilterArgs=arguments,this.$div.addClass("fancytree-ext-filter"),this.$div.addClass(h?"fancytree-ext-filter-hide":"fancytree-ext-filter-dimm"),this.visit(function(a){delete a.match,delete a.subMatch}),this.visit(function(b){return d&&null!=b.children||!a(b)||(g++,b.match=!0,b.visitParents(function(a){a.subMatch=!0}),!c)?void 0:(b.visit(function(a){a.match=!0}),"skip")}),this.render(),g},a.ui.fancytree._FancytreeClass.prototype.filterNodes=function(a,b){return this._applyFilterImpl(a,!1,b)},a.ui.fancytree._FancytreeClass.prototype.applyFilter=function(){return this.warn("Fancytree.applyFilter() is deprecated since 2014-05-10. Use .filterNodes() instead."),this.filterNodes.apply(this,arguments)},a.ui.fancytree._FancytreeClass.prototype.filterBranches=function(a){return this._applyFilterImpl(a,!0,null)},a.ui.fancytree._FancytreeClass.prototype.clearFilter=function(){this.visit(function(a){delete a.match,delete a.subMatch}),this.enableFilter=!1,this.lastFilterArgs=null,this.$div.removeClass("fancytree-ext-filter fancytree-ext-filter-dimm fancytree-ext-filter-hide"),this.render()},a.ui.fancytree.registerExtension({name:"filter",version:"0.3.0",options:{autoApply:!0,mode:"dimm"},treeInit:function(a){this._super(a)},nodeLoadChildren:function(a,b){return this._super(a,b).done(function(){a.tree.enableFilter&&a.tree.lastFilterArgs&&a.options.filter.autoApply&&a.tree._applyFilterImpl.apply(a.tree,a.tree.lastFilterArgs)})},nodeRenderStatus:function(b){var c,d=b.node,e=b.tree,f=a(d[e.statusClassPropName]);return c=this._super(b),f.length&&e.enableFilter?(f.toggleClass("fancytree-match",!!d.match).toggleClass("fancytree-submatch",!!d.subMatch).toggleClass("fancytree-hide",!(d.match||d.subMatch)),c):c}})}(jQuery,window,document);
90
91 /*! Extension 'jquery.fancytree.gridnav.min.js' */
92 !function(a){"use strict";function b(b,c){var d,e=c.get(0),f=0;return b.children().each(function(){return this===e?!1:(d=a(this).prop("colspan"),void(f+=d?d:1))}),f}function c(b,c){var d,e=null,f=0;return b.children().each(function(){return f>=c?(e=a(this),!1):(d=a(this).prop("colspan"),void(f+=d?d:1))}),e}function d(a,d){var f,g,h=a.closest("td"),i=null;switch(d){case e.LEFT:i=h.prev();break;case e.RIGHT:i=h.next();break;case e.UP:case e.DOWN:for(f=h.parent(),g=b(f,h);;){if(f=d===e.UP?f.prev():f.next(),!f.length)break;if(!f.is(":hidden")&&(i=c(f,g),i&&i.find(":input").length))break}}return i}var e=a.ui.keyCode,f={text:[e.UP,e.DOWN],checkbox:[e.UP,e.DOWN,e.LEFT,e.RIGHT],radiobutton:[e.UP,e.DOWN,e.LEFT,e.RIGHT],"select-one":[e.LEFT,e.RIGHT],"select-multiple":[e.LEFT,e.RIGHT]};a.ui.fancytree.registerExtension({name:"gridnav",version:"0.0.1",options:{autofocusInput:!1,handleCursorKeys:!0},treeInit:function(b){this._requireExtension("table",!0,!0),this._super(b),this.$container.addClass("fancytree-ext-gridnav"),this.$container.on("focusin",function(c){var d,e=a.ui.fancytree.getNode(c.target);e&&!e.isActive()&&(d=b.tree._makeHookContext(e,c),b.tree._callHook("nodeSetActive",d,!0))})},nodeSetActive:function(b,c){var d,e=b.options.gridnav,f=b.node,g=b.originalEvent||{},h=a(g.target).is(":input");c=c!==!1,this._super(b,c),c&&(b.options.titlesTabbable?(h||(a(f.span).find("span.fancytree-title").focus(),f.setFocus()),b.tree.$container.attr("tabindex","-1")):e.autofocusInput&&!h&&(d=a(f.tr||f.span),d.find(":input:enabled:first").focus()))},nodeKeydown:function(b){var c,e,g,h=b.options.gridnav,i=b.originalEvent,j=a(i.target);return c=j.is(":input:enabled")?j.prop("type"):null,c&&h.handleCursorKeys?(e=f[c],e&&a.inArray(i.which,e)>=0&&(g=d(j,i.which),g&&g.length)?(g.find(":input:enabled").focus(),!1):!0):(b.tree.debug("ext-gridnav NOT HANDLED",i,c),this._super(b))}})}(jQuery,window,document);
93
94 /*! Extension 'jquery.fancytree.table.min.js' */
95 !function(a,b,c){"use strict";function d(b,c){c=c||"",b||a.error("Assertion failed "+c)}function e(a,b){a.parentNode.insertBefore(b,a.nextSibling)}function f(a,b){a.visit(function(a){var c=a.tr;return c&&(c.style.display=a.hide||!b?"none":""),a.expanded?void 0:"skip"})}function g(b){var c,e,f,g=b.parent,h=g?g.children:null;if(h&&h.length>1&&h[0]!==b)for(c=a.inArray(b,h),f=h[c-1],d(f.tr);f.children&&(e=f.children[f.children.length-1],e.tr);)f=e;else f=g;return f}a.ui.fancytree.registerExtension({name:"table",version:"0.2.0",options:{checkboxColumnIdx:null,customStatus:!1,indentation:16,nodeColumnIdx:0},treeInit:function(b){var d,e,f,g=b.tree,h=g.widget.element;for(h.addClass("fancytree-container fancytree-ext-table"),g.tbody=h.find("> tbody")[0],g.columnCount=a("thead >tr >th",h).length,a(g.tbody).empty(),g.rowFragment=c.createDocumentFragment(),e=a("<tr />"),f="",b.options.aria&&(e.attr("role","row"),f=" role='gridcell'"),d=0;d<g.columnCount;d++)e.append(b.options.table.nodeColumnIdx===d?"<td"+f+"><span class='fancytree-node' /></td>":"<td"+f+" />");g.rowFragment.appendChild(e.get(0)),g.statusClassPropName="tr",g.ariaPropName="tr",this.nodeContainerAttrName="tr",this._super(b),a(g.rootNode.ul).remove(),g.rootNode.ul=null,g.$container=h,this.$container.attr("tabindex",this.options.tabbable?"0":"-1"),this.options.aria&&g.$container.attr("role","treegrid").attr("aria-readonly",!0)},nodeRemoveChildMarkup:function(b){var c=b.node;c.visit(function(b){b.tr&&(a(b.tr).remove(),b.tr=null)})},nodeRemoveMarkup:function(b){var c=b.node;c.tr&&(a(c.tr).remove(),c.tr=null),this.nodeRemoveChildMarkup(b)},nodeRender:function(b,c,h,i,j){var k,l,m,n,o,p,q,r,s=b.tree,t=b.node,u=b.options,v=!t.parent;if(j||(b.hasCollapsedParents=t.parent&&!t.parent.expanded),!v)if(t.tr)c?this.nodeRenderTitle(b):this.nodeRenderStatus(b);else{if(b.hasCollapsedParents)return void t.debug("nodeRender ignored due to unrendered parent");o=s.rowFragment.firstChild.cloneNode(!0),p=g(t),d(p),i===!0&&j?o.style.display="none":h&&b.hasCollapsedParents&&(o.style.display="none"),p.tr?e(p.tr,o):(d(!p.parent,"prev. row must have a tr, or is system root"),s.tbody.appendChild(o)),t.tr=o,t.key&&u.generateIds&&(t.tr.id=u.idPrefix+t.key),t.tr.ftnode=t,u.aria&&a(t.tr).attr("aria-labelledby","ftal_"+t.key),t.span=a("span.fancytree-node",t.tr).get(0),this.nodeRenderTitle(b),u.createNode&&u.createNode.call(s,{type:"createNode"},b)}if(u.renderNode&&u.renderNode.call(s,{type:"renderNode"},b),k=t.children,k&&(v||h||t.expanded))for(m=0,n=k.length;n>m;m++)r=a.extend({},b,{node:k[m]}),r.hasCollapsedParents=r.hasCollapsedParents||!t.expanded,this.nodeRender(r,c,h,i,!0);k&&!j&&(q=t.tr||null,l=s.tbody.firstChild,t.visit(function(a){if(a.tr){if(a.parent.expanded||"none"===a.tr.style.display||(a.tr.style.display="none",f(a,!1)),a.tr.previousSibling!==q){t.debug("_fixOrder: mismatch at node: "+a);var b=q?q.nextSibling:l;s.tbody.insertBefore(a.tr,b)}q=a.tr}}))},nodeRenderTitle:function(b){var c,d=b.node,e=b.options;this._super(b),e.checkbox&&null!=e.table.checkboxColumnIdx&&(c=a("span.fancytree-checkbox",d.span).detach(),a(d.tr).find("td:first").html(c)),d.isRoot()||this.nodeRenderStatus(b),!e.table.customStatus&&d.isStatusNode()||e.renderColumns&&e.renderColumns.call(b.tree,{type:"renderColumns"},b)},nodeRenderStatus:function(b){var c,d=b.node,e=b.options;this._super(b),a(d.tr).removeClass("fancytree-node"),c=(d.getLevel()-1)*e.table.indentation,a(d.span).css({marginLeft:c+"px"})},nodeSetExpanded:function(b,c,d){function e(a){c=c!==!1,f(b.node,c),a?c&&b.options.autoScroll&&!d.noAnimation&&b.node.hasChildren()?b.node.getLastChild().scrollIntoView(!0,{topNode:b.node}).always(function(){d.noEvents||b.tree._triggerNodeEvent(c?"expand":"collapse",b),g.resolveWith(b.node)}):(d.noEvents||b.tree._triggerNodeEvent(c?"expand":"collapse",b),g.resolveWith(b.node)):(d.noEvents||b.tree._triggerNodeEvent(c?"expand":"collapse",b),g.rejectWith(b.node))}var g=new a.Deferred,h=a.extend({},d,{noEvents:!0,noAnimation:!0});return d=d||{},this._super(b,c,h).done(function(){e(!0)}).fail(function(){e(!1)}),g.promise()},nodeSetStatus:function(b,c,d,e){if("ok"===c){var f=b.node,g=f.children?f.children[0]:null;g&&g.isStatusNode()&&a(g.tr).remove()}this._super(b,c,d,e)},treeClear:function(a){return this.nodeRemoveChildMarkup(this._makeHookContext(this.rootNode)),this._super(a)}})}(jQuery,window,document);
96
97 /*! Extension 'jquery.fancytree.themeroller.min.js' */
98 !function(a){"use strict";a.ui.fancytree.registerExtension({name:"themeroller",version:"0.0.1",options:{activeClass:"ui-state-active",foccusClass:"ui-state-focus",hoverClass:"ui-state-hover",selectedClass:"ui-state-highlight"},treeInit:function(b){this._super(b);var c=b.widget.element;"TABLE"===c[0].nodeName?(c.addClass("ui-widget ui-corner-all"),c.find(">thead tr").addClass("ui-widget-header"),c.find(">tbody").addClass("ui-widget-conent")):c.addClass("ui-widget ui-widget-content ui-corner-all"),c.delegate(".fancytree-node","mouseenter mouseleave",function(b){var c=a.ui.fancytree.getNode(b.target),d="mouseenter"===b.type;c.debug("hover: "+d),a(c.span).toggleClass("ui-state-hover ui-corner-all",d)})},treeDestroy:function(a){this._super(a),a.widget.element.removeClass("ui-widget ui-widget-content ui-corner-all")},nodeRenderStatus:function(b){var c=b.node,d=a(c.span);this._super(b),d.toggleClass("ui-state-active",c.isActive()),d.toggleClass("ui-state-focus",c.hasFocus()),d.toggleClass("ui-state-highlight",c.isSelected())}})}(jQuery,window,document);
99}));
100// --------------------------- END jquery.fancytree-all.min.js -----------------------------------------------------
101
102// --------------------------- selectID.js -----------------------------------------------------
103/*
104 Copyright 2014-2015 bluefox <bluefox@ccu.io>
105 */
106(function ($) {
107 if ($.fn.selectId) return;
108
109 var instance = 0;
110
111 function formatDate(dateObj) {
112 //return dateObj.getFullYear() + '-' +
113 // ("0" + (dateObj.getMonth() + 1).toString(10)).slice(-2) + '-' +
114 // ("0" + (dateObj.getDate()).toString(10)).slice(-2) + ' ' +
115 // ("0" + (dateObj.getHours()).toString(10)).slice(-2) + ':' +
116 // ("0" + (dateObj.getMinutes()).toString(10)).slice(-2) + ':' +
117 // ("0" + (dateObj.getSeconds()).toString(10)).slice(-2);
118 // Following implementation is 5 times faster
119 if (!dateObj) return '';
120
121 var text = dateObj.getFullYear();
122 var v = dateObj.getMonth() + 1;
123 if (v < 10) {
124 text += '-0' + v;
125 } else {
126 text += '-' + v;
127 }
128
129 v = dateObj.getDate();
130 if (v < 10) {
131 text += '-0' + v;
132 } else {
133 text += '-' + v;
134 }
135
136 v = dateObj.getHours();
137 if (v < 10) {
138 text += ' 0' + v;
139 } else {
140 text += ' ' + v;
141 }
142 v = dateObj.getMinutes();
143 if (v < 10) {
144 text += ':0' + v;
145 } else {
146 text += ':' + v;
147 }
148
149 v = dateObj.getSeconds();
150 if (v < 10) {
151 text += ':0' + v;
152 } else {
153 text += ':' + v;
154 }
155
156 return text;
157 }
158
159 function filterId(data, id) {
160 if (data.filter) {
161 if (data.filter.type && data.filter.type != data.objects[id].type) return false;
162
163 if (data.filter.common && data.filter.common.history && data.filter.common.history.enabled) {
164 if (!data.objects[id].common ||
165 !data.objects[id].common.history ||
166 !data.objects[id].common.history.enabled) return false;
167 }
168 }
169 return true;
170 }
171
172 function getAllStates(data) {
173 var objects = data.objects;
174 var isType = data.columns.indexOf('type') != -1;
175 var isRoom = data.columns.indexOf('room') != -1;
176 var isRole = data.columns.indexOf('role') != -1;
177 data.tree = {title: '', children: [], count: 0, root: true};
178
179 for (var id in objects) {
180
181 if (!filterId(data, id)) continue;
182
183 treeInsert(data, id, data.currentId == id);
184
185 if (objects[id].enums) {
186 for (var e in objects[id].enums) {
187 if (objects[e] &&
188 objects[e].common &&
189 objects[e].common.members &&
190 objects[e].common.members.indexOf(id) == -1) {
191 objects[e].common.members.push(id);
192 }
193 }
194 }
195
196 if (isRoom && objects[id].type == 'enum' && data.regexEnumRooms.test(id)) data.enums.push(id);
197
198
199 if (isType && data.types.indexOf(objects[id].type) == -1) data.types.push(objects[id].type);
200
201 if (isRole && objects[id].common && objects[id].common.role) {
202 var parts = objects[id].common.role.split('.');
203 var role = '';
204 for (var u = 0; u < parts.length; u++) {
205 role += (role ? '.' : '') + parts[u];
206 if (data.roles.indexOf(role) == -1) data.roles.push(role);
207 }
208 }
209 }
210 data.inited = true;
211 data.roles.sort();
212 data.types.sort();
213 data.enums.sort();
214 }
215
216 function treeSplit(data, id) {
217 if (!id) {
218 console.log('AAAA');
219 return null;
220 }
221 var parts = id.split('.');
222 if (data.regexSystemAdapter.test(id)) {
223 if (parts.length > 3) {
224 parts[0] = 'system.adapter.' + parts[2] + '.' + parts[3];
225 parts.splice(1, 3);
226 } else {
227 parts[0] = 'system.adapter.' + parts[2];
228 parts.splice(1, 2);
229 }
230 } else if (data.regexSystemHost.test(id)) {
231 parts[0] = 'system.host.' + parts[2];
232 parts.splice(1, 2);
233 } else if (parts.length > 1) {
234 parts[0] = parts[0] + '.' + parts[1];
235 parts.splice(1, 1);
236 }
237
238 /*if (optimized) {
239 parts = treeOptimizePath(parts);
240 }*/
241
242 return parts;
243 }
244
245 function _deleteTree(node, deletedNodes) {
246 if (node.parent) {
247 if (deletedNodes && node.id) deletedNodes.push(node);
248 var p = node.parent;
249 if (p.children.length <= 1) {
250 _deleteTree(node.parent);
251 } else {
252 for (var z = 0; z < p.children.length; z++) {
253 if (node.key == p.children[z].key) {
254 p.children.splice(z, 1);
255 break;
256 }
257 }
258 }
259 } else {
260 //error
261 }
262 }
263
264 function deleteTree(data, id, deletedNodes) {
265 var node = findTree(data, id);
266 if (!node) {
267 console.log('Id ' + id + ' not found');
268 return;
269 }
270 _deleteTree(node, deletedNodes);
271 }
272
273 function findTree(data, id) {
274 return _findTree(data.tree, treeSplit(data, id, false), 0);
275 }
276 function _findTree(tree, parts, index) {
277 var num = -1;
278 for (var j = 0; j < tree.children.length; j++) {
279 if (tree.children[j].title == parts[index]) {
280 num = j;
281 break;
282 }
283 if (tree.children[j].title > parts[index]) break;
284 }
285
286 if (num == -1) return null;
287
288 if (parts.length - 1 == index) {
289 return tree.children[num];
290 } else {
291 return _findTree(tree.children[num], parts, index + 1);
292 }
293 }
294
295 function treeInsert(data, id, isExpanded, addedNodes) {
296 return _treeInsert(data.tree, data.list ? [id] : treeSplit(data, id, false), id, 0, isExpanded, addedNodes);
297 }
298 function _treeInsert(tree, parts, id, index, isExpanded, addedNodes) {
299 if (!index) index = 0;
300
301 var num = -1;
302 var j;
303 for (j = 0; j < tree.children.length; j++) {
304 if (tree.children[j].title == parts[index]) {
305 num = j;
306 break;
307 }
308 if (tree.children[j].title > parts[index]) break;
309 }
310
311 if (num == -1) {
312 tree.folder = true;
313 tree.expanded = isExpanded;
314
315 var fullName = '';
316 for (var i = 0; i <= index; i++) {
317 fullName += ((fullName) ? '.' : '') + parts[i];
318 }
319 var obj = {
320 key: fullName,
321 children: [],
322 title: parts[index],
323 folder: false,
324 expanded: false,
325 parent: tree
326 };
327 if (j == tree.children.length) {
328 num = tree.children.length;
329 tree.children.push(obj);
330 } else {
331 num = j;
332 tree.children.splice(num, 0, obj);
333 }
334 if (addedNodes) addedNodes.push(tree.children[num]);
335 }
336 if (parts.length - 1 == index) {
337 tree.children[num].id = id;
338 } else {
339 tree.children[num].expanded = tree.children[num].expanded || isExpanded;
340 _treeInsert(tree.children[num], parts, id, index + 1, isExpanded, addedNodes);
341 }
342 }
343
344 function showActive($dlg, scrollIntoView) {
345 var data = $dlg.data('selectId');
346 // Select current element
347 if (data.selectedID) {
348 data.$tree.fancytree('getTree').visit(function (node) {
349 if (node.key == data.selectedID) {
350 node.setActive();
351 node.makeVisible({scrollIntoView: scrollIntoView || false});
352 return false;
353 }
354 });
355 }
356 }
357
358 function initTreeDialog($dlg) {
359 var c;
360 var data = $dlg.data('selectId');
361 var noStates = (data.objects && !data.states);
362 // Get all states
363 getAllStates(data);
364
365 if (!data.noDialog && !data.buttonsDlg) {
366 data.buttonsDlg = [
367 {
368 id: data.instance + '-button-ok',
369 text: data.texts.select,
370 click: function () {
371 var _data = $dlg.data('selectId');
372 if (_data && _data.onSuccess) _data.onSuccess(_data.selectedID, _data.currentId);
373 _data.currentId = _data.selectedID;
374 $dlg.dialog('close');
375 }
376 },
377 {
378 id: data.instance + '-button-cancel',
379 text: data.texts.cancel,
380 click: function () {
381 $(this).dialog('close');
382 }
383 }
384 ];
385
386 $dlg.dialog({
387 autoOpen: false,
388 modal: true,
389 width: '90%',
390 height: 500,
391 buttons: data.buttonsDlg
392 });
393 if (data.zindex !== null) {
394 $('div[aria-describedby="' + $dlg.attr('id') + '"]').css({'z-index': data.zindex})
395 }
396 }
397
398 // Store current filter
399 var filter = {ID: $('#filter_ID_' + data.instance).val()};
400 for (var u = 0; u < data.columns.length; u++) {
401 filter[data.columns[u]] = $('#filter_' + data.columns[u] + '_' + data.instance).val();
402 }
403
404 var textRooms;
405 if (data.columns.indexOf('room') != -1) {
406 textRooms = '<select id="filter_room_' + data.instance + '" class="filter_' + data.instance + '" style="padding:0;width:150px"><option value="">' + data.texts.all + '</option>';
407 for (var i = 0; i < data.enums.length; i++) {
408 textRooms += '<option value="' + data.objects[data.enums[i]].common.name + '">' + data.objects[data.enums[i]].common.name + '</option>';
409 }
410 textRooms += '</select>';
411 } else {
412 if (data.rooms) delete data.rooms;
413 }
414
415 var textRoles;
416 if (data.columns.indexOf('role') != -1) {
417 textRoles = '<select id="filter_role_' + data.instance + '" class="filter_' + data.instance + '" style="padding:0;width:150px"><option value="">' + data.texts.all + '</option>';
418 for (var j = 0; j < data.roles.length; j++) {
419 textRoles += '<option value="' + data.roles[j] + '">' + data.roles[j] + '</option>';
420 }
421 textRoles += '</select>';
422 }
423
424 var textTypes;
425 if (data.columns.indexOf('type') != -1) {
426 textTypes = '<select id="filter_type_' + data.instance + '" class="filter_' + data.instance + '" style="padding:0;width:150px"><option value="">' + data.texts.all + '</option>';
427 for (k = 0; k < data.types.length; k++) {
428 textTypes += '<option value="' + data.types[k] + '">' + data.types[k] + '</option>';
429 }
430 textTypes += '</select>';
431 }
432
433 var text = '<div id="' + data.instance + '-div" style="width:100%; height:100%"><table id="selectID_header_' + data.instance + '" style="width: 100%;padding:0; height: 50" cellspacing="0" cellpadding="0">';
434 text += '<colgroup>';
435 text += ' <col width="1px"/>';
436 text += ' <col width="400px"/>';
437
438 for (c = 0; c < data.columns.length; c++) {
439 if (data.columns[c] == 'image') {
440 text += '<col width="' + (data.widths ? data.widths[c] : '20px') + '"/>';
441 } else if (data.columns[c] == 'name') {
442 text += '<col width="' + (data.widths ? data.widths[c] : '*') + '"/>';
443 } else if (data.columns[c] == 'type') {
444 text += '<col width="' + (data.widths ? data.widths[c] : '150px') + '"/>';
445 } else if (data.columns[c] == 'role') {
446 text += '<col width="' + (data.widths ? data.widths[c] : '150px') + '"/>';
447 } else if (data.columns[c] == 'room') {
448 text += '<col width="' + (data.widths ? data.widths[c] : '150px') + '"/>';
449 } else if (data.columns[c] == 'value') {
450 text += '<col width="' + (data.widths ? data.widths[c] : '150px') + '"/>';
451 } else if (data.columns[c] == 'button') {
452 text += '<col width="' + (data.widths ? data.widths[c] : '100px') + '"/>';
453 } else if (data.columns[c] == 'enum') {
454 text += '<col width="' + (data.widths ? data.widths[c] : '*') + '"/>';
455 }
456 }
457
458 text += ' <col width="18px"/>'; // TODO calculate width of scroll bar
459 text += ' </colgroup>';
460 text += ' <thead>';
461 text += ' <tr><th></th><th><table style="width: 100%; padding:0" cellspacing="0" cellpadding="0"><tr>';
462 text += '<td><button id="btn_refresh_' + data.instance + '"></button></td>';
463 text += '<td><button id="btn_list_' + data.instance + '"></button></td>';
464 text += '<td><button id="btn_collapse_' + data.instance + '"></button></td>';
465 text += '<td><button id="btn_expand_' + data.instance + '"></button></td>';
466 if (data.panelButtons) {
467 for (c = 0; c < data.panelButtons.length; c++) {
468 text += '<td><button id="btn_custom_' + data.instance + '_' + c + '"></button></td>';
469 }
470 }
471
472 text += '<td style="width: 100%; text-align: center; font-weight: bold">' + data.texts.id + '</td></tr></table></th>';
473
474 for (c = 0; c < data.columns.length; c++) {
475 text += '<th>' + (data.texts[data.columns[c]] || '') + '</th>';
476 }
477
478 text += '<th></th></tr>';
479 text += ' </thead>';
480 text += ' <tbody>';
481 text += ' <tr><td></td>';
482 text += ' <td><table style="width:100%"><tr><td style="width:100%"><input style="width:100%;padding:0" type="text" id="filter_ID_' + data.instance + '" class="filter_' + data.instance + '"/></td><td style="vertical-align: top;"><button data-id="filter_ID_' + data.instance + '" class="filter_btn_' + data.instance + '"></button></td></tr></table></td>';
483
484 for (c = 0; c < data.columns.length; c++) {
485 if (data.columns[c] == 'image') {
486 text += '<td></td>';
487 } else if (data.columns[c] == 'name' || data.columns[c] == 'value' || data.columns[c] == 'enum') {
488 text += '<td><table style="width:100%"><tr><td style="width:100%"><input style="width:100%;padding:0" type="text" id="filter_' + data.columns[c] + '_' + data.instance + '" class="filter_' + data.instance + '"/></td><td style="vertical-align: top;"><button data-id="filter_' + data.columns[c] + '_' + data.instance + '" class="filter_btn_' + data.instance + '"></button></td></tr></table></td>';
489 } else if (data.columns[c] == 'type') {
490 text += '<td>' + textTypes + '</td>';
491 } else if (data.columns[c] == 'role') {
492 text += '<td>' + textRoles + '</td>';
493 } else if (data.columns[c] == 'room') {
494 text += '<td>' + textRooms + '</td>';
495 } else if (data.columns[c] == 'button') {
496 text += '<td style="text-align: center">';
497 if (data.customButtonFilter) {
498 var t = '<select id="filter_' + data.columns[c] + '_' + data.instance + '" class="filter_' + data.instance + '">';
499 t += '<option value="">' + data.texts.all + '</option>';
500 t += '<option value="true">' + data.texts.with + '</option>';
501 t += '<option value="false">' + data.texts.without + '</option>';
502 t += '</select>';
503
504 text += '<table cellpadding="0" cellspacing="0" style="border-spacing: 0px 0px"><tr><td>' + t + '</td>' + '<td><button id="filter_' + data.columns[c] + '_' + data.instance + '_btn"></button></td></tr></table>'
505 }
506 text += '</td>';
507 }
508 }
509
510 text += ' <td></td></tr>';
511 text += ' </tbody>';
512 text += ' </table>';
513
514 text += '<div style="width: 100%; height: ' + (data.buttons ? 100 : 85) + '%;padding:0; overflow-y: scroll">';
515 text +=' <table id="selectID_' + data.instance + '" style="width: 100%;padding:0;table-layout:fixed; overflow:hidden;white-space:nowrap" cellspacing="0" cellpadding="0">';
516 text += ' <colgroup>';
517 text += ' <col width="1px"/>';
518 text += ' <col width="400px"/>';
519
520 for (c = 0; c < data.columns.length; c++) {
521 if (data.columns[c] == 'image') {
522 text += '<col width="' + (data.widths ? data.widths[c] : '20px') + '"/>';
523 } else if (data.columns[c] == 'name') {
524 text += '<col width="' + (data.widths ? data.widths[c] : '*') + '"/>';
525 } else if (data.columns[c] == 'type') {
526 text += '<col width="' + (data.widths ? data.widths[c] : '150px') + '"/>';
527 } else if (data.columns[c] == 'role') {
528 text += '<col width="' + (data.widths ? data.widths[c] : '150px') + '"/>';
529 } else if (data.columns[c] == 'room') {
530 text += '<col width="' + (data.widths ? data.widths[c] : '150px') + '"/>';
531 } else if (data.columns[c] == 'value') {
532 text += '<col width="' + (data.widths ? data.widths[c] : '150px') + '"/>';
533 } else if (data.columns[c] == 'button') {
534 text += '<col width="' + (data.widths ? data.widths[c] : '100px') + '"/>';
535 } else if (data.columns[c] == 'enum') {
536 text += '<col width="' + (data.widths ? data.widths[c] : '*') + '"/>';
537 }
538 }
539
540 text += ' </colgroup>';
541 text += ' <thead>';
542 text += ' <tr><th></th><th></th>';
543 for (c = 0; c < data.columns.length; c++) {
544 text += '<th></th>';
545 }
546 text += '</tr>';
547 text += ' </thead>';
548 text += ' <tbody>';
549 text += ' </tbody>';
550 text += ' </table></div><div id="process_running_' + data.instance + '" style="position:absolute; top:50%; left:50%; width: 150; height: 25; padding: 12; background: rgba(30, 30, 30, 0.5); display: none; text-align:center; font-size: 1.2em; color: white; font-weight: bold; border-radius: 5">' + data.texts.wait + '</div>';
551
552 $dlg.html(text);
553
554 data.$tree = $('#selectID_' + data.instance);
555 data.$tree[0]._onChange = data.onSuccess || data.onChange;
556
557 var foptions = {
558 titlesTabbable: true, // Add all node titles to TAB chain
559 quicksearch: true,
560 source: data.tree.children,
561 extensions: ["table", "gridnav", "filter", "themeroller"],
562 table: {
563 indentation: 20,
564 nodeColumnIdx: 1
565 },
566 gridnav: {
567 autofocusInput: false,
568 handleCursorKeys: true
569 },
570 filter: {
571 mode: "hide",
572 autoApply: true
573 },
574 activate: function (event, data) {
575 // A node was activated: display its title:
576 // On change
577 //var $dlg = $('#' + data.instance + '-dlg');
578 var _data = $dlg.data('selectId');
579 var newId = data.node.key;
580 if (_data.onChange) _data.onChange(newId, _data.selectedID);
581
582 _data.selectedID = newId;
583
584 if (!_data.noDialog) {
585 // Set title of dialog box
586 if (_data.objects[newId] && _data.objects[newId].common && _data.objects[newId].common.name) {
587 $dlg.dialog('option', 'title', _data.texts.selectid + ' - ' + (_data.objects[newId].common.name || ' '));
588 } else {
589 $dlg.dialog('option', 'title', _data.texts.selectid + ' - ' + (newId || ' '));
590 }
591 // Enable/ disable "Select" button
592 if (_data.objects[newId] && _data.objects[newId].type == 'state') {
593 $('#' + _data.instance + '-button-ok').removeClass('ui-state-disabled');
594 } else {
595 $('#' + _data.instance + '-button-ok').addClass('ui-state-disabled');
596 }
597 }
598 },
599 renderColumns: function (event, _data) {
600 var node = _data.node;
601 var $tdList = $(node.tr).find(">td");
602
603 var isCommon = data.objects[node.key] && data.objects[node.key].common;
604
605 var base = 2;
606
607 for (var c = 0; c < data.columns.length; c++) {
608 if (data.columns[c] == 'image') {
609 var icon = '';
610 var alt = '';
611 var _id_ = 'system.adapter.' + node.key;
612 if (data.objects[_id_] && data.objects[_id_].common && data.objects[_id_].common.icon) {
613 icon = '/adapter/' + data.objects[_id_].common.name + '/' + data.objects[_id_].common.icon;
614 } else
615 if (isCommon) {
616 if (data.objects[node.key].common.icon) {
617 var instance;
618 if (data.objects[node.key].type == 'instance') {
619 icon = '/adapter/' + data.objects[node.key].common.name + '/' + data.objects[node.key].common.icon;
620 } else if (node.key.match(/^system\.adapter\./)) {
621 instance = node.key.split('.', 3);
622 if (data.objects[node.key].common.icon[0] == '/') {
623 instance[2] += data.objects[node.key].common.icon;
624 } else {
625 instance[2] += '/' + data.objects[node.key].common.icon;
626 }
627 icon = '/adapter/' + instance[2];
628 } else {
629 instance = node.key.split('.', 2);
630 if (data.objects[node.key].common.icon[0] == '/') {
631 instance[0] += data.objects[node.key].common.icon;
632 } else {
633 instance[0] += '/' + data.objects[node.key].common.icon;
634 }
635 icon = '/adapter/' + instance[0];
636 }
637 } else if (data.objects[node.key].type == 'device') {
638 icon = data.imgPath + 'device.png';
639 alt = 'device';
640 } else if (data.objects[node.key].type == 'channel') {
641 icon = data.imgPath + 'channel.png';
642 alt = 'channel';
643 } else if (data.objects[node.key].type == 'state') {
644 icon = data.imgPath + 'state.png';
645 alt = 'state';
646 }
647 }
648 if (icon) {
649 $tdList.eq(base).html('<img width=20 height=20 src="' + icon + '" alt="' + alt + '"/>');
650 } else {
651 $tdList.eq(base).text('');
652 }
653 base++;
654 } else
655 if (data.columns[c] == 'name') {
656 $tdList.eq(base++).text(isCommon ? data.objects[node.key].common.name : '').css({overflow: 'hidden', 'white-space': 'nowrap', 'text-overflow': 'ellipsis'}).attr('title', isCommon ? data.objects[node.key].common.name : '');
657 } else
658 if (data.columns[c] == 'type') {
659 $tdList.eq(base++).text(data.objects[node.key] ? data.objects[node.key].type: '');
660 } else
661 if (data.columns[c] == 'role') {
662 $tdList.eq(base++).text(isCommon ? data.objects[node.key].common.role : '');
663 } else
664 if (data.columns[c] == 'room') {
665 // Try to find room
666 if (data.rooms) {
667 var rooms = data.rooms[node.key];
668 if (!rooms) {
669 rooms = [];
670 for (var i = 0; i < data.enums.length; i++) {
671 if (data.objects[data.enums[i]].common.members.indexOf(node.key) != -1 &&
672 rooms.indexOf(data.objects[data.enums[i]].common.name) == -1) rooms.push(data.objects[data.enums[i]].common.name);
673 }
674 data.rooms[node.key] = rooms;
675 }
676 $tdList.eq(base++).text(rooms.join(', '));
677 } else {
678 $tdList.eq(base++).text('');
679
680 }
681
682 } else
683 if (data.columns[c] == 'value') {
684 if (data.states && (data.states[node.key] || data.states[node.key + '.val'] !== undefined)) {
685 var state = data.states[node.key];
686 if (!state) {
687 state = {
688 val: data.states[node.key + '.val'],
689 ts: data.states[node.key + '.ts'],
690 lc: data.states[node.key + '.lc'],
691 from: data.states[node.key + '.from'],
692 ack: (data.states[node.key + '.ack'] === undefined) ? '' : data.states[node.key + '.ack']
693 };
694 }
695
696 var fullVal;
697 if (state.val === undefined) {
698 state.val = '';
699 } else {
700 if (isCommon && data.objects[node.key].common.unit) state.val += ' ' + data.objects[node.key].common.unit;
701 fullVal = data.texts.value + ': ' + state.val;
702 fullVal += '\x0A' + data.texts.ack + ': ' + state.ack;
703 fullVal += '\x0A' + data.texts.ts + ': ' + (state.ts ? formatDate(new Date(state.ts * 1000)) : '');
704 fullVal += '\x0A' + data.texts.lc + ': ' + (state.lc ? formatDate(new Date(state.lc * 1000)) : '');
705 fullVal += '\x0A' + data.texts.from + ': ' + (state.from || '');
706 }
707 $tdList.eq(base).text(state.val);
708 $tdList.eq(base).attr('title', fullVal);
709 } else {
710 $tdList.eq(base).text('');
711 $tdList.eq(base).attr('title', '');
712 }
713 base++;
714 } else
715 if (data.columns[c] == 'button') {
716 // Show buttons
717 var text;
718 if (data.buttons) {
719 if (data.objects[node.key]) {
720 text = '';
721 if (data.editEnd) {
722 text += '<button data-id="' + node.key + '" class="select-button-edit"></button>' +
723 '<button data-id="' + node.key + '" class="select-button-ok"></button>' +
724 '<button data-id="' + node.key + '" class="select-button-cancel"></button>';
725 }
726
727 for (var j = 0; j < data.buttons.length; j++) {
728 text += '<button data-id="' + node.key + '" class="select-button-' + j + ' select-button-custom"></button>';
729 }
730
731 $tdList.eq(base).html(text);
732
733 for (var p = 0; p < data.buttons.length; p++) {
734 var btn = $('.select-button-' + p + '[data-id="' + node.key + '"]').button(data.buttons[p]).click(function () {
735 var cb = $(this).data('callback');
736 if (cb) cb($(this).attr('data-id'));
737 }).data('callback', data.buttons[p].click).attr('title', data.buttons[p].title || '');
738 if (data.buttons[p].width) btn.css({width: data.buttons[p].width});
739 if (data.buttons[p].height) btn.css({height: data.buttons[p].height});
740 if (data.buttons[p].match) data.buttons[p].match.call(btn, node.key);
741 }
742 } else {
743 $tdList.eq(base).text('');
744 }
745 } else if (data.editEnd) {
746 text = '<button data-id="' + node.key + '" class="select-button-edit"></button>' +
747 '<button data-id="' + node.key + '" class="select-button-ok"></button>' +
748 '<button data-id="' + node.key + '" class="select-button-cancel"></button>';
749 }
750
751 if (data.editEnd) {
752 $('.select-button-edit[data-id="' + node.key + '"]').button({
753 text: false,
754 icons: {
755 primary:'ui-icon-pencil'
756 }
757 }).click(function () {
758 $(this).data('node').editStart();
759 }).attr('title', data.texts.edit).data('node', node).css({width: 26, height: 20});
760
761 $('.select-button-ok[data-id="' + node.key + '"]').button({
762 text: false,
763 icons: {
764 primary:'ui-icon-check'
765 }
766 }).click(function () {
767 var node = $(this).data('node');
768 node.editFinished = true;
769 node.editEnd(true);
770 }).attr('title', data.texts.ok).data('node', node).hide().css({width: 26, height: 20});
771
772 $('.select-button-cancel[data-id="' + node.key + '"]').button({
773 text: false,
774 icons: {
775 primary:'ui-icon-close'
776 }
777 }).click(function () {
778 var node = $(this).data('node');
779 node.editFinished = true;
780 node.editEnd(false);
781 }).attr('title', data.texts.cancel).data('node', node).hide().css({width: 26, height: 20});
782 }
783
784 base++;
785 } else
786 if (data.columns[c] == 'enum') {
787 if (isCommon && data.objects[node.key].common.members && data.objects[node.key].common.members.length > 0) {
788 if (data.objects[node.key].common.members.length < 4) {
789 $tdList.eq(base).text('(' + data.objects[node.key].common.members.length + ')' + data.objects[node.key].common.members.join(', '));
790 } else {
791 $tdList.eq(base).text(data.objects[node.key].common.members.length);
792 }
793 $tdList.eq(base).attr('title', data.objects[node.key].common.members.join('\x0A'));
794 } else {
795 $tdList.eq(base).text('');
796 $tdList.eq(base).attr('title', '');
797 }
798 base++;
799 }
800 }
801 },
802 dblclick: function (event, _data) {
803 if (data.buttonsDlg && _data && _data.node && !_data.node.folder) {
804 data.buttonsDlg[0].click();
805 }
806 }
807 };
808 if (data.editEnd) {
809 foptions.extensions.push('edit');
810 foptions.edit = {
811 triggerStart: ["f2", "dblclick", "shift+click", "mac+enter"],
812 triggerStop: ["esc"],
813 beforeEdit: function (event, _data) {
814 // Return false to prevent edit mode
815 if (!data.objects[_data.node.key]) return false;
816 },
817 edit: function (event, _data) {
818 $('.select-button-edit[data-id="' + _data.node.key + '"]').hide();
819 $('.select-button-cancel[data-id="' + _data.node.key + '"]').show();
820 $('.select-button-ok[data-id="' + _data.node.key + '"]').show();
821 $('.select-button-custom[data-id="' + _data.node.key + '"]').hide();
822
823 var node = _data.node;
824 var $tdList = $(node.tr).find(">td");
825 // Editor was opened (available as data.input)
826 var inputs = {id: _data.input};
827
828 for (var c = 0; c < data.columns.length; c++) {
829 if (data.columns[c] == 'name') {
830 $tdList.eq(2 + c).html('<input type="text" id="select_edit_' + data.columns[c] + '" value="' + data.objects[_data.node.key].common[data.columns[c]] + '" style="width: 100%"/>');
831 inputs[data.columns[c]] = $('#select_edit_' + data.columns[c]);
832 }
833 }
834 for (var i in inputs) {
835 inputs[i].keyup(function (e) {
836 var node;
837 if (e.which == 13) {
838 // end edit
839 node = $(this).data('node');
840 node.editFinished = true;
841 node.editEnd(true);
842 } else if (e.which == 27) {
843 // end edit
844 node = $(this).data('node');
845 node.editFinished = true;
846 node.editEnd(false);
847 }
848 }).data('node', node);
849 }
850
851 if (data.editStart) data.editStart(_data.node.key, inputs);
852 node.editFinished = false;
853 },
854 beforeClose: function (event, _data) {
855 // Return false to prevent cancel/save (data.input is available)
856 return _data.node.editFinished;
857 },
858 save: function (event, _data) {
859 var node = _data.node;
860 var editValues = {id: _data.input.val()};
861
862 for (var c = 0; c < data.columns.length; c++) {
863 if (data.columns[c] == 'name') {
864 editValues[data.columns[c]] = $('#select_edit_' + data.columns[c]).val();
865 }
866 }
867
868 // Save data.input.val() or return false to keep editor open
869 if (data.editEnd) data.editEnd(_data.node.key, editValues);
870 _data.node.render(true);
871
872 // We return true, so ext-edit will set the current user input
873 // as title
874 return true;
875 },
876 close: function (event, _data) {
877 $('.select-button-edit[data-id="' + _data.node.key + '"]').show();
878 $('.select-button-cancel[data-id="' + _data.node.key + '"]').hide();
879 $('.select-button-ok[data-id="' + _data.node.key + '"]').hide();
880 $('.select-button-custom[data-id="' + _data.node.key + '"]').show();
881 if (_data.node.editFinished !== undefined) delete _data.node.editFinished;
882 // Editor was removed
883 if (data.save) {
884 // Since we started an async request, mark the node as preliminary
885 $(data.node.span).addClass("pending");
886 }
887 }
888 };
889 }
890
891 data.$tree.fancytree(foptions).on("nodeCommand", function (event, data) {
892 // Custom event handler that is triggered by keydown-handler and
893 // context menu:
894 var refNode;
895 var moveMode;
896 var tree = $(this).fancytree('getTree');
897 var node = tree.getActiveNode();
898
899 switch (data.cmd) {
900 case "moveUp":
901 node.moveTo(node.getPrevSibling(), "before");
902 node.setActive();
903 break;
904 case "moveDown":
905 node.moveTo(node.getNextSibling(), "after");
906 node.setActive();
907 break;
908 case "indent":
909 refNode = node.getPrevSibling();
910 node.moveTo(refNode, "child");
911 refNode.setExpanded();
912 node.setActive();
913 break;
914 case "outdent":
915 node.moveTo(node.getParent(), "after");
916 node.setActive();
917 break;
918 case "copy":
919 CLIPBOARD = {
920 mode: data.cmd,
921 data: node.toDict(function (n) {
922 delete n.key;
923 })
924 };
925 break;
926 case "clear":
927 CLIPBOARD = null;
928 break;
929 default:
930 alert("Unhandled command: " + data.cmd);
931 return;
932 }
933
934 }).on("keydown", function (e) {
935 var c = String.fromCharCode(e.which);
936 var cmd = null;
937
938 if (e.which === 'c' && e.ctrlKey) {
939 cmd = "copy";
940 }else if (e.which === $.ui.keyCode.UP && e.ctrlKey) {
941 cmd = "moveUp";
942 } else if (e.which === $.ui.keyCode.DOWN && e.ctrlKey) {
943 cmd = "moveDown";
944 } else if (e.which === $.ui.keyCode.RIGHT && e.ctrlKey) {
945 cmd = "indent";
946 } else if (e.which === $.ui.keyCode.LEFT && e.ctrlKey) {
947 cmd = "outdent";
948 }
949 if (cmd) {
950 $(this).trigger("nodeCommand", {cmd: cmd});
951 return false;
952 }
953 });
954
955 function customFilter(node) {
956 if (node.parent && node.parent.match) return true;
957
958 // Read all filter settings
959 if (data.filterVals === null) {
960 data.filterVals = {length: 0};
961 var value = $('#filter_ID_' + data.instance).val().toLowerCase();
962 if (value) {
963 data.filterVals.ID = value;
964 data.filterVals.length++;
965 }
966
967 for (var c = 0; c < data.columns.length; c++) {
968 if (data.columns[c] == 'image') {
969 continue;
970 } else if (data.columns[c] == 'role' || data.columns[c] == 'type' || data.columns[c] == 'room') {
971 value = $('#filter_' + data.columns[c] + '_' + data.instance).val();
972 if (value) {
973 data.filterVals[data.columns[c]] = value;
974 data.filterVals.length++;
975 }
976 } else {
977 value = $('#filter_' + data.columns[c] + '_' + data.instance).val();
978 if (value) {
979 value = value.toLowerCase();
980 data.filterVals[data.columns[c]] = value;
981 data.filterVals.length++;
982 }
983 }
984 }
985 }
986
987 var isCommon = null;
988
989 for (var f in data.filterVals) {
990 if (f == 'length') continue;
991
992 if (isCommon === null) isCommon = data.objects[node.key] && data.objects[node.key].common;
993
994 if (f == 'ID') {
995 if (node.key.toLowerCase().indexOf(data.filterVals[f]) == -1) return false;
996 } else
997 if (f == 'name' || f == 'enum') {
998 if (!isCommon || data.objects[node.key].common[f] === undefined || data.objects[node.key].common[f].toLowerCase().indexOf(data.filterVals[f]) == -1) return false;
999 } else
1000 if (f == 'role') {
1001 if (!isCommon || data.objects[node.key].common[f] === undefined || data.objects[node.key].common[f].indexOf(data.filterVals[f]) == -1) return false;
1002 } else
1003 if (f == 'type') {
1004 if (!data.objects[node.key] || data.objects[node.key][f] === undefined || data.objects[node.key][f] != data.filterVals[f]) return false;
1005 } else
1006 if (f == 'value') {
1007 if (!data.states[node.key] || data.states[node.key].val === undefined || data.states[node.key].val.toString().toLowerCase().indexOf(data.filterVals[f]) == -1) return false;
1008 } else
1009 if (f == 'button') {
1010 if (data.filterVals[f] === 'true') {
1011 if (!isCommon || !data.objects[node.key].common.history || !data.objects[node.key].common.history.enabled) return false;
1012 } else if (data.filterVals[f] === 'false') {
1013 if (!isCommon || data.objects[node.key].type != 'state' || (data.objects[node.key].common.history && data.objects[node.key].common.history.enabled)) return false;
1014 }
1015 } else
1016 if (f == 'room') {
1017 if (!data.objects[node.key]) return false;
1018
1019 // Try to find room
1020 var rooms = data.rooms[node.key];
1021 if (!data.rooms[node.key]) {
1022 rooms = [];
1023
1024 for (var i = 0; i < data.enums.length; i++) {
1025 if (data.objects[data.enums[i]].common.members.indexOf(node.key) != -1 &&
1026 rooms.indexOf(data.objects[data.enums[i]].common.name) == -1) {
1027 rooms.push(data.objects[data.enums[i]].common.name);
1028 }
1029 }
1030 data.rooms[node.key] = rooms;
1031 }
1032
1033 if (rooms.indexOf(data.filterVals[f]) == -1) return false;
1034 }
1035 }
1036
1037 return true;
1038 }
1039
1040 $('.filter_' + data.instance).change(function () {
1041 data.filterVals = null;
1042 $('#process_running_' + data.instance).show();
1043 data.$tree.fancytree('getTree').filterNodes(customFilter, false);
1044 $('#process_running_' + data.instance).hide();
1045 }).keyup(function () {
1046 var tree = data.$tree[0];
1047 if (tree._timer) tree._timer = clearTimeout(tree._timer);
1048
1049 var that = this;
1050 tree._timer = setTimeout(function () {
1051 $(that).trigger('change');
1052 }, 200);
1053 });
1054
1055 $('.filter_btn_' + data.instance).button({icons: {primary: 'ui-icon-close'}, text: false}).css({width: 18, height: 18}).click(function () {
1056 $('#' + $(this).attr('data-id')).val('').trigger('change');
1057 }).attr('title', data.texts.collapse);
1058
1059 $('#btn_collapse_' + data.instance).button({icons: {primary: 'ui-icon-folder-collapsed'}, text: false}).css({width: 18, height: 18}).click(function () {
1060 $('#process_running_' + data.instance).show();
1061 setTimeout(function () {
1062 data.$tree.fancytree('getRootNode').visit(function (node) {
1063 if (!data.filterVals.length || node.match || node.subMatch) node.setExpanded(false);
1064 });
1065 $('#process_running_' + data.instance).hide();
1066 }, 100);
1067 });
1068
1069 $('#btn_expand_' + data.instance).button({icons: {primary: 'ui-icon-folder-open'}, text: false}).css({width: 18, height: 18}).click(function () {
1070 $('#process_running_' + data.instance).show();
1071 setTimeout(function () {
1072 data.$tree.fancytree('getRootNode').visit(function (node) {
1073 if (!data.filterVals.length || node.match || node.subMatch)
1074 node.setExpanded(true);
1075 });
1076 $('#process_running_' + data.instance).hide();
1077 }, 100);
1078 }).attr('title', data.texts.expand);
1079
1080 $('#btn_list_' + data.instance).button({icons: {primary: 'ui-icon-grip-dotted-horizontal'}, text: false}).css({width: 18, height: 18}).click(function () {
1081 $('#process_running_' + data.instance).show();
1082 data.list = !data.list;
1083 if (data.list) {
1084 $('#btn_list_' + data.instance).addClass('ui-state-error');
1085 $('#btn_expand_' + data.instance).hide();
1086 $('#btn_collapse_' + data.instance).hide();
1087 $(this).attr('title', data.texts.list);
1088 } else {
1089 $('#btn_list_' + data.instance).removeClass('ui-state-error');
1090 $('#btn_expand_' + data.instance).show();
1091 $('#btn_collapse_' + data.instance).show();
1092 $(this).attr('title', data.texts.tree);
1093 }
1094 $('#process_running_' + data.instance).show();
1095 setTimeout(function () {
1096 data.inited = false;
1097 initTreeDialog(data.$dlg);
1098 $('#process_running_' + data.instance).hide();
1099 }, 200);
1100 }).attr('title', data.texts.tree)
1101 if (data.list) {
1102 $('#btn_list_' + data.instance).addClass('ui-state-error');
1103 $('#btn_expand_' + data.instance).hide();
1104 $('#btn_collapse_' + data.instance).hide();
1105 $('#btn_list_' + data.instance).attr('title', data.texts.list);
1106 }
1107
1108 $('#btn_refresh_' + data.instance).button({icons: {primary: 'ui-icon-refresh'}, text: false}).css({width: 18, height: 18}).click(function () {
1109 $('#process_running_' + data.instance).show();
1110 data.inited = false;
1111 initTreeDialog(data.$dlg);
1112 $('#process_running_' + data.instance).hide();
1113 }).attr('title', data.texts.refresh);
1114
1115 for (var f in filter) {
1116 if (f) $('#filter_' + f + '_' + data.instance).val(filter[f]).trigger('change');
1117 }
1118
1119 if (data.panelButtons) {
1120 for (var z = 0; z < data.panelButtons.length; z++) {
1121 $('#btn_custom_' + data.instance + '_' + z).button(data.panelButtons[z]).css({width: 18, height: 18}).click(data.panelButtons[z].click).attr('title', data.panelButtons[z].title || '');
1122 text += '<td><button id="btn_custom_' + data.instance + '_' + z + '"></button></td>';
1123 }
1124 }
1125
1126 if (data.customButtonFilter) {
1127 $('#filter_button_' + data.instance + '_btn').button(data.customButtonFilter).css({width: 18, height: 18}).click(data.customButtonFilter.callback);
1128 }
1129
1130 showActive($dlg);
1131 }
1132
1133 var methods = {
1134 "init": function (options) {
1135 // done, just to show possible settings, this is not required
1136 var settings = $.extend({
1137 currentId: '',
1138 objects: null,
1139 states: null,
1140 filter: null,
1141 imgPath: 'lib/css/fancytree/',
1142 connCfg: null,
1143 onSuccess: null,
1144 onChange: null,
1145 zindex: null,
1146 list: false,
1147 columns: ['image', 'name', 'type', 'role', 'enum', 'room', 'value', 'button']
1148 }, options);
1149
1150 settings.texts = settings.texts || {};
1151 settings.texts = $.extend({
1152 select: 'Select',
1153 cancel: 'Cancel',
1154 all: 'All',
1155 id: 'ID',
1156 name: 'Name',
1157 role: 'Role',
1158 type: 'Type',
1159 room: 'Room',
1160 enum: 'Members',
1161 value: 'Value',
1162 selectid: 'Select ID',
1163 from: 'From',
1164 lc: 'Last changed',
1165 ts: 'Time stamp',
1166 ack: 'Acknowledged',
1167 expand: 'Expand all nodes',
1168 collapse: 'Collapse all nodes',
1169 refresh: 'Rebuild tree',
1170 edit: 'Edit',
1171 ok: 'Ok',
1172 wait: 'Processing...',
1173 list: 'Show list view',
1174 tree: 'Show tree view'
1175 }, settings.texts);
1176
1177 var that = this;
1178 for (var i = 0; i < this.length; i++) {
1179 var dlg = this[i];
1180 var $dlg = $(dlg);
1181 var data = $dlg.data('selectId');
1182 // Init data
1183 if (!data) {
1184 data = {
1185 tree: {title: '', children: [], count: 0, root: true},
1186 enums: [],
1187 rooms: {},
1188 roles: [],
1189 types: [],
1190 regexSystemAdapter: new RegExp('^system.adapter.'),
1191 regexSystemHost: new RegExp('^system.host.'),
1192 regexEnumRooms: new RegExp('^enum.rooms.'),
1193 instance: instance++,
1194 inited: false
1195 };
1196 $dlg.data('selectId', data);
1197 }
1198 if (data.inited) {
1199 // Re-init tree if filter or selectedID changed
1200 if ((data.filter && !settings.filter && settings.filter !== undefined) ||
1201 (!data.filter && settings.filter) ||
1202 (data.filter && settings.filter && JSON.stringify(data.filter) != JSON.stringify(settings.filter))) {
1203 data.inited = false;
1204 }
1205 if (data.inited && settings.currentId !== undefined && (data.currentId != settings.currentId)) {
1206 // Deactivate current line
1207 var tree = data.$tree.fancytree('getTree');
1208 tree.visit(function (node) {
1209 if (node.key == data.currentId) {
1210 node.setActive(false);
1211 return false;
1212 }
1213 });
1214 }
1215 }
1216
1217 data = $.extend(data, settings);
1218
1219 data.selectedID = data.currentId;
1220
1221 // make a copy of filter
1222 data.filter = JSON.parse(JSON.stringify(data.filter));
1223
1224 if (!data.objects && data.connCfg) {
1225 // Read objects and states
1226 data.socketURL = '';
1227 data.socketSESSION = '';
1228 if (typeof data.connCfg.socketUrl != 'undefined') {
1229 data.socketURL = data.connCfg.socketUrl;
1230 if (data.socketURL && data.socketURL[0] == ':') {
1231 data.socketURL = location.protocol + '//' + location.hostname + data.socketURL;
1232 }
1233 data.socketSESSION = data.connCfg.socketSession;
1234 }
1235
1236 var connectTimeout = setTimeout(function () {
1237 if ($('#select-id-dialog').length == 0) {
1238 $('body').append('<div id="select-id-dialog"><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 50px 0;"></span><span>' + (data.texts.noconnection || 'No connection to server') + '</span></div>');
1239 }
1240 $('#select-id-dialog').dialog({
1241 modal: true
1242 });
1243 }, 5000);
1244
1245 data.socket = io.connect(data.socketURL, {
1246 'query': 'key=' + data.socketSESSION,
1247 'reconnection limit': 10000,
1248 'max reconnection attempts': Infinity
1249 });
1250
1251 data.socket.on('connect', function () {
1252 if (connectTimeout) clearTimeout(connectTimeout);
1253 this.emit('name', data.connCfg.socketName || 'selectId');
1254 this.emit('getObjects', function (err, res) {
1255 data.objects = res;
1256 data.socket.emit('getStates', function (err, res) {
1257 data.states = res;
1258 });
1259 });
1260 });
1261 data.socket.on('stateChange', function (id, obj) {
1262 that.selectId('state', id, obj);
1263 });
1264 data.socket.on('objectChange', function (id, obj) {
1265 that.selectId('object', id, obj);
1266 });
1267 }
1268
1269 $dlg.data('selectId', data);
1270 }
1271
1272 return this;
1273 },
1274 "show": function (currentId, filter, onSuccess) {
1275 if (typeof filter == 'function') {
1276 onSuccess = filter;
1277 filter = undefined;
1278 }
1279 if (typeof currentId == 'function') {
1280 onSuccess = currentId;
1281 currentId = undefined;
1282 }
1283
1284 for (var i = 0; i < this.length; i++) {
1285 var dlg = this[i];
1286 var $dlg = $(dlg);
1287 var data = $dlg.data('selectId');
1288 if (!data) continue;
1289 if (data.inited) {
1290 // Re-init tree if filter or selectedID changed
1291 if ((data.filter && !filter && filter !== undefined) ||
1292 (!data.filter && filter) ||
1293 (data.filter && filter && JSON.stringify(data.filter) != JSON.stringify(filter))) {
1294 data.inited = false;
1295 }
1296
1297 if (data.inited && currentId !== undefined && (data.currentId != currentId)) {
1298 // Deactivate current line
1299 var tree = data.$tree.fancytree('getTree');
1300 tree.visit(function (node) {
1301 if (node.key == data.currentId) {
1302 node.setActive(false);
1303 return false;
1304 }
1305 });
1306 }
1307 }
1308 if (currentId !== undefined) data.currentId = currentId;
1309 if (filter !== undefined) data.filter = JSON.parse(JSON.stringify(filter));
1310 if (onSuccess !== undefined) {
1311 data.onSuccess = onSuccess;
1312 data.$tree = $('#selectID_' + data.instance);
1313 if (data.$tree[0]) data.$tree[0]._onSuccess = data.onSuccess;
1314 }
1315 data.selectedID = data.currentId;
1316
1317 if (!data.inited) {
1318 data.$dlg = $dlg;
1319 initTreeDialog($dlg);
1320 } else {
1321 if (data.selectedID) {
1322 var tree = data.$tree.fancytree('getTree');
1323 tree.visit(function (node) {
1324 if (node.key == data.selectedID) {
1325 node.setActive();
1326 node.makeVisible({scrollIntoView: false});
1327 return false;
1328 }
1329 });
1330 }
1331 }
1332 if (!data.noDialog) {
1333 $dlg.dialog('option', 'title', data.texts.selectid + ' - ' + (data.currentId || ' '));
1334 if (data.currentId) {
1335 if (data.objects[data.currentId] && data.objects[data.currentId].common && data.objects[data.currentId].common.name) {
1336 $dlg.dialog('option', 'title', data.texts.selectid + ' - ' + (data.objects[data.currentId].common.name || ' '));
1337 } else {
1338 $dlg.dialog('option', 'title', data.texts.selectid + ' - ' + (data.currentId || ' '));
1339 }
1340 } else {
1341 $('#' + data.instance + '-button-ok').addClass('ui-state-disabled');
1342 }
1343
1344 $dlg.dialog('open');
1345 showActive($dlg, true);
1346 } else {
1347 $dlg.show();
1348 showActive($dlg, true);
1349 }
1350 }
1351
1352 return this;
1353 },
1354 "hide": function () {
1355 for (var i = 0; i < this.length; i++) {
1356 var dlg = this[i];
1357 var $dlg = $(dlg);
1358 var data = $dlg.data('selectId');
1359 if (data && !data.noDialog) {
1360 $dlg.dialog('hide');
1361 } else {
1362 $dlg.hide();
1363 }
1364 }
1365 return this;
1366 },
1367 "clear": function () {
1368 for (var i = 0; i < this.length; i++) {
1369 var dlg = this[i];
1370 var $dlg = $(dlg);
1371 var data = $dlg.data('selectId');
1372 // Init data
1373 if (data) {
1374 data.tree = {title: '', children: [], count: 0, root: true};
1375 data.rooms = {};
1376 data.enums = [];
1377 data.roles = [];
1378 data.typse = [];
1379 }
1380 }
1381 return this;
1382 },
1383 "getInfo": function (id) {
1384 for (var i = 0; i < this.length; i++) {
1385 var dlg = this[i];
1386 var $dlg = $(dlg);
1387 var data = $dlg.data('selectId');
1388 if (data && data.objects) {
1389 return data.objects[id];
1390 }
1391 }
1392 return null;
1393 },
1394 "getTreeInfo": function (id) {
1395 for (var i = 0; i < this.length; i++) {
1396 var dlg = this[i];
1397 var $dlg = $(dlg);
1398 var data = $dlg.data('selectId');
1399 if (!data || !data.$tree) continue;
1400
1401 var tree = data.$tree.fancytree('getTree');
1402 var node = null;
1403 tree.visit(function (n) {
1404 if (n.key == id) {
1405 node = n;
1406 return false;
1407 }
1408 });
1409 var result = {
1410 id: id,
1411 parent: (node && node.parent && node.parent.parent) ? node.parent.key : null,
1412 children: null,
1413 obj: data.objects ? data.objects[id] : null
1414 };
1415 if (node && node.children) {
1416 result.children = [];
1417 for (var t = 0; t < node.children.length; t++) {
1418 result.children.push(node.children[t].key);
1419 }
1420 if (!result.children.length) delete result.children;
1421
1422 }
1423 return result;
1424 }
1425 return null;
1426 },
1427 "destroy": function () {
1428 for (var i = 0; i < this.length; i++) {
1429 var dlg = this[i];
1430 var $dlg = $(dlg);
1431 $dlg.data('selectId', null);
1432 $('#' + data.instance + '-div')[0].innerHTML('');
1433 }
1434 return this;
1435 },
1436 "reinit": function () {
1437 for (var i = 0; i < this.length; i++) {
1438 var dlg = this[i];
1439 var $dlg = $(dlg);
1440 var data = $dlg.data('selectId');
1441 if (data) {
1442 data.inited = false;
1443 initTreeDialog(data.$dlg);
1444 }
1445 }
1446 return this;
1447 },
1448 // update states
1449 "state": function (id, state) {
1450 for (var i = 0; i < this.length; i++) {
1451 var dlg = this[i];
1452 var $dlg = $(dlg);
1453 var data = $dlg.data('selectId');
1454 if (!data || !data.states || !data.$tree) continue;
1455 if (data.states[id] && state && data.states[id].val == state.val) return;
1456 data.states[id] = state;
1457 var tree = data.$tree.fancytree('getTree');
1458 var node = null;
1459 tree.visit(function (n) {
1460 if (n.key == id) {
1461 node = n;
1462 return false;
1463 }
1464 });
1465 if (node) node.render(true);
1466 }
1467 return this;
1468 },
1469 // update objects
1470 "object": function (id, obj) {
1471 for (var k = 0; k < this.length; k++) {
1472 var dlg = this[k];
1473 var $dlg = $(dlg);
1474 var data = $dlg.data('selectId');
1475 if (!data || !data.$tree || !data.objects) continue;
1476
1477 if (id.match(/^enum\.rooms/)) data.rooms = {};
1478
1479 var tree = data.$tree.fancytree('getTree');
1480 var node = null;
1481 tree.visit(function (n) {
1482 if (n.key == id) {
1483 node = n;
1484 return false;
1485 }
1486 });
1487
1488 // If new node
1489 if (!node && obj) {
1490 // Filter it
1491
1492 data.objects[id] = obj;
1493 var addedNodes = [];
1494
1495 if (!filterId(data, id)) return;
1496
1497 treeInsert(data, id, false, addedNodes);
1498
1499 for (var i = 0; i < addedNodes.length; i++) {
1500 if (!addedNodes[i].parent.root) {
1501 tree.visit(function (n) {
1502 if (n.key == addedNodes[i].parent.key) {
1503 node = n;
1504 return false;
1505 }
1506 });
1507
1508 } else {
1509 node = data.$tree.fancytree('getRootNode');
1510 }
1511 // if no children
1512 if (!node.children || !node.children.length) {
1513 // add
1514 node.addChildren(addedNodes[i]);
1515 node.folder = true;
1516 node.expanded = false;
1517 node.render(true);
1518 node.children[0].match = true;
1519 } else {
1520 var c;
1521 for (c = 0; c < node.children.length; c++) {
1522 if (node.children[c].key > addedNodes[i].key) break;
1523 }
1524 // if some found greater than new one
1525 if (c != node.children.length) {
1526 node.addChildren(addedNodes[i], node.children[c]);
1527 node.children[c].match = true;
1528 node.render(true);
1529 } else {
1530 // just add
1531 node.addChildren(addedNodes[i]);
1532 node.children[node.children.length - 1].match = true;
1533 node.render(true);
1534 }
1535 }
1536 }
1537 } else if (!obj) {
1538 // object deleted
1539 delete data.objects[id];
1540 deleteTree(data, id);
1541 if (node) {
1542 if (node.children && node.children.length) {
1543 if (node.children.length == 1) {
1544 node.folder = false;
1545 node.expanded = false;
1546 }
1547 node.render(true);
1548 } else {
1549 if (node.parent && node.parent.children.length == 1) {
1550 node.parent.folder = false;
1551 node.parent.expanded = false;
1552 node.parent.render(true);
1553 }
1554 node.remove();
1555 }
1556 }
1557 } else {
1558 // object updated
1559 if (node) node.render(true);
1560 }
1561 }
1562 return this;
1563 },
1564 "getFilteredIds": function () {
1565 for (var k = 0; k < this.length; k++) {
1566 var dlg = this[k];
1567 var $dlg = $(dlg);
1568 var data = $dlg.data('selectId');
1569 if (!data || !data.$tree || !data.objects) continue;
1570
1571 var tree = data.$tree.fancytree('getTree');
1572 var nodes = [];
1573 tree.visit(function (n) {
1574 if (n.match) nodes.push(n.key);
1575 });
1576 return nodes;
1577 }
1578 return null;
1579 }
1580 };
1581
1582 $.fn.selectId = function (method) {
1583 if (methods[method]) {
1584 return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
1585 } else if (typeof method === 'object' || !method) {
1586 return methods.init.apply(this, arguments);
1587 } else {
1588 $.error('Method "' + method + '" not found in jQuery.selectId');
1589 }
1590 };
1591})(jQuery);
1592// --------------------------- END selectID.js -----------------------------------------------------
1593</script>
1594
1595<script type="text/javascript">
1596
1597 RED.nodes.registerType('ioBroker in',{
1598 category: 'input',
1599 defaults: {
1600 name: {value:""},
1601 topic: {value:"*",required:true},
1602 payloadType: {value:'value'},
1603 onlyack: {value:""},
1604 func: {value:"all"},
1605 gap: {value:"",validate:RED.validators.regex(/^(\d*[.]*\d*|)(%|)$/)}
1606
1607 },
1608 color:"#a8bfd8",
1609 inputs:0,
1610 outputs:1,
1611 icon: "ioBroker.png",
1612 label: function() {
1613 return this.name||this.topic||"ioBroker";
1614 },
1615 labelStyle: function() {
1616 return this.name?"node_label_italic":"";
1617 },
1618 oneditprepare: function() {
1619 if (!window.__iobroker) {
1620 $.getJSON("iobroker.json", function(data) {
1621 window.__iobroker = data;
1622 $('#dialog-select-member').selectId('init', {
1623 objects: window.__iobroker,
1624 columns: ['name', 'type', 'role', 'enum', 'room'],
1625 states: null,
1626 noImg: true
1627 });
1628 });
1629 } else {
1630 $('#dialog-select-member').selectId('init', {
1631 objects: window.__iobroker,
1632 columns: ['name', 'type', 'role', 'enum', 'room'],
1633 states: null,
1634 noImg: true
1635 });
1636 }
1637
1638 $('#node-input-topic-button').button({
1639 icons: {primary: 'ui-icon-folder-open'},
1640 text: false
1641 }).click(function () {
1642 $('#dialog-select-member').selectId('show', $('#node-input-topic').val(), undefined, function (newId, oldId) {
1643 var oldObj = $('#dialog-select-member').selectId('getInfo', oldId)
1644 var newObj = $('#dialog-select-member').selectId('getInfo', newId)
1645 $('#node-input-topic').val(newId);
1646 var oldName = $('#node-input-name').val();
1647 if (!oldName || !oldObj || (oldObj.common && oldName == oldObj.common.name && newObj.common)) {
1648 $('#node-input-name').val(newObj.common.name);
1649 }
1650 });
1651 });
1652 $("#node-input-func").on("change",function() {
1653 if ($("#node-input-func").val() == null) $("#node-input-func").val ("all");
1654 if ($("#node-input-func").val() === "deadband") {
1655 $("#node-bandgap").show();
1656 } else {
1657 $("#node-bandgap").hide();
1658 }
1659 });
1660
1661
1662
1663 }
1664 });
1665</script>
1666
1667<script type="text/x-red" data-template-name="ioBroker out">
1668 <div class="form-row">
1669 <label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label>
1670 <input type="text" id="node-input-topic" placeholder="Topic" style="width:60%"><input type="button" id="node-input-topic-button" style="display:inline-block;width:10%" value="."/>
1671 </div>
1672 <div id="dialog-select-member" style="display:none"></div>
1673 <div class="form-row">
1674 <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
1675 <input type="text" id="node-input-name" placeholder="Name">
1676 </div>
1677 <div class="form-row">
1678 <label for="node-input-ack"><i class="fa fa-arrow-up"></i> Type</label>
1679 <select id="node-input-ack" style="width:73% !important">
1680 <option value="true">value</option>
1681 <option value="false">command</option>
1682 </select>
1683 </div>
1684 <div class="form-row">
1685 <label for="node-input-autoCreate"><i class="fa fa-arrow-up"></i> Auto create</label>
1686 <select id="node-input-autoCreate" style="width:73% !important">
1687 <option value="true">Create states if not exist</option>
1688 <option value="false">Ignore messages for non existing states</option>
1689 </select>
1690 </div>
1691 <div class="form-tips">Tip: Leave topic blank if you want to set them via msg properties.</div>
1692</script>
1693
1694<script type="text/x-red" data-help-name="ioBroker out">
1695 <p>Connects to a ioBroker and publishes <b>msg.payload</b> either to the <b>msg.topic</b> or to the topic specified in the edit window. The value in the edit window has precedence.</p>
1696 <p>If <b>msg.payload</b> contains an object it will be stringified before being sent.</p>
1697 <p>If <b>msg.payload</b> contains "__create__", the object will be only created, but no value will be written.</p>
1698</script>
1699
1700<script type="text/javascript">
1701RED.nodes.registerType('ioBroker out',{
1702 category: 'output',
1703 defaults: {
1704 name: {value:""},
1705 topic: {value:""},
1706 ack: {value:"false"},
1707 autoCreate: {value: "false"}
1708 },
1709 color:"#a8bfd8",
1710 inputs:1,
1711 outputs:0,
1712 icon: "ioBroker.png",
1713 align: "right",
1714 label: function() {
1715 return this.name||this.topic||"ioBroker";
1716 },
1717 labelStyle: function() {
1718 return this.name?"node_label_italic":"";
1719 },
1720 oneditprepare: function() {
1721 if (!window.__iobroker) {
1722 $.getJSON("iobroker.json", function(data) {
1723 window.__iobroker = data;
1724 $('#dialog-select-member').selectId('init', {
1725 objects: window.__iobroker,
1726 columns: ['name', 'type', 'role', 'enum', 'room'],
1727 states: null,
1728 noImg: true
1729 });
1730 });
1731 } else {
1732 $('#dialog-select-member').selectId('init', {
1733 objects: window.__iobroker,
1734 columns: ['name', 'type', 'role', 'enum', 'room'],
1735 states: null,
1736 noImg: true
1737 });
1738 }
1739
1740 $('#node-input-topic-button').button({
1741 icons: {primary: 'ui-icon-folder-open'},
1742 text: false
1743 }).click(function () {
1744 $('#dialog-select-member').selectId('show', $('#node-input-topic').val(), undefined, function (newId, oldId) {
1745 var oldObj = $('#dialog-select-member').selectId('getInfo', oldId);
1746 var newObj = $('#dialog-select-member').selectId('getInfo', newId);
1747 $('#node-input-topic').val(newId);
1748
1749 var oldName = $('#node-input-name').val();
1750 if (!oldName || !oldObj || (oldObj.common && oldName == oldObj.common.name && newObj.common)) {
1751 $('#node-input-name').val(newObj.common.name);
1752 }
1753 });
1754 });
1755 }
1756 });
1757</script>
1758
1759<script type="text/x-red" data-template-name="ioBroker get">
1760 <div class="form-row">
1761 <label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label>
1762 <input type="text" id="node-input-topic" placeholder="Topic" style="width:60%"><input type="button" id="node-input-topic-button" style="display:inline-block;width:10%" value="."/>
1763 </div>
1764 <div id="dialog-select-member" style="display:none"></div>
1765 <div class="form-row">
1766 <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
1767 <input type="text" id="node-input-name" placeholder="Name">
1768 </div>
1769 <div class="form-row">
1770 <label for="node-input-payloadType"><i class="fa fa-envelope"></i> Payload</label>
1771 <select id="node-input-payloadType" style="width:125px !important">
1772 <option value="value">value</option>
1773 <option value="object">object</option>
1774 </select>
1775 </div>
1776 <div class="form-row">
1777 <label for="node-input-attrname"><i class="fa fa-tag"></i> Attribute</label>
1778 <input type="text" id="node-input-attrname" placeholder="attrname">
1779 </div>
1780 <div class="form-tips">Tip: Leave topic blank if you want to set them via msg properties.</div>
1781</script>
1782
1783<script type="text/x-red" data-help-name="ioBroker get">
1784 <p>Connects to a ioBroker and returns the requested value or the object in the massage attribute in the properties dialog, e.g. <b>msg.payload</b>. The object could be identified either by the <b>msg.topic</b> or specified in the poperties dialog. The value in the poperties dialog has precedence.</p>
1785 <p>The msg object also contains the attributs <b>msg.timestamp</b>, <b>msg.lastchange</b> and <b>msg.acknowledged</b>. All other attributes ob the input msg object will be passed to the output msg object.</p>
1786
1787</script>
1788
1789<script type="text/javascript">
1790RED.nodes.registerType('ioBroker get',{
1791 category: 'function',
1792 defaults: {
1793 name: {value:""},
1794 topic: {value:""},
1795 attrname: {value:"payload"},
1796 payloadType: {value:'value'}
1797 },
1798 color:"#a8bfd8",
1799 inputs:1,
1800 outputs:1,
1801 icon: "ioBroker.png",
1802 label: function() {
1803 return this.name||this.topic||"ioBroker get";
1804 },
1805 labelStyle: function() {
1806 return this.name?"node_label_italic":"";
1807 },
1808 oneditprepare: function() {
1809 if (!window.__iobroker) {
1810 $.getJSON("iobroker.json", function(data) {
1811 window.__iobroker = data;
1812 $('#dialog-select-member').selectId('init', {
1813 objects: window.__iobroker,
1814 columns: ['name', 'type', 'role', 'enum', 'room'],
1815 states: null,
1816 noImg: true
1817 });
1818 });
1819 } else {
1820 $('#dialog-select-member').selectId('init', {
1821 objects: window.__iobroker,
1822 columns: ['name', 'type', 'role', 'enum', 'room'],
1823 states: null,
1824 noImg: true
1825 });
1826 }
1827
1828 $('#node-input-topic-button').button({
1829 icons: {primary: 'ui-icon-folder-open'},
1830 text: false
1831 }).click(function () {
1832 $('#dialog-select-member').selectId('show', $('#node-input-topic').val(), undefined, function (newId, oldId) {
1833 var oldObj = $('#dialog-select-member').selectId('getInfo', oldId);
1834 var newObj = $('#dialog-select-member').selectId('getInfo', newId);
1835 $('#node-input-topic').val(newId);
1836
1837 var oldName = $('#node-input-name').val();
1838 if (!oldName || !oldObj || (oldObj.common && oldName == oldObj.common.name && newObj.common)) {
1839 $('#node-input-name').val(newObj.common.name);
1840 }
1841 });
1842 });
1843
1844 }
1845
1846 });
1847</script>
1848