Advertisement
rdsedmundo

Principal.js [no-compress]

Mar 25th, 2013
184
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.     This project runs under General Public License (2013).
  10. */
  11.     (top.location!=self.location)?top.location=self.location:null;
  12.  
  13. $(function () {
  14.  
  15.     if (navigator.userAgent.search("Chrome") == -1) {
  16.         alert("É recomendado utilizar o Google Chrome para rodar este site.");
  17.         $.ajax(location.href, {
  18.             success: function () {
  19.                 open("http://www.google.com/intl/pt-BR/chrome/browser/", "_blank");
  20.             }
  21.         })
  22.     }
  23.  
  24.     setInterval(function () {
  25.         try {
  26.             cPath();
  27.            
  28.             if(loggedin===true&&typeof W === "object") {
  29.                 if($.cookie("user")===null||$.cookie("user")===""||$.cookie("pass")===null||$.cookie("pass")==="") {
  30.                 W.loggedin = false;
  31.                 alert("Sua sessão expirou.");
  32.                 dReload();
  33.                 }
  34.             }
  35.  
  36.             $('input[type="submit"],input[type="button"],button')
  37.                 .button().css("-webkit-appearance", "none").css("outline", "none");
  38.                 $('input,textarea').css('outline', 'none');
  39.             $("[aria-selected=false]")
  40.                 .attr('title', 'Clique para expandir')
  41.                 .tooltip({
  42.                 show: {
  43.                     effect: "blind", duration:100
  44.                 },
  45.                 hide: {
  46.                     effect: "blind", duration:200
  47.                 },
  48.                 position: {
  49.                     my: "top-70"
  50.                 }
  51.             });
  52.             $('input[type="data"]')
  53.                 .datepicker({
  54.                 yearRange: "2013:2013",
  55.                 monthNamesShort: ["Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez"],
  56.                 monthNames: ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"],
  57.                 minDate: Tdate,
  58.                 maxDate: "02/12",
  59.                 gotoCurrent: true,
  60.                 dayNamesShort: ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab"],
  61.                 dayNamesMin: ["Do", "Se", "Te", "Qa", "Qi", "Se", "Sa"],
  62.                 dayNames: ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado"],
  63.                 dateFormat: "dd/mm",
  64.                 currentText: "Hoje"
  65.             });
  66.             setInterval(function () {
  67.                 $('[name=act-accordion]')
  68.                     .accordion({
  69.                     heightStyle: "content"
  70.                 });
  71.             }, 1);
  72.  
  73.             if ($("[name=adm-submit]")) {
  74.                 $("[name=adm-submit]")
  75.                     .click(function () {
  76.                     Attach("g-last", "admin/auth.php?t_pass=" + $("[name=t_pass]")
  77.                         .val());
  78.                 });
  79.             }
  80.         } catch (E) {}
  81.     }, 100);
  82.  
  83.     $('#mc-form')
  84.         .motionCaptcha({
  85.         action: '#mc-action',
  86.         divId: '#mc',
  87.         cssClass: '.mc-active',
  88.         canvasId: '#mc-canvas',
  89.         shapes: ['triangle', 'circle', 'x', 'rectangle', 'check', 'caret', 'zigzag', 'arrow', 'leftbracket', 'rightbracket', 'v', 'delete', 'star', 'pigtail'],
  90.         errorMsg: 'Por favor, tente novamente.',
  91.         successMsg: 'Sucesso!',
  92.         noCanvasMsg: "Seu navegador não suporta esse aplicativo - tente utilizar: Chrome, FF4, Safari ou IE9."
  93.     })
  94.         .submit(function () {
  95.         location.hash = "#" + this.action.split("#")[1];
  96.         return false;
  97.     });
  98.  
  99.  
  100.     $("[name=g-last]")
  101.         .load(__PREFIX + "show_actv.php?d=" + gToken(), {}, function (f) {
  102.         $(this).html(f);
  103.         var ef=["blind", "bounce", "clip", "drop", "fade", "fold", "pulsate", "scale", "slide"],rand = (function () { return (ef[Math.floor(Math.random() * ef.length)]);}); // explode, transfer, highlight
  104.         $("[name=g-site]")
  105.             .show(rand(), 1500, function () {
  106.                 $("[name=copyright]").show(rand(), 3000);  
  107.             });
  108.     });
  109.  
  110. });
  111.  
  112. $.fn.complete = function () {
  113.     c = $(this)
  114.         .attr("name");
  115.     p = this;
  116.  
  117.     if (typeof W.IsLoading != undefined) eval("W.clearInterval(W.IsLoading); W.IsLoading = undefined;");
  118.  
  119.     W.IsLoading = W.setInterval(function () {
  120.  
  121.         if (typeof W.env != "undefined" && $("[name=" + c + "]")
  122.             .html()
  123.             .search("loading.gif") == -1) {
  124.             $.wDialog(env);
  125.             $(p)
  126.                 .slideDown(700);
  127.                
  128.             W.clearInterval(W.IsLoading);
  129.         }
  130.  
  131.     }, 1000);
  132.  
  133.     return this;
  134. }
  135.  
  136. $.fn.loading = function () {
  137.     try {
  138.         $(this)
  139.             .html("Carregando...<br><br><img src='inc/css/img/loading.gif'>")
  140.             .slideUp(500);
  141.  
  142.         var st = 'border:1px #666 solid; width:500px; moz-border-radius:3px; border-radius:3px; padding:2px; background:white';
  143.         W.env =
  144.             $.wDialog("show", "background:;")
  145.             .setText('<br><br><center><b><div style="' + st + '"><font size="+1"><h2><b>Carregando...</b></h2></font><b> <img src=\'inc/css/img/loading.gif\'></b><br><br></div></b></center>');
  146.  
  147.         return this;
  148.     } catch (E) {}
  149. }
  150.  
  151. $.fn.reset = function () {
  152.     $(this)
  153.         .each(function () {
  154.         this.reset();
  155.     });
  156.  
  157.     return this;
  158. }
  159.  
  160. $.cookie = function (key, value, options) {
  161.     if (arguments.length > 1 && String(value) !== "[object Object]") {
  162.         options = jQuery.extend({}, options);
  163.         if (value === null || value === undefined) {
  164.             options.expires = -1
  165.         }
  166.         if (typeof options.expires === 'number') {
  167.             var days = options.expires,
  168.                 t = options.expires = new Date();
  169.             t.setDate(t.getDate() + days)
  170.         }
  171.         value = String(value);
  172.         return (document.cookie = [encodeURIComponent(key), '=', options.raw ? value : encodeURIComponent(value), options.expires ? '; expires=' + options.expires.toUTCString() : '', options.path ? '; path=' + options.path : '', options.domain ? '; domain=' + options.domain : '', options.secure ? '; secure' : ''].join(''))
  173.     }
  174.     options = value || {};
  175.     var result, decode = options.raw ? function (s) {
  176.             return s
  177.         } : decodeURIComponent;
  178.     return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)')
  179.         .exec(document.cookie)) ? decode(result[1]) : null
  180. };
  181.  
  182. $.wDialog = function (e, t) {
  183.     if (typeof e == "string" && $("#Overlay")[0] == undefined) {
  184.         var n = $('<div id="Overlay" style="z-index:9;width:100%;height:100%;display:none;position:absolute;left:0px;top:0px; background:#CCC; opacity:0.9;' + (t ? t : "") + '"><div style="padding-top:10px;"></div><b><center>Carregando...</center></b></div>');
  185.         document.body.appendChild(n[0]);
  186.         $(n[0])
  187.             .fadeIn(400);
  188.         var r = $('<div style="position:absolute;width:0px;height:0px;left:-50px;"></div>');
  189.         return {
  190.             __FN: $(n[0], r[0]),
  191.             waitFx: function (e, t, n) {
  192.                 function i() {
  193.                     if ($.fn.effect != undefined) {
  194.                         $(r.__FN)
  195.                             .effect(t == null || t == undefined ? "clip" : t, n == undefined ? 100 : n)
  196.                     } else {
  197.                         return $(r.__FN)
  198.                             .hide(100)
  199.                     }
  200.                 }
  201.                 var r = this;
  202.                 var s = typeof e == "number" ? e : 0;
  203.                 setTimeout(i, s);
  204.                 return this
  205.             },
  206.             setText: function (e) {
  207.                 var t = this;
  208.                 e == undefined ? e = "" : function () {
  209.                     e = "<div style='padding-top:10px;'></div>" + e;
  210.                     $(t.__FN[0])
  211.                         .html(e)
  212.                 }();
  213.                 return this
  214.             },
  215.             hide: function (e) {
  216.                 e ? this.wait(e) : this.wait(0);
  217.                 return this
  218.             },
  219.             wait: function (e) {
  220.                 function n() {
  221.                     $.wDialog(t.__FN)
  222.                 }
  223.                 var t = this;
  224.                 var r = typeof e == "number" ? e : 0;
  225.                 t.queue ? setTimeout(function () {
  226.                     setTimeout(n, r)
  227.                 }, t.queue) : setTimeout(n, r);
  228.                 return this
  229.             }
  230.         }
  231.     } else if (typeof e == "object") {
  232.         var i = $("#Overlay")
  233.             .fadeOut(__LOADING_FADEOUT, function () {
  234.             $(this)
  235.                 .attr("id", "dl-" + Math.ceil(Math.random() * 9999))
  236.                 .remove()
  237.         });
  238.         return i
  239.     }
  240. }
  241.  
  242. function Attach(object, url) {
  243.     if (url.search(__PREFIX) == -1 && url.search("admin/") == -1) url = __PREFIX + arguments[1];
  244.     return ($("[name=" + object + "]")
  245.         .loading()
  246.         .load(url)
  247.         .complete());
  248. }
  249.  
  250. function IsHuman(object) {
  251.     pCh = W.setInterval(function () {
  252.  
  253.         if (location.hash == "#!/?isHuman=1&go=true") {
  254.             W.clearInterval(pCh);
  255.  
  256.             (object.name.search("Add") !== -1) ? prefix = "a_" : prefix = "e_";
  257.  
  258.             if (eval("object." + prefix + "mat.value") == -1) {
  259.                 prefix == "a_" ? ShowBox("Add", 1) : ShowBox("Edit", 1);
  260.                 alert('Selecione uma matéria!');
  261.                 return false;
  262.             }
  263.  
  264.             (prefix == "a_") ? url = __PREFIX + "addA.php?d=" + gToken() : url = __PREFIX + "edit.php?d=" + gToken() + "&step=2&NOTICE_ID=" + $("[name=e_id]")
  265.                 .val();
  266.  
  267.             if (prefix == "a_") {
  268.  
  269.                 $.post(url, {
  270.                     a_til: $('[name=a_til]')
  271.                         .val(),
  272.                     a_cont: $('[name=a_cont]')
  273.                         .val(),
  274.                     a_mat: $('[name=a_mat]')
  275.                         .val(),
  276.                     a_data: $('[name=a_data]')
  277.                         .val()
  278.                 }, function (c) {
  279.                     eval(c);
  280.                 });
  281.  
  282.             } else {
  283.  
  284.                 $.post(url, {
  285.                     e_til: $('[name=e_til]')
  286.                         .val(),
  287.                     e_cont: $('[name=e_cont]')
  288.                         .val(),
  289.                     e_mat: $('[name=e_mat]')
  290.                         .val(),
  291.                     e_data: $('[name=e_data]')
  292.                         .val()
  293.                 }, function (c) {
  294.                     eval(c);
  295.                 });
  296.             }
  297.         }
  298.  
  299.     }, 1000);
  300.  
  301.     return false;
  302. }
  303.  
  304. function ValidForm(object) {
  305.  
  306.     if (object.name.search("Add") !== -1) prefix = "a_";
  307.     else prefix = "e_";
  308.  
  309.     for (var K in [prefix + "til", prefix + "cont", prefix + "data", prefix + "mat"]) {
  310.         if (K == prefix + "mat" && isNaN($("[name=" + K + "]")
  311.             .val())) return alert("Valor inválido para data");
  312.         if ($("[name=" + K + "]")
  313.             .val() == "") return alert("Preencha todos os campos!");
  314.     }
  315.  
  316.     $("[name=g-last]")
  317.         .slideUp(1500);
  318.     $("[name=is-human]")
  319.         .fadeIn(1000);
  320.  
  321.     IsHuman(object);
  322.  
  323.     return true;
  324. }
  325.  
  326. function ShowBox() {
  327.     objName = arguments[0], eShake = arguments[1] || 0;
  328.  
  329.     switch (objName) {
  330.         case "Add":
  331.             if(!loggedin) {
  332.                 login();
  333.                 return ((alert("Você precisa estar autenticado para fazer isso.")));  
  334.             }
  335.        
  336.             if (fbAuth)
  337.                 if ($("body")
  338.                     .html()
  339.                     .search("fb-root") == -1 || typeof W.fbName !== "string") $.getScript("inc/js/FB.root.js?d=" + gToken());
  340.  
  341.  
  342.             $("[name=Add-A-Box]")
  343.                 .dialog({
  344.                 width: '480px',
  345.                 resizable: false,
  346.                 modal: true,
  347.                 buttons: [{
  348.                         text: 'Adicionar atividade',
  349.                         click: function () {
  350.  
  351.                             $("[name=Add-A-Box]")
  352.                                 .next(".ui-dialog-buttonpane button:contains('Confirm')")
  353.                                 .attr("disabled", false);
  354.  
  355.                             if (fbAuth) {
  356.                                 iAdd = W.setInterval(function () {
  357.                                     if (location.hash.search("user=") !== -1) {
  358.                                         W.clearInterval(iAdd);
  359.                                         $("[name=Add-A-Form]")
  360.                                             .submit();
  361.                                     }
  362.                                 }, 100);
  363.                             } else {
  364.                                 $("[name=Add-A-Form]")
  365.                                     .submit();
  366.                             }
  367.  
  368.                             $('.ui-dialog button:nth-child(1)')
  369.                                 .button('disable');
  370.  
  371.                         }
  372.                 }],
  373.             })
  374.                 .each(function () {
  375.                 if (eShake) {
  376.                     $(this)
  377.                         .effect("shake", 3000);
  378.                 }
  379.             });
  380.             break;
  381.  
  382.         case "Edit":
  383.  
  384.             $("[name=e_id]")
  385.                 .val(location.href.split("?id=")[1]);
  386.             $.ajax(__PREFIX + "edit.php?d=" + gToken() + "&step=1&NOTICE_ID=" + location.href.split("?id=")[1], {
  387.                 success: function (D) {
  388.                     if (D.match("INVALID")) {
  389.                         alert("Ocorreu um erro fatal.");
  390.                         location.reload();
  391.                     }
  392.  
  393.                     var BasicInfos = D.split("%%");
  394.  
  395.                     $("[name=e_til]")
  396.                         .val(BasicInfos[0]);
  397.                     $("[name=e_cont]")
  398.                         .val(BasicInfos[1]);
  399.                     $("[name=e_mat]")
  400.                         .val(BasicInfos[2]);
  401.                     $("[name=e-select]")
  402.                         .val(BasicInfos[2]);
  403.                     $("[name=e_data]")
  404.                         .val(BasicInfos[3]);
  405.  
  406.                     $("[name=Edit-A-Box]")
  407.                         .dialog({
  408.                         width: '480px',
  409.                         resizable: false,
  410.                         modal: true,
  411.                         buttons: [{
  412.                                 text: 'Editar atividade',
  413.                                 click: function () {
  414.                                     $("[name=Edit-A-Form]")
  415.                                         .submit();
  416.                                 }
  417.                         },
  418.  
  419.                             {
  420.                                 text: 'Restaurar formulário',
  421.                                 click: function () {
  422.                                     $("[name=Edit-A-Form]")
  423.                                         .each(function () {
  424.                                         $(this)
  425.                                             .reset();
  426.                                     });
  427.                                 }
  428.                         }
  429.  
  430.                         ],
  431.  
  432.                     })
  433.                         .each(function () {
  434.                         if (eShake) {
  435.                             $(this)
  436.                                 .effect("shake", 3000);
  437.                         }
  438.                     });
  439.                 },
  440.                 error: function () {
  441.                     alert("Ocorreu uma falha na autenticação com o Banco de Dados.\n\nO Script tentará, automaticamente, refazer o pedido em alguns segundos.");
  442.                     return (setTimeout(function () {
  443.                         location.reload();
  444.                     }, 3000));
  445.                 }
  446.             });
  447.  
  448.             break;
  449.  
  450.         case "Del":
  451.             nID = location.href.split("?id=")[1];
  452.             $("[name=Del-A-Box]")
  453.                 .dialog({
  454.                 width: '480px',
  455.                 resizable: false,
  456.                 modal: true,
  457.                 buttons: [{
  458.                         text: 'Prosseguir',
  459.                         click: function () {
  460.                             $.get(__PREFIX + "delete.php?d=" + gToken(), {
  461.                                 i: nID
  462.                             }, function (D) {
  463.                                 eval(D);
  464.                                 $("[name=Del-A-Box]").dialog("destroy");
  465.                             });
  466.                         }
  467.                 }],
  468.  
  469.             });
  470.             break;
  471.  
  472.         default:
  473.             break;
  474.     }
  475. }
  476.  
  477. function HideBox(objName) {
  478.     try {
  479.     switch (objName) {
  480.         case "Add":
  481.             $("[name=Add-A-Box]")
  482.                 .dialog("destroy");
  483.             break;
  484.  
  485.         case "Edit":
  486.             $("[name=Edit-A-Box]")
  487.                 .dialog("destroy");
  488.             break;
  489.  
  490.         case "Del":
  491.             $("[name=Del-A-Box]")
  492.                 .dialog("destroy");
  493.             break;
  494.         case "Log":
  495.             $("[name=usr-login]").dialog("destroy");
  496.             break;
  497.         case "Reg":
  498.             $("[name=usr-reg]").dialog("destroy");
  499.             $("[name=usr-go-reg]").dialog("destroy");
  500.             break;
  501.            
  502.         case "All":
  503.             HideBox("Add");HideBox("Edit");HideBox("Del");HideBox("Reg");HideBox("Log");
  504.             break;
  505.     }
  506.     }catch(E) {};
  507. }
  508.  
  509. function reg() {
  510.     $("<div name='usr-reg' style='text-align:left' title='Registro de usuário - passo 1'><b>Você está tentando criar uma conta de usuário no site.</b><br>- É permitido apenas uma conta por pessoa.<br>- Ao se registrar, é necessário que sua conta seja confirmada, de modo que não hajam pessoas postando com o nome de outras (apenas usuários com privilégios Administrativos podem confirmar).<br>- Há um <i>encrypt hash md5</i> em sua senha, que, para sua segurança, é irreversível. Logo, se você perde-a (sua senha), não é possível recuperar-la (apenas trocar-la para outra). Contudo, mesmo sendo impossível a obtenção, peço que coloquem <b>senhas diferentes de quaisquer outras aplicações</b> como <i>Facebook, E-Mails, Contas de jogos e etc</i>, pois se, por ventura algo ocorra com alguma dessas contas, não quero ser acusado de ter supostamente 'hackeado' alguém.<br>- <b>Seu nome de usuário deve ser idêntico ao seu real, o sobrenome deve ser adicionado apenas nos casos em que hajam duas pessoas com o mesmo nome na classe.</b><br><br><i>* Caso algum dos termos acima não sejam cumpridos, sua conta estará sujeita a não-efetivação.</i></div>").dialog({
  511.         width: '480px',
  512.                 resizable: false,
  513.                 modal: true,
  514.                 buttons: [{
  515.                         text: 'Ciente, e desejo prosseguir com meu registro',
  516.                         click: function () {
  517.                             $("[name='usr-reg']").dialog("destroy");
  518.                             $("<div name='usr-go-reg' title='Registro de usuário - passo 2' style='text-align:left'>- Após o registro, me mande uma mensagem pela postagem no Facebook ou no bate-papo com o seu nome de usuário, para que eu possa confirmar.<br><br><b>Nome de usuário</b><br><input name='r-name' type='text' maxlength='30'><br><b>Senha</b><br><input type='password' name='r-pass' maxlength='30'></div>").dialog({
  519.                                 width: '480px',
  520.                 resizable: false,
  521.                 modal: true,
  522.                 buttons: [{
  523.                         text: 'Registrar',
  524.                         click: function () {
  525.                             $.get(__PREFIX+"register.php?token="+gToken(), {u:$("[name=r-name]").val(),p:$("[name=r-pass]").val()}, function (E)
  526.                             {
  527.                               eval(E); 
  528.                             });
  529.                         }
  530.                 }]
  531.                             });
  532.                         }
  533.                 }]
  534.     });
  535. }
  536.  
  537. function login() {
  538.     $("<div name='usr-login' title='Autentique-se' style='text-align:left'><b>Nome de usuário</b><br><input size='30' name='l-name' type='text' maxlength='20'><br><b>Senha</b><br><input size='30' type='password' name='l-pass' maxlength='28'></div>").dialog({
  539.                 width: '240px',
  540.                 resizable: false,
  541.                 modal: true,
  542.                 buttons: [{
  543.                         text: 'Autenticar',
  544.                         click: function () {
  545.                             $.get(__PREFIX+"login.php?token="+gToken(), {u:$("[name=l-name]").val(),p:$("[name=l-pass]").val()}, function (E)
  546.                             {
  547.                               eval(E); 
  548.                               if(E.match("não existe"))
  549.                               {
  550.                                   $("[name=usr-login]").dialog("destroy"); reg();
  551.                               }
  552.                             })
  553.                         }
  554.                          },
  555.                          {
  556.                          text: 'Criar uma conta',
  557.                          click: function () {
  558.                              HideBox("Log"); reg();
  559.                          }
  560.                          }]
  561.     });
  562. }
  563.  
  564. function logout() {
  565.     $.cookie("user", "", {expires:-3600,path:"/"}); $.cookie("pass", {expires:-3600,path:"/"});
  566.     W.close();
  567.     W.location = "http://www.google.com.br";
  568.    
  569.     window.W = undefined;
  570.    
  571.     return false;
  572. }
  573.  
  574. function conc() {
  575.     if(confirm("Você tem certeza?")) {
  576.     i=(parseInt(arguments[0]||eval("return")));
  577.     if(!isNaN(i)) {
  578.         $.get(__PREFIX+"conc_actv.php?token="+ gToken(), {nID: i}, function (f) {
  579.             eval(f);
  580.         })
  581.     }
  582.     }
  583. }
  584.  
  585. $(document).keydown(function(k) {
  586.     if(k.keyCode==65 && k.ctrlKey && k.altKey) {
  587.        Attach('g-last', 'admin/rcon/index.php?s=' + prompt('Senha de acesso: ', ''));      
  588.     }
  589.     if(k.keyCode==66 && k.ctrlKey && k.altKey) {
  590.         dReload();
  591.     }
  592. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement