windhamdavid 4 years ago
parent
commit
474f1b8d77
3 changed files with 47 additions and 14 deletions
  1. 1 1
      front-page.php
  2. 44 11
      inc/tweaks.php
  3. 2 2
      js/message.js

+ 1 - 1
front-page.php

@@ -117,7 +117,7 @@
 				</div>
 			</div> 
 			<div id="footer" role="contentinfo">
-			<!--<a data-target="#chat" role="button" class="btn" data-toggle="modal">Chat</a> // Add remote poll for control -->
+			<!--<a data-target="#chat" role="button" class="btn" data-toggle="modal">Chat</a>-->
 			<div class="modal fade chat" id="chat" tabindex="-1" role="dialog" aria-labelledby="chat" aria-hidden="true">
 				<div class="modal-dialog modal-lg">
 					<div class="modal-content message">

+ 44 - 11
inc/tweaks.php

@@ -94,28 +94,25 @@ function dw_online_get_status() {
 	$dw_status = get_option('daw_is_online_settings');
 	if( $dw_status['daw_is_online_select_field_0'] == '1' ) { ?>
 		<script type="text/javascript">
+		var i;i = 0;
 		$(function(){
 	        Messenger.options = {extraClasses: "messenger-fixed messenger-on-bottom messenger-on-left",theme: "flat"};
 			var msg; msg = Messenger().post({
 				message: 'I am currently online', type: 'success',
-				actions: {
-					retry: {
-						label: 'Connect', phrase: 'Chat & Video', delay: 30,
+				actions: {retry: {label: 'Connect', phrase: 'Chat & Video', delay: 30,
 						action: function(){
 							var msg_return; msg_return = Messenger().run({
-							  errorMessage: 'Please wait a moment while I get connected', successMessage: 'Connecting Now!',
+							  errorMessage: 'Please wait a moment while I am notified to get connected with you', successMessage: 'Connecting Now!',
 							  action: function(opts) {
 								  msg.hide();
-									i = 0
+								  txt_dave();
 									if (++i < 2) {
-										return opts.error({status: 500,readyState: 0,responseText: 0});
+										return opts.error({status: 500,readyState: 0,responseText: 0});	
 									} 
-									else if (++i < 3) { 
-										// Connect with Cackbone and Twilio via webrtc app at code.davidawindham.com
-										return opts.success();
-									}
 									else {
-										return msg.on();
+										get_dave()
+										return msg.update({message: 'Connecting Now... Please click the allow camera and microphone access up top', hideAfter: 10, type: 'success', actions: false});
+										window.location.href ="chat";
 									}
 								}
 							});
@@ -130,6 +127,42 @@ function dw_online_get_status() {
 				}
 			});
 		});
+
+
+		function get_dave () {
+		var statusElement = $("#chat");
+		var URLchatAPI = "http://macs.local:8080/status";
+			(function poll() {
+				var request = $.ajax({
+				    url: URLchatAPI,
+				    dataType: 'json',
+					cache: false, 
+					success: function (data) {
+						online = data.online;
+						if(online=='yes'){
+							$('.chat').modal('show');
+						};
+					},
+					complete: setTimeout(function() {poll()}, 5000),
+		            timeout: 2000,
+					error: function ( xhr, tStatus, err ) {
+						request.abort();
+						console.log('this is an error');
+					}
+				});
+			})();
+		};
+		
+		function txt_dave () {
+			$.ajax({
+			    url: 'http://davidawindham.com/wha/phony/sms.php',
+			    dataType: 'json',
+			    success: function(data){
+			      
+			    },
+			  });
+			}
+		
 		</script>
 	<?php }
 

+ 2 - 2
js/message.js

@@ -304,5 +304,5 @@ $('.chat').on('shown.bs.modal', function() {
     $(this).find('iframe').attr('src','http://code.davidawindham.com:8080')
 }) 
 $('.chat').on('hidden.bs.modal', function() {
-    $(this).find('iframe').attr('src','http://code.davidawindham.com:8080').remove();
-}) 
+	$(this).find('iframe').attr('src','http://code.davidawindham.com:8080').remove();
+})