You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.0 KiB

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset='utf-8'>
  5. <title>listing directory {directory}</title>
  6. <style>{style}</style>
  7. <script>
  8. function $(id){
  9. var el = 'string' == typeof id
  10. ? document.getElementById(id)
  11. : id;
  12. el.on = function(event, fn){
  13. if ('content loaded' == event) {
  14. event = window.attachEvent ? "load" : "DOMContentLoaded";
  15. }
  16. el.addEventListener
  17. ? el.addEventListener(event, fn, false)
  18. : el.attachEvent("on" + event, fn);
  19. };
  20. el.all = function(selector){
  21. return $(el.querySelectorAll(selector));
  22. };
  23. el.each = function(fn){
  24. for (var i = 0, len = el.length; i < len; ++i) {
  25. fn($(el[i]), i);
  26. }
  27. };
  28. el.getClasses = function(){
  29. return this.getAttribute('class').split(/\s+/);
  30. };
  31. el.addClass = function(name){
  32. var classes = this.getAttribute('class');
  33. el.setAttribute('class', classes
  34. ? classes + ' ' + name
  35. : name);
  36. };
  37. el.removeClass = function(name){
  38. var classes = this.getClasses().filter(function(curr){
  39. return curr != name;
  40. });
  41. this.setAttribute('class', classes);
  42. };
  43. return el;
  44. }
  45. function search() {
  46. var str = $('search').value
  47. , links = $('files').all('a');
  48. links.each(function(link){
  49. var text = link.textContent;
  50. if ('..' == text) return;
  51. if (str.length && ~text.indexOf(str)) {
  52. link.addClass('highlight');
  53. } else {
  54. link.removeClass('highlight');
  55. }
  56. });
  57. }
  58. $(window).on('content loaded', function(){
  59. $('search').on('keyup', search);
  60. });
  61. </script>
  62. </head>
  63. <body class="directory">
  64. <input id="search" type="text" placeholder="Search" autocomplete="off" />
  65. <div id="wrapper">
  66. <h1>{linked-path}</h1>
  67. {files}
  68. </div>
  69. </body>
  70. </html>