Projekt

Obecné

Profil

Stáhnout (1.65 KB) Statistiky
| Větev: | Tag: | Revize:
1
/**
2
* Funkce zavola servlet, ktery odstrani diagram z databáze a ze serveru.
3
*
4
* @param id_diagram - id diagramu
5
*/
6
function deleteDiagram(id_diagram) {
7
	var really = confirm('Do you really want to remove diagram?');
8
	if (really === false) {
9
		return false;
10
	}
11

    
12
	$.ajax({
13
		url: 'api/diagram?id_diagram=' + id_diagram,
14
		type: 'DELETE',
15
		success: function(result) {
16
			$('#diagram_id_' + id_diagram).remove();
17
			$('#public_diagram_id_' + id_diagram).remove();
18
		},
19
	});
20
}
21

    
22
/**
23
* Funkce nalezne vsechny komponenty zobrazene ve viewportu, ulozi je jako json a odesle servletu.
24
* 
25
* @param id_diagram ID diagramu
26
*/
27
function saveDiagram(id_diagram) {
28
	var vertex_position = new Array(),
29
		vertex_position_counter = 0;
30
	
31
	$('g.vertex').each(function () {
32
		vertex_position[vertex_position_counter] = ' {"id":"' + $(this).attr('id') + '" , ' +
33
		'  "transform":"' + $(this).attr('transform') + '" }';
34
		vertex_position_counter++;
35
	});
36
	
37
	vertex_position.join(',');
38
	vertex_position = '{"vertices_position": [ ' + vertex_position + ' ]}';
39
	
40
	$.post('api/diagram', {
41
		id_diagram: id_diagram,
42
		vertices_position: vertex_position,
43
	}).done(function () {
44
		alert("Diagram saved.");
45
	}).fail(function () {
46
		alert("Error - Diagram not saved!");
47
	});
48
}
49

    
50
/**
51
* Funkce zobrazi vyskakovaci okno s potvrzenim
52
*
53
* @param id_diagram ID diagramu
54
* @param diagram_hash hash diagramu
55
* @returns {Boolean} true if reset confirmed
56
*/
57
function reset_diagram(id_diagram, diagram_hash) {
58
	var really = confirm('Do you want to reset components position and refresh page?');
59
	if (really === false) {
60
		return false;
61
	}
62

    
63
	$.post('api/diagram', {
64
		id_diagram: id_diagram,
65
		vertices_position: "",
66
	});
67

    
68
	return true;
69
}
(2-2/19)