summaryrefslogtreecommitdiffstats
path: root/modules-available/roomplanner/templates/footer.html
blob: b4e0d028ba2acb2540557685bedc842020454bff (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
<div class="pull-left">
	<div class="input-group" style="width:1px">
		<div class="input-group-addon">{{lang_managerIp}}</div>
		<input class="form-control" type="text" id="manager-ip" value="{{managerip}}" placeholder="1.2.3.4"
				 style="width:120px" {{edit_disabled}}>
		<div class="input-group-addon checkbox">
			<input id="dedi-mgr" type="checkbox" {{dediMgrChecked}} {{edit_disabled}}>
			<label for="dedi-mgr">{{lang_dedicatedManager}}</label>
		</div>
	</div>
</div>
<div class="pull-right">
	<button class="btn btn-default" onclick="triggerCancel()">{{lang_cancel}}</button>
	<button id="saveBtn" class="btn btn-primary" {{edit_disabled}}>{{lang_save}}</button>
</div>
<div class="clearfix"></div>


<script type="application/javascript"><!--
var locationId = '{{locationid}}';
var subnetMachines, roomConfiguration;
var plannerLoadState = 'invalid';
const PLANNER_READ_ONLY = '{{edit_disabled}}'.length !== 0;
const CAN_OPEN_STATS = '{{statistics_disabled}}'.length === 0;
document.addEventListener("DOMContentLoaded", function () {

	subnetMachines = makeCombinedField({{{subnetMachines}}});
	roomConfiguration = {{{roomConfiguration}}};

	$.when(
		$.cachedScript("modules/roomplanner/js/lib/jquery-collision.js"),
		$.cachedScript("modules/roomplanner/js/lib/jquery-ui-draggable-collision.js"),
		$.cachedScript("modules/roomplanner/js/grid.js"),
		$.Deferred(function( deferred ){
			$( deferred.resolve );
		})
	).done(function() {
		$.cachedScript("modules/roomplanner/js/init.js", function() {
			initRoomplanner();
			loadRoom();
		});
	});
});

function loadRoom() {
	roomplanner.load(roomConfiguration); // TODO: Filter invalid PCs, they're currently invisible and cannot be removed
	plannerLoadState = roomplanner.serialize();
}

function triggerCancel() {
	if (roomplanner.serialize() !== plannerLoadState) {
		if (!confirm('{{lang_confirmDiscardChanges}}'))
			return;
	}
	window.close();
	// In case this page wasn't opened via JS, it will not close on modern browsers, so let's reset
	loadRoom();
}

// --></script>