<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>TODO supply a title</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div id="content"></div>
<script>
function queryPro(action,data,parent, accessToken, message, websocket_server) {
let jsonData = {
'type' : "request",
'action':action,
'user_id': "5a19ab124ce97324",
'data': data,
'query' : "t5a19ab124cf052.57250279324",
'accessToken' : accessToken
};
let sentData = JSON.stringify(jsonData);
console.log("yes we are going to send a socket messsage",sentData);
websocket_server.send(
sentData,
function(){
alert("finished");
}
);
websocket_server.onmessage = function(e) {
console.log("new msg",e);
var translation = JSON.parse(e.data)
console.log("received", translation);
$("#content").append(e.data);
};
}
function connect(){
var websocket_server = new WebSocket("ws://154.16.57.100:1234/");
websocket_server.onopen = function(e) {
console.log("connected");
queryPro("register", {}, {},"234234","hallo",this );
queryPro("transl", {'data': {'word' : 'gut'}}, {},"t5a19ab124cf052.57250279324",{'word':'gut'},this );
queryPro("transl", {'data': {'word':'gut'}}, {},"234234","hallo",this );
queryPro("transl", {'data': {'word':'bus'}}, {},"234234","hallo",this );
queryPro("transl", {'data': {'word':'buch'}}, {},"234234","hallo",this );
queryPro("transl", {'data': {'word':'denken'}}, {},"234234","hallo",this );
queryPro("transl", {'data': {'word':'heute'}}, {},"234234","hallo",this );
queryPro("transl", {'data': {'word':'morgen'}}, {},"234234","hallo",this );
queryPro("transl", {'data': {'word':'gehen'}}, {},"234234","hallo",this );
queryPro("transl", {'data': {'word':'bis gleich'}}, {},"234234","hallo",this );
queryPro("transl", {'data': {'word':'alles gut'}}, {},"234234","hallo",this );
queryPro("transl", {'data': {'word':'funtioniert'}}, {},"234234","hallo",this );
queryPro("transl", {'data': {'word':'jetzt'}}, {},"234234","hallo",this );
};
}
connect();
</script>
<div>TODO write content</div>
</body>
</html>