summaryrefslogtreecommitdiffstats
path: root/modules-available/roomplanner/js/init.js
blob: 79f8e17ecef3c7aa655bbd99baddb1d35559cd23 (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/* */

function initRoomplanner() {
	
	$('#drawarea').css('top',(-roomplanner.settings.scale*10)+'px');
	$('#drawarea').css('left',(-roomplanner.settings.scale*10)+'px');
	
	roomplanner.computerAttributes = [
		"hostname",
		"ip",
		"mac_address",
		"muuid"
	];
	
	$("#loadButton").click(function() {
		roomplanner.load($('#serializedRoom').val());
	});

	$("#serializeButton").click(function() {
		$('#serializedRoom').val(roomplanner.serialize());
	});

	$("#saveBtn").click(function() {
		var managerip = $('#manager-ip').val().trim();
		if (managerip.length !== 0 && !(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(managerip))) {
			alert('Invalid IP address format');
			return;
		}
		var dediMgr = $('#dedi-mgr').prop('checked') ? 'on' : '';
		var tutorUuid = $('[istutor="true"]').attr('muuid');
		$('#saveBtn').prop('disabled', true);
		$('#error-msg').hide();
		$('#success-msg').hide();
		$('#saving-msg').show();
		var serializedCurrent = roomplanner.serialize();
		$.post('?do=roomplanner&locationid=' + locationId,
			{ token: TOKEN, action: 'save', serializedRoom: serializedCurrent, managerip: managerip, dedimgr: dediMgr, tutoruuid: tutorUuid }
		).done(function ( data ) {
			if (data.indexOf('SUCCESS') !== -1) {
				window.close();
				// If window.close() failed, we give some feedback and remember the state as saved
				$('#success-msg').show();
				plannerLoadState = serializedCurrent;
				return;
			}
			$('#error-msg').text('Error: ' + data).show();
		}).fail(function (jq, textStatus, errorThrown) {
			$('#error-msg').text('AJAX save call failed: ' + textStatus + ' (' + errorThrown + ')').show();
		}).always(function() {
			$('#saveBtn').prop('disabled', false);
			$('#saving-msg').hide();
		});
	});
	
	$('#zoom-out').click(function() {
		roomplanner.slider.slider('value', roomplanner.settings.scale - 10);
	});
	
	$('#zoom-in').click(function() {
		roomplanner.slider.slider('value', roomplanner.settings.scale + 10);
	});

	$('#zoom-fit').click(function() {
		roomplanner.fitContent();
	});
}

var translation = {
	"muuid" : "UUID",
	"mac_address" : "MAC",
	"ip" : "IP",
	"hostname": "Hostname",

	"wall-horizontal" : "Wand (horizontal)",
	"wall-vertical" : "Mauer (vertikal)",
	"window-horizontal" : "Fenster",
	"window-vertical" : "Fenster",
	"door-nw" : "Tür",
	"door-ne" : "Tür",
	"door-sw" : "Tür",
	"door-se" : "Tür",
	"door-wn" : "Tür",
	"door-ws" : "Tür",
	"door-en" : "Tür",
	"door-es" : "Tür",			
	//"pc" : "PC",
	"pc-east" : "PC",
	"pc-south" : "PC",
	"pc-west" : "PC",
	"pc-north" : "PC",
	"copier" : "Kopierer",
	"printer" : "Drucker",
	"telephone" : "Telefon",
	"flatscreen" : "Flatscreen",
	"lamp" : "Schreibtischlampe",
	"tvcamera" : "Projektor",
	"4chairs1squaretable" : "4 Stühle und ein quadratischer Tisch",
	//"6chairs1table" : "6 Stühle und ein Tisch",
	"6chairs1table-horizontal" : "6 Stühle und ein Tisch",
	"6chairs1table-vertical" : "6 Stühle und ein Tisch",
	//"8chairs1conferencetable" : "8 Stühle und 1 Konferenztisch",
	"8chairs1conferencetable-horizontal" : "8 Stühle und 1 Konferenztisch",
	"8chairs1conferencetable-vertical" : "8 Stühle und 1 Konferenztisch",
	//"armchair" : "Sessel",
	"armchair-east" : "Sessel",
	"armchair-south" : "Sessel",
	"armchair-west" : "Sessel",
	"armchair-north" : "Sessel",
	//"chair" : "Stuhl",
	"chair-east" : "Stuhl",
	"chair-south" : "Stuhl",
	"chair-west" : "Stuhl",
	"chair-north" : "Stuhl",
	//"chair2" : "Stuhl",
	"chair2-east" : "Stuhl",
	"chair2-south" : "Stuhl",
	"chair2-west" : "Stuhl",
	"chair2-north" : "Stuhl",
	//"classroomdesk" : "Klassenzimmerpult",
	"classroomdesk-east" : "Klassenzimmerpult",
	"classroomdesk-south" : "Klassenzimmerpult",
	"classroomdesk-west" : "Klassenzimmerpult",
	"classroomdesk-north" : "Klassenzimmerpult",
	//"classroomdeskchair" : "Klassenzimmerpult mit Stuhl",
	"classroomdeskchair-east" : "Klassenzimmerpult mit Stuhl",
	"classroomdeskchair-south" : "Klassenzimmerpult mit Stuhl",
	"classroomdeskchair-west" : "Klassenzimmerpult mit Stuhl",
	"classroomdeskchair-north" : "Klassenzimmerpult mit Stuhl",
	//"classroomtable" : "Klassenzimmertisch",
	"classroomtable-east" : "Klassenzimmertisch",
	"classroomtable-south" : "Klassenzimmertisch",
	"classroomtable-west" : "Klassenzimmertisch",
	"classroomtable-north" : "Klassenzimmertisch",
	//"classroomtablechair" : "Klassenzimmertisch mit Stuhl",
	"classroomtablechair-east" : "Klassenzimmertisch mit Stuhl",
	"classroomtablechair-south" : "Klassenzimmertisch mit Stuhl",
	"classroomtablechair-west" : "Klassenzimmertisch mit Stuhl",
	"classroomtablechair-north" : "Klassenzimmertisch mit Stuhl",
	//"coatrack" : "Garderobe",
	"coatrack-east" : "Garderobe",
	"coatrack-south" : "Garderobe",
	"coatrack-west" : "Garderobe",
	"coatrack-north" : "Garderobe",
	//"conferencetable" : "Konferenztisch",
	"conferencetable-horizontal" : "Konferenztisch",
	"conferencetable-vertical" : "Konferenztisch",
	//"couch" : "Couch",
	"couch-east" : "Couch",
	"couch-south" : "Couch",
	"couch-west" : "Couch",
	"couch-north" : "Couch",
	//"greenchair" : "Stuhl",
	"greenchair-east" : "Stuhl",
	"greenchair-south" : "Stuhl",
	"greenchair-west" : "Stuhl",
	"greenchair-north" : "Stuhl",
	"lecturetheaterrow" : "Vorlesungssaalreihe mit Stühlen",
	"lecturetheaterrowseats" : "Vorlesungssaalstuhlreihe",
	//"locker" : "Schließfach",
	"locker-east" : "Schließfach",
	"locker-south" : "Schließfach",
	"locker-west" : "Schließfach",
	"locker-north" : "Schließfach",
	//"podium" : "Podium",
	"podium-east" : "Podium",
	"podium-south" : "Podium",
	"podium-west" : "Podium",
	"podium-north" : "Podium",
	//"roundeddesk" : "Eckschreibtisch",
	"roundeddesk-east" : "Eckschreibtisch",
	"roundeddesk-south" : "Eckschreibtisch",
	"roundeddesk-west" : "Eckschreibtisch",
	"roundeddesk-north" : "Eckschreibtisch",
	"roundtable" : "Runder Tisch",
	//"semicirculartable" : "Nierentisch",
	"semicirculartable-east" : "Nierentisch",
	"semicirculartable-south" : "Nierentisch",
	"semicirculartable-west" : "Nierentisch",
	"semicirculartable-north" : "Nierentisch",
	"squaretable" : "Quadratischer Tisch",
	//"studentdesk" : "Schülerpult",
	"studentdesk-east" : "Schülerpult",
	"studentdesk-south" : "Schülerpult",
	"studentdesk-west" : "Schülerpult",
	"studentdesk-north" : "Schülerpult",
	//"studentdeskchair" : "Schülerpult mit Stuhl",
	"studentdeskchair-east" : "Schülerpult mit Stuhl",
	"studentdeskchair-south" : "Schülerpult mit Stuhl",
	"studentdeskchair-west" : "Schülerpult mit Stuhl",
	"studentdeskchair-north" : "Schülerpult mit Stuhl",
	"papertray" : "Papierfach",
	"wastecan" : "Papierkorb",
	"plant" : "Pflanze",
	"plant2" : "Pflanze",
	"plant3" : "Pflanze",
	"projectionscreen" : "Projektionswand",
	"are you sure" : "Sind Sie sicher?"
};

function __(key) {
	if (translation[key]) {
		return translation[key];
	}

	return key;
}