summaryrefslogtreecommitdiffstats
path: root/modules-available/minilinux/templates/branches.html
blob: 64adda161d15d4827a68d434c63126b9bb1321c6 (plain) (blame)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<h3>{{lang_branchesHeading}}</h3>
{{#branches}}
<div id="ibm-mainframe" class="panel panel-default">
	<div class="panel-heading">
		<div class="pull-right">
			{{sourceid}} {{branchid}}
		</div>
		<b>{{title}}</b>
	</div>
	<div class="panel-body">
		{{description}}
	</div>
	{{{versionlist}}}
</div>
{{/branches}}

<script>
	document.addEventListener('DOMContentLoaded', function () {
		var addHandlers = function(parent) {
			parent.find('.btn-verify').click(function() {
				loadDetails($(this).data('version'), { show: "version", verify: 1 });
			});
			parent.find('.btn-download').click(function() {
				loadDetails($(this).data('version'), { show: "download" });
				$(this).remove();
			});
		};
		var loadDetails = function(version, params) {
			var c = $('.version-container[data-version="' + version + '"]');
			c.show();
			if (c.is(':empty')) {
				c.html('<span class="glyphicon glyphicon-refresh slx-rotation"></span>');
			} else {
				c.addClass('slx-fade');
				c.find('button, a').addClass('disabled').prop('disabled', true);
			}
			var data = { version: version, token: TOKEN };
			$.extend(data, params);
			c.load('?do=minilinux', data,
				function () {
					c.removeClass('slx-fade');
					addHandlers(c);
					c.find('button[data-confirm]').click(slxModalConfirmHandler);
					tmInit();
				});
		};
		$('.version-link').click(function(e) {
			e.preventDefault();
			var ver = $(this).data('version');
			var c = $('.version-container[data-version="' + ver + '"]');
			if (c.is(':visible')) {
				c.hide();
			} else if (c.is(':empty')) {
				loadDetails(ver, {show: "version"});
			} else {
				c.show();
			}
		});
		addHandlers($('#ibm-mainframe'));
		$('[data-autoclick="true"]').click();
	});
	var taskDone = {};
	var wasUnfinished = false;
	function dlTmCb(task) {
		if (!task.data || !task.data.files)
			return;
		for (var i = 0; i < task.data.files.length; ++i) {
			var f = task.data.files[i];
			var id = task.id + f.id;
			if (taskDone[id] === true)
				continue;
			var $div = $('#' + f.id);
			if (f.error) {
				$div.text(f.error).addClass('text-danger');
				taskDone[id] = true;
			} else {
				var wasDone = (taskDone[id] === 100);
				tmSetProgress($div, f.progress, wasDone ? 'TASK_FINISHED' : task.statusCode);
				taskDone[id] = wasDone ? true : f.progress;
			}
		}
		if (wasUnfinished && task.statusCode === 'TASK_FINISHED') location.reload(true);
		if (task.statusCode !== 'TASK_FINISHED') wasUnfinished = true;
	}
</script>