$(document).ready(function() { /* *** Initializations *** */ toastr.options = { "debug": false, "positionClass": "toast-bottom-right", "onclick": null, "fadeIn": 300, "fadeOut": 1000, "timeOut": 5000, "extendedTimeOut": 1000, "progressBar": true, toastClass: 'elevation-4', } bsCustomFileInput.init(); var d = new Date(); /* *** Cutting Title *** */ var headTitle = document.getElementsByTagName("title")[0].innerHTML; if(headTitle.includes("[")) { headTitle = headTitle.substring(0, headTitle.lastIndexOf(" [") + 1); } // $('.brand-text').text(headTitle); /* *** Replacements *** */ $('a.btn').each(function() { // Remove all "<<" from Links var thisText = $(this).text(); if(thisText.includes("<")) { $(this).text(thisText.substring(thisText.lastIndexOf("<") + 1, thisText.length).trim()).prepend(''); } }); $('input[type="submit"]').each(function() { // Remove all "<<" from Buttons var thisValue = $(this).val(); if(thisValue.includes("<")) { $(this).val(thisValue.substring(thisValue.lastIndexOf("<") + 1, thisValue.length).trim()); } }); $('img[src="modules/addonsmanager/loading.gif"]').replaceWith(''); $('img[src="images/online.png"], img[src$="icon_online.gif"]').replaceWith(''); $('img[src="images/offline.png"], img[src$="icon_offline.gif"]').replaceWith(''); $('img[src="images/magnifglass.png"]').replaceWith(''); $('[src="modules/administration/images/remove.gif"]').attr('src', 'themes/AdminLTE/dist/img/remove-icon.png').css('max-width', '1rem').css('margin-bottom', '-2px').addClass('mx-1'); /* *** Menu: Tickets Num *** */ if($('script[src="js/modules/tickets_global.js"]').length) { $('script[src="js/modules/tickets_global.js"]').remove(); $.getJSON("home.php?m=tickets&p=notifications&type=cleared", function(data) { if(data['notificationCount'] > 0) { $('.nav-link[href="?m=tickets"]').append('' + data['notificationCount'] + ''); } }); } /* *** Messages *** */ var allMessages = '' var errMessages = '' // error messages if($('.failure:not(#errorHeader), .ticketError').length > 0) { // only replace failure message if main has class X if($('.main').hasClass('game-monitor')) { $(".failure:not(#errorHeader), .ticketError").each(function () { var failureText = $(this).text().trim(); if(failureText !== "" && isNaN(failureText)) { $(this).replaceWith('
'+$(this).text().trim()+'
'); } }); }else { var errt = []; $(".failure:not(#errorHeader), .ticketError").each(function () { var failureText = $(this).text().trim(); if(failureText !== "" && isNaN(failureText)) { errt.push(failureText); } }); if(errt.length > 0) { if(errt.length > 1) { errMessages = ''; }else { errMessages = '

'+errt[0]+'

'; } allMessages += '
'+errMessages+'
'; } } } // refresh message if($('#refresh-manual').length > 0) { allMessages += '
'+$('#refresh-manual').html()+'
'; } // remove old error holders $('.failure, .ticketErrorHolder, #refresh-manual').remove(); /* *** Invalid Image replacement *** */ $('.main img, .main input[type="image"]').error(function() { $(this).unbind("error").attr("src", "themes/AdminLTE/dist/img/image_not_found.png").attr("style", "max-width:250px;").removeAttr('height'); }); /* *** Theme Changer *** */ $('#themeChanger').change(function() { themeChanger($(this).val(), true); }); /* *** Login Page Mod *** */ if(location.pathname.substring(location.pathname.length-1) == "/" || location.pathname.substring(location.pathname.length-9) == "index.php") { // get recaptcha if ($('.g-recaptcha').length > 0) { var recaptcha_pubkey = $('.g-recaptcha').attr('data-sitekey'); var recaptcha = "
"; } else { var recaptcha = ""; } // login form mod if($('form[name="login_form"]').length > 0) { // clear possible storage vars clearLocalStorageItems(); $('select[name=lang]').addClass('form-control'); var title = $('.main h4').text(); var lang = $('[name="login_form"] tr:nth-child(1) td:first-child').text().replace(':', ''); var user = $('[name="login_form"] tr:nth-child(2) td:first-child').text().replace(':', ''); var pass = $('[name="login_form"] tr:nth-child(3) td:first-child').text().replace(':', ''); var forgot = $('[href="?m=lostpwd"]').text(); var lbtn = $('[name="login"]').val(); var langinput = $('[name="lang"]').parent('td').html(); if($('[href="?m=register&p=form"]').length > 0) { var bottomLinks = '\

\ '+forgot+'\

\

\ '+$('[href="?m=register&p=form"] > span').text()+'\

\ '; } else { var bottomLinks = '\

\ '+forgot+'\

\ '; } new_form = '\
\
\ \
\
\ \
\
\
\
\ \
\
\ \
\
\
\
\ '+langinput+'\
\
\ \
\
\
\ '+recaptcha+'\
\
\ \
\
\
\ '+bottomLinks+'\ '; $('select[name=lang] > option:first-child').replaceWith(''); } // *** Lost Password Form *** if(window.location.href.indexOf('?m=lostpwd') > -1) { var title = $('.content-header h2').text(); if($('.main form').length==0) { // *** Error Message *** var err = $('.main strong').text(); var err_msg = []; $('.main p').each(function() { err_msg.push($(this).html()); }); var thisErrOut = ''; if(allMessages=='') { thisErrOut = '
'+err+'
'; } new_form = '\ ' + thisErrOut + '\

\ Back\

\ '; } else { var alert = ""; if ($('.main td > p').length > 0) { var alertClass = 'success'; if($('.main td > p').attr('style')=='color: red;') { var alertClass = 'danger'; } var errt = []; $('.main td > p').each(function() { errt.push($(this).text()); }); if(errt) { var alert = '
'; } } var email = $('.main label[for="email_address"]').text(); var lbtn = $('td > [type="submit"]').val(); var bbtn = $('[action="index.php"] > input[type="submit"]').val(); new_form = '\ '+alert+'\
\
\ \
\
\ \
\
\
\
\
\ \
\
\
\

\ '+bbtn+'\

\ '; } } // register form mod if($('form[action^="?m=register"]').length > 0) { var title = $('.main h2').text(); var user = $('[name="loginForm"] label[for="login_name"]').text().replace(':', ''); var pass = $('[name="loginForm"] label[for="users_passwd"]').text().replace(':', ''); var vpass = $('[name="loginForm"] label[for="users_cpasswd"]').text().replace(':', ''); var fname = $('[name="loginForm"] label[for="users_fname"]').text().replace(':', ''); var lname = $('[name="loginForm"] label[for="users_lname"]').text().replace(':', ''); var email = $('[name="loginForm"] label[for="users_email"]').text().replace(':', ''); var ucv = $('[name="users_comment"]').val(); var sbtn = $('[name="Submit"]').val(); var errout = ""; if($('.main > table').length > 0) { var errt = []; $(".main > table tr").each(function () { var tdtxt = $(this).find('td').text(); if(!tdtxt.includes('
  • ")+'
  • '; } new_form = '\ ' + errout + '\
    \
    \ \
    \
    \ \
    \
    \
    \
    \ \
    \
    \ \
    \
    \
    \
    \ \
    \
    \ \
    \
    \
    \
    \ \
    \
    \ \
    \
    \
    \
    \ \
    \
    \ \
    \
    \
    \
    \ \
    \
    \ \
    \
    \
    \ \ '+recaptcha+'\
    \
    \ \
    \
    \
    \ '; } var lbm = '' if(title !== undefined) { if (title.length > 0) { lbm = '

    ' + title + '

    '; } } var boxClass = 'login-box'; var headerContent = '\ \ \ '; if(new_form !== undefined) { $('body').addClass('login-page'); } if(allMessages && !errMessages && new_form === undefined) { var new_form = '

    ' } else if(new_form === undefined) { boxClass = 'col-md-8 col-12 main'; headerContent = '

    ' + $('.main > h2').text() + '

    '; $('body').removeClass('login-page'); $('.main > h2').remove(); var new_form = $('.main').html(); } // menu links var allLinks = []; $('.menu a').each(function() { allLinks.push(''); }); // Maintenance Hook $.ajax({ async: true, type: 'GET', url: 'themes/AdminLTE/dist/php/settings.php?m=global&p=check&v=maintenance', dataType: 'json', success: function(data) { if(data['maintenance_mode'] > 0) { toastr.info(data['maintenance_message'], data['maintenance_title'], { "timeOut": 0, "extendedTimeOut": 0, "preventDuplicates": true, "disableTimeOut" : true, "closeButton": true, }); toastr.error('', langConsts['OGP_LANG_maintenance_mode_on'], { "timeOut": 0, "extendedTimeOut": 0, "preventDuplicates": true, "disableTimeOut" : true, "closeButton": true, }); } } }); var new_body = '\ \
    \ ' + allMessages + '\
    \
    \ ' + headerContent + '\
    \
    \ ' + lbm + '\ ' + new_form + '\
    \
    \
    \ '; // apply new body var preLoader = $('.preloader'); $('body').empty().html(preLoader); $('body').append(new_body); // navbar toggler z-index hook $('.navbar-toggler').click(function() { console.log("css: " + $(this).parent('.navbar').css('z-index')); if($(this).parent('.navbar').css('z-index') == 'auto') { $(this).parent('.navbar').css('z-index', 9999); }else { $(this).parent('.navbar').css('z-index', ''); } }); } else { /* *** Messages Replacement *** */ $('section.content > .container-fluid').prepend(allMessages); /* *** Remove CSS Files *** */ $('link[href="css/global.css"]').remove(); $('link[href="js/bootstrap/css/bootstrap-combined.min.css"]').remove(); /* *** Removing Chars from Links *** */ $('a:not(.user_menu_link), a span').each(function(){ $(this).html($(this).html().replace('[','').replace(']','')); }); /* *** Table Styles *** */ $('table:not(".online_servers")').each(function() { $(this).addClass('table table-striped table-sm').removeAttr('style').wrap('
    '); // add top border none for first row if table has no head if($(this).find('th').length==0) { $(this).find('tr').first().find('td').css('border-top', 'none'); } }); $('table .first_row > td').each(function() { $(this).replaceWith(''+$(this).html()+''); }); /* *** Root Links to Buttons *** */ $('section > div > a').addClass('btn btn-primary'); /* *** Add Header to Content *** */ // var currentTitle = $('section > div > h2').first(); var currentTitle = $('.main > h2').first(); if(currentTitle.length) { var addHeader = ' \
    \
    \
    \
    \

    ' + $(currentTitle).text() + '

    \
    \
    \
    \
    \ '; $(currentTitle).remove(); $('body > .wrapper > .content-wrapper').prepend(addHeader); } /* *** Forms *** */ var buttons = $('button:not(".btn-tool"), input[type="button"], input[type="submit"], input[type="SUBMIT"], input[type="reset"], [href^="?m=gamemanager&p=update&update=refresh"], .main [href="?m=modulemanager&p=update"], .main [href="?m=simple-billing&p=shop"], .main [href^="home.php?m=TS3Admin&changevServer"], .main [href^="?m=gamemanager&p=game_monitor&home_id="], .serverIdToggle, .main [href="?m=settings&p=api_hosts"]'); $(buttons).addClass('btn btn-sm btn-primary'); var inputs = $('input, textarea, select').not('input[type=button], input[type="submit"], input[type="SUBMIT"], input[type=reset], input[type=radio], input[type=checkbox], input[type=image], input[type="file"]'); $(inputs).addClass('form-control').removeAttr('style'); /* *** Remove unwanted fixed Styles *** */ $('[style]').css('width', '').css('float', ''); $('.clear').remove(); $('pre').removeAttr('style'); /* *** MENU *** */ // original menu is nested in divs. remove them var menu = $('.menu > ul').html(); $('.menu-bg').remove(); $('.nav-sidebar').html(menu); $('.menu ul[id^=submenu] span').each(function() { var img_url = $(this).attr('data-icon_path'); $(this).before(""); }); // tree class for all ul elements $('.nav-sidebar ul').removeAttr('id').addClass('nav').addClass('nav-treeview'); $('.nav-sidebar li').each(function() { var tli = $(this); // item class for all li elements $(tli).addClass('nav-item'); // check if element has submenu and add dropdown icon if($(tli).has('ul').length) { $(tli).children('a').children('span').append(''); } // check all nav links and add active/selected state $(tli).find('a').each(function() { // links need nav-link class var ta = $(this); $(ta).addClass('nav-link text-truncate'); // check if current link has classes var thisClass = $(ta).attr('class'); if(thisClass !== undefined) { // check if a class contains selected to set the element active/open if(thisClass.includes('selected')) { $(tli).addClass('menu-open'); $(ta).addClass('active'); } } }); // Replace all span with paragraphs $(tli).find('span').each(function() { // check if span has img attribute and add it before paragraph var checkImage = $(this).attr('data-icon_path'); if(checkImage !== undefined) { $(this).replaceWith('

    ' + $(this).html() + '

    '); }else { $(this).replaceWith('

    ' + $(this).html() + '

    '); } }); }); // Add Default Icon to each Link $('.nav-sidebar .nav-link').each(function() { // check if link contains paragraph if($(this).find('p').length==0) { // fix missing paragraph $(this).html('

    '+$(this).html()+'

    '); } // check if nav-link has icon missing if($(this).find('img').length==0) { if($(this).parents('.nav-item').hasClass('osIcon')) { // add OS icon if($(this).parents('.osIcon').attr('class').includes('linux')) { $(this).prepend(''); }else { $(this).prepend(''); } }else { // Add Default Icon $(this).prepend(''); } } }); // Add Submenu Icon to all Submenus $('.nav-sidebar .nav-treeview').each(function() { if($(this).has('ul').length) { $(this).children('li').children('a').children('p').append(''); } }); // Only follow Link when Menu is open $('.nav-sidebar .nav-item > a').click(function(e) { if($(this).parent('li').hasClass('menu-open')) { e.stopPropagation(); // e.preventDefault(); window.location = $(this).attr('href'); } }); // Remove User Element and update top User Area var userNavItem = $('.nav-sidebar [href^="?m=user_admin&p=edit_user&user_id"]').parent('.nav-item'); var userProfileLink = $(userNavItem).children('a').attr('href'); var userId = new URLSearchParams(userProfileLink).get('user_id'); var setUserAvatar = 'themes/AdminLTE/dist/img/default-avatar.png'; if(userId) { if(!localStorage.getItem('avatar_' + userId)) { var d = new Date(); // set loading avatar setUserAvatar = 'themes/AdminLTE/dist/img/spinner.gif'; $('.user-panel > .image > img').attr('src', setUserAvatar + "?t=" + d.getTime()).removeClass('elevation-2'); // load avatar from db $.ajax({ cache: false, async: true, type: 'GET', url: 'themes/AdminLTE/dist/php/settings.php?m=user&p=getavatar&userid=' + userId, success: function(avatar) { var d = new Date(); // set avatar cache localStorage.setItem('avatar_' + userId, avatar); // set user avatar $('.user-panel > .image > img').attr('src', avatar + "?t=" + d.getTime()).addClass('elevation-2'); // set user avatar variable setUserAvatar = avatar; } }); }else { // set user avatar variable setUserAvatar = localStorage.getItem('avatar_' + userId); } } // set user avatar and link $('.user-panel > .image > img').attr('src', setUserAvatar + "?t=" + d.getTime()); $('.user-panel > .info > a').text($(userNavItem).children('a').children('p').text()).attr('href', userProfileLink); // check if user contains additional submenus if($(userNavItem).find('.nav').find('.nav-item:not(:last-of-type)').length > 0) { $(userNavItem).find('.nav').find('.nav-item:not(:last-of-type)').each(function() { $('.main-sidebar .nav-sidebar').append('
  • ' + $(this).html() + '
  • '); }); } // remove old user menu item $(userNavItem).remove(); /* *** add missing menu highlights *** */ var checkMenuLinks = ['?m=subusers', '?m=user_admin&p=show_groups']; checkMenuLinks.forEach((url, index) => { if(window.location.href.indexOf(url) > -1) { $('.main-sidebar .nav-sidebar [href^="' + url + '"]').addClass('active'); } }); // menu higlight fix for theme settings if(window.location.href.indexOf('?m=settings&p=themes') > -1) { $('.main-sidebar .nav-sidebar [href="?m=settings"]').removeClass('active'); } // menu higlight fix for mysql admin if(window.location.href.indexOf('?m=mysql&p=edit') > -1) { $('.main-sidebar .nav-sidebar [href="?m=mysql&p=mysql_admin"]').addClass('active').parent('.nav-item').parent('.nav').parent('.nav-item').addClass('menu-open'); } // menu higlight fix for gameserver if(window.location.href.indexOf('admin')==-1 && window.location.href.indexOf('m=user_games')==-1 && window.location.href.indexOf('m=config_games')==-1 && window.location.href.indexOf('m=fast_download')==-1) { if(window.location.href.indexOf('home_id-mod_id-ip-port') > -1 || window.location.href.indexOf('home_cfg_id') > -1 || window.location.href.indexOf('&home_id') > -1) { // specific server (can also be logs etc) if(window.location.href.indexOf('home_id-mod_id-ip-port') > -1) { var uri = window.location.href.substring(window.location.href.indexOf('home_id-mod_id-ip-port=')); // check if uri contains other parameters if(uri.includes('&')) { // cut uri before next parameter uri = uri.substring(0, uri.lastIndexOf("&")); } uri = 'href$="'+uri+'"'; } // all servers by config else if(window.location.href.indexOf('home_cfg_id') > -1) { var uri = window.location.href.substring(window.location.href.indexOf('?')); uri = 'href$="'+uri+'"'; } // specific server by home_id else if(window.location.href.indexOf('home_id') > -1) { const urlParams = new URLSearchParams(window.location.search); var homeId = urlParams.get('home_id'); var uri = '?m=gamemanager&p=game_monitor&home_id-mod_id-ip-port='+homeId+'-'; uri = 'href^="'+uri+'"'; } $('.nav-sidebar .active').removeClass('active'); $('.nav-sidebar .nav-link['+uri+']').addClass('active'); if(window.location.href.indexOf('home_id-mod_id-ip-port') > -1 || window.location.href.indexOf('home_cfg_id') > -1 || window.location.href.indexOf('home_id') > -1) { $('.nav-sidebar .nav-link['+uri+']').parents('.nav-item').addClass('menu-open'); } } } /* *** Pagination *** */ $('#pagination').each(function() { // remove empty paginations if($(this).html().length==0) { $(this).remove(); }else { $(this).replaceWith(''); var pm = $('.pagination'); var ps = $(pm).find('[class$="_paginationStart"]'); var pp = $(pm).find('[class$="_paginationPages"]'); var pe = $(pm).find('[class$="_paginationEnd"]'); if($(ps).length) { $(ps).find('a').each(function() { var tl = $(this).attr('href'); var tc = $(this).text(); $(pm).append('
  • '+tc+'
  • '); }); if($(ps).find('span').length) { $(pm).append('
  • ...
  • '); } $(ps).remove(); } $(pp).find('a').each(function() { var tl = $(this).attr('href'); var tc = $(this).text().replace('[','').replace(']',''); if($(this).is('[class$="_currentPageLink"]')) { $(pm).append('
  • '+tc+'
  • '); }else { $(pm).append('
  • '+tc+'
  • '); } }); $(pp).remove(); if($(pe).length) { if($(pe).find('span').length) { $(pm).append('
  • ...
  • '); } $(pe).find('a').each(function() { var tl = $(this).attr('href'); var tc = $(this).text(); $(pm).append('
  • '+tc+'
  • '); }); $(pe).remove(); } } }); /* *** Message Replacement *** */ var msgReplBodySkip = ['services', 'simple-billing']; var skipMsgRepl = false; for(i = 0; i < msgReplBodySkip.length; i++) { if($('.main').hasClass(msgReplBodySkip[i])) { skipMsgRepl = true; } } $('.success, .warning, .error, #refresh-manual').each(function() { if(!$('.main').hasClass('services')) { if($(this).hasClass('success')) { var thisClass = 'success'; } else if($(this).hasClass('warning')) { var thisClass = 'warning'; } else if($(this).hasClass('error')) { var thisClass = 'error'; } else if($(this).is('#refresh-manual')) { var thisClass = 'info'; } if(!skipMsgRepl) { $(this).replaceWith('

    '+$(this).html()+'

    '); }else { $(this).addClass('text-' + thisClass); } } }); /* *** Footer Mod *** */ $('.main-footer .OGPVersionArea').addClass('d-none'); $('.main-footer a').attr('target', '_blank').addClass('text-dark'); $('.main-footer .footer').html($('.main-footer .footer').html().replace("Theme - ", "Theme for OGP by oNdsen - ")) $('.main-footer .footer.center').removeClass('center'); $('.main-footer .OGPVersionArea .version').remove() $('.main-footer .OGPVersionArea').removeClass('inline-block').addClass('d-inline-block'); $('.main-footer .footer > br').last().remove() } /* *** Get Theme Settings *** */ // check if theme cache is set if(!localStorage.getItem('theme')) { // load theme settings from db $.ajax({ cache: false, async: true, type: 'GET', url: 'themes/AdminLTE/dist/php/settings.php?m=global&p=theme', dataType: 'json', success: function(theme) { // create theme cache localStorage.setItem('theme', theme); // change theme themeChanger(theme); } }); }else { // change theme themeChanger(localStorage.getItem('theme')); } // fill theme changer options var themeOptions = ['dark','light','mixed'] themeOptions.forEach(function(t) { if(localStorage.getItem('theme')==t) { $('#themeChanger').append(''); }else { $('#themeChanger').append(''); } }); /* *** Get ThemeNavWidth Setting *** */ if(!localStorage.getItem('themeNavWidth')) { // load themeNavWidth settings from db $.ajax({ cache: false, async: true, type: 'GET', url: 'themes/AdminLTE/dist/php/settings.php?m=global&p=themeNavWidth', dataType: 'json', success: function(themeNavWidth) { // create themeNavWidth cache localStorage.setItem('themeNavWidth', themeNavWidth); // set themeNavWidth setNavWidth(themeNavWidth); } }); }else { // set themeNavWidth setNavWidth(localStorage.getItem('themeNavWidth')); } /* *** Get Theme Logo Settings *** */ // check if theme logo cache is set if(!localStorage.getItem('themeLogo')) { // load themeLogo settings from db $.ajax({ cache: false, async: true, type: 'GET', url: 'themes/AdminLTE/dist/php/settings.php?m=global&p=themeLogo', dataType: 'json', success: function(themeLogo) { if(themeLogo!='0') { // create themeLogo cache localStorage.setItem('themeLogo', themeLogo); var d = new Date(); // set themeLogo $('img.brand-image').attr('src', localStorage.getItem('themeLogo') + "?" + d.getTime()); } } }); }else { // check if file exists and then apply themeLogo $.get(localStorage.getItem('themeLogo')).done(function() { var d = new Date(); // set themeLogo $('img.brand-image').attr('src', localStorage.getItem('themeLogo') + "?" + d.getTime()); }); } /* *** Get themeServerstats Setting *** */ if(!localStorage.getItem('themeServerstats')) { // load themeServerstats settings from db $.ajax({ cache: false, async: true, type: 'GET', url: 'themes/AdminLTE/dist/php/settings.php?m=global&p=themeServerstats', success: function(themeServerstats) { // create themeServerstats cache localStorage.setItem('themeServerstats', themeServerstats); } }); } /* *** Avatar Upload *** */ $('input[type=file]#userAvatar').change(function() { var userId = new URLSearchParams(userProfileLink).get('user_id'); $(this).simpleUpload('themes/AdminLTE/dist/php/settings.php?m=user&p=setavatar&userid=' + userId, { allowedExts: ["jpg", "jpeg", "jpe", "jif", "jfif", "jfi", "png", "gif"], allowedTypes: ["image/pjpeg", "image/jpeg", "image/png", "image/x-png", "image/gif", "image/x-gif"], maxFileSize: 5242880, // 5mb in bytes limit: 1, start: function() { toastr.info('Avatar Upload initiated'); }, success: function(data) { var jsonData = $.parseJSON(data); if(jsonData['code']=="success") { $.ajax({ url: jsonData['data'], type: 'HEAD', error: function() { toastr.error('Error: Uploaded File not found'); }, success: function() { var d = new Date(); // overwrite avatar cache localStorage.setItem('avatar_' + userId, jsonData['data']); // launch success toastr toastr.success('Successfully uploaded new Avatar'); // set user avatar $('.user-panel > .image > img').attr('src', jsonData['data'] + "?t=" + d.getTime()); } }); }else { toastr.error(jsonData['data']); } }, error: function(error) { toastr.error('Error: ' + error); } }); }); /* *** File Style Hack *** */ $.fn.input_file_styling = function() { var totalFileInputs = 1 $('.main input[type="file"]').each(function() { if($(this).parent().hasClass('custom-file')==false) { if(!$(this).is('[id]')) { // add id to element $(this).attr('id', 'file-'+totalFileInputs); } $(this).css('display', 'none').wrap('
    '); $(this).parent('.custom-file').append(''); } totalFileInputs++; }); // label text fix $(document).on('change', ':file', function() { numFiles = $(this).get(0).files ? $(this).get(0).files.length : 1, label = $(this).val().replace(/\\/g, '/').replace(/.*\//, ''); $(this).next('label').text(label); }); } // Init Call of the Function $.fn.input_file_styling(); // Restyle after Adding a File Input $('#add_file_attachment').click(function() { setTimeout($.fn.input_file_styling, 1); }); /* *** Tooltip Replacement *** */ $('.main .image-tip').each(function() { $(this).attr('data-toggle', 'tooltip').attr('data-html', 'true').attr('title', $(this).find('.tip').html()).html(''); }); // init tooltips $('[data-toggle="tooltip"]').tooltip(); }); $(window).load(function() { $('tr, td, div:not([class*="nicEdit"])').css("background-color", ""); $('div:not([class*="nicEdit"], #refreshed-0)').css("border", "").css("height", ""); $('input').css("width", ""); if($.trim($("div").text()) == "") { $(this).remove(); } $('.main-footer .versionInfo').click(function() { $('.OGPVersionArea, .OGPVersionArea .version, .OGPVersionArea .versionNumber').removeClass('d-none').removeClass('hide'); // add blink class to versionNumber $('.OGPVersionArea .versionNumber').addClass('shortblink'); // remove after 4 seconds setTimeout(function(){ $('.OGPVersionArea .versionNumber').removeClass('shortblink'); }, 4000); var copy = copyToClipboard($('.OGPVersionArea .versionNumber')); toastr.info('"' + copy + '" ' + $('.OGPVersionArea .copyVersionResult').attr('lang')); }); // circular notifications if($('body > #notification').length > 0) { var noteMsg = $('body > #notification').html().split("
    "); $('body > #notification').remove(); $('.content > .container-fluid').prepend('\
    \
    \
    \
    ' + noteMsg[0] + '
    \

    ' + noteMsg[1] + '

    \
    \
    \
    \ '); } // content to cards mod if(window.location.href.indexOf('m=dsi&p=admin_dsi') > -1 || window.location.href.indexOf('?m=administration&p=main') > -1) { $('.main').removeClass('main'); $('section.content > .container-fluid > .row > div').addClass('main'); var fillBox = false $('.main .card-body > *').each(function() { if($(this).is('h2')) { // add new box $('.main').append('\
    \
    \
    ' + $(this).text() + '
    \
    \
    \
    \
    \ '); // remove title $(this).remove(); // set fillBox to true, so content filling can start fillBox = true }else { if(fillBox) { // append this object to newest card $('.main > .card:last-child > .card-body').append($(this)); } } }); } // auto scroll down all logs if($('.content pre').length>0) { // $('.content pre').scrollTop($('.content pre')[0].scrollHeight); $('.content pre').each(function() { $(this).scrollTop($(this)[0].scrollHeight); }); } /* *** End of JS - Check if .main is empty to remove Element *** */ if($('.main').length > 0) { if($('.main').html().trim().length==0) { $('.main').parent('.card').remove(); } } }); /* *** menu sidebar hover hack because firefox doesnt support nested pseudo classes *** */ $(document).on('collapsed.lte.pushmenu', function() { $('body.sidebar-collapse .main-sidebar').hover(function() { $(this).addClass('hover'); }, function() { $(this).removeClass('hover'); }); }); function themeChanger(changeTo, save = false) { if(changeTo=='dark') { $('body').removeClass('light-mode mixed-mode').addClass('dark-mode'); $('nav.main-header').removeClass('navbar-light').addClass('navbar-dark'); $('aside.main-sidebar').removeClass('sidebar-light-primary').addClass('sidebar-dark-primary'); $('aside.control-sidebar').removeClass('control-sidebar-light').addClass('control-sidebar-dark'); if(!localStorage.getItem('themeLogo')) { $('img.brand-image').attr('src', 'themes/AdminLTE/dist/img/ogp_logo_dark.svg'); } $('link[href*="jquery-ui.min"]').attr('href', 'themes/AdminLTE/plugins/jquery-ui/jquery-ui.min.dark.css'); $('link[href*="jquery-ui.structure.min"]').attr('href', 'themes/AdminLTE/plugins/jquery-ui/jquery-ui.structure.min.dark.css'); $('link[href*="jquery-ui.theme.min"]').attr('href', 'themes/AdminLTE/plugins/jquery-ui/jquery-ui.theme.min.dark.css'); if(save) { $.ajax({ async: true, type: 'GET', url: 'themes/AdminLTE/dist/php/settings.php?m=global&p=theme&v=dark', dataType: 'json', success: function(data) { toastr.success('Successfully saved theme to dark'); localStorage.setItem('theme', 'dark'); } }); } } else if(changeTo=='light') { $('body').removeClass('dark-mode mixed-mode').addClass('light-mode'); $('nav.main-header').removeClass('navbar-dark').addClass('navbar-light'); $('aside.main-sidebar').removeClass('sidebar-dark-primary').addClass('sidebar-light-primary'); $('aside.control-sidebar').removeClass('control-sidebar-dark').addClass('control-sidebar-light'); if(!localStorage.getItem('themeLogo')) { $('img.brand-image').attr('src', 'themes/AdminLTE/dist/img/ogp_logo_light.svg'); } $('link[href*="jquery-ui.min"]').attr('href', 'themes/AdminLTE/plugins/jquery-ui/jquery-ui.min.light.css'); $('link[href*="jquery-ui.structure.min"]').attr('href', 'themes/AdminLTE/plugins/jquery-ui/jquery-ui.structure.min.light.css'); $('link[href*="jquery-ui.theme.min"]').attr('href', 'themes/AdminLTE/plugins/jquery-ui/jquery-ui.theme.min.light.css'); if(save) { $.ajax({ async: true, type: 'GET', url: 'themes/AdminLTE/dist/php/settings.php?m=global&p=theme&v=light', dataType: 'json', success: function(data) { toastr.success('Successfully saved theme to light'); localStorage.setItem('theme', 'light'); } }); } } else if(changeTo=='mixed') { $('body').removeClass('dark-mode').addClass('light-mode mixed-mode'); $('nav.main-header').removeClass('navbar-light').addClass('navbar-dark'); $('aside.main-sidebar').removeClass('sidebar-light-primary').addClass('sidebar-dark-primary'); $('aside.control-sidebar').removeClass('control-sidebar-dark').addClass('control-sidebar-light'); if(!localStorage.getItem('themeLogo')) { $('img.brand-image').attr('src', 'themes/AdminLTE/dist/img/ogp_logo_dark.svg'); } $('link[href*="jquery-ui.min"]').attr('href', 'themes/AdminLTE/plugins/jquery-ui/jquery-ui.min.light.css'); $('link[href*="jquery-ui.structure.min"]').attr('href', 'themes/AdminLTE/plugins/jquery-ui/jquery-ui.structure.min.light.css'); $('link[href*="jquery-ui.theme.min"]').attr('href', 'themes/AdminLTE/plugins/jquery-ui/jquery-ui.theme.min.light.css'); if(save) { $.ajax({ async: true, type: 'GET', url: 'themes/AdminLTE/dist/php/settings.php?m=global&p=theme&v=mixed', dataType: 'json', success: function(data) { toastr.success('Successfully saved theme to mixed'); localStorage.setItem('theme', 'mixed'); } }); } } // ace editor dark skin if($('.ace_editor').length > 0) { if(changeTo=='dark') { $.getScript('modules/litefm/ace/theme-tomorrow_night.js', function(data, textStatus, jqxhr) { $('.ace_editor').removeClass('ace-tomorrow').addClass('ace-tomorrow-night'); }); } else if(changeTo=='light') { $('.ace_editor').removeClass('ace-tomorrow-night').addClass('ace-tomorrow'); } } } function setNavWidth(width) { // only set if wider than 250px (default) and smaller than 350px (max) if(width>250 && width<=350) { // avoid dual set if($('style[id="themeNavWidth"]').length>0) { $('style[id="themeNavWidth"]').remove(); } // add custom width style to body $('body').prepend('\ \ '); }else { // remove possible themeNavWidth style if($('style[id="themeNavWidth"]').length>0) { $('style[id="themeNavWidth"]').remove(); } $('body').prepend('\ \ '); } } function copyToClipboard(node) { var elementText = $(node).text().replace(/\s/g, ""); var $temp = $(""); $("body").append($temp); $temp.val(elementText).select(); document.execCommand("copy"); $temp.remove(); return elementText; } function clearLocalStorageItems() { // loop trough all localStorage Items Object.keys(localStorage).forEach(function(key) { // remove item localStorage.removeItem(key); }); } function reloadBodyScripts() { console.log("reloaded body scripts"); // check if main contains script containers or script includes and reload them at the end $('.main').find('script').each(function() { if(this.hasAttribute('src')===false) { // script content $('body').append(''); } else { // script include $('body').append(''); } $(this).remove(); }); }