Advertisement
rdsedmundo

Site.Hook.js idented

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