-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
124 lines (93 loc) · 2.51 KB
/
script.js
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
$(function() {
var degree_start = 135,
cm_start = 9;
if ($('#verteiler').length > 0) {
var degrees = degree_start,
verteiler = $('#verteiler'),
degree = $('#degree'),
degree_h = $('#degree-h'),
cm = $('#cm'),
cm_h = $('#cm-h'),
meters = cm_start,
originalPos = verteiler.offset();
verteiler.rotate(degrees);
update = function() {
degrees = degrees % 360;
verteiler.rotate(degrees);
degree.text(degrees - degree_start);
degree_h.val(degrees - degree_start);
cm.text(meters - cm_start);
cm_h.val(meters - cm_start);
verteiler.css('left',originalPos.left + meters*2)
.css('top',originalPos.top);
};
// check for old values
if ($('#oldDegree').length > 0) {
degrees = degree_start + parseInt($('#oldDegree').text());
meters = cm_start + parseInt($('#oldCm').text());
$('select[name="team"]').val($('#oldTeam').text());
$('input[name="name"]').val($('#oldName').text());
$('input[name="comment"]').val($('#oldComment').text());
}
$('#rotate-min').click(function() {
degrees -= 2;
update();
return false;
});
$('#rotate-max').click(function() {
degrees += 2;
update();
return false;
});
$('#push-min').click(function() {
meters--;
update();
return false;
});
$('#push-max').click(function() {
meters++;
update();
return false;
});
var checked = false;
$('form').submit(function() {
if (checked) return true;
// check for name
$.get('?page=' + $('select[name="team"]').val(), function( data ) {
var ret = true;
//console.log(data);
$(data).find('span.realname').each(function() {
if ($(this).text() == $('input[name="name"]').val()) {
ret = false;
}
});
if (ret || confirm("Willst du die aktuelle Position überschreiben?")) {
checked = true;
$('form').submit();
} else {
checked = false;
}
}, 'html');
return false;
});
update();
verteiler.css('position','absolute');
}
if ($('#list').length > 0) {
var rows = $('#list tr');
rows.each(function() {
var tr = $(this),
cm = parseInt(tr.find('.cm').text()),
degree = parseInt(tr.find('.degree').text()),
td = tr.find('.verteiler'),
img = $('<img src="verteiler.png" alt="verteiler" style="width:100px"/>'),
pos;
td.append(img);
pos = img.offset();
img.rotate(degree + degree_start);
img.css('left', pos.left + (cm)*2+cm_start)
.css('top', pos.top)
.css('position', 'absolute');
});
}
});