cpee 2.0.18 → 2.0.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cockpit/css/wfadaptor.css +17 -0
- data/cockpit/js/instance.js +9 -8
- data/cockpit/js_libs.zip +0 -0
- data/cockpit/templates/.CPEE.xml +8 -0
- data/cockpit/templates/.Signavio.xml +8 -0
- data/cockpit/templates/.templates.xml +13 -0
- data/cockpit/templates/.transformations.xml +4 -0
- data/cockpit/themes/model/rngs/call.rng +2 -1
- data/cockpit/themes/model/rngs/callmanipulate.rng +2 -1
- data/cockpit/themes/model/theme.js +1 -1
- data/cpee.gemspec +2 -2
- data/lib/cpee/controller.rb +6 -3
- data/lib/cpee/implementation.rb +23 -8
- data/lib/cpee/implementation_notifications.rb +1 -1
- data/lib/cpee/persistence.rb +2 -1
- data/lib/cpee/redis.rb +57 -0
- data/server/handlerwrappers/default.rb +15 -15
- data/server/resources/notifications/logging/subscription.xml +6 -0
- data/server/routing/end.rb +16 -4
- data/server/routing/forward-events.rb +19 -7
- data/server/routing/forward-votes.rb +19 -7
- data/server/routing/persist.rb +26 -14
- data/tools/cpee +5 -5
- data/tools/test/README +4 -0
- data/tools/test/config.json +3 -0
- data/tools/test/contrib/graph_example.svg +1166 -0
- data/tools/test/contrib/legend.svg +817 -0
- data/tools/test/contrib/symbols.svg +224 -0
- data/tools/test/contrib/transformation1.xsl +264 -0
- data/tools/test/contrib/transformation2.xsl +10 -0
- data/tools/test/contrib/tree_example.svg +788 -0
- data/tools/test/css/model.css +24 -0
- data/tools/test/css/track.css +60 -0
- data/tools/test/css/ui.css +214 -0
- data/tools/test/css/wfadaptor.css +422 -0
- data/tools/test/edit.html +258 -0
- data/tools/test/graph.html +69 -0
- data/tools/test/index.html +258 -0
- data/tools/test/js/details.js +109 -0
- data/tools/test/js/instance.js +1344 -0
- data/tools/test/js/model.js +41 -0
- data/tools/test/js/parameters.js +82 -0
- data/tools/test/js/track.js +18 -0
- data/tools/test/js/ui.js +104 -0
- data/tools/test/js/wfadaptor.js +763 -0
- data/tools/test/js_libs.zip +0 -0
- data/tools/test/js_libs/Makefile +2 -0
- data/tools/test/js_libs/ansi_up.js +333 -0
- data/tools/test/js_libs/console.js +80 -0
- data/tools/test/js_libs/custommenu.css +84 -0
- data/tools/test/js_libs/custommenu.js +104 -0
- data/tools/test/js_libs/experiments1/relaxngui.css +185 -0
- data/tools/test/js_libs/experiments1/relaxngui.js +488 -0
- data/tools/test/js_libs/experiments1/rngtest9.html +60 -0
- data/tools/test/js_libs/experiments1/rngtest9.rng +35 -0
- data/tools/test/js_libs/experiments1/rngtest9.xml +8 -0
- data/tools/test/js_libs/jquery-2.2.4.min.js +4 -0
- data/tools/test/js_libs/jquery-3.2.1.min.js +4 -0
- data/tools/test/js_libs/jquery-3.3.1.min.js +2 -0
- data/tools/test/js_libs/jquery.browser.js +40 -0
- data/tools/test/js_libs/jquery.caret.min.js +10 -0
- data/tools/test/js_libs/jquery.cookie.js +117 -0
- data/tools/test/js_libs/jquery.min.js +1 -0
- data/tools/test/js_libs/jquery.svg.min.js +6 -0
- data/tools/test/js_libs/jquery.svgdom.min.js +6 -0
- data/tools/test/js_libs/markdown.min.js +1 -0
- data/tools/test/js_libs/parsequery.js +21 -0
- data/tools/test/js_libs/printf.js +368 -0
- data/tools/test/js_libs/relaxngui.css +213 -0
- data/tools/test/js_libs/relaxngui.js +543 -0
- data/tools/test/js_libs/strftime.min.js +1 -0
- data/tools/test/js_libs/tests/dataelements.html +59 -0
- data/tools/test/js_libs/tests/dataelements.rng +8 -0
- data/tools/test/js_libs/tests/dataelements.xml +3 -0
- data/tools/test/js_libs/tests/relaxngui.css +203 -0
- data/tools/test/js_libs/tests/relaxngui.js +502 -0
- data/tools/test/js_libs/tests/rngtest1.html +66 -0
- data/tools/test/js_libs/tests/rngtest1.rng +147 -0
- data/tools/test/js_libs/tests/rngtest1.xml +13 -0
- data/tools/test/js_libs/tests/rngtest2.html +60 -0
- data/tools/test/js_libs/tests/rngtest2.rng +6 -0
- data/tools/test/js_libs/tests/rngtest2.xml +3 -0
- data/tools/test/js_libs/tests/rngtest3.html +60 -0
- data/tools/test/js_libs/tests/rngtest3.rng +23 -0
- data/tools/test/js_libs/tests/rngtest3.xml +9 -0
- data/tools/test/js_libs/tests/rngtest4.html +60 -0
- data/tools/test/js_libs/tests/rngtest4.rng +19 -0
- data/tools/test/js_libs/tests/rngtest4.xml +12 -0
- data/tools/test/js_libs/tests/rngtest5.html +60 -0
- data/tools/test/js_libs/tests/rngtest5.rng +75 -0
- data/tools/test/js_libs/tests/rngtest5.xml +40 -0
- data/tools/test/js_libs/tests/rngtest6.html +60 -0
- data/tools/test/js_libs/tests/rngtest6.rng +24 -0
- data/tools/test/js_libs/tests/rngtest6.xml +6 -0
- data/tools/test/js_libs/tests/rngtest8.html +60 -0
- data/tools/test/js_libs/tests/rngtest8.rng +13 -0
- data/tools/test/js_libs/tests/rngtest8.xml +2 -0
- data/tools/test/js_libs/tests/rngtest9.html +60 -0
- data/tools/test/js_libs/tests/rngtest9.rng +31 -0
- data/tools/test/js_libs/tests/rngtest9.xml +8 -0
- data/tools/test/js_libs/ui.css +333 -0
- data/tools/test/js_libs/ui.html +168 -0
- data/tools/test/js_libs/ui.js +177 -0
- data/tools/test/js_libs/underscore.min.js +27 -0
- data/tools/test/js_libs/util.js +81 -0
- data/tools/test/js_libs/vkbeautify.0.99.00.beta.js +358 -0
- data/tools/test/js_libs/vkbeautify.js +1 -0
- data/tools/test/js_libs/webcomponents.min.js +196 -0
- data/tools/test/model.html +192 -0
- data/tools/test/rngs/attributes.rng +8 -0
- data/tools/test/rngs/dataelements.rng +8 -0
- data/tools/test/rngs/endpoints.rng +8 -0
- data/tools/test/templates.legacy/Async.xml +46 -0
- data/tools/test/templates.legacy/BCO.xml +70 -0
- data/tools/test/templates.legacy/BCS.xml +70 -0
- data/tools/test/templates.legacy/Centurio.xml +75 -0
- data/tools/test/templates.legacy/Concurrent.xml +40 -0
- data/tools/test/templates.legacy/Coopis Testset.xml +76 -0
- data/tools/test/templates.legacy/Endpoints and Data Manipulation.xml +30 -0
- data/tools/test/templates.legacy/ICSOC Testset.xml +95 -0
- data/tools/test/templates.legacy/Infinity.xml +28 -0
- data/tools/test/templates.legacy/Lego Boxer.xml +31 -0
- data/tools/test/templates.legacy/Lego Conveyor.xml +31 -0
- data/tools/test/templates.legacy/Lego Crane.xml +87 -0
- data/tools/test/templates.legacy/Lego Ejector.xml +55 -0
- data/tools/test/templates.legacy/Lego Full.xml +142 -0
- data/tools/test/templates.legacy/Lego Liddy.xml +40 -0
- data/tools/test/templates.legacy/Lego Plate.xml +31 -0
- data/tools/test/templates.legacy/Lego Transporter.xml +43 -0
- data/tools/test/templates.legacy/Lego_Part_1.xml +85 -0
- data/tools/test/templates.legacy/LgLinear.xml +65 -0
- data/tools/test/templates.legacy/Linear.xml +77 -0
- data/tools/test/templates.legacy/Log.xml +117 -0
- data/tools/test/templates.legacy/Mangler 1.xml +87 -0
- data/tools/test/templates.legacy/Mangler 2.xml +103 -0
- data/tools/test/templates.legacy/Manuel Labels.xml +55 -0
- data/tools/test/templates.legacy/Promise.xml +275 -0
- data/tools/test/templates.legacy/SOPROMO Test Sonification.xml +83 -0
- data/tools/test/templates.legacy/Subprocess.xml +56 -0
- data/tools/test/templates.legacy/Syncing P34 1.xml +77 -0
- data/tools/test/templates.legacy/Syncing P34 2.xml +77 -0
- data/tools/test/templates.legacy/Syncing P34 3.xml +77 -0
- data/tools/test/templates.legacy/Syncing P34.xml +77 -0
- data/tools/test/templates.legacy/TEST - Bad Loop.xml +173 -0
- data/tools/test/templates.legacy/TEST - Wrong Positions.xml +174 -0
- data/tools/test/templates.legacy/Take_5.xml +48 -0
- data/tools/test/templates.legacy/Update.xml +32 -0
- data/tools/test/templates.legacy/Worklist Parallel.xml +104 -0
- data/tools/test/templates.legacy/Worklist Test CPEE.xml +40 -0
- data/tools/test/templates.legacy/Worklist Test.xml +42 -0
- data/tools/test/templates.legacy/Worklist Test2.xml +43 -0
- data/tools/test/templates.legacy/convert_cpee2.rb +15 -0
- data/tools/test/templates.legacy/convert_preset.rb +32 -0
- data/tools/test/templates.legacy/testsets.xml +37 -0
- data/tools/test/templates.legacy/transformations.xml +4 -0
- data/tools/test/templates/Coopis 2010.xml +76 -0
- data/tools/test/templates/IUPC arXiv:1104.3609 P34 1.xml +77 -0
- data/tools/test/templates/IUPC arXiv:1104.3609 P34 2.xml +77 -0
- data/tools/test/templates/IUPC arXiv:1104.3609 P34 3.xml +77 -0
- data/tools/test/templates/Track Test Local.xml +82 -0
- data/tools/test/templates/Track Test.xml +82 -0
- data/tools/test/templates/UR-VUE 2020 Manual Adjust.xml +182 -0
- data/tools/test/templates/UR-VUE 2020 Solution Baseline.xml +203 -0
- data/tools/test/templates/UR-VUE 2020 Solution NN.xml +197 -0
- data/tools/test/templates/UR-VUE 2020 Solution View.xml +151 -0
- data/tools/test/templates/UR-VUE 2020.xml +26 -0
- data/tools/test/templates/Worklist.xml +42 -0
- data/tools/test/templates/instantiate.local/Take_Sub.xml +59 -0
- data/tools/test/templates/instantiate/Take_Perf.xml +46 -0
- data/tools/test/templates/instantiate/Take_Sub.xml +58 -0
- data/tools/test/templates/instantiate/Take_X.xml +48 -0
- data/tools/test/themes/compact/theme.js +1285 -0
- data/tools/test/themes/diana/theme.js +1650 -0
- data/tools/test/themes/extended/theme.js +1325 -0
- data/tools/test/themes/model/rngs/alternative.rng +1 -0
- data/tools/test/themes/model/rngs/call.rng +67 -0
- data/tools/test/themes/model/rngs/callmanipulate.rng +72 -0
- data/tools/test/themes/model/rngs/choose.rng +1 -0
- data/tools/test/themes/model/rngs/critical.rng +1 -0
- data/tools/test/themes/model/rngs/escape.rng +1 -0
- data/tools/test/themes/model/rngs/group.rng +1 -0
- data/tools/test/themes/model/rngs/loop.rng +1 -0
- data/tools/test/themes/model/rngs/manipulate.rng +1 -0
- data/tools/test/themes/model/rngs/otherwise.rng +1 -0
- data/tools/test/themes/model/rngs/parallel.rng +1 -0
- data/tools/test/themes/model/rngs/parallel_branch.rng +1 -0
- data/tools/test/themes/model/rngs/scripts.rng +7 -0
- data/tools/test/themes/model/rngs/stop.rng +1 -0
- data/tools/test/themes/model/rngs/terminate.rng +1 -0
- data/tools/test/themes/model/theme.js +1268 -0
- data/tools/test/themes/packed/theme.js +1286 -0
- data/tools/test/themes/preset/rngs/alternative.rng +25 -0
- data/tools/test/themes/preset/rngs/call.rng +122 -0
- data/tools/test/themes/preset/rngs/callmanipulate.rng +145 -0
- data/tools/test/themes/preset/rngs/choose.rng +14 -0
- data/tools/test/themes/preset/rngs/closed_loop.rng +62 -0
- data/tools/test/themes/preset/rngs/closed_loop_cancel.rng +5 -0
- data/tools/test/themes/preset/rngs/closed_loop_control.rng +31 -0
- data/tools/test/themes/preset/rngs/closed_loop_measuring.rng +12 -0
- data/tools/test/themes/preset/rngs/critical.rng +5 -0
- data/tools/test/themes/preset/rngs/escape.rng +1 -0
- data/tools/test/themes/preset/rngs/group.rng +3 -0
- data/tools/test/themes/preset/rngs/loop.rng +22 -0
- data/tools/test/themes/preset/rngs/manipulate.rng +9 -0
- data/tools/test/themes/preset/rngs/otherwise.rng +22 -0
- data/tools/test/themes/preset/rngs/parallel.rng +21 -0
- data/tools/test/themes/preset/rngs/parallel_branch.rng +8 -0
- data/tools/test/themes/preset/rngs/scripts.rng +23 -0
- data/tools/test/themes/preset/rngs/stop.rng +5 -0
- data/tools/test/themes/preset/rngs/terminate.rng +1 -0
- data/tools/test/themes/preset/symbols/alternative.svg +5 -0
- data/tools/test/themes/preset/symbols/arrow.svg +3 -0
- data/tools/test/themes/preset/symbols/call.svg +6 -0
- data/tools/test/themes/preset/symbols/callmanipulate.svg +8 -0
- data/tools/test/themes/preset/symbols/choose.svg +5 -0
- data/tools/test/themes/preset/symbols/choose_exclusive.svg +5 -0
- data/tools/test/themes/preset/symbols/choose_inclusive.svg +4 -0
- data/tools/test/themes/preset/symbols/closed_loop.svg +5 -0
- data/tools/test/themes/preset/symbols/closed_loop_cancel.svg +5 -0
- data/tools/test/themes/preset/symbols/closed_loop_control.svg +5 -0
- data/tools/test/themes/preset/symbols/closed_loop_measuring.svg +6 -0
- data/tools/test/themes/preset/symbols/complex.svg +8 -0
- data/tools/test/themes/preset/symbols/critical.svg +4 -0
- data/tools/test/themes/preset/symbols/end.svg +3 -0
- data/tools/test/themes/preset/symbols/escape.svg +5 -0
- data/tools/test/themes/preset/symbols/event_end.svg +3 -0
- data/tools/test/themes/preset/symbols/loop.svg +5 -0
- data/tools/test/themes/preset/symbols/manipulate.svg +4 -0
- data/tools/test/themes/preset/symbols/otherwise.svg +5 -0
- data/tools/test/themes/preset/symbols/parallel.svg +5 -0
- data/tools/test/themes/preset/symbols/parallel_branch.svg +5 -0
- data/tools/test/themes/preset/symbols/parallel_branch_compact.svg +4 -0
- data/tools/test/themes/preset/symbols/parallel_branch_event.svg +14 -0
- data/tools/test/themes/preset/symbols/parallel_branch_normal.svg +5 -0
- data/tools/test/themes/preset/symbols/scripts.svg +4 -0
- data/tools/test/themes/preset/symbols/start.svg +3 -0
- data/tools/test/themes/preset/symbols/stop.svg +5 -0
- data/tools/test/themes/preset/symbols/terminate.svg +4 -0
- data/tools/test/themes/preset/theme.js +1287 -0
- data/tools/test/track.html +142 -0
- metadata +225 -3
- data/cockpit/edit.html +0 -1
@@ -0,0 +1 @@
|
|
1
|
+
Date.ext={};Date.ext.util={};Date.ext.util.xPad=function(x,pad,r){if(typeof (r)=="undefined"){r=10}for(;parseInt(x,10)<r&&r>1;r/=10){x=pad.toString()+x}return x.toString()};Date.prototype.locale="en-GB";if(document.getElementsByTagName("html")&&document.getElementsByTagName("html")[0].lang){Date.prototype.locale=document.getElementsByTagName("html")[0].lang}Date.ext.locales={};Date.ext.locales.en={a:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],A:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],b:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],B:["January","February","March","April","May","June","July","August","September","October","November","December"],c:"%a %d %b %Y %T %Z",p:["AM","PM"],P:["am","pm"],x:"%d/%m/%y",X:"%T"};Date.ext.locales["en-US"]=Date.ext.locales.en;Date.ext.locales["en-US"].c="%a %d %b %Y %r %Z";Date.ext.locales["en-US"].x="%D";Date.ext.locales["en-US"].X="%r";Date.ext.locales["en-GB"]=Date.ext.locales.en;Date.ext.locales["en-AU"]=Date.ext.locales["en-GB"];Date.ext.formats={a:function(d){return Date.ext.locales[d.locale].a[d.getDay()]},A:function(d){return Date.ext.locales[d.locale].A[d.getDay()]},b:function(d){return Date.ext.locales[d.locale].b[d.getMonth()]},B:function(d){return Date.ext.locales[d.locale].B[d.getMonth()]},c:"toLocaleString",C:function(d){return Date.ext.util.xPad(parseInt(d.getFullYear()/100,10),0)},d:["getDate","0"],e:["getDate"," "],g:function(d){return Date.ext.util.xPad(parseInt(Date.ext.util.G(d)/100,10),0)},G:function(d){var y=d.getFullYear();var V=parseInt(Date.ext.formats.V(d),10);var W=parseInt(Date.ext.formats.W(d),10);if(W>V){y++}else{if(W===0&&V>=52){y--}}return y},H:["getHours","0"],I:function(d){var I=d.getHours()%12;return Date.ext.util.xPad(I===0?12:I,0)},j:function(d){var ms=d-new Date(""+d.getFullYear()+"/1/1 GMT");ms+=d.getTimezoneOffset()*60000;var doy=parseInt(ms/60000/60/24,10)+1;return Date.ext.util.xPad(doy,0,100)},m:function(d){return Date.ext.util.xPad(d.getMonth()+1,0)},M:["getMinutes","0"],p:function(d){return Date.ext.locales[d.locale].p[d.getHours()>=12?1:0]},P:function(d){return Date.ext.locales[d.locale].P[d.getHours()>=12?1:0]},S:["getSeconds","0"],u:function(d){var dow=d.getDay();return dow===0?7:dow},U:function(d){var doy=parseInt(Date.ext.formats.j(d),10);var rdow=6-d.getDay();var woy=parseInt((doy+rdow)/7,10);return Date.ext.util.xPad(woy,0)},V:function(d){var woy=parseInt(Date.ext.formats.W(d),10);var dow1_1=(new Date(""+d.getFullYear()+"/1/1")).getDay();var idow=woy+(dow1_1>4||dow1_1<=1?0:1);if(idow==53&&(new Date(""+d.getFullYear()+"/12/31")).getDay()<4){idow=1}else{if(idow===0){idow=Date.ext.formats.V(new Date(""+(d.getFullYear()-1)+"/12/31"))}}return Date.ext.util.xPad(idow,0)},w:"getDay",W:function(d){var doy=parseInt(Date.ext.formats.j(d),10);var rdow=7-Date.ext.formats.u(d);var woy=parseInt((doy+rdow)/7,10);return Date.ext.util.xPad(woy,0,10)},y:function(d){return Date.ext.util.xPad(d.getFullYear()%100,0)},Y:"getFullYear",z:function(d){var o=d.getTimezoneOffset();var H=Date.ext.util.xPad(parseInt(Math.abs(o/60),10),0);var M=Date.ext.util.xPad(o%60,0);return(o>0?"-":"+")+H+M},Z:function(d){return d.toString().replace(/^.*\(([^)]+)\)$/,"$1")},"%":function(d){return"%"}};Date.ext.aggregates={c:"locale",D:"%m/%d/%y",h:"%b",n:"\n",r:"%I:%M:%S %p",R:"%H:%M",t:"\t",T:"%H:%M:%S",x:"locale",X:"locale"};Date.ext.aggregates.z=Date.ext.formats.z(new Date());Date.ext.aggregates.Z=Date.ext.formats.Z(new Date());Date.ext.unsupported={};Date.prototype.strftime=function(fmt){if(!(this.locale in Date.ext.locales)){if(this.locale.replace(/-[a-zA-Z]+$/,"") in Date.ext.locales){this.locale=this.locale.replace(/-[a-zA-Z]+$/,"")}else{this.locale="en-GB"}}var d=this;while(fmt.match(/%[cDhnrRtTxXzZ]/)){fmt=fmt.replace(/%([cDhnrRtTxXzZ])/g,function(m0,m1){var f=Date.ext.aggregates[m1];return(f=="locale"?Date.ext.locales[d.locale][m1]:f)})}var str=fmt.replace(/%([aAbBCdegGHIjmMpPSuUVwWyY%])/g,function(m0,m1){var f=Date.ext.formats[m1];if(typeof (f)=="string"){return d[f]()}else{if(typeof (f)=="function"){return f.call(d,d)}else{if(typeof (f)=="object"&&typeof (f[0])=="string"){return Date.ext.util.xPad(d[f[0]](),f[1])}else{return m1}}}});d=null;return str};
|
@@ -0,0 +1,59 @@
|
|
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
|
+
<!DOCTYPE html>
|
19
|
+
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
20
|
+
<head>
|
21
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
22
|
+
<title>RelaxNGui Dataelements</title>
|
23
|
+
|
24
|
+
<!-- libs, do not modify -->
|
25
|
+
<script type="text/javascript" src="/js_libs/jquery.min.js"></script>
|
26
|
+
<script type="text/javascript" src="/js_libs/util.js"></script>
|
27
|
+
<script type="text/javascript" src="/js_libs/vkbeautify.js"></script>
|
28
|
+
|
29
|
+
<script type="text/javascript" src="relaxngui.js"></script>
|
30
|
+
<link rel="stylesheet" href="relaxngui.css" type="text/css"/>
|
31
|
+
<!-- custom stuff, play arround -->
|
32
|
+
|
33
|
+
<script type="text/javascript">
|
34
|
+
$("body").ready(function(){
|
35
|
+
$.ajax({
|
36
|
+
type: "GET",
|
37
|
+
url: "dataelements.rng",
|
38
|
+
success: function(rng){
|
39
|
+
$.ajax({
|
40
|
+
type: "GET",
|
41
|
+
url: "dataelements.xml",
|
42
|
+
success: function(data){
|
43
|
+
var rngui = new RelaxNGui(rng,$('#show'));
|
44
|
+
rngui.content(data);
|
45
|
+
$('#saveall').on('click',function(){
|
46
|
+
console.log($(rngui.save()).serializePrettyXML());
|
47
|
+
});
|
48
|
+
}
|
49
|
+
});
|
50
|
+
}
|
51
|
+
});
|
52
|
+
});
|
53
|
+
</script>
|
54
|
+
</head>
|
55
|
+
<body>
|
56
|
+
<div id="show"></div>
|
57
|
+
<button id='saveall'>save it all to console</button>
|
58
|
+
</body>
|
59
|
+
</html>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<element rngui:version="1.2" name="value" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes" xmlns="http://relaxng.org/ns/structure/1.0" xmlns:rngui="http://rngui.org">
|
2
|
+
<zeroOrMore rngui:label="Create Data Element">
|
3
|
+
<element rngui:label='Name'>
|
4
|
+
<anyName/>
|
5
|
+
<data type="string" rngui:label="Value"/>
|
6
|
+
</element>
|
7
|
+
</zeroOrMore>
|
8
|
+
</element>
|
@@ -0,0 +1,203 @@
|
|
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.closed > .relaxngui_table,
|
22
|
+
.relaxngui_table.closed > .relaxngui_dyn,
|
23
|
+
.relaxngui_table.closed > .relaxngui_row,
|
24
|
+
.relaxngui_table.closed > .relaxngui_control {
|
25
|
+
display: none;
|
26
|
+
}
|
27
|
+
.relaxngui_header.fold {
|
28
|
+
cursor: pointer;
|
29
|
+
}
|
30
|
+
.relaxngui_table.closed .relaxngui_fold:after {
|
31
|
+
content: "▶";
|
32
|
+
font-weight: bold;
|
33
|
+
vertical-align:top;
|
34
|
+
margin-right: 0.5em;
|
35
|
+
position: relative;
|
36
|
+
top: -0.13em;
|
37
|
+
}
|
38
|
+
.relaxngui_table .relaxngui_fold:after {
|
39
|
+
content: "▽";
|
40
|
+
font-weight: bold;
|
41
|
+
vertical-align:top;
|
42
|
+
margin-right: 0.5em;
|
43
|
+
position: relative;
|
44
|
+
top: -0.13em;
|
45
|
+
}
|
46
|
+
|
47
|
+
.relaxngui_table > .relaxngui_table > .relaxngui_table {
|
48
|
+
padding: 0;
|
49
|
+
padding-top: 0.2em;
|
50
|
+
padding-bottom: 0.5em;
|
51
|
+
padding-left: 1em;
|
52
|
+
}
|
53
|
+
.relaxngui_dyn {
|
54
|
+
margin: 0;
|
55
|
+
padding: 0;
|
56
|
+
display: flex;
|
57
|
+
flex-direction: row;
|
58
|
+
align-items: center;
|
59
|
+
padding-bottom: 0.25em;
|
60
|
+
padding-top: 0.25em;
|
61
|
+
margin-left: 0.5em;
|
62
|
+
}
|
63
|
+
.relaxngui_dyn > *:nth-child(1), .relaxngui_dyn > *:nth-child(2) {
|
64
|
+
margin: 0;
|
65
|
+
padding: 0;
|
66
|
+
font-size: 1em;
|
67
|
+
margin-right: 0.2em;
|
68
|
+
margin-left: 0.2em;
|
69
|
+
vertical-align: baseline;
|
70
|
+
cursor: pointer;
|
71
|
+
display: inline-block;
|
72
|
+
flex: 0 0 auto;
|
73
|
+
}
|
74
|
+
.relaxngui_dyn > *:nth-child(2) {
|
75
|
+
background-color: #000000;
|
76
|
+
color: #fff;
|
77
|
+
vertical-align: middle;
|
78
|
+
width: 1.5em;
|
79
|
+
display: flex;
|
80
|
+
align-self: stretch;
|
81
|
+
justify-content: center;
|
82
|
+
align-items: center;
|
83
|
+
user-select: none;
|
84
|
+
cursor: grab;
|
85
|
+
}
|
86
|
+
.relaxngui_dyn.moveable > *:nth-child(2) {
|
87
|
+
background-color: #ff0000;
|
88
|
+
cursor: grabbing;
|
89
|
+
}
|
90
|
+
.relaxngui_dyn.moveable {
|
91
|
+
cursor: grabbing;
|
92
|
+
}
|
93
|
+
.relaxngui_dyn > *:nth-child(3) {
|
94
|
+
flex: 1 1 auto;
|
95
|
+
}
|
96
|
+
|
97
|
+
.relaxngui_dyn > .relaxngui_table { padding: 0; margin: 0; }
|
98
|
+
.relaxngui_dyn:nth-child(even) { background-color: #fff; }
|
99
|
+
.relaxngui_dyn:nth-child(odd) { background-color: #e9e9e9; }
|
100
|
+
.relaxngui_table.even > .relaxngui_row:nth-child(even) { background-color: #fff; }
|
101
|
+
.relaxngui_table.even > .relaxngui_row:nth-child(odd) { background-color: #e9e9e9; }
|
102
|
+
.relaxngui_table.odd > .relaxngui_row:nth-child(even) { background-color: #e9e9e9; }
|
103
|
+
.relaxngui_table.odd > .relaxngui_row:nth-child(odd) { background-color: #fff; }
|
104
|
+
.relaxngui_table.even > .relaxngui_hint:nth-child(odd) { background-color: #fff; }
|
105
|
+
.relaxngui_table.even > .relaxngui_hint:nth-child(even) { background-color: #e9e9e9; }
|
106
|
+
.relaxngui_table.odd > .relaxngui_hint:nth-child(odd) { background-color: #e9e9e9; }
|
107
|
+
.relaxngui_table.odd > .relaxngui_hint:nth-child(even) { background-color: #fff; }
|
108
|
+
|
109
|
+
.relaxngui_dyn:nth-child(even) > .relaxngui_table > .relaxngui_row:nth-child(1):nth-last-child(1) {
|
110
|
+
background-color: #fff;
|
111
|
+
}
|
112
|
+
.relaxngui_dyn:nth-child(odd) > .relaxngui_table > .relaxngui_row:nth-child(1):nth-last-child(1) {
|
113
|
+
background-color: #e9e9e9;
|
114
|
+
}
|
115
|
+
|
116
|
+
.relaxngui_table.even { background-color: #e9e9e9; }
|
117
|
+
.relaxngui_table.odd { background-color: #fff; }
|
118
|
+
|
119
|
+
.relaxngui_row {
|
120
|
+
width: 100%;
|
121
|
+
display: flex;
|
122
|
+
flex-direction: row;
|
123
|
+
}
|
124
|
+
.relaxngui_hint {
|
125
|
+
padding-left: 0.2em;
|
126
|
+
}
|
127
|
+
.relaxngui_hint::before {
|
128
|
+
content: "↳ ";
|
129
|
+
}
|
130
|
+
.relaxngui_header {
|
131
|
+
margin: 0;
|
132
|
+
padding: 0;
|
133
|
+
padding-top: 0.7em;
|
134
|
+
padding-bottom: 0.2em;
|
135
|
+
padding-left: 0.1em;
|
136
|
+
display: block;
|
137
|
+
font-weight: bold;
|
138
|
+
}
|
139
|
+
.relaxngui_header[data-relaxngui-level="1"] {
|
140
|
+
font-size: 1.2em;
|
141
|
+
}
|
142
|
+
.relaxngui_dyn .relaxngui_header {
|
143
|
+
font-size: 1em;
|
144
|
+
}
|
145
|
+
button.relaxngui_control {
|
146
|
+
margin: 0.5em 0;
|
147
|
+
align-self: flex-start;
|
148
|
+
}
|
149
|
+
|
150
|
+
.relaxngui_cell { }
|
151
|
+
|
152
|
+
.relaxngui_cell.optional { text-decoration: line-through; }
|
153
|
+
|
154
|
+
.relaxngui_cell:nth-child(1), .relaxngui_cell:nth-child(2) {
|
155
|
+
margin: 0;
|
156
|
+
padding: 0.1em 0.2em;
|
157
|
+
font-size: 1em;
|
158
|
+
font-family: sans-serif;
|
159
|
+
}
|
160
|
+
input.relaxngui_cell:nth-child(1) {
|
161
|
+
border: 0 none;
|
162
|
+
background: none;
|
163
|
+
}
|
164
|
+
.relaxngui_cell:nth-child(3) {
|
165
|
+
margin: 0;
|
166
|
+
padding: 0.1em 0.2em;
|
167
|
+
flex: 1 1 auto;
|
168
|
+
font-size: 1em;
|
169
|
+
font-family: sans-serif;
|
170
|
+
}
|
171
|
+
select.relaxngui_cell:nth-child(3) {
|
172
|
+
-webkit-appearance: none; /*Removes default chrome and safari style*/
|
173
|
+
-moz-appearance: none; /* Removes Default Firefox style*/
|
174
|
+
padding: 0;
|
175
|
+
}
|
176
|
+
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) {
|
177
|
+
border: 0 none;
|
178
|
+
background: none;
|
179
|
+
}
|
180
|
+
|
181
|
+
[contenteditable].relaxngui_cell:nth-child(3) {
|
182
|
+
overflow-x: auto;
|
183
|
+
overflow-wrap: normal;
|
184
|
+
white-space: pre;
|
185
|
+
font-family: monospace,monospace;
|
186
|
+
}
|
187
|
+
[contenteditable][data-relaxngui-wrap='true'].relaxngui_cell:nth-child(3) {
|
188
|
+
white-space: pre-wrap;
|
189
|
+
}
|
190
|
+
[contenteditable].relaxngui_cell:focus {
|
191
|
+
outline: 0px solid transparent;
|
192
|
+
}
|
193
|
+
[contenteditable].relaxngui_cell:empty:before {
|
194
|
+
font-family: sans-serif;
|
195
|
+
color: #a1a1a1;
|
196
|
+
white-space: normal;
|
197
|
+
content: attr(placeholder);
|
198
|
+
display: block;
|
199
|
+
}
|
200
|
+
|
201
|
+
.relaxngui_template {
|
202
|
+
display: none;
|
203
|
+
}
|
@@ -0,0 +1,502 @@
|
|
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
|
+
$.each(tag.children,function(k,v){
|
38
|
+
if ((v.localName == 'param') && (v.namespaceURI == 'http://relaxng.org/ns/structure/1.0')) {
|
39
|
+
$.each(v.attributes,function(l,w){
|
40
|
+
if ((w.localName == 'name') && (w.nodeValue == 'minInclusive')) {
|
41
|
+
ret['min'] = v.lastChild.nodeValue;
|
42
|
+
}
|
43
|
+
if ((w.localName == 'name') && (w.nodeValue == 'maxInclusive')) {
|
44
|
+
ret['max'] = v.lastChild.nodeValue;
|
45
|
+
}
|
46
|
+
});
|
47
|
+
}
|
48
|
+
});
|
49
|
+
return ret;
|
50
|
+
}; //}}}
|
51
|
+
|
52
|
+
var addelements = function(target,container) { //{{{
|
53
|
+
var template = target.parent().find('> .relaxngui_template').clone(true,true);
|
54
|
+
template.removeClass('relaxngui_template');
|
55
|
+
template.find('[data-relaxngui-template]').each(function(j,t){
|
56
|
+
$(t).attr('data-relaxngui-template',false);
|
57
|
+
});
|
58
|
+
template.find('.relaxngui_template [data-relaxngui-template]').each(function(j,t){
|
59
|
+
$(t).attr('data-relaxngui-template',true);
|
60
|
+
});
|
61
|
+
template.addClass('relaxngui_dyn');
|
62
|
+
template.on('click', '> [data-type=del]', function(ev){ delelements($(ev.target)); });
|
63
|
+
template.find('> [data-type=mov]').moveitem(template);
|
64
|
+
|
65
|
+
if (container.find('> .relaxngui_dyn').length % 2 == 1) {
|
66
|
+
var evens = template.find('.even');
|
67
|
+
var odds = template.find('.odd');
|
68
|
+
evens.each(function(k,v){
|
69
|
+
$(v).removeClass('even');
|
70
|
+
$(v).addClass('odd');
|
71
|
+
});
|
72
|
+
odds.each(function(k,v){
|
73
|
+
$(v).removeClass('odd');
|
74
|
+
$(v).addClass('even');
|
75
|
+
});
|
76
|
+
}
|
77
|
+
|
78
|
+
container.find('> .relaxngui_control').before(template);
|
79
|
+
}; //}}}
|
80
|
+
|
81
|
+
var delelements = function(target) { //{{{
|
82
|
+
var it = target.parent();
|
83
|
+
var par = target.parent().parent();
|
84
|
+
it.remove();
|
85
|
+
par.trigger('relaxngui_remove');
|
86
|
+
}; //}}}
|
87
|
+
|
88
|
+
var recshow_header = function(tag,ret,level){ //{{{
|
89
|
+
var header;
|
90
|
+
var fold;
|
91
|
+
$.each(tag.attributes,function(k,v){
|
92
|
+
if ((v.localName == 'header') && (v.namespaceURI == 'http://rngui.org')) { header = v.nodeValue; }
|
93
|
+
if ((v.localName == 'fold') && (v.namespaceURI == 'http://rngui.org')) { fold = v.nodeValue; }
|
94
|
+
});
|
95
|
+
if (header) {
|
96
|
+
if (fold != undefined) {
|
97
|
+
var xxx = $("<div data-relaxngui-level='" + level + "' class='relaxngui_header fold'>" + header + "</div>");
|
98
|
+
xxx.prepend($("<span class='relaxngui_fold'></span>"));
|
99
|
+
ret.append(xxx);
|
100
|
+
if (fold == 'closed' || fold == 'closed_conditional') {
|
101
|
+
ret.addClass('closed');
|
102
|
+
}
|
103
|
+
if (fold == 'closed_conditional') {
|
104
|
+
ret.addClass(fold);
|
105
|
+
}
|
106
|
+
} else {
|
107
|
+
ret.append($("<div data-relaxngui-level='" + level + "' class='relaxngui_header'>" + header + "</div>"));
|
108
|
+
}
|
109
|
+
}
|
110
|
+
return fold;
|
111
|
+
} //}}}
|
112
|
+
|
113
|
+
var recshow_single = function(tag,ret,template,path,lencount,optional){ //{{{
|
114
|
+
var node = $('<div class="relaxngui_row"/>');
|
115
|
+
var name;
|
116
|
+
var label;
|
117
|
+
var labeltype;
|
118
|
+
var second = {};
|
119
|
+
var datalist = [];
|
120
|
+
var defaul = '';
|
121
|
+
var hint = '';
|
122
|
+
var retcount = 0;
|
123
|
+
$.each(tag.attributes,function(k,v){
|
124
|
+
if ((v.localName == 'label') && (v.namespaceURI == 'http://rngui.org')) { label = v.nodeValue; }
|
125
|
+
if ((v.localName == 'date') && (v.namespaceURI == 'http://rngui.org')) { label = v.nodeValue; }
|
126
|
+
if ((v.localName == 'labeltype') && (v.namespaceURI == 'http://rngui.org')) { labeltype = v.nodeValue; }
|
127
|
+
if ((v.localName == 'default') && (v.namespaceURI == 'http://rngui.org')) { defaul = v.nodeValue; }
|
128
|
+
if ((v.localName == 'hint') && (v.namespaceURI == 'http://rngui.org')) { hint = v.nodeValue; }
|
129
|
+
if (v.localName == 'name') { name = v.nodeValue.replace(/:/,'\\:'); }
|
130
|
+
});
|
131
|
+
|
132
|
+
$.each($(tag).children('data[type=string]'), function(k,v) { second = labextract('string',v); });
|
133
|
+
$.each($(tag).children('data[type=integer]'), function(k,v) { second = labextract('integer',v); });
|
134
|
+
$.each($(tag).children('data[type=nonNegativeInteger]'), function(k,v) { second = labextract('nonNegativeInteger',v); });
|
135
|
+
$.each($(tag).children('data[type=positiveInteger]'), function(k,v) { second = labextract('positiveInteger',v); });
|
136
|
+
$.each($(tag).children('data[type=float]'), function(k,v) { second = labextract('float',v); });
|
137
|
+
$.each($(tag).children('data[type=date]'), function(k,v) { second = labextract('date',v); });
|
138
|
+
$.each($(tag).children('text'), function(k,v) { second = labextract('text',v); });
|
139
|
+
$.each($(tag).children('choice[href]'), function(k,v) {
|
140
|
+
second = labextract('datalist',v);
|
141
|
+
|
142
|
+
});
|
143
|
+
$.each($(tag).find('choice > value'), function(k,v) {
|
144
|
+
second = labextract('datalist',$(v).parent()[0]);
|
145
|
+
datalist.push([v.textContent,$(v).attr('id') ? $(v).attr('id') : v.textContent]);
|
146
|
+
});
|
147
|
+
if (name && label) {
|
148
|
+
node.append($("<label class='relaxngui_cell" + (optional && defaul == '' ? " optional": "") + "' style='min-width: " + (lencount+1) + "ex' for=''>" + label + "</label><span class='relaxngui_cell'>⇒</span>"));
|
149
|
+
} else if (name) {
|
150
|
+
// a tag without information is ignored
|
151
|
+
node.addClass('relaxngui_hidden');
|
152
|
+
} else if (label) {
|
153
|
+
if (labeltype == 'xml') {
|
154
|
+
node.append($("<input data-relaxngui-template='" + template + "' data-relaxngui-parent='" + path + "' data-relaxngui-path='" + path + " > *[data-name]' class='relaxngui_cell' type='text' pattern='^[a-zA-Z_][a-zA-Z0-9_-]*$' id='' placeholder='" + label + "'></input><span class='relaxngui_cell'>⇒</span>"));
|
155
|
+
} else {
|
156
|
+
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>"));
|
157
|
+
}
|
158
|
+
}
|
159
|
+
|
160
|
+
var tpath = ((typeof name === 'undefined') ? path + ' > *' : (tag.localName == 'element' ? path + ' > ' + name : path + '[' + name + ']'));
|
161
|
+
if (label) {
|
162
|
+
if (defaul && typeof defaul == 'string' && defaul.match(/^javascript:/)) {
|
163
|
+
defaul = defaul.replace(/^javascript:/,'');
|
164
|
+
defaul = ceval ? ceval(defaul) : eval(defaul);
|
165
|
+
}
|
166
|
+
var os = (optional ? " onkeyup='var sl = $(this).siblings(\"label\"); if ($(this).get_val() == \"\") { if (!sl.hasClass(\"optional\")) { sl.addClass(\"optional\") } } else { sl.removeClass(\"optional\") }' data-optional='true'" : " data-optional='false'");
|
167
|
+
if (second.readonly)
|
168
|
+
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'" + os + "></input>"));
|
169
|
+
else {
|
170
|
+
if (second.type == 'string') {
|
171
|
+
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 + "'" + os + "></input>"));
|
172
|
+
} else if (second.type == 'integer') {
|
173
|
+
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 + "'" + (second.min != undefined ? (" min='" + second.min + "'") : '') + (second.max != undefined ? (" max='" + second.max + "'") : '') + os + "></input>"));
|
174
|
+
} else if (second.type == 'positiveInteger') {
|
175
|
+
if (second.min == undefined) second.min = 1;
|
176
|
+
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 + "'" + (second.min != undefined ? (" min='" + second.min + "'") : '') + (second.max != undefined ? (" max='" + second.max + "'") : '') + os + "></input>"));
|
177
|
+
} else if (second.type == 'nonNegativeInteger') {
|
178
|
+
if (second.min == undefined) second.min = 0;
|
179
|
+
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 + "'" + (second.min != undefined ? (" min='" + second.min + "'") : '') + (second.max != undefined ? (" max='" + second.max + "'") : '') + os + "></input>"));
|
180
|
+
} else if (second.type == 'date') {
|
181
|
+
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 + "'" + os + "></input>"));
|
182
|
+
} else if (second.type == 'float') {
|
183
|
+
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 + "'" + (second.min != undefined ? (" min='" + second.min + "'") : '') + (second.max != undefined ? (" max='" + second.max + "'") : '') + os + "></input>"));
|
184
|
+
} else if (second.type == 'text') {
|
185
|
+
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 + "'" + os + "></div>"));
|
186
|
+
} else if (second.type == 'datalist') {
|
187
|
+
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'" + os + "></select>");
|
188
|
+
$.each(datalist,function(didx,dname){
|
189
|
+
if (dname[1] == defaul)
|
190
|
+
tnode.append('<option value="' + dname[1] + '" selected="selected">' + dname[0] + '</value>');
|
191
|
+
else
|
192
|
+
tnode.append('<option value="' + dname[1] + '">' + dname[0] + '</value>');
|
193
|
+
});
|
194
|
+
node.append(tnode);
|
195
|
+
}
|
196
|
+
}
|
197
|
+
ret.append(node);
|
198
|
+
retcount += 1;
|
199
|
+
} else {
|
200
|
+
if (tag.localName != 'element') { // its an attribute, simulate its empty-ness
|
201
|
+
node.attr('data-relaxngui-template',template);
|
202
|
+
node.attr('data-relaxngui-parent',path);
|
203
|
+
node.attr('data-relaxngui-path',tpath);
|
204
|
+
ret.append(node);
|
205
|
+
retcount += 1;
|
206
|
+
}
|
207
|
+
}
|
208
|
+
if (hint) {
|
209
|
+
var n = $('<div class="relaxngui_hint"/>');
|
210
|
+
var s1 = $('<em>Hint: </em>');
|
211
|
+
var s2 = $('<span/>');
|
212
|
+
s2.text(hint);
|
213
|
+
|
214
|
+
n.append(s1);
|
215
|
+
n.append(s2);
|
216
|
+
ret.append(n);
|
217
|
+
retcount += 1;
|
218
|
+
}
|
219
|
+
return retcount;
|
220
|
+
} //}}}
|
221
|
+
|
222
|
+
var recshow = function(elements,template,path,attr) { //{{{
|
223
|
+
// delete all elements with relaxngui:ignore
|
224
|
+
if (attr.ignore) {
|
225
|
+
var tele = $.grep(elements,function(tagv){
|
226
|
+
var include = true;
|
227
|
+
$.each(tagv.attributes,function(k,v){
|
228
|
+
if ((v.localName == 'ignore') && (v.namespaceURI == 'http://rngui.org')) {
|
229
|
+
include = false;
|
230
|
+
}
|
231
|
+
});
|
232
|
+
return include;
|
233
|
+
});
|
234
|
+
elements = $(tele);
|
235
|
+
}
|
236
|
+
|
237
|
+
var ret = $('<div/>');
|
238
|
+
|
239
|
+
var lencount = 0;
|
240
|
+
$.each(elements,function(k,v){
|
241
|
+
var tag = $(v)[0];
|
242
|
+
if ((tag.localName == 'element') && (tag.namespaceURI == 'http://relaxng.org/ns/structure/1.0')) {
|
243
|
+
$(tag).children('attribute').each(function(l,w){
|
244
|
+
lencount = lenextract($(w)[0],lencount);
|
245
|
+
});
|
246
|
+
lencount = lenextract(tag,lencount);
|
247
|
+
}
|
248
|
+
});
|
249
|
+
$.each(elements,function(k,v){
|
250
|
+
if (attr.mode == 'even') { attr.mode = 'odd' }
|
251
|
+
else { attr.mode = 'even'; }
|
252
|
+
|
253
|
+
var tag = $(v)[0];
|
254
|
+
if ((tag.localName == 'element') && (tag.namespaceURI == 'http://relaxng.org/ns/structure/1.0')) {
|
255
|
+
var xxx;
|
256
|
+
if (template) {
|
257
|
+
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]">');
|
258
|
+
xxx = $('<div class="relaxngui_template"><div data-type="del">✖</div><div data-type="mov"><div>↕</div></div></div>');
|
259
|
+
xxx.append(yyy);
|
260
|
+
ret.append(xxx);
|
261
|
+
xxx = yyy;
|
262
|
+
} else {
|
263
|
+
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]">');
|
264
|
+
ret.append(xxx);
|
265
|
+
}
|
266
|
+
|
267
|
+
recshow_header(tag,xxx,attr.level);
|
268
|
+
var rcount = 0;
|
269
|
+
$(tag).children('attribute').each(function(l,w){
|
270
|
+
var ttag = $(w)[0];
|
271
|
+
rcount += recshow_single(ttag,xxx,template,path + ' > ' + $(tag).attr('name'),lencount,attr.optional ? true : false);
|
272
|
+
});
|
273
|
+
rcount += recshow_single(tag,xxx,template,path,lencount,attr.optional ? true : false);
|
274
|
+
|
275
|
+
var sub;
|
276
|
+
if (sub = recshow($(tag).children('element, zeroOrMore, optional'),false,path + ' > ' + $(tag).attr('name'),{ ignore: attr.ignore, mode: (attr.mode == 'even' && rcount % 2 == 0 ? 'odd' : 'even' ), level: attr.level + 1 })) {
|
277
|
+
var inode = xxx.append(sub);
|
278
|
+
if (template) {
|
279
|
+
inode.find('[data-relaxngui-template]').each(function(j,t){
|
280
|
+
$(t).attr('data-relaxngui-template',true);
|
281
|
+
});
|
282
|
+
}
|
283
|
+
}
|
284
|
+
} else if ((tag.localName == 'zeroOrMore') && (tag.namespaceURI == 'http://relaxng.org/ns/structure/1.0')) {
|
285
|
+
var label;
|
286
|
+
$.each(tag.attributes,function(k,v){
|
287
|
+
if ((v.localName == 'label') && (v.namespaceURI == 'http://rngui.org')) { label = v.nodeValue; }
|
288
|
+
});
|
289
|
+
var but = $('<button class="relaxngui_control">' + label + '</button>');
|
290
|
+
but.on('click',function(ev){ addelements($(ev.target),$(ev.target).parent()); });
|
291
|
+
|
292
|
+
ret.append(recshow($(tag).children(),true,path,{ ignore: attr.ignore, mode: attr.mode, level: attr.level }));
|
293
|
+
ret.append(but);
|
294
|
+
} else if ((tag.localName == 'optional') && (tag.namespaceURI == 'http://relaxng.org/ns/structure/1.0')) {
|
295
|
+
ret.append(recshow($(tag).children('element, zeroOrMore'),false,path,{ ignore: attr.ignore, mode: (attr.mode == 'even' ? 'odd' : 'even'), optional: true, level: attr.level + 1 }));
|
296
|
+
}
|
297
|
+
});
|
298
|
+
return ret.children().length > 0 ? ret.children() : undefined;
|
299
|
+
}; //}}}
|
300
|
+
|
301
|
+
var serializeXML = function (xml) { //{{{
|
302
|
+
var out = '';
|
303
|
+
if (typeof XMLSerializer == 'function') {
|
304
|
+
var xs = new XMLSerializer();
|
305
|
+
$(xml).each(function() {
|
306
|
+
out += xs.serializeToString(this);
|
307
|
+
});
|
308
|
+
} else if (xml && xml.xml != 'undefined') {
|
309
|
+
$(xml).each(function() {
|
310
|
+
out += this.xml;
|
311
|
+
});
|
312
|
+
}
|
313
|
+
return out;
|
314
|
+
}; //}}}
|
315
|
+
this.save = function() { //{{{
|
316
|
+
var xml;
|
317
|
+
var curr;
|
318
|
+
var tar = target.find('[data-relaxngui-path]:not([data-relaxngui-template=true])');
|
319
|
+
for (var i = 0; i<tar.length;) {
|
320
|
+
var path = $(tar[i]).attr('data-relaxngui-path');
|
321
|
+
var parent_path = $(tar[i]).attr('data-relaxngui-parent');
|
322
|
+
if (i == 0) {
|
323
|
+
var par = path.replace(/\[data-main\]/,'').replace(/ > /,'');
|
324
|
+
xml = $XR('<' + par + '/>');
|
325
|
+
} else {
|
326
|
+
var ma = path.match(/([^\s]+)$/)[1];
|
327
|
+
var att;
|
328
|
+
if (ma.match(/\*\[data-main\]/)) {
|
329
|
+
// do nothing. seriously. explicitly.
|
330
|
+
} else if (ma.match(/\[data-main\]/)) {
|
331
|
+
var par = ma.replace(/\[data-main\]/,'');
|
332
|
+
var curr = $($XR('<' + par + '/>').documentElement);
|
333
|
+
$(parent_path,xml).last().append(curr);
|
334
|
+
} else if (ma.match(/\[data-name\]/)) {
|
335
|
+
if ($(tar[i]).get_val()) {
|
336
|
+
var nn = $($XR('<' + $(tar[i]).get_val() + '/>').documentElement).text($(tar[i+1]).get_val());
|
337
|
+
$(parent_path,xml).append(nn);
|
338
|
+
}
|
339
|
+
i+=1;
|
340
|
+
} else if (att = ma.match(/\[([^\]]+)\]$/)) {
|
341
|
+
att[1] = att[1].replace(/\\/,'');
|
342
|
+
$(parent_path + ':last-child',xml).last().attr(att[1],$(tar[i]).get_val());
|
343
|
+
} else {
|
344
|
+
if ($(tar[i]).attr('data-optional') == 'true' && $(tar[i]).get_val() == '') {
|
345
|
+
$(path + ':last-child',xml).last().remove();
|
346
|
+
} else {
|
347
|
+
$(path + ':last-child',xml).last().text($(tar[i]).get_val())
|
348
|
+
}
|
349
|
+
}
|
350
|
+
}
|
351
|
+
i+=1;
|
352
|
+
}
|
353
|
+
return xml;
|
354
|
+
}; //}}}
|
355
|
+
this.save_text = function() { //{{{
|
356
|
+
return serializeXML(self.save());
|
357
|
+
} //}}}
|
358
|
+
|
359
|
+
this.content = function(data) { //{{{
|
360
|
+
if (!(data instanceof XMLDocument)) { // data has to be XMLDocument //{{{
|
361
|
+
data = $XR($(data).serializeXML());
|
362
|
+
} //}}}
|
363
|
+
|
364
|
+
if (data) {
|
365
|
+
var x = $(data).serializePrettyXML();
|
366
|
+
x = x.replace(/\s+xmlns(:[a-zA-Z0-9]+)?=\"[^\"]+\"/g, "");
|
367
|
+
x = x.replace(/<\?[^>]+>/g, "");
|
368
|
+
x = x.trim();
|
369
|
+
y = $(self.save()).serializePrettyXML();
|
370
|
+
if (x != y) {
|
371
|
+
target.find('.relaxngui_dyn').remove();
|
372
|
+
target.find('[data-relaxngui-path]').each(function(k,pa){
|
373
|
+
var path = $(pa).attr('data-relaxngui-path');
|
374
|
+
if (!path.match(/data-\w+\]$/)) {
|
375
|
+
if ($(pa).attr('data-relaxngui-template') == 'true' && path.match(/\*$/)) {
|
376
|
+
$(data).find(path).each(function(index,ele){
|
377
|
+
$(target.find('[data-relaxngui-path="' + path + '[data-name]"][data-relaxngui-template="false"]').get(index)).set_val(ele.localName);
|
378
|
+
$(target.find('[data-relaxngui-path="' + path + '"][data-relaxngui-template="false"]').get(index)).set_val($(ele).text());
|
379
|
+
});
|
380
|
+
} else if ($(pa).attr('data-relaxngui-template') == 'true' && !path.match(/\*$/)) {
|
381
|
+
$(data).find(path).each(function(index,ele){
|
382
|
+
var att;
|
383
|
+
var val;
|
384
|
+
if (att = path.match(/(.*)\[([^\]]+)\]$/)) {
|
385
|
+
val = $(ele).attr(att[2]);
|
386
|
+
} else {
|
387
|
+
val = $(ele).text();
|
388
|
+
}
|
389
|
+
if (val && val != '') {
|
390
|
+
$(target.find('[data-relaxngui-path="' + path + '"][data-relaxngui-template="false"]').get(index)).set_val(val);
|
391
|
+
}
|
392
|
+
});
|
393
|
+
} else {
|
394
|
+
var att;
|
395
|
+
var val;
|
396
|
+
if (att = path.match(/(.*)\[([^\]]+)\]$/)) {
|
397
|
+
val = $(data).find(att[1]).attr(att[2]);
|
398
|
+
} else {
|
399
|
+
val = $(data).find(path).text();
|
400
|
+
}
|
401
|
+
if (val && val != '') {
|
402
|
+
var t = target.find('[data-relaxngui-path="' + path + '"]');
|
403
|
+
t.set_val(val);
|
404
|
+
if (t.attr('data-optional') == 'true') {
|
405
|
+
t.siblings('label').removeClass('optional');
|
406
|
+
}
|
407
|
+
}
|
408
|
+
}
|
409
|
+
} else {
|
410
|
+
if ($(pa).attr('data-relaxngui-template') == 'true') {
|
411
|
+
var but = target.find('.relaxngui_table[data-relaxngui-template="false"] > .relaxngui_template > [data-relaxngui-path="' + path + '"][data-relaxngui-template="true"]').parent().parent().find('> button');
|
412
|
+
if (but.length > 0) {
|
413
|
+
var dpath = path.replace(/\[data-main\]$/,'');
|
414
|
+
var par = undefined;
|
415
|
+
var ind = -1;
|
416
|
+
$(data).find(dpath).each(function(ke,ele){
|
417
|
+
if (par != $(ele).parent()[0]) {
|
418
|
+
ind += 1;
|
419
|
+
par = $(ele).parent()[0];
|
420
|
+
}
|
421
|
+
if ($(but.get(ind)).attr('disabled')) {
|
422
|
+
$(but.get(ind)).removeAttr('disabled');
|
423
|
+
but.get(ind).click();
|
424
|
+
$(but.get(ind)).attr('disabled','disabled');
|
425
|
+
} else {
|
426
|
+
but.get(ind).click();
|
427
|
+
}
|
428
|
+
});
|
429
|
+
}
|
430
|
+
}
|
431
|
+
}
|
432
|
+
});
|
433
|
+
self.set_checkpoint();
|
434
|
+
}
|
435
|
+
target.find('.relaxngui_table.closed_conditional').each(function(k,e) {
|
436
|
+
$(e).find('input:not([readonly]), [contenteditable]:not([readonly])').each(function(l,f) {
|
437
|
+
if ($(f).get_val() != '') {
|
438
|
+
$(e).removeClass('closed');
|
439
|
+
}
|
440
|
+
});
|
441
|
+
});
|
442
|
+
}
|
443
|
+
}; //}}}
|
444
|
+
|
445
|
+
(function($) { //{{{
|
446
|
+
$.fn.moveitem = function(item) {
|
447
|
+
var drag = $(this);
|
448
|
+
var item = item;
|
449
|
+
var pos;
|
450
|
+
|
451
|
+
this.on("mousedown", function(e) {
|
452
|
+
item.addClass('moveable');
|
453
|
+
pos = e.originalEvent.clientY;
|
454
|
+
$(document).one("mouseup", function(e) {
|
455
|
+
item.removeClass('moveable');
|
456
|
+
e.preventDefault();
|
457
|
+
});
|
458
|
+
e.preventDefault();
|
459
|
+
});
|
460
|
+
|
461
|
+
$(document).on("mousemove", function(e) {
|
462
|
+
if (!item.hasClass('moveable'))
|
463
|
+
return;
|
464
|
+
|
465
|
+
var prev = item.prev('.relaxngui_dyn');
|
466
|
+
var next = item.next('.relaxngui_dyn');
|
467
|
+
|
468
|
+
if (prev.length > 0 && e.originalEvent.clientY < prev.position().top + prev.outerHeight()) {
|
469
|
+
$(prev).before($(item));
|
470
|
+
pos = e.originalEvent.clientY;
|
471
|
+
} else if (next.length > 0 && e.originalEvent.clientY > next.position().top) {
|
472
|
+
$(next).after($(item));
|
473
|
+
pos = e.originalEvent.clientY;
|
474
|
+
}
|
475
|
+
|
476
|
+
e.preventDefault();
|
477
|
+
});
|
478
|
+
}
|
479
|
+
})(jQuery); //}}}
|
480
|
+
|
481
|
+
// stuff to determine if user changed something
|
482
|
+
var orig = '';
|
483
|
+
this.set_checkpoint = function() { //{{{
|
484
|
+
orig = self.save_text();
|
485
|
+
} //}}}
|
486
|
+
this.has_changed = function() { //{{{
|
487
|
+
if (orig != self.save_text()) {
|
488
|
+
return true;
|
489
|
+
} else {
|
490
|
+
return false;
|
491
|
+
}
|
492
|
+
} //}}}
|
493
|
+
|
494
|
+
target.append(recshow($(rng.documentElement),false,'',{ ignore: ignore, mode: 'even', level: 0}));
|
495
|
+
|
496
|
+
var self = this;
|
497
|
+
|
498
|
+
target.unbind('click.relaxngui');
|
499
|
+
target.on('click.relaxngui','.relaxngui_header.fold',function(){
|
500
|
+
$(this).parent().toggleClass('closed');
|
501
|
+
});
|
502
|
+
};
|