cockpit/themes/compact/theme.js in cpee-2.1.53 vs cockpit/themes/compact/theme.js in cpee-2.1.54
- old
+ new
@@ -61,39 +61,31 @@
return JSON.stringify(nodes);
}; //}}}
//{{{ Render the details from rng (right hand side of graph tab)
this.update_details = function(svgid){
var tab = $('#dat_details');
- var focus_ele = $(':focus',tab);
- var focus_path = focus_ele.attr('data-relaxngui-path');
- var focus_pos = focus_ele.prop('selectionStart');
var node = self.adaptor.description.get_node_by_svg_id(svgid).get(0);
- tab.empty();
if (self.adaptor.description.elements[$(node).attr('svg-subtype')]) {
save['details_target'] = { 'svgid': svgid, 'model': self.adaptor.description };
var rng = self.adaptor.description.elements[$(node).attr('svg-subtype')].clone();
if (save['endpoints_cache'][$(node).attr('endpoint')] && save['endpoints_cache'][$(node).attr('endpoint')].schema) {
var schema = save['endpoints_cache'][$(node).attr('endpoint')].schema.documentElement;
$(rng).find(' > element[name="parameters"] > element[name="arguments"]').replaceWith($(schema).clone());
}
if (save['endpoints_list'][$(node).attr('endpoint')] && (!save['endpoints_list'][$(node).attr('endpoint')].startsWith('http') || save['endpoints_list'][$(node).attr('endpoint')].match(/^https?-/))) {
$(rng).find(' > element[name="parameters"] > element[name="method"]').remove();
}
- save['details'] = new RelaxNGui(rng,tab,self.adaptor.description.context_eval,true);
var nn = $X($(node).serializeXML());
nn.removeAttr('svg-id');
nn.removeAttr('svg-type');
nn.removeAttr('svg-subtype');
nn.removeAttr('svg-label');
+
+ tab.empty();
+ save['details'] = new RelaxNGui(rng,tab,self.adaptor.description.context_eval,true);
save['details'].content(nn);
- if (focus_ele.length > 0) {
- var ele = $('[data-relaxngui-path="' + focus_path + '"]',tab)[0];
- ele.focus();
- if (ele.setSelectionRange) {
- ele.setSelectionRange(focus_pos,focus_pos);
- }
- }
+
format_visual_forms();
}
}; //}}}
function copyOrMove(menu,group,xml_node,mode) { //{{{
@@ -209,12 +201,21 @@
'label': 'Remove Marked Elements',
'function_call': function(){
$(nodes).each(function(key,str) {
nodes[key] = $X(str);
});
+ let svgids = [];
$(nodes).each(function(key,node){
- var target = self.adaptor.description.get_node_by_svg_id($(node).attr('svg-id'));
+ svgids.push($(node).attr('svg-id'));
+ });
+ svgids.sort((a,b) => {
+ if (a > b) { return -1; }
+ else if (a < b) { return 1; }
+ else { return 0; }
+ });
+ svgids.forEach(svgid => {
+ var target = self.adaptor.description.get_node_by_svg_id(svgid);
del_ui_pos(target)
self.adaptor.description.remove(null,target);
localStorage.removeItem('marked');
localStorage.removeItem('marked_from');
});
@@ -1231,31 +1232,36 @@
'balance': true,
'expansion': function(node) {
return 'vertical';
},
'resolve_symbol': function(node) {
+ let alist = []
let plist = []
- let dirty = false
- $('*:not(:has(*))',node).each(function(i,n) {
- let lines = n.textContent.split(/(\r\n)|\n|;/)
- for (const l of lines) {
- if (l != null) {
- let m0 = l.match(/^[^=]*data\.([a-z0-9A-Z_]+)[^=]*=/)
- if (m0 != null) {
- plist.push(m0[1])
- }
- let m1 = l.match(/=[^=].*data\.([a-z0-9A-Z_]+)/)
- let m2 = l.match(/^[^=]*data\.([a-z0-9A-Z_]+)[^=]*$/)
- if (m1 != null && !plist.includes(m1[1])) {
- dirty = true
- }
- if (m2 != null && !plist.includes(m2[1])) {
- dirty = true
- }
- }
+
+ var regassi = /data\.([a-zA-Z_]+)\s*(=[^=]|\+\=|\-\=|\*\=|\/\=|<<|>>)/g; // we do not have to check for >/< version of stuff as only conditions are in attributes, and conditions can not contain assignments
+ var reg_not_assi = /data\.([a-zA-Z_]+)\s*/g;
+ $ ('call > parameters > arguments > *, call > code > *, loop[condition], alternative[condition]',node).each(function(i,n) {
+ let item;
+ if (n.hasAttribute('condition')) {
+ item = n.getAttribute('condition');
+ } else {
+ item = n.textContent;
}
+ if (n.parentNode.nodeName == 'arguments' && item.charAt(0) != '!' ) { return }
+
+ let indices = [];
+
+ for (const match of item.matchAll(regassi)) {
+ indices.push(match.index);
+ alist.push(match[1]);
+ }
+ for (const match of item.matchAll(reg_not_assi)) {
+ const arg1 = match[1];
+ if (indices.includes(match.index)) { continue; }
+ if (!alist.includes(arg1)) { plist.push(arg1); }
+ }
})
- if (dirty) { return 'start_event'; }
+ if (plist.length > 0) { return 'start_event'; }
},
'closing_symbol': 'end',
'col_shift': function(node) {
return true;
},