summaryrefslogtreecommitdiffstats
path: root/public/js/uploadPage.js
blob: f309f6608494c46834cdc5b8010f852969c04064 (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
(function() {
	var torrent = $("input[name=torrent]"),
	magnet = $("input[name=magnet]"),
	name = $("input[name=name]");

	torrent.on("change", function() {
		if (torrent.val() == "") {
			enableField(magnet);
			name.attr("required", "");
		} else {
			disableField(magnet);
			// .torrent file will allow autofilling name
			name.removeAttr("required", "");
		}
	});
	magnet.on("change", function() {
		if (magnet.val() == "")
			enableField(torrent);
		else
			disableField(torrent);
	});

	function enableField(e) {
		e.attr("required", "")
			.removeAttr("disabled");
	}
	function disableField(e) {
		e.attr("disabled", "")
			.removeAttr("required");
	}
})();