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
|
/* IVLE - Informatics Virtual Learning Environment
* Copyright (C) 2007-2008 The University of Melbourne
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Module: Terms of Service
* Author: Matt Giuca
* Date: 14/2/2008
*
* Client handler for the "Terms of Service" page.
* (Accepts user's acceptance, and calls usermgt to create the user's jail and
* activate their account).
*/
/* The user must send this declaration message to ensure they acknowledge the
* TOS.
* (This is the exact same string as in userservice).
*/
USER_DECLARATION = {"declaration":
"I accept the IVLE Terms of Service"};
/** Creates a "dot dot dot" animation to indicate the client is waiting for a
* response from the server.
* This will keep animating forever.
* Returns a DOM element which will automatically have its contents changed on
* intervals.
*/
function make_dots_anim()
{
var p = document.createElement("p");
anim_dots = document.createTextNode("");
p.appendChild(anim_dots);
setInterval("anim_dots.data = updateDots(anim_dots.data);", 500);
return p;
}
function updateDots(text)
{
if (text.length >= 4)
return ".";
else
return text + ".";
}
function accept_license()
{
/* The user has accepted the license.
* We need to call usermgt to tell it the good news.
* It will go away and make the user's jail and activate the account in
* the DB, among other things.
* This could take awhile (which is why we're using Ajax).
* We need to wait on this page for the server's response.
*/
/* Start by clearing away these buttons. */
var tos_acceptbuttons = document.getElementById("tos_acceptbuttons");
dom_removechildren(tos_acceptbuttons);
/* Print a "please wait" message */
tos_acceptbuttons.appendChild(dom_make_text_elem("p",
"IVLE is now setting up your environment. Please wait..."));
tos_acceptbuttons.appendChild(make_dots_anim());
/* Make the Ajax request */
ajax_call(handle_accept_response, "userservice", "activate_me",
USER_DECLARATION, "POST")
}
function handle_accept_response(xhr)
{
/* TEMP */
var tos_acceptbuttons = document.getElementById("tos_acceptbuttons");
dom_removechildren(tos_acceptbuttons);
try
{
response = JSON.parse(xhr.responseText);
}
catch (e)
{
response = {'response': 'parse-failure'};
}
if (response.response == 'usrmgt-failure')
{
tos_acceptbuttons.appendChild(dom_make_text_elem("p",
"Error connecting to User Management server. Please try again later."));
}
else if (response.response == 'parse-failure')
{
tos_acceptbuttons.appendChild(dom_make_text_elem("p",
"Error connecting to server. Please try again later. "));
}
else
{
/* Refresh the page; as the user is now (apparently) logged in */
window.location.href = window.location.href;
}
}
function decline_license()
{
/* Redirect to the logout page */
window.location.href = app_path("logout");
}
|