Supercharged Local Directory File Browser

Makes file:/// directory ("Index of...") pages (and many server-generated index pages) actually useful. Adds sidebar and preview pane; keyboard navigation for directory items; audio playback with shuffle and loop; video player; edit, preview, and save markdown/plain text files; preview images and fonts; image and font grids; sorting; user-defined shortcuts; more.

As of 02.07.2019. See ბოლო ვერსია.

  1. // ==UserScript==
  2. // @name Supercharged Local Directory File Browser
  3. // @version 4.0.0b
  4. // @description Makes file:/// directory ("Index of...") pages (and many server-generated index pages) actually useful. Adds sidebar and preview pane; keyboard navigation for directory items; audio playback with shuffle and loop; video player; edit, preview, and save markdown/plain text files; preview images and fonts; image and font grids; sorting; user-defined shortcuts; more.
  5. // @author Gaspar Schott (Michael Schrauzer) mshroud@gmail.com
  6. // @license GPL-3.0-or-later
  7. // @homepageURL https://openuserjs.org/scripts/gaspar_schot/Supercharged_Local_Directory_File_Browser
  8. // @contributionURL https://paypal.me/mschrauzer
  9. // @include file://*
  10. // @include about:blank
  11.  
  12. // @require https://code.jquery.com/jquery-latest.min.js
  13.  
  14. // @require https://cdnjs.cloudflare.com/ajax/libs/markdown-it/8.4.2/markdown-it.js
  15. // @require https://cdnjs.cloudflare.com/ajax/libs/markdown-it-footnote/3.0.1/markdown-it-footnote.min.js
  16. // @require https://cdn.jsdelivr.net/npm/markdown-it-toc-done-right@2.1.0/dist/markdown-it-toc-made-right.min.js
  17. // @require https://cdn.jsdelivr.net/npm/markdown-it-sub@1.0.0/dist/markdown-it-sub.min.js
  18. // @require https://cdn.jsdelivr.net/npm/markdown-it-sup@1.0.0/dist/markdown-it-sup.min.js
  19. // @require https://cdn.jsdelivr.net/npm/markdown-it-deflist@2.0.3/dist/markdown-it-deflist.min.js
  20. // @require https://cdn.jsdelivr.net/npm/markdown-it-multimd-table@3.1.3/dist/markdown-it-multimd-table.min.js
  21. // @require https://cdn.jsdelivr.net/npm/markdown-it-center-text@1.0.4/dist/markdown-it-center-text.min.js
  22.  
  23.  
  24. // NOTE: This script was developed in Vivaldi, running on Mac OS High Sierra. It has been tested in various Chrome and Gecko-based browsers.
  25. // It has been minimally tested on Windows and not at all on other OSes. It should work, but please report any issues.
  26. // The script does not work on local directories in Safari because Safari does not allow local directories to be browsed, but it will work on remote directories (or on local directories through a local server).
  27.  
  28. // NOTE: By default, Greasemonkey and Tampermonkey will not run scripts on file:/// urls, so for this script to work, you will have to enable it first.
  29. // For Tampermonkey, go to Chrome extension page, and tick the 'Allow access to file URLs' checkbox at the Tampermonkey extension section.
  30. // For Greasemonkey, open about:config and change greasemonkey.fileIsGreaseable to true.
  31.  
  32. // @namespace https://greatest.deepsurf.us/users/16170
  33. // ==/UserScript==
  34.  
  35. (function() {
  36. 'use strict';
  37. const $ = window.jQuery;
  38.  
  39. // ***** USER SETTINGS ***** //
  40.  
  41. const $settings = {
  42. // Paste your exported settings between the two lines below:
  43. //--------------------------------------------------------//
  44.  
  45. shortcuts: // N.B.: Directory links must end with "/", file links must end with another character.
  46. // You may add as many menus and links as you like; just copy the example below and edit as needed.
  47. // Local directory shortcuts must begin with "file:///"; external shortcuts must begin with the correct protocol ("http://" or "ftp://", etc.).
  48. // Note that because of same-origin security concerns, the browser will not allow you to navigate directly from an external webpage to a local directory.
  49. [
  50. {
  51. "menu_title":"My Sample Menu",
  52. "links":
  53. [
  54. { "link_name":"My Directory Link 1", "link":"file:///Path/To/My/Directory/" },
  55. { "link_name":"My Directory Link 2", "link":"file:///Path/To/My/Directory_2/" },
  56. { "link_name":"My External Link", "link":"https://www.mywebpage.com/" },
  57. { "link_name":"My File Link", "link":"file:///Path/To/My/File.ext" },
  58. ]
  59. },
  60. {
  61. "menu_title":"My Second Sample Menu",
  62. "links":
  63. [
  64. { "link_name":"My Directory Link 1", "link":"file:///Path/To/My/Directory/" },
  65. { "link_name":"My Directory Link 2", "link":"file:///Path/To/My/Directory_2/" },
  66. { "link_name":"My External Link", "link":"https://www.mywebpage.com/" },
  67. { "link_name":"My File Link", "link":"file:///Path/To/My/File.ext" },
  68. ]
  69. },
  70. ],
  71. // GENERAL USER SETTINGS
  72. alternate_background: true, // If true (default true), alternate sidebar row background color.
  73. apps_as_dirs: false, // Un*x/Mac OS only: if true, treat apps as directories; allows app contents to be browsed. This is the default behavior for Chrome.
  74. // If false (default), treat apps as ignored files.
  75. autoload_media: true, // If true (default: true), the first audio or video file found in a directory will be automatically selected and loaded for playback; also, cover art (if any, will be loaded in the preview pane).
  76. autoload_index_files: false, // If true (default: false), automatically select first "index.xxx" (.xxx !== .htm) file found in directory.
  77. // Note: the browser will automatically load any index.html files it finds in the directory, so the script will not work properly in such cases.
  78. theme: 'light', // Options: 'light' or 'dark'
  79. sort_by: 'default', // Choose from: 'name', 'size', 'date', 'kind', 'ext', 'default'.
  80. // default = Chrome sorting: dirs on top, files alphabetical.
  81. dirs_on_top: false, // If true, directories will always be listed firs except when sorting by "name" (since otherwise sorting by "name" would equal "default").
  82. // If false (default), directories and files will be sorted together. (In practice, dirs will typically still be separated when sorting by size, kind, and extension.)
  83. grid_font_size: 1, // Default = 1
  84. grid_image_size: 184, // Default = 184 (200px - 16px)
  85. show_details: true, // If true (default), hide file and directory details; if false, show them.
  86. show_ignored_files: false, // If true, ignored files will appear greyed-out.
  87. // If false (default), ignored files will be completely hidden from the file list;
  88. ignore_ignored_files: true, // If true (default), ignored files (see "$row_settings" below, after Keybindings and Changelog) will be greyed-out (default) in the file list and will not be loaded in the content pane when selected;
  89. // If false, ignored files will be treated like normal files, so if they are selected, the browser will attempt to download any file types it can't handle (which makes keyboard navigation inconvenient but may be useful in some circumstances).
  90. show_invisibles: true, // Un*x/Mac OS only: If true (default), files or directories beginning with a "." will be hidden.
  91. show_numbers: true, // If true (default true), number index items
  92. UI_font: 'system-ui, sans-serif', // Choose an installed font for the UI; if undefined, use browser defaults instead.
  93. UI_font_size: '13px', // Choose a default UI font size; use any standard CSS units.
  94. use_custom_icons: true, // if true (default), use custom icons for dirs and files
  95. // if false, use browser/server default icons
  96. // TEXT EDITING SETTINGS
  97. enable_text_editing: true, // If true (default), allow plain text files to be edited.
  98. default_text_view: 'preview_text', // Options: 'source_text' or 'preview_text' for text editor.
  99. // Note that split_view = true overrides this setting.
  100. split_view: true, // If true, show split view on plain text file load.
  101. // if true (default), use default preview_text setting.
  102. sync_scroll: true // If true (default: true), show split view on plain text file load
  103. // if false, use default preview_text setting.
  104. //--------------------------------------------------------//
  105. // Paste your exported settings between the above two lines.
  106. };
  107.  
  108. // $ROW_TYPES:
  109. // DO NOT DELETE ANY EXISTING CATEGORIES!
  110. // Add file extensions for sorting and custom icon display to the existing categories.
  111. // You can also define your own new categories, but do not add an extension to more than one row_type category.
  112. // Do not add leading "." to the extensions.
  113. const $row_types = {
  114. // myRowType: ['ext1','ext2'],
  115. dir: ['/'],
  116. app: ['app/','app','exe','msi'],
  117. archive: ['7z','archive','bz2','cbr','dmg','gz','pkg','rar','tar','zip'],
  118. audio: ['aac','aif','aiff','ape','flac','m4a','mp3','ogg','opus','wav','m3u'],
  119. bin: ['dll','dylib','icc','msi'],
  120. code: ['bak','bash','bash_profile','bashrc','c','cfg','cnf','codes','coffee','conf','csh','cshrc','cson','css','custom_aliases','default','dist','editorconfig','emacs','example','gemspec','gitconfig','gitignore','gitignore_global','h','hd','ini','js','json','jsx','less','list','local','login','logout','lua','mkshrc','old','php','pl','plist','pre-oh-my-zsh','profile','pth','py','rb','rc','rdoc','sass','settings','sh','strings','taskrc','tcl','viminfo','vimrc','vue','xml','yaml','yml','zlogin','zlogout','zpreztorc','zprofile','zsh','zshenv','zshrc'],
  121. database: ['db','sql', 'sqlite'],
  122. font: ['otf','ttf','woff','woff2','afm','pfb','pfm','tfm'],
  123. graphics: ['ai','book','dtp','eps','fm','icml','idml','indd','indt','inx','mif','pmd','pub','qxb','qxd','qxp','sla','swf'],
  124. htm: ['htm','html','xhtm','xhtml'],
  125. image: ['apng','bmp','gif','jpeg','jpg','png','svg','webp'],
  126. ignored_image: ['ai','arw','cr2','dng','eps','nef','psd','psd','raw','tif','tiff'],
  127. markdown: ['md','markdown','mdown','mkdn','mkd','mdwn','mdtxt','mdtext'],
  128. office: ['csv','doc','docx','epub','key','numbers','odf','ods','odt','pages','rtf','scriv','xls','xlsx','xlm'],
  129. pdf: ['pdf'],
  130. system: ['DS_Store','ds_store','icon','ics'],
  131. text: ['log','nfo','txt','m3u'],
  132. video: ['m4v','mov','mp4','mpeg','webm']
  133. };
  134.  
  135. // $ROW_SETTINGS: Ignore or Exclude files by extension
  136. const $row_settings = {
  137. // Ignore: $row_types or files with extensions added here will not be loaded if selected in the sidebar (prevents the browser from attempting to download the file).
  138. ignore: $row_types.archive.concat( 'alias', $row_types.bin, $row_types.database, $row_types.graphics, $row_types.ignored_image, $row_types.office, $row_types.system),
  139. // Exclude: Files with these exensions will not be inverted in dark mode
  140. exclude: ['htm','html','xhtm','xhtml']
  141. };
  142.  
  143. // ***** END USER SETTINGS ***** //
  144.  
  145. // ## FEATURES INCLUDE:
  146. // - Resizable sidebar and directory/file preview pane.
  147. // - Arrow navigation in sidebar:
  148. // - Up and Down Arrows select next/prev item.
  149. // - Left and Right Arrows select next/prev item of same type.
  150. // - Navigate sidebar by typed string.
  151. // - Show/Hide file details (size (if avail), date modified (if avail), kind, extension).
  152. // - Sort sidebar items by name or file details.
  153. // - Default sort = sort by name with folders on top.
  154. // - Preview all file types supported by browser (html, text, images, pdf, audio, video, etc.) and preview fonts.
  155. // - Preview and edit markdown and plain text files, with option to save files locally.
  156. // - Markdown rendered with markdownit.js ( https://github.com/markdown-it/markdown-it ).
  157. // - Uses Github Markdown styles for preview ( https://github.com/sindresorhus/github-markdown-css ), with a few customizations.
  158. // - Support for:
  159. // - TOC creation ( `${toc}` ) ( https://github.com/nagaozen/markdown-it-toc-done-right )
  160. // - Multimarkdown table syntax ( https://github.com/RedBug312/markdown-it-multimd-table )
  161. // - Live checkboxes ( `\[ ], [x]` ), allowed in lists and deflists.
  162. // - Superscript ( `^sup^` ) ( https://github.com/markdown-it/markdown-it-sup )
  163. // - Subscript ( `~sub~` ) ( https://github.com/markdown-it/markdown-it-sub )
  164. // - Definition lists ( https://github.com/markdown-it/markdown-it-deflist; for syntax, see http://pandoc.org/MANUAL.html#definition-lists )
  165. // - Centered text ( `->centered<-` ) ( https://github.com/jay-hodgson/markdown-it-center-text )
  166. // - Footnotes ( https://github.com/markdown-it/markdown-it-footnote )
  167. // - View source text, preview, or split pane with proportional sync scroll.
  168. // - Save edited source text or previewed HTML.
  169. // - Create and edit text in separate text editor.
  170. // - Audio and video playback, with shuffle, loop, skip audio +/- 10 or 30 sec via keyboard.
  171. // - Preview other files (e.g., lyrics or cover art) in same directory while playing audio.
  172. // - User setting to autoload cover art (if any images in directory, load "cover.ext" or first image found)
  173. // - Grid view for images and fonts.
  174. // - User settings (see $settings in code; some settings can be changed via the main menu in the UI and will be remembered in URL query):
  175. // - Light or Dark theme.
  176. // - Bookmarks for local or remote directories.
  177. // - Default image grid size.
  178. // - Default UI font size and font-family.
  179. // - Default UI font and font-size.
  180. // - Default file sorting.
  181. // - Sort with directories on top.
  182. // - Treat apps as directories (MacOS and *nix only)
  183. // - Show or hide invisible files.
  184. // - Show or hide ignored files in the ignored files list (see $row_settings in code below $settings).
  185. // - Show or hide file details.
  186. // - Use custom file icons or browser defaults.
  187. // - Autoload index.ext files.
  188. // - Autoload cover art in directories with audio files.
  189. // - Text editing default view: split, source, or preview.
  190. // - Text editing sync scroll: on or off.
  191.  
  192. // ## KEYBINDINGS (These don't work in all browsers):
  193.  
  194. // - <kbd>Arrow Up/Down</kbd>: Select prev/next item.
  195. // - If audio is playing, and prev/next file is also audio, it will be highlighted but not loaded in the audio player; press return to load it.
  196. // - <kbd>Arrow Left/Right</kbd>: Select prev/next row of the same kind as the current selection.
  197. // - If current selection is a media file, select and begin playback of the next media item.
  198. // - <kbd>Opt/Alt + Arrow Left/Right</kbd>: Skip audio ±10s
  199. // - <kbd>Opt/Alt + Shift + Arrow Left/Right</kbd>: Skip audio ±30s
  200. // - <kbd>Cmd/Ctrl + Arrow Up</kbd>: Go to parent directory
  201. // - <kbd>Cmd/Ctrl + Arrow Down</kbd>: Open selected directory
  202. // - <kbd>Return</kbd>: Open selected directory, select file, or pause/play media.
  203. // - <kbd>Space</kbd>: Pause/Play media files
  204. // - <kbd>Cmd/Ctrl + D</kbd>: Toggle file details (size, date modified) in some index page types.
  205. // - <kbd>Cmd/Ctrl + E</kbd>: Show text editor.
  206. // - <kbd>Cmd/Ctrl + G</kbd>: Show or Reset Grid.
  207. // - <kbd>Cmd/Ctrl + I</kbd>: Toggle Invisibles.
  208. // - <kbd>Cmd/Ctrl + Shift + O</kbd>: Open selected item in new window/tab.
  209. // - <kbd>Cmd/Ctrl + R</kbd>: Reload grids and previewed content, reset scaled images/fonts, reset media files to beginning.
  210. // - <kbd>Cmd/Ctrl + W</kbd>: Close previewed content (doesn't work in all browsers; use close button instead), or close window if no content is being previewed.
  211. // - <kbd>Cmd/Ctrl + Shift + < or ></kbd>: Scale preview items and grids.
  212.  
  213. // CHANGELOG:
  214.  
  215. // **4.0.0b** Numerous additions, improvements, and massive internal changes. Virtually no line of code has been left untouched.
  216. // **"b" === "bugs" likely. Updates will be coming.
  217. // **IMPORTANT:** This version uses a new format for user settings in the code; you will have to re-enter your defaults manually after updating.
  218. // - Do NOT use exported settings from any earlier version of the script.
  219. // **NEW:** Added independent text editor pane.
  220. // - Invoke with Cmd/Ctrl + E, or in main menu > Text Editing > Toggle Text Editor", or under "Show Details".
  221. // - To prevent loss of work (and for convenience, e.g., to refer to a file while writing), previously entered text will not be cleared when the "New" button is clicked again, when the "Close" button is clicked, or when a sidebar item is selected.
  222. // - Use the Save button to save the text as a text or html file, which can be previewed and edited as usual by navigating to its saved location.
  223. // **ADDED:** Option to number index items, with new user setting.
  224. // **ADDED:** Stats footer in sidebar showing dir and file count.
  225. // **ADDED:** Icons for shortcuts menu to indicate local vs. remote links.
  226. // **ADDED:** Text editing: Clear button to empty text editing pane.
  227. // **CHANGED:** Text editing: Github styling customizations: Make table cells top-aligned, darker blockquote text color.
  228. // **IMPROVED:** Text editing: When saving rendered HTML, header uplinks will be removed.
  229. // **IMPROVED:** Text editing: Don't close other previewed content when making new text editing pane.
  230. // **IMPROVED:** Text editing: Much improved warning system for edited text: now uses `postMessage` to communicate between iframe and parent.
  231. // **IMPROVED:** Content display: use the same code to prep and style directory contents in the preview pane.
  232. // **IMPROVED:** Live sorting of grid items (but images and fonts are still sorted separately).
  233. // **IMPROVED:** Image zoom positioned accurately under click.
  234. // **IMPROVED:** Better handling of 404 Errors (Page not found): server error message will appear in sidebar, warning icon in content pane.
  235. // **IMPROVED:** File URLs: If a file URL (instead of a directory) is entered directly in the browser URL bar, the parent directory will be loaded instead and the file automatically selected.
  236. // **IMPROVED:** Navigation: modifed highlighting styles to show when a non-audio item is selected for navigation vs. when it is loaded in preview pane but not selected (e.g. click a directory and then click an audio file; the directory item will be dimmed).
  237. // **IMPROVED:** Audio: Greatly simplified shuffle play code and fixed several bugs; shuffle list now correctly updates when individual audio tracks are checked or unchecked.
  238. // **CHANGED:** Moved scale buttons and prev/next image buttons to preview title bar.
  239. // **CHANGED:** Sort by "Name" always sorts files and directories together; "Default" sort always keeps files and directories separate.
  240. // **FIXED:** Text editing: Some issues with split-pane resizing.
  241. // **FIXED:** Cmd/Ctr+W (close) should work now: previewed content will be closed first, then audio, then the browser tab itself.
  242. // **FIXED:** Don't autoload audio cover art when next audio track begins; i.e., leave open whatever file is being previewed, including cover art or lyrics.
  243. // **FIXED:** An issue with sorting by size.
  244. // **FIXED:** An issue with the user UI font setting.
  245. // **FIXED:** Navigation by typed string now correctly scrolls directory list.
  246. // **OTHER:** Many small style fixes and tweaks. Among others, make the previewed image and image grid background color light in default theme.
  247. // **INTERNAL:** Complete code overhaul.
  248. // - Completely rewrote the code that preps the served directory index for processing by the script.
  249. // - Completely rewrote and simplied the sorting code.
  250. // - Alphabetized User Settings for easier editing.
  251. // - Fixes for additional server index configurations.
  252. // – Performance improvments (e.g., removed multiple calls to various functions, reduced initial DOM manipulation, etc.).
  253. // - General code cleanup (e.g., removed unused variables and unnecessary globals, named many formerly anonymous functions, fixed numerous syntax errors, etc.).
  254.  
  255. // **STILL TO COME:**
  256. // - Dark mode for text editing.
  257. // - Additional code cleanup, and more.
  258.  
  259. // ***** GENERAL SETUP ***** //
  260.  
  261. // ************************************ //
  262. // DON'T EDIT ANYTHING BELOW THIS LINE. //
  263. // ************************************ //
  264.  
  265. // PATHS
  266. // Fix "%" error in file name; see https://stackoverflow.com/questions/7449588/why-does-decodeuricomponent-lock-up-my-browser
  267. function decodeURIComponentSafe(s) {
  268. if (!s) { return s; }
  269. return decodeURIComponent(s.replace(/%(?:^[0-9]{2,})/g, '%25'));
  270. }
  271. const $protocol = window.location.protocol;
  272. const $origin = $protocol +'//'+ window.location.host;
  273. const $location = decodeURIComponentSafe( [location.protocol, '//', location.host, location.pathname].join('') );
  274. const $current_dir_path = $location.replace(/[\/|_|—]/g,'/<wbr>').replace(/\\/g,'/'); // URL w/o query string for display
  275.  
  276. // if URL is a file, change window location to parent dir, add querystring of file name; then autoload file.
  277. function loadFile() {
  278. if ( $location.slice($location.lastIndexOf('/')).indexOf('.') !== -1 && !$location.endsWith('/') && window.top === window.self ) {
  279. let $query_prefs = getQueryPrefs();
  280. $query_prefs.set( 'file', $location.slice($location.lastIndexOf('/') + 1) );
  281. window.location = $location.slice(0,$location.lastIndexOf('/') + 1) +'?'+ $query_prefs;
  282. return;
  283. }
  284. }
  285. loadFile();
  286.  
  287. // QUERY PREFS
  288. function getQueryPrefs() { return new URL(window.location).searchParams; }
  289. // set query key/value
  290. function setQuery(key, value) {
  291. let $query_prefs = getQueryPrefs();
  292. $query_prefs.set( key, value );
  293. updateQuery($query_prefs);
  294. }
  295. // get query value
  296. function getQuery(key) {
  297. let $query_prefs = getQueryPrefs();
  298. let value = '';
  299. if ( key === 'width' ) {
  300. value = ( !$query_prefs.has(key) ? 30 : Math.round(100 * $query_prefs.get('width')/window.innerWidth) ); // number string
  301. } else {
  302. value = ( $query_prefs.has(key) ? $query_prefs.get(key) : $settings[key] !== undefined ? $settings[key].toString() : '' );
  303. }
  304. return value;
  305. }
  306. // toggle query key
  307. function toggleQuery(key) {
  308. let $query_prefs = getQueryPrefs();
  309. let nonBoolPrefs = {
  310. 'theme_light':{'theme':'dark'},
  311. 'theme_dark':{'theme':'light'},
  312. 'source_text':{'default_text_view':'preview_text'},
  313. 'preview_text':{'default_text_view':'source_text'},
  314. 'sort_by_default':{'sort_by':'default'},
  315. 'sort_by_name':{'sort_by':'name'},
  316. 'sort_by_size':{'sort_by':'size'},
  317. 'sort_by_date':{'sort_by':'date'},
  318. 'sort_by_kind':{'sort_by':'kind'},
  319. 'sort_by_ext':{'sort_by':'ext'},
  320. };
  321. var value, queryValue, settingsValue;
  322. if ( nonBoolPrefs[key] !== undefined ) {
  323. value = Object.values(nonBoolPrefs[key]).toString();
  324. key = Object.keys(nonBoolPrefs[key]).toString(); // must come after value: i.e., don't redefine key before getting value
  325. if ( $settings[key] === value ) { $query_prefs.delete( key ); } else { $query_prefs.set( key, value ); }
  326. } else {
  327. queryValue = $query_prefs.get(key);
  328. settingsValue = $settings[key];
  329. value = ( queryValue === null ? settingsValue.toString() : queryValue.toString() );
  330. value = ( value === 'true' ? 'false' : 'true' );
  331. if ( ( queryValue !== null && queryValue !== settingsValue ) ) {
  332. $query_prefs.delete( key );
  333. } else {
  334. $query_prefs.set( key, value );
  335. }
  336. }
  337. updateQuery($query_prefs);
  338. }
  339. // remove query key
  340. function removeQuery(key) {
  341. let $query_prefs = getQueryPrefs();
  342. $query_prefs.delete(key);
  343. updateQuery($query_prefs);
  344. }
  345. // update query string
  346. function updateQuery(querystr) {
  347. window.history.replaceState({}, document.title, window.location.pathname +'?'+ querystr);
  348. updateParentLinks();
  349. }
  350.  
  351. // ***** SET UP UI ELEMENTS ***** //
  352.  
  353. // ***** SIDEBAR ELEMENTS ***** //
  354. const $parent_dir_menu = $('<nav id="parent_dir_menu"><a href="">&nbsp;</a></nav>');
  355. const $parents_dir_menu = $('<nav id="parents_dir_menu"><div></div></nav><ul class="menu"></ul>');
  356. const $shortcuts_menu = $('<nav id="shortcuts_menu"><div>&nbsp;</div></nav><ul id="shortcuts" class="menu"></ul>');
  357. const $show_details = $('<button class="toggle_UI_pref" id="show_details" tabindex="-1"><span>Show details</span><span>Hide details</span></button>');
  358. const $inv_checkbox = $('<label ><input class="toggle_UI_pref" type="checkbox" id="show_invisibles" for="inv_checkbox" name="inv_checkbox" tabindex="-1" />Show Invisibles</label>');
  359. const $grid_btn = $('<div id="grid_btn" tabindex="-1" title="Show Grid"><ul class="menu"><li id="show_image_grid">Show Image Grid</li><li id="show_font_grid">Show Font Grid</li></ul></div>');
  360. const $sidebar_header = $('<table id="sidebar_header"><thead><tr id="sidebar_title"><th colspan="3">INDEX OF</th></tr></thead><tbody><tr id="sidebar_menus"><td></td><td></td><td></td></tr><tr id="sidebar_buttons"><td colspan="3"></td></tr></tbody></table>');
  361. const $text_editor_item = $('<tr id="text_editor_row"><td colspan="6"><a href="#" title="Toggle Text Editor">Text Editor</a></td></tr>');
  362. const $dir_list_head = $('<thead id="thead"><tr id="theader" class="header"><th class="toggle_UI_pref name sorting" id="sort_by_name"><input id="play_toggle" type="checkbox" tabindex="-1" checked="true" /><span>Name</span></th><th class="toggle_UI_pref sorting" id="sort_by_default"><span>Default</span></th><th class="toggle_UI_pref details sorting" id="sort_by_size"><span>Size</span></th><th class="toggle_UI_pref details sorting" id="sort_by_date"><span>Date</span></th><th class="toggle_UI_pref details sorting" id="sort_by_kind"><span>Kind</span></th><th class="toggle_UI_pref details sorting" id="sort_by_ext"><span>Ext</span></th></tr></thead>');
  363. const $dir_list_body = $('<tbody id="tbody"></tbody>');
  364. var $dir_list = $('<table id="dir_list"></table>');
  365. const $sidebar = $('<div id="sidebar"></div>');
  366. const $handle = $('<div id="handle"></div>');
  367. const $sidebar_wrapper = $('<td id="sidebar_wrapper"></td>');
  368. const $toggle_sidebar = $('<div id="toggle_sidebar"></div>');
  369. const $index_stats = $('<tfoot id="index_stats"></tfoot>');
  370. const $warnings = $('<div id="warnings"><h3>Warning:</h3><p id="warning_unsaved">You have unsaved changes.</p><p id="warning_clear">Are you sure you want to clear all your text?</p><p id="warning_local">Can\'t load local directories or files from non-local web pages. Use your browser\'s bookmarks or enter the URL manually.</p><div><button id="warning_ignore_btn">Don\'t Save</button><button id="warning_cancel_btn" >Cancel</button><button id="warning_clear_btn">Clear</button><button id="warning_save_btn">Save</button><button id="warning_ok_btn">OK</button></div></div><div id="overlay"></div>');
  371.  
  372. // ***** CONTENT PANE ELEMENTS ***** //
  373. const $content_audio_title = $('<tr id="content_audio_title"><td colspan="3"></td></tr>');
  374. const $content_audio = $('<tr id="content_audio"><td colspan="3"></td></tr>');
  375. const $prev_track = $('<div id="prev_track" class="prev_next_track_btn" title="Previous track">&nbsp;</div>');
  376. const $next_track = $('<div id="next_track" class="prev_next_track_btn" title="Next track">&nbsp;</div>');
  377. const $audio_player = $('<audio id="audio" preload="auto" tabindex="0" controls>Sorry, your browser does not support HTML5 audio.</audio>');
  378. const $loop = $('<label><input type="checkbox" id="loop" for="loop" name="loop" tabindex="0" />Loop</label>');
  379. const $shuffle = $('<label><input type="checkbox" id="shuffle" for="shuffle" name="shuffle" tabindex="0" />Shuffle</label>');
  380. const $close_audio = $('<div id="close_audio" title="Close audio"></div>');
  381. const $font_grid_item_el = $('<div class="font_grid_item"></div>');
  382. const $content_grid = $('<div id="content_grid" data-grid-scale-factor="1" data-kind="grid"></div>');
  383. const $content_text = $('<div id="content_text"></div>');
  384. const $sample_string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ<br />abcdefghijklmnopqrstuvwxyz<br />0123456789 [(!@#$%^&*;:)]';
  385. const $hamburger_string = '<h1>Typography</h1><h4>The art of using types to produce impressions on paper, vellum, &amp;c.</h4><h2>S P E C I M E N</h2><h3>Typography is the work of typesetters (also known as compositors), typographers, graphic designers, art directors, manga artists, comic book artists, graffiti artists, and, now, anyone who arranges words, letters, numbers, and symbols for publication, display, or distribution.</h3><h5> </h5>';
  386. const $lorem_string = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
  387. const $specimen = $('<div class="specimen" contenteditable="true">'+ $sample_string +'</div><div class="hamburger" contenteditable="true">'+ $hamburger_string +'</div><div class="lorem first" style="font-size:1em;" contenteditable="true">'+ $lorem_string +'</div><div class="lorem" style="font-size:1em;" contenteditable="true">'+ $lorem_string +'</div><div class="lorem" style="font-size:1em;" contenteditable="true">'+ $lorem_string +'</div>');
  388. const $content_font = $('<div id="content_font" class="content" spellcheck="false" data-kind="font"></div>');
  389. const $content_image = $('<img id="content_image" class="content" data-kind="image" />');
  390. const $content_video = $('<video id="content_video" class="content media" controls data-kind="video">Your browser does not support the video tag.</video>');
  391. const $content_pdf = $('<embed id="content_pdf" class="content" name="plugin" tabindex="0" data-kind="pdf"></embed>');
  392. // if ( navigator.userAgent.indexOf('Chrome') > -1 ) { $content_pdf.attr('type','application/x-google-chrome-pdf'); }
  393. const $content_iframe = $('<iframe id="content_iframe" class="content" name="content_iframe" sandbox="allow-scripts allow-same-origin allow-modals" tabindex="0" data-kind="file"></iframe>');
  394. const $checkbox_cont = $('<div id="checkbox_div"></div>');
  395. const $title_buttons_left = $('<td id="title_buttons_left"><button id="reload_btn" tabindex="-1">Reload</button><button id="prev_next_btns" class="split_btn"><span id="prev_btn">&nbsp;</span><span id="next_btn">&nbsp;</span></button></td>');
  396. // const $content_stop_btn = $('<td><button id="stop" tabindex="-1">Stop</button></td>');
  397. const $title = $('<td id="title"></td>');
  398. const $content_title = $('<tr id="content_title"></tr>');
  399. const $title_buttons_right = $('<td id="title_buttons_right"><button id="scale" class="split_btn"><span id="decrease">&nbsp;</span><span id="increase">&nbsp;</span></button><button id="close_btn" tabindex="-1">Close</button></td>');
  400. const $content_header = $('<header id="content_header"><table><tbody></tbody></table></header>');
  401. // const $prev_btn = $('<div class="nav_btn" id="prev_btn"></div>');
  402. // const $next_btn = $('<div class="nav_btn" id="next_btn"></div>');
  403. const $content_container = $('<section id="content_container"></section>');
  404. const $content_pane = $('<td id="content_pane" class=""></td>');
  405.  
  406. const $main_content = $('<table id="main_content"><thead></thead><tbody><tr></tr></tbody><tfoot></tfoot></table>');
  407.  
  408. // SVG UI ICONS
  409. const $svg_prefix = 'url("data:image/svg+xml;utf8,<svg version=\'1.1\' id=\'Layer_1\' xmlns=\'http://www.w3.org/2000/svg\' xmlns:xlink=\'http://www.w3.org/1999/xlink\' x=\'0px\' y=\'0px\' ';
  410. const $up_arrow = $svg_prefix + 'width=\'12.728px\' height=\'7.779px\' viewBox=\'0 0 12.728 7.779\' enable-background=\'new 0 0 12.728 7.779\' xml:space=\'preserve\'><path fill=\'%23444444\' d=\'M6.364,2.828l4.95,4.949l1.414-1.414L6.364,0l0,0L0,6.363l1.413,1.416L6.364,2.828\'/></svg>")';
  411. const $up_arrow_inv = $svg_prefix + 'width=\'12.728px\' height=\'7.779px\' viewBox=\'0 0 12.728 7.779\' enable-background=\'new 0 0 12.728 7.779\' xml:space=\'preserve\'><path fill=\'%23CCCCCC\' d=\'M6.364,2.828l4.95,4.949l1.414-1.414L6.364,0l0,0L0,6.363l1.413,1.416L6.364,2.828\'/></svg>")';
  412. // const $svg_arrow = $svg_prefix + 'width=\'11px\' height=\'16px\' viewBox=\'234.5 248 11 16\' enable-background=\'new 234.5 248 11 16\' xml:space=\'preserve\'><path d=\'M245.5,261l-3,3l-8-8l8-8l3,3l-5,5L245.5,261z\'/></svg>")';
  413. const $svg_arrow = $svg_prefix + 'width=\'88.4px\' height=\'141.4px\' viewBox=\'0 0 88.4 141.4\' enable-background=\'new 0 0 88.4 141.4\' xml:space=\'preserve\'><polygon fill=\'%23231F20\' points=\'70.7,0 0,70.7 70.7,141.4 88.4,123.7 35.4,70.7 88.4,17.7 \'/></svg>")';
  414. const $toggle = $svg_prefix + 'width=\'13.779px\' height=\'12.729px\' viewBox=\'2.474 -2.475 13.779 12.729\' enable-background=\'new 2.474 -2.475 13.779 12.729\' xml:space=\'preserve\'> <path fill=\'%23444444\' d=\'M5.302,3.889l4.949-4.95L8.838-2.475L2.474,3.889l0,0l6.363,6.364l1.416-1.413L5.302,3.889\'/> <path fill=\'%23444444\' d=\'M11.302,3.889l4.949-4.95l-1.414-1.414L8.474,3.889l0,0l6.363,6.364l1.416-1.413L11.302,3.889\'/> </svg>")';
  415. const $check_mark = $svg_prefix + 'width=\'17px\' height=\'14px\' viewBox=\'250.182 490.01 17 14\' enable-background=\'new 250.182 490.01 16.971 14.143\' xml:space=\'preserve\'><polygon fill=\'%23444444\' points=\'255.839,498.495 253.011,495.667 250.182,498.496 255.839,504.152 267.152,492.838 264.323,490.01 \'/></svg>")';
  416. const $check_mark_inv = $svg_prefix + 'width=\'17px\' height=\'14px\' viewBox=\'250.182 490.01 17 14\' enable-background=\'new 250.182 490.01 16.971 14.143\' xml:space=\'preserve\'><polygon fill=\'%23CCCCCC\' points=\'255.839,498.495 253.011,495.667 250.182,498.496 255.839,504.152 267.152,492.838 264.323,490.01 \'/></svg>")';
  417. const $menu_arrow = $svg_prefix + 'width=\'24px\' height=\'16px\' viewBox=\'0 0 24 16\' enable-background=\'new 0 0 24 16\' xml:space=\'preserve\'> <polygon fill=\'%23444444\' points=\'0,0 13.873,8.008 0.001,16.017 \'/> </svg>")';
  418. const $menu_arrow_inv = $svg_prefix + 'width=\'24px\' height=\'16px\' viewBox=\'0 0 24 16\' enable-background=\'new 0 0 24 16\' xml:space=\'preserve\'> <polygon fill=\'%23CCCCCC\' points=\'0,0 13.873,8.008 0.001,16.017 \'/> </svg>")';
  419. const $menu_icon = $svg_prefix + 'width=\'13px\' height=\'10px\' viewBox=\'0 0 13 10\' enable-background=\'new 0 0 13 10\' xml:space=\'preserve\'><rect fill=\'%23444444\' width=\'13\' height=\'2\'/><rect y=\'4\' fill=\'%23444444\' width=\'13\' height=\'2\'/><rect y=\'8\' fill=\'%23444444\' width=\'13\' height=\'2\'/></svg>")';
  420. const $grid_icon = $svg_prefix + 'width=\'16px\' height=\'16px\' viewBox=\'0 0 16 16\' enable-background=\'new 0 0 16 16\' xml:space=\'preserve\'><g><path fill=\'%23666666\' d=\'M5,2v3H2V2H5 M7,0H0v7h7V0L7,0z\'/></g><g><path fill=\'%23666666\' d=\'M14,2v3h-3V2H14 M16,0H9v7h7V0L16,0z\'/></g><g><path fill=\'%23666666\' d=\'M5,11v3H2v-3H5 M7,9H0v7h7V9L7,9z\'/></g><g><path fill=\'%23666666\' d=\'M14,11v3h-3v-3H14 M16,9H9v7h7V9L16,9z\'/></g></svg>")';
  421. const $grid_icon_inv = $svg_prefix + 'width=\'16px\' height=\'16px\' viewBox=\'0 0 16 16\' enable-background=\'new 0 0 16 16\' xml:space=\'preserve\'><g><path fill=\'%23CCCCCC\' d=\'M5,2v3H2V2H5 M7,0H0v7h7V0L7,0z\'/></g><g><path fill=\'%23CCCCCC\' d=\'M14,2v3h-3V2H14 M16,0H9v7h7V0L16,0z\'/></g><g><path fill=\'%23CCCCCC\' d=\'M5,11v3H2v-3H5 M7,9H0v7h7V9L7,9z\'/></g><g><path fill=\'%23CCCCCC\' d=\'M14,11v3h-3v-3H14 M16,9H9v7h7V9L16,9z\'/></g></svg>")';
  422. const $plus_sign = $svg_prefix + 'width=\'16px\' height=\'16px\' viewBox=\'0 0 16 16\' xml:space=\'preserve\'><polygon points=\'16,6.5 9.5,6.5 9.5,0 6.5,0 6.5,6.5 0,6.5 0,9.5 6.5,9.5 6.5,16 9.5,16 9.5,9.5 16,9.5 \'/></svg>")';
  423. const $minus_sign = $svg_prefix + 'width=\'16px\' height=\'16px\' viewBox=\'0 0 16 16\' xml:space=\'preserve\'> <rect x=\'1\' y=\'6.499\' width=\'14\' height=\'3.001\'/> </svg>")';
  424. const $next_track_arrow = $svg_prefix + 'width=\'12.8px\' height=\'14px\' viewBox=\'-2 0 12.8 14\' enable-background=\'new -2 0 12.8 14\' xml:space=\'preserve\'><polygon fill=\'%23919191\' points=\'10.873,14.017 0,7.01 10.872,0 \'/><rect x=\'-2\' y=\'0\' fill=\'%23919191\' width=\'2\' height=\'14\'/></svg>")';
  425. const $next_track_arrow_gecko = $svg_prefix + 'width=\'12.8px\' height=\'14px\' viewBox=\'-2 0 12.8 14\' enable-background=\'new -2 0 12.8 14\' xml:space=\'preserve\'><polygon fill=\'white\' points=\'10.873,14.017 0,7.01 10.872,0 \'/><rect x=\'-2\' y=\'0\' fill=\'white\' width=\'2\' height=\'14\'/></svg>")';
  426. const $next_track_arrow_gecko_hover = $svg_prefix + 'width=\'12.8px\' height=\'14px\' viewBox=\'-2 0 12.8 14\' enable-background=\'new -2 0 12.8 14\' xml:space=\'preserve\'><polygon fill=\'%236bb5ff\' points=\'10.873,14.017 0,7.01 10.872,0 \'/><rect x=\'-2\' y=\'0\' fill=\'%236bb5ff\' width=\'2\' height=\'14\'/></svg>")';
  427. const $music = $svg_prefix + 'width=\'143.717px\' height=\'199.404px\' viewBox=\'0 0 143.717 199.404\' enable-background=\'new 0 0 143.717 199.404\' xml:space=\'preserve\'><g opacity=\'0.2\'> <path fill=\'%23757679\' d=\'M143.717,143.82c0,10.033-4.573,18.425-13.717,25.183c-8.394,6.143-17.776,9.211-28.149,9.211 c-6.074,0-11.056-1.432-14.943-4.297c-4.301-3.275-6.45-7.849-6.45-13.719c0-9.279,4.403-17.438,13.204-24.466 c8.326-6.616,17.266-9.93,26.82-9.93c8.052,0,13.922,1.605,17.606,4.812V25.487L63.26,45.654v119.354 c0,10.03-4.573,18.427-13.717,25.181c-8.394,6.142-17.778,9.215-28.148,9.215c-6.077,0-11.055-1.437-14.947-4.302 C2.151,191.827,0,187.253,0,181.386c0-9.282,4.401-17.436,13.206-24.465c8.323-6.615,17.262-9.929,26.817-9.929 c8.051,0,13.921,1.605,17.606,4.812V23.237L143.717,0V143.82z\'/></g></svg>")';
  428. const $error_icon = $svg_prefix + 'viewBox=\'0 0 512 512\' enable-background=\'new 0 0 512 512\' xml:space=\'preserve\'><g id=\'Layer_2\'> <path fill=\'%23FFB636\' fill-opacity=\'0.75\' d=\'M12.51,470.379L234.371,16.008c6.439-13.187,25.17-13.363,31.855-0.299l232.51,454.371 c6.064,11.849-2.542,25.92-15.853,25.92H28.512C15.348,496,6.734,482.209,12.51,470.379z\'/></g><g id=\'Layer_3\'> <path fill=\'%23444444\' fill-opacity=\'0.75\' d=\'M284.332,173L272.15,336.498c-0.911,12.233-11.567,21.411-23.8,20.499 c-11.116-0.828-19.706-9.707-20.499-20.499L215.668,173c-1.413-18.961,12.813-35.478,31.774-36.89s35.478,12.813,36.89,31.774 C284.456,169.546,284.441,171.384,284.332,173z M250,391.873c-17.432,0-31.564,14.131-31.564,31.564 C218.436,440.869,232.568,455,250,455s31.564-14.131,31.564-31.564C281.564,406.004,267.432,391.873,250,391.873z\'/></g></svg>")';
  429. // const $spinner = $svg_prefix + ' width=\'40px\' height=\'40px\' viewBox=\'-1 -1 40 40\' style=\'enable-background:new -1 -1 40 40;\' xml:space=\'preserve\'><g> <g transform=\'translate(1 1)\'> <circle style=\'fill:none;stroke:%23666666;stroke-width:4;stroke-opacity:0.5;\' cx=\'18\' cy=\'18\' r=\'18\'/> <path style=\'fill:none;stroke:%23AAAAAA;stroke-width:4;\' d=\'M36,18c0-9.94-8.061-18-18-18 \'><animateTransform type=\'rotate\' fill=\'remove\' repeatCount=\'indefinite\' attributeName=\'transform\' restart=\'always\' dur=\'1s\' from=\'0 18 18\' calcMode=\'linear\' to=\'360 18 18\' accumulate=\'none\' additive=\'replace\'> </animateTransform> </path> </g></g></svg>")';
  430. //SVG FILE ICONS
  431. // Chrome default icons
  432. const $file_icon_dir_default = 'url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAd5JREFUeNqMU79rFUEQ/vbuodFEEkzAImBpkUabFP4ldpaJhZXYm/RiZWsv/hkWFglBUyTIgyAIIfgIRjHv3r39MePM7N3LcbxAFvZ2b2bn22/mm3XMjF+HL3YW7q28YSIw8mBKoBihhhgCsoORot9d3/ywg3YowMXwNde/PzGnk2vn6PitrT+/PGeNaecg4+qNY3D43vy16A5wDDd4Aqg/ngmrjl/GoN0U5V1QquHQG3q+TPDVhVwyBffcmQGJmSVfyZk7R3SngI4JKfwDJ2+05zIg8gbiereTZRHhJ5KCMOwDFLjhoBTn2g0ghagfKeIYJDPFyibJVBtTREwq60SpYvh5++PpwatHsxSm9QRLSQpEVSd7/TYJUb49TX7gztpjjEffnoVw66+Ytovs14Yp7HaKmUXeX9rKUoMoLNW3srqI5fWn8JejrVkK0QcrkFLOgS39yoKUQe292WJ1guUHG8K2o8K00oO1BTvXoW4yasclUTgZYJY9aFNfAThX5CZRmczAV52oAPoupHhWRIUUAOoyUIlYVaAa/VbLbyiZUiyFbjQFNwiZQSGl4IDy9sO5Wrty0QLKhdZPxmgGcDo8ejn+c/6eiK9poz15Kw7Dr/vN/z6W7q++091/AQYA5mZ8GYJ9K0AAAAAASUVORK5CYII= ")';
  433. const $file_icon_file_default = 'url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAABnRSTlMAAAAAAABupgeRAAABHUlEQVR42o2RMW7DIBiF3498iHRJD5JKHurL+CRVBp+i2T16tTynF2gO0KSb5ZrBBl4HHDBuK/WXACH4eO9/CAAAbdvijzLGNE1TVZXfZuHg6XCAQESAZXbOKaXO57eiKG6ft9PrKQIkCQqFoIiQFBGlFIB5nvM8t9aOX2Nd18oDzjnPgCDpn/BH4zh2XZdlWVmWiUK4IgCBoFMUz9eP6zRN75cLgEQhcmTQIbl72O0f9865qLAAsURAAgKBJKEtgLXWvyjLuFsThCSstb8rBCaAQhDYWgIZ7myM+TUBjDHrHlZcbMYYk34cN0YSLcgS+wL0fe9TXDMbY33fR2AYBvyQ8L0Gk8MwREBrTfKe4TpTzwhArXWi8HI84h/1DfwI5mhxJamFAAAAAElFTkSuQmCC ")';
  434. // Custom file icons
  435. const $svg_icon_prefix = 'url("data:image/svg+xml;utf8,<svg version=\'1.1\' id=\'Layer_1\' xmlns=\'http://www.w3.org/2000/svg\' xmlns:xlink=\'http://www.w3.org/1999/xlink\' x=\'0px\' y=\'0px\' width=\'14px\' height=\'14px\' viewBox=\'0 0 14 14\' enable-background=\'new 0 0 14 14\' xml:space=\'preserve\'> ';
  436. const $file_icon_dir = $svg_icon_prefix + '<polygon fill=\'%233399FF\' points=\'6.1,2.7 4.8,1 0,1 0,13 14,13 14,2.7 \'/> <rect x=\'1.5\' y=\'4.2\' fill=\'%2399CCFF\' width=\'11\' height=\'7.3\'/> </svg> ")';
  437. const $file_icon_dir_invisible = $svg_icon_prefix + '<polygon fill=\'%23888888\' points=\'6.1,2.7 4.8,1 0,1 0,13 14,13 14,2.7 \'/> <rect x=\'1.5\' y=\'4.2\' fill=\'%23BBBBBB\' width=\'11\' height=\'7.3\'/> <circle fill=\'%23888888\' cx=\'7\' cy=\'7.9\' r=\'1\'/> </svg> ")';
  438. const $file_icon_app = $svg_icon_prefix + '<g> <polygon style=\'fill:%230066FF;\' points=\'14,0 0,0 0,14 14,14 \'/> </g> <path style=\'fill:%23FFFFFF;\' d=\'M6.466,3.696L5.854,3.421c-0.175-0.078-0.381,0.003-0.455,0.18L5.086,4.348l1.241,0.578l0.315-0.791 C6.71,3.965,6.632,3.771,6.466,3.696z\'/> <polygon style=\'fill:%23FFFFFF;\' points=\'4.955,4.663 2.755,9.922 4.091,10.544 6.201,5.243 \'/> <polygon style=\'fill:%23FFFFFF;\' points=\'2.625,10.237 2.563,12.166 3.955,10.856 \'/> <polygon style=\'fill:%23FFFFFF;\' points=\'9.998,6.663 10.569,8.027 13.143,8.027 13.143,6.663 \'/> <path style=\'fill:%23FFFFFF;\' d=\'M9.838,7.164L7.594,1.797C7.52,1.619,7.314,1.538,7.139,1.616L6.527,1.893 C6.36,1.968,6.282,2.16,6.35,2.329l2.17,5.449L9.838,7.164z\'/> <polygon style=\'fill:%23FFFFFF;\' points=\'9.97,7.479 8.646,8.096 9.021,9.035 10.367,8.43 \'/> <path style=\'fill:%23FFFFFF;\' d=\'M10.479,8.753l-1.3,0.585L9.178,9.339c-0.041,0.311-0.073,0.736,0.073,1.07 c0.35,0.798,1.045,1.264,0.923,1.959c0,0,0.887-1.152,0.989-1.896C11.286,9.579,10.82,9.05,10.479,8.753z\'/> <polygon style=\'fill:%23FFFFFF;\' points=\'5.459,8.027 8.251,8.027 7.708,6.663 6.003,6.663 \'/> <polygon style=\'fill:%23FFFFFF;\' points=\'3.749,6.663 0.857,6.663 0.857,8.027 3.178,8.027 \'/> </svg> ")';
  439. const $file_icon_file = $svg_icon_prefix + '<g> <polygon fill=\'%23888888\' points=\'8.3,0 1.5,0 1.5,14 12.5,14 12.5,4.2 \'/> <polygon fill=\'%23FFFFFF\' points=\'11,12.5 3,12.5 3,1.5 6.8,1.5 6.8,5.7 11,5.7 \'/> <polygon fill=\'%23FFFFFF\' points=\'8.3,4.2 10.2,4.2 8.3,2.2 \'/> </g> </svg> ")';
  440. const $file_icon_text = $svg_icon_prefix + '<g> <polygon style=\'fill:%238888AA;\' points=\'14,0 0,0 0,14 14,14 \'/> </g> <g> <rect x=\'2.155\' y=\'2.187\' style=\'fill:%23FFFFFF;\' width=\'9.69\' height=\'1.14\'/> </g> <g> <rect x=\'2.155\' y=\'5.036\' style=\'fill:%23FFFFFF;\' width=\'9.69\' height=\'1.14\'/> </g> <g> <rect x=\'2.155\' y=\'7.886\' style=\'fill:%23FFFFFF;\' width=\'9.69\' height=\'1.141\'/> </g> <g> <rect x=\'2.155\' y=\'10.736\' style=\'fill:%23FFFFFF;\' width=\'6.555\' height=\'1.14\'/> </g> </svg> ")';
  441. const $file_icon_image = $svg_icon_prefix + '<g id=\'Layer_2\'> </g> <circle fill=\'%23FFEE22\' cx=\'5.5\' cy=\'3.2\' r=\'1.5\'/> <g> <path fill=\'%23FFFFFF\' d=\'M5.6,7.5L3.8,6L0.2,8.7c0.1,0.6,0.6,1.5,0.5,1.3l3-2.4L5.6,9l4.7-4l3.6,3.2l0,0C14,7.8,14,7.4,14,7 c0-0.1,0-0.3,0-0.4l-3.6-3.2L5.6,7.5z\'/> </g> <path fill=\'%2399AADD\' d=\'M3.8,6l1.8,1.5l4.8-4.1L14,6.6C13.8,2.9,10.7,0,7,0C3.1,0,0,3.1,0,7c0,0.6,0.1,1.2,0.2,1.7L3.8,6z\'/> <path fill=\'%233366CC\' d=\'M10.3,5L5.6,9L3.7,7.6l-3,2.4c1.1,2.4,3.5,4,6.3,4c3.4,0,6.3-2.5,6.9-5.8L10.3,5z\'/> <circle fill=\'%23FFE650\' cx=\'5.5\' cy=\'3.2\' r=\'1.5\'/> </svg> ")';
  442. const $file_icon_pdf = $svg_icon_prefix + '<g> <polygon style=\'fill:%23D84444;\' points=\'14,0 0,0 0,14 14,14 14,0 \'/> </g> <path style=\'fill:%23FFFFFF;\' d=\'M12.634,9.094c-0.074,0.047-0.288,0.075-0.423,0.075c-0.439,0-0.981-0.202-1.745-0.529 c0.294-0.022,0.562-0.031,0.803-0.031c0.441,0,0.569,0,1.002,0.108C12.7,8.824,12.705,9.047,12.634,9.094z M4.99,9.162 c0.17-0.3,0.345-0.616,0.521-0.952c0.435-0.822,0.712-1.469,0.914-1.997c0.409,0.742,0.917,1.37,1.51,1.876 C8.011,8.151,8.09,8.212,8.174,8.276C6.962,8.519,5.914,8.809,4.99,9.162z M6.404,1.383c0.241,0,0.38,0.606,0.391,1.179 c0.011,0.568-0.12,0.965-0.287,1.265c-0.14-0.441-0.203-1.129-0.203-1.581C6.305,2.245,6.295,1.383,6.404,1.383z M1.663,12.3 c0.14-0.374,0.68-1.113,1.479-1.771c0.051-0.037,0.175-0.155,0.289-0.263C2.596,11.603,2.033,12.133,1.663,12.3z M12.864,8.31 c-0.24-0.238-0.781-0.363-1.599-0.373c-0.555-0.008-1.218,0.041-1.923,0.138C9.03,7.893,8.707,7.697,8.451,7.459 c-0.683-0.64-1.25-1.524-1.606-2.497c0.021-0.094,0.044-0.171,0.062-0.253c0,0,0.383-2.186,0.28-2.925 c-0.015-0.104-0.021-0.131-0.05-0.21L7.104,1.486c-0.103-0.241-0.31-0.497-0.633-0.483L6.283,0.997H6.28 c-0.358,0-0.654,0.184-0.729,0.456c-0.233,0.864,0.007,2.15,0.444,3.818L5.882,5.544c-0.312,0.76-0.704,1.527-1.048,2.203 L4.787,7.836c-0.362,0.71-0.693,1.315-0.99,1.825l-0.31,0.165c-0.021,0.014-0.551,0.292-0.675,0.367 c-1.053,0.628-1.752,1.343-1.868,1.91c-0.037,0.179-0.009,0.41,0.178,0.52l0.299,0.148c0.129,0.064,0.269,0.096,0.406,0.096 c0.75,0,1.621-0.931,2.817-3.023c1.387-0.452,2.965-0.828,4.347-1.035c1.052,0.595,2.346,1.006,3.163,1.006 c0.146,0,0.271-0.013,0.373-0.042c0.155-0.04,0.288-0.129,0.369-0.254c0.156-0.235,0.191-0.563,0.146-0.901 C13.032,8.519,12.95,8.395,12.864,8.31z\'/> </svg> ")';
  443. const $file_icon_font = $svg_icon_prefix + '<g><polygon style=\'fill:%23770099;\' points=\'14,0 0,0 0,14 14,14 \'/></g><g><path style=\'fill:%23FFFFFF;\' d=\'M4.599,11.321h1.44V2.774H3.334v1.088H1.83V1.222h10.34v2.641h-1.505V2.774H7.977v8.547h1.393v1.457 H4.599V11.321z\'/></g></svg>")';
  444. const $file_icon_code = $svg_icon_prefix + '<g> <polygon style=\'fill:%237722DD;\' points=\'14,0 0,0 0,14 14,14 \'/> </g> <g> <path style=\'fill:%23FFFFFF;\' d=\'M5.892,12.965c-1.049,0-1.784-0.161-2.209-0.48c-0.425-0.317-0.638-0.82-0.638-1.503V8.915 c0-0.446-0.146-0.764-0.438-0.95C2.315,7.777,1.898,7.684,1.351,7.684V6.316c0.547,0,0.967-0.094,1.259-0.28s0.438-0.5,0.438-0.938 V3.006c0-0.675,0.217-1.172,0.65-1.491C4.13,1.195,4.862,1.036,5.893,1.036v1.312c-0.401,0.01-0.718,0.09-0.952,0.24 c-0.233,0.15-0.348,0.426-0.348,0.827V5.4c0,0.876-0.511,1.396-1.532,1.559v0.083c1.021,0.154,1.532,0.67,1.532,1.544v1.997 c0,0.41,0.116,0.688,0.349,0.835c0.233,0.146,0.55,0.223,0.951,0.232L5.892,12.965L5.892,12.965z\'/> <path style=\'fill:%23FFFFFF;\' d=\'M8.045,12.965v-1.313c0.392-0.009,0.706-0.089,0.944-0.239c0.236-0.15,0.355-0.426,0.355-0.829 V8.588c0-0.867,0.511-1.382,1.531-1.545V6.959C9.855,6.795,9.345,6.28,9.345,5.413V3.416c0-0.41-0.116-0.688-0.349-0.834 C8.764,2.436,8.447,2.358,8.045,2.349V1.036c1.049,0,1.785,0.159,2.21,0.479c0.423,0.319,0.637,0.821,0.637,1.505v2.065 c0,0.447,0.146,0.765,0.438,0.951c0.292,0.187,0.711,0.28,1.257,0.28v1.367c-0.546,0.012-0.967,0.107-1.259,0.287 C11.035,8.153,10.89,8.47,10.89,8.915v2.08c0,0.674-0.217,1.172-0.65,1.491C9.808,12.805,9.075,12.965,8.045,12.965z\'/> </g> </svg>")';
  445. const $file_icon_html = $svg_icon_prefix + '<path style=\'fill:%23FFFFFF;\' d=\'M7,14c-3.9,0-7-3.1-7-7C0,3.2,3.1,0,7,0H7C8.9,0,10.6,0.7,12,2C13.3,3.4,14,5.1,14,7 c0,1.9-0.7,3.6-2,5C10.7,13.3,8.9,14,7,14C7,14,7,14,7,14z\'/> <g> <path style=\'fill:%23EE7700;\' d=\'M5.3,1.1C4.7,1.9,4.2,2.6,3.8,3.5C3.4,3.3,3,3.1,2.6,2.8C3.3,2.1,4.2,1.5,5.3,1.1z M2,3.6 c0.5,0.3,1,0.6,1.5,0.8C3.3,5,3.2,5.6,3.1,6.3c0,0.1,0,0.2,0,0.3H0.9C1,5.4,1.4,4.4,2,3.6z M2,10.4c-0.6-0.9-1-1.9-1.1-3h2.1 c0,0.8,0.2,1.5,0.4,2.2C2.9,9.9,2.5,10.1,2,10.4z M2.6,11.2c0.4-0.3,0.8-0.5,1.2-0.6c0.3,0.8,0.8,1.5,1.4,2.2c0,0,0.1,0.1,0.1,0.1 C4.2,12.5,3.3,11.9,2.6,11.2z M6.5,12.9c-0.2-0.2-0.5-0.5-0.7-0.7c-0.5-0.6-0.9-1.3-1.2-1.9C5.3,10,5.9,9.9,6.5,9.9V12.9z M6.5,9 C5.8,9,5,9.1,4.3,9.4C4.1,8.7,4,8.1,4,7.5h2.6V9z M6.5,6.5H4c0-0.1,0-0.1,0-0.2c0.1-0.6,0.2-1.2,0.3-1.7C5.1,4.9,5.8,5,6.5,5V6.5z M6.5,4.1C5.9,4.1,5.3,4,4.7,3.8c0.4-1,1.1-1.9,1.9-2.6V4.1z M12,3.6c0.6,0.9,1,1.9,1.1,3h-2.2c0-0.8-0.2-1.5-0.4-2.2 C11,4.1,11.5,3.9,12,3.6z M11.3,2.7c0,0,0.1,0.1,0.1,0.1c-0.4,0.3-0.8,0.5-1.2,0.7C9.9,2.7,9.4,2,8.8,1.3C8.8,1.3,8.7,1.2,8.7,1.1 C9.7,1.4,10.6,2,11.3,2.7z M7.5,1.2c0.2,0.2,0.5,0.5,0.7,0.7C8.6,2.5,9,3.1,9.3,3.8C8.7,4,8.1,4.1,7.5,4.1V1.2z M7.5,5 c0.7,0,1.5-0.2,2.2-0.4C9.9,5.3,10,5.9,10,6.5H7.5V5z M7.5,7.5H10c0,0.1,0,0.2,0,0.2c0,0.6-0.2,1.1-0.3,1.7C9,9.1,8.2,9,7.5,9V7.5z M7.5,12.9v-3c0.6,0,1.3,0.1,1.9,0.3C8.9,11.2,8.3,12.1,7.5,12.9z M11.3,11.3c-0.7,0.7-1.6,1.3-2.6,1.5c0.6-0.7,1.1-1.5,1.5-2.3 c0.4,0.2,0.8,0.4,1.2,0.6C11.4,11.2,11.4,11.2,11.3,11.3z M10.5,9.7c0.2-0.6,0.3-1.2,0.4-1.9c0-0.1,0-0.2,0-0.3h2.2 c-0.1,1.1-0.4,2.1-1.1,3C11.5,10.1,11,9.9,10.5,9.7z M7,0C3.1,0,0,3.1,0,7s3.1,7,7,7s7-3.1,7-7S10.9,0,7,0z\'/> </g> </svg>")';
  446. const $file_icon_ignored = $svg_icon_prefix + '<path fill=\'%23CCCCCC\' d=\'M7,0C3.1,0,0,3.1,0,7c0,3.9,3.1,7,7,7c3.9,0,7-3.1,7-7C14,3.1,10.9,0,7,0L7,0z\'/><path fill=\'%23EEEEEE\' d=\'M7,2c2.8,0,5,2.2,5,5s-2.2,5-5,5c-2.8,0-5-2.2-5-5S4.2,2,7,2\'/><rect x=\'0.8\' y=\'5.9\' transform=\'matrix(0.7071 -0.7071 0.7071 0.7071 -2.8818 7.0063)\' fill=\'%23CCCCCC\' width=\'12.5\' height=\'2.3\'/></svg>")';
  447. const $file_icon_ignored_inv = $svg_icon_prefix + '<path fill=\'%23444444\' d=\'M7,0C3.1,0,0,3.1,0,7c0,3.9,3.1,7,7,7c3.9,0,7-3.1,7-7C14,3.1,10.9,0,7,0L7,0z\'/><path fill=\'%23555555\' d=\'M7,2c2.8,0,5,2.2,5,5s-2.2,5-5,5c-2.8,0-5-2.2-5-5S4.2,2,7,2\'/><rect x=\'0.8\' y=\'5.9\' transform=\'matrix(0.7071 -0.7071 0.7071 0.7071 -2.8818 7.0063)\' fill=\'%23444444\' width=\'12.5\' height=\'2.3\'/></svg>")';
  448. const $file_icon_invisible = $svg_icon_prefix + '<g> <polygon fill=\'%23888888\' points=\'8.3,0 1.5,0 1.5,14 12.5,14 12.5,4.2 \'/> <polygon fill=\'%23BBBBBB\' points=\'11,12.5 3,12.5 3,1.5 6.8,1.5 6.8,5.7 11,5.7 \'/> <polygon fill=\'%23BBBBBB\' points=\'8.3,4.2 10.2,4.2 8.3,2.2 \'/> </g> <circle fill=\'%23777777\' cx=\'7\' cy=\'9\' r=\'1\'/> </svg>")';
  449. // const $file_icon_video = 'url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\' viewBox=\'0 0 100 100\'><style type=\'text/css\'>.st0{fill:%23FFFFFF;}.st1{fill:%23EF6F2E;}</style><rect class=\'st0\' width=\'100\' height=\'100\'/><path class=\'st1\' d=\'M100 100H0V0h100V100zM9.7 90h80.7V10H9.7\'/><path class=\'st1\' d=\'M21 26.4v47.1h58V26.4H21zM31.9 69.9h-7.2v-7.2h7.2V69.9zM31.9 59.1h-7.2v-7.2h7.2V59.1zM31.9 48.2h-7.2v-7.2h7.2V48.2zM31.9 37.3h-7.2v-7.2h7.2V37.3zM42.8 62.7V37.3L60.9 50 42.8 62.7zM75.4 69.9h-7.2v-7.2h7.2V69.9zM75.4 59.1h-7.2v-7.2h7.2V59.1zM75.4 48.2h-7.2v-7.2h7.2V48.2zM75.4 37.3h-7.2v-7.2h7.2V37.3z\'/></svg>")';
  450. // const $file_icon_audio = 'url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\' viewBox=\'0 0 100 100\'><style type=\'text/css\'>.st0{fill:%23FFFFFF;}.st1{fill:%230E3693;}.st2{fill:%23003399;}</style><rect class=\'st0\' width=\'100\' height=\'100\'/><path class=\'st1\' d=\'M100 100H0V0h100V100zM9.7 90h80.7V10H9.7\'/><polyline class=\'st2\' points=\'32.5 37.5 23.5 37.5 23.5 62.5 32.5 62.5 53.6 77 53.6 23 32.5 37.5 \'/><path class=\'st2\' d=\'M71.9 50c0 6.8-3.7 12.7-9.1 15.8l2.8 4.9c7.1-4.1 11.9-11.8 11.9-20.7 0-8.8-4.8-16.6-11.9-20.7l-2.8 4.9C68.2 37.3 71.9 43.2 71.9 50z\'/><path class=\'st2\' d=\'M62.1 50c0 3.2-1.7 5.9-4.3 7.4l2.7 4.7c4.2-2.4 7-6.9 7-12.1 0-5.2-2.8-9.7-7-12.1l-2.7 4.7C60.4 44.1 62.1 46.8 62.1 50z\'/></svg>")';
  451. // const $file_icon_archive = 'url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\' viewBox=\'0 0 100 100\'><style type=\'text/css\'>.st0{fill:%23FFFFFF;}.st1{fill:%23D8A13F;}</style><rect class=\'st0\' width=\'100\' height=\'100\'/><path class=\'st1\' d=\'M100 100H0V0h100V100zM9.7 90h80.7V10H9.7\'/><path class=\'st1\' d=\'M72.4 38.5h-7.9v-7.9L72.4 38.5zM51.1 30.6v28.8h21.4v-19h-9.9v-9.9H51.1zM54.4 23H30.8v5.6h9.3l-5.9 4.5v4.8l8.6-6.6v-2.7h30.1v-2.3L54.4 23zM42.9 35.1l-8.6 6.6v4.8l8.6-6.6V35.1zM34.2 55.1l8.6-6.6v-4.8l-8.6 6.6V55.1zM42.9 57.1v-4.8l-8.6 6.6v2.6h-3.4v5.6h5.3v3.8H33c-0.6-1-1.6-1.6-2.8-1.6 -1.8 0-3.2 1.4-3.2 3.2s1.4 3.2 3.2 3.2c1.2 0 2.2-0.6 2.8-1.6h3.1V77h4.8v-2.9H44c0.6 1 1.6 1.6 2.8 1.6 1.8 0 3.2-1.4 3.2-3.2s-1.4-3.2-3.2-3.2c-1.2 0-2.2 0.6-2.8 1.6h-3.1v-3.8h13.5l18.5-3.3v-2.3H37.1L42.9 57.1z\'/></svg>")';
  452.  
  453. // Assemble UI Elements
  454. function assembleUIElements() {
  455. $parents_dir_menu.find('div').append( $current_dir_path );
  456. $sidebar_header.find('thead th');
  457. $sidebar_header.find('tbody tr').first().find('td').first().append( $parent_dir_menu ).next().append( $parents_dir_menu ).next().append( $shortcuts_menu );
  458. $sidebar_header.find('tbody tr:last-child td').append( $show_details, $inv_checkbox, $grid_btn );
  459. $dir_list_head.append($text_editor_item);
  460. $dir_list.append($dir_list_head, $dir_list_body, $index_stats);
  461. $sidebar.append($sidebar_header, $dir_list);
  462. $sidebar_wrapper.append( $sidebar, $handle, $toggle_sidebar );
  463. // content pane items
  464. $checkbox_cont.append( $loop, $shuffle );
  465. $content_audio.find('td').append( $prev_track, $next_track, $audio_player, $close_audio, $checkbox_cont );
  466. $content_title.append($title_buttons_left, $title, $title_buttons_right);
  467. $content_header.find('tbody').append( $content_title, $content_audio_title, $content_audio );
  468. $content_font.append( $specimen );
  469. $content_container.append( $content_grid, $content_text, $content_font, $content_image, $content_pdf, $content_video, $content_iframe );
  470. $content_pane.append( $content_header, $content_container );
  471. $main_content.find('thead').append($warnings);
  472. }
  473.  
  474. //***** STYLES *****//
  475.  
  476. // DEFINE STYLES
  477. var $main_style_rules =
  478. // Align-content
  479. '#content_pane.has_image #content_container' + //body.theme_light #dir_list .selected.audio,
  480. '{ align-items: center; justify-content: center; }' +
  481. // BACKGROUND: COLOR
  482. '#sidebar_wrapper, body.theme_light #sidebar, body.theme_light #sidebar ul, body.theme_light #preview_text, body.theme_light #source_text, body.theme_light #content_header' +
  483. '{ background-color: lightgray }' +
  484. 'body.theme_light #dir_list tr.selected:not(.playing)' + //body.theme_light #dir_list .selected.audio,
  485. '{ background-color: lightsteelblue !important; }' +
  486. 'body.theme_light #dir_list tr.loaded:not(.selected)' + //body.theme_light #dir_list .selected.audio,
  487. '{ background-color: rgba(69%,77%,87%,0.75); }' +
  488. 'body.theme_light #dir_list tr.loaded:hover' + //body.theme_light #dir_list .selected.audio,
  489. '{ background-color: rgba(69%,77%,87%,1) !important; }' +
  490. '#content_pane.has_grid .image_grid_item::after' + //body.theme_light #dir_list .selected.audio,
  491. '{ background-color: gray; }' +
  492. 'body.theme_dark #dir_list tr.selected:not(.playing)' +
  493. '{ background-color: slategray !important; }' +
  494. 'body.theme_dark #dir_list tr.loaded:not(.selected)' +
  495. '{ background-color: rgba(44%,50%,56%,0.5); }' +
  496. 'body.theme_dark #dir_list tr.loaded:hover' +
  497. '{ background-color: rgba(44%,50%,56%,1) !important; }' +
  498. 'body.theme_dark #content_pane.has_grid #content_container, body.theme_dark #content_grid > div:hover, body.theme_dark #content_grid > div.hovered, body.theme_dark #content_grid > div.selected' +
  499. '{ background-color: #262626; }' +
  500. 'body.theme_dark #content_grid > div, body.theme_dark #content_pane.has_image, body.theme_dark #content_font, body.theme_dark #content_pane, body.theme_dark #content_pane.has_grid #content_grid::after, .split_btn::after' +
  501. '{ background-color: #333; }' +
  502. 'body.theme_dark #sidebar ul, body.theme_dark #preview_text_menu_item span, body.theme_dark #sidebar_header thead, body.theme_dark #sidebar_menus, body.theme_dark #preview_text, body.theme_dark #source_text, body.theme_dark.alternate_background #dir_list tbody tr:nth-of-type(odd):not(.selected):not(.loaded), body.theme_dark.alternate_background #dir_list tbody tr:nth-of-type(odd):not(.loaded), body.theme_dark #index_stats' +
  503. '{ background-color: #444; }' +
  504. 'body.theme_dark #sidebar, body.theme_dark #dir_list #tbody, body.theme_dark #grid_btn .menu li, body.theme_dark #content_header, body.theme_dark .font_grid_item:hover, body.theme_dark .font_grid_item.hovered, body.theme_dark .image_grid_item:hover, body.theme_dark .image_grid_item.hovered' +
  505. '{ background-color: #555; }' +
  506. 'body.theme_dark #sidebar ul li:not(#preview_text_menu_item):hover, body.theme_dark #preview_text_menu_item span:hover, body.theme_dark #preview_text:hover, body.theme_dark #source_text:hover' +
  507. '{ background-color: #666; }' +
  508. 'body.theme_dark #sidebar .hovered, body.theme_dark #grid_btn .menu li:hover, body.theme_dark #dir_list tbody tr:hover, body.theme_dark #dir_list tbody li:hover, body.theme_dark.alternate_background #dir_list #tbody tr:hover, body.theme_dark.alternate_background #dir_list #tbody tr:nth-of-type(odd).hovered, body.theme_dark #content_iframe[href^="/"]' +
  509. '{ background-color: #777; }' +
  510. 'body.theme_light #sidebar_header thead tr, body.theme_light #sidebar_menus, #parents_dir_menu + ul li:hover, #shortcuts_menu + ul li:not(.has_submenu):not(#preview_text_menu_item):hover, body.theme_light #preview_text_menu_item span:hover, body.theme_light #preview_text:hover, body.theme_light #source_text:hover, #grid_btn.has_images.has_fonts:hover .menu li:hover, body.theme_light #dir_list tbody tr:hover, body.theme_light.alternate_background #dir_list #tbody tr:hover, body.theme_light #dir_list .hovered, body.theme_light.alternate_background #dir_list #tbody tr.hovered' +
  511. '{ background-color: #BBB; }' +
  512. 'body.theme_light #grid_btn .menu li, body.theme_light.alternate_background #dir_list tbody tr:nth-of-type(odd):not(.selected):not(.playing):not(.loaded), body.theme_light #index_stats' +
  513. '{ background-color: #CCC; }' +
  514. 'body.theme_light #dir_list tbody' +
  515. '{ background-color: #DFDFDF; }' +
  516. 'body.theme_light #content_pane.has_image, body.theme_light #content_grid > div, #warnings, body.theme_light #content_pane.has_grid #content_grid::after, body.theme_light #content_pane.has_grid .image_grid_item::after' +
  517. '{ background-color: #EEE; }' +
  518. 'body.theme_light #content_pane, body.theme_light #content_grid, body.theme_light #content_grid div.selected, #content_font, #content_iframe, #scale, body.is_chrome #audio:focus, body.theme_light #content_grid div:hover, body.theme_light #content_grid div.hovered' +
  519. '{ background-color: #FFF; }' +
  520. // EXCLUDED: Prevent previewed files with these extensions from being inverted in dark mode
  521. //for ( i = 0; i < $row_settings.exclude.length; i += 1) {
  522. // 'body.theme_dark #content_iframe[src*="'+ $row_settings.exclude[i] +'" i] { background:#FFF; filter: unset; }' +
  523. //}
  524. 'body.is_chrome #audio' +
  525. '{ background-color: rgb(241, 243, 244); }' +
  526. 'body.theme_light #dir_list .playing, body.theme_light.has_text #text_editor_row, body.theme_light.edited #text_editor_row' +
  527. '{ background-color: #99bebf; }' +
  528. 'body.theme_dark #dir_list .playing, body.theme_dark.alternate_background #dir_list tbody tr.playing:nth-of-type(odd), body.theme_dark.has_text #text_editor_row, body.theme_dark.edited #text_editor_row' + //body.theme_dark #dir_list .selected.audio,
  529. '{ background-color: #4C7E80; }' +
  530. '#dir_list tbody tr, #dir_list .audio a, #dir_list .video a, body.has_audio #content_pane.has_ignored, body #dir_list tr.file.audio a.icon, body #dir_list tr.file.video a.icon, body.use_custom_icons #dir_list tr.file.ignore a.icon' +
  531. '{ background-color: transparent; }' +
  532. '#warnings button:focus,#warnings button.focus' +
  533. '{ background: #0E4399; }' +
  534.  
  535. // BACKGROUND: SVG IMAGES & ICONS
  536. '#parent_dir_menu a { background:' + $up_arrow + 'center no-repeat; }' +
  537. '#shortcuts_menu div { background:'+ $menu_icon + 'center no-repeat; }' +
  538. 'body.theme_light #shortcuts > li.has_submenu { background:'+ $menu_arrow +' right no-repeat; background-size: 12px; }' +
  539. 'body.theme_light #shortcuts > li.has_submenu:hover { background:#BBB '+ $menu_arrow +' right no-repeat; background-size: 12px; }' +
  540. 'body.theme_dark #shortcuts > li.has_submenu { background:'+ $menu_arrow_inv +' right no-repeat; background-size: 12px; }' +
  541. 'body.theme_dark #shortcuts > li.has_submenu:hover { background:#666 '+ $menu_arrow_inv +' right no-repeat; background-size: 12px; }' +
  542. 'body.theme_light.sort_by_default #sort_by_default span::before, body.theme_light.sort_by_name #sort_by_name span::before, body.theme_light.sort_by_size #sort_by_size span::before, body.theme_light.sort_by_date #sort_by_date span::before, body.theme_light.sort_by_kind #sort_by_kind span::before, body.theme_light.sort_by_ext #sort_by_ext span::before, body.theme_light.sort_by_default #default, body.theme_light.sort_by_name #name, body.theme_light.sort_by_size #size, body.theme_light.sort_by_date #date, body.theme_light.sort_by_kind #kind, body.theme_light.sort_by_ext #ext, body.theme_light #theme span, body.theme_light.alternate_background #alternate_background span, body.theme_light.show_numbers #show_numbers span, body.theme_light.autoload_media #autoload_media span, body.theme_light.split_view #split_view_menu_item, body.theme_light.split_view #split_view, body.theme_light:not(.enable_text_editing) #enable_text_editing, body.theme_light.source_text #source_text, body.theme_light.preview_text #preview_text { background:'+ $check_mark +' 4px center no-repeat; background-size:10px; }' +
  543. 'body.theme_dark.sort_by_default #sort_by_default span::before, body.theme_dark.sort_by_name #sort_by_name span::before, body.theme_dark.sort_by_size #sort_by_size span::before, body.theme_dark.sort_by_date #sort_by_date span::before, body.theme_dark.sort_by_kind #sort_by_kind span::before, body.theme_dark.sort_by_ext #sort_by_ext span::before, body.theme_dark.sort_by_default #default, body.theme_dark.sort_by_name #name, body.theme_dark.sort_by_size #size, body.theme_dark.sort_by_date #date, body.theme_dark.sort_by_kind #kind, body.theme_dark.sort_by_ext #ext, body.theme_dark #theme span, body.theme_dark.alternate_background #alternate_background span, body.theme_dark.show_numbers #show_numbers span, body.theme_dark.autoload_media #autoload_media span, body.theme_dark.split_view #split_view_menu_item, body.theme_dark.split_view #split_view, body.theme_dark:not(.enable_text_editing) #enable_text_editing, body.theme_dark.source_text #source_text, body.theme_dark.preview_text #preview_text { background:'+ $check_mark_inv +' 4px center no-repeat; background-size:10px; }' +
  544. 'body #grid_btn { background:'+ $grid_icon +' right 6px top 0 no-repeat; }' +
  545. 'body.theme_light.has_images.has_fonts #grid_btn:hover .menu { background: #DDD '+ $grid_icon +' right 6px top 6px no-repeat; }' +
  546. 'body.theme_dark.has_images.has_fonts #grid_btn:hover .menu { background: #555 '+ $grid_icon_inv +' right 6px top 6px no-repeat; }' +
  547. '#toggle_sidebar { background:'+ $toggle +' center no-repeat; background-size:12px; }' +
  548. // 'body.theme_light #dir_list thead th.checked span::before { background-image:'+ $check_mark +'; background-repeat: no-repeat; background-size:10px; background-position: center; }' +
  549. // 'body.theme_dark #dir_list thead th.checked span::before { background-image:'+ $check_mark_inv +'; background-repeat: no-repeat; background-size:10px; background-position: center; }' +
  550. 'body.theme_light.sort_by_default #sort_by_default span::after, body.theme_light.sort_by_name #sort_by_name span::after, body.theme_light.sort_by_size #sort_by_size span::after, body.theme_light.sort_by_date #sort_by_date span::after, body.theme_light.sort_by_kind #sort_by_kind span::after, body.theme_light.sort_by_ext #sort_by_ext span::after { background-image:'+ $up_arrow +'; background-repeat: no-repeat; background-size:10px; background-position: center; }' +
  551. 'body.theme_dark.sort_by_default #sort_by_default span::after, body.theme_dark.sort_by_name #sort_by_name span::after, body.theme_dark.sort_by_size #sort_by_size span::after, body.theme_dark.sort_by_date #sort_by_date span::after, body.theme_dark.sort_by_kind #sort_by_kind span::after, body.theme_dark.sort_by_ext #sort_by_ext span::after { background-image:'+ $up_arrow_inv +'; background-repeat: no-repeat; background-size:10px; background-position: center; }' +
  552. '#dir_list tbody a { background-size:auto 13px; background-position:6px 4px; }' +
  553. 'body.has_audio #content_pane:not(.has_image):not(.has_video):not(.has_ignored) { background-image: ' + $music +'; background-position: center; background-repeat: no-repeat; background-size:33.33%; }' +
  554. '#prev_track, #next_track { background: rgb(241, 243, 244) '+ $next_track_arrow +' center no-repeat; background-blend-mode:difference; }' +
  555. '#prev_track:hover, #next_track:hover, #close_audio:hover { background-blend-mode:normal; }' +
  556. '#close_audio { background:rgb(241, 243, 244); }' +
  557. '#close_audio::after { background:'+ $plus_sign +' center no-repeat; background-blend-mode:difference; background-size:14px; }' +
  558. '#decrease { background:'+ $minus_sign +' center no-repeat; background-size: 10px; }' +
  559. '#increase { background:'+ $plus_sign +' center no-repeat; background-size: 10px; }' +
  560. '#prev_btn, #next_btn { background: ' + $svg_arrow + ' 45% center no-repeat; background-size: contain; }' +
  561. 'body #content_pane.has_ignored:not(.has_grid) { background-image:'+ $file_icon_ignored +'; background-position: center; background-repeat: no-repeat; background-size:50%; }' +
  562. 'body.theme_dark #content_pane.has_ignored:not(.has_grid) { background-color:#333; background-image:'+ $file_icon_ignored_inv +'; background-position: center; background-repeat: no-repeat; background-size:50%; }' +
  563. 'body.theme_light.is_error #content_pane { background:#FFF '+ $error_icon +' center no-repeat; background-size:50%;}' +
  564. 'body.theme_dark.is_error #content_pane { background:#333 '+ $error_icon +' center no-repeat; background-size:50%;}' +
  565. // '#content_pane.has_image #content_container, #content_pane.has_pdf #content_container { background: '+ $spinner +' center no-repeat; background-size:20px; }' +
  566. // Default File Icons
  567. 'body.use_default_icons #dir_list .dir a.icon span { background:'+ $file_icon_dir_default + ' 6px 0 no-repeat; background-size:auto 13px; }' +
  568. 'body.use_default_icons #dir_list .file a.icon span { background:'+ $file_icon_file_default + ' 6px 0 no-repeat; background-size:auto 13px; }' +
  569. // Custom File Icons
  570. 'body.use_custom_icons #dir_list tr.file:not(.dir) a.icon span { background: '+ $file_icon_file +' 6px 0 no-repeat; background-size:14px 14px; }' +
  571. 'body.use_custom_icons #dir_list tr.file.audio a.icon span, body.use_custom_icons #dir_list tr.file.video a.icon span { background: transparent; }' +
  572. 'body.use_custom_icons #dir_list tr.file.font a.icon span { background: '+ $file_icon_font +' 6px 0 no-repeat; background-size:14px 14px; }' +
  573. 'body.use_custom_icons #dir_list tr.file.image a.icon span { background: '+ $file_icon_image +' 6px 0 no-repeat; background-size:14px 14px; }' +
  574. 'body.use_custom_icons #dir_list tr.file.pdf a.icon span { background: '+ $file_icon_pdf +' 6px 0 no-repeat; background-size:14px 14px; }' +
  575. 'body.use_custom_icons #dir_list tr.file[class*="htm"] a.icon span { background: '+ $file_icon_html +' 6px 0 no-repeat; background-size:14px 14px; }' +
  576. 'body.use_custom_icons #dir_list tr.file.ignore a.icon span { background: '+ $file_icon_ignored +' 6px 0 no-repeat; }' +
  577. 'body.use_custom_icons #dir_list tr.file.invisible a.icon span { background: '+ $file_icon_invisible +' 6px 0 no-repeat; background-size:14px 14px; }' +
  578. 'body.use_custom_icons #dir_list tr.dir.invisible a.icon span { background: '+ $file_icon_dir_invisible +' 6px 0 no-repeat; background-size:14px 14px; }' +
  579. 'body.use_custom_icons #dir_list tr.dir:not(.app) a.icon span { background: '+ $file_icon_dir +' 6px 0 no-repeat; background-size:14px 14px; }' +
  580. 'body.use_custom_icons #dir_list tr.app a span { background: '+ $file_icon_app +' 6px 0 no-repeat !important; background-size:14px 14px; }' +
  581. 'body.use_custom_icons #dir_list tr.file.code a.icon span { background: '+ $file_icon_code +' 6px 0 no-repeat; background-size:14px 14px }' +
  582. 'body.use_custom_icons #dir_list tr.file.text a.icon span, body.use_custom_icons #dir_list tr.file.markdown a.icon span { background: '+ $file_icon_text +' 6px 0 no-repeat; background-size:14px 14px }' +
  583. // shortcuts icons
  584. '#shortcuts ul a { background: '+ $file_icon_file +' 8px center no-repeat; background-size:14px 14px }' +
  585. '#shortcuts ul a[href^="file"] { background: '+ $file_icon_dir +' 8px center no-repeat; background-size:14px 14px }' +
  586. '#shortcuts ul a[href^="http"] { background: '+ $file_icon_html +' 8px center no-repeat; background-size:14px 14px }' +
  587. // BORDERS
  588. ':root, html, body, #sidebar_wrapper, #sidebar_header, #dir_list, #main_content, #content_pane, #content_pdf, #content_iframe' +
  589. '{ border: 0 !important; }' +
  590. 'body.theme_dark ul' +
  591. '{ border: solid 1px #222; }' +
  592. 'button' +
  593. '{ border: solid 1px #333; }' +
  594. 'body.theme_light #sidebar ul' +
  595. '{ border: solid 1px gray; }' +
  596. // border-top
  597. 'body.theme_dark #sidebar_header .menu, body.theme_dark #grid_btn ul.menu, body.theme_dark #text_editor_row, body.theme_dark #dir_list #tbody, body.theme_dark #index_stats' +
  598. '{ border-top:solid 1px #111; }' +
  599. 'body.theme_light #dir_list tbody, #grid_btn .menu, body.theme_light #shortcuts, body.theme_light #text_editor_row, #index_stats, .font_grid_item:not(:first-of-type), .image_grid_item + .font_grid_item' +
  600. '{ border-top:solid 1px grey; }' +
  601. '#sort_by, tr.sorted, tr:not(.invisible) ~ tr.invisible + tr:not(.invisible)' + // , tr.dir ~ tr:not(.dir,.invisible,.ignore)
  602. '{ border-top:solid 1px #999; }' +
  603. // border-right
  604. '#parents_dir_menu + ul, #shortcuts_menu + ul, #grid_btn ul.menu' +
  605. '{ border-right:0 !important; }' +
  606. 'body.theme_dark #parents_dir_menu, body.theme_dark #sidebar, body.theme_dark #grid_btn .menu li, body.theme_dark #warnings' +
  607. '{ border-right:solid 1px #111; }' +
  608. '#sidebar, body.theme_light #parents_dir_menu, #grid_btn .menu li, .image_grid_item' +
  609. '{ border-right:solid 1px grey; }' +
  610. // border-bottom
  611. 'body.theme_dark #sidebar_title, body.theme_dark #sidebar_menus, body.theme_dark #sidebar_header .menu, body.theme_dark #content_header, body.theme_dark #content_pane.has_audio #content_title, body.theme_dark #grid_btn .menu li:first-of-type, body.theme_dark #grid_btn ul.menu, body.theme_dark #warnings' +
  612. '{ border-bottom:solid 1px #111; }' +
  613. 'body.theme_light #sidebar_header thead tr, body.theme_light #shortcuts, body.theme_light #sidebar_menus, #grid_btn .menu li:first-of-type, #grid_btn .menu, .specimen, .font_grid_item:last-of-type, .image_grid_item' +
  614. '{ border-bottom:solid 1px grey; }' +
  615. 'body.theme_light #content_title, body.theme_light #content_pane.has_audio #content_header' +
  616. '{ border-bottom:solid 1px #888; }' +
  617. '#shortcuts_menu + ul > li.has_submenu.ruled, .rule' +
  618. '{ border-bottom:solid 1px #999; }' +
  619. 'body.theme_dark #content_pane.has_font #content_font hr, .hamburger h4' +
  620. '{ border-bottom:solid 1px #CCC; }' +
  621. // border-left
  622. '#parents_dir_menu + ul, #shortcuts_menu + ul' +
  623. '{ border-left:0; }' +
  624. 'body.theme_dark #parents_dir_menu, body.theme_dark #grid_btn ul.menu, body.theme_dark #warnings' +
  625. '{ border-left:solid 1px #111; }' +
  626. 'body.theme_light #parents_dir_menu, #grid_btn .menu' +
  627. '{ border-left:solid 1px grey; }' +
  628. // border-collapse
  629. 'table' +
  630. '{ border-collapse: collapse; }' +
  631. // border-radius
  632. 'html, body, :root' +
  633. '{ border-radius: 0; }' +
  634. 'button' +
  635. '{ border-radius: 3px; }' +
  636. '#warnings' +
  637. '{ border-radius: 0 0 3px 3px; }' +
  638. // bottom
  639. '#handle, #parent_dir_menu, #dir_list, #index_stats, #close_audio::after, #dir_list tbody, #content_container, #overlay, #content_pane.has_grid #content_grid::after, #content_pane.has_grid .image_grid_item::after, .split_btn::after' +
  640. '{ bottom: 0; }' +
  641. // box-shadow
  642. 'body.theme_light #sidebar ul' +
  643. '{ box-shadow: 0px 2px 3px -2px #888; }' +
  644. 'body.theme_dark #sidebar ul' +
  645. '{ box-shadow:0px 2px 3px -2px #111; }' +
  646. '#warnings' +
  647. '{ box-shadow:0px 2px 12px 0 #111; }' +
  648. 'body.theme_dark #grid_btn ul.menu' +
  649. '{ box-shadow:none; }' +
  650. // box-sizing
  651. 'html, body, :root, #sidebar, #grid_btn .menu li, #content_container, #content_source, #content_preview' +
  652. '{ box-sizing: border-box; }' +
  653. // clear
  654. '#dir_list tbody .name' +
  655. '{ clear:right; }' +
  656. '#checkbox_div label, #grid_btn .menu li, #content_grid .font_grid_item' +
  657. '{ clear: both; }' +
  658. // columns
  659. '.lorem + .lorem' +
  660. '{ columns:2; column-gap:2em; }' +
  661. '.lorem + .lorem + .lorem' +
  662. '{ columns:3; }' +
  663. // COLOR
  664. 'body.theme_light #sidebar, body.theme_light #sidebar a, #content_header, body.theme_light #content_font, body.theme_light .font_grid_item a, body.theme_light .image_grid_item p, body.theme_light #content_font, body.theme_light .font_grid_item p, body.theme_light .font_grid_item a, body.theme_light .image_grid_item p, .split_btn span, body #warnings' +
  665. '{ color: #111 }' +
  666. 'body.theme_light #index_stats' +
  667. '{ color: #444 }' +
  668. 'body.theme_light #dir_list tr.ignore a, body.theme_light #dir_list tr.ignore.app a' +
  669. '{ color: #777 }' +
  670. '#sort_menu .disabled span, #dir_list th.disabled' +
  671. '{ color: #999 }' +
  672. 'body.theme_dark #dir_list tr.ignore td, body.theme_dark #dir_list tr.file.ignore a, body.theme_dark #index_stats' +
  673. '{ color: #BBB }' +
  674. 'body.theme_dark #sidebar th:not(.disabled), body.theme_dark #sidebar td, body.theme_dark #sidebar a, body.theme_dark #error_message *,body.theme_dark #content_header tr, body.theme_dark #content_font, body.theme_dark .font_grid_item p, body.theme_dark .font_grid_item a, body.theme_dark .image_grid_item p, #warnings button:focus, #warnings button.focus' +
  675. '{ color: #EEE }' +
  676. // CONTENT
  677. 'body#top.edited #warnings.unloading h3::before, #dir_list th span::before, #dir_list th span::after, body.has_hidden_sidebar #handle, #dir_list tr:empty, #dir_list .audio td.icon, #dir_list .video td.icon, tr.invisible, body.hide_ignored .ignore, .split_btn::after, #close_audio::after, #content_pane.has_grid #content_grid::after, #content_pane.has_grid .image_grid_item::after' +
  678. '{ content:"" }' +
  679. '#content_pane.has_audio #content_audio_title td::before, body #content_pane.has_video #title::before' +
  680. '{ content:"Playing: " }' + // .audio, .video
  681. '#content_pane.has_dir:not(.has_grid) #title::before' +
  682. '{ content:"Index of: " }' + // .dir
  683. '#content_pane.has_grid:not(.has_ignored) #title::before' +
  684. '{ content:"Fonts and Images from: " }' + // font and image grid
  685. 'body:not(.has_images) #content_pane.has_grid:not(.has_ignored) #title::before, #content_pane.has_grid #title.font_grid::before' +
  686. '{ content:"Fonts from: " }' + // font grid
  687. 'body:not(.has_fonts) #content_pane.has_grid:not(.has_ignored) #title::before, #content_pane.has_grid #title.image_grid::before' +
  688. '{ content:"Images from: " }' + // image grid
  689. '#content_pane.has_ignored:not(.has_grid) #title::before' +
  690. '{ content:"Ignored content: " }' + // .ignored
  691. 'body.edited.has_text #title::after, body.iframe_edited:not(.has_text) #content_pane.has_iframe #title::after' +
  692. '{ content:" (edited)" }' + // .ignored
  693. 'body#top.edited #text_editor_row a:after' +
  694. '{ content: " (edited)" }' + // .dir
  695. 'body#top.edited #warnings.unloading h3::before' +
  696. '{ content: "Text Editor: " }' + // .dir
  697. '#title::after' +
  698. '{ content: attr(data-after) }' + // .dir
  699. // counter
  700. 'body.show_numbers #tbody' +
  701. '{ counter-reset: row; }' +
  702. 'body.show_numbers #tbody tr td.name a::before' +
  703. '{ counter-increment: row; content:counter(row);}' +
  704. // cursor
  705. '#sidebar_title th, #sort_menu .disabled span, #dir_list .disabled' +
  706. '{ cursor: default; }' +
  707. '#sidebar_menus td:hover, #parents_dir_menu div, #shortcuts_menu div, #grid_btn, #dir_list thead th, .split_btn span' +
  708. '{ cursor: pointer; }' +
  709. '#handle' +
  710. '{ cursor: col-resize; }' +
  711. '#content_pane:not(.has_zoom_image) #content_image' +
  712. '{ cursor: zoom-in; }' +
  713. '#content_pane.has_zoom_image content_image' +
  714. '{ cursor: zoom-out; }' +
  715. // DISPLAY
  716. '#sidebar_menus ul, #show_details span, #grid_btn, #grid_btn .menu, #dir_list thead .name input, #dir_list thead th.up::before, #dir_list .details, #dir_list thead td.icon, #dir_list tr::before, #tbody tr td:not(.name), #text_editor_row, body.has_hidden_sidebar #handle, body.has_hidden_sidebar #sidebar, #dir_list tr:empty, #dir_list tr.audio td.icon, #dir_list tr.video td.icon, tr.invisible, body.hide_ignored #tbody tr.ignore, #content_title::before, #content_pane #content_audio_title, .split_btn, #content_pane #content_audio, #content_pane #content_grid, #content_pane #content_text, #content_pane .content, #content_pane.has_grid .content, body.has_text .content:not(#content_text), #content_pane.has_hidden_grid #content_grid, body.theme_light #theme_dark, body.theme_dark #theme_light, body.use_custom_icons #dir_list img, #dir_list tr.file.audio a img, #dir_list tr.file.video a img, #warnings, #warnings p, #warnings button, #clear_warning, #overlay' +
  717. '{ display: none; }' +
  718. '#sidebar li, #parent_dir_menu, #parent_dir_menu a, #parents_dir_menu + ul li a, #shortcuts_menu + ul li a, #shortcuts_menu + ul li > span, #shortcuts_menu + ul > li:hover > ul, #shortcuts_menu + ul > li > ul:hover, body.show_details #show_details span:last-of-type, body:not(.show_details) #show_details span:first-of-type, body.has_hidden_text #text_editor_row, #sort_by_default, #dir_list tbody a, #content_header, #content_pane.has_font:not(.has_grid) #content_font, #content_pane.has_image:not(.has_grid) #content_image, #content_pane.has_zoom_image #content_image, #content_pane.has_pdf:not(.has_grid) #content_pdf, body.has_text #content_pane:not(.has_grid) #content_text, #content_pane.has_video:not(.has_grid) #content_video, body:not(.has_text) #content_pane.has_iframe:not(.has_grid) #content_iframe, #content_pane.has_dir:not(.has_grid) #content_iframe, #content_pane.has_grid #content_grid.has_grid, #content_pane.has_grid #content_grid.has_font_grid, #content_pane.has_grid .nav_btn, #content_pane.has_font .nav_btn, .font_grid_item a, .image_grid_item a, #checkbox_div label, body.theme_dark #theme_dark, body.theme_light #theme_light, body:not(.has_hidden_sidebar) #dir_list .name, body.has_warning #warnings, body.has_warning #warnings.unloading p#warning_unsaved, body.has_warning #warnings.clear #warning_clear, body.has_warning #warnings.local p#warning_local, body.has_warning #overlay' +
  719. '{ display: block; }' +
  720. 'body.has_text #dir_list tr#text_editor_row td, body #dir_list tr#text_editor_row td a, body.show_details #text_editor_row td, body.show_details #text_editor_row td a, body.has_images.has_fonts #grid_btn:hover ul.menu' +
  721. '{ display:block !important; }' +
  722. '#parents_dir_menu div, body.has_fonts #grid_btn, body.has_images #grid_btn, #dir_list thead th span::before, #enable_text_editing::before, #dir_list thead th span::after, body.show_details #dir_list th.details:not(#name):not(#sort_by_default), body.show_details #dir_list td.details:not(.name):not(.ext), body.show_numbers #tbody tr td.name a::before, body.has_audio #dir_list thead input, #title, #checkbox_div, #prev_track, #next_track, #close_audio, #content_pane.has_grid .split_btn, #content_pane.has_image .split_btn, #content_pane.has_zoom_image .split_btn, #content_pane.has_font .split_btn, .split_btn span, body.has_warning #warnings.unloading #warning_ignore_btn, body.has_warning #warnings.unloading #warning_cancel_btn, body.has_warning #warnings.unloading #warning_save_btn, body.has_warning #warnings.clear #warning_clear_btn, body.has_warning #warnings.clear #warning_cancel_btn, body.has_warning #warnings.local #warning_ok_btn' +
  723. '{ display: inline-block; }' +
  724. '#dir_list tr td.name span, #content_pane.has_image:not(.has_grid) #content_container, #content_pane.has_video:not(.has_grid) #content_container' +
  725. '{ display: flex; }' +
  726. '#content_pane.has_audio #content_audio_title, #content_pane.has_audio #content_audio' +
  727. '{ display: table-row !important; }' +
  728. '#shortcuts_menu div, #content_pane, #content_pane.has_audio #content_audio td' +
  729. '{ display: table-cell; }' +
  730. // display grid: dir_list editor row
  731. 'body.has_text #dir_list #text_editor_row, body.show_details #text_editor_row' +
  732. '{ display: grid; grid-gap:0; grid-template-columns: 1fr; }' +
  733. // display grid: table header
  734. '#theader' +
  735. '{ display: grid; grid-gap:0; grid-template-columns: 1fr 1fr 1fr 1fr; }' +
  736. 'th#sort_by_name' +
  737. '{ grid-column: 1 / span 2; }' +
  738. 'th#sort_by_default' +
  739. '{ grid-column: 3 / span 2; }' +
  740. // display grid: dir_list rows and cells
  741. '#dir_list #tbody tr:not(.invisible), body.show_invisibles #tbody tr.invisible, body.show_details #dir_list tr td.details' +
  742. '{ display: grid; grid-gap:0; grid-template-columns: minmax(auto,6rem) 1fr minmax(auto,6rem); }' +
  743. 'td.name' +
  744. '{ grid-column: 1 / span 3; }' +
  745. 'td.size' +
  746. '{ grid-column: 1; grid-row: 2; }' +
  747. 'td.date' +
  748. '{ grid-column: 2; grid-row: 2; }' +
  749. 'td.kind' +
  750. '{ grid-column: 3; grid-row: 2; }' +
  751. // display grid: content pane grids
  752. '#content_pane.has_grid #content_grid' +
  753. '{ display: grid !important; grid-gap:0; grid-template-columns: repeat(auto-fill, minmax('+ ($settings.grid_image_size +16) +'px, auto)); grid-auto-rows: minmax(min-content, max-content); }' +
  754. '#content_pane.has_grid #content_grid .image_grid_item' +
  755. '{ grid-column: auto; display:flex; align-items: center; }' +
  756. '#content_pane.has_grid #content_grid .font_grid_item' +
  757. '{ grid-column: 1 / -1; }' +
  758. // FILTER
  759. 'body.theme_dark #grid_btn, body.theme_dark #grid_btn .menu, body.theme_dark #parent_dir_menu, body.theme_dark #shortcuts_menu, body.theme_dark #toggle_sidebar' +
  760. '{ filter:invert(100%); }' +
  761. // FLOAT
  762. '#dir_list tr td.name a::before, #checkbox_div label' +
  763. '{ float: left; }' +
  764. '#grid_btn' +
  765. '{ float: right; }' +
  766. // font-family
  767. 'html, body, :root' +
  768. '{ font-family:'+ $settings.UI_font +'; }' +
  769. // font-size
  770. 'html' +
  771. '{ font-size: 100.001%; }' +
  772. 'body, :root, #content_text' +
  773. '{ font-size:'+ $settings.UI_font_size +'; }' +
  774. '#sidebar, #sidebar_header, #dir_list, #index_stats, #content_header, #content_header table, #warnings' +
  775. '{ font-size: 0.875rem; }' +
  776. '#content_grid, .font_grid_item p, #error_message h1, #error_message h2' +
  777. '{ font-size: 1rem; }' +
  778. '#content_grid .font_grid_item h2' +
  779. '{ font-size:'+ $settings.grid_font_size * 4 +'em; }' +
  780. '#content_font' +
  781. '{ font-size:'+ $settings.grid_font_size +'em; }' +
  782. '#content_font .specimen' +
  783. '{ font-size:4em; }' +
  784. '#content_font .hamburger h1' +
  785. '{ font-size: 8em }' +
  786. '#content_font .hamburger h2' +
  787. '{ font-size:6em; text-align:justify; }' +
  788. '#content_font .hamburger h3' +
  789. '{ font-size:2em; }' +
  790. '#content_font .hamburger h4' +
  791. '{ font-size:1.618em; }' +
  792. '.lorem.first:first-line' +
  793. '{ font-size:'+ $settings.grid_font_size * 1.33 +'em; }' +
  794. // font-variant
  795. '.lorem.first:first-line' +
  796. '{ font-variant: small-caps }' +
  797. // font-weight
  798. '#sidebar_title th, h1, h2, h3, h4, h5, h6' +
  799. '{ font-weight: normal }' +
  800. '#dir_list .selected a' +
  801. '{ font-weight: bold }' +
  802. // HEIGHT
  803. 'html, body, :root, #parent_dir_menu a, #dir_list, #main_content, #content_pane, #content_pdf, #content_text, #content_iframe' +
  804. '{ height: 100%; }' +
  805. '#sidebar_header, #parents_dir_menu, #parents_dir_menu div, #content_pane:not(.has_zoom_image) #content_image, #content_grid div img' +
  806. '{ height: auto; }' +
  807. '#dir_list thead th span::before, #dir_list thead th span::after' +
  808. '{ height: 8px; }' +
  809. '#toggle_sidebar' +
  810. '{ height: 14px; }' +
  811. '#dir_list td.icon' +
  812. '{ height: 16px; }' +
  813. '#grid_btn, #scale, #prev_next_btns, #close_btn, #reload_btn' +
  814. '{ height: 18px; }' +
  815. '#audio' +
  816. '{ height: 32px; }' +
  817. '.image_grid_item a' +
  818. '{ align-self: center; justify-self: center; }' +
  819. //'#content_grid.has_grid .image_grid_item' +
  820. // '{ height: '+ $grid_image_size +'px; }' +
  821. '#main_content' +
  822. '{ height:'+ window.innerHeight +'px; }' +
  823. // max-height
  824. '#content_pane:not(.has_zoom_image) #content_image' +
  825. '{ max-height: calc(100% - 4em); }' +
  826. '#content_pane.has_zoom_image #content_image' +
  827. '{ max-height: none; }' +
  828. '#content_grid div img' +
  829. '{ max-height:'+ ($settings.grid_image_size) +'px; }' +
  830. // min-height
  831. '#title' +
  832. '{ min-height: 18px; }' +
  833. '#sidebar' +
  834. '{ min-height: 100%; }' +
  835. // hyphens
  836. '#parents_dir_menu div, #content_header td button, #content_font' +
  837. '{ hyphens: none; }' +
  838. 'html, body, :root, .hamburger h3, .lorem' +
  839. '{ hyphens: auto; }' +
  840. // LEFT
  841. '#sidebar ul, #parent_dir_menu, #dir_list thead, #dir_list tbody, #index_stats, #close_audio::after, body.has_hidden_sidebar #toggle_sidebar, #overlay' +
  842. '{ left: 0; }' +
  843. ' #grid_btn ul.menu' +
  844. '{ left: unset; }' +
  845. 'body.has_hidden_sidebar #sidebar_wrapper' +
  846. '{ left: 3px; }' +
  847. 'body.show_numbers #tbody tr td.name a::before' +
  848. '{ left: 6px; }' +
  849. '#warnings, .split_btn::after' +
  850. '{ left: 50%; }' +
  851. '#shortcuts_menu + ul > li > ul' +
  852. '{ left: 100%; }' +
  853. '#dir_list thead th span::before' +
  854. '{ left: -16px; }' +
  855. // letter-spacing
  856. '.lorem.first:first-line, .font_grid_item p' +
  857. '{ letter-spacing: 0.1em }' +
  858. '#sidebar_title th' +
  859. '{ letter-spacing: 0.5em }' +
  860. // line-height
  861. '.image_grid_item a' +
  862. '{ line-height: 0; }' +
  863. '.split_btn span, .font_grid_item p' +
  864. '{ line-height: 1; }' +
  865. '#content_font .specimen' +
  866. '{ line-height: 1.2; }' +
  867. '#dir_list tr a, #title, .lorem' +
  868. '{ line-height: 1.4; }' +
  869. // list-style
  870. '#sidebar ul, #grid_btn .menu li' +
  871. '{ list-style-type: none; }' +
  872. // MARGIN
  873. 'html, body, :root, #sidebar ul, #parent_dir_menu, #parent_dir_menu, #parents_dir_menu, #parents_dir_menu + ul li a, #shortcuts_menu + ul li a, #shortcuts_menu + ul li > span, #shortcuts_menu, #grid_btn, #dir_list tbody a, #content_font .hamburger *, #content_grid p, #content_grid h2, #content_text, #warnings h3' +
  874. '{ margin: 0; }' +
  875. // margin-top
  876. '.image_grid_item + .font_grid_item' +
  877. '{ margin-top:-1px; }' +
  878. '#checkbox_div label input, #show_details, body.is_error #tbody h1' +
  879. '{ margin-top: 0; }' +
  880. 'body.has_audio #dir_list input' +
  881. '{ margin-top: 1px; }' +
  882. // margin-right
  883. '#content_image, #content_video, .image_grid_item a' +
  884. '{ margin-right: auto; }' +
  885. '#increase' +
  886. '{ margin-right: -4px; }' +
  887. '#tbody th input, tr.media input, #reload_btn, #scale' +
  888. '{ margin-right: 8px; }' +
  889. '#show_details' +
  890. '{ margin-right: 0.5em; }' +
  891. '#dir_list th#sort_by_default span, #warning_ignore_btn' +
  892. '{ margin-right: 2em; }' +
  893. '#checkbox_div' +
  894. '{ margin-right: calc(-6em - 4px); }' +
  895. // margin-bottom
  896. '#show_details' +
  897. '{ margin-bottom: 0; }' +
  898. 'body.has_audio #dir_list input' +
  899. '{ margin-bottom: 1px; }' +
  900. '#content_grid.has_image_grid' +
  901. '{ margin-bottom: 1rem; }' +
  902. // margin-left
  903. '#content_image, #content_video, .image_grid_item a' +
  904. '{ margin-left: auto; }' +
  905. '#decrease' +
  906. '{ margin-left: -4px; }' +
  907. 'th input, tr.media input' +
  908. '{ margin-left: 7px; }' +
  909. 'body.has_hidden_sidebar #title_buttons_left' +
  910. '{ margin-left: 16pt; }' +
  911. '#show_details, #warnings button' +
  912. '{ margin-left: 0.5em; }' +
  913. '#warnings' +
  914. '{ margin-left: -12em; }' +
  915. '#dir_list tbody tr' +
  916. '{ margin-inline-start:0; }' +
  917. // -webkit-margin
  918. '#sidebar ul' +
  919. '{ -webkit-margin-before:0em !important; -webkit-margin-after:0em !important; -webkit-padding-start:0em; }' +
  920. // Object-fit
  921. '#content_image' +
  922. '{ object-fit:contain; }' +
  923. // OPACITY
  924. '#content_pane.has_ignored::before, #close_audio::after' +
  925. '{ opacity:0.3; }' +
  926. '#close_audio:hover::after' +
  927. '{ opacity:0.6; }' +
  928. '#sidebar_menus td:last-of-type:hover > div, #shortcuts_menu div, #shortcuts_menu div, #parent_dir_menu, #content_pane:hover #prev_btn, #content_pane:hover #next_btn, #toggle_sidebar, body.use_custom_icons #dir_list tr.file.ignore a.icon::before, .split_btn span' +
  929. '{ opacity: 0.7; }' +
  930. '#content_grid div img' +
  931. '{ opacity:0.8; }' +
  932. '#grid_btn:hover, #parent_dir_menu:hover, #content_pane #prev_btn:hover, #content_pane #next_btn:hover, #toggle_sidebar:hover, .split_btn span:hover' +
  933. '{ opacity:1; }' +
  934. // outline
  935. '#grid_btn, #dir_list tbody, #dir_list tbody a, #audio:focus, #content_grid .font_grid_item, #content_font, #warnings button:focus, #content_video' +
  936. '{ outline: none; }' +
  937. // OVERFLOW
  938. 'html, body, :root, #parents_dir_menu div, #shortcuts_menu, #dir_list, #dir_list tbody a, #main_content, #close_audio, .hamburger h1, .hamburger h2, .hamburger h4' +
  939. '{ overflow: hidden; }' +
  940. '#dir_list tbody, #next_track, #prev_track, #content_container, #content_font, #content_grid' +
  941. '{ overflow: auto; }' +
  942. '#sidebar, #content_font' +
  943. '{ overflow-wrap: break-word; }' +
  944. '.lorem' +
  945. '{ overflow-wrap: normal; }' +
  946. // PADDING
  947. 'html, body, :root, #sidebar_wrapper, #sidebar ul, #parent_dir_menu, #sidebar_header tbody tr td, #parent_dir_menu, #parent_dir_menu a, #parents_dir_menu, #shortcuts_menu, #dir_list .details a, #content_pane, #content_pdf, #content_iframe, #content_text, audio::-webkit-media-controls-panel' +
  948. '{ padding: 0; }' +
  949. '#sidebar_title th' +
  950. '{ padding: 4px; }' +
  951. '.image_grid_item' +
  952. '{ padding:6px; }' +
  953. '#error_message, #warnings' +
  954. '{ padding:1rem; }' +
  955. // padding-top
  956. '#dir_list thead th, #dir_list .details, #prev_track, #next_track, #close_audio' +
  957. '{ padding-top: 0; }' +
  958. '#show_details, #text_editor_row a' +
  959. '{ padding-top: 2px; }' +
  960. '#parents_dir_menu div, #grid_btn .menu li, #dir_list tbody a, #index_stats, #title_buttons_left, #title_buttons_right, #title, body #content_audio_title td, #content_audio td' +
  961. '{ padding-top: 4px; }' +
  962. '#sidebar_header tbody tr:last-of-type td, #parents_dir_menu + ul li a, #shortcuts_menu + ul li a, #shortcuts_menu + ul li > span, #shortcuts_menu + ul li div span, .hamburger h4' +
  963. '{ padding-top: 6px; }' +
  964. '#content_header table' +
  965. '{ padding-top: 7px; }' +
  966. '#content_grid .font_grid_item, .font_grid_item p, #content_font div.lorem' +
  967. '{ padding-top: 0.5rem; }' +
  968. 'body:not(.has_text) #content_pane.has_image:not(.has_grid) #content_container, #content_font div.specimen' +
  969. '{ padding-top: 2rem; }' +
  970. // padding-right
  971. '#sidebar_header tbody tr:last-of-type td, #prev_track, #next_track, #prev_next_btns, #close_audio' +
  972. '{ padding-right: 0; }' +
  973. '#scale' +
  974. '{ padding-right: 4px; }' +
  975. '#parents_dir_menu div, #show_details, #grid_btn .menu li, #index_stats, #title_buttons_left, #title_buttons_right, #content_audio td, #close_audio' +
  976. '{ padding-right: 6px; }' +
  977. '#parents_dir_menu + ul li a, #shortcuts_menu + ul li a, #shortcuts_menu + ul li > span, #shortcuts_menu + ul li div span, body.show_numbers #tbody tr td.name a::before, #dir_list tbody a' +
  978. '{ padding-right: 8px; }' +
  979. '#dir_list th.details, #dir_list td.details, #content_header table, #title' +
  980. '{ padding-right: 12px; }' +
  981. '#grid_btn .menu, #content_audio_title td' +
  982. '{ padding-right: 29px; }' +
  983. '.font_grid_item p, .font_grid_item a' +
  984. '{ padding-right: 2rem; }' +
  985. 'body:not(.has_text) #content_pane.has_image:not(.has_grid) #content_container, #content_font div' +
  986. '{ padding-right: 2.5rem; }' +
  987. // padding-bottom
  988. '#prev_track, #next_track, #close_audio' +
  989. '{ padding-bottom: 0px }' +
  990. '#show_details, body.is_dirs_on_top #dir_list tbody tr.sorted:not(:last-of-type)' +
  991. '{ padding-bottom: 2px; }' +
  992. '#title, body #content_audio_title td, #text_editor_row a' +
  993. '{ padding-bottom: 3px;}' +
  994. '#parents_dir_menu div, #grid_btn .menu li, #dir_list tbody a, #dir_list .details, #index_stats' +
  995. '{ padding-bottom: 4px; }' +
  996. '#title_buttons_left, #title_buttons_right' +
  997. '{ padding-bottom: 3px; }' +
  998. '#content_header table' +
  999. '{ padding-bottom: 5px; }' +
  1000. '#sidebar_header tbody tr:last-of-type td, #parents_dir_menu + ul li a, #shortcuts_menu + ul li a, #shortcuts_menu + ul li > span, #shortcuts_menu + ul li div span, #dir_list thead th, #content_audio td' +
  1001. '{ padding-bottom: 6px; }' +
  1002. '#dir_list thead th.details, .hamburger h4' +
  1003. '{ padding-bottom: 9px; }' +
  1004. '.specimen, .font_grid_item p, .font_grid_item a' +
  1005. '{ padding-bottom: 0.5rem; }' +
  1006. 'body:not(.has_text) #content_pane.has_image:not(.has_grid) #content_container, #content_font div:first-of-type, #content_font .lorem:last-of-type' +
  1007. '{ padding-bottom: 2rem; }' +
  1008. // padding-left
  1009. '#dir_list #tbody td.name a.icon, #dir_list td.details, #grid_btn .menu, #sidebar_header tbody tr:last-of-type td, #prev_next_btns' +
  1010. '{ padding-left: 0px; }' +
  1011. '#dir_list .audio a, #dir_list .video a, #checkbox_div, #scale' +
  1012. '{ padding-left: 4px; }' +
  1013. '#parents_dir_menu div, #dir_list th#name, #dir_list td.icon, #dir_list .icon + td.name a, #checkbox_div #parents_dir_menu div, #show_details, #grid_btn .menu li, #index_stats, #title_buttons_left, #title_buttons_right, #content_audio td, #prev_track' +
  1014. '{ padding-left: 6px; }' +
  1015. '#parents_dir_menu + ul li a, #shortcuts_menu + ul li a, #shortcuts_menu + ul li > span, #shortcuts_menu + ul li div span' +
  1016. '{ padding-left: 8px; }' +
  1017. '#content_header table, #dir_list th.details, #title' +
  1018. '{ padding-left: 12px; }' +
  1019. '#shortcuts ul li a' +
  1020. '{ padding-left: 16px; }' +
  1021. 'body:not(.has_media) #sort_by_name' +
  1022. '{ padding-left: 20px; }' +
  1023. '#dir_list #tbody tr:not(.media) a span, #text_editor_row a' +
  1024. '{ padding-left: 27px; -webkit-padding-start: 27px; }' +
  1025. '#dir_list thead th#size, #dir_list #tbody td.details.size, #content_audio_title td' +
  1026. '{ padding-left: 29px; }' +
  1027. 'tr.media a.icon' +
  1028. '{ padding-left: 31px; }' +
  1029. '#sort_menu li span, body.show_numbers.has_media #dir_list thead .name, .font_grid_item p, .font_grid_item a' +
  1030. '{ padding-left: 2rem; }' +
  1031. 'body:not(.has_text) #content_pane.has_image:not(.has_grid) #content_container, #content_font div' +
  1032. '{ padding-left: 2.5rem; }' +
  1033. //-webkit-padding
  1034. '#dir_list td.name a' +
  1035. '{ -webkit-padding-start:0; }' +
  1036. '#dir_list .icon + td.name a' +
  1037. '{ -webkit-padding-start:1em; }' +
  1038. // POSITION
  1039. '#sidebar_wrapper, #sidebar_header, #sidebar_buttons, #sidebar_menus td:first-of-type, #sidebar_header tbody tr:last-of-type td, #dir_list, #dir_list thead th span, body.show_numbers #tbody tr td.name a::before, #dir_list tr.ignore a, #dir_list tr.ignore.app a, #dir_list tr.ignore td.details, #shortcuts_menu + ul > li.has_submenu, #content_pane, #content_header, #content_grid, #content_text, #content_font, #content_pdf, #content_iframe, #close_audio, #content_grid div img, #content_text, .split_btn' +
  1040. '{ position: relative; }' +
  1041. '#sidebar ul, #handle, #parent_dir_menu, #toggle_sidebar, body.has_hidden_sidebar #sidebar_wrapper, #dir_list tbody, #close_audio::after, .split_btn::after, #content_container, #content_image, #warnings, #overlay, #content_pane.has_grid #content_grid::after, #content_pane.has_grid .image_grid_item::after' +
  1042. '{ position: absolute; }' +
  1043. '#dir_list thead, #index_stats' +
  1044. '{ position: fixed; }' +
  1045. // RIGHT
  1046. '#sidebar ul, #parent_dir_menu, #grid_btn .menu, #dir_list thead, #dir_list tbody, #index_stats, #close_audio::after, #title_buttons_right, #next_btn, #overlay, #content_pane.has_grid #content_grid::after, #content_pane.has_grid .image_grid_item::after' +
  1047. '{ right: 0; }' +
  1048. '#dir_list thead th span::after' +
  1049. '{ right: -16px; }' +
  1050. '#toggle_sidebar' +
  1051. '{ right: 4px; }' +
  1052. '#handle' +
  1053. '{ right: -4px; }' +
  1054. // table-layout
  1055. '#dir_list' +
  1056. '{ table-layout: fixed; }' +
  1057. // text-align
  1058. '#sidebar ul, #dir_list tbody, #dir_list tbody .name, #dir_list thead th:not(.details), #dir_list tr.details, #title_buttons_left' +
  1059. '{ text-align: left; }' +
  1060. '#parent_dir_menu a, #parents_dir_menu, th.details, #parents_dir_menu div, #shortcuts_menu div, #content_header, #content_title, #content_audio_title, #content_audio td' +
  1061. '{ text-align: center; }' +
  1062. '#grid_btn .menu li, body.show_numbers #tbody tr td.name a::before, #dir_list th#sort_by_default, #dir_list .size, #dir_list .date, #dir_list .kind, #title_buttons_right, #warnings div' +
  1063. '{ text-align: right; }' +
  1064. '.hamburger, .lorem' +
  1065. '{ text-align: justify; }' +
  1066. // text-decoration
  1067. 'a, a:hover' +
  1068. '{ text-decoration: none !important; }' +
  1069. // text-indent
  1070. '#shortcuts li' +
  1071. '{ text-indent: 1em; }' +
  1072. // text-transform
  1073. '.font_grid_item p' +
  1074. '{ text-transform: uppercase; }' +
  1075. // TOP
  1076. '#handle, #parent_dir_menu, #dir_list, #title_buttons_left, #title_buttons_right, #close_audio::after, #prev_btn, #next_btn, #warnings, #overlay, #content_pane.has_grid #content_grid::after, .split_btn::after' +
  1077. '{ top: 0; }' +
  1078. '#shortcuts_menu + ul > li > ul, body.theme_light #grid_btn .menu' +
  1079. '{ top: -1px !important; }' +
  1080. 'body.has_hidden_sidebar #sidebar_wrapper, #dir_list thead th span::before, #dir_list thead th span::after' +
  1081. '{ top: 2px; }' +
  1082. '#toggle_sidebar' +
  1083. '{ top: 4px; }' +
  1084. 'body.theme_dark #grid_btn .menu' +
  1085. '{ top: -7px; }' +
  1086. // TRANSFORM
  1087. '#dir_list' +
  1088. '{ transform: scale(1); }' + // needed to establish #dir_list as containing block for thead and tfoot position fixed.
  1089. 'body.has_hidden_sidebar #toggle_sidebar, #dir_list thead th:not(.up) span::after, #next_track, #next_btn' +
  1090. '{ transform:rotate(180deg); }' +
  1091. '#close_audio::after' +
  1092. '{ transform:rotate(45deg); }' +
  1093. // user-select
  1094. '#sidebar_header, #content_pane:not(.has_zoom_image) #content_image' +
  1095. '{ user-select:none; -webkit-user-select:none; }' +
  1096. // vertical-align
  1097. '#content_pane' +
  1098. '{ vertical-align:top; }' +
  1099. '#title_buttons_left, #title_buttons_right, #title' +
  1100. '{ vertical-align:middle; }' +
  1101. // white-space
  1102. '#sidebar_header tbody tr:last-of-type td, #parents_dir_menu div, #parents_dir_menu + ul li a, #shortcuts_menu + ul li a, #shortcuts_menu + ul li > span, #dir_list tbody a, .specimen, .lorem' +
  1103. '{ white-space: normal; }' +
  1104. '#tbody td:not(.name), #grid_btn .menu li, .hamburger h1, .hamburger h2, .hamburger h4' +
  1105. '{ white-space: pre; }' +
  1106. // WIDTH
  1107. 'html, body, :root, table, #parent_dir_menu a, #dir_list thead, #tbody, #text_editor_row td, #tbody tr, #shortcuts_menu + ul > li > ul, #grid_btn .menu li, #content_container, #content_header, #content_grid, #content_text, #content_font svg, #content_pdf, #content_iframe' +
  1108. '{ width: 100%; }' +
  1109. '#sidebar_menus td:nth-of-type(2), #dir_list .date, #title, #title_buttons_left, #title_buttons_right, #content_pane:not(.has_zoom_image) #content_image, #content_grid div img' +
  1110. '{ width: auto; }' +
  1111. '.split_btn span' +
  1112. '{ width: 2em; }' +
  1113. '#content_pane.has_grid #content_grid::after, #content_pane.has_grid .image_grid_item::after, .split_btn::after' +
  1114. '{ width: 1px; }' +
  1115. '#handle' +
  1116. '{ width: 8px; }' +
  1117. '#dir_list thead th span::before, #dir_list thead th span::after, #toggle_sidebar' +
  1118. '{ width: 16px; }' +
  1119. '#sidebar_menus td:nth-of-type(odd)' +
  1120. '{ width: 24px; }' +
  1121. '#grid_btn' +
  1122. '{ width: 28px; }' +
  1123. '#prev_track, #next_track, #close_audio' +
  1124. '{ width: 2rem; }' +
  1125. '#shortcuts_menu div, #checkbox_div' +
  1126. '{ width: 6em; }' +
  1127. '#content_pane.has_image #title_buttons_left, #content_pane.has_image #title_buttons_right' +
  1128. '{ width: 11em; }' +
  1129. '#warnings' +
  1130. '{ width: 26em; }' +
  1131. 'body.has_hidden_sidebar #sidebar_wrapper' +
  1132. '{ width: 0 !important; }' +
  1133. 'body.has_hidden_sidebar #content_pane' +
  1134. '{ width: 100% !important; }' +
  1135. 'body:not(.has_hidden_sidebar) #sidebar_wrapper' +
  1136. '{ width:'+ getQuery('width').toString() +'%; }' +
  1137. 'body:not(.has_hidden_sidebar) #content_pane' +
  1138. '{ width:'+ (100 - getQuery('width')).toString() +'%; }' +
  1139. // max-width
  1140. 'html, body, :root' +
  1141. '{ max-width: 100%; }' +
  1142. '#content_pane:not(.has_zoom_image) #content_image' +
  1143. '{ max-width: calc(100% - 5em); }' +
  1144. '#content_pane.has_zoom_image #content_image' +
  1145. '{ max-width: none; }' +
  1146. '#sidebar_menus td:nth-of-type(odd)' +
  1147. '{ max-width: 24px; }' +
  1148. '#content_grid div img' +
  1149. '{ max-width:'+ ($settings.grid_image_size).toString() +'px; }' +
  1150. // min-width
  1151. 'body.show_numbers #tbody tr td.name a::before' +
  1152. '{ min-width: 17px; }' +
  1153. 'body:not(.has_hidden_sidebar) #sidebar_menus td:nth-of-type(odd)' +
  1154. '{ min-width: 24px; }' +
  1155. 'body:not(.has_hidden_sidebar) #dir_list' +
  1156. '{ min-width: 100px; }' +
  1157. 'body:not(.has_hidden_sidebar) #sidebar_wrapper' +
  1158. '{ min-width: 220px; }' +
  1159. // will-change
  1160. '#sidebar_wrapper, #content_pane' +
  1161. '{ will-change: width }' +
  1162. // word-break
  1163. '#content_header td button' +
  1164. '{ word-break: none; }' +
  1165. '#title' +
  1166. '{ word-break: break-word; }' +
  1167. '#content_font .specimen' +
  1168. '{ word-break: break-all; }' +
  1169. '.lorem' +
  1170. '{ word-break: normal; }' +
  1171. // Z-INDEX
  1172. '#content_pane' +
  1173. '{ z-index: 0; }' +
  1174. '#handle, #sidebar_wrapper' +
  1175. '{ z-index: 1 !important; }' +
  1176. '#parents_dir_menu + ul, #content_header' +
  1177. '{ z-index: 20; }' +
  1178. '#sidebar_header, #content_pane.has_grid .image_grid_item::after' +
  1179. '{ z-index: 2000; }' +
  1180. '#shortcuts_menu + ul, #toggle_sidebar' +
  1181. '{ z-index: 9997; }' +
  1182. '#overlay' +
  1183. '{ z-index: 9997; }' +
  1184. '#warnings' +
  1185. '{ z-index: 9999; }' +
  1186. 'body.has_hidden_sidebar #sidebar_header' +
  1187. '{ z-index:unset; }'
  1188. ;
  1189. // Gecko Styles:
  1190. const $gecko_style_rules =
  1191. 'html, body.is_gecko { border: solid 1px gray !important; }' +
  1192. 'body.is_gecko button { padding:revert; }' +
  1193. 'body.is_gecko #grid_btn .menu { top:-7px; left:-120px; }' +
  1194. 'body.is_gecko thead {font-size:100%;}' +
  1195. 'body.is_gecko #dir_list th, body.is_gecko #dir_list td {width:auto;}' +
  1196. 'body.is_gecko #dir_list .dir::before {position:absolute;}' +
  1197. 'body.is_gecko.use_default_icons:not(.is_converted_list) #dir_list .file .name .icon { padding-left:4px; background:none; }' +
  1198. 'body.is_gecko.use_default_icons #dir_list .file .name .icon img { margin-right:6px; height:14px; }' +
  1199. 'body.is_gecko #tbody > tr > td:not(:first-of-type) { float:left }' +
  1200. 'body.is_gecko #content_audio_title td { padding-top: 6px; }' +
  1201. 'body.is_gecko #content_audio_title td { padding-bottom: 0; }' +
  1202. 'body.is_gecko #prev_track { padding-left: 16px; }' +
  1203. 'body.is_gecko #close_audio { background-color: #252525; }' +
  1204. 'body.is_gecko #close_audio::after { filter:invert(100%); opacity:0.5; }' +
  1205. 'body.is_gecko #close_audio:hover::after { opacity:0.75; }' +
  1206. 'body.is_gecko.dark #prev_track, body.is_gecko.dark #next_track { background: #252525 '+ $next_track_arrow_gecko +' center no-repeat; }' +
  1207. 'body.is_gecko #prev_track:hover, body.is_gecko #next_track:hover { background: #252525 '+ $next_track_arrow_gecko_hover +' center no-repeat; }'
  1208. ;
  1209. var $text_editing_style_rules =
  1210. 'html, body, #iframe_body { margin:0; padding:0; }' +
  1211. // toolbar
  1212. '#toolbar { margin:0; padding:0; height:32px; display:block; position:relative; left:0; right:0; z-index:100; background:#EEE; border:0; border-bottom: solid 1px #999; font-family:'+ $settings.UI_font +'; font-size:'+ parseFloat($settings.UI_font_size) * 0.875 + $settings.UI_font_size.replace(/\d*/,'') +'; -webkit-user-select: none; -moz-user-select: none; user-select:none; }' +
  1213. '#toolbar li { margin:4px; padding:4px; width:3.5em; display:block; opacity:0.5; list-style-type:none; cursor:pointer; }' +
  1214. '#toolbar li:hover, .preview_text:not(.split) #toolbar li#show_preview, .source_text:not(.split) #toolbar li#showSRC, .split #toolbar li#toggle_split, .edited #save_btn { opacity:1; }' +
  1215. '#toolbar li#toggle_split { float:left; width:16px; height: 16px; margin: 4px 0 4px 4px; background:url("data:image/svg+xml;utf8,<svg version=\'1.1\' id=\'Layer_1\' xmlns=\'http://www.w3.org/2000/svg\' xmlns:xlink=\'http://www.w3.org/1999/xlink\' x=\'0px\' y=\'0px\' width=\'16px\' height=\'16px\' viewBox=\'0 0 16 16\' enable-background=\'new 0 0 16 16\' xml:space=\'preserve\'><path fill=\'%23444444\' d=\'M0,0v16h16V0H0z M15,15H8.5V1H15V15z M7.5,15H1V1h6.5V15z\'/></svg>") center no-repeat; }' +
  1216. '#toolbar li#sync_scroll { width:8em; float:left; opacity:1; }' +
  1217. '#toolbar li#sync_scroll input { float:left; }' +
  1218. '#toolbar li#sync_scroll label { width:8em; display:block; font-size:inherit; line-height:1.5; }' +
  1219. '#toolbar li#clear_text { height:16px; float:right; text-align:center; }' +
  1220. '#toolbar li#save_btn { float:right; width:20px; height:16px; background: url("data:image/svg+xml;utf8,<svg version=\'1.1\' id=\'Layer_1\' xmlns=\'http://www.w3.org/2000/svg\' xmlns:xlink=\'http://www.w3.org/1999/xlink\' x=\'0px\' y=\'0px\' width=\'16px\' height=\'16px\' viewBox=\'0 0 16 16\' enable-background=\'new 0 0 16 16\' xml:space=\'preserve\'><g> <path fill=\'%23444444\' d=\'M16,0v10.02h-1.33V1.33H1.33v8.69H0V0H16z\'/> <path fill=\'%23444444\' d=\'M8.47,16h-0.7l-3.08-3.08l0.94-0.94l1.83,1.83V4.28h1.33v9.53l1.81-1.82l0.94,0.93L8.47,16z\'/></g></svg>") 8px 4px no-repeat; position:relative; }' +
  1221. '#toolbar li#show_source { float:left; width:16px; height: 16px; margin: 4px 0 4px 12px; background:url("data:image/svg+xml;utf8,<svg version=\'1.1\' id=\'Layer_1\' xmlns=\'http://www.w3.org/2000/svg\' xmlns:xlink=\'http://www.w3.org/1999/xlink\' x=\'0px\' y=\'0px\' width=\'42px\' height=\'16px\' viewBox=\'0 0 42 16\' enable-background=\'new 0 0 42 16\' xml:space=\'preserve\'><g> <path fill=\'%23444444\' d=\'M0.08,7.02L5.94,3.9l0.43,0.78L1.18,7.42l5.19,2.74l-0.43,0.78L0.08,7.82V7.02z\'/> <path fill=\'%23444444\' d=\'M7.84,16.01H6.82L13.78,0h1.02L7.84,16.01z\'/> <path fill=\'%23444444\' d=\'M21.75,7.87l-5.86,3.12l-0.43-0.78l5.19-2.74l-5.19-2.74l0.43-0.78l5.86,3.12V7.87z\'/> <path fill=\'%23444444\' d=\'M30.98,2.65h-3.63V1.58h8.55v1.07h-3.63v9.65h-1.28V2.65z\'/> <path fill=\'%23444444\' d=\'M36.38,4.71h1.3l0.42-2h0.8v2h2.45v0.99h-2.45v4.63c0,0.74,0.27,1.15,0.96,1.15c0.43,0,1.09-0.21,1.39-0.35 l0.18,0.95c-0.42,0.26-1.18,0.45-1.81,0.45c-1.36,0-1.94-0.7-1.94-2.19V5.71h-1.3V4.71z\'/></g></svg>") left 5px no-repeat; }' +
  1222. '#toolbar li#show_preview { float:left; width:16px; height: 16px; margin: 4px 0 4px 4px; background:url("data:image/svg+xml;utf8,<svg version=\'1.1\' id=\'Layer_1\' xmlns=\'http://www.w3.org/2000/svg\' xmlns:xlink=\'http://www.w3.org/1999/xlink\' x=\'0px\' y=\'0px\' width=\'42px\' height=\'16px\' viewBox=\'0 0 42 16\' enable-background=\'new 0 0 42 16\' xml:space=\'preserve\'><g> <path fill=\'%23444444\' d=\'M0.08,7.02L5.94,3.9l0.43,0.78L1.18,7.42l5.19,2.74l-0.43,0.78L0.08,7.82V7.02z\'/> <path fill=\'%23444444\' d=\'M7.84,16.01H6.82L13.78,0h1.02L7.84,16.01z\'/> <path fill=\'%23444444\' d=\'M21.75,7.87l-5.86,3.12l-0.43-0.78l5.19-2.74l-5.19-2.74l0.43-0.78l5.86,3.12V7.87z\'/> <path fill=\'%23444444\' d=\'M30.98,2.65h-3.63V1.58h8.55v1.07h-3.63v9.65h-1.28V2.65z\'/> <path fill=\'%23444444\' d=\'M36.38,4.71h1.3l0.42-2h0.8v2h2.45v0.99h-2.45v4.63c0,0.74,0.27,1.15,0.96,1.15c0.43,0,1.09-0.21,1.39-0.35 l0.18,0.95c-0.42,0.26-1.18,0.45-1.81,0.45c-1.36,0-1.94-0.7-1.94-2.19V5.71h-1.3V4.71z\'/></g></svg>") -24px 5px no-repeat; }' +
  1223. '.edited #toolbar li#save_btn { background: url("data:image/svg+xml;utf8,<svg version=\'1.1\' id=\'Layer_1\' xmlns=\'http://www.w3.org/2000/svg\' xmlns:xlink=\'http://www.w3.org/1999/xlink\' x=\'0px\' y=\'0px\' width=\'16px\' height=\'16px\' viewBox=\'0 0 16 16\' enable-background=\'new 0 0 16 16\' xml:space=\'preserve\'><g> <path fill=\'%23DD2222\' d=\'M16,0v10.02h-1.33V1.33H1.33v8.69H0V0H16z\'/> <path fill=\'%23DD2222\' d=\'M8.47,16h-0.7l-3.08-3.08l0.94-0.94l1.83,1.83V4.28h1.33v9.53l1.81-1.82l0.94,0.93L8.47,16z\'/></g></svg>") 8px 4px no-repeat; position:relative; }' +
  1224. '#toolbar li#save_btn div { display:none; position:relative; top:-9px; left:-24px; color:#999; text-align:right; }' +
  1225. '#toolbar li#save_btn:hover div { display:block; }' +
  1226. '#toolbar li#save_btn span { width:6rem; padding:4px 6px; background: #EEE; float:right; display:block; border:solid 1px #999; position:relative; z-index:1; }' +
  1227. '#toolbar li#save_btn span:first-of-type { border-bottom-width:0px; }' +
  1228. '#toolbar li#save_btn span:hover { color:#444; }' +
  1229. // resize handle
  1230. '.split_view #text_editing_handle { width:9px; position:absolute; top:0; bottom:0; left:calc(50% - 4px); cursor:col-resize; z-index:11; }' +
  1231. '#text_editing_handle { z-index:-1; }' +
  1232. // source
  1233. '#content_source { margin:0; padding: 14px; width:100%; display:block; line-height:1.2; box-sizing:border-box; z-index:1; border:0; overflow-y:scroll; background:#EEE; resize:none; font-family:monospace; font-size:'+ parseFloat($settings.UI_font_size) + $settings.UI_font_size.replace(/\d*/,'') +'; }' +
  1234. '#content_source, #content_preview { position:absolute; top:32px; right:0; bottom:0; left:0; }' +
  1235. '#content_source:focus { outline:none; background:#FFF; box-shadow: inset 0 0 4px #888; }' +
  1236. // preview
  1237. '#content_preview { margin:0; padding: 14px; box-sizing:border-box; z-index:1; border:0; overflow-y:scroll; background:#FFF; font-size:'+ parseFloat($settings.UI_font_size) + $settings.UI_font_size.replace(/\d*/,'') +'; }' +
  1238. // split views
  1239. '.preview_text:not(.split_view) #content_source, .source_text:not(.split_view) #content_preview, li#save_btn div, .comment { display:none; }' +
  1240. '.split_view #content_preview { border-left:solid 1px #999; }' +
  1241. '.split_view #content_source {width:50%; }' +
  1242. '.split_view #content_preview {left:50%; }' +
  1243. // preview styles
  1244. '#content_preview pre { border:solid 1px #CCC; border-radius:3px; white-space:pre-wrap; word-break:break-word; font-size:'+ parseFloat($settings.UI_font_size) + $settings.UI_font_size.replace(/\d*/,'') +'; }' +
  1245. '#content_preview .no_list { list-style:none; }' +
  1246. '#content_preview > .no_list { padding:0; }' +
  1247. '#content_preview .text-align-center { text-align:center; }' +
  1248. '#content_preview th, #content_preview td { vertical-align:top; }' +
  1249. '#content_preview blockquote { margin-top:1em; margin-bottom:1em; color: #555; }' +
  1250. '#content_preview blockquote + blockquote { margin-top:0; }' +
  1251. '.markdown-body input[type="checkbox"] { margin-top:0.375em; margin-right:6px; float:left; }' +
  1252. 'h1 .uplink,h2 .uplink,h3 .uplink,h4 .uplink,h5 .uplink,h6 .uplink { margin:0; padding:0; display:inline-block; font-size:0.875em; cursor:pointer; transition: opacity 0.25s; opacity:0; }' +
  1253. 'h1:hover .uplink,h2:hover .uplink,h3:hover .uplink,h4:hover .uplink,h5:hover .uplink,h6:hover .uplink { transition: opacity 0.25s; opacity:0.5; }' +
  1254. '#content_preview table { font-size:inherit; }' +
  1255. '#content_preview table th { background-color:#EEE; }' +
  1256. '.markdown-body::before, .markdown-body::after { display:none !important; background:transparent; }' +
  1257. // edited warning
  1258. '#iframe_body #warnings p, #iframe_body #warnings button { display:none; }' +
  1259. '#iframe_body #warnings { width:22em; margin-left:-12.5em; padding:1rem; font-size:0.75rem; border-radius:0 0 3px 3px; display:none; position:absolute; top:0; left:50%; z-index:9999; background:#EEE; box-shadow: 0px 2px 12px 0 #111; }' +
  1260. '#iframe_body #warnings h3 { margin:0; font-weight:normal; }' +
  1261. '#iframe_body #warnings div { text-align:right; }' +
  1262. '#iframe_body #warnings button { margin-left:0.5em; }' +
  1263. '#iframe_body #warnings #warning_ignore_btn { margin-right:2em; }' +
  1264. '#iframe_body.has_warning #warnings, #iframe_body.has_warning #warnings.unsaved p#warning_unsaved, #iframe_body.has_warning #warnings.clear p#warning_clear { display:block; }' +
  1265. '#iframe_body.has_warning #warnings.clear #warning_clear_btn, #iframe_body.has_warning #warnings.clear #warning_cancel_btn, #iframe_body.has_warning #warnings.unloading p#warning_unsaved, #iframe_body.has_warning #warnings.unloading #warning_ignore_btn, #iframe_body.has_warning #warnings.unloading #warning_cancel_btn, #iframe_body.has_warning #warnings.unloading #warning_save_btn { display:inline-block; }' +
  1266. // disabled text editing
  1267. '#iframe_body.enable_text_editing #toolbar, #iframe_body.enable_text_editing #preview_text, #iframe_body.enable_text_editing #text_editing_handle { display:none; }' +
  1268. '#iframe_body.enable_text_editing #content_source.disabled { top:0; background:white; }'
  1269. ;
  1270. var $iframe_styles =
  1271. // background
  1272. '#iframe_body a.up { background:transparent; }' +
  1273. '#iframe_body :root, html, body { background-color:#BBB; }' +
  1274. '#iframe_body #thead, #tbody tr { background:rgba(221,221,221,0.5); }' +
  1275. '#iframe_body #tbody tr:nth-of-type(odd) { background:rgba(221,221,221,1); }' +
  1276. '#iframe_body #tbody tr:hover { background:#BBB; }' +
  1277. // border
  1278. ':root, html, #iframe_body { border:0 !important; }' +
  1279. 'html, #iframe_body { border-radius:0; }' +
  1280. '#iframe_body #dir_list { border-collapse:collapse; }' +
  1281. '#iframe_body #dir_list thead th { border-bottom:solid 1px #999; }' +
  1282. // box-sizing
  1283. '#iframe_body, iframe_body td.name, iframe_body td.details { box-sizing:border-box; }' +
  1284. // color
  1285. '#iframe_body a { color:#111111; }' +
  1286. '#iframe_body a:hover { color:#000000; }' +
  1287. '#iframe_body tr.ignore, #iframe_body tr.ignore a { color:grey; }' +
  1288. // display
  1289. '#iframe_body #dir_list tr::before, #iframe_body #dir_list td.name input, #iframe_body td.ext { display:none; }' +
  1290. '#iframe_body a { display:block; }' +
  1291. '#iframe_body #dir_list #tbody tr { display: grid; grid-gap:0; grid-template-columns: minmax(200px,100%) minmax(auto,5em) minmax(auto,1fr) minmax(auto,5em); }' +
  1292. '#iframe_body td.name { grid-column: 1; }' +
  1293. '#iframe_body td.size { grid-column: 2; }' +
  1294. '#iframe_body td.date { grid-column: 3; }' +
  1295. '#iframe_body td.kind { grid-column: 4; }' +
  1296. // float
  1297. '#iframe_body #dir_list a::before { float:left; }' +
  1298. // fonts
  1299. '#iframe_body { font-family:'+ $settings.UI_font +'; }' +
  1300. '#iframe_body { font-size:'+ parseFloat($settings.UI_font_size) * 0.875 + $settings.UI_font_size.replace(/\d*/,'') +'; }' +
  1301. '#iframe_body #dir_list, #iframe_body #thead { font-size: 1em; }' +
  1302. // height
  1303. '#iframe_body, #iframe_body #dir_list { height:100%; }' +
  1304. '#iframe_body #content_source { height:inherit; }' +
  1305. '#iframe_body #thead { height:2em; max-height:2em; }' +
  1306. // line-height
  1307. '#iframe_body #tbody tr { line-height:1.5; }' +
  1308. // margin
  1309. 'html, body, #iframe_body { margin:0; }' +
  1310. '#iframe_body .dir::before, #iframe_body .file > img { margin-inline-end: 6px; }' +
  1311. // outline
  1312. '#iframe_body #dir_list tr, #iframe_body #tbody tr:hover { outline:0; }' +
  1313. // overflow
  1314. '#iframe_body, #iframe_body #dir_list { overflow:hidden; }' +
  1315. '#iframe_body #dir_list #tbody { overflow:auto; }' +
  1316. // padding
  1317. 'html, :root, #iframe_body, body { padding:0; }' +
  1318. '#iframe_body #tbody tr td, #iframe_body #thead tr th { padding-top:3px; }' +
  1319. '#iframe_body #thead tr th { padding-right:0; }' +
  1320. '#iframe_body #tbody tr td { padding-right: 6px; }' +
  1321. '#iframe_body #tbody tr td, #iframe_body #thead tr th { padding-bottom:3px; }' +
  1322. '#iframe_body #tbody tr td.details.kind { padding-right: 1em; }' +
  1323. '#iframe_body td.details { padding-left: 6px; }' +
  1324. '#iframe_body #thead tr th, #tbody tr td.name { padding-left:1em; }' +
  1325. // position
  1326. '#iframe_body #dir_list { position:relative; }' +
  1327. '#iframe_body, #iframe_body #dir_list #tbody { position:absolute; right:0; bottom:0; left:0; }' +
  1328. // text-align
  1329. '#iframe_body th:not(:first-of-type), #iframe_body td.details { text-align:right; }' +
  1330. '#iframe_body th:first-of-type { text-align:left; }' +
  1331. // text-decoration
  1332. '#iframe_body a, #iframe_body a:hover, #iframe_body td:hover { text-decoration:none !important; }' +
  1333. // text-indent
  1334. '#iframe_body a.icon { text-indent:2px; }' +
  1335. // vertical-align
  1336. '#iframe_body td.details { vertical-align:top; }' +
  1337. // width
  1338. 'html, #iframe_body, #iframe_body #dir_list, #iframe_body #dir_list tr { width:100%; max-width:100%; min-width:100%; }' +
  1339. '#iframe_body #dir_list td:not(:first-child) { width:unset; }' +
  1340. // white-space
  1341. '#iframe_body td:not(.name) { white-space:pre; }'
  1342. ;
  1343.  
  1344. // ADD STYLES
  1345. const $font_styles = document.createElement('style');
  1346. const $font_grid_styles = document.createElement('style');
  1347.  
  1348. function addStyles(el) {
  1349. el.find('style, link[rel="stylesheet"], link[href$="css"]').remove(); // remove any existing stylesheets
  1350. el.append('<style>'+ $main_style_rules +'</style>');
  1351. el.append('<style>'+ $gecko_style_rules +'</style>');
  1352. el.append($font_styles); // empty until font is previewed
  1353. el.append($font_grid_styles); // empty until font grid is made
  1354. el.append('<style>'+ $text_editing_style_rules +'</style>');
  1355. el.append('<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/3.0.1/github-markdown.min.css"></link>');
  1356. }
  1357. // ***** END STYLES ***** //
  1358.  
  1359. // ***** BUILD MENUS ***** //
  1360. // Parent and Parents Menus
  1361. function updateQueryStr(str) {
  1362. str = str.replace(/([^\?]*)selected=[^&]*(.*)$/m,'$1$2') // delete current selected query, if any
  1363. .replace(/([^\?]*)history=(\d+)\+*([^&]*)(&*)(.*)/m,'$1$4$5&selected=$2&history=$3').replace(/&{2,}/g,'&').replace(/\?&/m,'\?'); // format query with selected and history at end
  1364. if ( str.endsWith('&history=') ) { str = str.replace(/(.+)&history=$/m,'$1'); } // if no history, delete query
  1365. return str;
  1366. }
  1367. function createParentLinks() {
  1368. let $links = [];
  1369. let $protocol = window.location.protocol;
  1370. let $href = decodeURIComponentSafe(window.location.href);
  1371. let str = decodeURIComponentSafe(window.location.search);
  1372. let $linkPieces = $href.split('/');
  1373. $linkPieces = $linkPieces.slice(2,-2); // remove beginning and ending empty elements and current directory
  1374. while ( $linkPieces.length > 0 ) { // while there are link pieces...
  1375. str = updateQueryStr(str); // update selected and history
  1376. let link = $protocol +'//'+ $linkPieces.join('/') +'/'+ str; // assemble link
  1377. $links.push(link); // add to link array
  1378. $linkPieces.pop(); // remove last link piece and repeat...
  1379. }
  1380. return $links;
  1381. }
  1382. function createParentLinkItems() {
  1383. let $parent_link_menu_items = [];
  1384. let $links = createParentLinks();
  1385. $parent_dir_menu.find('a').attr( 'href', $links[0] ); // set parent link
  1386. for ( let i = 0; i < $links.length; i++ ) {
  1387. let menu_item = '<li><a href="'+ $links[i] +'">' + $links[i].slice(0,$links[i].lastIndexOf('?') - 1) + '/</a></li>';
  1388. $parent_link_menu_items.push(menu_item);
  1389. }
  1390. return $parent_link_menu_items; // return parents link items
  1391. }
  1392. function updateParentLinks() { $parents_dir_menu.siblings('ul').empty().append( createParentLinkItems() ); }
  1393.  
  1394. // MENUS: User Shortcuts
  1395. function shortcutMenuItems() {
  1396. const $shortcuts = $settings.shortcuts;
  1397. let menu_items = [];
  1398. let $links_arr = [];
  1399. let $links_arr_str = '';
  1400. let $links;
  1401. if ( $shortcuts.length > 0 ) {
  1402. for ( let i = 0; i < $shortcuts.length; i+=1 ) {
  1403. $links = $shortcuts[i].links;
  1404. // make array of links
  1405. for ( let j = 0; j < $links.length; j+=1 ) {
  1406. $links_arr[j] = '<li><a href="'+ $links[j].link +'">' + $links[j].link_name + '</a></li>';
  1407. if ( !$links[j].link.endsWith('/') ) {
  1408. $links[j].link = $links[j].link.slice(0,$links[j].link.lastIndexOf('/') + 1) + '?file=' + $links[j].link.slice($links[j].link.lastIndexOf('/') + 1) ;
  1409. }
  1410. $links_arr[j] = '<li><a href="'+ $links[j].link +'">' + $links[j].link_name + '</a></li>';
  1411. }
  1412. $links_arr_str = $links_arr.join('');
  1413. menu_items[i] = '<li class="has_submenu"><a>'+ $shortcuts[i].menu_title +'</a><ul>'+ $links_arr_str +'</ul></li>';
  1414. }
  1415. menu_items = menu_items.join('');
  1416. }
  1417. return menu_items;
  1418. }
  1419.  
  1420. // MENUS: Other menu items
  1421. const $sort_by = $('<li class="has_submenu rule" id="sort_by"><span>Sort by&hellip;</span><ul id="sort_menu"><li id="name"><span>Name</span></li><li id="size"><span>Size</span></li><li id="date"><span>Date</span></li><li id="kind"><span>Kind</span></li><li id="ext"><span>Extension</span></li><li id="default"><span>Default</span></li></ul>');
  1422. const $autoload_media = $('<li class="toggle_UI_pref rule" id="autoload_media"><span id="autoload_media_menu">Autoload Media</span></li>');
  1423. const $theme = $('<li id="theme"><div><span class="toggle_UI_pref" id="theme_dark">Dark Theme</span><span class="toggle_UI_pref" id="theme_light">Light Theme</span></div></li>');
  1424. const $alternate_background = $('<li class="toggle_UI_pref" id="alternate_background"><span>Alternate Backgrounds</span></li>');
  1425. const $show_numbers = $('<li class="toggle_UI_pref rule" id="show_numbers"><span>Show Numbers</span></li>');
  1426. const $text_editing = $('<li class="has_submenu rule" id="text_editing"><span>Text Editing</span><ul id="text_editing_menu"><li id="text_editor_menu_item" class="rule"><span id="text_editor">Toggle Text Editor</span></li><li id="split_view" class="toggle_UI_pref rule"><span id="toggle_split_view">Split View</span></li><li id="preview_text_menu_item"><span class="toggle_UI_pref" id="source_text">Source Text</span><span class="toggle_UI_pref rule" id="preview_text">Preview Text</span></li><li><span class="toggle_UI_pref" id="enable_text_editing">Disable Text Editing</span></li></ul>');
  1427. const $default_settings = $('<li><a href="#" id="default_settings" title="Delete URL query string and reload page.">Default User Settings</a></li>');
  1428. const $export_settings = $('<li class="rule"><a href="#" id="export_settings" title="Export user settings to text file.">Export User Settings</a></li>');
  1429. const $contact_link = $('<li><a id="contact" href="mailto:mshroud@vivaldi.net">Contact</a></li>');
  1430. const $donate_link = $('<li><a id="donate" href="https://paypal.me/mschrauzer" target="_blank">Donate</a></li>');
  1431.  
  1432. function assembleMenus() { // called by buildUI();
  1433. $parents_dir_menu.siblings('ul').empty().append( createParentLinkItems() );
  1434. $shortcuts_menu.siblings('ul').append( shortcutMenuItems(), $sort_by, $theme, $alternate_background, $show_numbers, $autoload_media, $text_editing, $default_settings, $export_settings, $contact_link, $donate_link );
  1435. }
  1436. // ***** END BUILD MENUS ***** //
  1437. // ***** INDEX PREP ***** //
  1438. function getIndexType(el) {
  1439. if ( $(el).find('> pre').length > 0 ) {
  1440. return 'pre';
  1441. } else if ( $(el).find('> ul').length > 0 ) {
  1442. return 'list';
  1443. } else if ( $(el).find('> table').length > 0 ) {
  1444. if ( $protocol !== 'file:' ) { return 'table'; }
  1445. if ( $protocol === 'file:' ) { return 'default'; } // local directories
  1446. } else {
  1447. return 'error';
  1448. }
  1449. }
  1450. // Index Prep: Get Index Items
  1451. function getIndexItems(el,type) {
  1452. let els;
  1453. switch(type) {
  1454. case 'list':
  1455. els = el.find('> ul:last-of-type').children().length !== 0 ? el.find('> ul:last-of-type') : el.find('> ul:nth-last-of-type(2)');
  1456. break;
  1457. case 'pre':
  1458. els = el.find('> pre').html();
  1459. break;
  1460. case 'table':
  1461. els = (el.find('> table:last-of-type > tbody').length > 0 ? el.find('> table:last-of-type > tbody') : el.find('> table, > div > table > tbody') );
  1462. break;
  1463. case 'default':
  1464. els = el.find('> table').find('> tbody');
  1465. break;
  1466. case 'error':
  1467. els = $('body').html();
  1468. break;
  1469. }
  1470. return els;
  1471. }
  1472. // Index Prep: Add body class based on type
  1473. function prepBody(type) {
  1474. switch(type) {
  1475. case 'list':
  1476. $('body#top').addClass('is_converted_list');
  1477. break;
  1478. case 'pre':
  1479. $('body#top').addClass('is_converted_pre');
  1480. break;
  1481. case 'table':
  1482. $('body#top').addClass('is_converted_table');
  1483. break;
  1484. case 'default':
  1485. $('body#top').addClass('is_default');
  1486. break;
  1487. case 'error':
  1488. $('body#top').addClass('is_error');
  1489. break;
  1490. }
  1491. }
  1492. // Index Prep: convert rows and return array of rows, with link, size, date-modified
  1493. function convertIndexItems(type,items) {
  1494. let converted = [];
  1495. switch(type) {
  1496. case 'list':
  1497. converted = convertListType(items);
  1498. break;
  1499. case 'pre':
  1500. converted = convertPreType(items);
  1501. break;
  1502. case 'table':
  1503. case 'default': // local chrome indexes
  1504. converted = convertTableType(type,items);
  1505. break;
  1506. case 'error':
  1507. converted = convertErrorType(items);
  1508. break;
  1509. }
  1510. return converted;
  1511. }
  1512. // Index Prep: convert list type function
  1513. function convertListType(items) {
  1514. let preppedIndex = [];
  1515. const rows = Array.from(items.find('li'));
  1516. for ( let i = 0; i < rows.length; i++ ) {
  1517. let row = rows[i].innerHTML;
  1518. row = prepRow(row).split(' ');
  1519. if ( row.length > 0 ) { preppedIndex.push(row); }
  1520. }
  1521. return preppedIndex;
  1522. }
  1523. // Index Prep: convert pre type function
  1524. function convertPreType(items) {
  1525. let preppedIndex = [];
  1526. const rows = items.split('\n');
  1527. const spaces = /\s{2,}/; // assumes pre type only uses spaces between "columns"
  1528. for ( let i = 0; i < rows.length; i++ ) {
  1529. let row = prepRow(rows[i]);
  1530. let preppedRow = [];
  1531. let cells = row.split(spaces);
  1532. for ( let i = 0; i < cells.length; i++ ) {
  1533. if ( cells[i].length > 0 ) { preppedRow.push(cells[i]); }
  1534. }
  1535. if ( preppedRow.length > 0 ) { preppedIndex.push(preppedRow); }
  1536. }
  1537. return preppedIndex;
  1538. }
  1539. // Index Prep: convert table type function
  1540. function convertTableType(type,items) { // for local chrome indexes and server-generated table-type indexes
  1541. let preppedIndex = [];
  1542. const rows = Array.from(items.find('> tr'));
  1543. for ( let i = 0; i < rows.length; i++ ) {
  1544. let preppedRow = [];
  1545. let cellContents = '';
  1546. const cells = Array.from( $(rows[i]).find('td') );
  1547. for ( let i = 0; i < cells.length; i++ ) {
  1548. cellContents = cells[i].innerHTML.trim();
  1549. if ( cellContents.indexOf('table') > 0 ) { cellContents = '&nbsp;'; } // for Gecko-style local indexes, which uses nested tables for the item name
  1550. if ( type === 'default' && cellContents === '' ) { cellContents = '-'; } // chrome doesn't report local dir sizes
  1551. cellContents = prepRow(cellContents);
  1552. if ( cellContents.length > 0 && cellContents !== '&nbsp;' ) { preppedRow.push(cellContents); } // make prepped row
  1553. }
  1554. if ( preppedRow.length > 2 ) { preppedIndex.push(preppedRow); } // preppedRow.length > 2 in order to omit parent directory row
  1555. }
  1556. return preppedIndex;
  1557. }
  1558. // Index Prep: convert error pages (page not found, etc.)
  1559. function convertErrorType(items) {
  1560. items = items.replace(/ style="[^"]*?"/g,'').replace(/<hr>/g,'');
  1561. items = '<div id="error_message"><div id="error_message_icon"></div>'+ items +'</div>';
  1562. return items;
  1563. }
  1564. // Index Prep: Remove images, empty cells, hrs, and extract href from link
  1565. function prepRow(str) {
  1566. str = str.replace(/<img[^>]+?>\s*/g,'') // remove images
  1567. .replace(/<a[^>]*?>[^<]*?<\/a>\s*<a[^>]*?>[^<]*?<\/a>/,'') // some servers add an extra link for icons
  1568. .replace(/<a[^>]*?>\s*<\/a>/,'') // some servers add an extra link for icons
  1569. .replace(/<a.*?href="([^?"]+?)"[\s\S]+?<\/a>/g,'$1') // extract link
  1570. .replace(/<hr>/g,'') // remove hr
  1571. // .replace(/^[\s\/-]+$/m,'') // remove empty headers
  1572. .replace(/>[&nbsp;|\s*]</g,'><'); // remove empty elements (typically "description" or dir size)
  1573. return str;
  1574. }
  1575. // Index Prep: Build new Index from prepped rows
  1576. function buildNewIndex(preppedIndex) {
  1577. let newIndexItems = [];
  1578. for ( let i = 0; i < preppedIndex.length; i++ ) {
  1579. // Get row attrs and text
  1580. var rowLink = preppedIndex[i][0].replace(/&amp;/g,'&');//.replace(//,''); // decode some reserved characters
  1581. const rowName = getItemName(rowLink).replace(/^\//m,'').replace(/([-_——])/g,'$1<wbr>'); // display name, with word breaks added after unbreakable chars
  1582. const rowSortName = getItemName(rowLink).replace(/^\//m,'').replace('/','').toLocaleLowerCase();
  1583. const sizesAndDates = getItemSizeAndDate(preppedIndex[i]);
  1584. const rowSize = sizesAndDates[0];
  1585. const rowSortSize = sizesAndDates[1];
  1586. const rowDate = sizesAndDates[2];
  1587. const rowSortDate = sizesAndDates[3];
  1588. const rowExt = getItemExt(rowLink);
  1589. const rowSortKind = getItemKind(rowExt);
  1590. const rowKind = rowSortKind.slice(0,1).toUpperCase() + rowSortKind.slice(1);
  1591. const rowClasses = getItemClasses(rowName,rowSortKind,rowExt);
  1592. // Assemble row elements
  1593. let newRow = $('<tr></tr>').attr('id','rowid-'+i).addClass(rowClasses).attr('data-kind',rowSortKind).attr('data-ext',rowExt);
  1594. const checkbox = ( rowClasses.indexOf('media') > 0 ? $('<input type="checkbox" tabindex="-1" checked="true" />') : '' );
  1595. const nameSpan = $('<span></span>').append(checkbox, rowName);
  1596. const cellLink = $('<a></a>').addClass('icon').attr('href',rowLink).append(nameSpan);
  1597. const cellName = $('<td></td>').addClass('name').attr('data-name',rowSortName).append(cellLink);
  1598. const cellSize = $('<td></td>').addClass('size details').attr('data-size',rowSortSize).append(rowSize);
  1599. const cellDate = $('<td></td>').addClass('date details').attr('data-date',rowSortDate).append(rowDate);
  1600. const cellKind = $('<td></td>').addClass('kind details').attr('data-kind',rowSortKind).append(rowKind);
  1601. const cellExt = $('<td></td>').addClass('ext details').attr('data-ext',rowExt);
  1602. // Assemble row
  1603. newRow.append(cellName, cellSize, cellDate, cellKind, cellExt);
  1604. newIndexItems.push(newRow[0]);
  1605. }
  1606. let sortedIndexItems = sortDirList($(newIndexItems), 'sort_by_'+ getQuery('sort_by'), 1); // initial sort
  1607. return sortedIndexItems;
  1608. }
  1609. // Index Prep: get row name
  1610. function getItemName(link) {
  1611. let name = decodeURIComponentSafe(link);
  1612. if ( name.split('/').length > 2 ) { // get name only if x = full path
  1613. let arr = name.split('/');
  1614. if ( name.startsWith('/') && name.endsWith('/') ) { // dirs
  1615. name = arr[arr.length - 2] + '/';
  1616. } else {
  1617. name = arr[arr.length - 1]; // files
  1618. }
  1619. }
  1620. return name;
  1621. }
  1622. // Index Prep: get row classes
  1623. function getItemClasses(name,kind,ext) {
  1624. let itemClasses = [];
  1625. itemClasses.push(kind);
  1626. if ( ext !== 'dir' && ext !== 'app' ) {
  1627. itemClasses.push('file');
  1628. }
  1629. if ( name.indexOf('.') === 0 ) {
  1630. itemClasses.push('invisible');
  1631. }
  1632. if ( !JSON.stringify($row_types).match( ext ) ) { // else classify as "other" if extension is not in $row_types.
  1633. itemClasses.push('other'); //itemType = 'Other'; itemKind = 'other';
  1634. } else if ( kind === '' ) {
  1635. // itemClasses.push('code'); //itemType = 'Code'; itemKind = 'code';
  1636. } else {
  1637. itemClasses.push(ext);
  1638. }
  1639. if ( $row_settings.ignore.includes( ext ) ) {
  1640. itemClasses.push('ignore');
  1641. }
  1642. if ( $row_settings.exclude.includes( ext ) ) {
  1643. itemClasses.push('exclude');
  1644. }
  1645. if ( kind === 'audio' || kind === 'video' ) {
  1646. itemClasses.push('media');
  1647. }
  1648. itemClasses = Array.from(new Set(itemClasses)); // remove dupe classes
  1649. return itemClasses.join(' ');
  1650. }
  1651. // Index Prep: get formatted row size and date
  1652. function getItemSizeAndDate(row) {
  1653. let sizesAndDates = []; let rowSize; let rowSortSize; let rowDate; let rowSortDate;
  1654. if ( row.length > 1 && row[1] !== undefined && row[2] !== undefined ) { // in case server doesn't provide size or date
  1655. rowSize = ( row[1].length < row[2].length ? row[1] : row[2] ); // determine which cell is date and which is size, assuming date length is always longer than size length
  1656. rowSize = ( rowSize === '-' || rowSize === '' ? '&mdash;' : rowSize.toUpperCase() );
  1657. rowSortSize = getItemSortSize(rowSize);
  1658. rowDate = ( row[1].length < row[2].length ? row[2] : row[1] );
  1659. rowSortDate = getItemDate(rowDate).replace(/-|:|\s*/g,'');
  1660. } else {
  1661. if ( row[1] === undefined ) {
  1662. rowSize = '&mdash;'; rowSortSize = '0';
  1663. }
  1664. if ( row[2] === undefined ) {
  1665. rowDate = '&mdash;'; rowSortDate = '0';
  1666. }
  1667. }
  1668. sizesAndDates.push(rowSize,rowSortSize,rowDate,rowSortDate);
  1669. return sizesAndDates;
  1670. }
  1671. // Index Prep: get row size for sorting
  1672. function getItemSortSize(val) {
  1673. const size = val.replace('&mdash;','0').replace(/[A-z\s]+/,'').trim(); // = any non-alpha chars, i.e. numbers
  1674. const unit = val.replace('&mdash;','B').replace(/[\d\\.]+/g,'').trim(); // = any non-numeric chars
  1675. const factor = { '':1, B:1, K:1000, KB:1000, M:1000000, MB:1000000, G:1000000000, GB:1000000000, T:1000000000000, TB:1000000000000 }; // unit to file size
  1676. const sortSize = size * factor[unit]; // convert byte size to multiplication factor
  1677. return sortSize;
  1678. }
  1679. function processDate(match,p1,p2,p3) { //date formats: 2017-10-09 13:12 || 2015-07-25T02:02:57.000Z || 12-Mon-2017 21:11
  1680. const mo = 'JanFebMarAprMayJunJulAugSepOctNovDec'.indexOf(p2)/3 + 1; // e.g., convert month into number, or use number
  1681. return p3 +'-'+ mo +'-'+ p1;
  1682. }
  1683. // Index Prep: get row date
  1684. function getItemDate(val) {
  1685. const sortDate = val.replace(/^(\d{2})-(\w{3})-(\d{4})/m, processDate);
  1686. return sortDate;
  1687. }
  1688. // Index Prep: get row kind
  1689. function getItemKind(ext) {
  1690. let kind = '';
  1691. if ( ext === 'dir' || ext === 'app' ) {
  1692. kind = ext;
  1693. } else {
  1694. for ( let types in $row_types ) {
  1695. if ( $row_types[types].includes( ext ) ) {
  1696. kind = types;
  1697. return kind;
  1698. }
  1699. }
  1700. }
  1701. if ( kind === '' ) { kind = 'other'; }
  1702. return kind;
  1703. }
  1704. // Index Prep: get row extension
  1705. function getItemExt(link) {
  1706. let ext = '';
  1707. if ( ext.endsWith('app/') || ext.endsWith('exe') ) {
  1708. ext = 'app';
  1709. } else if ( link.endsWith('/') ) {
  1710. ext = 'dir';
  1711. } else if ( link.indexOf('.') < 0 ) { // if no '.' in link, ...
  1712. ext = link.slice(link.lastIndexOf('/') + 1).toLowerCase();
  1713. } else { // find the last . and get the remaining characters
  1714. ext = link.slice(link.lastIndexOf('.') + 1).toLowerCase();
  1715. }
  1716. return ext;
  1717. }
  1718. // END INDEX PREP
  1719. // ***** MAKE NEW INDEX ***** //
  1720. function makeNewIndex(el) {
  1721. const type = getIndexType( el );
  1722. prepBody(type);
  1723. const items = getIndexItems( el, type );
  1724. const convertedIndex = convertIndexItems( type, items ); // = array of rows ["link","date","size"]
  1725. if ( type === 'error' ) {
  1726. return convertedIndex;
  1727. } else {
  1728. let newIndex = buildNewIndex( convertedIndex );
  1729. return newIndex;
  1730. }
  1731. }
  1732. function appendNewIndex(body_top) { // setUpUI();
  1733. $dir_list_body.append( makeNewIndex(body_top) );
  1734. }
  1735. // get and set index stats
  1736. function getIndexStats(el) {
  1737. const total = el.length;
  1738. const dirs = el.filter('.dir').length;
  1739. const files = el.filter('.file').length;
  1740. const stats = total +' items: '+ dirs +' directories, '+ files +' files';
  1741. return stats;
  1742. }
  1743. // ***** END DIR_LIST SETUP ***** //
  1744.  
  1745. // ***** UI SETUP ***** //
  1746. // Build UI: Append all assembled elements to $body
  1747. function setUpBody() {
  1748. if ( window.self === window.top ) { // if it's an iframe...
  1749. $('head').prepend('<meta charset="utf-8">');
  1750. $('body').attr('id','top').attr('lang','en').find('script').remove();
  1751. } else {
  1752. $('body').attr('id','iframe_body');
  1753. }
  1754. }
  1755. function buildUI() {
  1756. setUpBody();
  1757. addStyles( $('body#top').prev('head') );
  1758. assembleUIElements();
  1759. assembleMenus();
  1760. appendNewIndex($('body#top'));
  1761. $main_content.find('tr').append( $sidebar_wrapper, $content_pane );
  1762. $index_stats.text(getIndexStats($dir_list.find('#tbody tr')));
  1763. $('body#top').empty().append($main_content);
  1764. }
  1765. buildUI();
  1766.  
  1767. const $body = $('body#top');
  1768. const $iframe_body = $('body#iframe_body');
  1769. const $iFrame_head = $iframe_body.prev('head');
  1770. const $dir_list_row = $dir_list_body.find('> tr');
  1771. const $audio_files = $dir_list_body.find('.audio');
  1772. const $font_files = $dir_list_body.find('.font');
  1773. const $image_files = $dir_list_body.find('.image');
  1774. const $media_files = $dir_list_body.find('.media');
  1775. const $video_files = $dir_list_body.find('.video');
  1776. function $selected_file() { return $dir_list_body.find('.selected'); }
  1777. function $playing_file() { return $dir_list_body.find('.playing'); }
  1778.  
  1779. // UI Setup: build UI and add body classes and other initial settings
  1780. function setupUIprefs() {
  1781. for ( let key in $settings ) {
  1782. if ( getQuery(key) === 'true' ) {
  1783. $body.addClass(key);
  1784. } else { // non-boolean settings and others
  1785. if ( key === 'theme' ) { $body.addClass( 'theme_'+ getQuery('theme') ); }
  1786. if ( key === 'sort_by' ) {
  1787. $body.addClass( 'sort_by_'+ getQuery(key) );
  1788. $('#theader').find('th[id="sort_by_'+ getQuery(key) +'"]').addClass('up');
  1789. }
  1790. if ( key === 'default_text_view' ) {
  1791. if ( getQuery(key) === 'source_text' ) { $body.addClass('source_text'); } else { $body.addClass('preview_text'); }
  1792. }
  1793. if ( getQuery('toggle_sidebar') === 'true' ) { $body.addClass( 'has_hidden_sidebar' ); }
  1794. }
  1795. }
  1796. if ( navigator.userAgent.indexOf('Chrome') > 0 ) { $body.addClass('is_chrome'); }
  1797. if ( navigator.userAgent.indexOf('Firefox') > 0 ) { $body.addClass('is_gecko'); }
  1798. if ( $audio_files.length > 0 ) { $body.add($dir_list).addClass('has_audio has_media'); }
  1799. if ( $font_files.length > 0 ) { $body.addClass('has_fonts'); }
  1800. if ( $image_files.length > 0 ) { $body.addClass('has_images'); }
  1801. if ( $video_files.length > 0 ) { $body.add($dir_list).addClass('has_video has_media'); }
  1802. // UI Setup: show invisibles
  1803. if ( navigator.platform.indexOf('Win') > -1 || $location.indexOf('file:') < 0 ) {
  1804. $inv_checkbox.hide();
  1805. } else if ( $body.hasClass('show_invisibles') ) {
  1806. $inv_checkbox.find('input').attr('checked','checked');
  1807. }
  1808. }
  1809.  
  1810. function setUpUI() {
  1811. setupUIprefs();
  1812. setUpIframeUI( getQuery('enable_text_editing') );
  1813. initMedia();
  1814. autoSelectFile();
  1815. autoLoadCoverArt();
  1816. setContentTitle();
  1817. setContentHeight();
  1818. }
  1819. setUpUI();
  1820.  
  1821. // SET UI TO DEFAULT SETTINGS: remove queries;
  1822. function defaultSettings() {
  1823. let $location = window.location.href;
  1824. $location = $location.slice(0,$location.lastIndexOf('?'));
  1825. window.location.assign($location);
  1826. }
  1827. $default_settings.on('click', function() {
  1828. if (window.confirm( 'Are you sure you want to reset all your temporary UI settings to the defaults in your user_settings?\nThis action cannot be undone.' ) ) {
  1829. defaultSettings();
  1830. }
  1831. });
  1832. // EXPORT SETTINGS
  1833. function saveSettings(filename, data) {
  1834. const blob = new Blob([data], {type: 'text/html'});
  1835. const elem = window.document.createElement('a');
  1836. elem.href = window.URL.createObjectURL(blob);
  1837. elem.download = filename;
  1838. document.body.appendChild(elem);
  1839. elem.click();
  1840. document.body.removeChild(elem);
  1841. URL.revokeObjectURL(blob);
  1842. }
  1843. $export_settings.on('click','a',function(e) {
  1844. e.preventDefault();
  1845. const $settings_string = ( JSON.stringify($settings,null,'\t'));
  1846. saveSettings('settings.txt',$settings_string);
  1847. });
  1848.  
  1849. // Click Menu Link (with warning)
  1850. function setLocation(link) { window.location = link; }
  1851. $('#parent_dir_menu,#parents_dir_menu + .menu,#shortcuts').on('click','a',function(e) {
  1852. e.preventDefault();
  1853. if ( $(this).attr('href').indexOf('file://') > -1 && $protocol !== 'file:' ) {
  1854. $body.addClass('has_warning').find('#warnings').addClass('local');
  1855. } else {
  1856. showWarning( 'setLocation', thisLink($(this)) );
  1857. }
  1858. });
  1859. // Show Menus
  1860. function showMenus(el) {
  1861. let $position = $(el).position();
  1862. $(el).find('> ul').css({'top':$position.top + $(el).innerHeight() + 'px'}).toggle().parent('td').siblings('td').find('.menu').hide();
  1863. }
  1864. $parents_dir_menu.add($shortcuts_menu).parent('td').on('click',function(e) {
  1865. e.stopPropagation();
  1866. showMenus(this);
  1867. });
  1868. // Hide Menus
  1869. $(document).on('click', function() { $('.menu').hide(); });
  1870.  
  1871. // Toggle UI Preferences
  1872. function toggleUIpref(prefID) {
  1873. let prefClass = prefID;
  1874. if ( prefID === 'split_view' ) { sendMessage('iframe','split_view'); }
  1875. if ( prefID.startsWith('sort_by') ) { $body.removeClass('sort_by_default sort_by_name sort_by_size sort_by_date sort_by_kind sort_by_ext'); }
  1876. if ( prefID.startsWith('theme') ) { prefClass = 'theme_dark theme_light'; }
  1877. if ( prefID.endsWith('text') && !$body.hasClass(prefID) ) {
  1878. sendMessage('iframe','default_text_view');
  1879. $body.toggleClass('preview_text source_text');
  1880. }
  1881. toggleQuery(prefID);
  1882. $body.toggleClass(prefClass);
  1883. setContentHeight();
  1884. if ( prefID === 'enable_text_editing' ) { $('.selected.text, .selected.markdown').click(); }
  1885. $('#shortcuts').hide(); // don't hide menus after click?
  1886. }
  1887. // Click Toggle UI Pref elements
  1888. $('.toggle_UI_pref').on('click',function(e) {
  1889. if ( !$(this).is('input') ) {
  1890. e.preventDefault(); // allow checkboxes to be checked
  1891. }
  1892. toggleUIpref( $(this).attr('id') );
  1893. });
  1894.  
  1895. // Toggle Sidebar
  1896. function toggleSidebar() {
  1897. $body.toggleClass('has_hidden_sidebar');
  1898. if ( $body.hasClass('has_hidden_sidebar') ) { setQuery('toggle_sidebar','true'); } else { removeQuery('toggle_sidebar'); }
  1899. setContentHeight();
  1900. scrollThis('tbody','selected',true); // true = instant scroll
  1901. }
  1902. $toggle_sidebar.on('click', function() {
  1903. toggleSidebar();
  1904. });
  1905.  
  1906. // RESIZE Sidebar/Content Pane
  1907. function resizeSidebar(f) {
  1908. f.stopPropagation();
  1909. const $startX = f.pageX;
  1910. let $window_width = window.innerWidth;
  1911. let $sidebar_width = $sidebar_wrapper.width();
  1912. $('#overlay').css({'display':'block','z-index':'1'});
  1913. $('#handle').css({'z-index':'9999'});
  1914. $body.css({'-moz-user-select':'none','user-select':'none'});
  1915.  
  1916. $(document).on('mousemove',function(e) {
  1917. e.stopPropagation();
  1918. e.preventDefault();
  1919. const $deltaX = e.pageX - $startX;
  1920. if ( e.pageX > 230 && e.pageX < $window_width - 200 ) {
  1921. $sidebar_wrapper.css({'width':$sidebar_width + $deltaX + 'px'});
  1922. $content_pane.css({'width':($window_width - $sidebar_width) - $deltaX + 'px'});
  1923. }
  1924. setContentHeight();
  1925. });
  1926. $(document).on('mouseup',function() {
  1927. $('#overlay').css({'display':'none','z-index':'unset'});
  1928. $('#handle').css({'z-index':'unset'});
  1929. $body.css({'-moz-user-select':'unset','user-select':'unset'});
  1930. $(document).off('mousemove');
  1931. $sidebar_width = $sidebar_wrapper.width();
  1932. setQuery('width',$sidebar_width);
  1933. });
  1934. }
  1935. $handle.on('mousedown', function(f) {
  1936. f.stopPropagation();
  1937. resizeSidebar(f);
  1938. });
  1939.  
  1940. // ***** BASIC UI FUNCTIONS ***** //
  1941. // Get dir_list item row
  1942. function thisRow(x) {
  1943. return $(x).closest('#dir_list > tbody > tr').length > 0 ? $(x).closest('#dir_list > tbody > tr') : $(x).closest('#dir_list > li');
  1944. }
  1945. function thisID(x) {
  1946. return thisRow(x).attr('id');
  1947. }
  1948. // Get row link
  1949. function thisLink(x) {
  1950. return $(x).find('a').length > 0 ? $(x).find('a').attr('href') : $(x).attr('href');
  1951. }
  1952. // Get row name
  1953. function thisText(x) {
  1954. return $(x).find('a span').length > 0 ? decodeURIComponentSafe( $(x).find('a span').text().toLocaleLowerCase() ) : decodeURIComponentSafe( $(x).text().toLocaleLowerCase() );
  1955. }
  1956. // get row text
  1957. function thisExt(x) {
  1958. let $this_name = thisText(x);
  1959. return $this_name.endsWith('app/') ? 'app' : $this_name.endsWith('/') ? '/' : $this_name.lastIndexOf('.') === -1 ? undefined : $this_name.toLocaleLowerCase().slice( $this_name.lastIndexOf('.') + 1 );
  1960. }
  1961. function getElById(id) {
  1962. return $(document.getElementById(id) );
  1963. }
  1964.  
  1965. // SET CONTENT HEIGHT
  1966. function setContentHeight() {
  1967. // accommodate multi-line title names in preview pane
  1968. if ( $title.outerWidth() > ( $('#content_title').innerWidth() - 2 * $('#title_buttons_left').outerWidth() ) ) {
  1969. $title.css({'margin-top':'2em'});
  1970. } else {
  1971. $title.css({'margin-top':'0'});
  1972. }
  1973. let $window_height = window.innerHeight;
  1974. let $content_header_height = $content_header.outerHeight();
  1975.  
  1976. $sidebar.add($main_content).add($content_pane).css({'height':$window_height });
  1977. $dir_list.css({'height':$window_height - $('#sidebar_header').outerHeight(), 'max-height':$window_height - $('#sidebar_header').outerHeight() });
  1978. $dir_list_body.css({'top': $dir_list_head.outerHeight(),'bottom': $dir_list.find('tfoot').outerHeight(),'height': $dir_list.innerHeight() - $dir_list_head.outerHeight() - $dir_list.find('tfoot').outerHeight(),'max-height': $dir_list.innerHeight() - $dir_list_head.outerHeight() - $dir_list.find('tfoot').outerHeight() });
  1979.  
  1980. $prev_track.add($next_track).add($close_audio).css({'height':$('#audio').height() }); // set height of audio controls
  1981. $content_container.css({'top':$content_header_height +'px' });
  1982. }
  1983. window.addEventListener('resize', setContentHeight );
  1984.  
  1985. // SET CONTENT TITLE
  1986. function setContentTitle() {
  1987. let $title_text = '';
  1988. if ( $playing_file().hasClass('audio') ) { // set audio player title
  1989. $content_audio_title.find('td').empty().text( $playing_file().find('td.name a').text() );
  1990. }
  1991. if ( $content_pane.hasClass('has_grid') ) { // set main title for other content
  1992. $title_text = $('#parents_dir_menu').find('> div').html().split('<wbr>').reverse()[1];
  1993. } else if ( $body.hasClass('has_text') ) {
  1994. $title_text = 'Text Editor';
  1995. } else if ( $selected_file().hasClass('audio') ) {
  1996. return;
  1997. } else if ( !$selected_file().hasClass('audio') || $content_pane.hasClass('has_hidden_text') ) {
  1998. $title_text = $selected_file().not('.audio').find('td.name a span').text(); // Assemble title
  1999. }
  2000. if ( $content_pane.hasClass('has_image') ) {
  2001. setDimensions($('.selected.image'));
  2002. } else {
  2003. $title.attr('data-after',''); // remove image dimensions
  2004. }
  2005. $title.empty().text($title_text);
  2006. if ( $title.outerWidth() > ( $('#content_title').innerWidth() - 2 * $('#title_buttons_left').outerWidth() ) ) { $title.css({'margin-top':'2em'}); } else { $title.css({'margin-top':'0'}); }
  2007. }
  2008. // Get Image Dimensions
  2009. function getDimensions(link, callback) {
  2010. let img = new Image();
  2011. img.src = link;
  2012. img.onload = function() { callback( this.width, this.height ); };
  2013. }
  2014. function setDimensions(row) {
  2015. getDimensions( thisLink(row), function( width, height ) {
  2016. $title.attr('data-after',' (' + width + 'px × ' + height + 'px)');
  2017. });
  2018. }
  2019. // Scroll Selected Items
  2020. function scrollThis(elID,className,bool) {
  2021. let $behavior = 'smooth';
  2022. if ( bool !== undefined ) { $behavior = 'instant'; }
  2023. let $block = ( navigator.userAgent.indexOf('Firefox') > -1 ? 'start' : 'nearest' );
  2024. if ( document.getElementsByClassName(className).length > 0 ) {
  2025. document.getElementById(elID).getElementsByClassName(className)[0].scrollIntoView({ behavior:$behavior, block:$block, inline:'nearest' });
  2026. }
  2027. setContentHeight();
  2028. }
  2029.  
  2030. // ***** SORTING ***** //
  2031. function sortIndex(els,id,sortDirection) { // id = sort type
  2032. let sorted = [];
  2033.  
  2034. const newSort = new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' }); // needs to be above makeNewIndex()
  2035. sorted = els.removeClass('sorted').sort((a, b) => {
  2036. let aName = $(a).find('td.name').data('name');
  2037. let bName = $(b).find('td.name').data('name');
  2038. let aData = $(a).find('td[data-'+ id +']').data(id);
  2039. let bData = $(b).find('td[data-'+ id +']').data(id);
  2040. if ( sortDirection === 1 ) { // sort by detail data value, then by name (i.e., if data values are the same, sort by name)
  2041. if ( newSort.compare(aData, bData) === 0 ) {
  2042. return newSort.compare(aName, bName);
  2043. } else {
  2044. return newSort.compare(aData, bData);
  2045. }
  2046. } else { // reverse sort
  2047. if ( newSort.compare(bData, aData) === 0 ) {
  2048. return newSort.compare(bName, aName);
  2049. } else {
  2050. return newSort.compare(bData, aData);
  2051. }
  2052. }
  2053. });
  2054. sorted = sorted.sort((a, b) => { // add sorted style (rules between different rows)
  2055. if ( id === 'kind' || id === 'ext' && sortDirection === 1 ) {
  2056. if ( $(a).find('td[data-'+ id +']').data(id) !== $(b).find('td[data-'+ id +']').data(id) ) { $(a).addClass('sorted'); }
  2057. }
  2058. if ( id === 'kind' || id === 'ext' && sortDirection === -1 ) {
  2059. if ( $(b).find('td[data-'+ id +']').data(id) !== $(a).find('td[data-'+ id +']').data(id) ) { $(a).addClass('sorted'); }
  2060. }
  2061.  
  2062. });
  2063. return sorted;
  2064. }
  2065. // Sort the Dir List on click
  2066. function sortDirList(rows, id, sortDirection) {
  2067. const $sort_all = rows;
  2068. const $sort_dirs = $sort_all.filter('.dir:not(.app)');
  2069. const $sort_files = $sort_all.filter('.file,.app');
  2070. const $sort_id = id.slice(8);// === 'default' ? 'name' : id;
  2071.  
  2072. const $sorted_dirs = sortIndex($sort_dirs, $sort_id, sortDirection);
  2073. const $sorted_files = sortIndex( $sort_files, $sort_id, sortDirection );
  2074. const $sorted_all = sortIndex( $sort_all, $sort_id, sortDirection );
  2075. let $sorted = [];
  2076.  
  2077. if ( $sort_id === 'default' || ( $sort_id !== 'name' && $settings.dirs_on_top === true )) {
  2078. if (sortDirection === 1) {
  2079. $sorted = $.merge($sorted_dirs,$sorted_files);
  2080. } else {
  2081. $sorted = $.merge($sorted_files,$sorted_dirs);
  2082. }
  2083. } else {
  2084. $sorted = $sorted_all;
  2085. }
  2086. return $sorted;
  2087. }
  2088. // Sort on click
  2089. function clickSort(el) {
  2090. const id = el.attr('id'); // id from th sort item = 'sort_by_xxx'
  2091. var sortDirection = ( el.hasClass('up') ? -1 : 1 ); // Only reverse sort order after clicking a sort column once.
  2092. // SORT EM!
  2093. const $sorted_index = sortDirList( $dir_list_row, id, sortDirection );
  2094. $dir_list_body.append($sorted_index);
  2095. $('th[id="'+ id +'"]').toggleClass('up').siblings().removeClass('up');
  2096. if ( $content_grid.hasClass('has_font_grid') ) { $('#show_font_grid').click(); }
  2097. if ( $content_grid.hasClass('has_image_grid') ) { $('#show_image_grid').click(); }
  2098. if ( $content_grid.hasClass('has_grid') ) { $('#grid_btn').click(); }
  2099. setContentHeight();
  2100. }
  2101. // Sort on clicking dir_list sort item
  2102. $('#theader').on('click','th.sorting:not(.disabled)',function(e) {
  2103. e.preventDefault();
  2104. e.stopPropagation();
  2105. clickSort( $(this) );
  2106. });
  2107. // Sort Menu: click the list header that contains the selected menu text.
  2108. $('#sort_menu').on('click','li:not(.disabled)',function(e) {
  2109. e.preventDefault();
  2110. e.stopPropagation();
  2111. $('#theader th[id="sort_by_'+ $(this).attr('id') +'"]').click(); // click corresponding dir_list sort item
  2112. });
  2113. // ***** END SORTING ***** //
  2114. // ***** END BASIC UI FUNCTIONS ***** //
  2115.  
  2116. // ***** CONTENT PANE ***** //
  2117. // SELECT ROW on click and set classes for $content_pane
  2118. function selectThis(row) {
  2119. const $grid_selected = $content_grid.find('div.font_grid_item a[href="'+ thisLink(row) +'"]').closest('div').add('div.image_grid_item a[href="'+ thisLink(row) +'"]').closest('div').addBack();
  2120. if ( $content_pane.hasClass('has_grid') ) { // Select corresponding grid item
  2121. row.addClass('selected').siblings().removeClass('selected hovered');
  2122. $grid_selected.addClass('selected').siblings().removeClass('selected');
  2123. } else { // remove classes from rows, but leave .audio with playing
  2124. row.addClass('selected').siblings().removeClass('selected hovered');
  2125. }
  2126. }
  2127.  
  2128. //***** SHOW CONTENT *****//
  2129. function showAudio(rowID) {
  2130. let row = getElById(rowID);
  2131. closeMedia('video');
  2132. if ( row.hasClass('audio') ) { row.addClass('playing selected').siblings('.media').removeClass('playing selected'); }
  2133. $audio_player.attr('src', thisLink( row ) );
  2134. $content_pane.addClass('has_audio');
  2135. setContentTitle();
  2136. setContentHeight();
  2137. }
  2138. // Show Grid
  2139. function showGrid() {
  2140. $content_pane.removeClass('has_hidden_grid').addClass('has_grid');
  2141. closeMedia('video');
  2142. setContentTitle();
  2143. setContentHeight();
  2144. selectThis($selected_file());
  2145. }
  2146. // Show Font (and create font items)
  2147. function showFont(row,bool,sheet) { // bool = true if for show font grid, sheet defined at fontGridItems()
  2148. let fontStyles = $font_styles.sheet;
  2149. const $font_family = thisText(row);
  2150. const $font_url = thisLink(row);
  2151. if ( bool === false ) {
  2152. if ( fontStyles.cssRules.length > 0 ) { fontStyles.deleteRule(0); } // delete previous @font-face rule
  2153. fontStyles.insertRule('@font-face { font-family: "'+ $font_family +'"; src: url("'+ $font_url +'"); }');
  2154. $content_font.css({ 'font-family':'"'+ $font_family +'"' }); // set content font style
  2155. } else {
  2156. let grid_item = $font_grid_item_el.clone();
  2157. const $display_name = $font_family;
  2158. sheet.insertRule('@font-face { font-family: "'+ $font_family +'"; src: url("'+ $font_url +'"); }');
  2159. grid_item.append('<p>'+ $display_name +'</p><h2 style=\'font-family: "'+ $font_family +'"\'; ><a href="'+ $font_url +'">'+ $display_name.slice(0,$font_family.lastIndexOf('.')) +'</a></h2>' );
  2160. return grid_item;
  2161. }
  2162. }
  2163. // Show/Hide Editor or Grid
  2164. function showEditorOrGrid() {
  2165. if ( $body.hasClass('has_hidden_text') ) { $body.toggleClass('has_text has_hidden_text'); }
  2166. if ( $content_pane.hasClass('has_hidden_grid') ) { $content_pane.toggleClass('has_grid has_hidden_grid'); }
  2167. }
  2168. function hideEditorOrGrid() {
  2169. if ( $body.hasClass('has_text') ) { $body.toggleClass('has_text has_hidden_text'); }
  2170. if ( $content_pane.hasClass('has_grid') ) { $content_pane.toggleClass('has_grid has_hidden_grid'); }
  2171. }
  2172. // Set Content Pane classes
  2173. function setContentClasses(content_el) {
  2174. if ( content_el === 'audio' ) {
  2175. $content_pane.addClass('has_audio');
  2176. } else {
  2177. hideEditorOrGrid();
  2178. let classes = ['has_font','has_image','has_zoom_image','has_pdf','has_video','has_iframe','has_dir','has_ignored'];
  2179. $content_pane.removeClass(classes.join(' ')).addClass( 'has_'+ content_el ); // remove classes, excluding grid and text classes; add content class
  2180. }
  2181. }
  2182. // Set Content Element Sources and row classes
  2183. function setContentSources(row,link,kind,content_el) {
  2184. if ( kind === 'audio' ) { $audio_player.attr('src',link); }
  2185. if ( kind === 'font' ) { showFont(row,false); }
  2186. if ( kind === 'pdf' ) { link = link + '?#view=fitB&scrollbar=1&toolbar=1&navpanes=1'; } // add pdf query str to link
  2187. if ( kind === 'code' || kind === 'markdown' || kind === 'text' ) {
  2188. link = thisLink(row) +'?split_view='+ getQuery('split_view') +'&default_text_view='+ getQuery('default_text_view');
  2189. if ( !$body.hasClass('enable_text_editing') ) { link += '&enable_text_editing=false'; } else { link += '&enable_text_editing=true'; }
  2190. }
  2191. if ( kind === 'video' ) { row.addClass('playing'); } else { row.addClass('loaded'); }
  2192. $('#content_'+ content_el).addClass('has_content').attr('src',link).removeAttr('srcdoc');
  2193. }
  2194. // Show Content
  2195. function showContent(row) { // show any content excluding grids on row click
  2196. if ( row.length === -1 ) { return; } // needed for left/right arrow nav when there are no valid items (i.e. images or fonts)
  2197.  
  2198. let link = thisLink(row);
  2199. let kind = thisRow(row).attr('data-kind') ;
  2200. let rowID = row.attr('id');
  2201. let content_el = ( row.hasClass('ignore') && $body.hasClass('ignore_ignored_files') ? 'ignored' : !['audio','font','image','pdf','video'].includes(kind) || kind === 'dir' ? 'iframe' : kind ); // load dirs and any other kind of content except audio, font, image, pdf, or video into iframe
  2202.  
  2203. if ( row.hasClass('m3u') ) {
  2204.  
  2205. } else
  2206.  
  2207. if ( row.hasClass('audio') ) {
  2208. showAudio( rowID );
  2209. } else {
  2210. closeContentEls(row);
  2211. setContentClasses(content_el);
  2212. setContentSources(row,link,kind,content_el);
  2213. setContentTitle();
  2214. setContentHeight();
  2215. row.siblings().removeClass('loaded');
  2216. }
  2217. }
  2218.  
  2219. //***** CLOSE CONTENT (Close button or Cmd/Ctrl + W) *****//
  2220. // Close Audio/Video
  2221. function closeMedia(type) { // type === audio || video
  2222. let $mediaEl = ( type === 'audio' ? $audio_player : $content_video );
  2223. // let $mediaFile = $(document.getElementsByClassName(type));
  2224. $('.media.playing, .media.loaded').removeClass('playing loaded');
  2225. $content_pane.removeClass('has_'+ type);
  2226. $mediaEl.trigger('pause').attr('src','');
  2227. if ( type === 'audio' ) { $('#content_audio_title td').empty(); } else { $title.empty(); }
  2228. setContentHeight();
  2229. }
  2230. // Close Audio button click
  2231. $close_audio.on('click',function(e) {
  2232. e.stopPropagation();
  2233. closeMedia('audio');
  2234. $('.audio.selected').removeClass('selected');
  2235. if ( $('.loaded').length === 1 ) { $('.loaded').addClass('selected'); }
  2236. });
  2237. // Close Text Editor
  2238. // Close Grid
  2239. function closeGrid() {
  2240. $content_pane.removeClass('has_grid');
  2241. $content_grid.empty().removeClass().attr('style','').find('.image_grid_item, img').attr('style','');
  2242. }
  2243. // Close .content elements (not #content_audio, #content_text, or #content_grid) when opening new content
  2244. function closeContentEls(row) {
  2245. // close media
  2246. if ( row !== undefined && row.hasClass('video') ) {
  2247. closeMedia('audio');
  2248. } else if ( row !== undefined && row.hasClass('audio') ) {
  2249. closeMedia('video');
  2250. }
  2251. // close content
  2252. if ( $('body').hasClass('has_text') && $(this).hasClass('selected') ) { // if text editor visible, just hide it and show selected item
  2253. $('body').removeClass('has_text').addClass('has_hidden_text');
  2254. } else if ( $('.content.has_content').length ) {
  2255. let $contentID = $('.content.has_content').attr('id');
  2256. switch($contentID) {
  2257. case 'content_font':
  2258. $content_font.css({'font-family':''});
  2259. break;
  2260. case 'content_image':
  2261. $content_pane.removeClass('has_zoom_image');
  2262. $content_image.attr('style',''); // reset image: comment out to retain image scale after loading other content
  2263. // $content_grid.find('a[href="' + thisLink(row) + '"]').parent('div').addClass('selected').siblings().removeClass('selected'); // select grid image
  2264. break;
  2265. case 'content_video':
  2266. closeMedia('video');
  2267. break;
  2268. }
  2269. $content_pane.removeClass('has_'+ $contentID.slice(8));
  2270. $('.content').removeClass('has_content').removeAttr('src');
  2271. // $content_iframe.attr('srcdoc',$content_parent_link);
  2272. }
  2273. }
  2274. // Close button
  2275. function closeContent() {
  2276. if ( $content_pane.hasClass('has_grid') ) { // close grid
  2277. closeGrid();
  2278. } else if ( $body.hasClass('iframe_edited') ) { // warn if iframe edited
  2279. hideEditorOrGrid();
  2280. showWarning('closeContent');
  2281. } else if ( ['has_font','has_image','has_zoom_image','has_pdf','has_video','has_iframe','has_dir','has_ignored','has_text'].some( c => $content_pane.attr('class').split(' ').indexOf( c ) >= 0 ) ) {
  2282. closeContentEls(); // close content if content pane has one of these classes, except audio and grids
  2283. $('.selected:not(.audio)').removeClass('selected');
  2284. $('.loaded').removeClass('loaded');
  2285. $title.removeAttr('data-after').empty();
  2286. showEditorOrGrid();
  2287. } else if ( $body.hasClass('has_text') && !$body.hasClass('edited') ) { // simply hide unedited text editor...
  2288. $body.removeClass('has_text');
  2289. } else if ( $body.hasClass('edited') ) { // ...else show edited warning
  2290. showWarning('closeContent');
  2291. } else { // close audio last of all
  2292. closeMedia('audio');
  2293. $('.selected.audio').removeClass('selected');
  2294. }
  2295. setContentTitle();
  2296. setContentHeight();
  2297. }
  2298. $('#close_btn').on('click', function(e) {
  2299. e.preventDefault();
  2300. closeContent(); // close content unless body.edited or body.iframe_edited
  2301. });
  2302.  
  2303. //***** RESET CONTENT (Reset button or Cmd/Ctrl + R) *****//
  2304. function resetContent() {
  2305. if ( $content_pane.attr('class') === '' ) { window.location = window.location.href; } // reload page
  2306. if ( $content_pane.hasClass('has_audio') ) { $audio_player.prop('currentTime', 0).trigger('pause'); }
  2307. if ( $content_pane.hasClass('has_grid') ) { $grid_btn.click(); }
  2308. if ( $content_pane.hasClass('has_font') ) { $content_font.css({'font-size':'1em'});}
  2309. if ( $content_pane.hasClass('has_image') ) { $content_pane.removeClass('has_zoom_image').find('#content_image').attr('style',''); }
  2310. if ( $content_pane.hasClass('has_video') ) { $content_video.prop('currentTime',0).trigger('pause'); }
  2311. if ( $content_pane.hasClass('has_iframe') || $content_pane.hasClass('has_dir') ) { $selected_file().find('a').click(); }
  2312. setContentHeight();
  2313. }
  2314. $('#reload_btn').on('click', function(e) {
  2315. e.preventDefault();
  2316. showWarning('resetContent');
  2317. });
  2318.  
  2319. //**********************//
  2320. //***** NAVIGATION *****//
  2321. function firstRowID(className) {
  2322. return ( $('#tbody').find(':visible:not(.unchecked)').filter(className).length ? $('#tbody').find('tr:visible:not(.unchecked)').filter(className).first().attr('id') : null );
  2323. }
  2324. function prevRowID(className) {
  2325. let row = ( ['.audio','.video','.media'].includes(className) ? $playing_file() : $selected_file() );
  2326. return ( !row.length || !row.prevAll(':visible:not(.unchecked)').filter(className).length ) ? $('#tbody').find('tr').filter(className).last().attr('id') : row.prevAll(':visible:not(.unchecked)').filter(className).first().attr('id');
  2327. }
  2328. function nextRowID(className) { // if nothing selected, or if no next row with classname, return first row with classname, else return next row with classname
  2329. let row = ( ['.audio','.video','.media'].includes(className) ? $playing_file() : $selected_file() );
  2330. return ( !row.length || !row.nextAll(':visible:not(.unchecked)').filter(className).length ) ? $('#tbody').find('tr').filter(className).first().attr('id') : row.nextAll(':visible:not(.unchecked)').filter(className).first().attr('id');
  2331. }
  2332. function lastRowID(className) {
  2333. return ( $('#tbody').find(':visible:not(.unchecked)').filter(className).length ? $('#tbody').find('tr:visible:not(.unchecked)').filter(className).last().attr('id') : null );
  2334. }
  2335. function selectRowID(className,key) {
  2336. let id = '';
  2337. if ( key === 'ArrowUp' ) { id = prevRowID('.dir,.file'); }
  2338. if ( key === 'ArrowLeft' ) { id = prevRowID(className); }
  2339. if ( key === 'ArrowRight' ) { id = nextRowID(className); }
  2340. if ( key === 'ArrowDown' ) { id = nextRowID('.dir,.file'); }
  2341. return id;
  2342. }
  2343. // NAVIGATION: select GRID items by left/right arrow keys @ arrowNavigation();
  2344. function gridNavigation(key) {
  2345. let className = '';
  2346. if ( $content_grid.hasClass('has_font_grid') ) { className = '.font:not(.ignore)'; }
  2347. if ( $content_grid.hasClass('has_image_grid') ) { className = '.image:not(.ignore)'; }
  2348. if ( $content_grid.hasClass('has_grid') ) { className = '.font:not(.ignore),.image:not(.ignore)'; }
  2349. selectThis( getElById(selectRowID(className,key) ) );
  2350. }
  2351. // NAVIGATION: FONTS and IMAGES by prev/next buttons
  2352. $content_pane.on( 'click','#prev_btn, #next_btn', function(e) {
  2353. e.stopPropagation();
  2354. e.preventDefault();
  2355. let key = $(this).attr('id') === 'prev_btn' ? 'ArrowLeft' : 'ArrowRight';
  2356. clickRow( selectRowID('.font,.image',key));
  2357. });
  2358. // NAVIGATION: MEDIA tracks by arrow left/right @ leftRightArrowNavigation() & button click; // handle shuffle or loop play, as well as normal continuous playback after end of track with ArrowRight
  2359. function playPrevNextTrack(key) {
  2360. if ( $('.playing').length === 0 ) { // Arrow L/R selects first/last audio file if nothing selected
  2361. clickRow( selectRowID('.media',key) );
  2362. playMedia('play');
  2363. } else if ( $('.playing').length === 1 ) {
  2364. let mediaClass = ( $('.playing').hasClass('audio') ? '.audio' : '.video' );
  2365. // If shuffle play...
  2366. if ( $body.hasClass('shuffle_audio') ) {
  2367. let trackRowID = $audio_player.data('shufflelist').pop();
  2368. if ( trackRowID !== undefined ) { // if shuffle list is not empty...
  2369. showAudio( trackRowID ); // load audio...
  2370. playMedia('play'); // and play
  2371. } else if ( trackRowID === undefined ) { // if end of shufflelist...
  2372. if ( $body.hasClass('loop_audio') ) { // and if loop audio, update the shufflelist and play
  2373. updateShuffleList();
  2374. playMedia('play');
  2375. } else { // else load the first track
  2376. showAudio( firstRowID( mediaClass ));
  2377. }
  2378. }
  2379. // else if there is another media file selected, play it next
  2380. } else if ( $(mediaClass).filter('.selected').length === 1 && !$('.media.selected').hasClass('playing') ) {
  2381. showAudio( $('.media.selected').attr('id') );
  2382. playMedia('play');
  2383. } else { // else select and play the next track
  2384. if ( $body.hasClass('loop_audio') || nextRowID( mediaClass ) !== firstRowID( mediaClass ) ) {
  2385. showAudio( selectRowID( mediaClass,key ) );
  2386. playMedia('play');
  2387. } else {
  2388. showAudio( selectRowID( mediaClass,key ) );
  2389. }
  2390. }
  2391. }
  2392. }
  2393. // NAVIGATION: Audio by prev/next audio buttons
  2394. $('.prev_next_track_btn').on('click',function() {
  2395. let key = ( $(this).attr('id') === 'prev_track' ? 'ArrowLeft' : 'ArrowRight' );
  2396. playPrevNextTrack(key);
  2397. });
  2398. // NAVIGATION: Prev/Next Audio or Prev/Next File of same data-kind by arrow left/right
  2399. function leftRightArrowNavigation(className,key) {
  2400. if ( $('.selected').hasClass('media') && $('.playing').length === 1 ) {
  2401. playPrevNextTrack(key);
  2402. } else {
  2403. if ( $('.selected').length === 0 ) { // else select first/last row
  2404. clickRow( selectRowID('.dir,.file',key) );
  2405. } else { // else select prev/next row of same data-kind
  2406. clickRow( selectRowID('.'+ $('.loaded').attr('data-kind'),key) );
  2407. }
  2408. }
  2409. }
  2410. function upDownArrowNavigation(key) {
  2411. let row = $(document.getElementById(selectRowID('.dir,.file',key)));
  2412. if ( row.hasClass('audio') && $('.audio.playing').length === 1 ) { // just select audio file if another audio is playing
  2413. selectThis( row );
  2414. } else {
  2415. clickRow( selectRowID('.dir,.file',key) );
  2416. }
  2417. }
  2418. // NAVIGATE directory index items by arrow up/down or left/right keys, with/without grid @ indexNavigation()
  2419. function arrowNavigation(className,key) {
  2420. if ( key === 'ArrowUp' || key === 'ArrowDown' ) {
  2421. upDownArrowNavigation(key);
  2422. } else { // key === 'ArrowLeft" || key === 'ArrowRight'
  2423. if ( $content_pane.hasClass('has_grid') ) { // Grid navigation: L/R arrow selects images and fonts only
  2424. gridNavigation(key);
  2425. } else {
  2426. leftRightArrowNavigation(className,key);
  2427. }
  2428. }
  2429. if ( $content_pane.hasClass('has_grid') ) {
  2430. scrollThis('content_grid','selected');
  2431. } else {
  2432. scrollThis('tbody','selected');
  2433. }
  2434. }
  2435.  
  2436. // NAVIGATION: Main navigation by arrow keys
  2437. function indexNavigation(key) {
  2438. let className = ( $('.selected[data-kind]') === undefined ? $dir_list.find('tbody tr:visible').first().attr('data-kind') : $('.selected[data-kind]').attr('data-kind') );
  2439. arrowNavigation(className,key);
  2440. }
  2441.  
  2442. // NAVIGATE items by typed string
  2443. var str = '';
  2444. function timeoutID() {
  2445. return window.setTimeout( function() { str = ''; }, 1500 );
  2446. }
  2447. function alphaNav(e) { // Select Dir_List row by typed string; Todo: select next row by nearest letter
  2448. let timer = timeoutID();
  2449. if ( typeof timer === 'number' ) {
  2450. window.clearTimeout( timer );
  2451. timer = 0; // id
  2452. }
  2453. timeoutID();
  2454. str += e.key;
  2455. str = str.toLowerCase();
  2456. if ( $('#dir_list').find('td.name[data-name^="'+ str +'"]').length ) {
  2457. $('#dir_list').find('td.name[data-name^="'+ str +'"]').first().find('a').click();
  2458. scrollThis('tbody','selected');
  2459. // } else {
  2460. // null; // replace this with some sort of fuzzy match function? TBD
  2461. }
  2462. }
  2463. //***** END NAVIGATION *****//
  2464.  
  2465. //***** CLICK TO SELECT/SHOW CONTENT *****//
  2466.  
  2467. // CLICK element by id
  2468. function clickThis(id) {
  2469. let el = $(document.getElementById(id));
  2470. if ( el.find('a').length > 0 ) { el.find('a').click(); } else { el.click(); }
  2471. }
  2472. // CLICK Row
  2473. function clickRow(id) {
  2474. let row = getElById(id);
  2475. selectThis(row);
  2476. showContent(row);
  2477. }
  2478. $body.find('#tbody').on('click','tr', function(e) {
  2479. e.preventDefault();
  2480. e.stopPropagation();
  2481. if ( $(this).hasClass('playing') ) {
  2482. playPauseMedia();
  2483. } else {
  2484. showWarning( 'clickRow', $(this).attr('id') );
  2485. }
  2486. });
  2487.  
  2488. // DOUBLE-CLICK Row to open directory
  2489. function doubleClickRow(row) { // row.dir only
  2490. let $query_str = decodeURIComponentSafe(window.location.search);
  2491. if ( $query_str === '' ) { $query_str = '?'; }
  2492. const $current_index = row.prevAll('.dir:visible:not(.ignore)').length;
  2493. if ( $query_str.indexOf('history') !== -1 ) {
  2494. $query_str = $query_str.replace(/&selected=\d+/,'').replace(/&history=/,'&history='+ $current_index +'+');
  2495. } else {
  2496. $query_str = $query_str.replace(/&selected=\d+/,'') + '&history='+ $current_index;
  2497. }
  2498. window.location = row.find('a').attr('href') + $query_str;
  2499. }
  2500. $('#tbody').find('tr.dir').on('dblclick', function(e) {
  2501. e.preventDefault();
  2502. e.stopPropagation();
  2503. showWarning( 'doubleClickRow', $(this) );
  2504. });
  2505.  
  2506. // CLICK grid item
  2507. function gridItemClick(e,el) {
  2508. e.preventDefault();
  2509. clickThis( thisID($dir_list.find('a[href*="'+ thisLink(el) +'"]') ) );
  2510. }
  2511. $content_grid.on('click','div', function(e) {
  2512. gridItemClick(e,$(this));
  2513. });
  2514.  
  2515. // HOVER Grid Item
  2516. $content_grid.on('mouseenter','> div:not(.selected)',function() {
  2517. thisRow($dir_list.find('a[href*="'+ thisLink(this) +'"]')).addClass('hovered');
  2518. }).on('mouseleave','> div:not(.selected)',function() {
  2519. thisRow($dir_list.find('a[href*="'+ thisLink(this) +'"]')).removeClass('hovered');
  2520. });
  2521. // HOVER Dir_list_row and highlight corresponding grid item
  2522. $dir_list_row.hover(function() {
  2523. if ( $content_grid.is(':visible') ) {
  2524. $content_grid.find('[href*="'+ thisLink(this) +'"]').closest('div').addClass('hovered');
  2525. }
  2526. }, function() {
  2527. if ( $content_grid.is(':visible') ) {
  2528. $content_grid.find('.hovered').removeClass('hovered');
  2529. }
  2530. });
  2531.  
  2532. //***** AUTOLOAD CONTENT: index files or files from the file shortcut list *****//
  2533. function autoSelectFile() {
  2534. let $query_prefs = getQueryPrefs();
  2535. let $UI_pref_selected = ( $query_prefs.get('selected') === null ? '' : $query_prefs.get('selected') );
  2536. if ( getQuery('file') !== undefined && getQuery('file').length > 0 && window.top == window.self ) { // load individual files
  2537. clickRow( $dir_list.find('a[href*="'+ getQuery('file') +'"]').closest('tr').attr('id') );
  2538. removeQuery('file');
  2539. } else if ( $UI_pref_selected !== '' && !$body.hasClass('has_media') ) {
  2540. clickRow( $dir_list.find('tr.dir:not(.invisible)').eq($UI_pref_selected).attr('id') );
  2541. } else if ( $body.hasClass('autoload_index_files') && $dir_list.find( 'a[href*="/index."]').length > 0 ) { // else load index file
  2542. clickRow( $dir_list.find('a[href*="/index."]').closest('tr').attr('id') );
  2543. } else { // else select first non-media item
  2544. // clickRow( $dir_list.find('tbody tr:not(.media):not(.invisible)').first() );
  2545. }
  2546. if ( $body.hasClass('autoload_media') && $body.hasClass('has_media') ) { // else if audio and images, load cover art
  2547. // showAudio( firstRowID('.audio,.video') );
  2548. clickRow( firstRowID('.audio,.video') );
  2549. if ( $playing_file() ) { scrollThis('tbody','playing'); }
  2550. }
  2551. if ( $selected_file() ) { scrollThis('tbody','selected'); }
  2552. }
  2553.  
  2554. // Autoload Cover Art
  2555. function getImageNames() {
  2556. let image_names = [];
  2557. $image_files.each(function() {
  2558. let name = $(this).find('td.name').attr('data-name');
  2559. name = name.slice(0,name.lastIndexOf('.'));
  2560. image_names.push( name );
  2561. });
  2562. return image_names;
  2563. }
  2564. function getCoverArtID() {
  2565. const cover_names = ['cover','front'];
  2566. const image_names = getImageNames();
  2567. for ( let cover_name of cover_names ) {
  2568. if ( image_names.includes(cover_name) ) { // file name = a cover name
  2569. return $image_files.eq( image_names.indexOf(cover_name) ).attr('id');
  2570. } else if ( image_names.some( name => name.startsWith(cover_name)) ) { // file name starts with a cover name
  2571. return $image_files.find('td.name[data-name^="'+ cover_name +'"]').closest('tr').attr('id');
  2572. } else if ( image_names.some( name => name.indexOf(cover_name) > 0 ) ) { // file name includes a cover name
  2573. return $image_files.find('td.name[data-name*="'+ cover_name +'"]').closest('tr').attr('id');
  2574. } else { // else use first image
  2575. return $image_files.first().attr('id');
  2576. }
  2577. }
  2578. }
  2579. function autoLoadCoverArt() { // autoload cover art for audio if dir contains audio and images, and audio is loaded and non-image content is not loaded
  2580. if ( $body.hasClass('has_audio') && $body.hasClass('has_images') && $body.hasClass('autoload_media') ) {
  2581. let $coverID = getCoverArtID();
  2582. if ( $coverID !== undefined ) {
  2583. let row = getElById($coverID);
  2584. showContent(row);
  2585. row.addClass('loaded');
  2586. }
  2587. }
  2588. }
  2589.  
  2590. //***** KEYBOARD EVENTS *****//
  2591. $body.on('keydown',$dir_list,function(e) {
  2592. const $selected = $selected_file();
  2593.  
  2594. if ( $('#content_source').is(':focus') || $('#content_font div').is(':focus') && e.key !== 'Escape' ) {
  2595. return;
  2596. }
  2597. // Disable all keydown events except return and tab when warning is shown
  2598. if ( $('body').hasClass('has_warning') ) {
  2599. if (e.key !== 'Enter' && e.key !== 'Tab' && e.key !== 'Shift' ) {
  2600. e.preventDefault();
  2601. return false;
  2602. }
  2603. if ( e.key === 'Enter' ) {
  2604. e.preventDefault();
  2605. e.stopPropagation();
  2606. $('#warnings').find('button.focus').click();
  2607. }
  2608. if ( e.key === 'Tab' ) {
  2609. e.preventDefault();
  2610. e.stopPropagation();
  2611. if ( $('#warnings').find('button.focus').length === 0 || $('#warnings').find('button.focus').prev('button').length === 0 ) {
  2612. $('#warnings').find('button').last('button').focus().addClass('focus').siblings().removeClass('focus').blur();
  2613. } else {
  2614. $('#warnings').find('button.focus').prev('button').focus().addClass('focus').siblings().removeClass('focus').blur();
  2615. }
  2616. }
  2617. }
  2618.  
  2619. $(':focus').blur(); // Need this to able to select grid items after clicking close button (or other buttons).
  2620.  
  2621. switch ( e.key ) {
  2622. case 'ArrowUp':
  2623. if ( (navigator.platform.match('Mac') ? e.metaKey && !e.ctrlKey : e.ctrlKey) && !e.shiftKey && !e.altKey ) { // Cmd/Ctrl + up arrow = go to parent directory
  2624. if ( $('#parents_dir_menu + ul a').length < 1 ) {
  2625. return;
  2626. } else {
  2627. showWarning( 'clickThis', $('#parent_dir_menu').attr('id') );
  2628. }
  2629. break;
  2630. }
  2631. if ( $('*[contentEditable="true"]').is(':focus') ) { // Allow arrow navigation within content_editable elements
  2632. return;
  2633. }
  2634. e.preventDefault();
  2635. showWarning( 'indexNavigation', 'ArrowUp' );
  2636. break;
  2637. case 'ArrowDown':
  2638. if ( (navigator.platform.match('Mac') ? e.metaKey && !e.ctrlKey : e.ctrlKey) && !e.shiftKey && !e.altKey && $selected.hasClass('app') && $settings.apps_as_dirs === false ) { // Ignore Cmd/Ctrl + arrow or if focused element is content editable or open dir
  2639. return;
  2640. } else if ( $('*[contentEditable="true"]' ).is(':focus') ) {
  2641. return;
  2642. } else if ( (e.ctrl || e.metaKey) && $selected.hasClass('dir') ) {
  2643. $selected.find('a').trigger('dblclick');
  2644. break;
  2645. }
  2646. e.preventDefault();
  2647. showWarning( 'indexNavigation', 'ArrowDown' );
  2648. break;
  2649. case 'ArrowLeft':
  2650. if ( (e.ctrl || e.metaKey) || (e.ctrl && e.metaKey) ) {
  2651. return;
  2652. } else if ( $('*[contentEditable="true"]').is(':focus') ) { // Ignore Cmd/Ctrl + arrow or if focused element is content editable
  2653. return;
  2654. }
  2655. if ( (e.altKey && e.shiftKey) || e.altKey && !e.metaKey && !e.ctrlKey ) { // Skip audio 30s/10s: Opt-Shift-Arrow/Opt-Arrow
  2656. mediaSkip(e);
  2657. return;
  2658. } else {
  2659. showWarning( 'indexNavigation','ArrowLeft' );
  2660. }
  2661. break;
  2662. case 'ArrowRight':
  2663. if ( e.metaKey && !e.altKey && !e.shiftKey && $selected.hasClass('dir') ) { // Open dir with Cmd/Ctrl + Right Arrow
  2664. $selected.find('a').trigger('dblclick');
  2665. return;
  2666. }
  2667. if ( (e.ctrl || e.metaKey) || (e.ctrl && e.metaKey) ) { // Ignore Cmd/Ctrl + arrow or if focused element is content editable
  2668. return;
  2669. } else if ( $('*[contentEditable="true"]').is(':focus') || $selected.hasClass('dir ignore') ) {
  2670. return;
  2671. }
  2672. if ( (e.altKey && e.shiftKey) || e.altKey && !e.metaKey && !e.ctrlKey ) { // Skip audio 30s/10s: Opt-Shift-Arrow/Opt-Arrow
  2673. mediaSkip(e);
  2674. return;
  2675. } else {
  2676. showWarning( 'indexNavigation','ArrowRight' );
  2677. }
  2678. break;
  2679. case ' ': // space
  2680. if ( $content_pane.hasClass('has_audio') || $content_pane.hasClass('has_video') ) { // Play/pause media (space bar)
  2681. e.preventDefault();
  2682. playPauseMedia();
  2683. } else {
  2684. alphaNav(e);
  2685. }
  2686. break;
  2687. case 'Enter': // Open directories (or ignore)
  2688. if ( $selected.hasClass('app') && $settings.apps_as_dirs === false ) {
  2689. break;
  2690. } else {
  2691. if ( $selected.hasClass('dir') ) {
  2692. $selected.find('a').trigger('dblclick');
  2693. } else if ( $selected.hasClass('playing') || $selected.hasClass('video') ) { // content_audio or content_video
  2694. playPauseMedia();
  2695. } else {
  2696. $selected.click();
  2697. }
  2698. }
  2699. break;
  2700. // Alphabetical navigation
  2701. case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z':
  2702. case 'a': case 'b': case 'c': case 'f': case 'h': case 'j': case 'k': case 'l': case 'm': case 'n': case 'p': case 'q': case 's': case 't': case 'u': case 'v': case 'x': case 'y': case 'z':
  2703. case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '`': case '~': case '!': case '@': case '#': case '$': case '%': case '^': case '&': case '*': case '(': case ')': case '+': case '[': case ']': case '{': case '}': /*case '\\':*/ case '|': case '/': case '.': case ',': case '?': case '–': case '—': case '\'': case '"': case '“': case '”': case '‘': case '’': case '…': case 'π':
  2704. case '∫': case '∂': case 'ƒ': case '©': case '˙': case '∆': case '˚': case 'µ': case '®': case 'ß': case '†': case '√': case '∑': case '≈': case '¥': case 'Ω': case '¡': case '™': case '£': case '¢': case '∞': case '§': case '¶': case '•': case 'ª': case 'º': case '≠':
  2705. case '⁄': case '€': case '‹': case '›': case 'fl': case '‡': case '°': case '·': case '‚': case '±': case '¯': case '˘': case '¿':
  2706. case 'ı': case '': case '´': case '˝': case 'ˆ': case '': case '˜': case '‰': case 'ˇ': case '¨': case '◊': case '„': case '˛': case '¸':
  2707. // case 'α': case 'β': case 'γ': case 'δ': case 'ε': case 'ζ': case 'η': case 'θ': case 'ι': case 'κ': case 'λ': case 'μ': case 'ν': case 'ξ': case 'ο': case 'π': case 'ρ': case 'ς': case 'σ': case 'τ': case 'υ': case 'φ': case 'χ': case 'ψ': case 'ω': case 'ϑ': case 'ϒ': case 'ϖ':
  2708. // case 'Α': case 'Β': case 'Γ': case 'Δ': case 'Ε': case 'Ζ': case 'Η': case 'Θ': case 'Ι': case 'Κ': case 'Λ': case 'Μ': case 'Ν': case 'Ξ': case 'Ο': case 'Π': case 'Ρ': case 'Σ': case 'Σ': case 'Τ': case 'Υ': case 'Φ': case 'Χ': case 'Ψ': case 'Ω': case 'Θ': case 'ϒ':
  2709. if ( !e.metaKey && !e.ctrlKey && !e.altKey ) {
  2710. alphaNav(e);
  2711. }
  2712. break;
  2713. case 'd': // Cmd/Ctrl + D: Toggle Details
  2714. if ( (navigator.platform.match('Mac') ? e.metaKey && !e.ctrlKey : e.ctrlKey) && !e.shiftKey && !e.altKey ) {
  2715. e.preventDefault();
  2716. $show_details.click();
  2717. } else {
  2718. alphaNav(e);
  2719. }
  2720. break;
  2721. case 'e': // Cmd/Ctrl + E: Show Text Editor
  2722. if ( (navigator.platform.match('Mac') ? e.metaKey && !e.ctrlKey : e.ctrlKey) && !e.shiftKey && !e.altKey ) {
  2723. e.preventDefault();
  2724. $('#text_editor_row').find('a').click();
  2725. } else {
  2726. alphaNav(e);
  2727. }
  2728. break;
  2729. case 'g': // Cmd/Ctrl + G: Show image Grid
  2730. if ( (navigator.platform.match('Mac') ? e.metaKey && !e.ctrlKey : e.ctrlKey) && !e.shiftKey && !e.altKey ) {
  2731. e.preventDefault();
  2732. $grid_btn.click();
  2733. } else {
  2734. alphaNav(e);
  2735. }
  2736. break;
  2737. case 'i': // Cmd/Ctrl + I: Toggle Invisibles
  2738. if ( (navigator.platform.match('Mac') ? e.metaKey && !e.ctrlKey : e.ctrlKey) && !e.shiftKey && !e.altKey ) {
  2739. e.preventDefault();
  2740. $inv_checkbox.find('input').click();
  2741. } else {
  2742. alphaNav(e);
  2743. }
  2744. break;
  2745. case 'o': // Cmd/Ctrl + Shift + O: Open selected item in new window
  2746. if ( (navigator.platform.match('Mac') ? e.metaKey && !e.ctrlKey : e.ctrlKey) && e.shiftKey && !e.altKey ) {
  2747. window.open( thisLink($selected_file()) );
  2748. } else {
  2749. alphaNav(e);
  2750. }
  2751. break;
  2752. case 'r': // Cmd/Ctrl + Shift + R: Refresh
  2753. if ( (navigator.platform.match('Mac') ? e.metaKey && !e.ctrlKey : e.ctrlKey) && !e.shiftKey && !e.altKey ) {
  2754. e.preventDefault();
  2755. $('#reload_btn').click();
  2756. } else {
  2757. alphaNav(e);
  2758. }
  2759. break;
  2760. case 'w': // Close content pane if Close button visible with Cmd/Crtl + W
  2761. if ( (navigator.platform.match('Mac') ? e.metaKey && !e.ctrlKey : e.ctrlKey) && !e.shiftKey && !e.altKey ) {
  2762. if ( $content_pane.attr('class').indexOf('has_') > -1 ) {
  2763. e.preventDefault();
  2764. $('#close_btn').click();
  2765. }
  2766. } else {
  2767. alphaNav(e);
  2768. }
  2769. break;
  2770. case '\\':
  2771. if ( (navigator.platform.match('Mac') ? e.metaKey && !e.ctrlKey : e.ctrlKey) && !e.shiftKey && !e.altKey ) {
  2772. e.preventDefault();
  2773. $('#toggle_split_view').click();
  2774. } else {
  2775. alphaNav(e);
  2776. }
  2777. break;
  2778. case '=':
  2779. if ( (navigator.platform.match('Mac') ? e.metaKey && !e.ctrlKey : e.ctrlKey) && !e.shiftKey && !e.altKey ) {
  2780. e.preventDefault();
  2781. $('#increase').click();
  2782. } else {
  2783. alphaNav(e);
  2784. }
  2785. break;
  2786. case '-':
  2787. if ( (navigator.platform.match('Mac') ? e.metaKey && !e.ctrlKey : e.ctrlKey) && !e.shiftKey && !e.altKey ) {
  2788. e.preventDefault();
  2789. $('#decrease').click();
  2790. } else {
  2791. alphaNav(e);
  2792. }
  2793. break;
  2794. case 'tab':
  2795. break;
  2796. case 'Escape':
  2797. $('*:focus').blur();
  2798. break;
  2799. } // end switch
  2800. });
  2801. // ***** END KEYBOARD EVENTS ***** //
  2802.  
  2803. // ***** GRID SETUP ***** //
  2804. // Create Font Grid Items
  2805. function fontGridItems() {
  2806. let $font_grid_items_arr = [];
  2807. let $font_files = $dir_list_body.find('.font');
  2808. let fontGridStyles = $font_grid_styles.sheet;
  2809. for ( let i = 1; i < $font_files.length; i++ ) {
  2810. let newGridItem = showFont($font_files[i],true,fontGridStyles);
  2811. $font_grid_items_arr.push( newGridItem );
  2812. }
  2813. return $font_grid_items_arr;
  2814. }
  2815. // Create Image Grid Items
  2816. function imageGridItems() {
  2817. let $image_grid_items_arr = [];
  2818. let $image_files = $dir_list_body.find('.image');
  2819. for ( let i = 0; i < $image_files.length; i++ ) {
  2820. const $this_link = thisLink($image_files[i]);
  2821. const exts = $row_types.image.filter( ext => $.inArray(ext, $row_settings.ignore) == -1 ); // decide which image files can be displayed
  2822. const $title_name = $this_link.slice($this_link.lastIndexOf('/') + 1);
  2823. if ( $.inArray( thisExt($image_files[i]), exts ) > -1 ) { // if this row file ext is in the image extension array
  2824. let item = '<div class="image_grid_item"><a href="'+$this_link+'"><img src="'+$this_link+'" title="'+$title_name+'" loading="lazy" /></a></div>';
  2825. $image_grid_items_arr.push( item );
  2826. }
  2827. }
  2828. return $image_grid_items_arr;
  2829. }
  2830. // Make Grids
  2831. function makeGrids(el) {
  2832. closeGrid();
  2833. $content_pane.removeClass('has_hidden_grid').addClass('has_grid');
  2834. if ( el.attr('id') === 'show_font_grid' || !$body.hasClass('has_images') ) { // only show font grid
  2835. $title.removeClass().addClass('font_grid');
  2836. $content_grid.addClass('has_font_grid');
  2837. $content_grid.append( fontGridItems() );
  2838. } else if ( el.attr('id') === 'show_image_grid' || !$body.hasClass('has_fonts') ) { // only show image grid
  2839. $title.removeClass().addClass('image_grid');
  2840. $content_grid.addClass('has_image_grid');
  2841. $content_grid.append( imageGridItems() );
  2842. } else { // show grid of both images and fonts
  2843. $title.removeClass();
  2844. if ( $body.hasClass() ) { $content_grid.addClass('has_image_grid'); } else { $content_grid.addClass('has_grid'); }
  2845. $content_grid.append( imageGridItems(), fontGridItems() );
  2846. }
  2847. }
  2848. // Click grid button
  2849. $sidebar_header.on('click', '#grid_btn, #show_font_grid, #show_image_grid', function(e) {
  2850. e.stopPropagation();
  2851. makeGrids($(this));
  2852. showGrid();
  2853. });
  2854.  
  2855. // ***** SCALE PREVIEWED IMAGES & FONTS ***** //
  2856. // Scale Fonts
  2857. function scaleFonts(incr, y) {
  2858. const $em = parseInt(getComputedStyle(document.body).fontSize); // pts/em
  2859. const getFontSize = function(el) { return parseFloat(el.css('font-size')); };
  2860. if ( y === 'decrease' ) { incr = 1/incr; }
  2861. if ( $content_pane.hasClass('has_grid') && ( $content_grid.hasClass('has_font_grid') || $content_grid.hasClass('has_grid') ) ) {
  2862. $content_grid.css({'font-size':( getFontSize($content_grid)/$em * incr ) +'em'});
  2863. return;
  2864. }
  2865. if ( $content_pane.hasClass('has_font') ) {
  2866. $content_font.css({'font-size':( getFontSize($content_font)/$em * incr ) +'em'});
  2867. return;
  2868. }
  2869. }
  2870. // Scale Images
  2871. function scaleImages(incr, y) {
  2872. if (y === 'decrease' ) { incr = 1/incr; }
  2873. if ( $content_pane.hasClass('has_image') || $content_pane.hasClass('has_zoom_image') && !$content_pane.hasClass('has_grid') ) {
  2874. var $image_width = Math.round( $content_image.width() ) * incr; // increment image size
  2875. var $image_height = Math.round( $content_image.height() ) * incr; // increment image size
  2876. $content_pane.removeClass('has_zoom_image').addClass('has_image');
  2877. $content_image.css({'width':$image_width +'px', 'height': $image_height +'px', 'max-width':'none', 'max-height':'none' });
  2878. $content_container.scrollLeft( ( $image_width - $(window).width() )/2 ) ;
  2879. // if image is wider or taller than the window height, adjust position to enable scrolling:
  2880. if ( ( ( $image_width - $(window).width() )/2 ) > 0 ) { $content_image.css({'left':0}); } else { $content_image.css({'left':'unset'}); }
  2881. if ( ( ( $image_height - $(window).height() )/2 ) > 0 ) { $content_image.css({'top':0}); } else { $content_image.css({'top':'unset'}); }
  2882. return;
  2883. }
  2884. if ( $content_pane.hasClass('has_grid') && ( $content_grid.hasClass('has_image_grid') || $content_grid.hasClass('has_grid') ) ) {
  2885. let $image_grid_item_width = Number.parseFloat( $('.image_grid_item img').width(),10) * incr;
  2886. let $image_grid_item_height = Number.parseFloat( $('.image_grid_item img').height(),10) * incr;
  2887. let $image_grid_item_maxwidth = Number.parseFloat( $('.image_grid_item img').css('maxWidth'),10) * incr;
  2888. let $image_grid_item_maxheight = Number.parseFloat( $('.image_grid_item img').css('maxHeight'),10) * incr;
  2889. // prevent reducing grid image size on first scale click:
  2890. if ( $image_grid_item_width < $image_grid_item_maxwidth ) { $image_grid_item_width = $image_grid_item_maxwidth; }
  2891. if ( $image_grid_item_height < $image_grid_item_maxheight ) { $image_grid_item_height = $image_grid_item_maxheight; }
  2892. // set grid properties
  2893. $content_grid.css({'grid-template-columns':'repeat(auto-fill, minmax('+ ($image_grid_item_width +16) +'px, auto ) )'});
  2894. $content_grid.find('img').css({'max-width':( $image_grid_item_width ) +'px', 'max-height':( $image_grid_item_height ) +'px'});
  2895. return;
  2896. }
  2897. }
  2898. // Scale Fonts and Images
  2899. function scalePreviewItems(y) { // combine scaling into one function
  2900. scaleImages( 1.125, y );
  2901. scaleFonts( 1.125, y );
  2902. }
  2903. // Scale Content
  2904. $('#scale').on('click','span',function(e) {
  2905. e.preventDefault();
  2906. e.stopPropagation();
  2907. let val = ( $(this).attr('id') === 'increase' ? 'increase' : 'decrease' );
  2908. scalePreviewItems(val);
  2909. });
  2910. // Zoom Images on click
  2911. function zoomImage(e) {
  2912. const $this_link = $content_image.attr('src');
  2913. const $offset = $content_image.offset();
  2914. const $this_width = $content_image.width();
  2915. const $this_height = $content_image.height();
  2916. const percentX = ( e.pageX - $offset.left ) / $this_width;
  2917. const percentY = ( e.pageY - $offset.top ) / $this_height;
  2918.  
  2919. if ( ( $content_image.attr('style') !== '' || $content_image.attr('style') !== undefined ) ) { $content_image.attr('style',''); }
  2920. if ( $this_link !== undefined ) {
  2921. getDimensions( $this_link, function( width, height ) {
  2922. if ( width < $content_container.width() && height < $content_container.height() ) { // don't zoom small images
  2923. $content_pane.removeClass('has_zoom_image').addClass('has_image'); // remove zoom classes in case window resized after zoom
  2924. } else if ( width > $content_container.width() && height < $content_container.height() ) { // scroll-x to click position, center vertically
  2925. $content_pane.toggleClass('has_image has_zoom_image');
  2926. if ( $content_pane.hasClass('has_image') ) { $content_image.css({'margin-top':0}); } else { $content_image.css({'margin-top': ($content_container.height() - $content_image.height() )/2 }); }
  2927. $content_container.scrollLeft( width * percentX - ( $content_container.width() * percentX ) ) ;
  2928. } else if ( width < $content_container.width() && height > $content_container.height() ) { // center horizonally
  2929. $content_pane.toggleClass('has_image has_zoom_image');
  2930. if ( $content_pane.hasClass('has_image') ) { $content_image.css({'margin-left':0}); } else { $content_image.css({'margin-left': ($content_container.width() - $content_image.width() )/2 }); }
  2931. $content_container.scrollTop( height * percentY - ( $content_container.height() * percentY ) );
  2932. } else {
  2933. $content_pane.toggleClass('has_image has_zoom_image');
  2934. $content_container.scrollLeft( width * percentX - ( $content_container.width() * percentX ) ) ;
  2935. $content_container.scrollTop( height * percentY - ( $content_container.height() * percentY ) );
  2936. }
  2937. });
  2938. }
  2939. }
  2940. $content_image.on('click', function(e) {
  2941. zoomImage(e);
  2942. });
  2943. // ***** END SCALE PREVIEW ITEMS ***** //
  2944.  
  2945.  
  2946. // ***** AUDIO CONTENT ***** //
  2947. // Update Playlist
  2948. function updatePlaylist() {
  2949. let playlist = [];
  2950. $audio_files.not('.unchecked').each(function() {
  2951. playlist.push( thisID( $(this) ) );
  2952. });
  2953. return playlist;
  2954. }
  2955. // Randomize Shuffle List
  2956. function shuffleArray(array) {
  2957. for ( let i = array.length - 1; i > 0; i-- ) {
  2958. const j = Math.floor(Math.random() * (i + 1));
  2959. [array[i], array[j]] = [array[j], array[i]];
  2960. }
  2961. return array;
  2962. }
  2963. // Attach Shuffle List data to $audio_player
  2964. function updateShuffleList(id) {
  2965. if ( !$body.hasClass('shuffle_audio') ) {
  2966. return;
  2967. } else if ( id !== undefined ) { // don't include .playing and .unchecked track in shufflelist
  2968. let shuffleList = $audio_player.data('shufflelist');
  2969. if ( $(document.getElementById(id)).hasClass('unchecked') || $(document.getElementById(id)).hasClass('playing') ) {
  2970. shuffleList.splice(shuffleList.indexOf(id), 1);
  2971. $audio_player.data('shufflelist',shuffleList);
  2972. } else {
  2973. shuffleList.push(id);
  2974. shuffleList = shuffleArray( shuffleList );
  2975. }
  2976. } else {
  2977. let shuffleList = shuffleArray( updatePlaylist() );
  2978. $audio_player.data('shufflelist',shuffleList);
  2979. }
  2980. }
  2981.  
  2982. // Check/Uncheck Audio/Video Files
  2983. function toggleChecked(e) {
  2984. e.stopPropagation();
  2985. $(this).blur();
  2986. thisRow(this).toggleClass('unchecked');
  2987. updateShuffleList(thisRow(this).attr('id'));
  2988. }
  2989. $media_files.on('click','input', toggleChecked );
  2990. // Check/Uncheck all Audio/Video Files
  2991. function toggleAllChecked(e) {
  2992. e.stopPropagation();
  2993. $dir_list_row.find('input').trigger('click');
  2994. updateShuffleList();
  2995. }
  2996. $dir_list.find('#play_toggle').on('click', toggleAllChecked );
  2997.  
  2998. // Is Playing
  2999. function isPlaying(el) {
  3000. return (el !== undefined && el.get(0).currentTime > 0 && !el.get(0).paused && !el.get(0).ended); // returns true if all conditions are true
  3001. }
  3002. // Play Media
  3003. function playMedia(task) {
  3004. if ( $playing_file().hasClass('audio') ) { $audio_player.trigger(task); } else { $content_video.trigger(task); }
  3005. }
  3006. // Skip media tracks +/-10/30 seconds
  3007. function mediaSkip(e) {
  3008. const factor = ( e.key === 'ArrowLeft' ? -1 : 1 ); // forward or backward?
  3009. const skip = ( e.altKey && e.shiftKey ? 30 : e.altKey ? 10 : null ); // 30s or 10s?
  3010. const $player = ( $playing_file().hasClass('audio') ? $audio_player : $content_video ); // audio or video?
  3011. const time = $player.prop('currentTime'); // current time
  3012. $player.prop('currentTime', time + factor*(skip)); // set time
  3013. }
  3014.  
  3015. // Play/Pause Audio/Video
  3016. function playPauseMedia() {
  3017. let $player = ( $content_pane.hasClass('has_audio') ? $('#audio') : $('#content_video') );
  3018. if ( isPlaying( $player ) ) { $player.trigger('pause'); } else { $player.trigger('play'); }
  3019. }
  3020. // Play Next Track
  3021. function playPrevNextTrackBtn(el) {
  3022. let key = ( el.attr('id') === 'prev_track' ? 'ArrowLeft' : 'ArrowRight' );
  3023. playPrevNextTrack(key);
  3024. }
  3025. // Prev/Next Track buttons
  3026. $('.prev_next_track_btn').on( 'click', function() { playPrevNextTrackBtn( $(this) ); });
  3027.  
  3028. // Toggle Shuffle Play
  3029. $('#checkbox_div').on('click','#shuffle', function() {
  3030. $body.toggleClass('shuffle_audio');
  3031. updateShuffleList();
  3032. if ( $body.hasClass('shuffle_audio') && $('.playing').length === 0 ) {
  3033. playPrevNextTrack('ArrowRight');
  3034. } else {
  3035. // do nothing: i.e., allow current track to continue playing
  3036. }
  3037. });
  3038. // Toggle Loop Play
  3039. $('#checkbox_div').on('click','#loop', function() {
  3040. $body.toggleClass('loop_audio');
  3041. });
  3042.  
  3043. // Initialize Audio
  3044. function initMedia() {
  3045. $('#audio, #content_video').on('ended', function() {
  3046. playPrevNextTrack('ArrowRight');
  3047. scrollThis('tbody','playing');
  3048. });
  3049. }
  3050. // ***** END AUDIO PLAYBACK ***** //
  3051.  
  3052. // ***** IFRAME SETUP ***** //
  3053. // For directory display or editable text files
  3054. // If row is a directory, set up iFrameDirUI(); if it's an editable text document, set up iFrameTextEditingUI().
  3055. function setUpIframeUI(bool) {
  3056. if ( window.self !== window.top ) {
  3057. const $textFiles = $row_types.markdown.concat($row_types.text, $row_types.code); // define which files are editable
  3058. // if selected index item is a directory, set up the directory UI....
  3059. if ( window.location.pathname.endsWith('/') ) {
  3060. iFrameDirUI( $('#iframe_body') );
  3061. }
  3062. if ( JSON.parse(bool) === true && $textFiles.includes( window.location.pathname.slice( window.location.pathname.lastIndexOf('.') + 1 ) ) ) {
  3063. $iFrame_head.append('<style>'+ $text_editing_style_rules +'</style>');
  3064. $iFrame_head.append('<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/3.0.1/github-markdown.min.css"></link>');
  3065. let splitClass = ( getQuery('split_view') === 'true' ? 'split_view' : '' );
  3066. let viewClass = getQuery('default_text_view');
  3067. TextEditing( $('body:not(#top)') );
  3068. $iframe_body.removeClass().addClass(splitClass).addClass(viewClass).prepend($warnings);
  3069. $('#content_source').removeClass().prop('disabled',false);
  3070. }
  3071. }
  3072. }
  3073.  
  3074. // IFRAME DIRECTORY Prep
  3075. function iFrameDirUI(el) { // el = iframeBody
  3076. $iFrame_head.find('style').remove();
  3077. $iFrame_head.append('<style>'+ $iframe_styles +'</style>');
  3078.  
  3079. var parentLink = decodeURIComponentSafe(window.location.pathname);
  3080. parentLink = parentLink.split('/').slice(0,-2).join('/');
  3081. var parentLinkCell = '<tr id="parent"><th colspan=5><a href="'+ parentLink +'">Parent Directory</a></th></tr>';
  3082. var preppedIndex = makeNewIndex(el);
  3083. var iFrameTable = $('<table id="dir_list"><thead id="thead">'+ parentLinkCell +'</thead><tbody id="tbody"></tbody></table>');
  3084. // append prepped index
  3085. el.empty().append(iFrameTable).find('tbody').append(preppedIndex);
  3086. $('#iframe_body').find('#tbody').css({'top':$('#iframe_body').find('#thead').height() + 1 +'px'});
  3087. }
  3088. //***** TEXT EDITING PANE *****//
  3089. function textEditorUI(el) { //
  3090. if ( el.attr('id') === 'content_text' && $content_text.children().length === 0 ) { // only add UI once
  3091. $body.addClass('has_text');
  3092. $content_pane.removeClass('has_dir');
  3093. TextEditing($content_text);
  3094. el.find('#content_preview').html(el.find('#content_source').val()); // make sure any source text is also previewed.
  3095. if ( getQuery('split_view') === 'true' || getQuery('default_text_view') === 'source_text' ) { el.find('#content_source').focus(); }
  3096. } else { // show text editor
  3097. $body.addClass('has_text').removeClass('has_hidden_text');
  3098. }
  3099. setContentTitle();
  3100. setContentHeight();
  3101. }
  3102. // show text editor pane
  3103. $('#text_editor, #text_editor_row a').on('click', function(e) {
  3104. e.preventDefault();
  3105. textEditorUI($content_text);
  3106. });
  3107.  
  3108. // Main Text Editing Function
  3109. function TextEditing(container_el) { // container_el = $content_text or $content_iframe body
  3110. const $srctxt = ( container_el.find('> pre').length ? container_el.find('> pre').text() : container_el.html() ); // source text equals file content or nothing
  3111.  
  3112. MDbuildUI(container_el);
  3113.  
  3114. const $toolbar = container_el.find('#toolbar');
  3115. const $source = container_el.find('#content_source');
  3116. const $preview = container_el.find('#content_preview');
  3117. const $MDhandle = container_el.find('#text_editing_handle');
  3118.  
  3119. MDsetupTextEditingUI(container_el,$srctxt);
  3120. // Toolbar button functions
  3121. $toolbar.on('click','li,span',function(e) {
  3122. e.stopPropagation();
  3123. MDtoolBarFunctions($(this));
  3124. });
  3125. $(window).on('resize',function() {
  3126. $source.add($preview).add($MDhandle).attr('style','');
  3127. });
  3128. $('body#top').on('input', '#content_source', function() {
  3129. $source.add($preview).css({'height':$('#main_content').height() - $('#content_header').height() - 32 });
  3130. });
  3131.  
  3132. // Resize
  3133. $MDhandle.on('mousedown', function(e) {
  3134. e.stopPropagation();
  3135. MDresizeSplit($MDhandle,$source,$preview);
  3136. });
  3137. // Click labels to toggle checkboxes
  3138. $preview.add($toolbar).on('click','label', function(e) {
  3139. e.stopPropagation();
  3140. $(this).siblings('input').click();
  3141. });
  3142. // Sync scroll
  3143. $source.on('scroll',function() { MDsyncScroll(this); });
  3144. $preview.on('scroll',function() { MDsyncScroll(this); });
  3145.  
  3146. // TEXT EDITING
  3147. // Generate Preview
  3148. const $source_text = ( $source.length === 0 ? '' : $source.val() );
  3149. MDmarkdown( $source_text, $preview );
  3150.  
  3151. // Live preview update, and set edited classes for unsaved warning
  3152. $source.on('input', function() {
  3153. if ( !$('body').hasClass('edited') && $(this).parents('#top').length === 1 ) {
  3154. $('body#top').addClass('edited');
  3155. }
  3156. if ( !$('body').hasClass('edited') && $(this).parents('#iframe_body').length === 1 ) {
  3157. $('body#iframeBody').addClass('edited');
  3158. sendMessage('top','iframe_edited','','');
  3159. }
  3160. MDlivePreview($source,$preview);
  3161. });
  3162. // Checklists
  3163. MDsetChecklistClass();
  3164. // Live checkboxes
  3165. $preview.on('click','.checklist input',function(e) {
  3166. e.stopPropagation();
  3167. MDliveCheckBoxes($(this),$source,$preview);
  3168. });
  3169. // Preview TOC click navigation
  3170. $preview.on('click','.table-of-contents a',function(e) {
  3171. e.preventDefault();
  3172. MDtocClick($(this),$preview);
  3173. });
  3174. $preview.on('click','.uplink',function(e) {
  3175. e.stopPropagation();
  3176. MDheaderClick($preview);
  3177. });
  3178. }
  3179. ///// END MAIN MD FUNCTION
  3180.  
  3181. // MARKDOWN Functions
  3182. // MD Build UI
  3183. function MDbuildUI(container_el) {
  3184. const toggleSplitBtn = $('<li id="toggle_split" title="Toggle Split"></li>');
  3185. const syncScrollEl = $('<li id="sync_scroll"><input name="sync_scroll" type="checkbox"><label for="sync_scroll">Sync Scroll</label></li>');
  3186. const toggleSrcBtn = $('<li id="show_source" title="Show Source"></li>');
  3187. const togglePreviewBtn = $('<li id="show_preview" title="Show Preview"></li>');
  3188. const clearTextBtn = $('<li id="clear_text" title="Clear Text">Clear</li>');
  3189. const saveBtn = $('<li id="save_btn" title=""><div><span id="save_text"><a target="_blank">Save Source</a></span><span id="save_HTML">Save HTML</span></div></li>');
  3190. const buttonsCont = $('<ul id="toolbar"></ul>');
  3191. buttonsCont.append(toggleSrcBtn, togglePreviewBtn, toggleSplitBtn, syncScrollEl, saveBtn, clearTextBtn);
  3192. const textEditingUI = '<textarea id="content_source"></textarea><div id="content_preview" class="markdown-body"></div><div id="text_editing_handle"></div>';
  3193. // append the UI to the container_el
  3194. container_el.prepend(buttonsCont).append(textEditingUI);
  3195. }
  3196.  
  3197. // MD Set up UI
  3198. function MDsetupTextEditingUI(container_el,sourceText) {
  3199. container_el.find('pre').first().remove();
  3200. container_el.find('#content_source').val(sourceText); // set source text from pre
  3201. if ( getQuery('split_view') === 'true' ) { $('body').addClass('split_view'); } else { $('body').removeClass('split_view'); }
  3202. if ( getQuery('default_text_view') === 'preview' ) { $('body').addClass('preview_text').removeClass('source_text'); } else { $('body').addClass('source_text').removeClass('preview_text'); }
  3203. if ( getQuery('sync_scroll') === 'true' ) { $('#sync_scroll input').prop({checked:true}); }
  3204. }
  3205. // MD UI Buttons functions
  3206. function MDtoolBarFunctions(btn) {
  3207. let $thisFileName;
  3208. let container_el = btn.closest('body');
  3209. let sourceEl = container_el.find('#content_source');
  3210. let previewEl = container_el.find('#content_preview');
  3211. if ( $body.hasClass('has_text') ) {
  3212. $thisFileName = 'untitled';
  3213. } else {
  3214. $thisFileName = decodeURI(window.location.pathname.slice(window.location.pathname.lastIndexOf('/') + 1));
  3215. }
  3216. const $thisId = btn.attr('id');
  3217. const $saveHTMLOpen = '<!DOCTYPE html><html><head><title></title><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/3.0.1/github-markdown.min.css"></link><style></style><script></script></head><body lang="en" class="markdown-body">';
  3218. const $saveHTMLClose = '</body></html>';
  3219. switch ($thisId) {
  3220. case 'toggle_split':
  3221. $('body').toggleClass('split_view').find('#content_source,#content_preview,#text_editing_handle').attr('style','');
  3222. if ( container_el.hasClass('source_text') ) {
  3223. sourceEl.focus();
  3224. document.getElementById('content_source').setSelectionRange(0,0);
  3225. }
  3226. break;
  3227. case 'show_source':
  3228. container_el.removeClass('split_view preview_text').addClass('source_text').find('#content_source,#content_preview,#text_editing_handle').attr('style',''); // remove styles in case split has been resized
  3229. sourceEl.css({'width':'100%'}).focus();
  3230. document.getElementById('content_source').setSelectionRange(0,0);
  3231. break;
  3232. case 'show_preview':
  3233. container_el.removeClass('split_view source_text').addClass('preview_text').find('#content_source,#content_preview,#text_editing_handle').attr('style','');
  3234. break;
  3235. case 'clear_text':
  3236. container_el.addClass('has_warning').find('#warnings').removeClass().addClass('clear');
  3237. break;
  3238. case 'save_text':
  3239. saveMD( $thisFileName, sourceEl.val() );
  3240. break;
  3241. case 'save_HTML':
  3242. saveMD( $thisFileName.slice(0,$thisFileName.lastIndexOf('.') + 1) + 'html', $saveHTMLOpen + MDprepHTML(previewEl.html()) + $saveHTMLClose );
  3243. break;
  3244. }
  3245. }
  3246. // MD Custom pre- and post-processing for text.
  3247. function MDaddHeaderIDs(match, p1, p2, p3, offset, string) { // create header ids for TOC
  3248. return '<h'+ p1 +' id="'+ p3.toLowerCase().replace(/\s/g,'-') +'" ' + p2 +'>'+ p3;
  3249. }
  3250. function MDcustomPreProcess(src) {
  3251. return src; // we're not doing anything here just yet...
  3252. }
  3253. function MDcustomPostProcess(html) {
  3254. html = html.replace(/<(p|li|dt|dd)>\-*\s*\[\s*x\s*\]\s*(.+?)<\/(p|li|dt|dd)>$/gm,'<$1 class="checklist"><input type="checkbox" checked><label>$2</label></$3>') // checkboxes in p,li,dt,dd
  3255. .replace(/<(p|li|dt|dd)>-*\s*\[\s{1,}\]\s*(.+?)<\/(p|li|dt|dd)>$/gm,'<$1 class="checklist"><input type="checkbox"><label>$2</label></$3>') // checkboxes
  3256. // .replace(/<li><p class="checklist">"/g,'<li class="checklist"><p>')
  3257. .replace(/^<h(\d)([^>]*)>([^<]+)/gm, MDaddHeaderIDs) // add header IDs;
  3258. .replace(/<\/h(\d)>/g,'<span class="uplink">&uarr;</span></h$1>');
  3259. return html;
  3260. }
  3261. //MD Render markdown from preprocessed source text
  3262. function MDmarkdown(sourceText,previewEl) {
  3263. const MDit = window.markdownit({linkify:false,typography:false,html:true})
  3264. .use(window.markdownitMultimdTable, {enableMultilineRows: true})
  3265. .use(window.markdownitSub)
  3266. .use(window.markdownitSup)
  3267. .use(window.markdownitFootnote)
  3268. .use(window.markdownitCentertext)
  3269. .use(window.markdownitDeflist)
  3270. .use(window.markdownitTocDoneRight)
  3271. ;
  3272. let MDpreview = MDit.render( MDcustomPreProcess( sourceText ) );
  3273. previewEl.html( MDcustomPostProcess( MDpreview ) ); // set previewed html
  3274. }
  3275. // MD Live preview, add edited warning
  3276. function MDlivePreview(sourceEl,previewEl) {
  3277. MDmarkdown( sourceEl.val(),previewEl );
  3278. MDsetChecklistClass();
  3279. }
  3280.  
  3281. // MD Live Checkboxes prep: find each instance of [ ] or [x] and replace text in index = to clicked checkbox in Preview.
  3282. function MDreplaceAt(str, replacement, position) {
  3283. str = str.substring(0, position) + replacement + str.substring(position + replacement.length);
  3284. return str;
  3285. }
  3286. function MDreplaceNthSubStr(str,substr,replacement,index) {
  3287. let count = 0;
  3288. let found = substr.exec(str);
  3289. while ( found !== null ) {
  3290. if ( count === index ) {
  3291. return MDreplaceAt(str, replacement, found.index );
  3292. } else {
  3293. count++;
  3294. found = substr.exec(str);
  3295. }
  3296. }
  3297. }
  3298. // MD Live Checkboxes
  3299. function MDliveCheckBoxes(checkbox,sourceEl,previewEl) {
  3300. $('.checklist').removeClass('clicked');
  3301. checkbox.closest('p,li,dt,dd').addClass('clicked');
  3302. const thisIndex = previewEl.find('.checklist').index( $('.clicked') );
  3303. const srctext = sourceEl.val();
  3304. const substr = new RegExp(/\[\s*.\s*\]/g);
  3305. const replacement = ( checkbox.is(':checked') ? '[x]' : '[ ]' );
  3306. sourceEl.val( MDreplaceNthSubStr(srctext, substr, replacement, thisIndex) );
  3307. }
  3308. // MD Checkbox list class: Prevent checkbox lists from having list bullets
  3309. function MDsetChecklistClass() {
  3310. $('input[type="checkbox"]').closest('ul').addClass('no_list');
  3311. }
  3312.  
  3313. // MD Resize Split View
  3314. function MDresizeSplit(handle,sourceEl,previewEl) {
  3315. let $sidebarWidth = $('#sidebar').outerWidth();
  3316. let $pageWidth = window.innerWidth;
  3317.  
  3318. $(document).on('mousemove',function(e) {
  3319. e.stopPropagation();
  3320. e.preventDefault();
  3321. let pageX = e.pageX;
  3322. if ( pageX > $sidebarWidth + 100 && pageX < $pageWidth - 100 ) { // min widths
  3323. handle.css({'left': pageX - $sidebarWidth - 4 + 'px'});
  3324. sourceEl.css({'width': pageX - $sidebarWidth + 'px'});
  3325. previewEl.css({'left': sourceEl.outerWidth() + 'px'});
  3326. }
  3327. });
  3328. handle.on('mouseup',function() {
  3329. $(document).off('mousemove');
  3330. });
  3331. }
  3332. // MD UI Sync Scroll
  3333. function MDpercentage(el) { return (el.scrollTop / (el.scrollHeight - el.offsetHeight)); }
  3334. function MDsyncScroll(el1) {
  3335. let el2 = ( el1.getAttribute('id') === 'content_preview' ? document.getElementById('content_source') : document.getElementById('content_preview') );
  3336. if ( document.querySelector('input[name="sync_scroll"').checked ) {
  3337. el2.scrollTo( 0, (MDpercentage(el1) * (el2.scrollHeight - el2.offsetHeight)).toFixed(0) ); // toFixed(0) prevents scrolling feedback loop
  3338. }
  3339. }
  3340. // click TOC anchors
  3341. function MDtocClick(el,previewEl) {
  3342. let thisId = el.attr('href');
  3343. if ( thisId ) {
  3344. previewEl.scrollTop( $(thisId).offset().top - 48 );
  3345. }
  3346. }
  3347. // click Headers to return to TOC or top
  3348. function MDheaderClick(previewEl) {
  3349. if ( previewEl.find('.table-of-contents').length > 0 ) {
  3350. document.getElementsByClassName('table-of-contents')[0].scrollIntoView(true);
  3351. } else {
  3352. document.getElementById('preview').scroll(0,0);
  3353. }
  3354. }
  3355. // MD Clear text source
  3356. function clearText(container_el) {
  3357. if ( window.top !== window.self ) { // if iframe, send message to top (to remove iframe_edited class)
  3358. sendMessage('top','clear');
  3359. }
  3360. container_el.find('#content_source').show().focus().val('');
  3361. container_el.find('#content_preview').empty();
  3362. container_el.removeClass('edited has_warning');
  3363. }
  3364. // MD SAVE SOURCE or HTML
  3365. function MDprepHTML(data) {
  3366. data = data.replace(/<span\sclass="uplink">.<\/span>/g,'');
  3367. return data;
  3368. }
  3369. function saveMD(filename, data) {
  3370. let blob = new Blob([data], {type: 'text/plain'});
  3371. let downloadEl = window.document.createElement('a');
  3372. downloadEl.href = window.URL.createObjectURL(blob);
  3373. downloadEl.download = filename;
  3374. document.body.appendChild(downloadEl);
  3375. downloadEl.click();
  3376. document.body.removeChild(downloadEl);
  3377. URL.revokeObjectURL(blob);
  3378. if ( window.top !== window.self ) { // if iframe, send message to top
  3379. sendMessage('top','clear');
  3380. }
  3381. $('body,#content_source,#content_text').removeClass('edited');
  3382. }
  3383. // list of functions to remember while sending messages and then execute after warning button click
  3384. function doFunction(funcName,args) {
  3385. var funcDictionary = { 'setLocation':setLocation, 'resetContent':resetContent, 'closeContent':closeContent, 'clickThis':clickThis, 'clickRow':clickRow, 'doubleClickRow':doubleClickRow, 'indexNavigation':indexNavigation, 'clearText':clearText, 'null':null };
  3386. return funcName === 'null' ? null : funcDictionary[funcName](args);
  3387. }
  3388. // Show warning after certain user actions if text editor or iframe has edited text; otherwise do the action.
  3389. function showWarning(funcName,args) {
  3390. // Don't show the warning if func = indexNavigation or clickRow; i.e., just hide text editor;
  3391. // In other words, only show warning when changing directories or if iframe content has been edited
  3392. if ( ( $('body').hasClass('edited') && funcName !== 'indexNavigation' && funcName !== 'clickRow' ) || $('body').hasClass('iframe_edited') ) {
  3393. if ( $('body').hasClass('edited') ) { // show warning and text editor (if hidden)
  3394. $body.addClass('has_warning').find('#warnings').removeClass().addClass('unloading');
  3395. $body.removeClass('has_hidden_text').addClass('has_text');
  3396. }
  3397. if ( $('body').hasClass('iframe_edited') ) { // if iframe is edited, send unloading message
  3398. sendMessage('iframe','unloading',funcName,args); // upon receipt of message, iframe will show its warning message, based on the funcName
  3399. }
  3400. } else {
  3401. doFunction(funcName,args);
  3402. }
  3403. }
  3404. // Send a message to iframe or parent
  3405. function sendMessage(target,message,funcName,args) {
  3406. var messageObj = { 'messageContent': message, 'functionName': funcName, 'arguments': args };
  3407. if ( target === 'iframe' ) {
  3408. let contentIFrame = document.getElementById('content_iframe');
  3409. contentIFrame.contentWindow.postMessage( messageObj, '*' );
  3410. }
  3411. if ( target === 'top' ) {
  3412. window.parent.postMessage( messageObj, '*');
  3413. }
  3414. }
  3415. // Receive a message from iframe or parent, do appropriate action
  3416. function receiveMessage(e) {
  3417. if ( e.origin === 'null' || e.origin === $origin ) {
  3418. let $message = e.data.messageContent;
  3419. let funcName = e.data.functionName;
  3420. let args = e.data.arguments;
  3421.  
  3422. if ( $message === 'split_view' ) {
  3423. $iframe_body.toggleClass('split_view');
  3424. }
  3425. if ( $message === 'default_text_view' ) {
  3426. $iframe_body.toggleClass('preview_text source_text').removeClass('split_view');
  3427. }
  3428. // warn iframe that user wants to change iframes
  3429. // use separate function to warn when $content_text.edited
  3430. if ( $message === 'unloading' && !$iframe_body.hasClass('has_warning') ) {
  3431. $iframe_body.addClass('has_warning').find('#warnings').removeClass().addClass('unloading').attr('data-function_name',funcName).attr('data-args',args);
  3432. }
  3433. // let top know iframe text has been edited
  3434. if ( $message === 'iframe_edited' && !$('body#top').hasClass('iframe_edited') ) {
  3435. $('body#top').addClass('iframe_edited');
  3436. }
  3437. if ( $message === 'ignore' || $message === 'clear' ) {
  3438. $('body#top').removeClass('iframe_edited');
  3439. if ( $message === 'ignore' ) { doFunction(funcName,args); }
  3440. }
  3441. }
  3442. }
  3443. window.addEventListener('message',receiveMessage,false);
  3444.  
  3445. // Edited Warning buttons: what to do when the user clicks a warning button
  3446. function editedWarningButtons(id) {
  3447. let btn = $(document.getElementById(id));
  3448. let container_el = btn.closest('body');
  3449. let func = $('#warnings').attr('data-function_name');
  3450. let args = $('#warnings').attr('data-args');
  3451. switch(id) {
  3452. case 'warning_ignore_btn': // do the user initiated func without saving the edited text
  3453. if ( window.self !== window.top ) { // if iframe, send message to top
  3454. sendMessage('top','ignore',func,args);
  3455. }
  3456. container_el.removeClass('edited has_text has_warning');
  3457. clearText(container_el);
  3458. break;
  3459. case 'warning_cancel_btn': // cancel the func
  3460. container_el.removeClass('has_warning').find('#warnings').removeClass();
  3461. break;
  3462. case 'warning_clear_btn': // clear the text editor
  3463. clearText(container_el);
  3464. break;
  3465. case 'warning_save_btn': // save the text
  3466. if ( window.top !== window.self ) { // if iframe, send message to top
  3467. sendMessage('top','clear');
  3468. }
  3469. container_el.removeClass('edited has_warning');
  3470. $('#save_text').click();
  3471. break;
  3472. case 'warning_ok_btn': // clear the text editor
  3473. $('body').removeClass('has_warning').find('#warnings').removeClass('local');
  3474. break;
  3475. }
  3476. }
  3477. $('#warnings').on('click','button',function(e) {
  3478. e.preventDefault();
  3479. editedWarningButtons( $(this).attr('id') );
  3480. });
  3481. // Edited Warning overlay: prevent user clicks on rest of UI
  3482. $('#overlay').on('click mousedown mouseup',function(e) {
  3483. e.preventDefault();
  3484. e.stopPropagation();
  3485. return;
  3486. });
  3487.  
  3488. // END Text Editing
  3489.  
  3490. })();
  3491. // THE END!