-
Notifications
You must be signed in to change notification settings - Fork 3
/
presence_siscad_tweak.user.js
80 lines (79 loc) · 3.01 KB
/
presence_siscad_tweak.user.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
// ==UserScript==
// @name SiscadPresence
// @author andvicoso
// @namespace andvicoso_siscad_tweak
// @description Hide students with more than 25% of absences and other stuff.
// @version 2.0
// @grant none
// @icon https://siscad-admin.ufms.br/favicon.ico
// @downloadURL https://github.com/andvicoso/siscad_tweak/raw/master/presence_siscad_tweak.user.js
// @include https://siscad-admin.ufms.br/titan.php?toSection=3&toAction=edit*
// @include https://siscad-admin.ufms.br/titan.php?toSection=303&toAction=edit*
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js
// @require https://raw.githubusercontent.com/jmosbech/StickyTableHeaders/master/js/jquery.stickytableheaders.min.js
// @require https://raw.githubusercontent.com/andvicoso/siscad_tweak/master/siscad_tweak_utils.js
// @require https://code.responsivevoice.org/responsivevoice.js
// ==/UserScript==
this.$ = this.jQuery = jQuery.noConflict(true);
//presence
var failed = 0;
var warning = 0;
$('.frequencia').prop('id', 'notas');
var all = $('#notas > tbody > tr:not(.cabecalho)');
var total = all.length;
all.each(function (index) {
var line = $(this);
var obj = line.find('[id^="f_"]').first();
var value = getValue(obj.val());
var presence = 'P';
if (isFailed(value)) {
var name = getData(line, 1);
failed++;
presence = 'F';
//change color for the students with more than 26% of absence
line.css('background-color', '#ff7d66'); //old tomato
}
else if (isWarning(value)) {
warning++;
//change color for the students with more than 19% of absences
line.css('background-color', 'khaki');
} /*set the defined presence to each input text field of the line
single click, multiple edition*/
var inputs = line.find('.input_hide');
inputs.each(function (index) {
//if not already filled
if (!$(this).val()) {
$(this).val(presence);
$(this).css('font-weight','Bold');
}
$(this).click(function () {
var currpresence = $(this).val();
inputs.each(function (index) {
$(this).val(currpresence);
$(this).css('font-weight','normal');
});
});
});
});
//summary table
appendSummaryTable(warning, failed, total);
//auto chamada
$('.caixaAzul').first().before('<div id="autochamanda" style="border: 1px solid black;"><input id="autochamada_btn" type="button" value="Auto Chamada [BETA-TEST]"><input type="checkbox" id="audio_autochamada" checked="checked">Com áudio</div>');
$('#autochamada_btn').click(function () {
all.each(function (index) {
var line = $(this);
var obj = line.find('[id^="f_"]').first();
var value = getValue(obj.val());
if (!isFailed(value)) {
var name = getData(line, 1);
if ($('#audio_autochamada').prop('checked')) {
responsiveVoice.speak(name, 'Brazilian Portuguese Female');
}
var presence = confirm(name) ? 'P' : 'F';
var inputs = line.find('.input_hide');
inputs.each(function (index) {
$(this).val(presence);
});
}
});
});