Guest User

Untitled

a guest
May 24th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. // In the order it is defined at myfile.js, which is loaded after jquery.js
  2.  
  3. var generic_check = function (url, callback) {
  4. jQuery.getJSON(url, callback);
  5. };
  6.  
  7.  
  8. // Here there is a lot of experimentation on a trial and error basis... I had some
  9. // problem converting this from MochiKit (where I used a swap dom method) to jQuery
  10. var generic_display = function (id, url, am_an, tipo_plural, tipo_singular, tempo, dados) {
  11. var destino = jQuery("<div id='" + id + "'></div>");
  12. if (dados.quantidade > 1) {
  13. destino.append("<a href='" + url + "'>Há " + dados.quantidade +
  14. am_an + 's ' + tipo_plural + ' ' + tempo + "</a>");
  15. } else if (dados.quantidade == 1) {
  16. destino.append("<a href='" + url + "'>Há 1 " +
  17. am_an + tipo_singular + ' ' + tempo + "</a>");
  18. }
  19. if (dados.quantidade >= 1) {
  20. jQuery(id).replaceWith(destino);
  21. } else {
  22. jQuery(id).replaceWith('');
  23. }
  24. };
  25.  
  26.  
  27. var displayConcessoesPendentes = function (dados) {
  28. generic_display('concessoes-pendentes',
  29. '/pendencias/concessoes_pendentes/',
  30. 'registro',
  31. 'aguardando concessão',
  32. 'aguardando concessão',
  33. '',
  34. dados);
  35. };
  36.  
  37. var checarConcessoesPendentes = function () {
  38. this.generic_check('/pendencias/checar_concessoes_pendentes/?' +
  39. 'tg_random=' + timestamp(),
  40. this.displayConcessoesPendentes);
  41. };
  42.  
  43. var g2c = new Object();
  44. g2c.alertas = function() {
  45. this.timestamp = timestamp;
  46.  
  47. this.generic_check = generic_check;
  48. this.generic_display = generic_display;
  49.  
  50. this.checarAmostrasAguardandoLiberacao = checarAmostrasAguardandoLiberacao;
  51. this.checarAmostrasNaoFracionadas = checarAmostrasNaoFracionadas;
  52. this.checarAmostrasNaoRecebidas = checarAmostrasNaoRecebidas;
  53. this.checarAmostrasVencendo = checarAmostrasVencendo;
  54. this.checarConcessoesPendentes = checarConcessoesPendentes;
  55.  
  56. this.displayAmostrasAguardandoLiberacao = displayAmostrasAguardandoLiberacao;
  57. this.displayAmostrasNaoFracionadas = displayAmostrasNaoFracionadas;
  58. this.displayAmostrasNaoRecebidas = displayAmostrasNaoRecebidas;
  59. this.displayAmostrasVencendo = displayAmostrasVencendo;
  60. this.displayConcessoesPendentes = displayConcessoesPendentes;
  61. }
Add Comment
Please, Sign In to add comment