1var rotas = '/rotas/'; 2var carregando = $("#carregando").hide(); 3 4$(document).ready(function() { 5 $(document) 6 .ajaxStart(function() { 7 carregando.show(); 8 }) 9 .ajaxStop(function() { 10 carregando.hide(); 11 }); 12 inicia(); 13 14 $('#texto').trumbowyg({ 15 lang: 'pt_br', 16 autogrow: true, 17 urlProtocol: true, 18 btns: [ 19 ['viewHTML'], 20 ['undo', 'redo'], // Only supported in Blink browsers 21 ['formatting'], 22 ['strong', 'em', 'del'], 23 ['superscript', 'subscript'], 24 ['link'], 25 ['insertImage'], 26 ['justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'], 27 ['unorderedList', 'orderedList'], 28 ['horizontalRule'], 29 ['removeformat'], 30 ['fullscreen'] 31 ] 32 }); 33}); 34 35function inicia() { 36 entrada(); 37 recupera(); 38 senha(); 39 menu(); 40 busca(); 41 atualiza_perfil(); 42 atualiza_avatar(); 43 envia_pesquisa(); 44 edita_pesquisa(); 45 apaga_pesquisa(); 46 reporta_bug(); 47 cria_usuario(); 48 $('[data-mask-data]').mask('00/00/0000 00:00'); 49} 50 51function menu() { 52 $(document).on('click', '.botao-menu, .fecha-menu, .menu-back', function() { 53 $('.menu').toggleClass('ativo'); 54 $('.menu-back').toggleClass('ativo'); 55 }); 56 $(document).on('click', '#abre_admin', function() { 57 $('.menu-admin').toggleClass('ativo'); 58 }); 59} 60 61function busca() { 62 $(document).on('click', '#abre_busca', function() { 63 $('.busca').toggleClass('active'); 64 }); 65 $(document).on('click', '#fecha_busca', function() { 66 $('.busca').toggleClass('active'); 67 $('#busca').focus(); 68 }); 69} 70 71function entrada() { 72 $(document).on('submit', '#form_entrada', function(evt) { 73 evt.preventDefault(); 74 75 var dados = $(this).serialize(); 76 progresso(); 77 78 var ajax = $.ajax({ 79 url: rotas + 'entrada/', 80 type: 'POST', 81 dataType: 'json', 82 data: dados 83 }); 84 85 ajax.done(function(data) { 86 dialogo('Resposta', data.resposta); 87 if (data.sucesso) { 88 progresso(); 89 window.location.href = "/"; 90 } 91 }); 92 93 ajax.fail(function(data) { 94 dialogo('Resposta', 'Ocorreu um erro inesperado.'); 95 }); 96 97 }); 98} 99 100function recupera() { 101 $(document).on('submit', '#form_recupera', function(evt) { 102 evt.preventDefault(); 103 104 var dados = $(this).serialize(); 105 progresso(); 106 107 var ajax = $.ajax({ 108 url: rotas + 'recupera/', 109 type: 'POST', 110 dataType: 'json', 111 data: dados 112 }); 113 114 ajax.done(function(data) { 115 dialogo('Resposta', data.resposta); 116 if (data.sucesso) { 117 progresso(); 118 window.location.href = "/entrada/"; 119 } 120 }); 121 122 ajax.fail(function(data) { 123 dialogo('Resposta', 'Ocorreu um erro inesperado.'); 124 console.log(data); 125 }); 126 127 }); 128} 129 130function senha() { 131 132 $(document).on('submit', '#form_senha', function(evt) { 133 evt.preventDefault(); 134 135 var dados = $(this).serialize(); 136 progresso(); 137 138 var ajax = $.ajax({ 139 url: rotas + 'senha/', 140 type: 'POST', 141 dataType: 'json', 142 data: dados 143 }); 144 145 ajax.done(function(data) { 146 dialogo('Resposta', data.resposta); 147 if (data.sucesso) { 148 progresso(); 149 window.location.href = "/entrada/"; 150 } 151 }); 152 153 ajax.fail(function(data) { 154 dialogo('Resposta', 'Ocorreu um erro inesperado.'); 155 }); 156 157 }); 158} 159 160function atualiza_perfil() { 161 162 $(document).on('submit', '#form_perfil', function(evt) { 163 evt.preventDefault(); 164 165 var dados = $(this).serialize(); 166 167 progresso(); 168 169 var ajax = $.ajax({ 170 url: rotas + 'atualiza-perfil/', 171 type: 'POST', 172 dataType: 'json', 173 data: dados, 174 }); 175 176 ajax.done(function(data) { 177 dialogo('Resposta', data.resposta); 178 if (data.sucesso) { 179 progresso(); 180 window.location.href = "/perfil/"; 181 } 182 }); 183 184 ajax.fail(function(data) { 185 dialogo('Resposta', 'Ocorreu um erro inesperado.'); 186 console.log(data.responseText); 187 }); 188 189 }); 190 191} 192 193function atualiza_avatar() { 194 195 $(document).on('click', '#fotoPerfil, #btnVatar', function() { 196 $("#avatar").click(); 197 198 document.getElementById("avatar").onchange = function(evt) { 199 var tgt = evt.target || window.event.srcElement, 200 files = tgt.files; 201 202 // FileReader support 203 if (FileReader && files && files.length) { 204 var fr = new FileReader(); 205 fr.onload = function() { 206 $(".avatar").attr("src", fr.result); 207 $('#form_avatar').submit(); 208 }
209 fr.readAsDataURL(files[0]); 210 } else { 211 // fallback -- perhaps submit the input to an iframe and temporarily store 212 // them on the server until the user's session ends. 213 } 214 } 215 }); 216 217 $(document).on('submit', '#form_avatar', function(evt) { 218 evt.preventDefault(); 219 220 var avatar = $('#avatar').prop('files')[0]; 221 var dados = new FormData(); 222 dados.append('avatar', avatar); 223 224 var ajax = $.ajax({ 225 enctype: 'multipart/form-data', 226 url: rotas + 'atualiza-avatar/', 227 type: 'POST', 228 dataType: 'json', 229 data: dados, 230 processData: false, 231 contentType: false, 232 cache: false, 233 timeout: 60000 234 }); 235 236 ajax.done(function(data) { 237 // dialogo('Resposta', data.resposta); 238 window.location.reload(); 239 }); 240 241 ajax.fail(function(data) { 242 dialogo('Resposta', 'Ocorreu um erro inesperado.'); 243 console.log(data); 244 }); 245 246 }); 247} 248 249function envia_pesquisa() { 250 $(document).on('submit', '#form_pesquisa', function(evt) { 251 evt.preventDefault(); 252 253 var projeto = $("#projeto").val(); 254 var doi = $("#doi").val(); 255 var autor = $("#autor").val(); 256 var coautor = $("#coautor").val(); 257 var titulo = $("#titulo").val(); 258 //var anexo = $('#anexo').prop('files')[0]; 259 var editor = $("#texto").html(); 260 261 var form = $('#form_pesquisa')[0]; 262 var data = new FormData(form); 263 data.append('projeto', projeto); 264 data.append('doi', doi); 265 data.append('autor', autor); 266 data.append('coautor', coautor); 267 data.append('titulo', titulo); 268 //data.append('anexo' , anexo); 269 data.append('editor', editor); 270 271 var ajax = $.ajax({ 272 enctype: 'multipart/form-data', 273 url: rotas + 'cria-pesquisa/', 274 type: 'POST', 275 dataType: 'json', 276 data: data, 277 processData: false, 278 contentType: false, 279 cache: false, 280 timeout: 60000 281 }); 282 283 ajax.done(function(data) { 284 dialogo('Resposta', data.resposta); 285 }); 286 287 ajax.fail(function(data) { 288 dialogo('Resposta', 'Ocorreu um erro inesperado.'); 289 console.log(data.responseText); 290 }); 291 292 }); 293} 294 295function edita_pesquisa() { 296 $(document).on('submit', '#form_edita_pesquisa', function(evt) { 297 evt.preventDefault(); 298 299 var slug = $("#slug").val(); 300 var doi = $("#doi").val(); 301 var autor = $("#autor").val(); 302 var coautor = $("#coautor").val(); 303 var editor = $("#texto").html(); 304 305 var form = $('#form_pesquisa')[0]; 306 var data = new FormData(form); 307 308 data.append('slug', slug); 309 data.append('doi', doi); 310 data.append('autor', autor); 311 data.append('coautor', coautor); 312 data.append('editor', editor); 313 314 var ajax = $.ajax({ 315 enctype: 'multipart/form-data', 316 url: rotas + 'edita-pesquisa/', 317 type: 'POST', 318 dataType: 'json', 319 data: data, 320 processData: false, 321 contentType: false, 322 cache: false, 323 timeout: 60000 324 }); 325 326 ajax.done(function(data) { 327 dialogo('Resposta', data.resposta); 328 }); 329 330 ajax.fail(function(data) { 331 dialogo('Resposta', 'Ocorreu um erro inesperado.'); 332 console.log(data.responseText); 333 }); 334 335 }); 336} 337 338function apaga_pesquisa() { 339 $(document).on('submit', '#form_apaga_pesquisa', function(evt) { 340 evt.preventDefault(); 341 342 var data = $(this).serialize(); 343 344 var ajax = $.ajax({ 345 url: rotas + 'apaga-pesquisa/', 346 type: 'POST', 347 dataType: 'json', 348 data: data, 349 timeout: 60000 350 }); 351 352 ajax.done(function(data) { 353 dialogo('Resposta', data.resposta); 354 window.location.href = "../../"; 355 }); 356 357 ajax.fail(function(data) { 358 dialogo('Resposta', 'Ocorreu um erro inesperado.'); 359 console.log(data.responseText); 360 }); 361 362 }); 363} 364 365//Exibe dialogos ao UI 366function dialogo(titulo, texto) { 367 368 var dialogo_dom = $('#dialogo'); 369 var dialogo_titulo_dom = $('#dialogoTitulo'); 370 var dialogo_texto_dom = $('#dialogoTexto'); 371 var dialogo_acoes_dom = $('#dialogoAcoes'); 372 373 dialogo_titulo_dom.html(titulo); 374 dialogo_texto_dom.html(texto); 375 dialogo_acoes_dom.show(); 376 dialogo_dom.modal('show'); 377} 378 379function progresso() { 380 carregando.show(); 381 // dialogo('Aguarde', 'Carregando...'); 382 // $('#dialogoAcoes').hide(); 383} 384 385function reporta_bug() { 386 387 $(document).on('submit', '#form_bug', function(evt) { 388 evt.preventDefault(); 389 390 var dados = $(this).serialize(); 391 392 progresso(); 393 394 var ajax = $.ajax({ 395 url: rotas + 'reporta-bug/', 396 type: 'POST', 397 dataType: 'json', 398 data: dados, 399 }); 400 401 ajax.done(function(data) { 402 dialogo('Resposta', data.resposta); 403 if (data.sucesso) { 404 $('#limparForm').click(); 405 } 406 }); 407 408 ajax.fail(function(data) { 409 dialogo('Resposta', 'Ocorreu um erro inesperado.'); 410 console.log(data.responseText); 411 }); 412 413 }); 414 415} 416 417function cria_usuario() { 418 419 $(document).on('submit', '#form_usuario', function(evt) { 420 evt.preventDefault(); 421 422 var dados = $(this).serialize(); 423 424 progresso(); 425 426 var ajax = $.ajax({
427 url: rotas + 'cria-usuario/', 428 type: 'POST', 429 dataType: 'json', 430 data: dados, 431 }); 432 433 ajax.done(function(data) { 434 dialogo('Resposta', data.resposta); 435 if (data.sucesso) { 436 $('#limparForm').click(); 437 } 438 }); 439 440 ajax.fail(function(data) { 441 dialogo('Resposta', 'Ocorreu um erro inesperado.'); 442 console.log(data.responseText); 443 }); 444 445 }); 446 447}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.