Advertisement
D_Pain

Access UI element values within a Plugin

Aug 25th, 2020
1,963
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.86 KB | None | 0 0
  1. <div data---="modal__common.form__if:request;submit:request/submit;title:Confirmation Window" class="hidden">
  2.     <div>
  3.         <span class="link cancel"><i class="fa fa-times"></i></span>
  4.         <label></label>
  5.     </div>
  6.  
  7.     <div>
  8.         <div class="padding bgsmoke">
  9.             <div class="row">
  10.                 <div class="col-md-6 m">
  11.                     <div data---="input__comment__type:string">Comments</div>
  12.                 </div>
  13.                 <div class="col-md-6 m">
  14.                     <div data---="input__vercode__type:password;required">Verification Code</div>
  15.                 </div>
  16.             </div>
  17.             <div class="row">
  18.                 <div class="col-md-12">
  19.                     <button class="pull-right" name="submit" data-exec="request/submit">
  20.                         Send request
  21.                     </button>
  22.                 </div>
  23.             </div>
  24.         </div>
  25.         <hr class="nmt nmb">
  26.         <div class="padding">
  27.             <div class="row">
  28.                 <div class="col-md-12">
  29.                     <div><b>Response:</b></div>
  30.                 </div>
  31.             </div>
  32.             <div class="row">
  33.                 <div class="col-md-12 mt10">
  34.                     <div data---="codemirror__response__type:json;height:150;">response from server goes here.</div>
  35.                 </div>
  36.             </div>
  37.         </div>
  38.     </div>
  39.  
  40. </div>
  41.  
  42. <script>
  43.     PLUGIN('request', function (exports) {
  44.         exports.submit = function () {
  45.             console.log(GET("path.to.access.comments"));
  46.             console.log(GET("path.to.access.vercode"));
  47.  
  48.             // Event Listener whenever server websocket sends a message.
  49.             ON('message', function (data) {
  50.                 if (data.type != null && data.type == 'request') {
  51.                     console.log('Received a message from the server');
  52.                     console.log(data);
  53.                     SET("path.to.access.code.mirror", data.response);   // Display response to codemirror.
  54.                 }
  55.             });
  56.  
  57.             // Sends values to flow server that ultimately sends an api call to another endpoint.
  58.             SETTER('websocket', 'send', {
  59.                 'type': 'request', 'value': {
  60.                     'comment': GET("path.to.access.comments"),
  61.                     'code': GET("path.to.access.vercode")
  62.                 }
  63.             });
  64.         }
  65.  
  66.     })
  67. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement