-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathwebapp.html
89 lines (80 loc) · 2.68 KB
/
webapp.html
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
<!DOCTYPE html>
<html>
<head>
<title>ViSH Viewer: API Testing</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<script type="text/javascript" src="../../js/VISH.IframeAPI.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
</head>
<body>
<script type="text/javascript">
window.onload = function(){
_loadEvents();
VISH.IframeAPI.init(
{
wapp: true,
tracking: true,
callback: _onConnect
}
);
};
//APP code
var _onConnect = function(origin){
// console.log("WAPP EXAMPLE: " + "Communication stablished with " + origin);
VISH.IframeAPI.getUser(function(user){
if(user.logged){
document.getElementById("username").innerHTML = "Hola " + user.username;
VISH.IframeAPI.getAuthToken(function(token){
// console.log("WAPP EXAMPLE: " + "Token es: " + token);
});
}
});
};
var _afterSetScore = function(score){
alert("Has sacado un " + score);
console.log("WAPP EXAMPLE: " + "Score fijado a: " + score);
console.log("WAPP EXAMPLE: " + score);
};
var _loadEvents = function(){
$("#responder").click(function(){
if(VISH.IframeAPI.isConnected()){
if($("#quiz input[type='radio'][value='Madrid']").is(":checked")){
VISH.IframeAPI.setScore(100,_afterSetScore);
VISH.IframeAPI.setProgress(100,function(progress){
console.log("WAPP EXAMPLE: " + "Progress fijado a: " + progress);
});
VISH.IframeAPI.setSuccessStatus("passed",function(status){
console.log("WAPP EXAMPLE: " + "Success status fijado a: " + status);
});
VISH.IframeAPI.setCompletionStatus("completed",function(status){
console.log("WAPP EXAMPLE: " + "Completion status fijado a: " + status);
});
} else {
VISH.IframeAPI.setScore(0,_afterSetScore);
VISH.IframeAPI.setProgress(100,function(progress){
console.log("WAPP EXAMPLE: " + "Progress fijado a: " + progress);
});
VISH.IframeAPI.setSuccessStatus("failed",function(status){
console.log("WAPP EXAMPLE: " + "Success status fijado a: " + status);
});
VISH.IframeAPI.setCompletionStatus("completed",function(status){
console.log("WAPP EXAMPLE: " + "Completion status fijado a: " + status);
});
}
}
});
};
</script>
<h1> ViSH Editor WebAPP Example </h1>
<p id="username"></p>
<br/>
<div id="quiz">
<p>¿Cúal es la capital de España?</p>
<input type="radio" value="Barcelona">Barcelona</input>
<input type="radio" value="Madrid">Madrid</input>
<input type="radio" value="Valencia">Valencia</input>
<br/>
<input id="responder" type="button" value="Responder"></input>
</div>
</body>
</html>