myEvents.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. $( document ).ready(function() {
  2. console.log( "ready!" );
  3. $.ajax({
  4. url: 'http://localhost:3001/require/all',
  5. error: function() {
  6. console.log("Error");
  7. },
  8. dataType: 'text',
  9. success: function(data) {
  10. console.log("success");
  11. },
  12. type: 'GET'
  13. });
  14. });
  15. $('#jstree_demo_div').on("open_node.jstree", function (e, data) {
  16. console.log(data.node);
  17. });
  18. $('#jstree_demo_div').on("select_node.jstree", function (e, data) {
  19. console.log(data);
  20. var x = data.node.data.idx;
  21. var nid = data.node.id;
  22. var nc = data.node.data.nodeclass;
  23. if(nc == "Object"){
  24. var ul = 'http://127.0.0.1:3001/look/'+x+'/'+nid+'/'+nc+'/';
  25. $.ajax({
  26. url: ul+'name',
  27. type: 'GET', // http method
  28. success: function (resp, status, xhr) {
  29. $('#instancename').val(resp.result);
  30. },
  31. error: function (jqXhr, textStatus, errorMessage) {
  32. console.log('Error: ' + errorMessage);
  33. }
  34. });
  35. //$('#instancename').val(data.node.text);
  36. $.ajax({
  37. url: ul+'nsurl',
  38. type: 'GET', // http method
  39. success: function (resp, status, xhr) {
  40. $('#instancenamespace').val(resp.result);
  41. },
  42. error: function (jqXhr, textStatus, errorMessage) {
  43. console.log('Error: ' + errorMessage);
  44. }
  45. });
  46. $('#instancenodeclass').val(nc);
  47. //$('#instancetypedefinition').val(data.node.data.);
  48. $('#instancenodeidtype').val();
  49. $.ajax({
  50. url: ul+'nodeidtype',
  51. type: 'GET', // http method
  52. success: function (resp, status, xhr) {
  53. $('#instancenodeidtype').val(resp.result);
  54. },
  55. error: function (jqXhr, textStatus, errorMessage) {
  56. console.log('Error: ' + errorMessage);
  57. }
  58. });
  59. $('#instancenodeid').val(nid);
  60. $.ajax({
  61. url: ul+'eventnotifier',
  62. type: 'GET', // http method
  63. success: function (resp, status, xhr) {
  64. var plc = "";
  65. switch(resp.result){
  66. case 0: plc = "0 (None)"; break;
  67. case 1: plc = "1 (EventNotifierSubscribeToEvents)"; break;
  68. case 4: plc = "4 (EventNotifierHistoryRead)"; break;
  69. case 5: plc = "5 (EventNotifierSubscribeToEvents|EventNotifierHistoryRead)"; break;
  70. case 8: plc = "8 (EventNotifierHistoryWrite)"; break;
  71. case 9: plc = "9 (EventNotifierSubscribeToEvents|EventNotifierHistoryWrite)"; break;
  72. case 12: plc = "12 (EventNotifierHistoryRead|EventNotifierHistoryWrite)"; break;
  73. default: plc = "";
  74. }
  75. $('#instanceeventnotifier').attr('placeholder',plc);
  76. },
  77. error: function (jqXhr, textStatus, errorMessage) {
  78. console.log('Error: ' + errorMessage);
  79. }
  80. });
  81. $('#instancedisplayname1').val("");
  82. $.ajax({
  83. url: ul+'displayname',
  84. type: 'GET', // http method
  85. success: function (resp, status, xhr) {
  86. $('#instancedisplayname2').val(resp.result);
  87. },
  88. error: function (jqXhr, textStatus, errorMessage) {
  89. console.log('Error: ' + errorMessage);
  90. }
  91. });
  92. //$('#instancedisplayname2').val(data.node.text);
  93. $.ajax({
  94. url: ul+'displayname',
  95. type: 'GET', // http method
  96. success: function (resp, status, xhr) {
  97. $('#instancebrowsename2').val(resp.result);
  98. },
  99. error: function (jqXhr, textStatus, errorMessage) {
  100. console.log('Error: ' + errorMessage);
  101. }
  102. });
  103. console.log("obj enabled");
  104. $('#objectattributesbutton').prop('disabled', false);
  105. $('#collapseTwo1').collapse('hide');
  106. $('#variableattributesbutton').prop('disabled',true);
  107. $('#collapseTwo2').collapse('hide');
  108. $('#methodattributesbutton').prop('disabled',true);
  109. }
  110. if(data.node.data.nodeclass == "Variable"){
  111. /*$.ajax({
  112. url: 'http://127.0.0.1:3001',
  113. type: 'POST', // http method
  114. data: { key_id: name }, // data to submit
  115. success: function (data, status, xhr) {
  116. $('p').append('status: ' + status + ', data: ' + data);
  117. },
  118. error: function (jqXhr, textStatus, errorMessage) {
  119. $('p').append('Error: ' + errorMessage);
  120. }
  121. });*/
  122. $('#variableattributesbutton').prop('disabled', false);
  123. $('#collapseTwo').collapse('hide');
  124. $('#objectattributesbutton').prop('disabled',true);
  125. $('#collapseTwo2').collapse('hide');
  126. $('#methodattributesbutton').prop('disabled',true);
  127. }
  128. if(data.node.data.nodeclass == "Method"){
  129. /*$.ajax({
  130. url: 'http://127.0.0.1:3001',
  131. type: 'POST', // http method
  132. data: { key_id: name }, // data to submit
  133. success: function (data, status, xhr) {
  134. $('p').append('status: ' + status + ', data: ' + data);
  135. },
  136. error: function (jqXhr, textStatus, errorMessage) {
  137. $('p').append('Error: ' + errorMessage);
  138. }
  139. });*/
  140. $('#methodattributesbutton').prop('disabled',false);
  141. $('#collapseTwo').collapse('hide');
  142. $('#objectattributesbutton').prop('disabled',true);
  143. $('#collapseTwo1').collapse('hide');
  144. $('#variableattributesbutton').prop('disabled',true);
  145. }
  146. /*$.ajax({
  147. url: 'http://127.0.0.1:3001',
  148. type: 'POST', // http method
  149. data: { key_id: name }, // data to submit
  150. success: function (data, status, xhr) {
  151. $('p').append('status: ' + status + ', data: ' + data);
  152. },
  153. error: function (jqXhr, textStatus, errorMessage) {
  154. $('p').append('Error: ' + errorMessage);
  155. }
  156. });*/
  157. });
  158. $('#nodesetfile').on("open", function (e, data) {
  159. console.log('hello');
  160. });
  161. $('#changeinstance').click(function () {
  162. console.log('hello');
  163. });
  164. $('#savenodespecification').click(function () {
  165. console.log('save this');
  166. console.log($('#instancename').val());
  167. console.log($('#instancenamespace').val());
  168. console.log($('#instancenodeclass').val());
  169. console.log($('#instancetypedefinition').val());
  170. console.log($('#instancenodeidtype').val());
  171. console.log($('#instancenodeid').val());
  172. console.log($('#instanceeventnotifier').attr('placeholder'));
  173. console.log($('#instancedisplayname1').val());
  174. console.log($('#instancedisplayname2').val());
  175. console.log($('#instancebrowsename1').val());
  176. });
  177. $('#numericnodeid').click(function () {
  178. console.log("It is number");
  179. $('#instancenodeidtype').text('Numeric')
  180. });
  181. $('#stringnodeid').click(function () {
  182. console.log("It is string");
  183. $('#instancenodeidtype').text('String')
  184. });
  185. $('#guidnodeid').click(function () {
  186. console.log("It is guid");
  187. $('#instancenodeidtype').text('Guid')
  188. });
  189. $('#opaquenodeid').click(function () {
  190. console.log("It is opaque");
  191. $('#instancenodeidtype').text('Opaque')
  192. });
  193. $('#instancebrowsename1').click(function () {
  194. console.log("Add the script");
  195. var sz = parseInt($('#namespaceidxbrowsename').attr("size"));
  196. console.log(sz);
  197. var num_ns = "6";
  198. var nnum = parseInt(num_ns);
  199. if(sz < nnum){
  200. var lin = "<li><a class='dropdown-item' href='#'>"+num_ns+"</a></li>"
  201. $('#namespaceidxbrowsename').append(lin);
  202. $('#namespaceidxbrowsename').attr("size",num_ns);
  203. }
  204. });
  205. $('#subscribeevents').click(function () {
  206. if($('#subscribeevents').prop('checked')==true && $('#historyread').prop('checked')==true && $('#historywrite').prop('checked')==true ){
  207. $('#instanceeventnotifier').attr('placeholder', '13 (EventNotifierSubscribeToEvents|EventNotifierHistoryRead|EventNotifierHistoryWrite)');
  208. }
  209. if($('#subscribeevents').prop('checked')==true && $('#historyread').prop('checked')==false && $('#historywrite').prop('checked')==false ){
  210. $('#instanceeventnotifier').attr('placeholder', '1 (EventNotifierSubscribeToEvents)');
  211. }
  212. if($('#subscribeevents').prop('checked')==false && $('#historyread').prop('checked')==true && $('#historywrite').prop('checked')==false ){
  213. $('#instanceeventnotifier').attr('placeholder', '4 (EventNotifierHistoryRead)');
  214. }
  215. if($('#subscribeevents').prop('checked')==false && $('#historyread').prop('checked')==false && $('#historywrite').prop('checked')==true ){
  216. $('#instanceeventnotifier').attr('placeholder', '8 (EventNotifierHistoryWrite)');
  217. }
  218. if($('#subscribeevents').prop('checked')==false && $('#historyread').prop('checked')==false && $('#historywrite').prop('checked')==false ){
  219. $('#instanceeventnotifier').attr('placeholder', '0 (None)');
  220. }
  221. if($('#subscribeevents').prop('checked')==true && $('#historyread').prop('checked')==true && $('#historywrite').prop('checked')==false ){
  222. $('#instanceeventnotifier').attr('placeholder', '5 (EventNotifierSubscribeToEvents|EventNotifierHistoryRead)');
  223. }
  224. if($('#subscribeevents').prop('checked')==false && $('#historyread').prop('checked')==true && $('#historywrite').prop('checked')==true ){
  225. $('#instanceeventnotifier').attr('placeholder', '12 (EventNotifierHistoryRead|EventNotifierHistoryWrite)');
  226. }
  227. if($('#subscribeevents').prop('checked')==true && $('#historyread').prop('checked')==false && $('#historywrite').prop('checked')==true ){
  228. $('#instanceeventnotifier').attr('placeholder', '9 (EventNotifierSubscribeToEvents|EventNotifierHistoryWrite)');
  229. }
  230. });
  231. $('#historyread').click(function () {
  232. if($('#subscribeevents').prop('checked')==true && $('#historyread').prop('checked')==true && $('#historywrite').prop('checked')==true ){
  233. $('#instanceeventnotifier').attr('placeholder', '13 (EventNotifierSubscribeToEvents|EventNotifierHistoryRead|EventNotifierHistoryWrite)');
  234. }
  235. if($('#subscribeevents').prop('checked')==true && $('#historyread').prop('checked')==false && $('#historywrite').prop('checked')==false ){
  236. $('#instanceeventnotifier').attr('placeholder', '1 (EventNotifierSubscribeToEvents)');
  237. }
  238. if($('#subscribeevents').prop('checked')==false && $('#historyread').prop('checked')==true && $('#historywrite').prop('checked')==false ){
  239. $('#instanceeventnotifier').attr('placeholder', '4 (EventNotifierHistoryRead)');
  240. }
  241. if($('#subscribeevents').prop('checked')==false && $('#historyread').prop('checked')==false && $('#historywrite').prop('checked')==true ){
  242. $('#instanceeventnotifier').attr('placeholder', '8 (EventNotifierHistoryWrite)');
  243. }
  244. if($('#subscribeevents').prop('checked')==false && $('#historyread').prop('checked')==false && $('#historywrite').prop('checked')==false ){
  245. $('#instanceeventnotifier').attr('placeholder', '0 (None)');
  246. }
  247. if($('#subscribeevents').prop('checked')==true && $('#historyread').prop('checked')==true && $('#historywrite').prop('checked')==false ){
  248. $('#instanceeventnotifier').attr('placeholder', '5 (EventNotifierSubscribeToEvents|EventNotifierHistoryRead)');
  249. }
  250. if($('#subscribeevents').prop('checked')==false && $('#historyread').prop('checked')==true && $('#historywrite').prop('checked')==true ){
  251. $('#instanceeventnotifier').attr('placeholder', '12 (EventNotifierHistoryRead|EventNotifierHistoryWrite)');
  252. }
  253. if($('#subscribeevents').prop('checked')==true && $('#historyread').prop('checked')==false && $('#historywrite').prop('checked')==true ){
  254. $('#instanceeventnotifier').attr('placeholder', '9 (EventNotifierSubscribeToEvents|EventNotifierHistoryWrite)');
  255. }
  256. });
  257. $('#historywrite').click(function () {
  258. if($('#subscribeevents').prop('checked')==true && $('#historyread').prop('checked')==true && $('#historywrite').prop('checked')==true ){
  259. $('#instanceeventnotifier').attr('placeholder', '13 (EventNotifierSubscribeToEvents|EventNotifierHistoryRead|EventNotifierHistoryWrite)');
  260. }
  261. if($('#subscribeevents').prop('checked')==true && $('#historyread').prop('checked')==false && $('#historywrite').prop('checked')==false ){
  262. $('#instanceeventnotifier').attr('placeholder', '1 (EventNotifierSubscribeToEvents)');
  263. }
  264. if($('#subscribeevents').prop('checked')==false && $('#historyread').prop('checked')==true && $('#historywrite').prop('checked')==false ){
  265. $('#instanceeventnotifier').attr('placeholder', '4 (EventNotifierHistoryRead)');
  266. }
  267. if($('#subscribeevents').prop('checked')==false && $('#historyread').prop('checked')==false && $('#historywrite').prop('checked')==true ){
  268. $('#instanceeventnotifier').attr('placeholder', '8 (EventNotifierHistoryWrite)');
  269. }
  270. if($('#subscribeevents').prop('checked')==false && $('#historyread').prop('checked')==false && $('#historywrite').prop('checked')==false ){
  271. $('#instanceeventnotifier').attr('placeholder', '0 (None)');
  272. }
  273. if($('#subscribeevents').prop('checked')==true && $('#historyread').prop('checked')==true && $('#historywrite').prop('checked')==false ){
  274. $('#instanceeventnotifier').attr('placeholder', '5 (EventNotifierSubscribeToEvents|EventNotifierHistoryRead)');
  275. }
  276. if($('#subscribeevents').prop('checked')==false && $('#historyread').prop('checked')==true && $('#historywrite').prop('checked')==true ){
  277. $('#instanceeventnotifier').attr('placeholder', '12 (EventNotifierHistoryRead|EventNotifierHistoryWrite)');
  278. }
  279. if($('#subscribeevents').prop('checked')==true && $('#historyread').prop('checked')==false && $('#historywrite').prop('checked')==true ){
  280. $('#instanceeventnotifier').attr('placeholder', '9 (EventNotifierSubscribeToEvents|EventNotifierHistoryWrite)');
  281. }
  282. });