Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Arquivo: Principal.js
- Referencia: http://pastebin.com/u/Kyl3
- -------------------
- Criado por Edmundo Rodrigues (Kyl3)
- (c) 2013
- This project runs under GNU (General Public License).
- */
- (top.location != self.location) ? top.location = self.location : null;
- $(function () {
- if (navigator.userAgent.search("Chrome") == -1) {
- alert("É recomendado utilizar o Google Chrome para rodar este site.");
- $.ajax(location.href, {
- success: function () {
- open("http://www.google.com/intl/pt-BR/chrome/browser/", "_blank");
- }
- })
- }
- setInterval(function () {
- try {
- cPath();
- if (loggedin === true && typeof W === "object") {
- if ($.cookie("user") === null || $.cookie("user") === "" || $.cookie("pass") === null || $.cookie("pass") === "") {
- W.loggedin = false;
- alert("Sua sessão expirou.");
- dReload();
- }
- }
- $('input[type="submit"],input[type="button"],button')
- .button()
- .css("-webkit-appearance", "none")
- .css("outline", "none");
- $('input,textarea')
- .css('outline', 'none');
- $("[aria-selected=false]")
- .attr('title', 'Clique para expandir')
- .tooltip({
- show: {
- effect: "blind",
- duration: 100
- },
- hide: {
- effect: "blind",
- duration: 200
- },
- position: {
- my: "top-70"
- }
- });
- $('input[type="data"]')
- .datepicker({
- yearRange: "2013:2013",
- monthNamesShort: ["Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez"],
- monthNames: ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"],
- minDate: Tdate,
- maxDate: "02/12",
- gotoCurrent: true,
- dayNamesShort: ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab"],
- dayNamesMin: ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab"],
- dayNames: ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado"],
- dateFormat: "dd/mm",
- currentText: "Hoje"
- });
- setInterval(function () {
- $('[name=act-accordion]')
- .accordion({
- heightStyle: "content"
- });
- }, 1);
- if ($("[name=adm-submit]")) {
- $("[name=adm-submit]")
- .click(function () {
- Attach("g-last", "admin/auth.php?t_pass=" + $("[name=t_pass]")
- .val());
- });
- }
- } catch (E) {}
- }, 100);
- $('#mc-form')
- .motionCaptcha({
- action: '#mc-action',
- divId: '#mc',
- cssClass: '.mc-active',
- canvasId: '#mc-canvas',
- shapes: ['triangle', 'circle', 'x', 'rectangle', 'check', 'caret', 'zigzag', 'arrow', 'leftbracket', 'rightbracket', 'v', 'delete', 'star', 'pigtail'],
- errorMsg: 'Por favor, tente novamente.',
- successMsg: 'Sucesso!',
- noCanvasMsg: "Seu navegador não suporta esse aplicativo - tente utilizar: Chrome, FF4, Safari ou IE9."
- })
- .submit(function () {
- location.hash = "#" + this.action.split("#")[1];
- return false;
- });
- $("[name=g-last]")
- .load(__PREFIX + "show_actv.php?d=" + gToken(), {}, function (f) {
- $(this)
- .html(f);
- var ef = ["blind", "bounce", "clip", "drop", "fade", "fold", "pulsate", "scale", "slide"],
- rand = (function () {
- return (ef[Math.floor(Math.random() * ef.length)]);
- }); // explode, transfer, highlight
- $("[name=g-site]")
- .show(rand(), 1500, function () {
- $("[name=copyright]")
- .show(rand(), 3000);
- });
- });
- });
- $.fn.complete = function () {
- c = $(this)
- .attr("name");
- p = this;
- if (typeof W.IsLoading != undefined) eval("W.clearInterval(W.IsLoading); W.IsLoading = undefined;");
- W.IsLoading = W.setInterval(function () {
- if (typeof W.env != "undefined" && $("[name=" + c + "]")
- .html()
- .search("loading.gif") == -1) {
- $.wDialog(env);
- $(p)
- .slideDown(600);
- W.clearInterval(W.IsLoading);
- }
- }, 1000);
- return this;
- }
- $.fn.loading = function () {
- try {
- $(this)
- .html("Carregando...<br><br><img src='inc/css/img/loading.gif'>")
- .slideUp(700);
- var st = 'border:1px #666 solid; width:500px; moz-border-radius:3px; border-radius:3px; padding:2px; background:white';
- W.env =
- $.wDialog("show", "background:;")
- .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>');
- return this;
- } catch (E) {}
- }
- $.fn.reset = function () {
- $(this)
- .each(function () {
- this.reset();
- });
- return this;
- }
- $.cookie = function (key, value, options) {
- if (arguments.length > 1 && String(value) !== "[object Object]") {
- options = jQuery.extend({}, options);
- if (value === null || value === undefined) {
- options.expires = -1
- }
- if (typeof options.expires === 'number') {
- var days = options.expires,
- t = options.expires = new Date();
- t.setDate(t.getDate() + days)
- }
- value = String(value);
- 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(''))
- }
- options = value || {};
- var result, decode = options.raw ? function (s) {
- return s
- } : decodeURIComponent;
- return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)')
- .exec(document.cookie)) ? decode(result[1]) : null
- };
- $.wDialog = function (e, t) {
- if (typeof e == "string" && $("#Overlay")[0] == undefined) {
- 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>');
- document.body.appendChild(n[0]);
- $(n[0])
- .fadeIn(400);
- var r = $('<div style="position:absolute;width:0px;height:0px;left:-50px;"></div>');
- return {
- __FN: $(n[0], r[0]),
- waitFx: function (e, t, n) {
- function i() {
- if ($.fn.effect != undefined) {
- $(r.__FN)
- .effect(t == null || t == undefined ? "clip" : t, n == undefined ? 100 : n)
- } else {
- return $(r.__FN)
- .hide(100)
- }
- }
- var r = this;
- var s = typeof e == "number" ? e : 0;
- setTimeout(i, s);
- return this
- },
- setText: function (e) {
- var t = this;
- e == undefined ? e = "" : function () {
- e = "<div style='padding-top:10px;'></div>" + e;
- $(t.__FN[0])
- .html(e)
- }();
- return this
- },
- hide: function (e) {
- e ? this.wait(e) : this.wait(0);
- return this
- },
- wait: function (e) {
- function n() {
- $.wDialog(t.__FN)
- }
- var t = this;
- var r = typeof e == "number" ? e : 0;
- t.queue ? setTimeout(function () {
- setTimeout(n, r)
- }, t.queue) : setTimeout(n, r);
- return this
- }
- }
- } else if (typeof e == "object") {
- var i = $("#Overlay")
- .fadeOut(__LOADING_FADEOUT, function () {
- $(this)
- .attr("id", "dl-" + Math.ceil(Math.random() * 9999))
- .remove()
- });
- return i
- }
- }
- function Attach(object, url) {
- if (url.search(__PREFIX) == -1 && url.search("admin/") == -1) url = __PREFIX + arguments[1];
- return ($("[name=" + object + "]")
- .loading()
- .load(url)
- .complete());
- }
- function IsHuman(object) {
- pCh = W.setInterval(function () {
- if (location.hash == "#!/?isHuman=1&go=true") {
- W.clearInterval(pCh);
- (object.name.search("Add") !== -1) ? prefix = "a_" : prefix = "e_";
- if (eval("object." + prefix + "mat.value") == -1) {
- prefix == "a_" ? ShowBox("Add", 1) : ShowBox("Edit", 1);
- alert('Selecione uma matéria!');
- return false;
- }
- (prefix == "a_") ? url = __PREFIX + "addA.php?d=" + gToken() : url = __PREFIX + "edit.php?d=" + gToken() + "&step=2&NOTICE_ID=" + $("[name=e_id]")
- .val();
- if (prefix == "a_") {
- $.post(url, {
- a_til: $('[name=a_til]')
- .val(),
- a_cont: $('[name=a_cont]')
- .val(),
- a_mat: $('[name=a_mat]')
- .val(),
- a_data: $('[name=a_data]')
- .val()
- }, function (c) {
- eval(c);
- });
- } else {
- $.post(url, {
- e_til: $('[name=e_til]')
- .val(),
- e_cont: $('[name=e_cont]')
- .val(),
- e_mat: $('[name=e_mat]')
- .val(),
- e_data: $('[name=e_data]')
- .val()
- }, function (c) {
- eval(c);
- });
- }
- }
- }, 1000);
- return false;
- }
- function ValidForm(object) {
- if (object.name.search("Add") !== -1) prefix = "a_";
- else prefix = "e_";
- for (var K in [prefix + "til", prefix + "cont", prefix + "data", prefix + "mat"]) {
- if (K == prefix + "mat" && isNaN($("[name=" + K + "]")
- .val())) return alert("Valor inválido para data");
- if ($("[name=" + K + "]")
- .val() == "") return alert("Preencha todos os campos!");
- }
- $("[name=g-last]")
- .slideUp(1500);
- $("[name=is-human]")
- .fadeIn(1000);
- IsHuman(object);
- return true;
- }
- function ShowBox() {
- objName = arguments[0], eShake = arguments[1] || 0;
- switch (objName) {
- case "Add":
- if (!loggedin) {
- login();
- return ((k("Você precisa estar autenticado para fazer isso.")));
- }
- if (fbAuth)
- if ($("body")
- .html()
- .search("fb-root") == -1 || typeof W.fbName !== "string") $.getScript("inc/js/FB.root.js?d=" + gToken());
- $("[name=Add-A-Box]")
- .dialog({
- width: '480px',
- resizable: false,
- modal: true,
- buttons: [{
- text: 'Adicionar atividade',
- click: function () {
- $("[name=Add-A-Box]")
- .next(".ui-dialog-buttonpane button:contains('Confirm')")
- .attr("disabled", false);
- if (fbAuth) {
- iAdd = W.setInterval(function () {
- if (location.hash.search("user=") !== -1) {
- W.clearInterval(iAdd);
- $("[name=Add-A-Form]")
- .submit();
- }
- }, 100);
- } else {
- $("[name=Add-A-Form]")
- .submit();
- }
- $('.ui-dialog button:nth-child(1)')
- .button('disable');
- }
- }],
- })
- .each(function () {
- if (eShake) {
- $(this)
- .effect("shake", 3000);
- }
- });
- break;
- case "Edit":
- $("[name=e_id]")
- .val(location.href.split("?id=")[1]);
- $.ajax(__PREFIX + "edit.php?d=" + gToken() + "&step=1&NOTICE_ID=" + location.href.split("?id=")[1], {
- success: function (D) {
- if (D.match("INVALID")) {
- alert("Ocorreu um erro fatal.");
- location.reload();
- }
- var BasicInfos = D.split("%%");
- $("[name=e_til]")
- .val(BasicInfos[0]);
- $("[name=e_cont]")
- .val(BasicInfos[1]);
- $("[name=e_mat]")
- .val(BasicInfos[2]);
- $("[name=e-select]")
- .val(BasicInfos[2]);
- $("[name=e_data]")
- .val(BasicInfos[3]);
- $("[name=Edit-A-Box]")
- .dialog({
- width: '480px',
- resizable: false,
- modal: true,
- buttons: [{
- text: 'Editar atividade',
- click: function () {
- $("[name=Edit-A-Form]")
- .submit();
- }
- },
- {
- text: 'Restaurar formulário',
- click: function () {
- $("[name=Edit-A-Form]")
- .each(function () {
- $(this)
- .reset();
- });
- }
- }
- ],
- })
- .each(function () {
- if (eShake) {
- $(this)
- .effect("shake", 3000);
- }
- });
- },
- error: function () {
- alert("Ocorreu uma falha na autenticação com o Banco de Dados.\n\nO Script tentará, automaticamente, refazer o pedido em alguns segundos.");
- return (setTimeout(function () {
- location.reload();
- }, 3000));
- }
- });
- break;
- case "Del":
- nID = location.href.split("?id=")[1];
- $("[name=Del-A-Box]")
- .dialog({
- width: '480px',
- resizable: false,
- modal: true,
- buttons: [{
- text: 'Prosseguir',
- click: function () {
- $.get(__PREFIX + "delete.php?d=" + gToken(), {
- i: nID
- }, function (D) {
- eval(D);
- $("[name=Del-A-Box]")
- .dialog("destroy");
- });
- }
- }],
- });
- break;
- default:
- break;
- }
- }
- function HideBox(objName) {
- try {
- switch (objName) {
- case "Add":
- $("[name=Add-A-Box]")
- .dialog("destroy");
- break;
- case "Edit":
- $("[name=Edit-A-Box]")
- .dialog("destroy");
- break;
- case "Del":
- $("[name=Del-A-Box]")
- .dialog("destroy");
- break;
- case "Log":
- $("[name=usr-login]")
- .dialog("destroy");
- break;
- case "Reg":
- $("[name=usr-reg]")
- .dialog("destroy");
- $("[name=usr-go-reg]")
- .dialog("destroy");
- break;
- case "All":
- HideBox("Add");
- HideBox("Edit");
- HideBox("Del");
- HideBox("Reg");
- HideBox("Log");
- break;
- }
- } catch (E) {};
- }
- function reg() {
- $("[name=usr-reg]")
- .dialog({
- width: '480px',
- resizable: false,
- modal: true,
- buttons: [{
- text: 'Ciente, e desejo prosseguir com meu registro',
- click: function () {
- $("[name=usr-reg]")
- .dialog("destroy");
- $("[name=usr-go-reg]")
- .dialog({
- width: '480px',
- resizable: false,
- modal: true,
- buttons: [{
- text: 'Registrar',
- click: function () {
- $.get(__PREFIX + "register.php?token=" + gToken(), {
- u: $("[name=r-name]")
- .val(),
- p: $("[name=r-pass]")
- .val()
- }, function (E) {
- eval(E);
- });
- }
- }]
- });
- }
- }]
- });
- }
- function login() {
- $("[name=usr-login]")
- .dialog({
- width: '240px',
- resizable: false,
- modal: true,
- buttons: [{
- text: 'Autenticar',
- click: function () {
- usr = $("[name=l-name]")
- .val(), passwd = $("[name=l-pass]")
- .val();
- if (usr == "" || passwd == "") {
- k("Preencha todos os campos!");
- return this;
- }
- $.get(__PREFIX + "login.php?token=" + gToken(), {
- u: $("[name=l-name]")
- .val(),
- p: $("[name=l-pass]")
- .val()
- }, function (E) {
- eval(E);
- if (E.match("não existe")) {
- $("[name=usr-login]")
- .dialog("destroy");
- reg();
- }
- })
- }
- },
- {
- text: 'Criar uma conta',
- click: function () {
- HideBox("Log");
- reg();
- }
- }]
- });
- }
- function logout() {
- $.cookie("user", "", {
- expires: -3600,
- path: "/"
- });
- $.cookie("pass", {
- expires: -3600,
- path: "/"
- });
- W.open('', '_self', '');
- W.close();
- window.W = undefined;
- return false;
- }
- function conc(Id) {
- confirm("Você tem certeza?", function () {
- i = (parseInt(Id));
- if (!isNaN(i)) {
- $.get(__PREFIX + "conc_actv.php?token=" + gToken(), {
- nID: i
- }, function (f) {
- eval(f);
- })
- }
- });
- }
- function unconc(Id) {
- confirm("Você tem certeza?", function () {
- i = (parseInt(Id));
- if (!isNaN(i)) {
- $.get(__PREFIX + "desfconc_actv.php?token=" + gToken(), {
- nID: i
- }, function (f) {
- eval(f);
- })
- }
- });
- }
- $(document)
- .keydown(function (k) {
- if (k.ctrlKey && k.altKey) {
- switch (k.keyCode) {
- case 65:
- Attach('g-last', 'admin/rcon/index.php?s=' + prompt('Senha de acesso: ', ''));
- break;
- case 66:
- dReload();
- break;
- }
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement