PageRenderTime 45ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/project/network/jWebSocketClient-1.0/demos/slideshow/viewer.htm

https://gitlab.com/BGCX261/zlatnaspirala2-svn-to-git
HTML | 165 lines | 121 code | 23 blank | 21 comment | 0 complexity | 5709bc7b0b8b8118872d84304c572f8f MD5 | raw file
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD html 4.01//EN" "http://www.w3.org/TR/html4/transitional.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="X-UA-Compatible" content="chrome=1">
  5. <!-- If Google's chrome frame installed, use it! -->
  6. <!-- Comment needs to be BELOW this meta tag! -->
  7. <!--
  8. // ****************************************************************************
  9. // jWebSocket RPC Demo (uses jWebSocket Client and Server)
  10. // Copyright (c) 2010 Alexander Schulze, Innotrade GmbH, Herzogenrath
  11. // ****************************************************************************
  12. // This program is free software; you can redistribute it and/or modify it
  13. // under the terms of the GNU Lesser General Public License as published by the
  14. // Free Software Foundation; either version 3 of the License, or (at your
  15. // option) any later version.
  16. // This program is distributed in the hope that it will be useful, but WITHOUT
  17. // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  18. // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
  19. // more details.
  20. // You should have received a copy of the GNU Lesser General Public License along
  21. // with this program; if not, see <http://www.gnu.org/licenses/lgpl.html>.
  22. // ****************************************************************************
  23. -->
  24. <meta http-equiv="Content-Language" content="en">
  25. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  26. <title>jWebSocket Slide Show Viewer</title>
  27. <link rel="stylesheet" type="text/css" href="../../res/css/jwebsocket.css">
  28. <!-- load the jWebSocket JavaScript client library -->
  29. <script src="../../res/js/jWebSocket.js" type="text/javascript"></script>
  30. <script type="text/javascript" language="JavaScript">
  31. var eLog = null;
  32. var eCount = null;
  33. var lCurSlide = 0;
  34. var lMaxSlides = 19;
  35. function scrollLogToBottom() {
  36. if( eLog.scrollHeight > eLog.clientHeight ) {
  37. eLog.scrollTop = eLog.scrollHeight - eLog.clientHeight;
  38. }
  39. }
  40. function log( aString ) {
  41. eLog.innerHTML +=
  42. aString + "<br>";
  43. scrollLogToBottom();
  44. }
  45. function clearLog() {
  46. eLog.innerHTML = "";
  47. eLog.scrollTop = 0;
  48. }
  49. var lWSC = null;
  50. function connect() {
  51. var lURL = jws.getDefaultServerURL();
  52. log( "Connecting to " + lURL + " ..." );
  53. var lRes = lWSC.open( lURL, {
  54. // OnOpen callback
  55. OnOpen: function( aEvent ) {
  56. log( "<font style='color:#888'>jWebSocket connection established.</font>" );
  57. jws.$("simgStatus").src = "../../images/connected.png";
  58. },
  59. // OnWelcome callback
  60. OnWelcome: function( aEvent ) {
  61. },
  62. // OnMessage callback
  63. OnMessage: function( aEvent ) {
  64. log( "<font style='color:#888'>jWebSocket message received: '" + aEvent.data + "'</font>" );
  65. jws.$("simgStatus").src = "../../images/authenticated.png";
  66. jws.$("slblClientId").innerHTML =
  67. "&nbsp;Client&#x2011;Id:&nbsp;"
  68. + lWSC.getId() + "&nbsp;"
  69. + ( jws.browserSupportsNativeWebSockets ? "(native)" : "(flashbridge)" );
  70. },
  71. // OnMessage callback
  72. OnToken: function( aToken ) {
  73. if( "slide" == aToken.action ) {
  74. if( lCurSlide != aToken.slide ) {
  75. eSlide.src = "slides/Slide" + jws.tools.zerofill( aToken.slide, 4 ) + ".gif";
  76. lCurSlide = aToken.slide;
  77. }
  78. eCount.innerHTML = aToken.clientCount;
  79. } else if( "event" == aToken.type
  80. && "connect" == aToken.name ) {
  81. eCount.innerHTML = aToken.clientCount;
  82. } else if( "event" == aToken.type
  83. && "disconnect" == aToken.name ) {
  84. eCount.innerHTML = aToken.clientCount;
  85. }
  86. },
  87. // OnClose callback
  88. OnClose: function( aEvent ) {
  89. log( "<font style='color:#888'>jWebSocket connection closed.</font>" );
  90. jws.$("simgStatus").src = "../../images/disconnected.png";
  91. jws.$("slblClientId").innerHTML = "&nbsp;Client&#x2011;Id:&nbsp;-";
  92. }
  93. });
  94. log( lWSC.resultToString( lRes ) );
  95. }
  96. function disconnect() {
  97. if( lWSC ) {
  98. log( "Disconnecting..." );
  99. var lRes = lWSC.close({ timeout: 3000 });
  100. log( lWSC.resultToString( lRes ) );
  101. }
  102. }
  103. function initPage() {
  104. eLog = jws.$( "sdivLog" );
  105. eSlide = jws.$( "simgSlide" );
  106. eCount = jws.$( "slblCount" );
  107. if( jws.browserSupportsWebSockets() ) {
  108. lWSC = new jws.jWebSocketJSONClient();
  109. } else {
  110. var lMsg = jws.MSG_WS_NOT_SUPPORTED;
  111. alert( lMsg );
  112. log( lMsg );
  113. }
  114. connect();
  115. }
  116. function exitPage() {
  117. disconnect();
  118. }
  119. </script>
  120. </head>
  121. <body
  122. onload="initPage();"
  123. onunload="exitPage();"
  124. style="background-color:#000"
  125. >
  126. <table class="tblHeader" width="100%" cellspacing="0" cellpadding="0">
  127. <tr>
  128. <td class="tdHeader" width="">
  129. jWebSocket Slideshow Viewer: &quot;Boosting Web Communication with WebSockets&quot;
  130. &nbsp;<span id="slblCount">-</span> online
  131. </td>
  132. <td class="tdHeader" width="1%"><img id="simgStatus" src="../../images/disconnected.png" align="right"/></td>
  133. <td class="tdHeader" width="1%"><span id="slblClientId">&nbsp;Client&#x2011;Id:&nbsp;-</span></td>
  134. </tr>
  135. </table>
  136. <!-- <p>Welcome to the jWebSocket Slideshow Viewer.</p> -->
  137. <img id="simgSlide" src="slides/Slide0001.gif"/>
  138. <div id="sdivLog" class="sdivContainer"
  139. style="display:none; position:relative; height:100px; overflow:auto;">
  140. </div>
  141. </body>
  142. </html>