-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
52 lines (37 loc) · 1.23 KB
/
script.js
File metadata and controls
52 lines (37 loc) · 1.23 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
$(function() {
// Center the flag
var height = $(window).height();
var margins = Math.max(0,height - 60 /* top */ - 400 /* flag */ - 120 /* foot */) / 2;
$('#flag').css({ 'margin': margins + 'px auto' });
// Cycle through flag colors
var cycle = [ "blue" , "white" , "red" ], current = 0, auto = true;
function doCycle() {
if (!auto) return;
$("#flag").removeClass(cycle[current]);
current = (current + 1) % 3;
$("#flag").addClass(cycle[current]);
}
function cycleTo(pos) {
auto = false;
if (current == pos) return;
$("#flag").removeClass(cycle[current]);
current = pos;
$("#flag").addClass(cycle[current]);
}
setInterval(doCycle, 10000);
$("#flag").children().click(function(){
var pos = $(this).prevAll().length;
cycleTo(pos);
});
// Send the e-mail on the server
var contact = "http://m2014.fr/post-contact";
function postContact(email) {
if (!email) return;
$.post(contact,{m2014:"DemandeSiteM2014",email:email},function(){});
$("#contact").addClass("sent");
}
$("#contact form").submit(function(){
postContact($('input').val());
return false;
});
});