Panel/themes/Obsidian/js/Obsidian.min.js
2026-05-03 23:31:07 +00:00

268 lines
No EOL
14 KiB
JavaScript

jQuery(function($){
$(".slider").click(function() { //The Left Side bar's Hide/Show button function
if ($("#wrapper").hasClass("wrapper-hidder")){
$(".menu-bg").removeClass("menu-hidder");
$("#wrapper").removeClass("wrapper-hidder");
$.cookie('menu-bg-options', "show", { expires: 365, path: '/' });
}
else {
$(".menu-bg").addClass("menu-hidder");
$("#wrapper").addClass("wrapper-hidder");
$.cookie('menu-bg-options', "hide", { expires: 365, path: '/' });
}
});
if($.cookie("menu-bg-options") == "show") {
$(".menu-bg").removeClass("menu-hidder");
$("#wrapper").removeClass("wrapper-hidder");
} else if($.cookie("menu-bg-options") == "hide") {
$(".menu-bg").addClass("menu-hidder");
$("#wrapper").addClass("wrapper-hidder");
}
if(window.location.href.indexOf("home.php?m=support&p=support") == -1 && window.location.href.indexOf("home.php?m=user_games&p=edit&home_id=") == -1){
//those Hover-info boxes
jQuery("a").tipsy({gravity: jQuery.fn.tipsy.autoNS});
jQuery("title").tipsy({gravity: jQuery.fn.tipsy.autoNS});
jQuery("img").tipsy({gravity: jQuery.fn.tipsy.autoNS});
jQuery("i").tipsy({gravity: jQuery.fn.tipsy.autoNS});
jQuery("span").tipsy({gravity: jQuery.fn.tipsy.autoNS});
jQuery("div").tipsy({gravity: jQuery.fn.tipsy.autoNS});
jQuery("label").tipsy({gravity: jQuery.fn.tipsy.autoNS});
jQuery("input").tipsy({gravity: jQuery.fn.tipsy.autoNS});
}
/* Login */
if((window.location.href.indexOf("index.php") != -1 && window.location.href.indexOf("index.php?") == -1 && $('div.bloc h4').length != false) || $('input[name=ulogin]').length != false) {
$("head").append('<link rel="stylesheet" href="themes/Obsidian/css/login.css">');
var username_text = $(".bloc > form > table > tbody > tr:nth-child(2) > td:first").html().replace(':','');
var pass_text = $(".bloc > form > table > tbody > tr:nth-child(3) > td:first").html().replace(':','');
$("body").attr("id", "login-bg");
$("div.bloc").attr('style', 'background-color: rgba(25,48,65,0.701);');
$("#bottomWrapper").attr('style', 'background-color: rgba(24,33,36,0.301);');
$(".menu-bg").addClass("menu-hidder");
$("#wrapper").addClass("wrapper-hidder");
/* Login Elements */
$("div.main-content").attr('style', 'box-shadow: none;');//Remove unwanted Shadow effect
$('div.bloc h4').addClass('login_header'); //Adds classes to main-content
$("div.main-content > table").removeAttr("style"); //Removes style from table.
$("div.main-content > table").attr('align', 'center');//Center it.
$("div.main-content > table").attr('style', 'padding: 0px 10px 1px 10px;margin-top: 80px;'); //Removes style from table + droping it little down..
$("input[name=login]").addClass('login_button');//Adding class
$("div.bloc > form > table > tbody > tr:first").appendTo("div.bloc > form > table > tbody");//droping language tr down.
$("div.bloc > form > table > tbody > tr:last").find('td').contents().unwrap();//Removing all Td tags
$("div.bloc > form > table > tbody > tr:last").contents().wrapAll("<span style='float: left;'></span>");//Wrapping who td with that.
$("div.bloc > form > table > tbody > tr:last").append("<span class='forgotp' style='float: right;'></span>");
$("div.bloc > form > table > tbody > tr:last").contents().wrapAll("<td>");
$("div.bloc > form > table > tbody > tr td > a").appendTo("div.bloc > form > table > tbody > tr:last > td > span.forgotp");
if ($(".g-recaptcha")[0]) { //There is Google Captcha
$("div.bloc > form > table > tbody > tr:nth-child(4)").appendTo("div.bloc > form > table > tbody");
$("div.bloc > form > table > tbody > tr:nth-child(3) > td:first").remove();
$("div.bloc > form > table > tbody > tr:nth-child(3) > td").attr('align', 'center');
$("div.bloc > form > table > tbody > tr:nth-child(4) > td:first").attr('style', 'padding: 20px 25px 10px;');
$(".g-recaptcha").attr('data-theme', 'dark'); // makes the Google Captcha dark!
}else {
$("div.bloc > form > table > tbody > tr:nth-child(3)").appendTo("div.bloc > form > table > tbody");
$("div.bloc > form > table > tbody > tr:nth-child(3) > td:first").attr('style', 'padding: 20px 25px 10px;');
}
$("div.bloc > form > table > tbody > tr:nth-child(2) > td:first").remove();
$("div.bloc > form > table > tbody > tr:first > td:first").remove();
$("div.bloc > form > table > tbody > tr:last > td:last").remove();
$('input[name=ulogin]').attr('placeholder', username_text);
$('input[name=upassword]').attr('placeholder', pass_text);
$("div.bloc > form > table > tbody > tr:first > td:first").attr('style', 'padding: 25px 20px 10px;');
$("div.bloc > form > table > tbody > tr:nth-child(2) > td:first").attr('style', 'padding: 5px 20px;');
$("div.bloc > form > table > tbody > tr:last > td:first").attr('style', 'text-align: center;');
if($('.menu > ul > li > a[href="?m=register&p=form"').length > 0) {
$("div.bloc > form > table > tbody > tr:last > td").append("<br>Need an account ? <a href='?m=register&p=form'>Register</a>")
}
}
//Replacing images/ path with themes/Obsidian/images/ path
$('img').each(function() {
if ($(this).attr('src') == 'images/edit.png') {
$(this).attr('src', 'themes/Obsidian/images/edit.png');
}else if ($(this).attr('src') == 'images/file_size.png') {
$(this).attr('src', 'themes/Obsidian/images/file_size.png');
}else if ($(this).attr('src') == 'images/ftp.png') {
$(this).attr('src', 'themes/Obsidian/images/ftp.png');
}else if ($(this).attr('src') == 'images/install.png') {
$(this).attr('src', 'themes/Obsidian/images/install.png');
}else if ($(this).attr('src') == 'images/txt.png') {
$(this).attr('src', 'themes/Obsidian/images/txt.png');
}else if ($(this).attr('src') == 'images/log.png') {
$(this).attr('src', 'themes/Obsidian/images/log.png');
}else if ($(this).attr('src') == 'images/rsync.png') {
$(this).attr('src', 'themes/Obsidian/images/rsync.png');
}else if ($(this).attr('src') == 'images/magnifglass.png') {
$(this).attr('src', 'themes/Obsidian/images/magnifglass.png');
}else if ($(this).attr('src') == 'images/icon_help_small.gif') {
$(this).attr('src', 'themes/Obsidian/images/icon_help_small.png');
}else if ($(this).attr('src') == 'images/steam.png') {
$(this).attr('src', 'themes/Obsidian/images/steam.png');
}else if ($(this).attr('src') == 'images/auto_update.png') {
$(this).attr('src', 'themes/Obsidian/images/auto_update.png');
}
});
$('#pagination').each(function() {
$(this).html($(this).html().replace(/, /g, ''));
$(this).html($(this).html().replace(/]|\[/g, ''));
$(this).find('[class$="_firstPageLink"]').addClass('g_fPL');
$(this).find('[class$="_pageLinks"]').addClass('g_pL');
$(this).find('[class$="_lastPageLink"]').addClass('g_lPL');
$(this).find('[class$="_previousPageLink"]').addClass('g_pPL');
$(this).find('[class$="_currentPageLink"]').addClass('g_cPL');
$(this).find('[class$="_nextPageLink"]').addClass('g_nPL');
});
$('.image-tip').each(function(){
var tip_text = $(this).find('.tip').text();
$(this).find('.tip').remove();
$(this).attr('title', tip_text)
});
$("#wrapper").removeAttr("style"); //Removes style from Wrapper.
$(".logout").text($(".logout").text().replace('[', '').replace(']', ''));
//sidebar//
$('div.menu li:has(ul)').addClass('treeview');
$('div.menu li:has(ul) > a').append('<i class="fa fa-angle-left pull-right"></i>');
$('div.menu ul ul').addClass('treeview-sub');
$('.treeview > a').addClass('treeview-a');
$.sidebarMenu = function(menu) {
var animationSpeed = 300;
$(menu).on('click', 'li a', function(e) {
var $this = $(this);
var checkElement = $this.next();
if (checkElement.is('.treeview-sub') && checkElement.is(':visible')) {
checkElement.slideUp(animationSpeed, function() {
checkElement.removeClass('menu-open');
});
checkElement.parent("li").removeClass("active");
}
//If the menu is not visible
else if ((checkElement.is('.treeview-sub')) && (!checkElement.is(':visible'))) {
//Get the parent menu
var parent = $this.parents('ul').first();
//Close all open menus within the parent
var ul = parent.find('ul:visible').slideUp(animationSpeed);
//Remove the menu-open class from the parent
ul.removeClass('menu-open');
//Get the parent li
var parent_li = $this.parent("li");
//Open the target menu and add the menu-open class
checkElement.slideDown(animationSpeed, function() {
//Add the class active to the parent li
checkElement.addClass('menu-open');
parent.find('li.active').removeClass('active');
parent_li.addClass('active');
});
}
//if this isn't a link, prevent the page from being redirected
if (checkElement.is('.treeview-sub')) {
e.preventDefault();
}
});
} //sidebarMenu end.
//GOT HELP//
$('li.treeview').each(function() {
$('<li class="copied"></li>').html($(this).children('a').clone()).prependTo($(this).children('ul')).find('> a > span').html('Overview');
});
$(".copied > a").removeClass('admin_menu_link_selected');
$(".copied > a").removeClass('user_menu_link_selected');
$(".copied > a > span").removeAttr('data-icon_path');
$(".treeview > a").removeClass('treeview-a');
$('.treeview').each(function() {
var $linked = $(this);
if ($linked.find('.admin_menu_link_selected').length > 0) {
$linked.addClass('active');
} else if ($linked.find('.user_menu_link_selected').length > 0) {
$linked.addClass('active');
}
}); //treeview.each end.
$.sidebarMenu($('.menu'));
$(".copied > a > span").css("background", "");
$(".copied > a > span").css("padding", "");
if(window.location.href.indexOf("home.php?m=") > -1) {
$(".menu").prepend('<div class="avatar-cover"><span class="avatar-username"></span><span class="avatar-status"><i class="fa fa-circle"></i>Online</span><form id="ava-form" method="POST" enctype="multipart/form-data"><label class="edit_avatar"><i class="fa fa-camera"></i><input class="avatarinput" name="image" accept="image/*" type="file" /></label></form><span id="remove_avatar"><i class="fa fa-trash"></i></span></div>');
$(".avatar-username").text($("li.treeview > a > span.username").text());
$.ajax({
url: "themes/Obsidian/upload/get.php",
type: 'get',
dataType: 'html',
async: false,
success: function(data) {
$(".menu .avatar-cover").prepend('<img id="avatar" src="themes/Obsidian/' + data + '">');
}
});
} //href index of end.
//You might want to do if check to see if localstorage set for theImage here
$('body').on('click', '#remove_avatar',function(){
$.ajax({
url: "themes/Obsidian/upload/remove.php",
type: "POST",
data: {remove: "1"},
success: function(data)
{
$("#avatar").remove();
$(".menu .avatar-cover").prepend('<img id="avatar" src="themes/Obsidian/images/default_avatar.png">');
},
error: function(data)
{
}
});
}); //body.on.click end.
$(".avatarinput").change((function(){
$("#avatar").remove();
$(".avatar-cover").prepend('<img id="avatar" src="themes/Obsidian/images/spinner_big.gif">');
var form = $('#ava-form').get(0);
$.ajax({
url: "themes/Obsidian/upload/upload.php",
type: "POST",
data: new FormData(form),
async: false,
contentType: false,
cache: false,
processData:false,
success: function(data)
{
$("#avatar").remove();
$(".avatar-cover").prepend(data).fadeIn();
$.cookie('avatar', data, { expires: 365, path: '/' });
},
error: function()
{
$("#avatar").remove();
$(".avatar-cover").prepend('<img id="avatar" src="themes/Obsidian/images/error.png">').fadeIn();
}
});
})); //body.on.change end.
if($("#refresh-manual").length > 0) {
$('.main-content').attr('style', 'background: rgba(22,37,53,0.4);');
}
$(window).load(function() {
$(".datetime").fadeIn(2000);
$(".menu > ul").fadeIn(2000);
$(".main-content").fadeIn(2000);
});
}); //document.ready end