From 7289ec5588005725f81f4b04d28f33bf1434bd5e Mon Sep 17 00:00:00 2001 From: vados-dev Date: Fri, 6 Mar 2026 16:29:24 +0300 Subject: [PATCH] Auto-commit: dirlist.js updated on 3/6/2026 --- html/.include/js/dirlist.js | 133 ++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 html/.include/js/dirlist.js diff --git a/html/.include/js/dirlist.js b/html/.include/js/dirlist.js new file mode 100644 index 000000000..36d470df8 --- /dev/null +++ b/html/.include/js/dirlist.js @@ -0,0 +1,133 @@ + // + // Configure BetterListing here: + var websiteName = 'Загрузки'; + var websiteURL = '*URL сайта*'; + // End of normal settings. + // + + $(document).ready(function(){ + + // Working on nginx HTML and applying settings. + var text = $("h1").text(); + var array = text.split('/'); + var last = array[array.length-2]; + var dirStructure = $("a").text(); + var dirStructure = document.getElementsByTagName('a')[0].href; + var dir = text.substring(10); + var currentDir = last.charAt(0).toUpperCase() + last.slice(1); + var dirTrun; + + // Truncate long folder names. + if (currentDir.length > 19){ + var currentDir = currentDir.substring(0, 18) + '...'; + } + + // Updating page title. + document.title = websiteName; + + // Add back button. + $("h1").html('

логотип

'); + + if (dir.length > 90) { + dirTrun = dir.replace(/(.{90})/g, "$1\n") + } else { + dirTrun = dir.substring(0, dir.length - 1); + } + + // Add subtitle and back arrow. + $("h1").append('

Загрузить: ' + dirTrun.slice(0) + '

'); + + // Add search box. + $("h1").prepend('
'); + + // Add parent directory bit. + $("a").eq(1).html('Parent Directory'); + + // Add titles. + $("pre").prepend('
Name Time Size
'); + + // Establish supported formats. + var list = new Array(); + var formats = ["bin", "jpg", "gif", "png", "html", "css", "zip", "iso", "tiff", "ico", "psd", "pdf", "exe", "rar", "deb", "swf", "7z", "doc", "docx", "xls", "xlsx", "pptx", "ppt", "txt", "php", "js", "c", "c++", "torrent", "sql", "wmv", "avi", "mp4", "mp3", "wma", "ogg", "msg", "wav", "py", "java", "gzip", "jpeg", "raw"]; + + // Run when text is entered in the search box. + $('#custom-search-form').on('input',function(e){ + e.preventDefault(); + var target = $('#searchBox').val(); + filter(target); + }); + + // Instant search. + function filter(target){ + var parent_directory = 'parent directory'; + $('pre a').each(function(){ + var arraySearch = $(this).attr('href'); + var arraySearch = decodeURIComponent( arraySearch ) + // Check the href data for searched term. Using href because the link label truncates if the file or folder name is too long. + // Special handling for 'Parent Directory' as the href data doesn't contain that word. + if (arraySearch.toLowerCase().indexOf(target.toLowerCase()) > -1 || (($(this).text() == 'Parent Directory') && (parent_directory.indexOf(target.toLowerCase()) > -1))){ + $(this).show(); + $($(this)[0].nextSibling).css('display', 'inline'); + } else { + $(this).hide(); + if($($(this)[0].nextSibling).hasClass('hideMe')) { + $($(this)[0].nextSibling).css('display', 'none'); + } else { + $($(this)[0].nextSibling).wrap('