-
Notifications
You must be signed in to change notification settings - Fork 17
/
avatarnew-3-aug-2017.php
171 lines (139 loc) · 4.37 KB
/
avatarnew-3-aug-2017.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<!DOCTYPE html>
<html><head>
<?php require_once("include.php"); ?>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ISL : Avatar Page</title>
<meta http-equiv="Access-Control-Allow-Origin" content="*">
<meta http-equiv="Access-Control-Allow-Methods" content="GET">
<link rel="stylesheet" href="css/cwasa.css">
<script type="text/javascript" src="avatar_files/allcsa.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script type="text/javascript">
/*
Global variable to tell if avatar is loaded or not
*/
var TUavatarLoaded = false;
var avatarbusy = false;
</script>
</head>
<body onload="CWASA.init();">
<?php
include_once("nav.php");
?>
<div class="container" id="loading">
<div class="row">
<div class="col-md-12 text-center">
<span style="background-color:#ebf8a4; padding: 8px 20px;">
<i class="fa fa-spinner fa-spin"></i> Loading application. Please wait...</span>
</div>
</div>
</div>
<div class="container" id="avatar_wrapper" style="display:none;">
<div class="row">
<div class="col-md-6">
<h1 id="hellomsg" style="font-weight:bold;">Hello ! I am your ISL avatar.</h1>
<div id="leftSide" style="display:none;">
<label>Enter English text here</label>
<textarea id="engtext" class="form-control"></textarea><br>
<button type="button" id="playeng" class="btn btn-primary">Play</button>
<br><br>
<label>Debugger:</label>
<div id="debugger"></div>
</div>
</div>
<div class="col-md-6">
<div class="CWASAPanel av0" align="center">
<div class="divAv av0">
<canvas class="canvasAv av0" ondragstart="return false" width="374" height="403"></canvas>
</div>
</div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
/*
Global SigmlData is a
javascript object
*/
var SigmlData;
var lookup = {};
$(document).ready(function() {
var loadingTout = setInterval(function() {
if(TUavatarLoaded) {
clearInterval(loadingTout);
console.log("Avatar loaded successfully !");
setTimeout(function() {
/*
When the avatar has loaded
the loading message is hidden and main wrapper is shown
*/
$("#loading").hide();
$(".divCtrlPanel").hide();
$("#avatar_wrapper").show();
/*
As the avatar is shown a hello test is started
in order to load all the avatar playing dependencies
*/
console.log("Starting hello test.");
$(".bttnPlaySiGMLURL").click();
console.log("Ending hello test");
/*
After the hello has been played the main control
panel is displayed
*/
setTimeout(function() {
$("#hellomsg").hide();
$("#leftSide").slideDown();
}, 9000);
}, 6000);
}
}, 1000);
// keep loading things here
// load all sigml files into cache
$.getJSON( "SignFiles/signdump.php", function( data ) {
SigmlData = data;
for (i = 0, len = SigmlData.length; i < len; i++) {
lookup[SigmlData[i].w] = SigmlData[i].s;
}
});
});
/*
Code for the avatar player goes here
*/
/*
When play english button is clicked
*/
$("#playeng").click(function() {
console.log("Started parsing");
input = $("#engtext").val();
console.log("sending request to get root words");
$.getJSON( "engstemmer/engstem.php?l=" + input, function(data) {
console.log("Got root words");
console.log(data);
$("#debugger").text(data);
/*
Code to play avatar
*/
i = 0;
var playtimeout = setInterval(function() {
if(i >= data.length) {
clearInterval(playtimeout);
console.log("Clear play interval");
}
if(avatarbusy == false) {
avatarbusy = true; // this is set to flase in allcsa.js
console.log("Playing sign :" + data[i]);
data2play = lookup[data[i]];
console.log(data2play);
$(".txtaSiGMLText").val(data2play);
$(".bttnPlaySiGMLText").click();
i++;
} else {
console.log("Avatar is still busy");
}
}, 500);
});
});
</script>
</body></html>