Advertisement
Guest User

Untitled

a guest
Jul 12th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.51 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. </head>
  5. <body>
  6. <style>
  7. h1,p,h3 {
  8. font-family: "Tahoma";
  9. }
  10. a {
  11. font-size: 10px;
  12. font-family: "tahoma";
  13. color: #000;
  14. padding: none;
  15. text-decoration: none;
  16. }
  17. h3{
  18. font-size: 15px;
  19. padding: none;
  20. width:150px;
  21. }
  22. a:hover {
  23. color: blue;
  24. text-decoration: none;
  25. }
  26.  
  27. .volume {
  28. left: 15%;
  29. width: 100px;
  30. bottom: 2px;
  31. height: 10px;
  32. }
  33.  
  34. .p2pFailed {
  35. background: red;
  36. width: 55px;
  37. }
  38.  
  39. .p2pDisconnected {
  40. background: orange;
  41. width: 55px;
  42. }
  43.  
  44. .p2pCompleted,.p2pConnected {
  45. background: green;
  46. width: 55px;
  47. }
  48.  
  49. table,th,tr {
  50. border: 3px solid black;
  51. }
  52.  
  53. button {
  54. border: none;
  55. background: none;
  56. }
  57. #lgsm {
  58. height:10%;
  59. width:10%;
  60. }
  61. </style>
  62. <a href="index.html"><img src="dux.png" id="lgsm"></a>
  63. <a href="sci.htm"> Science </a>
  64. <a href="tec.htm"> Technology </a>
  65. <a href="biz.htm"> Business </a>
  66. <a href="pol.htm"> Politics </a>
  67. <a href="mus.htm"> Music </a>
  68. <a href="tv.htm"> Tv </a>
  69. <a href="com.htm"> Comedy </a>
  70. <a href="drw.htm"> Drawing(idle board) </a>
  71. <a href="vdg.htm"> Video Games(idle board) </a>
  72. <a href="cod.htm"> Coding(idle board) </a>
  73. <a href="qna.htm"> QnA </a>
  74. <a href="his.htm"> History </a>
  75. <a href="hob.htm"> Hobbies </a>
  76. <a href="rnd.htm"> Random </a>
  77. <a href="bob.htm"> Battle Of the Boards </a>
  78. <hr>
  79. <table>
  80. <tr>
  81. <th><button onclick="mute()"><img width="50%" height="50%" src="speaker.png" id="urimg"></button><meter width="10" id="localVolume" class="volume" min="-45" max="-20" high="-25" low="-40" value="-45"></meter></th>
  82. </tr>
  83. </table>
  84. <div id="remotes"></div>
  85. <div id="remotesVideos"></div>
  86. <video height="300" id="localVideo"></video>
  87. <script src="https://webrtc.github.io/adapter/adapter-4.2.2.js"></script>
  88. <script src="https://simplewebrtc.com/latest-v2.js"></script>
  89. <script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
  90. <script type="text/javascript">
  91. var rm="drw";
  92. </script>
  93. <script type="text/javascript">
  94. var webrtc = new SimpleWebRTC({
  95. remoteVideosEl: 'remotesVideos',
  96. localVideoEl: 'localVideo',
  97. autoRequestMedia: true,
  98. detectSpeakingEvents: true,
  99. autoAdjustMic: false,
  100. media: {
  101. video: false,
  102. audio: true
  103. },
  104. debug: false
  105. });
  106. webrtc.on('readyToCall', function() {
  107. webrtc.joinRoom(rm);
  108. });
  109. if (location.protocol == "http:") {
  110. alert("Please use https://www. on our page, otherwise RTC will not function.");
  111. }
  112.  
  113. function showVolume(el, volume) {
  114. if (!el) return;
  115. if (volume < -45) volume = -45;
  116. if (volume > -20) volume = -20;
  117. el.value = volume;
  118. }
  119.  
  120. function track(name, info) {
  121. if (webrtc && webrtc.connection) {
  122. webrtc.connection.emit('metrics', name, info || {});
  123. }
  124. }
  125. var thisNumRand;
  126. webrtc.on('createdPeer', function(peer) {
  127. var pyd =peer.id.substring(0,6);
  128. for(var i=0; i<6; i++){
  129. var strout=0;
  130. var alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","1","2","3","4","5","6","7","8","9","0","-"];
  131. var letter = pyd[i];
  132. var letterPosition = alphabet.indexOf(letter)+1;
  133. strout=strout+letterPosition;
  134. if (i==0){
  135. thisNumRand=strout*26291;
  136. }
  137. }
  138. var remotes = document.getElementById('remotes');
  139. if (!remotes) return;
  140. var container = document.createElement('div');
  141. container.className = 'peerContainer';
  142. container.id = 'container_' + webrtc.getDomId(peer);
  143. var tri = document.createElement('tr');
  144. var th = document.createElement('th');
  145. var name = document.createElement('h3');
  146. name.style.color="#"+thisNumRand;
  147. txn = document.createTextNode("Anon "+thisNumRand);
  148. name.appendChild(txn);
  149. th.appendChild(name);
  150. var thi = document.createElement('th');
  151. var thii = document.createElement('th');
  152. var img = document.createElement('img');
  153. img.src = "speaker.png";
  154. img.height = 50;
  155. img.width = 50;
  156. var mute = document.createElement('a');
  157. var vol = document.createElement('meter');
  158. vol.id = 'volume_' + peer.id;
  159. vol.className = 'volume';
  160. vol.min = -45;
  161. vol.max = -20;
  162. vol.low = -40;
  163. vol.high = -25;
  164. thi.appendChild(mute);
  165. mute.appendChild(img);
  166. thii.appendChild(vol);
  167. tri.appendChild(thi);
  168. tri.appendChild(th);
  169. tri.appendChild(thii);
  170. container.appendChild(tri);
  171. remotes.appendChild(container);
  172. /*if(pmu==clientson){
  173. webrtc.leaveRoom();
  174. }saving it for when i get my errors otw*/
  175. var xnte=0;
  176. mute.onclick = function() {
  177. var cli ="#"+webrtc.getDomId(peer) + '_video_incoming';
  178. console.log("bp1");
  179. xnte = xnte + 1;
  180. if (xnte % 2 == 0) {// unmute
  181. $(cli).prop('muted', true);
  182. img.src = 'muted.png';
  183. console.log("bp2");
  184. } else { // mute
  185. $(cli).prop('muted', false);
  186. img.src = 'speaker.png';
  187. console.log("bp3");
  188. }
  189. };
  190.  
  191. if (peer && peer.pc) {
  192. peer.firsttime = true;
  193. peer.pc.on('iceConnectionStateChange', function(event) {
  194. var state = peer.pc.iceConnectionState;
  195. container.className = 'peerContainer p2p' +
  196. state.substr(0, 1).toUpperCase() +
  197. state.substr(1);
  198. switch (state) {
  199. case 'connected':
  200. case 'completed':
  201. mute.style.visibility = 'visible';
  202. if (peer.firsttime) {
  203. peer.firsttime = false;
  204. track('iceSuccess', {
  205. session: peer.sid,
  206. peerprefix: peer.browserPrefix,
  207. prefix: webrtc.capabilities.prefix,
  208. version: webrtc.capabilities.browserVersion
  209. });
  210. }
  211. break;
  212. case 'closed':
  213. container.remove();
  214. break;
  215. }
  216. });
  217. }
  218. remotes.appendChild(container);
  219. });
  220. webrtc.on('volumeChange', function(volume, threshold) {
  221. showVolume(document.getElementById('localVolume'), volume);
  222. });
  223. webrtc.on('remoteVolumeChange', function(peer, volume) {
  224. showVolume(document.getElementById('volume_' + peer.id), volume);
  225. });
  226. var totalSeconds = 0;
  227. setInterval(setTime, 1000);
  228. function setTime() {
  229. ++totalSeconds;
  230. if (totalSeconds > 300) {
  231. webrtc.leaveRoom();
  232. document.write("Disconnected due to inactivity");
  233. window.location = "index.html";
  234. }
  235. }
  236. var px = 0;
  237. function mute() {
  238. px = px + 1;
  239. if (px % 2 == 0) {
  240. webrtc.unmute();
  241. $("#urimg").attr("src", "speaker.png");
  242. } else {
  243. webrtc.mute();
  244. $("#urimg").attr("src", "muted.png");
  245. }
  246. }
  247. </script>
  248. </body>
  249. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement