forked from code-dot-org/code-dot-org
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtermsInterstitial.js
More file actions
57 lines (50 loc) · 1.52 KB
/
termsInterstitial.js
File metadata and controls
57 lines (50 loc) · 1.52 KB
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
import $ from 'jquery';
$(document).ready(function () {
$("#user_terms_of_service_version").on('change', function (event) {
if ($(this).is(':checked')) {
$("#accept-terms-submit").prop('disabled', false).removeClass("disabled-button");
} else {
$("#accept-terms-submit").prop('disabled', true).addClass("disabled-button");
}
});
$("#edit_user").submit(function (event) {
event.preventDefault();
$.ajax({
type: 'POST',
url: $(this).attr('action'),
data: $(this).serialize(),
dataType: 'json',
success: function (data) {$("#terms-modal").modal('hide'); location.reload();}
});
});
$('#later-link').click(function () {
$("#terms-modal").modal('hide');
});
});
$(document).ready(function () {
var printLink = $('#print-terms');
if (printLink) {
printLink.click(function () {
var item = $("#print-frame")[0];
item.contentWindow.print();
});
}
});
function setCookie(key, value) {
var expires = new Date();
// Kill hide_tos cookie at midnight every night
// so the terms interstitial pops up once a day.
expires.setHours(23,59,59,0);
document.cookie = key + '=' + value + ';expires=' + expires.toUTCString();
}
function getCookie(key) {
var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)');
return keyValue ? keyValue[2] : null;
}
$(document).ready(function () {
var already_shown = !!getCookie('hide_tos');
if (!already_shown) {
$("#terms-modal").modal('show');
setCookie('hide_tos', '1');
}
});