-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
686 lines (681 loc) · 26.7 KB
/
index.html
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
<!DOCTYPE html>
<html>
<head>
<title>Lista de Tarefas</title>
<meta charset='utf-8'/>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta content="Aplicação para Gerenciamento de tarefas usando API do Google." name="description">
<meta content="Daniel Rosa, https://play.google.com/store/apps/developer?id=Daniel+Rosa " name="author">
<link href="./css/bootstrap.min.css" rel="stylesheet">
<link href="./css/index.animate.min.css" rel="stylesheet" type="text/css"/>
<link href="./css/responsive.min.css" rel="stylesheet" type="text/css"/>
<link href="./css/green.css" id="changeable-colors" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" href="./css/header-nav.css">
<link href="./css/style.min.css" rel="stylesheet" type="text/css"/>
<link href="./css/docs.css" rel="stylesheet" type="text/css"/>
<!-- Google Font Begins -->
<link href='https://fonts.googleapis.com/css?family=Black+Ops+One' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Roboto:400,300,300italic,400italic,500,500italic,700italic,700,900,900italic' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Raleway:400,700,600,500,300,200,100,800,900' rel='stylesheet' type='text/css'>
<style>
tr{
border-top:1px solid silver;
}
th, buttom, table ,tr ,td{
text-align: center;
vertical-align: middle;
}
.table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th {
text-align: center;
vertical-align: middle;
}
@keyframes animacaorolagem {
0% { opacity: 0; }
50% { opacity: .5; }
100% { opacity: 1; }
}
.iconeanimacao {
-webkit-animation:animacaorolagem 1s infinite;
-moz-animation: animacaorolagem 1s infinite;
-webkit-animation-delay: .1s;
-moz-animation-delay: .1s;
-webkit-animation-direction: alternate;
}
.iconeanimacao2 {
-webkit-animation:animacaorolagem 1s infinite;
-moz-animation: animacaorolagem 1s infinite;
-webkit-animation-delay: .2s;
-moz-animation-delay: .2s;
-webkit-animation-direction: alternate;
}
@keyframes fa-spin {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(359deg);
transform: rotate(359deg);
}
}
.fa-spin {
-webkit-animation: fa-spin 2s infinite linear;
animation: fa-spin 2s infinite linear;
}
.bordastabelatarefas{
border-bottom: 1px solid #ddd;
border-left: 1px solid #ddd;
border-right: 1px solid #ddd;
border-bottom: 1px solid #ddd;
}
</style>
</head>
<body id="home">
<div id="pageloader" style="background-color: transparent;">
<div id="iconepageloader" class="loader-item fa fa-spin colored-border" style="background-color: transparent;"></div>
</div>
<header id="header">
<div class="bg-overlay pattern"></div>
<div id="navigation" class="navbar navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button data-target=".bs-navbar-collapse" data-toggle="collapse" type="button" class="navbar-toggle">
<span class="sr-only">Alterar navegação</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span>
</button>
<a class="navbar-brand">Lista de Tarefas</a>
</div>
<nav id="topnav" role="navigation" class="collapse navbar-collapse bs-navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="#duvidas">Dúvidas</a></li>
<li><a href="#" id="btnlogin" style="display:none; class="login-link">Entrar</a></li>
<li><a href="#" id="btnsair" style="display:none; class="logof-link">Sair</a></li>
</ul>
</nav>
</div>
</div>
<div class="container" id='telaapresentacao'>
<div class="row" style="margin-top:5%">
<div class="col-md-12 intro-text">
<div class="main">
<h2>Crie e edite e consulte as <span class="text-color">Listas de Tarefas</span> vinculadas a sua conta do Gmail</h2>
</div>
</div>
</div>
<div class="row" style="margin-top:2%">
<div class="col-md-12 intro-text">
<div class="main">
<span id="btnlogin2" style="display:none;"><a href="" target="_blank" class="btn slide-btn bg-inverse">Entrar</a></span>
</div>
</div>
</div>
<div class="row" style="display:none;margin-top:5%" id="divnomeusuario">
<div class="col-md-12 intro-text">
<div class="main">
<h3>Bem vindo <span class="text-color" id='nomeusuario'></span></h3>
</div>
</div>
</div>
<div class="row diviconeanimacao" style="margin-top:5%;display:none">
<div class="col-md-12 intro-text">
<button style="background-color: transparent;border: transparent;" onclick="moveScroll('#rowprincipal')" class="glyphicon glyphicon-menu-down iconeanimacao" aria-hidden="true"></button>
</div>
<div class="col-md-12 intro-text">
<button style="background-color: transparent;border: transparent;" onclick="moveScroll('#rowprincipal')" class="glyphicon glyphicon-menu-down iconeanimacao2" aria-hidden="true"></button>
</div>
</div>
</div>
</header>
<section id="principal">
<div class='row' style='margin-top:5%;margin-bottom:5%;'>
<div class="container">
<div class="col-xs-12 col-sm-12 col-md-12" id='rowprincipal' style="display:none">
<h1 align="center">Listas de Tarefas</h1>
<div class="input-group">
<input id='inputtitulonovalista' style="position:initial;" maxlength='30' type="text" class="form-control" placeholder="Nova Lista">
<span class="input-group-btn">
<button id='btncriaListadeTarefas' class="btn btn-default" type="button">Criar</button>
</span>
</div>
<table id="lista" style='margin-top:5%;' class="table table-hover">
</table>
</div>
</div>
</div>
</section>
<hr>
<section id="duvidas" style='margin-top:10%;margin-bottom:1%;'>
<div class='row' style='margin-top:5%;margin-bottom:15%;'>
<div class="container">
<div class="col-xs-12 col-sm-12 col-md-12">
<h1 align="center">Dúvidas</h1>
<p class="lead">Use o Lista de tarefas para gerenciar seu Google Tarefas. Basta clicar no botão ENTRAR e utilizar sua conta do Google para fazer login.</p>
<a href="https://github.com/danielcordeirorosa/To-do-list" target="_blank">Maiores informações</a>
<br>
<a href="https://support.google.com/mail/answer/106237" target="_blank">Dúvidas Google Task</a>
</div>
</div>
</div>
</section>
<section id="copyright" class="index-copyright">
<div class="container">
<div class="row social-media animated" data-animation="fadeInUp" data-animation-delay="400">
<div class="col-md-12">
<a href="https://github.com/danielcordeirorosa/To-do-list" target="_blank">GitHub</a>
</div>
</div>
<div class="row">
<div class="col-md-12 text-center" style="margin-top:9px">
<a href="terms.html">Terms</a> | <a href="privacy.html">Privacy Policy</a>
</div>
<div class="col-md-12 text-center">
<p>Copyright 2017, Daniel Rosa.</p>
</div>
</div>
</div>
</section>
<script src="./js/jquery.min.js"></script>
<script src="./js/bootstrap.min.js"></script>
<script type="text/javascript" src="./js/bootstrapValidator.min.js"></script>
<script type="text/javascript" src="./js/jquery.sticky.js"></script>
<!-- Overlay -->
<script type="text/javascript" src="./js/modernizr.js"></script>
<!-- Screenshot -->
<script type="text/javascript" src="./js/jquery.flexisel.min.js"></script>
<!-- Portfolio -->
<script type="text/javascript" src="./js/jquery.prettyPhoto.min.js" ></script>
<!-- Smooth scrolling -->
<script type="text/javascript" src="./js/jquery.easing.1.3.js"></script>
<!-- Counting Section -->
<script type="text/javascript" src="./js/jquery.appear.js"></script>
<!-- Page loader -->
<script type="text/javascript" src="./js/effect.min.js"></script>
<!-- Twitter -->
<script src="./js/jquery.cookie.min.js"></script>
<!-- Carousel -->
<script type="text/javascript" src="./js/carousel.min.js"></script>
<!-- Custom -->
<script type="text/javascript" src="./js/custom.min.js"></script>
<script>
// Enter an API key from the Google API Console:
// https://console.developers.google.com/apis/credentials
var apiKey = 'AIzaSyDgRwdbQT8jfzGW4qHeOBi4dqeifJUtreM';
// Client ID and API key from the Developer Console
var CLIENT_ID = '1017346446163-v1v6nqbt59r88ssqh3lunefaujmk0b4j.apps.googleusercontent.com';
// Array of API discovery doc URLs for APIs used by the quickstart
var DISCOVERY_DOCS = ["https://www.googleapis.com/discovery/v1/apis/tasks/v1/rest","https://people.googleapis.com/$discovery/rest?version=v1"];
// Authorization scopes required by the API; multiple scopes can be
// included, separated by spaces.
var SCOPES = 'https://www.googleapis.com/auth/tasks';
var btnlogin = document.getElementById('btnlogin');
var btnlogin2 = document.getElementById('btnlogin2');
var btnsair = document.getElementById('btnsair');
var rowprincipal = document.getElementById('rowprincipal');
var carregamentopendente=false;
/**
* On load, called to load the auth2 library and API client library.
*/
function handleClientLoad() {
gapi.load('client:auth2', iniciaCliente);
}
/**
* Initializes the API client library and sets up sign-in state
* listeners.
*/
function iniciaCliente() {
carregando(true);
gapi.client.init({
apiKey: apiKey,
discoveryDocs: DISCOVERY_DOCS,
clientId: CLIENT_ID,
scope: SCOPES
}).then(function () {
// Listen for sign-in state changes.
gapi.auth2.getAuthInstance().isSignedIn.listen(atualizaStatusSessao);
// Handle the initial sign-in state.
atualizaStatusSessao(gapi.auth2.getAuthInstance().isSignedIn.get());
btnlogin.onclick = handleAuthClick;
btnlogin2.onclick = handleAuthClick;
btnsair.onclick = handleSignoutClick;
carregando(false);
}, function(reason) {
carregando(false);
console.log(reason);
alert("Desculpe, ocorreu um erro.")
});
}
/**
* Called when the signed in status changes, to update the UI
* appropriately. After a sign-in, the API is called.
*/
function atualizaStatusSessao(ativa) {
if (ativa) {
btnlogin.style.display = 'none';
btnlogin2.style.display = 'none';
rowprincipal.style.display = 'block';
btnsair.style.display = 'block';
$('#btncriaListadeTarefas').on('click',function(){
var novotitulo=$("#inputtitulonovalista").val();
criaListadeTarefas(novotitulo);
});
buscaNomeUsuario();
listaListasdeTarefas();
} else {
btnlogin.style.display = 'block';
btnlogin2.style.display = 'block';
rowprincipal.style.display = 'none';
btnsair.style.display = 'none';
escondeNomeUsuario();
$('#lista').html("<thead><tr><th>#</th><th>Nome da Lista</th><th>Data criação</th><th>Tarefas</th><th>Ações</th></tr></thead>");
}
}
function exibeNomeUsuario(nome)
{
$('#divnomeusuario').show();
$('#nomeusuario').html("<h1 style='margin-top: -5%;'>"+nome+"</h1>");
$('.diviconeanimacao').show();
}
function escondeNomeUsuario()
{
$('#divnomeusuario').hide();
$('.diviconeanimacao').hide();
$('#nomeusuario').html("");
}
/**
* Sign in the user upon button click.
*/
function handleAuthClick(event) {
gapi.auth2.getAuthInstance().signIn();
}
/**
* Sign out the user upon button click.
*/
function handleSignoutClick(event) {
gapi.auth2.getAuthInstance().signOut();
}
function lookupCampoSituacao(s){
if(s=="completed")
return "Completa";
if(s=="needsAction")
return "Aguardando execução";
}
function lookupCampoData(data){
var data= new Date(data);
var min=data.getMinutes();
if((min+"").length==1)
{
min="0"+min;
}
var hr=data.getHours();
if((hr+"").length==1)
{
hr="0"+hr;
}
return (data.getDate()+"/"+(data.getMonth()+1)+"/"+data.getFullYear()+" "+hr+":"+min);
}
function lookupCampoNotas(task,txt){
txt=txt||"";
return "<textarea id='notas"+task+"' taskid='"+task+"' class='form-control' rows='2'>"+txt+"</textarea>";
}
function addListadeTarefas(tasklist){
if(!tasklist)
{
$('#lista').append("<tr><td scope='row'>"+($('#lista > tbody > tr').length+1)+"</td><td colspan='3' class='tdeditartitulo'>Nenhum Registro encontrado</td></tr>");
return;
}
var titulo=tasklist.title;
var id=tasklist.id;
var data=tasklist.updated;
var btndeletar="<button style='border:transparent;' tasklistid='"+id+"' type='button' class='btn btn-default glyphicon glyphicon-trash deletar"+id+"'></button>";
var btneditar="<button style='border:transparent;' tasklistid='"+id+"' type='button' class='btn btn-default glyphicon glyphicon-pencil editar"+id+"'></button>";
var btnabrirlistadetarefas="<a id='btnabrirlistadetarefas"+id+"' role='button' data-toggle='collapse' href='#collapse"+id+"' aria-expanded='false' aria-controls='collapse"+id+"' tasklistid='"+id+"' type='button'>Tarefas</a>";
var colunaslistadetarefas="<td id='indice"+id+"' scope='row'>"+($('#lista > tbody > .contador').length+1)+"</td><td class='tdeditartitulo' titulo='"+titulo+"'>"+titulo+"</td><td>"+lookupCampoData(data)+"</td><td>"+btnabrirlistadetarefas+"</td><td>"+btndeletar+btneditar+"</td>";
$('#lista').append("<tr id='tr"+id+"' class='contador'>"+colunaslistadetarefas+"</tr>");
var cabecalhotabela="<thead style='background-color: rgba(221, 221, 221, 0.22);' ><tr><th>Tarefa</th><th>Anotações</th><th>Status</th><th>Ações</th></tr></thead>";
var tabela="<table class='table table-hover bordastabelatarefas' id='tarefasdalista"+id+"' >"+cabecalhotabela+"</table>";
var div ="<div id='collapse"+id+"' style='margin:0% 3% 0% 3%' class='panel-collapse collapse in' role='tabpanel' aria-labelledby='headingOne'>"+tabela+"</div>";
$('#lista').append("<tr><td colspan='5' style='padding: 0px;'>"+div+"</td></tr>");
$('.deletar'+id).on('click',function(){
deletaListadeTarefas($(this).attr('tasklistid'));
});
$('.editar'+id).on('click',function(){
abrecampoeditalista($(this).attr('tasklistid'));
});
listaTarefasdasListasdeTarefas(id);
}
function addTarefa(tasklist,task){
if(!task)
{
$('#tarefasdalista'+tasklist).append("<tr><th colspan='5'>Nenhuma tarefa cadastrada</th></tr>");
return;
}
var campodata="Aberta em "+lookupCampoData(task.updated);
var camposituacao="<button id='btnconcluir"+task.id+"' class='btn btn-default btnconcluir"+task.id+"' taskid='"+task.id+"' style='margin-right: 2%;width:50%;' type='button'>Concluir</button></div>";
if(lookupCampoSituacao(task.status)=="Completa")
{
camposituacao="<button id='btnabrir"+task.id+"' class='btn btn-default btnabrir"+task.id+"' taskid='"+task.id+"' style='margin-right: 2%;width:50%;' type='button'>Reabrir tarefa</button></div>";
campodata="Concluido em "+lookupCampoData(task.updated);
}
var btndeletar="<button style='border:transparent;' tasklistid='"+tasklist+"' taskid='"+task.id+"' type='button' class='btn btn-default glyphicon glyphicon-trash deletar"+task.id+"'></button>";
var input="<input type='text' maxlength='30' class='form-control novotitulotask' placeholder='Novo titulo' value='"+task.title+"' taskid='"+task.id+"' id='ipuntnovotitulotask"+task.id+"' >";
var tds="<td>"+input+"</td><td>"+lookupCampoNotas(task.id,task.notes)+"</td><td>"+campodata+"</td><td colspan='2' >"+camposituacao+btndeletar+"</td>";
$('#tarefasdalista'+tasklist).prepend("<tr id='tr"+task.id+"' tasklistid='"+tasklist+"'>"+tds+"</tr>");
$('.deletar'+task.id).on('click',function(){
deletaTarefa($(this).attr('tasklistid'),$(this).attr('taskid'));
});
$('#notas'+task.id).on('change',function(){
salvaAnotacao($(this).attr('taskid'),$(this).val());
});
$('#ipuntnovotitulotask'+task.id).on('change',function(){
salvaTituloTarefa($(this).attr('taskid'),$(this).val());
});
$('#btnconcluir'+task.id).on('click',function(){
concluiTarefa($(this).attr('taskid'));
});
$('#btnabrir'+task.id).on('click',function(){
reabreTarefa($(this).attr('taskid'));
});
}
function abrecampoeditalista(tasklist){
removeCampoEditarListadeTarefas(tasklist);
var btnconfirmar="<button class='btn btn-default' id='btnsalvaedicao"+tasklist+"' tasklistid='"+tasklist+"' type='button'><span class='glyphicon glyphicon-ok'></span></button>";
var btncancelar="<button onclick=\"removeCampoEditarListadeTarefas('"+tasklist+"');\" class='btn btn-default' type='button'><span class='glyphicon glyphicon-remove'></span></button>";
var input="<input type='text' maxlength='30' class='form-control' placeholder='Novo titulo' id='ipuntnovotitulo"+tasklist+"'>";
$('#tr'+tasklist+' > .tdeditartitulo').append("<div class='input-group'>"+input+"<div class='input-group-btn'>"+btnconfirmar+btncancelar+"</div>");
$('#btnsalvaedicao'+tasklist).on('click',function(){
atualizaTituloListadeTarefas($(this).attr('tasklistid'),$('#ipuntnovotitulo'+$(this).attr('tasklistid')).val());
});
}
function removeCampoEditarListadeTarefas(tasklist)
{
$('#tr'+tasklist+' > .tdeditartitulo > .input-group').remove();
}
function atualizaTituloListadeTarefas(tasklist,novotitulo)
{
if(novotitulo.length<1)
{
return;
}
else if($( "td[titulo='"+novotitulo+"']" ).length>0)
{
exibeMsgErro("Titulo já cadastrado para outra tarefa.");
return;
}
carregando(true);
gapi.client.tasks.tasklists.update({
'tasklist':tasklist,
'id':tasklist,
'title':novotitulo
}).then(function(response) {
listaListasdeTarefas();
carregando(false);
}, function(reason){
alert('Erro: ' + reason.result.error.message);
carregando(false);
});
}
function salvaAnotacao(task,anotacao){
if(anotacao.length<1)
{
anotacao="";
}
carregando(true);
gapi.client.tasks.tasks.update({
'tasklist':$('#tr'+task).attr('tasklistid'),
'task':task,
'id':task,
'notes':anotacao
}).then(function(r){
exibeMsgSucesso("Anotação salva com sucesso.")
carregando(false);
},function(r){
alert('Erro o registro não foi atualizado.');
carregando(false);
});
}
function salvaTituloTarefa(task,novotitulo){
if(novotitulo.length<1)
{
return;
}
else if($( "td[titulo='"+novotitulo+"']" ).length>0)
{
exibeMsgErro("Titulo já cadastrado para outra Tarefa.");
return;
}
carregando(true);
gapi.client.tasks.tasks.update({
'tasklist':$('#tr'+task).attr('tasklistid'),
'task':task,
'id':task,
'title':novotitulo
}).then(function(r){
exibeMsgSucesso("Titulo "+novotitulo+" foi salvo com sucesso.");
carregando(false);
},function(r){
alert('Erro o registro não foi atualizado.');
carregando(false);
});
}
function concluiTarefa(task){
carregando(true);
gapi.client.tasks.tasks.update({
'tasklist':$('#tr'+task).attr('tasklistid'),
'task':task,
'id':task,
'status':'completed'
}).then(function(r){
exibeMsgSucesso("Tarefa foi concluida com sucesso.");
listaTarefasdasListasdeTarefas($('#tr'+task).attr('tasklistid'));
carregando(false);
},function(r){
alert('Erro o registro não foi atualizado.');
carregando(false);
});
}
function reabreTarefa(task){
carregando(true);
gapi.client.tasks.tasks.update({
'tasklist':$('#tr'+task).attr('tasklistid'),
'task':task,
'id':task,
'status':'needsAction'
}).then(function(r){
exibeMsgSucesso("Tarefa foi concluida com sucesso.");
listaTarefasdasListasdeTarefas($('#tr'+task).attr('tasklistid'));
carregando(false);
},function(r){
alert('Erro o registro não foi atualizado.');
carregando(false);
});
}
function listaListasdeTarefas() {
carregando(true);
gapi.client.tasks.tasklists.list({
}).then(function(response) {
$('#lista').html("<thead><tr><th>#</th><th>Nome da Lista</th><th>Data criação</th><th>Tarefas</th><th>Ações</th></tr></thead>");
var taskLists = response.result.items;
if (taskLists && taskLists.length > 0) {
for (var i = 0; i < taskLists.length; i++) {
addListadeTarefas(taskLists[i]);
}
} else {
addListadeTarefas(false);
}
carregando(false);
}, function(reason) {
alert('Erro: ' + reason.result.error.message);
carregando(false)
});
}
function listaTarefasdasListasdeTarefas(tasklist) {
carregando(true);
var btnnovo="<button class='btn btn-default btnnovo"+tasklist+"' id='btnnovo"+tasklist+"' tasklistid='"+tasklist+"' type='button'>Nova Tarefa</button></div>";
$('#tarefasdalista'+tasklist).html("<thead style='background-color: rgba(221, 221, 221, 0.22);' ><tr><th>Tarefa</th><th>Anotações</th><th>Status</th><th>Ações</th><th>"+btnnovo+"</th></tr></thead>");
$("#btnnovo"+tasklist).on('click',function(){
criaTarefa($(this).attr('tasklistid'));
});
gapi.client.tasks.tasks.list({'tasklist':tasklist}).then(function(response) {
var task=response.result.items;
if (task && task.length > 0) {
for (var i = 0; i < task.length; i++){
addTarefa(tasklist,task[i]);
}
} else {
addTarefa(tasklist,false);
}
carregando(false);
}, function(reason) {
alert('Erro: ' + reason.result.error.message);
carregando(false);
});
}
function criaListadeTarefas(titulo) {
if(carregamentopendente){
exibeMsgErro("Aguarde, ainda tem uma alteração pendente de carreamento.");
return;
}
if(titulo.length<1)
{
return;
}
else if($("td[titulo='"+titulo+"']").length>0)
{
exibeMsgErro("Titulo já cadastrado para outra Lista de Tarefa.");
return;
}
carregando(true);
gapi.client.tasks.tasklists.insert({'title':titulo}).then(function(response) {
addListadeTarefas(response.result);
moveScroll('#tr'+response.result.id);
carregando(false);
}, function(reason) {
alert('Erro: ' + reason.result.error.message);
carregando(false);
});
}
function criaTarefa(tasklist) {
if(carregamentopendente){
exibeMsgErro("Aguarde, ainda tem uma alteração pendente de carreamento.");
return;
}
carregando(true);
gapi.client.tasks.tasks.insert({'tasklist':tasklist}).then(function(response) {
listaTarefasdasListasdeTarefas(tasklist);
carregando(false);
},function(reason){
alert('Erro ao criar Tarefa');
carregando(false);
});
}
function moveScroll(seletor)
{
$('html, body').animate({scrollTop: $(seletor).offset().top}, 1000);
}
function deletaListadeTarefas(tasklist) {
carregando(true);
gapi.client.tasks.tasklists.delete({'tasklist':tasklist}).then(function(response) {
listaListasdeTarefas();
carregando(false);
}, function(reason) {
if($('#indice'+tasklist).html()==1)
{
exibeMsgErro('O google bloquea a exclusão da primeira lista de tarefas.');
}
else
{
alert('Erro: ' + reason.result.error.message);
}
carregando(false);
});
}
function deletaTarefa(tasklist,task) {
carregando(true);
gapi.client.tasks.tasks.delete({'tasklist':tasklist,'task':task}).then(function(resp) {
$('#tr'+task).remove();
carregando(false);
}, function(reason) {
if(reason.result.status==404)
{
alert('Erro: ' + reason.result.body);
}
else{
alert('Erro: ' + reason.result.error.message);
}
carregando(false);
});
}
function buscaNomeUsuario() {
carregando(true);
gapi.client.people.people.get({
'resourceName': 'people/me',
'requestMask.includeField': 'person.names'
}).then(function(resp) {
exibeNomeUsuario(resp.result.names[0].displayName);
carregando(false);
}, function(reason) {
alert('Erro: ' + reason.result.error.message);
carregando(false);
});
}
var tempomsgdeerro;
function exibeMsgErro(msg){
if($('.divalertadeerro'))
{
clearTimeout(tempomsgdeerro);
$($('.divalertadeerro > div > div')[0]).finish();
}
var html="<div class='row divalertadeerro' style='position:fixed;top:85%;width:100%;'><div class='col-xs-2 col-sm-2 col-md-2 col-lg-2'></div><div class='cl-xs-8 col-sm-8 col-md-8 col-lg-8' align='center'><div class='alert alert-danger' role='alert'>"+msg+"</div></div><div class='col-xs-2 col-sm-2 col-md-2 col-lg-2'></div></div>";
$('body').append(html);
tempomsgdeerro=setTimeout(function(){
$('.divalertadeerro > div > div').animate({opacity:'-=1'},2000,function(){
$('.divalertadeerro').remove();
});
}, 5000);
}
var tempomsgdesucesso;
function exibeMsgSucesso(msg){
if($('.divalertadesucesso'))
{
clearTimeout(tempomsgdesucesso);
$($('.divalertadesucesso')[0]).finish();
}
var html="<div class='row divalertadesucesso' style='position:fixed;top:85%;width:100%;'><div class='col-xs-2 col-sm-2 col-md-2 col-lg-2'></div><div class='cl-xs-8 col-sm-8 col-md-8 col-lg-8' align='center'><div class='alert alert-success' role='alert'>"+msg+"</div></div><div class='col-xs-2 col-sm-2 col-md-2 col-lg-2'></div></div>";
$('body').append(html);
tempomsgdesucesso=setTimeout(function(){
$('.divalertadesucesso').animate({opacity:'-=1'},2000,function(){
$('.divalertadesucesso').remove();
});
}, 5000);
}
</script>
<script>
$(window).scroll(function(){
if($(this).scrollTop()<700)
{
$("#navigation").show();
}
else
{
$('#navigation').hide();
}
});
function carregando(exibir){
carregamentopendente=exibir;
if(exibir)
{
$('#pageloader').show();
$('#iconepageloader').show();
}
else
{
setTimeout(function(){
$('#pageloader').hide();
$('#iconepageloader').hide();
},500);
}
}
</script>
<script async defer src="https://apis.google.com/js/api.js" onload="this.onload=function(){};handleClientLoad()" onreadystatechange="if (this.readyState === 'complete') this.onload()"></script>
</body>
</html>