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
- */
- (top.location != self.location) ? top.location = self.location : null;
- $(function () {
- if (navigator.userAgent.search("Chrome") == -1) alert("Para uma melhor exibição deste site, é recomendado usar o Google Chrome.", {
- f: OPTIONS_SHOW_OR_NOT,
- s: 0
- });
- setInterval(function () {
- try {
- $('label').each(function () {
- if ($(this).hasClass("select") == false && $(this).html().match(/option/gi)) $(this).addClass("select");
- });
- 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");
- $('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"
- });
- $("#act-accordion").accordion({
- heightStyle: "content"
- });
- } catch (a) {}
- }, 1);
- $("#mc-form").motionCaptcha({
- action: "#mc-action",
- divId: "#mc",
- cssClass: ".mc-active",
- canvasId: "#mc-canvas",
- shapes: ["triangle", "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: Google Chrome"
- }).submit(function () {
- location.hash = "#" + this.action.split("#")[1];
- return false
- });
- $("#g-last").load(__PREFIX + "show_actv.php?d=" + gToken(), {}, function (d) {
- $(this).html(d);
- var a = ["fade", "fold", "pulsate", "slide"],
- b = (function () {
- return (a[Math.floor(Math.random() * a.length)])
- });
- $("#gsite").tabs({
- fx: {
- height: 'toggle',
- opacity: 'toggle'
- }
- }).show(b(), 1500, function () {
- $("#copyright").show(b(), 3000)
- })
- })
- $("#l-forgot").click(function (event) {
- var e = event,
- refer = event.timeStamp;
- Attach("g-last", "forgot.php?from=" + refer);
- HideBox("Log");
- return false;
- });
- });
- $.fn.loading = function () {
- $(this).html("<div id='pbar_text'>Carregando (0%)...</div><br><br><div id='progressbar' style='width:600px'></div>");
- return this;
- }
- jQuery.fn.load = function (url, params, callback) {
- $("#progressbar").progressbar();
- if (typeof url !== "string" && _load) {
- return _load.apply(this, arguments);
- }
- var selector, response, type,
- self = this,
- off = url.indexOf(" ");
- if (off >= 0) {
- selector = url.slice(off, url.length);
- url = url.slice(0, off);
- }
- // If it's a function
- if (jQuery.isFunction(params)) {
- // We assume that it's the callback
- callback = params;
- params = undefined;
- // Otherwise, build a param string
- } else if (params && typeof params == "object") {
- type = "POST";
- }
- // If we have elements to modify, make the request
- if (self.length > 0) {
- jQuery.ajax({
- xhr: function () {
- var xhr = new W.XMLHttpRequest();
- xhr.upload.addEventListener("progress", function (evt) {
- if (evt.lengthComputable) {
- Percent = Math.round((100 * e.loaded / e.total));
- $('#progressbar').progressbar({
- value: Percent
- });
- $('#pbar_text').html(Percent + "%");
- }
- }, false);
- xhr.addEventListener('progress', function (e) {
- if (e.lengthComputable) {
- Percent = Math.round((100 * e.loaded / e.total));
- $('#progressbar').progressbar({
- value: Percent
- });
- $('#pbar_text').html(Percent + "%");
- }
- });
- return xhr;
- },
- url: url,
- // if "type" variable is undefined, then "GET" method will be used
- type: type,
- dataType: "html",
- data: params
- }).done(function (responseText) {
- // Save response for use in complete callback
- response = arguments;
- self.html(selector ? jQuery("<div>").append(jQuery.parseHTML(responseText)).find(selector) : responseText);
- }).complete(callback && function (jqXHR, status) {
- self.each(callback, response || [jqXHR.responseText, status, jqXHR]);
- });
- }
- return this;
- };
- $.fn.reset = function () {
- $(this).each(function () {
- this.reset()
- });
- return this
- };
- $.cookie = function (e, f, b) {
- if (arguments.length > 1 && String(f) !== "[object Object]") {
- b = jQuery.extend({}, b);
- if (f == null || f == undefined) {
- b.expires = -1
- }
- if (typeof b.expires == "number") {
- var h = b.expires,
- d = b.expires = new Date();
- d.setDate(d.getDate() + h)
- }
- f = String(f);
- 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(""))
- }
- b = f || {};
- var a, g = b.raw ? function (j) {
- return j
- } : decodeURIComponent;
- return (a = new RegExp("(?:^|; )" + encodeURIComponent(e) + "=([^;]*)").exec(document.cookie)) ? g(a[1]) : null
- };
- function Attach(b, a) {
- if (a.search(__PREFIX) == -1 && a.search("admin/") == -1) {
- a = __PREFIX + arguments[1]
- }
- return ($("#" + b).loading().load(a))
- }
- function IsHuman(object) {
- pCh = W.setInterval(function () {
- if (location.hash == "#!/?isHuman=1&go=true") {
- W.clearInterval(pCh);
- (object.id.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=" + $("#e_id").val();
- if (prefix == "a_") {
- stuff = function () {
- $.post(url, {
- a_til: $("#a_til").val(),
- a_cont: $("#a_cont").val(),
- a_mat: $("#a_mat").val(),
- a_data: $("#a_data").val()
- }, function (c) {
- eval(c)
- })
- }
- if (W.GCasync) {
- $.post("inc/other/google_calendar/Post.php", {
- t: $("#a_til").val(),
- c: $("#a_cont").val(),
- m: parseMat($("#a_mat").val()),
- d: $("#a_data").val()
- }, function (c) {
- k("G-Mail response: " + c, 1);
- if (c.search("Enviado") !== -1) stuff();
- else k("Ocorreu um erro no envio ao g-mail, tente novamente.");
- });
- } else {
- stuff();
- }
- } else {
- $.post(url, {
- e_til: $("#e_til").val(),
- e_cont: $("#e_cont").val(),
- e_mat: $("#e_mat").val(),
- e_data: $("#e_data").val()
- }, function (c) {
- eval(c)
- })
- }
- }
- }, 1000);
- return false
- }
- function ValidForm(b) {
- if (b.id.search("Add") !== -1) {
- prefix = "a_"
- } else {
- prefix = "e_"
- }
- for (var a in [prefix + "til", prefix + "cont", prefix + "data", prefix + "mat"]) {
- if (a == prefix + "mat" && isNaN($("#" + a).val())) {
- return alert("Valor inválido para data")
- }
- if ($("#" + a).val() == "") {
- return alert("Preencha todos os campos!")
- }
- }
- $("#g-last").slideUp(1500);
- $("#is-human").fadeIn(1000);
- IsHuman(b);
- 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())
- }
- }
- $("#Add-A-Box").dialog({
- width: "480px",
- resizable: false,
- modal: true,
- buttons: [{
- text: "Adicionar atividade",
- click: function () {
- $("#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);
- $("#Add-A-Form").submit()
- }
- }, 100)
- } else {
- $("#Add-A-Form").submit()
- }
- $(".ui-dialog button:nth-child(1)").button("disable")
- }
- }
- ],
- }).each(function () {
- if (eShake) {
- $(this).effect("shake", 3000)
- }
- });
- break;
- case "Edit":
- $("#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("%%");
- $("#e_til").val(BasicInfos[0]);
- $("#e_cont").val(BasicInfos[1]);
- $("#e_mat").val(BasicInfos[2]);
- $("#e-select").val(BasicInfos[2]);
- $("#e_data").val(BasicInfos[3]);
- $("#Edit-A-Box").dialog({
- width: "480px",
- resizable: false,
- modal: true,
- buttons: [{
- text: "Editar atividade",
- click: function () {
- $("#Edit-A-Form").submit()
- }
- }, {
- text: "Restaurar formulário",
- click: function () {
- $("#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];
- $("#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);
- $("#Del-A-Box").dialog("destroy")
- })
- }
- }
- ],
- });
- break;
- default:
- break
- }
- }
- function HideBox(b) {
- switch (b) {
- case "Add":
- $("#Add-A-Box").dialog("destroy");
- break;
- case "Edit":
- $("#Edit-A-Box").dialog("destroy");
- break;
- case "Del":
- $("#Del-A-Box").dialog("destroy");
- break;
- case "Log":
- $("#usr-login").dialog("destroy");
- break;
- case "Reg":
- $("#usr-reg").dialog("destroy");
- $("#usr-go-reg").dialog("destroy");
- break;
- case "All":
- try {
- $("#Add-A-Box").dialog("destroy");
- } catch (E) {}
- try {
- $("#Edit-A-Box").dialog("destroy");
- } catch (E) {}
- try {
- $("#Del-A-Box").dialog("destroy");
- } catch (E) {}
- try {
- $("#usr-login").dialog("destroy");
- } catch (E) {}
- try {
- $("#usr-reg").dialog("destroy");
- } catch (E) {}
- try {
- $("#usr-go-reg").dialog("destroy");
- } catch (E) {}
- break
- }
- }
- function reg() {
- $("#usr-reg").dialog({
- width: "480px",
- resizable: false,
- modal: true,
- buttons: [{
- text: "Ciente, e desejo prosseguir com meu registro",
- click: function () {
- $("#usr-reg").dialog("destroy");
- $("#usr-go-reg").dialog({
- width: "480px",
- resizable: false,
- modal: true,
- buttons: [{
- text: "Registrar",
- click: function () {
- $.get(__PREFIX + "register.php?token=" + gToken(), {
- u: $("#r-name").val(),
- p: $("#r-pass").val()
- }, function (E) {
- eval(E)
- })
- }
- }
- ]
- })
- }
- }
- ]
- })
- }
- function login() {
- $("#usr-login").dialog({
- width: "240px",
- resizable: false,
- modal: true,
- buttons: [{
- text: "Autenticar",
- click: function () {
- usr = $("#l-name").val(), passwd = $("#l-pass").val();
- if (usr == "" || passwd == "") {
- k("Preencha todos os campos!");
- return this
- }
- $.get(__PREFIX + "login.php?token=" + gToken(), {
- u: $("#l-name").val(),
- p: $("#l-pass").val()
- }, function (E) {
- eval(E);
- if (E.match("não existe")) {
- $("#usr-login").dialog("destroy");
- }
- })
- }
- }, {
- 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)
- })
- }
- })
- }
- $(W).keydown(function (a) {
- if (a.ctrlKey && a.altKey) {
- switch (a.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