-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyscript.js
279 lines (274 loc) · 10.1 KB
/
myscript.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
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
function CheckLogin(){
var x= getCookie("AutoLog")=== 'undefined'?"":getCookie("AutoLog");
var y= getCookie("sessioncook")=== 'undefined'?"":getCookie("sessioncook");
var xmlhttp=new XMLHttpRequest();
var flag;
xmlhttp.onloadend=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
flag= this.responseText;
if(flag==0){
window.location.href = "script/AccountManager.php";
}
}
}
xmlhttp.open("GET","script/CheckCookieVal.php?x="+x+"&y="+y,true);
xmlhttp.send();
//document.cookie = "sessioncook= ; expires = Thu, 01 Jan 1970 00:00:00 GMT";
}
function Login(email, password){
var xmlhttp=new XMLHttpRequest();
xmlhttp.onloadend=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("checkauth").innerHTML=this.responseText== "true"? "<lottie-player src='icon_json/loading.json' background='transparent' speed='1' style='width: 250px; height: 250px; margin: 0 auto;' loop autoplay></lottie-player>": this.responseText;
document.getElementById("checkauth").value= this.responseText;
}
}
console.log(this.responseText);
xmlhttp.addEventListener("loadend", CheckResult, false);
var check= document.getElementById("check").checked? "true": "false";
xmlhttp.open("GET","script/Login.php?email="+email+"&password="+password+"&check="+check,true);
xmlhttp.send();
}
function CheckResult(){
if(document.getElementById("checkauth").value=="true"){
window.location.href = "../";
}
}
function GetProfileInfo(){
var xmlhttp=new XMLHttpRequest();
xmlhttp.onloadend=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("profile").innerHTML=this.responseText;
}
}
xmlhttp.open("GET","script/RecoverProfileInfo.php",true);
xmlhttp.send();
}
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
function SendLogOut(){
console.log(getCookie("sessioncookie"));
document.cookie = "AutoLog= ; domain=cantierebuzi.it; path=/; expires = Thu, 01 Jan 1970 00:00:00 GMT";
document.cookie = "sessioncook= ; domain=cantierebuzi.it; path=/; expires = Thu, 01 Jan 1970 00:00:00 GMT";
console.log(getCookie("sessioncookie"));
window.location.href = "Login.html";
console.log(getCookie("sessioncookie"));
}
function CheckPasswordOnSign(){
var fpass= document.getElementById("fpassword").value;
var spass= document.getElementById("spassword").value;
if(fpass==spass){
document.getElementById("submit").setAttribute("onclick", "CreateOperaio()");
document.getElementById("notcorrect").innerHTML= "Ottimo!"
}
else{
document.getElementById("notcorrect").innerHTML= "Le password non corrispondono";
document.getElementById("submit").setAttribute("onclick", "");
}
}
function CreateOperaio(){
var xmlhttp=new XMLHttpRequest();
var allid = new Array("nome","cognome","nascita","luogo","email","CF","fpassword","SelectCantiere","SelectUtente");
xmlhttp.onloadend=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("notcorrect").innerHTML=this.responseText;
}
}
var url="script/CreateOp.php";
for(var s=0;s<allid.length;s++){
var sign= s==0?"?":"&";
url= url+sign+allid[s]+"="+document.getElementById(allid[s]).value;
}
xmlhttp.open("GET",url,true);
xmlhttp.send();
}
function GetCantiere(x){
var xmlhttp=new XMLHttpRequest();
xmlhttp.onloadend=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("SelectCantiere").innerHTML=this.responseText;
}
}
xmlhttp.open("GET","script/GetCantiere.php?index="+x,true);
xmlhttp.send();
}
function ProfileMobileManager(index){
var Keys= new Array("pills-home","pills-profile","pills-messages","pills-settings");
var width = (window.innerWidth > 0) ? window.innerWidth : screen.width;
if(width<560&&index==0){
document.getElementById("items-table").style="visibility: visible; max-height: 100%; max-width: 100%;";
document.getElementById("v-pills-tab").style="visibility: hidden; max-height: 0; max-width: 0;";
document.getElementById("goback").style="visibility: visible; max-height: 100%; max-width: 100%;";
}
else if(index==1){
document.getElementById("items-table").style="visibility: hidden; max-height: 0; max-width: 0;";
document.getElementById("v-pills-tab").style="visibility: visible; max-height: 100%; max-width: 100%;";
document.getElementById("goback").style="visibility: hidden; max-height: 0; max-width: 0;";
}
}
function GetWorkerHrs(){
var xmlhttp=new XMLHttpRequest();
xmlhttp.onloadend=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("ResultTable").innerHTML=this.responseText;
}
}
document.getElementById("ResultDiv").style= "display: block;";
xmlhttp.open("GET","script/GetWorkerHrs.php?month="+document.getElementById("Month").value,true);
xmlhttp.send();
}
function SearchWorkerCount(){
var xmlhttp=new XMLHttpRequest();
xmlhttp.onloadend=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("accordionExample").innerHTML=this.responseText;
}
}
xmlhttp.open("GET","script/workercount.php?Cantiere="+document.getElementById("SelectCantiere").value,true);
xmlhttp.send();
}
function GetDPI(){
var xmlhttp=new XMLHttpRequest();
xmlhttp.onloadend=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("SelectDPI").innerHTML=this.responseText;
}
}
xmlhttp.open("GET","script/GetDPI.php",true);
xmlhttp.send();
}
function GetDpiUsage(){
var xmlhttp=new XMLHttpRequest();
xmlhttp.onloadend=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("ResultTable").innerHTML=this.responseText;
}
}
document.getElementById("ResultDiv").style= "display: block;";
xmlhttp.open("GET","script/GetDpiUsage.php?dpi="+document.getElementById("SelectDPI").value,true);
xmlhttp.send();
}
function RecoverPassword(){
var xmlhttp=new XMLHttpRequest();
var email= document.getElementById("email").value;
console.log(email);
xmlhttp.onloadend=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("PasswordDiv").innerHTML=this.responseText;
}
}
xmlhttp.open("GET","script/PasswordRecover.php?email="+email,true);
xmlhttp.send();
setTimeout(function () {
window.location.href = "Login.html";
}, 10000);
}
function RedirectTimer(){
window.location.href = "Login.html";
}
function GetWorkerType(){
var xmlhttp=new XMLHttpRequest();
var cf= document.getElementById("CF").value;
var data= document.getElementById("data").value;
xmlhttp.onloadend=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("ResultTable").innerHTML=this.responseText;
}
}
document.getElementById("ResultDiv").style= "display: block;";
xmlhttp.open("GET","script/SearchWorkType.php?cf="+cf+"&data="+data,true);
xmlhttp.send();
}
function GetProfile(){
var x= getCookie("AutoLog")=== 'undefined'?"":getCookie("AutoLog");
var y= getCookie("sessioncook")=== 'undefined'?"":getCookie("sessioncook");
console.log(y);
console.log(x);
var xmlhttp=new XMLHttpRequest();
xmlhttp.onloadend=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("items-table").innerHTML=this.responseText;
var s=getCookie("name");
document.getElementById("title").innerHTML=s.replace("+"," ");
}
}
xmlhttp.open("GET","script/ProfileSection.php?x="+x+"&y="+y,true);
xmlhttp.send();
}
function SetNewPassword(){
var x= getCookie("AutoLog")=== 'undefined'?"":getCookie("AutoLog");
var y= getCookie("sessioncook")=== 'undefined'?"":getCookie("sessioncook");
var opass= document.getElementById("opass").value
var npass=document.getElementById("npass").value
var xmlhttp=new XMLHttpRequest();
xmlhttp.onloadend=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("PasswordResult").innerHTML=this.responseText;
}
}
xmlhttp.open("GET","script/SetNewPassword.php?x="+x+"&y="+y+"&npass="+npass+"&opass="+opass,true);
xmlhttp.send();
document.cookie = "AutoLog= ; domain=cantierebuzi.it; path=/; expires = Thu, 01 Jan 1970 00:00:00 GMT";
document.cookie = "sessioncook= ; domain=cantierebuzi.it; path=/; expires = Thu, 01 Jan 1970 00:00:00 GMT";
setTimeout(function () {
window.location.href = "Login.html";
}, 10000);
}
function SetNewMail(){
var x= getCookie("AutoLog")=== 'undefined'?"":getCookie("AutoLog");
var y= getCookie("sessioncook")=== 'undefined'?"":getCookie("sessioncook");
var epass= document.getElementById("epass").value
var nmail=document.getElementById("nmail").value
var xmlhttp=new XMLHttpRequest();
xmlhttp.onloadend=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("MailResult").innerHTML=this.responseText;
}
}
xmlhttp.open("GET","script/SetNewMail.php?x="+x+"&y="+y+"&nmail="+nmail+"&epass="+epass,true);
xmlhttp.send();
document.cookie = "AutoLog= ; domain=cantierebuzi.it; path=/; expires = Thu, 01 Jan 1970 00:00:00 GMT";
document.cookie = "sessioncook= ; domain=cantierebuzi.it; path=/; expires = Thu, 01 Jan 1970 00:00:00 GMT";
setTimeout(function () {
window.location.href = "Login.html";
}, 10000);
}
function DownloadData(){
var xmlhttp=new XMLHttpRequest();
var memail= document.getElementById("memail").value;
var x= getCookie("AutoLog")=== 'undefined'?"":getCookie("AutoLog");
var y= getCookie("sessioncook")=== 'undefined'?"":getCookie("sessioncook");
xmlhttp.onloadend=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("DataResult").innerHTML=this.responseText;
}
}
xmlhttp.open("GET","script/downloadData.php?memail="+memail+"&x="+x+"&y="+y,true);
xmlhttp.send();
}
function OnOver(x){
var mouseTarget= elementMouseIsOver =x;
mouseTarget.className+="border border-3 border-primary";
}
function OnExit(x){
var mouseTarget= elementMouseIsOver =x;
if(x.id!="dont-fade"){
mouseTarget.className="fade my-5 mx-2 shadow-lg ";
}
else {
mouseTarget.className="my-5 mx-2 shadow-lg ";
}
}