cpee 1.4.26 → 1.4.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/cockpit/js_libs.zip +0 -0
- data/cockpit/js_libs/Makefile +2 -0
- data/cockpit/js_libs/ansi_up.js +333 -0
- data/cockpit/js_libs/console.js +80 -0
- data/cockpit/js_libs/custommenu.css +84 -0
- data/cockpit/js_libs/custommenu.js +101 -0
- data/cockpit/js_libs/jquery-2.2.4.min.js +4 -0
- data/cockpit/js_libs/jquery-3.2.1.min.js +4 -0
- data/cockpit/js_libs/jquery-3.3.1.min.js +2 -0
- data/cockpit/js_libs/jquery.browser.js +40 -0
- data/cockpit/js_libs/jquery.caret.min.js +10 -0
- data/cockpit/js_libs/jquery.cookie.js +117 -0
- data/cockpit/js_libs/jquery.min.js +1 -0
- data/cockpit/js_libs/jquery.svg.min.js +6 -0
- data/cockpit/js_libs/jquery.svgdom.min.js +6 -0
- data/cockpit/js_libs/markdown.min.js +1 -0
- data/cockpit/js_libs/parsequery.js +21 -0
- data/cockpit/js_libs/printf.js +368 -0
- data/cockpit/js_libs/relaxngui.css +153 -0
- data/cockpit/js_libs/relaxngui.js +402 -0
- data/cockpit/js_libs/strftime.min.js +1 -0
- data/cockpit/js_libs/tests/dataelements.html +58 -0
- data/cockpit/js_libs/tests/dataelements.rng +8 -0
- data/cockpit/js_libs/tests/dataelements.xml +3 -0
- data/cockpit/js_libs/tests/rngtest1.html +59 -0
- data/cockpit/js_libs/tests/rngtest1.rng +41 -0
- data/cockpit/js_libs/tests/rngtest1.xml +11 -0
- data/cockpit/js_libs/tests/rngtest2.html +59 -0
- data/cockpit/js_libs/tests/rngtest2.rng +6 -0
- data/cockpit/js_libs/tests/rngtest2.xml +3 -0
- data/cockpit/js_libs/tests/rngtest3.html +59 -0
- data/cockpit/js_libs/tests/rngtest3.rng +23 -0
- data/cockpit/js_libs/tests/rngtest3.xml +9 -0
- data/cockpit/js_libs/tests/rngtest4.html +59 -0
- data/cockpit/js_libs/tests/rngtest4.rng +19 -0
- data/cockpit/js_libs/tests/rngtest4.xml +12 -0
- data/cockpit/js_libs/tests/rngtest5.html +59 -0
- data/cockpit/js_libs/tests/rngtest5.rng +75 -0
- data/cockpit/js_libs/tests/rngtest5.xml +40 -0
- data/cockpit/js_libs/tests/rngtest6.html +59 -0
- data/cockpit/js_libs/tests/rngtest6.rng +24 -0
- data/cockpit/js_libs/tests/rngtest6.xml +6 -0
- data/cockpit/js_libs/tests/rngtest8.html +59 -0
- data/cockpit/js_libs/tests/rngtest8.rng +13 -0
- data/cockpit/js_libs/tests/rngtest8.xml +2 -0
- data/cockpit/js_libs/ui.css +301 -0
- data/cockpit/js_libs/ui.html +168 -0
- data/cockpit/js_libs/ui.js +172 -0
- data/cockpit/js_libs/underscore.min.js +27 -0
- data/cockpit/js_libs/util.js +84 -0
- data/cockpit/js_libs/vkbeautify.0.99.00.beta.js +358 -0
- data/cockpit/js_libs/vkbeautify.js +1 -0
- data/cockpit/js_libs/webcomponents.min.js +196 -0
- data/cpee.gemspec +2 -1
- data/server/instances/104/notifications/888d50456e0c2d39d0542a21999c9e0b/consumer-secret +1 -0
- data/server/instances/104/notifications/888d50456e0c2d39d0542a21999c9e0b/producer-secret +1 -0
- data/server/instances/104/notifications/888d50456e0c2d39d0542a21999c9e0b/subscription.xml +38 -0
- data/server/instances/104/notifications/logging/consumer-secret +1 -0
- data/server/instances/104/notifications/logging/producer-secret +1 -0
- data/server/instances/104/notifications/logging/subscription.xml +19 -0
- data/server/instances/104/properties.xml +31 -0
- data/tools/cpee +36 -7
- metadata +77 -5
- data/server/server.pid +0 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/*
|
|
2
|
+
This file is part of RelaxNGui.
|
|
3
|
+
|
|
4
|
+
RelaxNGui is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
6
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
7
|
+
version.
|
|
8
|
+
|
|
9
|
+
RelaxNGui is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
10
|
+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
11
|
+
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
12
|
+
|
|
13
|
+
You should have received a copy of the GNU General Public License along with
|
|
14
|
+
RelaxNGui (file COPYING in the main directory). If not, see
|
|
15
|
+
<http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
.relaxngui_table { }
|
|
19
|
+
.relaxngui_table .relaxngui_table { }
|
|
20
|
+
|
|
21
|
+
.relaxngui_table > .relaxngui_table > .relaxngui_table {
|
|
22
|
+
padding: 0;
|
|
23
|
+
padding-top: 0.2em;
|
|
24
|
+
padding-bottom: 0.5em;
|
|
25
|
+
padding-left: 1em;
|
|
26
|
+
}
|
|
27
|
+
.relaxngui_dyn {
|
|
28
|
+
margin: 0;
|
|
29
|
+
padding: 0;
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: row;
|
|
32
|
+
align-items: center;
|
|
33
|
+
padding-bottom: 0.25em;
|
|
34
|
+
padding-top: 0.25em;
|
|
35
|
+
margin-left: 0.5em;
|
|
36
|
+
}
|
|
37
|
+
.relaxngui_dyn > *:nth-child(1) {
|
|
38
|
+
margin: 0;
|
|
39
|
+
padding: 0;
|
|
40
|
+
font-size: 1em;
|
|
41
|
+
margin-right: 0.2em;
|
|
42
|
+
margin-left: 0.2em;
|
|
43
|
+
vertical-align: baseline;
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
display: inline-block;
|
|
46
|
+
}
|
|
47
|
+
.relaxngui_dyn > *:nth-child(2) {
|
|
48
|
+
flex: 1 1 auto;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.relaxngui_dyn > .relaxngui_table { padding: 0; margin: 0; }
|
|
52
|
+
.relaxngui_dyn:nth-child(even) { background-color: #fff; }
|
|
53
|
+
.relaxngui_dyn:nth-child(odd) { background-color: #e9e9e9; }
|
|
54
|
+
.relaxngui_table.even > .relaxngui_row:nth-child(even) { background-color: #fff; }
|
|
55
|
+
.relaxngui_table.even > .relaxngui_row:nth-child(odd) { background-color: #e9e9e9; }
|
|
56
|
+
.relaxngui_table.odd > .relaxngui_row:nth-child(even) { background-color: #e9e9e9; }
|
|
57
|
+
.relaxngui_table.odd > .relaxngui_row:nth-child(odd) { background-color: #fff; }
|
|
58
|
+
.relaxngui_table.even > .relaxngui_hint:nth-child(odd) { background-color: #fff; }
|
|
59
|
+
.relaxngui_table.even > .relaxngui_hint:nth-child(even) { background-color: #e9e9e9; }
|
|
60
|
+
.relaxngui_table.odd > .relaxngui_hint:nth-child(odd) { background-color: #e9e9e9; }
|
|
61
|
+
.relaxngui_table.odd > .relaxngui_hint:nth-child(even) { background-color: #fff; }
|
|
62
|
+
|
|
63
|
+
.relaxngui_dyn:nth-child(even) > .relaxngui_table > .relaxngui_row:nth-child(1):nth-last-child(1) {
|
|
64
|
+
background-color: #fff;
|
|
65
|
+
}
|
|
66
|
+
.relaxngui_dyn:nth-child(odd) > .relaxngui_table > .relaxngui_row:nth-child(1):nth-last-child(1) {
|
|
67
|
+
background-color: #e9e9e9;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.relaxngui_table.even { background-color: #e9e9e9; }
|
|
71
|
+
.relaxngui_table.odd { background-color: #fff; }
|
|
72
|
+
|
|
73
|
+
.relaxngui_row {
|
|
74
|
+
width: 100%;
|
|
75
|
+
display: flex;
|
|
76
|
+
flex-direction: row;
|
|
77
|
+
}
|
|
78
|
+
.relaxngui_hint {
|
|
79
|
+
padding-left: 0.2em;
|
|
80
|
+
}
|
|
81
|
+
.relaxngui_hint::before {
|
|
82
|
+
content: "↳ ";
|
|
83
|
+
}
|
|
84
|
+
.relaxngui_header {
|
|
85
|
+
margin: 0;
|
|
86
|
+
padding: 0;
|
|
87
|
+
padding-top: 0.7em;
|
|
88
|
+
padding-bottom: 0.2em;
|
|
89
|
+
padding-left: 0.1em;
|
|
90
|
+
display: block;
|
|
91
|
+
font-weight: bold;
|
|
92
|
+
font-size: 1.2em;
|
|
93
|
+
}
|
|
94
|
+
.relaxngui_dyn .relaxngui_header {
|
|
95
|
+
font-size: 1em;
|
|
96
|
+
}
|
|
97
|
+
button.relaxngui_control {
|
|
98
|
+
margin: 0.5em 0;
|
|
99
|
+
align-self: flex-start;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.relaxngui_cell { }
|
|
103
|
+
|
|
104
|
+
.relaxngui_cell:nth-child(1), .relaxngui_cell:nth-child(2) {
|
|
105
|
+
margin: 0;
|
|
106
|
+
padding: 0.1em 0.2em;
|
|
107
|
+
font-size: 1em;
|
|
108
|
+
font-family: sans-serif;
|
|
109
|
+
}
|
|
110
|
+
input.relaxngui_cell:nth-child(1) {
|
|
111
|
+
border: 0 none;
|
|
112
|
+
background: none;
|
|
113
|
+
}
|
|
114
|
+
.relaxngui_cell:nth-child(3) {
|
|
115
|
+
margin: 0;
|
|
116
|
+
padding: 0.1em 0.2em;
|
|
117
|
+
flex: 1 1 auto;
|
|
118
|
+
font-size: 1em;
|
|
119
|
+
font-family: sans-serif;
|
|
120
|
+
}
|
|
121
|
+
select.relaxngui_cell:nth-child(3) {
|
|
122
|
+
-webkit-appearance: none; /*Removes default chrome and safari style*/
|
|
123
|
+
-moz-appearance: none; /* Removes Default Firefox style*/
|
|
124
|
+
padding: 0;
|
|
125
|
+
}
|
|
126
|
+
select.relaxngui_cell:nth-child(3), button.relaxngui_cell:nth-child(3), textarea.relaxngui_cell:nth-child(3), input.relaxngui_cell:nth-child(3), [contenteditable].relaxngui_cell:nth-child(3) {
|
|
127
|
+
border: 0 none;
|
|
128
|
+
background: none;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
[contenteditable].relaxngui_cell:nth-child(3) {
|
|
132
|
+
overflow-x: auto;
|
|
133
|
+
overflow-wrap: normal;
|
|
134
|
+
white-space: pre;
|
|
135
|
+
font-family: monospace,monospace;
|
|
136
|
+
}
|
|
137
|
+
[contenteditable][data-relaxngui-wrap='true'].relaxngui_cell:nth-child(3) {
|
|
138
|
+
white-space: normal;
|
|
139
|
+
}
|
|
140
|
+
[contenteditable].relaxngui_cell:focus {
|
|
141
|
+
outline: 0px solid transparent;
|
|
142
|
+
}
|
|
143
|
+
[contenteditable].relaxngui_cell:empty:before {
|
|
144
|
+
font-family: sans-serif;
|
|
145
|
+
color: #a1a1a1;
|
|
146
|
+
white-space: normal;
|
|
147
|
+
content: attr(placeholder);
|
|
148
|
+
display: block;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.relaxngui_template {
|
|
152
|
+
display: none;
|
|
153
|
+
}
|
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
/*
|
|
2
|
+
This file is part of RelaxNGui.
|
|
3
|
+
|
|
4
|
+
RelaxNGui is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
6
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
7
|
+
version.
|
|
8
|
+
|
|
9
|
+
RelaxNGui is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
10
|
+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
11
|
+
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
12
|
+
|
|
13
|
+
You should have received a copy of the GNU General Public License along with
|
|
14
|
+
RelaxNGui (file COPYING in the main directory). If not, see
|
|
15
|
+
<http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
var RelaxNGui = function(rng,target,ceval,ignore=false) {
|
|
19
|
+
if (!(rng instanceof XMLDocument)) { // rng has to be XMLDocument //{{{
|
|
20
|
+
rng = $XR($(rng).serializeXML());
|
|
21
|
+
} //}}}
|
|
22
|
+
|
|
23
|
+
var lenextract = function(tag, lencount) { //{{{
|
|
24
|
+
$.each(tag.attributes,function(k,v){
|
|
25
|
+
if ((v.localName == 'label') && (v.namespaceURI == 'http://rngui.org')) { lencount = v.nodeValue.length > lencount ? v.nodeValue.length : lencount; }
|
|
26
|
+
});
|
|
27
|
+
return lencount;
|
|
28
|
+
}; //}}}
|
|
29
|
+
|
|
30
|
+
var labextract = function(type,tag) { //{{{
|
|
31
|
+
var ret = { 'type': type, 'wrap': false, 'readonly': false, 'label': '', default: '' };
|
|
32
|
+
$.each(tag.attributes,function(k,v){
|
|
33
|
+
if ((v.localName == 'label') && (v.namespaceURI == 'http://rngui.org')) { ret['label'] = v.nodeValue; }
|
|
34
|
+
if ((v.localName == 'readonly') && (v.namespaceURI == 'http://rngui.org')) { ret['readonly'] = v.nodeValue == 'true' ? true : false; }
|
|
35
|
+
if ((v.localName == 'wrap') && (v.namespaceURI == 'http://rngui.org')) { ret['wrap'] = v.nodeValue == 'true' ? true : false; }
|
|
36
|
+
});
|
|
37
|
+
return ret;
|
|
38
|
+
}; //}}}
|
|
39
|
+
|
|
40
|
+
var addelements = function(target) { //{{{
|
|
41
|
+
var template = target.parent().find('> .relaxngui_template').clone(true,true);
|
|
42
|
+
template.removeClass('relaxngui_template');
|
|
43
|
+
template.find('[data-relaxngui-template]').each(function(j,t){
|
|
44
|
+
$(t).attr('data-relaxngui-template',false);
|
|
45
|
+
});
|
|
46
|
+
template.find('.relaxngui_template [data-relaxngui-template]').each(function(j,t){
|
|
47
|
+
$(t).attr('data-relaxngui-template',true);
|
|
48
|
+
});
|
|
49
|
+
template.addClass('relaxngui_dyn');
|
|
50
|
+
template.on('click', '> *:first-child', function(ev){ delelements($(ev.target)); });
|
|
51
|
+
|
|
52
|
+
if (target.parent().find('> .relaxngui_dyn').length % 2 == 1) {
|
|
53
|
+
var evens = template.find('.even');
|
|
54
|
+
var odds = template.find('.odd');
|
|
55
|
+
evens.each(function(k,v){
|
|
56
|
+
$(v).removeClass('even');
|
|
57
|
+
$(v).addClass('odd');
|
|
58
|
+
});
|
|
59
|
+
odds.each(function(k,v){
|
|
60
|
+
$(v).removeClass('odd');
|
|
61
|
+
$(v).addClass('even');
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
target.parent().find('> .relaxngui_control').before(template);
|
|
66
|
+
}; //}}}
|
|
67
|
+
|
|
68
|
+
var delelements = function(target) { //{{{
|
|
69
|
+
var it = target.parent();
|
|
70
|
+
var par = target.parent().parent();
|
|
71
|
+
it.remove();
|
|
72
|
+
par.trigger('relaxngui_remove');
|
|
73
|
+
}; //}}}
|
|
74
|
+
|
|
75
|
+
var recshow_header = function(tag,ret){ //{{{
|
|
76
|
+
var header;
|
|
77
|
+
$.each(tag.attributes,function(k,v){
|
|
78
|
+
if ((v.localName == 'header') && (v.namespaceURI == 'http://rngui.org')) { header = v.nodeValue; }
|
|
79
|
+
});
|
|
80
|
+
if (header) {
|
|
81
|
+
ret.append($("<div class='relaxngui_header'>" + header + "</div>"));
|
|
82
|
+
}
|
|
83
|
+
} //}}}
|
|
84
|
+
|
|
85
|
+
var recshow_single = function(tag,ret,template,path,lencount){ //{{{
|
|
86
|
+
var node = $('<div class="relaxngui_row"/>');
|
|
87
|
+
var name;
|
|
88
|
+
var label;
|
|
89
|
+
var second = {};
|
|
90
|
+
var datalist = [];
|
|
91
|
+
var defaul = '';
|
|
92
|
+
var hint = '';
|
|
93
|
+
var retcount = 0;
|
|
94
|
+
$.each(tag.attributes,function(k,v){
|
|
95
|
+
if ((v.localName == 'label') && (v.namespaceURI == 'http://rngui.org')) { label = v.nodeValue; }
|
|
96
|
+
if ((v.localName == 'date') && (v.namespaceURI == 'http://rngui.org')) { label = v.nodeValue; }
|
|
97
|
+
if ((v.localName == 'default') && (v.namespaceURI == 'http://rngui.org')) { defaul = v.nodeValue; }
|
|
98
|
+
if ((v.localName == 'hint') && (v.namespaceURI == 'http://rngui.org')) { hint = v.nodeValue; }
|
|
99
|
+
if (v.localName == 'name') { name = v.nodeValue; }
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
$.each($(tag).children('data[type=string]'), function(k,v) { second = labextract('string',v); });
|
|
103
|
+
$.each($(tag).children('data[type=integer]'), function(k,v) { second = labextract('integer',v); });
|
|
104
|
+
$.each($(tag).children('data[type=nonNegativeInteger]'), function(k,v) { second = labextract('nonNegativeInteger',v); });
|
|
105
|
+
$.each($(tag).children('data[type=positiveInteger]'), function(k,v) { second = labextract('positiveInteger',v); });
|
|
106
|
+
$.each($(tag).children('data[type=float]'), function(k,v) { second = labextract('float',v); });
|
|
107
|
+
$.each($(tag).children('data[type=date]'), function(k,v) { second = labextract('date',v); });
|
|
108
|
+
$.each($(tag).children('text'), function(k,v) { second = labextract('text',v); });
|
|
109
|
+
$.each($(tag).find('choice > value'), function(k,v) {
|
|
110
|
+
second = labextract('datalist',$(v).parent()[0]);
|
|
111
|
+
datalist.push(v.textContent);
|
|
112
|
+
});
|
|
113
|
+
if (name && label) {
|
|
114
|
+
node.append($("<label class='relaxngui_cell' style='min-width: " + (lencount+1) + "ex' for=''>" + label + "</label><span class='relaxngui_cell'>⇒</span>"));
|
|
115
|
+
} else if (name) {
|
|
116
|
+
// a tag without information is ignored
|
|
117
|
+
} else if (label) {
|
|
118
|
+
node.append($("<input data-relaxngui-template='" + template + "' data-relaxngui-parent='" + path + "' data-relaxngui-path='" + path + " > *[data-name]' class='relaxngui_cell' type='text' pattern='^[a-z][a-zA-Z0-9_]*$' id='' placeholder='" + label + "'></input><span class='relaxngui_cell'>⇒</span>"));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
var tpath = ((typeof name === 'undefined') ? path + ' > *' : (tag.localName == 'element' ? path + ' > ' + $(tag).attr('name') : path + '[' + $(tag).attr('name') + ']'));
|
|
122
|
+
if (label) {
|
|
123
|
+
if (defaul && typeof defaul == 'string' && defaul.match(/^javascript:/)) {
|
|
124
|
+
defaul = defaul.replace(/^javascript:/,'');
|
|
125
|
+
defaul = ceval ? ceval(defaul) : eval(defaul);
|
|
126
|
+
}
|
|
127
|
+
if (second.readonly)
|
|
128
|
+
node.append($("<input " + (defaul && typeof defaul == 'string' ? 'value="' + defaul + '"' : '') + " data-relaxngui-template='" + template + "' data-relaxngui-parent='" + path + "' data-relaxngui-path='" + tpath + "' class='relaxngui_cell' type='text' id='' readonly='readonly'></input>"));
|
|
129
|
+
else {
|
|
130
|
+
if (second.type == 'string')
|
|
131
|
+
node.append($("<input " + (defaul && typeof defaul == 'string' ? 'value="' + defaul + '"' : '') + " data-relaxngui-template='" + template + "' data-relaxngui-parent='" + path + "' data-relaxngui-path='" + tpath + "' class='relaxngui_cell' type='text' id='' placeholder='" + second.label + "'></input>"));
|
|
132
|
+
else if (second.type == 'integer')
|
|
133
|
+
node.append($("<input " + (defaul && typeof defaul == 'string' ? 'value="' + defaul + '"' : '') + " data-relaxngui-template='" + template + "' data-relaxngui-parent='" + path + "' data-relaxngui-path='" + tpath + "' class='relaxngui_cell' type='number' id='' placeholder='" + second.label + "'></input>"));
|
|
134
|
+
else if (second.type == 'positiveInteger')
|
|
135
|
+
node.append($("<input " + (defaul && typeof defaul == 'string' ? 'value="' + defaul + '"' : '') + " data-relaxngui-template='" + template + "' data-relaxngui-parent='" + path + "' data-relaxngui-path='" + tpath + "' class='relaxngui_cell' type='number' id='' placeholder='" + second.label + "' min='1'></input>"));
|
|
136
|
+
else if (second.type == 'nonNegativeInteger')
|
|
137
|
+
node.append($("<input " + (defaul && typeof defaul == 'string' ? 'value="' + defaul + '"' : '') + " data-relaxngui-template='" + template + "' data-relaxngui-parent='" + path + "' data-relaxngui-path='" + tpath + "' class='relaxngui_cell' type='number' id='' placeholder='" + second.label + "' min='0'></input>"));
|
|
138
|
+
else if (second.type == 'date')
|
|
139
|
+
node.append($("<input " + (defaul && typeof defaul == 'string' ? 'value="' + defaul + '"' : '') + " data-relaxngui-template='" + template + "' data-relaxngui-parent='" + path + "' data-relaxngui-path='" + tpath + "' class='relaxngui_cell' type='date' id='' placeholder='" + second.label + "'></input>"));
|
|
140
|
+
else if (second.type == 'float')
|
|
141
|
+
node.append($("<input " + (defaul && typeof defaul == 'string' ? 'value="' + defaul + '"' : '') + " data-relaxngui-template='" + template + "' data-relaxngui-parent='" + path + "' data-relaxngui-path='" + tpath + "' class='relaxngui_cell' type='number' step='any' id='' placeholder='" + second.label + "'></input>"));
|
|
142
|
+
else if (second.type == 'text')
|
|
143
|
+
node.append($("<div contenteditable='true' data-relaxngui-wrap='" + second.wrap + "' " + (defaul && typeof defaul == 'string' ? 'value="' + defaul + '"' : '') + " data-relaxngui-template='" + template + "' data-relaxngui-parent='" + path + "' data-relaxngui-path='" + tpath + "' class='relaxngui_cell' id='' placeholder='" + second.label + "'></div>"));
|
|
144
|
+
else if (second.type == 'datalist') {
|
|
145
|
+
var tnode = $("<select " + (defaul && typeof defaul == 'string' ? 'value="' + defaul + '"' : '') + " data-relaxngui-template='" + template + "' data-relaxngui-parent='" + path + "' data-relaxngui-path='" + tpath + "' class='relaxngui_cell' id='' size='1'></select>");
|
|
146
|
+
$.each(datalist,function(didx,dname){
|
|
147
|
+
if (dname == defaul)
|
|
148
|
+
tnode.append('<option value="' + dname + '" selected="selected">' + dname + '</value>');
|
|
149
|
+
else
|
|
150
|
+
tnode.append('<option value="' + dname + '">' + dname + '</value>');
|
|
151
|
+
});
|
|
152
|
+
node.append(tnode);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
ret.append(node);
|
|
156
|
+
retcount += 1;
|
|
157
|
+
} else {
|
|
158
|
+
if (tag.localName != 'element') { // its an attribute, simulate its empty-ness
|
|
159
|
+
node.attr('data-relaxngui-template',template);
|
|
160
|
+
node.attr('data-relaxngui-parent',path);
|
|
161
|
+
node.attr('data-relaxngui-path',tpath);
|
|
162
|
+
ret.append(node);
|
|
163
|
+
retcount += 1;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (hint) {
|
|
167
|
+
var n = $('<div class="relaxngui_hint"/>');
|
|
168
|
+
var s1 = $('<em>Hint: </em>');
|
|
169
|
+
var s2 = $('<span/>');
|
|
170
|
+
s2.text(hint);
|
|
171
|
+
|
|
172
|
+
n.append(s1);
|
|
173
|
+
n.append(s2);
|
|
174
|
+
ret.append(n);
|
|
175
|
+
retcount += 1;
|
|
176
|
+
}
|
|
177
|
+
return retcount;
|
|
178
|
+
} //}}}
|
|
179
|
+
|
|
180
|
+
var recshow = function(elements,template,path,attr) { //{{{
|
|
181
|
+
// delete all elements with relaxngui:ignore
|
|
182
|
+
if (attr.ignore) {
|
|
183
|
+
var tele = $.grep(elements,function(tagv){
|
|
184
|
+
var include = true;
|
|
185
|
+
$.each(tagv.attributes,function(k,v){
|
|
186
|
+
if ((v.localName == 'ignore') && (v.namespaceURI == 'http://rngui.org')) {
|
|
187
|
+
include = false;
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
return include;
|
|
191
|
+
});
|
|
192
|
+
elements = $(tele);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
var ret = $('<div/>');
|
|
196
|
+
|
|
197
|
+
var lencount = 0;
|
|
198
|
+
$.each(elements,function(k,v){
|
|
199
|
+
var tag = $(v)[0];
|
|
200
|
+
if ((tag.localName == 'element') && (tag.namespaceURI == 'http://relaxng.org/ns/structure/1.0')) {
|
|
201
|
+
$(tag).children('attribute').each(function(l,w){
|
|
202
|
+
lencount = lenextract($(w)[0],lencount);
|
|
203
|
+
});
|
|
204
|
+
lencount = lenextract(tag,lencount);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
$.each(elements,function(k,v){
|
|
208
|
+
if (attr.mode == 'even') { attr.mode = 'odd' }
|
|
209
|
+
else { attr.mode = 'even'; }
|
|
210
|
+
|
|
211
|
+
var tag = $(v)[0];
|
|
212
|
+
|
|
213
|
+
if ((tag.localName == 'element') && (tag.namespaceURI == 'http://relaxng.org/ns/structure/1.0')) {
|
|
214
|
+
var xxx;
|
|
215
|
+
if (template) {
|
|
216
|
+
var yyy = $('<div class="relaxngui_table ' + attr.mode + '" data-relaxngui-template="true" data-relaxngui-parent="' + path + '" data-relaxngui-path="' + (path == '' ? ' > ' + (typeof elements.attr('name') === 'undefined' ? '*' : elements.attr('name')) : path + ' > ' + (typeof $(tag).attr('name') === 'undefined' ? '*' : $(tag).attr('name'))) + '[data-main]">');
|
|
217
|
+
xxx = $('<div class="relaxngui_template"><span>✖</span></div>');
|
|
218
|
+
xxx.append(yyy);
|
|
219
|
+
ret.append(xxx);
|
|
220
|
+
xxx = yyy;
|
|
221
|
+
} else {
|
|
222
|
+
xxx = $('<div class="relaxngui_table ' + attr.mode + '" data-relaxngui-template="false" data-relaxngui-parent="' + path + '" data-relaxngui-path="' + (path == '' ? ' > ' + elements.attr('name') : path + ' > ' + $(tag).attr('name')) + '[data-main]">');
|
|
223
|
+
ret.append(xxx);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
recshow_header(tag,xxx);
|
|
227
|
+
var rcount = 0;
|
|
228
|
+
$(tag).children('attribute').each(function(l,w){
|
|
229
|
+
var ttag = $(w)[0];
|
|
230
|
+
rcount += recshow_single(ttag,xxx,template,path + ' > ' + $(tag).attr('name'),lencount);
|
|
231
|
+
});
|
|
232
|
+
rcount += recshow_single(tag,xxx,template,path,lencount);
|
|
233
|
+
|
|
234
|
+
var sub;
|
|
235
|
+
if (sub = recshow($(tag).children('element, zeroOrMore'),false,path + ' > ' + $(tag).attr('name'),{ ignore: attr.ignore, mode: (attr.mode == 'even' && rcount % 2 == 0 ? 'odd' : 'even' ) })) {
|
|
236
|
+
var inode = xxx.append(sub);
|
|
237
|
+
if (template) {
|
|
238
|
+
inode.find('[data-relaxngui-template]').each(function(j,t){
|
|
239
|
+
$(t).attr('data-relaxngui-template',true);
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
} else if ((tag.localName == 'zeroOrMore') && (tag.namespaceURI == 'http://relaxng.org/ns/structure/1.0')) {
|
|
244
|
+
var label;
|
|
245
|
+
$.each(tag.attributes,function(k,v){
|
|
246
|
+
if ((v.localName == 'label') && (v.namespaceURI == 'http://rngui.org')) { label = v.nodeValue; }
|
|
247
|
+
});
|
|
248
|
+
var but = $('<button class="relaxngui_control">' + label + '</button>');
|
|
249
|
+
but.on('click',function(ev){ addelements($(ev.target)); });
|
|
250
|
+
|
|
251
|
+
ret.append(recshow($(tag).children(),true,path,{ ignore: attr.ignore, mode: attr.mode }));
|
|
252
|
+
ret.append(but);
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
return ret.children().length > 0 ? ret.children() : undefined;
|
|
256
|
+
}; //}}}
|
|
257
|
+
|
|
258
|
+
var serializeXML = function (xml) { //{{{
|
|
259
|
+
var out = '';
|
|
260
|
+
if (typeof XMLSerializer == 'function') {
|
|
261
|
+
var xs = new XMLSerializer();
|
|
262
|
+
$(xml).each(function() {
|
|
263
|
+
out += xs.serializeToString(this);
|
|
264
|
+
});
|
|
265
|
+
} else if (xml && xml.xml != 'undefined') {
|
|
266
|
+
$(xml).each(function() {
|
|
267
|
+
out += this.xml;
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
return out;
|
|
271
|
+
}; //}}}
|
|
272
|
+
this.save = function() { //{{{
|
|
273
|
+
var xml;
|
|
274
|
+
var curr;
|
|
275
|
+
var tar = target.find('[data-relaxngui-path]:not([data-relaxngui-template=true])');
|
|
276
|
+
for (var i = 0; i<tar.length;) {
|
|
277
|
+
var path = $(tar[i]).attr('data-relaxngui-path');
|
|
278
|
+
var parent_path = $(tar[i]).attr('data-relaxngui-parent');
|
|
279
|
+
if (i == 0) {
|
|
280
|
+
var par = path.replace(/\[data-main\]/,'').replace(/ > /,'');
|
|
281
|
+
xml = $XR('<' + par + '/>');
|
|
282
|
+
} else {
|
|
283
|
+
var ma = path.match(/([^\s]+)$/)[1];
|
|
284
|
+
var att;
|
|
285
|
+
if (ma.match(/\*\[data-main\]/)) {
|
|
286
|
+
// do nothing. seriously. explicitly.
|
|
287
|
+
} else if (ma.match(/\[data-main\]/)) {
|
|
288
|
+
var par = ma.replace(/\[data-main\]/,'');
|
|
289
|
+
var curr = $($XR('<' + par + '/>').documentElement);
|
|
290
|
+
$(parent_path,xml).last().append(curr);
|
|
291
|
+
} else if (ma.match(/\[data-name\]/)) {
|
|
292
|
+
if ($(tar[i]).get_val()) {
|
|
293
|
+
var nn = $($XR('<' + $(tar[i]).get_val() + '/>').documentElement).text($(tar[i+1]).get_val());
|
|
294
|
+
$(parent_path,xml).append(nn);
|
|
295
|
+
}
|
|
296
|
+
i+=1;
|
|
297
|
+
} else if (att = ma.match(/\[([^\]]+)\]$/)) {
|
|
298
|
+
$(parent_path + ':last-child',xml).last().attr(att[1],$(tar[i]).get_val());
|
|
299
|
+
} else {
|
|
300
|
+
$(path + ':last-child',xml).last().text($(tar[i]).get_val())
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
i+=1;
|
|
304
|
+
}
|
|
305
|
+
return xml;
|
|
306
|
+
}; //}}}
|
|
307
|
+
this.save_text = function() { //{{{
|
|
308
|
+
return serializeXML(self.save());
|
|
309
|
+
} //}}}
|
|
310
|
+
|
|
311
|
+
this.content = function(data) { //{{{
|
|
312
|
+
if (!(data instanceof XMLDocument)) { // data has to be XMLDocument //{{{
|
|
313
|
+
data = $XR($(data).serializeXML());
|
|
314
|
+
} //}}}
|
|
315
|
+
|
|
316
|
+
if (data) {
|
|
317
|
+
var x = $(data).serializePrettyXML();
|
|
318
|
+
x = x.replace(/\s+xmlns(:[a-zA-Z0-9]+)?=\"[^\"]+\"/g, "");
|
|
319
|
+
x = x.replace(/<\?[^>]+>/g, "");
|
|
320
|
+
x = x.trim();
|
|
321
|
+
y = $(self.save()).serializePrettyXML();
|
|
322
|
+
if (x != y) {
|
|
323
|
+
target.find('.relaxngui_dyn').remove();
|
|
324
|
+
target.find('[data-relaxngui-path]').each(function(k,pa){
|
|
325
|
+
var path = $(pa).attr('data-relaxngui-path');
|
|
326
|
+
if (!path.match(/data-\w+\]$/)) {
|
|
327
|
+
if ($(pa).attr('data-relaxngui-template') == 'true' && path.match(/\*$/)) {
|
|
328
|
+
$(data).find(path).each(function(index,ele){
|
|
329
|
+
$(target.find('[data-relaxngui-path="' + path + '[data-name]"][data-relaxngui-template="false"]').get(index)).set_val(ele.localName);
|
|
330
|
+
$(target.find('[data-relaxngui-path="' + path + '"][data-relaxngui-template="false"]').get(index)).set_val($(ele).text());
|
|
331
|
+
});
|
|
332
|
+
} else if ($(pa).attr('data-relaxngui-template') == 'true' && !path.match(/\*$/)) {
|
|
333
|
+
$(data).find(path).each(function(index,ele){
|
|
334
|
+
var att;
|
|
335
|
+
var val;
|
|
336
|
+
if (att = path.match(/(.*)\[([^\]]+)\]$/)) {
|
|
337
|
+
val = $(ele).attr(att[2]);
|
|
338
|
+
} else {
|
|
339
|
+
val = $(ele).text();
|
|
340
|
+
}
|
|
341
|
+
if (val && val != '') {
|
|
342
|
+
$(target.find('[data-relaxngui-path="' + path + '"][data-relaxngui-template="false"]').get(index)).set_val(val);
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
} else {
|
|
346
|
+
var att;
|
|
347
|
+
var val;
|
|
348
|
+
if (att = path.match(/(.*)\[([^\]]+)\]$/)) {
|
|
349
|
+
val = $(data).find(att[1]).attr(att[2]);
|
|
350
|
+
} else {
|
|
351
|
+
val = $(data).find(path).text();
|
|
352
|
+
}
|
|
353
|
+
if (val && val != '') {
|
|
354
|
+
target.find('[data-relaxngui-path="' + path + '"]').set_val(val);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
} else {
|
|
358
|
+
if ($(pa).attr('data-relaxngui-template') == 'true') {
|
|
359
|
+
var but = target.find('.relaxngui_table[data-relaxngui-template="false"] > .relaxngui_template > [data-relaxngui-path="' + path + '"][data-relaxngui-template="true"]').parent().parent().find('> button');
|
|
360
|
+
if (but.length > 0) {
|
|
361
|
+
var dpath = path.replace(/\[data-main\]$/,'');
|
|
362
|
+
var par = undefined;
|
|
363
|
+
var ind = -1;
|
|
364
|
+
$(data).find(dpath).each(function(ke,ele){
|
|
365
|
+
if (par != $(ele).parent()[0]) {
|
|
366
|
+
ind += 1;
|
|
367
|
+
par = $(ele).parent()[0];
|
|
368
|
+
}
|
|
369
|
+
if ($(but.get(ind)).attr('disabled')) {
|
|
370
|
+
$(but.get(ind)).removeAttr('disabled');
|
|
371
|
+
but.get(ind).click();
|
|
372
|
+
$(but.get(ind)).attr('disabled','disabled');
|
|
373
|
+
} else {
|
|
374
|
+
but.get(ind).click();
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
self.set_checkpoint();
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}; //}}}
|
|
385
|
+
|
|
386
|
+
// stuff to determine if user changed something
|
|
387
|
+
var orig = '';
|
|
388
|
+
this.set_checkpoint = function() { //{{{
|
|
389
|
+
orig = self.save_text();
|
|
390
|
+
} //}}}
|
|
391
|
+
this.has_changed = function() { //{{{
|
|
392
|
+
if (orig != self.save_text()) {
|
|
393
|
+
return true;
|
|
394
|
+
} else {
|
|
395
|
+
return false;
|
|
396
|
+
}
|
|
397
|
+
} //}}}
|
|
398
|
+
|
|
399
|
+
target.append(recshow($(rng.documentElement),false,'',{ ignore: ignore, mode: 'even'}));
|
|
400
|
+
|
|
401
|
+
var self = this;
|
|
402
|
+
};
|