index.html 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  5. <script src="jquery-2.1.4.min.js"></script>
  6. <script src="bootstrap.min.js"></script>
  7. <!-- Blockly core imports -->
  8. <script src="blockly_compressed.js"></script>
  9. <script src="blocks_compressed.js"></script>
  10. <script src="en.js"></script>
  11. <!-- R2RML Blockly -->
  12. <script src="r2rml.js"></script>
  13. <script src="r2rml_generator.js"></script>
  14. <link rel="stylesheet" type="text/css" href="bootstrap-theme.min.css">
  15. <link rel="stylesheet" type="text/css" href="bootstrap.min.css">
  16. <style type="text/css">
  17. .hideInput {
  18. display: none;
  19. }
  20. .wow {font-style: italic;}
  21. body .blocklyIconShape {
  22. fill: #f00 ;
  23. }
  24. </style>
  25. </head>
  26. <body>
  27. <ul class="nav nav-tabs" role="tablist">
  28. <li role="presentation" class="active"><a href="#tab1" aria-controls="tab1" role="tab" data-toggle="tab">Mapping</a></li>
  29. <li role="presentation"><a href="#tab2" aria-controls="tab2" role="tab" data-toggle="tab">R2RML-Mapping</a></li>
  30. </ul>
  31. <div class="tab-content">
  32. <div role="tabpanel" class="tab-pane active" id="tab1">
  33. <div class="row">
  34. <br />
  35. <div class="col-md-9">
  36. <div class="panel panel-info">
  37. <div id="blocklyDiv" style="height: calc(100vh - 290px);"></div>
  38. </div>
  39. </div>
  40. <div id="edit" class="col-md-3" style="display:none;">
  41. <div class="panel panel-info">
  42. <div class="panel-heading">Table name or SQL query</div>
  43. <div class="panel panel-info">
  44. <textarea id="content" class="form-control" rows="3"></textarea>
  45. </div>
  46. <button id="saveLogicalTable" class="btn btn-default">OK</button>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. <div role="tabpanel" class="tab-pane" id="tab2">
  52. <div class="row">
  53. <br />
  54. <div class="col-md-12">
  55. <div class="panel panel-info">
  56. <textarea id="code" class="form-control" rows="20" readonly="readonly"></textarea>
  57. </div>
  58. </div>
  59. </div>
  60. </div>
  61. </div>
  62. <xml id="toolbox" style="display: none">
  63. <category name="Templates" colour="360">
  64. <block type="triplemap">
  65. <value name="logicaltable">
  66. <block type="tablesqlquery"></block>
  67. </value>
  68. <statement name="subjectmap">
  69. <block type="subjectmap">
  70. <field name="TERMMAP">TEMPLATE</field>
  71. </block>
  72. </statement>
  73. <statement name="predicateobjectmap">
  74. <block type="predicateobjectmap">
  75. <statement name="ppredicateobjectmap">
  76. <block type="predicatemap"></block>
  77. </statement>
  78. <statement name="opredicateobjectmap">
  79. <block type="objectmap">
  80. <field name="TERMMAP">COLUMN</field>
  81. </block>
  82. </statement>
  83. </block>
  84. </statement>
  85. </block>
  86. <block type="predicateobjectmap">
  87. <statement name="ppredicateobjectmap">
  88. <block type="predicatemap"></block>
  89. </statement>
  90. <statement name="opredicateobjectmap">
  91. <block type="objectmap">
  92. <field name="TERMMAP">COLUMN</field>
  93. </block>
  94. </statement>
  95. </block>
  96. </category>
  97. <category name="Prefixes" colour="62">
  98. <block type="predefinedprefix"></block>
  99. <block type="prefix"></block>
  100. <block type="base"></block>
  101. </category>
  102. <category name="Triple Map" colour="200">
  103. <block type="triplemap"></block>
  104. <category name="Logical Table" colour="85">
  105. <block type="tablesqlquery"></block>
  106. </category>
  107. <category name="Subject" colour="122">
  108. <block type="subjectmap">
  109. <field name="TERMMAP">TEMPLATE</field>
  110. </block>
  111. <block type="class"></block>
  112. <block type="subjecttermtype"></block>
  113. <block type="subjectgraphtermap"></block>
  114. </category>
  115. <category name="Predicate Object" colour="62">
  116. <block type="predicateobjectmap"></block>
  117. <category name="Predicate" colour="215">
  118. <block type="predicatemap"></block>
  119. </category>
  120. <block type="predicatetermtype"></block>
  121. <category name="Object" colour="170">
  122. <block type="objectmap">
  123. <field name="TERMMAP">COLUMN</field>
  124. </block>
  125. <block type="objecttermtype">
  126. <field name="TERMTYPE">termtypeliteral</field>
  127. </block>
  128. <block type="objectdatatype"></block>
  129. <block type="objectlanguage"></block>
  130. <block type="parenttriplesmap"></block>
  131. <block type="joincondition"></block>
  132. </category>
  133. <category name="Graph" colour="320">
  134. <block type="predicategraphtermap"></block>
  135. </category>
  136. </category>
  137. </category>
  138. </xml>
  139. <xml id="startBlocks" style="display:none">
  140. <block type="mapping" x="9" y="3">
  141. </block>
  142. </xml>
  143. <!-- <xml id="startBlocks" style="display:none">
  144. <block type="mapping" x="9" y="3">
  145. <statement name="mapping">
  146. <block type="prefix"></block>
  147. </statement>
  148. <statement name="triplesmap">
  149. <block type="triplemap">
  150. <statement name="logicaltable">
  151. <block type="tablesqlquery"></block>
  152. </statement>
  153. <statement name="subjectmap">
  154. <block type="subjectmap">
  155. <field name="TERMMAP">TEMPLATE</field>
  156. </block>
  157. </statement>
  158. <statement name="predicateobjectmap">
  159. <block type="predicateobjectmap">
  160. <statement name="ppredicateobjectmap">
  161. <block type="predicatemap"></block>
  162. </statement>
  163. <statement name="opredicateobjectmap">
  164. <block type="objectmap">
  165. <field name="TERMMAP">COLUMN</field>
  166. </block>
  167. </statement>
  168. </block>
  169. </statement>
  170. </block>
  171. </statement>
  172. </block>
  173. </xml> -->
  174. <script>
  175. var workspace = Blockly.inject('blocklyDiv',
  176. {toolbox: document.getElementById('toolbox'),
  177. zoom:
  178. {controls: true,
  179. wheel: true,
  180. startScale: 0.8,
  181. maxScale: 3,
  182. minScale: 0.3,
  183. scaleSpeed: 1.1},
  184. trashcan: true});
  185. Blockly.Xml.domToWorkspace(document.getElementById('startBlocks'), Blockly.mainWorkspace);
  186. function generateCode(event) {
  187. var code = R2RML.workspaceToCode(workspace);
  188. document.getElementById('code').value = code;
  189. }
  190. workspace.addChangeListener(generateCode);
  191. $('.nav-tabs a').on('click', function(event){
  192. var x = $(event.target).text(); // active tab
  193. if(x != 'Mapping') {
  194. $('.blocklyToolboxDiv').hide();
  195. } else {
  196. $('.blocklyToolboxDiv').show();
  197. }
  198. });
  199. </script>
  200. </body>
  201. </html>