Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.20 KB | None | 0 0
  1. <html lang="en"><head>
  2. <title>Passion Fruit Jam</title>
  3. <script type="text/javascript" src="/socket.io/socket.io.js"></script>
  4. <!--The above library(/socket.io/socket.io.js) will be generated by socket.io module of server -->
  5. <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
  6.  
  7. <link rel="stylesheet" media="screen" href="https://ajwebcdn1.akamaized.net/assets/2.0/main-91475b0eba3490d3394bacd04d3653ef8822d80feb78bad48e45d3c2c840cd4d.css" />
  8.  
  9. <link rel="icon" type="image/png" sizes="96x96" href="https://i.imgur.com/eUiPsfq.png">
  10.  
  11. </head>
  12. <style>
  13. body
  14. {background: url(https://i.imgur.com/txii070.jpg); no-repeat fixed top center; background-size: 1920px 1000px; }
  15.  
  16. </style>
  17.  
  18. <form>
  19. <div id="wrapper">
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26. <input type="text" id="message" placeholder="Enter desired string" style="
  27. border-left-width: 0px;
  28. padding-bottom: 140px;
  29. margin-left: 820px;
  30. position: absolute;
  31. left: 0;
  32. top: 135px;
  33. background: #fcf7de;
  34. border: #83583f 2px solid;
  35. border-radius: 16px;
  36. padding: 8px 0 120px 10px;
  37. box-shadow: inset 0px 3px 2px 0px rgba(50,50,50,0.25);
  38. box-sizing: border-box;
  39. width: 195px;
  40.  
  41.  
  42.  
  43.  
  44. "> <!--text form to send data to the server-->
  45. <input id="submit" type="button" value="Send data to Client" style="
  46. padding-bottom: 5px;
  47. margin-left: 827px;
  48. position: absolute;
  49. left: 0;
  50. top: 300px;
  51.  
  52. display: inline-block;
  53. color: #086600;
  54. font-weight: bold;
  55. text-align: center;
  56. text-decoration: none;
  57. background-color: #70DB43;
  58. background-image: linear-gradient(0deg, #86fd64 0%, #56b021 53.4%, #78c04d 53.5%, #d4ebc6 98%);
  59. cursor: pointer;
  60. font-family: Tiki-Island;
  61. font-weight: normal;
  62. font-size: 20px;
  63. line-height: 30px;
  64. letter-spacing: 1px;
  65. height: 40px;
  66. border-radius: 82px;
  67.  
  68.  
  69.  
  70. "><input type="text" id="message" placeholder="Enter desired string" style="
  71.  
  72.  
  73. border-left-width: 0px;
  74. padding-bottom: 140px;
  75. margin-left: 1225px;
  76. position: absolute;
  77. left: 0;
  78. top: 135px;
  79. background: #fcf7de;
  80. border: #83583f 2px solid;
  81. border-radius: 16px;
  82. padding: 8px 0 120px 10px;
  83. box-shadow: inset 0px 3px 2px 0px rgba(50,50,50,0.25);
  84. box-sizing: border-box;
  85. width: 195px;
  86.  
  87. "><input id="submitting" type="button" value="Send data to Server" style="
  88. padding-bottom: 5px;
  89. margin-left: 1230px;
  90. position: absolute;
  91. left: 0;
  92. top: 300px;
  93.  
  94. display: inline-block;
  95. color: #086600;
  96. font-weight: bold;
  97. text-align: center;
  98. text-decoration: none;
  99. background-color: #70DB43;
  100. background-image: linear-gradient(0deg, #86fd64 0%, #56b021 53.4%, #78c04d 53.5%, #d4ebc6 98%);
  101. cursor: pointer;
  102. font-family: Tiki-Island;
  103. font-weight: normal;
  104. font-size: 20px;
  105. line-height: 30px;
  106. letter-spacing: 1px;
  107. height: 40px;
  108. border-radius: 82px;
  109.  
  110. "><input type="text" id="message1" placeholder="Text to match" style="
  111.  
  112.  
  113.  
  114. border-left-width: 0px;
  115. padding-bottom: 140px;
  116. margin-left: 1635px;
  117. position: absolute;
  118. left: 0;
  119. top: 150px;
  120.  
  121. background: #fcf7de;
  122. border: #83583f 2px solid;
  123. border-radius: 72px;
  124. padding: 8px 0 25px 10px;
  125. box-shadow: inset 0px 3px 2px 0px rgba(50,50,50,0.25);
  126. box-sizing: border-box;
  127. width: 195px;
  128.  
  129. "><input type="text" id="message" placeholder="Replace with" style="
  130.  
  131.  
  132. border-left-width: 0px;
  133. padding-bottom: 140px;
  134. margin-left: 1635px;
  135. position: absolute;
  136. left: 0;
  137. top: 215px;
  138.  
  139. background: #fcf7de;
  140. border: #83583f 2px solid;
  141. border-radius: 72px;
  142. padding: 8px 0 25px 10px;
  143. box-shadow: inset 0px 3px 2px 0px rgba(50,50,50,0.25);
  144. box-sizing: border-box;
  145. width: 195px;
  146.  
  147. "><input id="submit" type="button" value="Set" style="
  148. padding-bottom: 50px;
  149. margin-left: 1705px;
  150. position: absolute;
  151. left: 0;
  152. top: 290px;
  153.  
  154. display: inline-block;
  155. color: #086600;
  156. font-weight: bold;
  157. text-align: center;
  158. text-decoration: none;
  159. background-color: #70DB43;
  160. background-image: linear-gradient(0deg, #86fd64 0%, #56b021 53.4%, #78c04d 53.5%, #d4ebc6 98%);
  161. cursor: pointer;
  162. font-family: Tiki-Island;
  163. font-weight: normal;
  164. font-size: 40px;
  165. line-height: 45px;
  166. letter-spacing: 1px;
  167. height: 40px;
  168. border-radius: 82px;
  169.  
  170.  
  171.  
  172.  
  173.  
  174. ">
  175. <div id="content" style=" width:721px; height: 376px; overflow-y: auto;"><p></p>
  176. <style>
  177.  
  178. </style>
  179. </div><!--This is where the data from the server is added-->
  180.  
  181.  
  182. </div>
  183.  
  184. </form>
  185.  
  186. <script type="text/javascript">
  187. var socket = io.connect("/");
  188. /*Initializing the connection with the server via websockets */
  189. socket.on("message",function(message){
  190. /*
  191. When server sends data to the client it will trigger "message" event on the client side , by
  192. using socket.on("message") , one cna listen for the ,message event and associate a callback to
  193. be executed . The Callback function gets the dat sent from the server
  194. */
  195. console.log("Message from the server arrived")
  196. console.log(message); /*converting the data into JS object */
  197. $('#content').append('<div >'+message.data+'</div>'); /*appending the data on the page using Jquery */
  198. });
  199. $(function(){
  200. $('#submit').click(function(){ /*listening to the button click using Jquery listener*/
  201. var data = { /*creating a Js ojbect to be sent to the server*/
  202. message:$('#message').val(), /*getting the text input data */
  203. }
  204. console.log("Sending");
  205. console.log(data);
  206. socket.send(JSON.stringify(data));
  207. /*Data can be sent to server very easily by using socket.send() method
  208. The data has to be changed to a JSON before sending
  209. it (JSON.stringify() does this job )*/
  210. /* This triggers a message event on the server side
  211. and the event handler obtains the data sent */
  212. $('#message').val('');
  213. //Emptying the text box value using jquery
  214. });
  215. $(function() {
  216. $('#submit').click(function () { /*listening to the button click using Jquery listener*/
  217. var data = {
  218. /*creating a Js ojbect to be sent to the server*/
  219. message: $('#message').val(), /*getting the text input data */
  220. }
  221. console.log("Sending");
  222. console.log(data);
  223. socket.send(JSON.stringify(data));
  224. /*Data can be sent to server very easily by using socket.send() method
  225. The data has to be changed to a JSON before sending
  226. it (JSON.stringify() does this job )*/
  227. /* This triggers a message event on the server side
  228. and the event handler obtains the data sent */
  229. $('#message').val('');
  230. //Emptying the text box value using jquery
  231. });
  232. });
  233.  
  234.  
  235. $(function() {
  236. $('#submitting').click(function () { /*listening to the button click using Jquery listener*/
  237. var data = {
  238. /*creating a Js ojbect to be sent to the server*/
  239. messagee: $('#message1').val(), /*getting the text input data */
  240. }
  241. console.log("Sending");
  242. console.log(data);
  243. socket.send(JSON.stringify(data));
  244. /*Data can be sent to server very easily by using socket.send() method
  245. The data has to be changed to a JSON before sending
  246. it (JSON.stringify() does this job )*/
  247. /* This triggers a message event on the server side
  248. and the event handler obtains the data sent */
  249. $('#message1').val('');
  250. //Emptying the text box value using jquery
  251. });
  252. });
  253.  
  254.  
  255.  
  256.  
  257. });
  258. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement