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

(function($) {
	function clickToTap() {
		if (matchMedia && matchMedia('(hover: none)').matches) $(".clickToTap").each(function() {
			var x = $(this);
			if (x.text() === "Click") x.text("Tap");
			else x.text("tap");
		});
	}
	
	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;
	}

	$(clickToTap);
	$(clickForVideo);
	$(seekVideo);
})($);