SMS-proj is a project to send receive SMS messages.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sms-proj/templates/index.html

68 lines
2.6 KiB

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/static/main.css">
<script src="/static/jquery-3.3.1.min.js"></script>
<title> Yeah! </title>
<script type="text/javascript">
$("document").ready(function() {
// Do something...
$("#submit-chat").click(function(){
fromDid = '19516025252';
inputchat = $("#input-chat").val();
if (!$("#input-chat").val()){
alert("Empty message field! Cant do this!");
return false;
}
$.ajax({
method: "POST",
url: "/submitMessage",
data: { message: inputchat, fromdid: fromDid }
}).done(function( msg ) {
dt = new Date();
time = dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds();
msgParsed = $.parseJSON(msg);
statusHTML = '<div id="alert-messages">Success! Got "'+ msg +'"</div>';
newHTML = '<div id="msg"><span class="chat-time">(' + time + ')</span> <span class="chat-from">' + msgParsed.fromdid + '</span>: ' + msgParsed.msg + '</div>';
$("#chat-body").append( newHTML );
$("#alert-messages").html(statusHTML);
});
});
$('#test-ajax').click(function() {
$.ajax({
url: '/testAjax',
type: 'GET',
success: function(response) {
newHTML = '<div id="msg"><span class="chat-from">SYSTEM</span>: ' + response + '</div>';
statusHTML = '<div id="alert-messages">Success! Got "'+ response +'"</div>';
$("#chat-body").append( newHTML );
$("#alert-messages").html(statusHTML);
},
error: function(error) {
errorHTML = '<div id="msg"><span class="chat-from">SYSTEM</span>: Error ' + error + '</div>';
statusHTML = '<div id="alert-messages">Error! Got "'+ error +'"</div>';
$("#chat-body").append( errorHTML );
$("#alert-messages").html(statusHTML);
}
});
});
});
</script>
</head>
<body>
<h1 id="channel-name">SMS Project</h1>
<div id="chat">
<div id="chat-body">
<div id="msg"><span class="chat-from">OPERATOR</span>: Welcome!</div>
</div>
<div id="chat-input">
<input type="text" id="input-chat" />
<input type="button" id="submit-chat" value="Send"/>
<input type="button" id="test-ajax" value="test ajax"/>
</div>
<div id="alert-messages">
Stuff
</div>
</div>
</body>
</html>