Nice little directory browser :D
at master 112 lines 4.1 kB view raw
1@* 2 This file is part of Utatane. 3 4 Utatane is free software: you can redistribute it and/or modify it under 5 the terms of the GNU Affero General Public License as published by the Free 6 Software Foundation, either version 3 of the License, or (at your option) 7 any later version. 8 9 Utatane is distributed in the hope that it will be useful, but WITHOUT ANY 10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for 12 more details. 13 14 You should have received a copy of the GNU Affero General Public License 15 along with Utatane. If not, see <http://www.gnu.org/licenses/>. 16*@ 17 18<header class="n-box"> 19 <Breadcrumbs Path="@Path" /> 20 <div id="toolbar"> 21 <button id="reload-table" 22 class="clickable" 23 type="button" 24 aria-label="Reload table" 25 _=" 26-- shortcut: only the active <th> will have aria-sort 27on click send nhnd:run to <th[aria-sort]/> 28" 29 > 30 <span class="[vertical-align:sub]">↻</span> 31 </button> 32 33 <GoBackButton Path="@Path"/> 34 35 <abbr id="search-label" title="Search">🔎</abbr> 36 <input id="search" class="border-black" type="search" aria-labelledby="search-label" _="@_scriptForIdSearch" /> 37 38 <abbr id="rx-label" title="Search with RegEx">.*</abbr> 39 <input id="use-rx-for-search" type="checkbox" autocomplete="off" checked aria-labelledby="rx-label" _="@_scriptForIdUseRxForSearch" /> 40 41 <span id="file-counter" class="my-auto" _="@_scriptForIdFileCounter" /> 42 </div> 43</header> 44 45@code { 46 47 [Parameter] 48 public required String Path { get; set; } 49 50 #region _hyperscript strings 51 // these are just the big ones, smaller ones are littered throughout 52 private readonly String _scriptForIdSearch = @" 53on load 54 set my value to '' 55on input 56 if (#use-rx-for-search's checked is true) then 57 make a RegExp from my value called rxSearch 58 show <tbody > tr/> in #filetable when rxSearch.test(the @data-order of .file-name in it) is true 59 otherwise 60 show <tbody > tr/> in #filetable when (the first @data-order of .file-name in it) contains my value.toLowerCase() 61 end 62on keydown[key==""Enter""] 63 if event.isComposing or event.keyCode really equals 229 then 64 exit 65 otherwise 66 send click to the first <#filetable-body > tr:not(.hidden) > .file-name > a/> 67 set my value to """" 68 end 69on keydown from body 70 make a RegExp from ""^(F|Soft)\\d"" called rx 71 if not ( 72 document.activeElement is me or -- dont repeat it! 73 event.key is """" or -- actually I forgot 74 event.ctrlKey or event.altKey or event.metaKey or -- dont react on modifier combos 75 [""Shift"", ""Tab"", ""ArrowUp"", ""ArrowRight"", ""ArrowLeft"", ""ArrowDown"", 76 ""AltGraph"", ""CapsLock"", ""Fn"", ""FnLock"", ""Hyper"", ""NumLock"", 77 ""ScrollLock"", ""Super"", ""Symbol"", ""SymbolLock"", ""OS"", ""End"", ""Home"", 78 ""PageDown"", ""PageUp"", ""Backspace"", ""Clear"", ""Delete"", ""Redo"", 79 ""Undo"", ""Accept"", ""Again"", ""Attn"", ""Cancel"", ""ContextMenu"", 80 ""Escape"", ""Find"", ""Pause"", ""Play"", ""Props"", ""Select"", ""ZoomIn"", 81 ""ZoomOut"", ""Apps"", ""BrightnessDown"", ""BrightnessUp"", ""PrintScreen"", 82 ""MediaFastForward"", ""MediaPause"", ""MediaPlay"", ""MediaPlayPause"", 83 ""MediaRecord"", ""MediaRewind"", ""MediaStop"", ""MediaTrackNext"", 84 ""MediaTrackPrevious""].includes(event.key) or -- special keys to not react on 85 rx.test(event.key) -- more special keys but these can be regexed 86 ) 87 go to the top of the body 88 focus() on me 89"; 90 91 private readonly String _scriptForIdUseRxForSearch = @" 92on load or click -- on load for if this comes checked 93 if < #use-rx-for-search:checked />'s length 94 add .font-mono to #search 95 otherwise 96 remove .font-mono from #search 97 end 98 send input to #search 99"; 100 101 private readonly String _scriptForIdFileCounter = @" 102on nhnd:update 103 set files to $('.file').length 104 set dirs to $('.directory').length 105 set my innerHTML to `${dirs} __W ${files} __X` 106" 107 .Replace("__W", Utils.AbbrIconPlain("Directories", "📁")) 108 .Replace("__X", Utils.AbbrIconPlain("Files", "📄")); 109 110 #endregion _hyperscript strings 111 112}