aboutsummaryrefslogtreecommitdiff
path: root/website/resources/js/main.js
blob: eaf5e18819d9702bf7a0569d60151815853e3127 (plain)
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
"use strict";

(function($) {
	function clickForVideo() {
		var cfv = $("#clickForVideo");
		var f = function() {
			if (!cfv.is(":visible")) return;
			cfv.hide();
			$("#demoVideo").show().get(0).play();
		};
		
		cfv.css("cursor", "pointer").on("click", f).on("touchstart", function() {
			$(this).data("moved", 0);
		}).on("touchmove", function() {
			$(this).data("moved", 1);
		}).on("touchend", function() {
			if ($(this).data("moved") === 0) f();
		});
	}

	function seekVideo() {
		var t = window.location.hash;
		if (!t) return;
		var s = /^#?(?:(\d\d?):)?(\d\d?):(\d\d?)$/.exec(t);
		if (!s) return;
		var videoj = $("#presentationVideo");
		if (!videoj || videoj.length == 0) return;
		var video = videoj[0];
		var h = parseInt(s[1]);
		if (!h) h = 0;
		var m = parseInt(s[2]);
		var s = parseInt(s[3]);
		video.currentTime = (((h * 60) + m) * 60) + s;
	}

	function aButtonsRespondToSpacebar() {
		$('a[role="button"]').keyup(function(e) {
			if (e.which == 32) e.target.click();
		});
	}

	$(clickForVideo);
	$(seekVideo);
	$(aButtonsRespondToSpacebar);
})($);