Advertisement
Guest User

Untitled

a guest
May 28th, 2015
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.72 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>WeDo Wear Notifications Simulation</title>
  5. <style>
  6. </style>
  7. </head>
  8. <body>
  9. <!-- using bootstrap 3.X (already included) define the html layout, validate the form -->
  10. <!-- the form should include the following fields -->
  11. <!-- ActinId -> Unique ID - Integer && auto-increment ->
  12. <!-- Name -> String & Required - max length 20 -->
  13. <!-- Message -> String & Required - max length 50 -->
  14. <!-- PhoneNumber -> Number & Required - min/max length 9 this number can only start with '91 || 92 || 93 || 96'-->
  15. <!-- Action -> Select between 2 options: "Wear Notifications || Normal Action" -->
  16. <form>
  17. Action Number:<br>
  18. <input type="number" id="actionId" name="actionId" readonly>
  19. <br>
  20. Name:<br>
  21. <input type="text" id="username" name="username" maxlength="20" required>
  22. <br>
  23. Message:<br>
  24. <input type="text" id="message" name="message" maxlength="50" required >
  25. <br>
  26. Phone Number:<br>
  27. <input type="text" id="customerPhone" name="customerPhone" maxlength="9" minlength="9" pattern="(91|92|93|96)[0-9]{7}" title="must have 9 numbers and start by 9" required >
  28. <br>
  29. Action:<br>
  30. <select id="actionTriggered" name="actionTriggered" form="chose">
  31. <option value="send">Wear Notifications</option>
  32. <option value="dont">Normal Action</option>
  33. </select>
  34. <br>
  35. <br>
  36.  
  37. <button onclick="enviar()">Submit</button>
  38. </form>
  39.  
  40.  
  41. <script src="node_modules/socket.io/node_modules/socket.io-client/socket.io.js"></script>
  42. <script src="http://code.jquery.com/jquery-latest.min.js"></script>
  43. <script>
  44.  
  45. var socket = io('http://localhost:18282');
  46. var counter = new Date().getTime();
  47.  
  48. $('#actionId').val(counter);
  49.  
  50. function enviar(){
  51.  
  52. var ActionIdValue=0;
  53. var MessageValue="x";
  54. var NameValue="a";
  55. var PhoneNumberValue=1;
  56. var ActionValue="s";
  57.  
  58.  
  59. //Create socket connection using socket.io
  60.  
  61. //on button click a json should be created
  62. result = {
  63. "action" : {
  64. "actionId": $('#actionId').val(),
  65. "message": $('#message').val(),
  66. "username": $('#username').val(),
  67. "customerPhone": $('#customerPhone').val(),
  68. "actionTriggered": $('#actionTriggered').val()
  69. }
  70. }
  71. // AND
  72.  
  73.  
  74. console.log("----");
  75. console.log(result);
  76. console.log("----");
  77.  
  78.  
  79. socket.emit('data',result);
  80. }
  81.  
  82. </script>
  83. <!-- Latest compiled and minified CSS -->
  84. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
  85. <!-- Optional theme -->
  86. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">
  87. <!-- Latest compiled and minified JavaScript -->
  88. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
  89. <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>
  90. </body>
  91. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement