Passed
Push — dev ( eba5ae...a64d90 )
by Salim
06:06
created

gaelO.js ➔ µ   A

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
/**
2
 Copyright (C) 2018-2020 KANOUN Salim
3
 This program is free software; you can redistribute it and/or modify
4
 it under the terms of the Affero GNU General Public v.3 License as published by
5
 the Free Software Foundation;
6
 This program is distributed in the hope that it will be useful,
7
 but WITHOUT ANY WARRANTY; without even the implied warranty of
8
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
 Affero GNU General Public Public for more details.
10
 You should have received a copy of the Affero GNU General Public Public along
11
 with this program; if not, write to the Free Software Foundation, Inc.,
12
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
13
 */
14
15
/**
16
 * check all require filds in a form before submit
17
 */
18
function checkForm(form) {
19
	 var inputs = form.elements;
20
		for (var i = 0; i < inputs.length; i++) {
21
			if(inputs[i].hasAttribute("required")){
22
		        if(inputs[i].value == ""){
23
		            // found an empty field
24
		        	alertifyError("Please fill in all fields");
25
		            return false;
26
		        }
27
			}
28
		}
29
	return true;
30
}
31
32
/**
33
 * Change color of key text value in the tables
34
 * @returns
35
 */
36
function changeColor(){
37
	
38
	//Polly fill for IE11 missing function
39
	if (!String.prototype.includes) {
40
		  Object.defineProperty(String.prototype, 'includes', {
41
		    value: function(search, start) {
42
		      if (typeof start !== 'number') {
43
		        start = 0
44
		      }
45
		      
46
		      if (start + search.length > this.length) {
47
		        return false
48
		      } else {
0 ignored issues
show
Comprehensibility introduced by
else is not necessary here since all if branches return, consider removing it to reduce nesting and make code more readable.
Loading history...
49
		        return this.indexOf(search, start) !== -1
50
		      }
51
		    }
52
		  })
53
	}
54
	
55
	
56
  //on parcours tout les tableaux (balises table)
57
  $("table:visible").each(function (i, el){
58
    //si la table a un id
59
    if(el.id != ""){
60
      //on parcours chaque clonne de la table (identifiée grace à son id)
61
      $('#'+el.id+' tr').each(function (i, el){
0 ignored issues
show
Unused Code introduced by
The parameter el is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
Unused Code introduced by
The parameter i is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
62
    	  
63
        $(this).find('td').each (function() {
64
          if( $(this).html().includes("Not Done") || $(this).html().includes("Refused") ){
65
            $(this).css('color', '#D53333');
66
          }
67
         else if( $(this).html().includes("Done") || $(this).html().includes("Accepted") ) {
68
            $(this).css('color', '#47B236)');
69
         }
70
         else if($(this).html().includes("Should be done") || $(this).html().includes("Wait Definitive Conclusion") || $(this).html().includes("Draft") || $(this).html().includes("Corrective Action Asked")){
71
            $(this).css('color', '#E29300');
72
        }
73
        });
74
      });
75
    }
76
77
  });
78
}
79
80
/**
81
 * Download documentation by id
82
 * @param id
83
 * @returns
84
 */
85
function downloadDocumentation(id){
86
	window.location="scripts/download_documentation.php?idDocumentation="+id;
87
}
88
89
function alertifyError(message){
90
	alertify.error(message);
0 ignored issues
show
Bug introduced by
The variable alertify seems to be never declared. If this is a global, consider adding a /** global: alertify */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
91
}
92
93
function alertifyWarning(message){
94
	alertify.warning(message);
0 ignored issues
show
Bug introduced by
The variable alertify seems to be never declared. If this is a global, consider adding a /** global: alertify */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
95
}
96
97
function alertifySuccess(message){
98
	alertify.success(message);
0 ignored issues
show
Bug introduced by
The variable alertify seems to be never declared. If this is a global, consider adding a /** global: alertify */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
99
}
100
101
function alertifyMessage(message) {
102
	alertify.message(message);
0 ignored issues
show
Bug introduced by
The variable alertify seems to be never declared. If this is a global, consider adding a /** global: alertify */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
103
}
104
105
function µ(str) {
106
	// Escape & < > " chars
107
	return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
108
}
109
110
111