Advertisement
rdsedmundo

103T V0.4 - APR/13

Apr 11th, 2013
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     Arquivo: Principal.js
  3.     Referencia: http://pastebin.com/u/Kyl3
  4.    
  5.     -------------------
  6.     Criado por Edmundo Rodrigues (Kyl3)
  7.     (c) 2013
  8. */
  9. (top.location != self.location) ? top.location = self.location : null;
  10. $(function () {
  11.     if (navigator.userAgent.search("Chrome") == -1) alert("Para uma melhor exibição deste site, é recomendado usar o Google Chrome.", {
  12.             f: OPTIONS_SHOW_OR_NOT,
  13.             s: 0
  14.         });
  15.     setInterval(function () {
  16.         try {
  17.             $('label').each(function () {
  18.                 if ($(this).hasClass("select") == false && $(this).html().match(/option/gi)) $(this).addClass("select");
  19.             });
  20.             if (loggedin == true && typeof W == "object") {
  21.                 if ($.cookie("user") == null || $.cookie("user") == "" || $.cookie("pass") == null || $.cookie("pass") == "") {
  22.                     W.loggedin = false;
  23.                     alert("Sua sessão expirou.");
  24.                     dReload()
  25.                 }
  26.             }
  27.             $('input[type="submit"],input[type="button"],button').button().css("-webkit-appearance", "none").css("outline", "none");
  28.             $("input,textarea").css("outline", "none");
  29.             $('input[type="data"]').datepicker({
  30.                 yearRange: "2013:2013",
  31.                 monthNamesShort: ["Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez"],
  32.                 monthNames: ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"],
  33.                 minDate: Tdate,
  34.                 maxDate: "02/12",
  35.                 gotoCurrent: true,
  36.                 dayNamesShort: ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab"],
  37.                 dayNamesMin: ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab"],
  38.                 dayNames: ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado"],
  39.                 dateFormat: "dd/mm",
  40.                 currentText: "Hoje"
  41.             });
  42.             $("#act-accordion").accordion({
  43.                 heightStyle: "content"
  44.             });
  45.         } catch (a) {}
  46.     }, 1);
  47.  
  48.     $("#mc-form").motionCaptcha({
  49.         action: "#mc-action",
  50.         divId: "#mc",
  51.         cssClass: ".mc-active",
  52.         canvasId: "#mc-canvas",
  53.         shapes: ["triangle", "x", "rectangle", "check", "caret", "zigzag", "arrow", "leftbracket", "rightbracket", "v", "delete", "star", "pigtail"],
  54.         errorMsg: "Por favor, tente novamente.",
  55.         successMsg: "Sucesso!",
  56.         noCanvasMsg: "Seu navegador não suporta esse aplicativo - tente utilizar: Google Chrome"
  57.     }).submit(function () {
  58.         location.hash = "#" + this.action.split("#")[1];
  59.         return false
  60.     });
  61.     $("#g-last").load(__PREFIX + "show_actv.php?d=" + gToken(), {}, function (d) {
  62.         $(this).html(d);
  63.         var a = ["fade", "fold", "pulsate", "slide"],
  64.             b = (function () {
  65.                 return (a[Math.floor(Math.random() * a.length)])
  66.             });
  67.         $("#gsite").tabs({
  68.             fx: {
  69.                 height: 'toggle',
  70.                 opacity: 'toggle'
  71.             }
  72.         }).show(b(), 1500, function () {
  73.             $("#copyright").show(b(), 3000)
  74.         })
  75.     })
  76.     $("#l-forgot").click(function (event) {
  77.         var e = event,
  78.             refer = event.timeStamp;
  79.         Attach("g-last", "forgot.php?from=" + refer);
  80.         HideBox("Log");
  81.         return false;
  82.     });
  83. });
  84. $.fn.loading = function () {
  85.     $(this).html("<div id='pbar_text'>Carregando (0%)...</div><br><br><div id='progressbar' style='width:600px'></div>");
  86.     return this;
  87. }
  88. jQuery.fn.load = function (url, params, callback) {
  89.     $("#progressbar").progressbar();
  90.     if (typeof url !== "string" && _load) {
  91.         return _load.apply(this, arguments);
  92.     }
  93.  
  94.     var selector, response, type,
  95.         self = this,
  96.         off = url.indexOf(" ");
  97.  
  98.     if (off >= 0) {
  99.         selector = url.slice(off, url.length);
  100.         url = url.slice(0, off);
  101.     }
  102.  
  103.     // If it's a function
  104.     if (jQuery.isFunction(params)) {
  105.  
  106.         // We assume that it's the callback
  107.         callback = params;
  108.         params = undefined;
  109.  
  110.         // Otherwise, build a param string
  111.     } else if (params && typeof params == "object") {
  112.         type = "POST";
  113.     }
  114.  
  115.     // If we have elements to modify, make the request
  116.     if (self.length > 0) {
  117.         jQuery.ajax({
  118.             xhr: function () {
  119.                 var xhr = new W.XMLHttpRequest();
  120.                 xhr.upload.addEventListener("progress", function (evt) {
  121.                     if (evt.lengthComputable) {
  122.                         Percent = Math.round((100 * e.loaded / e.total));
  123.                         $('#progressbar').progressbar({
  124.                             value: Percent
  125.                         });
  126.                         $('#pbar_text').html(Percent + "%");
  127.                     }
  128.                 }, false);
  129.                 xhr.addEventListener('progress', function (e) {
  130.                     if (e.lengthComputable) {
  131.                         Percent = Math.round((100 * e.loaded / e.total));
  132.                         $('#progressbar').progressbar({
  133.                             value: Percent
  134.                         });
  135.                         $('#pbar_text').html(Percent + "%");
  136.                     }
  137.                 });
  138.                 return xhr;
  139.             },
  140.             url: url,
  141.  
  142.             // if "type" variable is undefined, then "GET" method will be used
  143.             type: type,
  144.             dataType: "html",
  145.             data: params
  146.         }).done(function (responseText) {
  147.  
  148.             // Save response for use in complete callback
  149.             response = arguments;
  150.  
  151.             self.html(selector ? jQuery("<div>").append(jQuery.parseHTML(responseText)).find(selector) : responseText);
  152.  
  153.         }).complete(callback && function (jqXHR, status) {
  154.             self.each(callback, response || [jqXHR.responseText, status, jqXHR]);
  155.         });
  156.     }
  157.  
  158.     return this;
  159. };
  160. $.fn.reset = function () {
  161.     $(this).each(function () {
  162.         this.reset()
  163.     });
  164.     return this
  165. };
  166. $.cookie = function (e, f, b) {
  167.     if (arguments.length > 1 && String(f) !== "[object Object]") {
  168.         b = jQuery.extend({}, b);
  169.         if (f == null || f == undefined) {
  170.             b.expires = -1
  171.         }
  172.         if (typeof b.expires == "number") {
  173.             var h = b.expires,
  174.                 d = b.expires = new Date();
  175.             d.setDate(d.getDate() + h)
  176.         }
  177.         f = String(f);
  178.         return (document.cookie = [encodeURIComponent(e), "=", b.raw ? f : encodeURIComponent(f), b.expires ? "; expires=" + b.expires.toUTCString() : "", b.path ? "; path=" + b.path : "", b.domain ? "; domain=" + b.domain : "", b.secure ? "; secure" : ""].join(""))
  179.     }
  180.     b = f || {};
  181.     var a, g = b.raw ? function (j) {
  182.             return j
  183.         } : decodeURIComponent;
  184.     return (a = new RegExp("(?:^|; )" + encodeURIComponent(e) + "=([^;]*)").exec(document.cookie)) ? g(a[1]) : null
  185. };
  186.  
  187. function Attach(b, a) {
  188.     if (a.search(__PREFIX) == -1 && a.search("admin/") == -1) {
  189.         a = __PREFIX + arguments[1]
  190.     }
  191.     return ($("#" + b).loading().load(a))
  192. }
  193.  
  194. function IsHuman(object) {
  195.     pCh = W.setInterval(function () {
  196.         if (location.hash == "#!/?isHuman=1&go=true") {
  197.             W.clearInterval(pCh);
  198.             (object.id.search("Add") !== -1) ? prefix = "a_" : prefix = "e_";
  199.             if (eval("object." + prefix + "mat.value") == -1) {
  200.                 prefix == "a_" ? ShowBox("Add", 1) : ShowBox("Edit", 1);
  201.                 alert("Selecione uma matéria!");
  202.                 return false
  203.             }(prefix == "a_") ? url = __PREFIX + "addA.php?d=" + gToken() : url = __PREFIX + "edit.php?d=" + gToken() + "&step=2&NOTICE_ID=" + $("#e_id").val();
  204.             if (prefix == "a_") {
  205.                 stuff = function () {
  206.                     $.post(url, {
  207.                         a_til: $("#a_til").val(),
  208.                         a_cont: $("#a_cont").val(),
  209.                         a_mat: $("#a_mat").val(),
  210.                         a_data: $("#a_data").val()
  211.                     }, function (c) {
  212.                         eval(c)
  213.                     })
  214.                 }
  215.  
  216.                 if (W.GCasync) {
  217.                     $.post("inc/other/google_calendar/Post.php", {
  218.                         t: $("#a_til").val(),
  219.                         c: $("#a_cont").val(),
  220.                         m: parseMat($("#a_mat").val()),
  221.                         d: $("#a_data").val()
  222.                     }, function (c) {
  223.                         k("G-Mail response: " + c, 1);
  224.                         if (c.search("Enviado") !== -1) stuff();
  225.                         else k("Ocorreu um erro no envio ao g-mail, tente novamente.");
  226.                     });
  227.                 } else {
  228.                     stuff();
  229.                 }
  230.             } else {
  231.                 $.post(url, {
  232.                     e_til: $("#e_til").val(),
  233.                     e_cont: $("#e_cont").val(),
  234.                     e_mat: $("#e_mat").val(),
  235.                     e_data: $("#e_data").val()
  236.                 }, function (c) {
  237.                     eval(c)
  238.                 })
  239.             }
  240.         }
  241.     }, 1000);
  242.     return false
  243. }
  244.  
  245. function ValidForm(b) {
  246.     if (b.id.search("Add") !== -1) {
  247.         prefix = "a_"
  248.     } else {
  249.         prefix = "e_"
  250.     }
  251.     for (var a in [prefix + "til", prefix + "cont", prefix + "data", prefix + "mat"]) {
  252.         if (a == prefix + "mat" && isNaN($("#" + a).val())) {
  253.             return alert("Valor inválido para data")
  254.         }
  255.         if ($("#" + a).val() == "") {
  256.             return alert("Preencha todos os campos!")
  257.         }
  258.     }
  259.     $("#g-last").slideUp(1500);
  260.     $("#is-human").fadeIn(1000);
  261.     IsHuman(b);
  262.     return true
  263. }
  264.  
  265. function ShowBox() {
  266.     objName = arguments[0], eShake = arguments[1] || 0;
  267.     switch (objName) {
  268.     case "Add":
  269.         if (!loggedin) {
  270.             login();
  271.             return ((k("Você precisa estar autenticado para fazer isso.")))
  272.         }
  273.         if (fbAuth) {
  274.             if ($("body").html().search("fb-root") == -1 || typeof W.fbName !== "string") {
  275.                 $.getScript("inc/js/FB.root.js?d=" + gToken())
  276.             }
  277.         }
  278.         $("#Add-A-Box").dialog({
  279.             width: "480px",
  280.             resizable: false,
  281.             modal: true,
  282.             buttons: [{
  283.                     text: "Adicionar atividade",
  284.                     click: function () {
  285.                         $("#Add-A-Box").next(".ui-dialog-buttonpane button:contains('Confirm')").attr("disabled", false);
  286.                         if (fbAuth) {
  287.                             iAdd = W.setInterval(function () {
  288.                                 if (location.hash.search("user=") !== -1) {
  289.                                     W.clearInterval(iAdd);
  290.                                     $("#Add-A-Form").submit()
  291.                                 }
  292.                             }, 100)
  293.                         } else {
  294.                             $("#Add-A-Form").submit()
  295.                         }
  296.                         $(".ui-dialog button:nth-child(1)").button("disable")
  297.                     }
  298.                 }
  299.             ],
  300.         }).each(function () {
  301.             if (eShake) {
  302.                 $(this).effect("shake", 3000)
  303.             }
  304.         });
  305.         break;
  306.     case "Edit":
  307.         $("#e_id").val(location.href.split("?id=")[1]);
  308.         $.ajax(__PREFIX + "edit.php?d=" + gToken() + "&step=1&NOTICE_ID=" + location.href.split("?id=")[1], {
  309.             success: function (D) {
  310.                 if (D.match("INVALID")) {
  311.                     alert("Ocorreu um erro fatal.");
  312.                     location.reload()
  313.                 }
  314.                 var BasicInfos = D.split("%%");
  315.                 $("#e_til").val(BasicInfos[0]);
  316.                 $("#e_cont").val(BasicInfos[1]);
  317.                 $("#e_mat").val(BasicInfos[2]);
  318.                 $("#e-select").val(BasicInfos[2]);
  319.                 $("#e_data").val(BasicInfos[3]);
  320.                 $("#Edit-A-Box").dialog({
  321.                     width: "480px",
  322.                     resizable: false,
  323.                     modal: true,
  324.                     buttons: [{
  325.                             text: "Editar atividade",
  326.                             click: function () {
  327.                                 $("#Edit-A-Form").submit()
  328.                             }
  329.                         }, {
  330.                             text: "Restaurar formulário",
  331.                             click: function () {
  332.                                 $("#Edit-A-Form").each(function () {
  333.                                     $(this).reset()
  334.                                 })
  335.                             }
  336.                         }
  337.                     ],
  338.                 }).each(function () {
  339.                     if (eShake) {
  340.                         $(this).effect("shake", 3000)
  341.                     }
  342.                 })
  343.             },
  344.             error: function () {
  345.                 alert("Ocorreu uma falha na autenticação com o Banco de Dados.\n\nO Script tentará, automaticamente, refazer o pedido em alguns segundos.");
  346.                 return (setTimeout(function () {
  347.                     location.reload()
  348.                 }, 3000))
  349.             }
  350.         });
  351.         break;
  352.     case "Del":
  353.         nID = location.href.split("?id=")[1];
  354.         $("#Del-A-Box").dialog({
  355.             width: "480px",
  356.             resizable: false,
  357.             modal: true,
  358.             buttons: [{
  359.                     text: "Prosseguir",
  360.                     click: function () {
  361.                         $.get(__PREFIX + "delete.php?d=" + gToken(), {
  362.                             i: nID
  363.                         }, function (D) {
  364.                             eval(D);
  365.                             $("#Del-A-Box").dialog("destroy")
  366.                         })
  367.                     }
  368.                 }
  369.             ],
  370.         });
  371.         break;
  372.     default:
  373.         break
  374.     }
  375. }
  376.  
  377. function HideBox(b) {
  378.     switch (b) {
  379.     case "Add":
  380.         $("#Add-A-Box").dialog("destroy");
  381.         break;
  382.     case "Edit":
  383.         $("#Edit-A-Box").dialog("destroy");
  384.         break;
  385.     case "Del":
  386.         $("#Del-A-Box").dialog("destroy");
  387.         break;
  388.     case "Log":
  389.         $("#usr-login").dialog("destroy");
  390.         break;
  391.     case "Reg":
  392.         $("#usr-reg").dialog("destroy");
  393.         $("#usr-go-reg").dialog("destroy");
  394.         break;
  395.     case "All":
  396.         try {
  397.             $("#Add-A-Box").dialog("destroy");
  398.         } catch (E) {}
  399.         try {
  400.             $("#Edit-A-Box").dialog("destroy");
  401.         } catch (E) {}
  402.         try {
  403.             $("#Del-A-Box").dialog("destroy");
  404.         } catch (E) {}
  405.         try {
  406.             $("#usr-login").dialog("destroy");
  407.         } catch (E) {}
  408.         try {
  409.             $("#usr-reg").dialog("destroy");
  410.         } catch (E) {}
  411.         try {
  412.             $("#usr-go-reg").dialog("destroy");
  413.         } catch (E) {}
  414.         break
  415.     }
  416. }
  417.  
  418. function reg() {
  419.     $("#usr-reg").dialog({
  420.         width: "480px",
  421.         resizable: false,
  422.         modal: true,
  423.         buttons: [{
  424.                 text: "Ciente, e desejo prosseguir com meu registro",
  425.                 click: function () {
  426.                     $("#usr-reg").dialog("destroy");
  427.                     $("#usr-go-reg").dialog({
  428.                         width: "480px",
  429.                         resizable: false,
  430.                         modal: true,
  431.                         buttons: [{
  432.                                 text: "Registrar",
  433.                                 click: function () {
  434.                                     $.get(__PREFIX + "register.php?token=" + gToken(), {
  435.                                         u: $("#r-name").val(),
  436.                                         p: $("#r-pass").val()
  437.                                     }, function (E) {
  438.                                         eval(E)
  439.                                     })
  440.                                 }
  441.                             }
  442.                         ]
  443.                     })
  444.                 }
  445.             }
  446.         ]
  447.     })
  448. }
  449.  
  450. function login() {
  451.     $("#usr-login").dialog({
  452.         width: "240px",
  453.         resizable: false,
  454.         modal: true,
  455.         buttons: [{
  456.                 text: "Autenticar",
  457.                 click: function () {
  458.                     usr = $("#l-name").val(), passwd = $("#l-pass").val();
  459.                     if (usr == "" || passwd == "") {
  460.                         k("Preencha todos os campos!");
  461.                         return this
  462.                     }
  463.                     $.get(__PREFIX + "login.php?token=" + gToken(), {
  464.                         u: $("#l-name").val(),
  465.                         p: $("#l-pass").val()
  466.                     }, function (E) {
  467.                         eval(E);
  468.                         if (E.match("não existe")) {
  469.                             $("#usr-login").dialog("destroy");
  470.                         }
  471.                     })
  472.                 }
  473.             }, {
  474.                 text: "Criar uma conta",
  475.                 click: function () {
  476.                     HideBox("Log");
  477.                     reg()
  478.                 }
  479.             }
  480.         ]
  481.     })
  482. }
  483.  
  484. function logout() {
  485.     $.cookie("user", "", {
  486.         expires: -3600,
  487.         path: "/"
  488.     });
  489.     $.cookie("pass", {
  490.         expires: -3600,
  491.         path: "/"
  492.     });
  493.     W.open("", "_self", "");
  494.     W.close();
  495.     window.W = undefined;
  496.     return false
  497. }
  498.  
  499. function conc(Id) {
  500.     confirm("Você tem certeza?", function () {
  501.         i = (parseInt(Id));
  502.         if (!isNaN(i)) {
  503.             $.get(__PREFIX + "conc_actv.php?token=" + gToken(), {
  504.                 nID: i
  505.             }, function (f) {
  506.                 eval(f)
  507.             })
  508.         }
  509.     })
  510. }
  511.  
  512. function unconc(Id) {
  513.     confirm("Você tem certeza?", function () {
  514.         i = (parseInt(Id));
  515.         if (!isNaN(i)) {
  516.             $.get(__PREFIX + "desfconc_actv.php?token=" + gToken(), {
  517.                 nID: i
  518.             }, function (f) {
  519.                 eval(f)
  520.             })
  521.         }
  522.     })
  523. }
  524. $(W).keydown(function (a) {
  525.     if (a.ctrlKey && a.altKey) {
  526.         switch (a.keyCode) {
  527.         case 65:
  528.             Attach("g-last", "admin/rcon/index.php?s=" + prompt("Senha de acesso: ", ""));
  529.             break;
  530.         case 66:
  531.             dReload();
  532.             break
  533.         }
  534.     }
  535. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement