diff --git a/css/iconfont.css b/css/iconfont.css new file mode 100644 index 0000000..39a6df2 --- /dev/null +++ b/css/iconfont.css @@ -0,0 +1,12 @@ +.icon { + width: 1.2em; + height: 1.2em; + vertical-align: -0.15em; + fill: currentColor; + overflow: hidden; + float: left; + margin-right: 5px; +} +tr{ + line-height: 1.5em; +} diff --git a/footer.html b/footer.html index 5bae493..1ced571 100644 --- a/footer.html +++ b/footer.html @@ -9,7 +9,7 @@ for (var i=0; i' + window.unescape(segments[i]) + '<\/a>'; + breadcrumbs += '' + window.unescape(decodeURI(segments[i])) + '<\/a>'; } else if (segments.length -1 !== i) { currentPath += ''; breadcrumbs += 'Root<\/a>'; diff --git a/header.html b/header.html index 3c7a260..9064e40 100644 --- a/header.html +++ b/header.html @@ -7,7 +7,7 @@ Files... diff --git a/js/history.js b/js/history.js index 6818ece..fc169a1 100644 --- a/js/history.js +++ b/js/history.js @@ -27,7 +27,7 @@ if (!!(window.history && history.pushState)) { })(); var updateCrumbs = function() { - window.document.title = window.location.pathname; + window.document.title = decodeURI(window.location.pathname); setTimeout(function () { var loc = window.location.pathname; var segments = loc.split('/'); @@ -78,7 +78,7 @@ if (!!(window.history && history.pushState)) { if (event.target.nodeName == 'A' && event.target.innerHTML.indexOf('/') !== -1) { event.preventDefault(); swapPage(event.target.href); - var title = event.target.innerHTML; + var title = decodeURI(event.target.innerHTML); history.pushState({page: title}, title, event.target.href); updateCrumbs(); } diff --git a/js/icon.js b/js/icon.js new file mode 100644 index 0000000..5d96362 --- /dev/null +++ b/js/icon.js @@ -0,0 +1,53 @@ +var updateIcons = function(){ + var trs = document.getElementsByTagName('tr'); + var iconHTML = ''; + $('tr').each(function(idx, val){ + var td = $(this).children('td'); + if(td.length >= 1){ + td = td.eq(0); + let a = td.children('a').eq(0); + let filename = a.attr('href').split('?')[0]; + let ext = ''; + if (/\/$/.test(filename)) { + ext = 'icon-folder' + } else if (/\.(zip|7z|bz2|gz|tar|tgz|tbz2|cab|rar)$/.test(filename)) { + ext = 'icon-file-zip' + } else if (/\.(jpg|png|bmp|gif|ico|webp)$/.test(filename)) { + ext = 'icon-file-image' + } else if (/\.(flv|mp4|mkv|avi|mkv|rmvb|wmv)$/.test(filename)) { + ext = 'icon-file-video' + } else if (/\.(doc|docx|)$/.test(filename)) { + ext = 'icon-file-doc' + } else if (/\.(torrent)$/.test(filename)) { + ext = 'icon-file-bt' + } else if (/\.(txt|md)$/.test(filename)) { + ext = 'icon-file-txt' + } else if (/\.(mp3|wma|wav|ogg|ape|acc|m4a)$/.test(filename)) { + ext = 'icon-file-music' + } else if (/\.(srt|ass|ssa)$/.test(filename)) { + ext = 'icon-file-subtitles' + } else if (/\.(py|json|xml|js|php|h|aria2)$/.test(filename)) { + ext = 'icon-file-code' + } else if (/\.(nfo)$/.test(filename)) { + ext = 'icon-file-info' + } else if (/\.(pdf)$/.test(filename)) { + ext = 'icon-file-pdf' + } else if (/\.(ppt|pptx)$/.test(filename)) { + ext = 'icon-file-ppt' + } else if (/\.(xls|xlsx)$/.test(filename)) { + ext = 'icon-file-excel' + } else if (/\.(part)$/.test(filename)) { + ext = 'icon-file-bin' + } else { + ext = 'icon-file-unknown' + } + + $svg = $(iconHTML); + $svg.children('use').attr('xlink:href', '#'+ext); + td.prepend($svg); + } + }) +} +$(document).ready(function(){ + updateIcons(); +});