Swiches Client Web app from Blazor to ASP.NET Core MVC

This commit is contained in:
BinaryAlley committed 2024-10-02 22:19:14 +03:00
1 parent cf94676666
commit 9a7d4c607d
35 files changed
+4066 -1853

No files matched your search

@@ -1,61 +0,0 @@
#blazor-error-ui {
background: lightyellow;
bottom: 0;
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
display: none;
left: 0;
padding: 0.6rem 1.25rem 0.7rem 1.25rem;
position: fixed;
width: 100%;
z-index: 1000;
}
#blazor-error-ui .dismiss {
cursor: pointer;
position: absolute;
right: 0.75rem;
top: 0.5rem;
}
.blazor-error-boundary {
background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
padding: 1rem 1rem 1rem 3.7rem;
color: white;
}
.blazor-error-boundary::after {
content: "An error has occurred."
}
.loading-progress {
position: relative;
display: block;
width: 8rem;
height: 8rem;
margin: 20vh auto 1rem auto;
}
.loading-progress circle {
fill: none;
stroke: #e0e0e0;
stroke-width: 0.6rem;
transform-origin: 50% 50%;
transform: rotate(-90deg);
}
.loading-progress circle:last-child {
stroke: #1b6ec2;
stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
transition: stroke-dasharray 0.05s ease-in-out;
}
.loading-progress-text {
position: absolute;
text-align: center;
font-weight: bold;
inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}
.loading-progress-text:after {
content: var(--blazor-load-percentage-text, "Loading");
}
@@ -0,0 +1,161 @@
.abort-button {
text-decoration: none;
border-radius: 4px;
border: solid 1px;
border-color: #006666 #004030 #003020 #006666;
background: linear-gradient(to bottom, #90AEA6 0%, #336659 50%, #004030 50%, #004030 100%);
color: #999999;
position: relative;
overflow: hidden;
transition: all 0.3s;
cursor: pointer;
outline: none;
box-shadow: 0 4px 4px rgba(0, 0, 0, 0.5);
z-index: 1;
}
.abort-button:before {
content: "";
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 50%;
background: radial-gradient(circle at center, #00FF00, transparent);
background-size: 120% 100%;
transform: translateY(100%);
background-position: center;
transition: transform 0.3s, opacity 0.8s;
pointer-events: none;
opacity: 0;
filter: blur(8px);
}
.abort-button:hover {
color: #fff;
}
.abort-button:hover:before {
transform: translateY(50%);
opacity: 1;
}
.abort-button:active {
background: #CC009F58;
font-style: italic;
}
.abort-button:disabled {
background: #333333;
border-color: #333333;
color: #777;
cursor: not-allowed;
}
.abort-button:disabled:hover:before {
transform: translateY(100%);
opacity: 0;
}
.abort-button:disabled:active {
font-style: normal;
}
.abort-button[disabled] {
background: #333333;
border-color: #333333;
color: #777;
cursor: not-allowed;
pointer-events: none;
text-decoration: none;
}
.abort-button[disabled]:hover:before {
transform: translateY(100%);
opacity: 0;
}
.abort-button[disabled]:active {
font-style: normal;
}
.confirm-button {
text-decoration: none;
border-radius: 4px;
border: solid 1px;
border-color: #363636 #000 #000 #363636;
background: linear-gradient(to bottom, #AAAAAA 0%, #363636 50%, #000 50%, #000 100%);
color: #AAAAAA;
position: relative;
overflow: hidden;
transition: all 0.3s;
cursor: pointer;
outline: none;
box-shadow: 0 4px 4px rgba(0, 0, 0, 0.5);
z-index: 1;
}
.confirm-button:before {
content: "";
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 50%;
background: radial-gradient(circle at center, #00FF8B, transparent);
background-size: 120% 100%;
transform: translateY(100%);
background-position: center;
transition: transform 0.3s, opacity 0.8s;
pointer-events: none;
opacity: 0;
filter: blur(8px);
}
.confirm-button:hover {
color: #fff;
}
.confirm-button:hover:before {
transform: translateY(50%);
opacity: 1;
}
.confirm-button:active {
background: #CC000000;
font-style: italic;
}
.confirm-button:disabled {
background: #333333;
border-color: #333333;
color: #777;
cursor: not-allowed;
}
.confirm-button:disabled:hover:before {
transform: translateY(100%);
opacity: 0;
}
.confirm-button:disabled:active {
font-style: normal;
}
confirm-button[disabled] {
background: #333333;
border-color: #333333;
color: #777;
cursor: not-allowed;
pointer-events: none;
text-decoration: none;
}
.confirm-button[disabled]:hover:before {
transform: translateY(100%);
opacity: 0;
}
.confirm-button[disabled]:active {
font-style: normal;
}
@@ -0,0 +1,6 @@
namespace Lumina.Presentation.Web.wwwroot.css
{
public class checkbox
{
}
}
@@ -0,0 +1,154 @@
.enlightenment-combobox {
position: relative;
font-family: Arial, sans-serif;
padding: 0;
margin: 0;
box-sizing: border-box;
}
.enlightenment-toggle-checkbox {
display: none;
}
.enlightenment-toggle {
display: flex;
align-items: center;
justify-content: space-between;
cursor: pointer;
font-family: Arial, sans-serif;
font-size: 14px;
border-radius: 3px;
box-shadow: 0 0 3px rgba(0, 0, 0, 0.5);
color: #6DCBFE;
padding: 3px 24px 3px 18px;
width: 100%;
border: none;
outline: none;
appearance: none;
border-top: #989898 1px solid;
border-bottom: #151515 1px solid;
border-left: #878787 1px solid;
border-right: #202020 1px solid;
background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2212%22%20height%3D%225%22%3E%3Cpath%20fill%3D%22none%22%20stroke%3D%22%23fff%22%20stroke-width%3D%222%22%20d%3D%22M2%2C0L6%2C4L10%2C0%22%2F%3E%3C%2Fsvg%3E'), url('../images/ui/scrollbar_dots_v.png'), linear-gradient(180deg, #606060, #555555, #4C4C4C, #414141);
background-repeat: no-repeat, no-repeat, repeat;
background-position: right 10px top 50%, left 7px top 50%, 0 0;
background-size: 12px 6px, 3px auto, 100%;
user-select: none;
box-sizing: border-box;
}
.enlightenment-toggle:hover {
background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2212%22%20height%3D%225%22%3E%3Cpath%20fill%3D%22none%22%20stroke%3D%22%23fff%22%20stroke-width%3D%222%22%20d%3D%22M2%2C0L6%2C4L10%2C0%22%2F%3E%3C%2Fsvg%3E'), url('../images/ui/scrollbar_dots_lit_v.png'), linear-gradient(180deg, #606060, #555555, #4C4C4C, #414141);
background-repeat: no-repeat, no-repeat, repeat;
background-position: right 10px top 50%, left 7px top 50%, 0 0;
background-size: 12px 6px, 3px auto, 100%;
}
.enlightenment-selected-text {
flex: 1;
text-align: right;
}
.enlightenment-dropdown {
display: none;
position: absolute;
top: 100%;
left: 0;
width: 100%;
box-sizing: border-box;
background-image: url('../images/ui/metal-plate.png'), linear-gradient(180deg, #505050, #464646, #404040, #363636);
background-repeat: repeat, no-repeat;
background-position: 3px 3px, 0 0; /* offset the metal-plate image by 3 pixels from the top and left */
background-clip: content-box, border-box; /* clip the metal-plate image to the content box */
border-top: #989898 1px solid;
border-bottom: #151515 1px solid;
border-left: #878787 1px solid;
border-right: #202020 1px solid;
padding: 3px;
z-index: 999;
max-height: none;
overflow-y: auto;
}
.enlightenment-dropdown > .shine-effect:first-child {
top: -4px;
}
.enlightenment-item {
display: block;
border-left: 1px solid #232323;
border-right: 1px solid #777777;
border-top: 1px solid #232323;
border-bottom: 1px solid #777777;
color: #FFFFFF;
padding: 5px 10px;
width: 100%;
box-sizing: border-box;
user-select: none;
cursor: pointer;
}
.enlightenment-item.first-item {
border-top: 1px solid #232323;
margin-top: -1px;
}
.enlightenment-item.last-item {
border-bottom: 1px solid #777777;
}
.enlightenment-item.disabled {
color: #AAAAAA;
}
.enlightenment-item:hover {
background-image: none;
background: linear-gradient(to bottom, #505050, #464646, #404040, #363636);
color: #1D8AF9;
box-shadow: inset 1px 0 0 0 #777777, inset -1px 0 0 0 #232323, inset 0 1px 0 0 #989898, inset 0 -1px 0 0 #151515;
}
.enlightenment-combobox.open .enlightenment-dropdown {
display: block;
}
.enlightenment-combobox > .shine-effect:first-child {
top: 1px;
opacity: 0;
transition: opacity 0.5s;
}
.enlightenment-combobox:hover > .shine-effect:first-child {
opacity: 1;
}
.enlightenment-combobox > .shine-effect::before,
.enlightenment-combobox > .shine-effect::after {
content: "";
position: absolute;
top: -1px;
left: 50%;
transform: translateX(-50%);
opacity: 0;
transition: opacity 0.5s;
}
.enlightenment-combobox > .shine-effect::before {
width: 3px;
height: 2px;
border-radius: 5px 5px 0 0;
background-color: #FFFFFF;
}
.enlightenment-combobox > .shine-effect::after {
width: 10px;
height: 3px;
border-radius: 5px 5px 0 0;
background-color: #FFFFFF;
filter: blur(3px);
}
.enlightenment-combobox:hover > .shine-effect::before,
.enlightenment-combobox:hover > .shine-effect::after {
opacity: 1;
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,78 @@
.tree-node {
padding: 2px 0;
}
.node-content {
display: flex;
align-items: flex-start;
cursor: pointer;
padding: 0px;
border-radius: 2px;
border: 1px solid transparent;
flex-wrap: wrap;
min-width: 100%;
display: inline-block;
white-space: nowrap;
}
.node-content:hover {
background-color: #131313;
border-top: 1px solid var(--border-color-light);
border-left: 1px solid var(--border-color-light);
border-right: 1px solid var(--border-color-dark);
background-color: var(--container-background);
}
.node-content.selected {
background-color: #131313;
border-bottom: 1px solid var(--border-color-light);
border-right: 1px solid var(--border-color-light);
border-left: 1px solid var(--border-color-dark);
background-color: var(--container-background);
}
.node-icon {
margin-right: 5px;
width: 16px;
text-align: center;
flex-shrink: 0;
}
.node-icon, .expand-button {
flex-shrink: 0;
align-self: center;
}
.child-nodes {
padding-left: 20px;
border-left: 1px dotted #ccc;
margin-left: 7px;
}
.expand-button {
display: inline-flex;
width: 10px;
height: 10px;
margin-right: 5px;
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='%231E90FF' d='M6 4l4 4-4 4z'/></svg>");
background-size: contain;
transition: transform 0.2s ease;
}
.expand-button.expanded {
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='%23f00' d='M6 4l4 4-4 4z'/></svg>");
transform: rotate(90deg);
}
.spacer {
display: inline-block;
width: 15px;
}
.node-name {
margin-left: 3px;
overflow-wrap: break-word;
word-break: break-all;
flex: 1;
align-self: end;
}
@@ -0,0 +1,344 @@
.overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
visibility: hidden;
transition: opacity 0.50s, visibility 0.50s, height 0.50s;
-webkit-transition: opacity 0.50s, visibility 0.50s, height 0.50s;
overflow: hidden;
background: black;
z-index: -1;
}
#hamburger-input {
display: none;
}
#hamburger-menu {
cursor: pointer;
position: fixed;
border-radius: 4px;
border: 1px solid #777777;
border-bottom-color: #000000;
border-right-color: #000000;
top: 10px;
left: 10px;
width: 46px;
height: 46px;
display: none;
z-index: 2;
padding: 5px 0;
margin: 0px;
font-family: 'Cabin', Sans-serif;
background: linear-gradient(to top, #424343 0%, #505050 50%, #5E5D5D 100%);
}
#hamburger-menu > span {
display: block;
width: 30px;
height: 4px;
margin: 6px auto;
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.4));
border-radius: 2px;
box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.2), 0 1px 0 rgba(255, 255, 255, 0.2);
}
#hamburger-menu:hover {
background: linear-gradient(to top, #505050 0%, #5E5D5D 50%, #6A6969 100%);
}
#hamburger-menu:hover > span {
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.5));
box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.3);
}
#hamburger-menu #mobile-menu {
visibility: hidden;
position: fixed;
margin: 0px;
top: 0;
left: -100%;
width: 100%;
border: 1px solid #777777;
border-bottom-color: #000000;
border-right-color: #000000;
overflow: auto;
color: #6DCBFE;
text-align: center;
background: #4F4F4F;
transition: 0.50s;
-webkit-transition: 0.50s;
padding: 0px 10px;
box-sizing: border-box;
}
#mobile-menu-content {
border: 1px solid #777777;
border-top-color: #000000;
border-left-color: #000000;
margin-top: 4px;
margin-left: -6px;
margin-right: -5px;
margin-bottom: 3px;
color: #6DCBFE;
text-align: center;
font-size: 18px;
font-family: 'Trebuchet MS', 'Lucida Grande', Verdana, Arial, Sans-Serif;
font-weight: bold;
text-shadow: 0px 0px 2px rgba(0,0,0,1);
/*background: #000 url(../images/metal-plate.png);*/
}
.mobile-menu-heading {
height: 35px;
font-size: 28px;
background: rgb(10, 11, 11);
border: 1px solid #777777;
border-bottom-color: #000000;
border-right-color: #000000;
width: 100%;
background-image: linear-gradient(180deg, #505050, #464646, #404040, #363636);
}
#hamburger-menu ul {
margin-left: 0px;
margin-top: 0px;
margin-bottom: 0px;
padding: 0px;
width: 100%;
}
#hamburger-menu li {
width: 100%;
list-style-type: none;
line-height: 2rem;
display: flex;
font-weight: normal;
font-size: 10px;
text-shadow: none;
text-align: left;
border: 1px solid #333333;
border-bottom-color: #000000;
border-right-color: #000000;
}
#hamburger-menu li:nth-child(even) {
background-color: #191E21;
}
#hamburger-menu li:nth-child(odd) {
background-color: #28292B;
}
#hamburger-menu a {
padding-left: 5px;
width: 100%;
color: #6DCBFE;
font-weight: normal;
font-size: 18px;
font-family: 'Arial';
text-decoration: none;
display: inline-block;
margin-left: 0.3em;
}
#hamburger-menu a:focus,
#hamburger-menu a:active {
color: #7CACF8;
}
#hamburger-menu a:hover {
color: #FFFFFF;
background: rgb(10, 11, 11);
background-image: linear-gradient(180deg, #505050, #464646, #404040, #363636);
}
#hamburger-input:checked + #hamburger-menu {
background: linear-gradient(to bottom, #424343 0%, #505050 50%, #5E5D5D 100%);
border: 1px solid #777777;
border-top: 1px solid #000000;
border-left: 1px solid #000000;
}
#hamburger-input:checked + #hamburger-menu #mobile-menu {
visibility: visible;
left: 0;
top: 71px;
}
#hamburger-input:checked + #hamburger-menu {
z-index: 2;
}
#hamburger-input:checked ~ .overlay {
visibility: visible;
opacity: 0.5;
z-index: 1;
}
.menubar {
background: linear-gradient( to bottom, #505050 0%, #464646 35%, #404040 55%, #363636 100% );
padding: 0;
position: fixed;
top: 0px;
left: 0px;
width: 100%;
z-index: 900;
}
.menubar ul {
list-style-type: none;
margin: 0;
padding: 0;
}
.menubar > ul > li {
display: inline-block;
position: relative;
}
.menubar label,
.menubar a {
display: block;
padding: 2px 10px;
text-decoration: none;
cursor: default;
color: #6DCBFE;
position: relative;
user-select: none;
border: 1px solid transparent;
}
.menubar > ul > li > label:hover,
.menubar > ul > li > a:hover {
background: linear-gradient( to bottom, #505050 0%, #464646 35%, #404040 55%, #363636 100% );
border-left: 1px solid #777777;
border-right: 1px solid #000000;
border-top: 1px solid #505050;
border-bottom: 1px solid #222222;
color: #FFFFFF;
}
.menubar input[type="radio"] {
display: none;
}
.menubar ul ul {
display: none;
position: absolute;
top: 100%;
left: 0;
min-width: 150px;
background: #4F4F4F;
border: 1px solid #777777;
border-bottom-color: #000000;
border-right-color: #000000;
padding-top: 4px;
padding-left: 4px;
padding-bottom: 4px;
padding-right: 4px;
}
.menubar ul ul li {
background: #232323;
border-left: 1px solid #000000;
border-right: 1px solid #777777;
position: relative;
}
.menubar ul ul li:first-child {
border-top: 1px solid #000000;
}
.menubar ul ul li:last-child {
border-bottom: 1px solid #777777;
}
.menubar ul ul li > label:hover,
.menubar ul ul li > a:hover {
background: linear-gradient( to bottom, #505050 0%, #464646 35%, #404040 55%, #363636 100% );
border: 1px solid #777777;
border-right-color: #000000;
border-bottom-color: #000000;
color: #FFFFFF;
}
.menubar ul ul ul {
left: 100%;
top: 0;
}
.menubar li:focus-within > ul {
display: block;
outline: none;
}
.menubar > ul > li:focus-within > label,
.menubar > ul > li:focus-within > a {
background-color: #28292B;
background: radial-gradient( 115% 115% at 68% 70%, #30303088 0%, #20202044 50%, #101010 100% );
border: 1px solid #777777;
border-top: 1px solid #000000;
border-left: 1px solid #000000;
color: #FFFFFF;
}
.menubar .has-submenu > label::after,
.menubar .has-submenu > a::after {
content: " ▶";
font-size: 0.6em;
position: absolute;
right: 5px;
top: 50%;
transform: translateY(-50%);
transition: transform 0.3s ease;
}
.menubar .has-submenu:focus-within > label,
.menubar .has-submenu:focus-within > a {
background: linear-gradient( to bottom, #505050 0%, #464646 35%, #404040 55%, #363636 100% );
border: 1px solid #777777;
border-right-color: #000000;
border-bottom-color: #000000;
}
.menubar .has-submenu:focus-within > label::after,
.menubar .has-submenu:focus-within > a::after {
content: " ▼";
color: #FF0000;
transform: translateY(-50%) rotate(0deg);
}
.menubar .has-submenu:focus-within > label,
.menubar .has-submenu:focus-within > a {
color: #7CACF8;
}
/* For phones */
@media only screen and (max-width: 768px) {
.menubar {
visibility: hidden;
}
#hamburger-menu {
display: block;
}
#mobile-menu {
height: calc(100% - 70px);
}
}
/* For desktop: */
@media only screen and (min-width: 768px) {
.menubar {
visibility: visible;
}
.overlay {
visibility: hidden !important;
}
}
@@ -0,0 +1,106 @@
.notification-container {
position: fixed;
bottom: 10px;
left: 20px;
z-index: 1000;
width: 300px;
max-height: calc(100vh - 40px); /* full viewport height minus 40px */
overflow-y: auto; /* add vertical scrollbar if content exceeds max-height */
}
.notification {
border-radius: 4px;
margin-bottom: 10px;
margin-right: 10px;
display: flex;
flex-direction: row; /* stack content horizontally */
align-items: flex-start; /* align items to the top */
background: linear-gradient(135deg, #404040, #232323) !important;
border-top: 1px solid #505050 !important;
border-left: 1px solid #505050 !important;
border-right: 1px solid #000 !important;
border-bottom: 1px solid #000 !important;
box-shadow: 5px 5px 5px var(--shadow-color);
animation: fadeIn 0.3s, fadeOut 0.3s 4.7s;
flex-direction: column;
flex-wrap: nowrap;
align-items: stretch;
justify-content: flex-start;
position: relative;
}
.notification-body {
padding: 15px;
display: flex;
flex-direction: row; /* stack content horizontally */
align-items: flex-start; /* align items to the top */
word-wrap: break-word; /* allow long words to break and wrap */
overflow-wrap: break-word; /* modern browsers */
word-break: break-word; /* for very long words or URLs */
}
.notification-message {
flex-grow: 1; /* allow message to take up available space */
margin-right: 3px; /* add some space between message and close button */
overflow-wrap: break-word; /* modern browsers */
word-break: break-word; /* for very long words or URLs */
hyphens: auto; /* enable automatic hyphenation */
white-space: pre-wrap; /* preserve line breaks */
font-family: monospace;
}
.close-button {
background: none;
color: var(--text-foreground);
border: none;
font-size: 20px;
cursor: pointer;
padding: 0;
line-height: 1;
flex-shrink: 0; /* prevent button from shrinking */
}
.shine-effect {
background: linear-gradient(to right, transparent, #fff, transparent);
width: 100%;
top: -1px;
height: 1px;
flex-shrink: 0;
pointer-events: none; /* ensure it doesn't interfere with interactions */
}
.info {
color: #2196F3;
}
.success {
color: #4CAF50;
}
.warning {
color: #FFC107;
}
.error {
color: #F44336;
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes fadeOut {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
@@ -52,6 +52,7 @@ main {
}
#modal-background {
display: none;
z-index: 998;
position: absolute;
top: 0px;
@@ -1244,4 +1245,4 @@ main {
/* For desktop: */
@media only screen and (min-width: 768px) {
}
}
@@ -0,0 +1,56 @@
.enlightenment-input {
font-size: 14px;
padding: 5px;
border: 1px solid;
border-color: var(--border-color-dark) var(--border-color-light) var(--border-color-light) var(--border-color-dark);
border-radius: 3px;
background: linear-gradient(0deg, #90c247, #509c00);
transition: background 0.3s, color 0.3s;
color: #000;
outline: none;
position: relative;
box-sizing: border-box;
}
.enlightenment-input:hover {
background: var(--window-button-over-color);
}
.enlightenment-input:not(:focus) {
background: linear-gradient(0deg, #6b7579, #576b65);
color: #000;
}
.enlightenment-input:focus {
font-style: italic;
color: #333;
background: linear-gradient(0deg, #6AAFF8, #82E9F7);
box-shadow: inset 4px 6px 8px rgba(0,0,0,0.6);
border-color: var(--border-color-dark) var(--border-color-light) var(--border-color-light) var(--border-color-dark);
outline: none;
}
.enlightenment-input::placeholder {
color: #999;
}
.enlightenment-input:disabled {
color: #999;
background: var(--container-background);
}
.enlightenment-input[readonly] {
color: #999;
background: var(--container-background);
border-color: var(--border-color-light) var(--border-color-dark) var(--border-color-dark) var(--border-color-light);
}
.enlightenment-input[data-has-error="true"] {
border-color: #f00;
color: #FFF;
background: #700;
}
textarea {
resize: none;
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,107 @@
/**
* Enum-like object for notification types.
* @readonly
* @enum {string}
*/
const NotificationType = {
INFO: 'info',
SUCCESS: 'success',
WARNING: 'warning',
ERROR: 'error'
};
/**
* Manages the creation, display, and removal of notifications.
*/
class NotificationService {
/**
* Creates an instance of NotificationService.
* Initializes the notification container and appends it to the document body.
*/
constructor() {
this.notifications = [];
this.container = document.createElement('div');
this.container.className = 'notification-container';
document.body.appendChild(this.container);
}
/**
* Displays a new notification.
* @param {string} message - The message to display in the notification.
* @param {NotificationType} type - The type of notification.
*/
show(message, type) {
const notification = {
id: Date.now().toString(),
message,
type
};
this.addNotification(notification);
}
/**
* Adds a notification to the list and displays it.
* @param {Object} notification - The notification object to add.
* @param {string} notification.id - Unique identifier for the notification.
* @param {string} notification.message - The notification message.
* @param {NotificationType} notification.type - The type of notification.
*/
addNotification(notification) {
this.notifications.push(notification);
this.displayNotification(notification);
// log the notification to the console
const message = `${notification.type.charAt(0).toUpperCase() + notification.type.slice(1)}: ${notification.message}`;
if (notification.type === 'info')
console.info(message);
else if (notification.type === 'warning')
console.warn(message);
else if (notification.type === 'error')
console.error(message);
else
console.log(message);
// set a timeout to remove the notification after 5 seconds
setTimeout(() => this.removeNotification(notification.id), 5000);
}
/**
* Removes a notification from the list and the DOM.
* @param {string} id - The ID of the notification to remove.
*/
removeNotification(id) {
const index = this.notifications.findIndex(n => n.id === id);
if (index !== -1) {
this.notifications.splice(index, 1);
const element = document.getElementById(`notification-${id}`);
if (element) {
element.remove();
}
}
}
/**
* Creates and displays a notification element in the DOM.
* @param {Object} notification - The notification object to display.
* @param {string} notification.id - Unique identifier for the notification.
* @param {string} notification.message - The notification message.
* @param {NotificationType} notification.type - The type of notification.
*/
displayNotification(notification) {
const notificationElement = document.createElement('div');
notificationElement.id = `notification-${notification.id}`;
notificationElement.className = `notification ${notification.type}`;
notificationElement.innerHTML = `
<div class="shine-effect"></div>
<div class="notification-body">
<span class="notification-message">${notification.message}</span>
<button class="close-button" onclick="notificationService.removeNotification('${notification.id}')">×</button>
</div>
`;
this.container.appendChild(notificationElement);
}
}
// create a global instance of the NotificationService
const notificationService = new NotificationService();
+109 -618
View File
@@ -1,28 +1,89 @@
const scrollbarHeight = getScrollbarHeight();
const scrollbarWidth = getScrollbarWidth();
const progressIndicator = document.getElementById('progress-indicator');
const progressIndicatorValue = document.getElementById('progress-indicator-value');
const progressIndicatorValueShadow = document.getElementById('progress-indicator-value-shadow');
const progressIndicatorValueText = document.getElementById('progress-indicator-value-text');
let selectionStartPosition = { x: 0, y: 0 };
let currentMousePosition = { x: 0, y: 0 };
let isSelecting = false;
let isSelectionMode = false;
let fileSystemExplorer = null;
let fileSystemExplorerContainer = null;
let visibleSelectionRectangle = null;
let selectionRectangle = null;
let scrollTimeout; // timeout to delay thumbnail loading after scrolling
let resizeTimeout; // timeout to delay thumbnail loading after resizing
let abortController; // allows the cancellation of thumbnail retrieval jobs
let hasScrolledAfterModeChange = false; // flag to track if scrolling occurred after a mode change
let showThumbnails = true; // whether to show thumbnails or not
let scrollThumbnailRetrievalTimeout = 1000; // the time span to wait after the last scroll, before getting thumbnails
let inspectFileForThumbnails = false; // whether to check the actual header bytes in order to determine if a file is an image, rather than its extension
let thumbnailsRetrievalBatchSize = 20; // the number of thumbnails to ask from the server, concurrently
let imagePreviewsQuality = 70; // the quality used for image thumbnails
let fullImageQuality = 90; // the quality used for full images
let enableConsoleDebugMessages = false; // whether to display debug messages at the developer console, or not
// =================== common helper function ===================
var ajaxCallCounter = 0;
//+======================================================================================+
//| API interaction |
//+======================================================================================+
/**
* Performs a GET request to the specified API endpoint.
* @param {string} url - The API endpoint URL.
* @returns {Promise<any>} The response data if successful, undefined otherwise.
*/
async function callApiGetAsync(url) {
try {
// create the URL for the API endpoint
const response = await fetch(url); // call the API
if (!response.ok)
throw new Error('Network response was not ok');
const jsonResponse = await response.json();
if (jsonResponse.success)
return jsonResponse.data;
else
notificationService.show(jsonResponse.errorMessage, NotificationType.ERROR);
} catch (error) {
console.error('Error:', error);
notificationService.show(error, NotificationType.ERROR);
}
}
//+======================================================================================+
//| Common Helper Functions |
//+======================================================================================+
/**
* Starts progress indicator
*/
function showBusyIndicator() {
//if (ajaxCallCounter === 0)
//progressIndicator.classList.remove('hidden');
ajaxCallCounter++;
}
/**
* Hides progress indicator
*/
function hideBusyIndicator() {
ajaxCallCounter--;
//if (ajaxCallCounter === 0)
//progressIndicator.classList.add('hidden');
}
/**
* Shows the elements that display a progress operation
*/
function showOperationProgress() {
progressIndicatorValueShadow.classList.remove('hidden');
progressIndicatorValue.classList.remove('hidden');
}
/**
* Hides the elements that display a progress operation
*/
function hideOperationProgress() {
progressIndicatorValueShadow.classList.add('hidden');
progressIndicatorValue.classList.add('hidden');
}
/**
* Updates the progress indicator
* @param {int} completed - Number of completed elements
* @param {int} total - Number of total elements
*/
function updateOperationProgress(completed, total) {
progressIndicatorValueText.innerText = completed + '/' + total;
}
/**
* Convert Blob to Base64.
@@ -117,23 +178,40 @@ function getScrollbarWidth() {
}
/**
* Enables horizontal scrolling to the element identified by the specified id.
* Handles the wheel event for horizontal scrolling.
* @param {WheelEvent} event - The wheel event object.
*/
function addHorizontalScrolling(id) {
document.getElementById(id).addEventListener('wheel', function (e) {
e.preventDefault();
this.scrollLeft += (e.deltaY > 0 ? 1 : -1) * 80;
}, { passive: false });
const scrollHandler = function (event) {
event.preventDefault();
this.scrollLeft += (event.deltaY > 0 ? 1 : -1) * 80;
};
/**
* Enables horizontal scrolling to the element identified by the specified id or element.
* @param {string|HTMLElement} idOrElement - The id of the element or the element itself.
*/
function addHorizontalScrolling(idOrElement) {
let element = idOrElement;
if (typeof idOrElement === 'string')
element = document.getElementById(idOrElement);
if (element instanceof HTMLElement)
element.addEventListener('wheel', scrollHandler, { passive: false });
else
console.error('Invalid input: Expected an element ID or HTMLElement');
}
/**
* Disables horizontal scrolling to the element identified by the specified id.
* Disables horizontal scrolling for the element identified by the specified id or element.
* @param {string|HTMLElement} idOrElement - The id of the element or the element itself.
*/
function removeHorizontalScrolling(id) {
document.getElementById(id).removeEventListener('wheel', function (e) {
e.preventDefault();
this.scrollLeft += (e.deltaY > 0 ? 1 : -1) * 80;
}, { passive: false });
function removeHorizontalScrolling(idOrElement) {
let element = idOrElement;
if (typeof idOrElement === 'string')
element = document.getElementById(idOrElement);
if (element instanceof HTMLElement)
element.removeEventListener('wheel', scrollHandler, { passive: false });
else
console.error('Invalid input: Expected an element ID or HTMLElement');
}
/**
@@ -159,590 +237,3 @@ function getElementOffset(id) {
height: 0
};
}
/**
* Get the position and size of an HTML element.
* @param {string} id - The id of the element to get the rectangle of.
* @returns {object} An object containing the element's X (left), Y (top), Width, and Height in pixels.
*/
function getElementRectangle(id) {
const element = document.getElementById(id);
const rect = element.getBoundingClientRect();
return {
x: rect.left,
y: rect.top,
width: rect.width,
height: rect.height
};
}
// =================== file system browser dialog ===================
/**
* Adjusts the height of a dropdown identified by `comboboxId` to fit in the available space.
* @param {string} comboboxId The Id of the combobox whose dropdown should be adjusted.
*/
function adjustDropdownHeight(comboboxId = null) {
const comboboxes = comboboxId
? [document.getElementById(comboboxId)] // if comboboxId is provided, use only that element
: document.querySelectorAll('[id^="combobox_"]:not([id^="combobox_checkbox_"])'); // otherwise, select all dropdowns
if (comboboxes) {
comboboxes.forEach(combobox => {
if (!combobox) return; // skip if no element is found
const dropdown = combobox.querySelector('.enlightenment-dropdown');
if (!dropdown) return; // skip if there's no dropdown inside
// get the bounds of the combobox and the height of the viewport
const comboboxRect = combobox.getBoundingClientRect();
const viewportHeight = window.innerHeight;
// calculate the space available between the combobox and the bottom of the viewport, with a 10px margin
const dropdownTopPosition = comboboxRect.top + comboboxRect.height;
const availableSpace = viewportHeight - dropdownTopPosition - 10; // 10px margin
// adjust the dropdown height
dropdown.style.maxHeight = `${availableSpace}px`;
});
}
}
/**
* Updates the position and height of the dropdown relative to the specified path segment.
* @param {string} pathSegmentId - The ID of the path segment element to position the dropdown relative to.
*/
function updateDropdownPosition(pathSegmentId) {
const element = document.getElementById(pathSegmentId);
const dropdown = document.getElementById('navigatorDropdown');
if (element && dropdown) {
const rect = getElementOffset(pathSegmentId);
dropdown.style.top = `${rect.top + rect.height}px`;
dropdown.style.left = `${rect.left}px`;
// calculate the available height between the dropdown and the bottom of the viewport
const viewportHeight = window.innerHeight;
const availableHeight = viewportHeight - (rect.top + rect.height) - 10; // 10 px margin
// set the dropdown's max height, ensuring it doesn't exceed the available height
dropdown.style.maxHeight = `${availableHeight}px`;
}
}
/**
* Focuses the navigator address bar input.
*/
function focusNavigatorInputElement() {
const elements = document.getElementsByClassName('navigator-address-bar-input');
if (elements.length > 0)
elements[0].focus();
}
/**
* Unchecks all checkboxes except the one with the specified Id.
* @param {string} id - The Id of the checkbox to leave checked.
*/
function uncheckAllExcept(id) {
const checkboxes = document.querySelectorAll('.navigator-toggle-checkbox');
checkboxes.forEach((checkbox) => {
if (checkbox.id !== id)
checkbox.checked = false;
});
}
/**
* Closes all navigator path segments.
*/
function closeNavigatorPathSegments() {
const checkboxes = document.getElementsByClassName('navigator-toggle-checkbox');
for (let i = 0; i < checkboxes.length; i++)
checkboxes[i].checked = false;
}
/**
* Handles the scroll event for the explorer or explorerContainer.
* Clears any previous timeout and creates a new one to fetch visible items.
*/
function handleFileSystemBrowserScrollEvent() {
// clear any previously set timeouts to debounce the getVisibleItems call
if (scrollTimeout) clearTimeout(scrollTimeout);
// if there's an ongoing operation, abort it
if (abortController) {
abortController.abort();
abortController = null;
}
// set a timeout to call getVisibleItems once the user stops scrolling
scrollTimeout = setTimeout(() => {
if (showThumbnails)
getVisibleItems();
}, scrollThumbnailRetrievalTimeout);
hasScrolledAfterModeChange = true;
}
/**
* Handles the window's resize event.
* Clears any previous timeout and creates a new one to fetch file system browser visible items.
*/
function handleFileSystemBrowserResizeEvent() {
// clear any previously set timeouts to debounce the getVisibleItems call during resize
if (resizeTimeout) clearTimeout(resizeTimeout);
// if there's an ongoing operation, abort it
if (abortController) {
abortController.abort();
abortController = null;
}
// set a timeout to call getVisibleItems once the user stops resizing
resizeTimeout = setTimeout(() => {
if (showThumbnails)
getVisibleItems();
}, scrollThumbnailRetrievalTimeout);
}
/**
* Switches to a different view mode.
*/
function switchViewMode() {
hasScrolledAfterModeChange = false; // reset the flag indicating a mode change
// check if content has been scrolled after the mode change; since scroll is the one triggering thumbnails retrieval,
// and there is no initial scroll when mode is changed, we need to trigger the retrieval manually
setTimeout(() => {
if (!hasScrolledAfterModeChange && showThumbnails)
getVisibleItems();
}, 50); // wait 50ms to ensure all other events have processed
}
// =================== file system browser dialog selection ===================
/**
* Function called at the initialization of fle system browser dialog
* @param {any} dotnetHelper - .NET object to invoke methods asynchronously.
*/
function initializeFileSystemBrowser(dotnetHelper) {
// cache frequently accessed elements
if (!selectionRectangle)
selectionRectangle = document.getElementById('selection-rectangle');
if (!visibleSelectionRectangle)
visibleSelectionRectangle = document.getElementById('visible-selection-rectangle');
if (!fileSystemExplorer) {
fileSystemExplorer = document.getElementById('file-system-browser-file-system-explorer');
if (fileSystemExplorer) {
fileSystemExplorer.addEventListener('mouseup', handleFileSystemExplorerMouseUp);
fileSystemExplorer.addEventListener('scroll', handleFileSystemBrowserScrollEvent);
}
}
// event handlers needed for selection
if (!fileSystemExplorerContainer) {
fileSystemExplorerContainer = document.getElementById('file-system-browser-file-system-explorer-container');
if (fileSystemExplorerContainer) {
fileSystemExplorerContainer.addEventListener('mousedown', startSelection);
fileSystemExplorerContainer.addEventListener('mousemove', updateSelection);
fileSystemExplorerContainer.addEventListener('mouseup', endSelection);
fileSystemExplorerContainer.addEventListener('wheel', handleSelection);
fileSystemExplorerContainer.addEventListener('scroll', handleFileSystemBrowserScrollEvent);
fileSystemExplorerContainer.addEventListener('scroll', handleSelection);
}
}
// handler for the mouse down event of file system browser dialog files and directories elements
window.handleFileSystemEntityMouseDown = function (e) {
// stop the event from bubbling up to the explorer - we dont want to start selection rectangles when clicking files or directories
e.stopPropagation();
};
// handler for the mouse up event of file system browser dialog files and directories elements
window.handleFileSystemEntityMouseUp = function (e) {
e.preventDefault();
if (!isSelecting)
e.stopPropagation();
const allEClassElements = Array.from(fileSystemExplorer.querySelectorAll('.e'));
const currentIndex = allEClassElements.indexOf(e.currentTarget);
// If a previous click timestamp exists, check the time difference
const previousTime = parseInt(e.currentTarget.dataset.selectionStartTime || 0);
const currentTime = new Date().getTime();
const timeDifference = currentTime - previousTime;
// TODO: needs to account for when the element is already selected, and a double click occurs - on first click it would check the difference and go to rename -
// maybe just wait half second before performing action
// if time difference is less than 300ms, treat it as a double-click
if (timeDifference < 300) {
if (e.currentTarget.dataset.type === 'directory') { // directories
dotnetHelper.invokeMethodAsync('OnDirectoryDoubleClickAsync', e.currentTarget.dataset.path);
return;
}
else { // files
}
// reset the timestamp used to track double clicks
e.currentTarget.dataset.selectionStartTime = 0;
return;
}
else
e.currentTarget.dataset.selectionStartTime = currentTime; // element was single clicked, update the selection start time to now
if (e.ctrlKey || isSelectionMode) { // when CTRL key is pressed
// toggle selection for the current clicked item
e.currentTarget.classList.toggle('selected');
// set the selection start if it's not already set
if (fileSystemExplorer.dataset.selectionStart === undefined)
fileSystemExplorer.dataset.selectionStart = currentIndex;
}
else if ((e.shiftKey && fileSystemExplorer.dataset.selectionStart !== undefined) || isSelectionMode) { // when SHIFT key is pressed
const start = parseInt(fileSystemExplorer.dataset.selectionStart);
// remove all selections
allEClassElements.forEach(elem => {
elem.classList.remove('selected');
});
// define the range to select items from and to
const [from, to] = start < currentIndex ? [start, currentIndex] : [currentIndex, start];
// add the 'selected' class to items in the range
for (let i = from; i <= to; i++)
allEClassElements[i].classList.add('selected');
}
else { // when neither CTRL nor SHIFT keys are pressed
if (!isSelectionMode) {
// get all elements that are selected
const selectedElements = allEClassElements.filter(element => element.classList.contains('selected'));
// add 'selected' class to the current clicked item
e.currentTarget.classList.add('selected');
// if there are no selected elements, or if there are more than one, deselect all of them, and select just the clicked one
if ((selectedElements.length === 1 && e.currentTarget !== selectedElements[0]) || selectedElements.length !== 1) {
// deselect all items
selectedElements.forEach(elem => {
if (elem !== e.currentTarget) {
elem.classList.remove('selected');
// remove selectionStartTime from all items
delete elem.dataset.selectionStartTime;
}
});
// set the current item as the selection start
fileSystemExplorer.dataset.selectionStart = currentIndex;
// store the current timestamp for future double-click checks
e.currentTarget.dataset.selectionStartTime = currentTime;
}
}
else // if its selection mode, just toggle selection of item, when clicked
e.currentTarget.classList.toggle('selected');
}
};
}
/**
* Handler for the mouse up event of the file system browser dialog explorer
* @param {MouseEvent} e - The mouseup event object.
*/
function handleFileSystemExplorerMouseUp(e) {
const explorerScrollbars = hasScrollbars(fileSystemExplorer);
// check if clicked on the horizontal scrollbar
if (explorerScrollbars.horizontal && e.clientY > fileSystemExplorer.getBoundingClientRect().top + fileSystemExplorer.offsetHeight - scrollbarHeight)
return;
if (!e.ctrlKey && !e.shiftKey && !isSelectionMode) {
// deselect all file system elements when their explorer is clicked
fileSystemExplorer.querySelectorAll('.e.selected').forEach(item => {
item.classList.remove('selected');
});
// do not store information about what item was clicked first, in context of Shift-selection
fileSystemExplorer.removeAttribute('data-selection-start');
}
}
/**
* Handler for the file system browser dialog selection start.
* @param {MouseEvent} e - The mousedown event object.
*/
function startSelection(e) {
const explorerScrollbars = hasScrollbars(fileSystemExplorer);
const containerExplorerScrollbars = hasScrollbars(fileSystemExplorerContainer);
// check if clicked on the horizontal or vertical scrollbar
if (explorerScrollbars.horizontal && e.clientY > fileSystemExplorer.getBoundingClientRect().top + fileSystemExplorer.offsetHeight - scrollbarHeight)
return;
if (containerExplorerScrollbars.vertical && e.clientX > fileSystemExplorerContainer.getBoundingClientRect().left + fileSystemExplorerContainer.offsetWidth - scrollbarWidth)
return;
// store information about selection start
isSelecting = true;
document.body.style.overflowY = 'hidden'; // needed in order to not put a vertical scrollbar on the document, while in vertical layout selection
document.documentElement.style.overflowY = 'hidden';
selectionStartPosition.x = e.pageX + fileSystemExplorer.scrollLeft;
selectionStartPosition.y = e.pageY + fileSystemExplorerContainer.scrollTop; // not a mistake - in vertical mode, this is the overflow container!
// place the selection rectangle at the clicked location (relative to the whole page, and taking into account scroll offset), with 0 size
visibleSelectionRectangle.style.left = e.pageX + 'px';
visibleSelectionRectangle.style.top = e.pageY + 'px';
visibleSelectionRectangle.style.width = '0px';
visibleSelectionRectangle.style.height = '0px';
visibleSelectionRectangle.style.visibility = 'visible';
selectionRectangle.style.left = e.pageX + 'px';
selectionRectangle.style.top = e.pageY + 'px';
selectionRectangle.style.width = '0px';
selectionRectangle.style.height = '0px';
}
/**
* Handler for the file system browser dialog selection update.
* @param {MouseEvent} e - The mousemove event object.
*/
function updateSelection(e) {
if (!isSelecting)
return;
currentMousePosition.x = e.pageX;
currentMousePosition.y = e.pageY;
handleSelection();
}
/**
* Handler for the file system browser dialog selection end.
* @param {MouseEvent} e - The mouseup event object.
*/
function endSelection(e) {
// selection ended, hide the selection rectangle
isSelecting = false;
document.body.style.removeProperty('overflow-y');
document.documentElement.style.removeProperty('overflow-y');
visibleSelectionRectangle.style.visibility = 'hidden';
selectionRectangle.style.visibility = 'hidden';
selectionRectangle.style.left = '0px';
selectionRectangle.style.top = '0px';
selectionRectangle.style.width = '0px';
selectionRectangle.style.height = '0px';
visibleSelectionRectangle.style.left = '0px';
visibleSelectionRectangle.style.top = '0px';
visibleSelectionRectangle.style.width = '0px';
visibleSelectionRectangle.style.height = '0px';
// go through each .e item that was inside the selection rectangle, and mark it as selected
fileSystemExplorer.querySelectorAll('.e.selection-hover').forEach(item => {
item.classList.add('selected');
item.classList.remove('selection-hover');
});
}
/**
* Function for handling the file system browser dialog selection.
*/
function handleSelection() {
if (!isSelecting) // only relevant when we have a selection initialized
return;
// calculate dimensions of the selection rectangle
const currentX = currentMousePosition.x;
const currentY = currentMousePosition.y;
const width = currentX - (selectionStartPosition.x - fileSystemExplorer.scrollLeft);
const height = currentY - (selectionStartPosition.y - fileSystemExplorerContainer.scrollTop);
// update selection rectangle dimensions
visibleSelectionRectangle.style.width = Math.abs(width) + 'px';
visibleSelectionRectangle.style.height = Math.abs(height) + 'px';
selectionRectangle.style.width = Math.abs(width) + 'px';
selectionRectangle.style.height = Math.abs(height) + 'px';
// adjust position based on selection direction
if (width < 0) {
selectionRectangle.style.left = currentX + 'px';
visibleSelectionRectangle.style.left = currentX + 'px';
} else {
selectionRectangle.style.left = (selectionStartPosition.x - fileSystemExplorer.scrollLeft) + 'px';
visibleSelectionRectangle.style.left = (selectionStartPosition.x - fileSystemExplorer.scrollLeft) + 'px';
}
if (height < 0) {
selectionRectangle.style.top = currentY + 'px';
visibleSelectionRectangle.style.top = currentY + 'px';
} else {
selectionRectangle.style.top = (selectionStartPosition.y - fileSystemExplorerContainer.scrollTop) + 'px';
visibleSelectionRectangle.style.top = (selectionStartPosition.y - fileSystemExplorerContainer.scrollTop) + 'px';
}
// do not let the selection rectangle go outside of explorer container, clip it if needed
const containerRect = fileSystemExplorerContainer.getBoundingClientRect();
const left = parseFloat(visibleSelectionRectangle.style.left);
const top = parseFloat(visibleSelectionRectangle.style.top) + 1;
const right = left + parseFloat(visibleSelectionRectangle.style.width);
const bottom = top + parseFloat(visibleSelectionRectangle.style.height);
if (left < containerRect.left) {
const difference = containerRect.left - left;
visibleSelectionRectangle.style.width = (parseFloat(visibleSelectionRectangle.style.width) - difference) + 'px';
visibleSelectionRectangle.style.left = containerRect.left + 'px';
}
if (right > containerRect.right)
visibleSelectionRectangle.style.width = (containerRect.right - left) + 'px';
if (top < containerRect.top) {
const difference = containerRect.top - top;
visibleSelectionRectangle.style.height = (parseFloat(visibleSelectionRectangle.style.height) - difference) + 'px';
visibleSelectionRectangle.style.top = containerRect.top + 'px';
}
if (bottom > containerRect.bottom)
visibleSelectionRectangle.style.height = (containerRect.bottom - top) + 'px';
// change color of items that fall within selection rectangle
const selectionRect = selectionRectangle.getBoundingClientRect();
// go through each .e item which has not had its thumbnail retrieved yet
fileSystemExplorer.querySelectorAll('.e').forEach(item => {
const itemRect = item.getBoundingClientRect();
// check if the item is fully or partially visible horizontally and vertically
const isFullyVisibleHorizontally = itemRect.left >= selectionRect.left && itemRect.right <= selectionRect.right;
const isFullyVisibleVertically = itemRect.top >= selectionRect.top && itemRect.bottom <= selectionRect.bottom;
const isPartiallyVisibleHorizontally = itemRect.left < selectionRect.right && itemRect.right > selectionRect.left;
const isPartiallyVisibleVertically = itemRect.top < selectionRect.bottom && itemRect.bottom > selectionRect.top;
// if the item is fully or partially visible in both directions, add it to our list
if ((isFullyVisibleHorizontally || isPartiallyVisibleHorizontally) && (isFullyVisibleVertically || isPartiallyVisibleVertically))
item.classList.add('selection-hover');
else
item.classList.remove('selection-hover');
});
}
/**
* Toggles the state of selection mode.
* @param {MouseEvent} e - The mouseup event object.
*/
function toggleSelectionMode(e) {
isSelectionMode = !isSelectionMode;
}
// =================== file system browser dialog thumbnails preview ===================
/**
* Identifies items within the explorerContainer that are either fully or partially visible.
* Items with thumbnails already retrieved are excluded.
* Populates a list of such visible items and passes them for further processing.
*/
function getVisibleItems() {
const containerRect = fileSystemExplorerContainer.getBoundingClientRect();
const visibleItems = [];
// go through each .e item which has not had its thumbnail retrieved yet
const fileElements = Array.from(fileSystemExplorer.querySelectorAll('.e:not([data-thumbnail-retrieved])[data-type="file"]'));
// if the option for checking file header bytes is disabled, filter images by extension
const itemsToProcess = inspectFileForThumbnails ? fileElements : fileElements.filter(item => isImageFile(item.getAttribute('data-path')));
itemsToProcess.forEach(item => {
const itemPath = item.getAttribute('data-path');
const itemRect = item.getBoundingClientRect();
// check if the item is fully or partially visible horizontally and vertically
const isFullyVisibleHorizontally = itemRect.left >= containerRect.left && itemRect.right <= containerRect.right;
const isFullyVisibleVertically = itemRect.top >= containerRect.top && itemRect.bottom <= containerRect.bottom;
const isPartiallyVisibleHorizontally = itemRect.left < containerRect.right && itemRect.right > containerRect.left;
const isPartiallyVisibleVertically = itemRect.top < containerRect.bottom && itemRect.bottom > containerRect.top;
// if the item is fully or partially visible in both directions, add it to our list
if ((isFullyVisibleHorizontally || isPartiallyVisibleHorizontally) &&
(isFullyVisibleVertically || isPartiallyVisibleVertically)) {
const imgElement = item.querySelector('img');
visibleItems.push({
path: itemPath,
img: imgElement
});
}
});
// process the list of visible items
processVisibleItems(visibleItems);
}
/**
* Processes a given item by retrieving its thumbnail from an API and updating the item's thumbnail image.
* If there are more items in the visibleItems list, it continues to process the next item.
* If an error occurs during the retrieval process (including an aborted fetch operation), it is handled gracefully.
* @param {Object} item - The item containing its path and corresponding image element.
* @param {Array} visibleItems - List of remaining visible items to process.
* @throws {AbortError} - Indicates the fetch operation was aborted.
* @throws {Error} - Catches and logs other errors that might occur during the thumbnail retrieval.
*/
async function processItem(item, visibleItems) {
try {
const result = await getThumbnailApiCall(item.path, imagePreviewsQuality);
// update the item's thumbnail using the retrieved data
if (typeof result.base64Data !== "undefined")
item.img.src = `data:${result.mimeType};base64,${result.base64Data}`;
item.img.closest('.e').setAttribute('data-thumbnail-retrieved', 'true');
// continue with next item if there are more in the queue
if (visibleItems.length > 0) {
const nextItem = visibleItems.shift();
processItem(nextItem, visibleItems);
}
} catch (error) {
if (error.name === 'AbortError') {
// console.log('Fetch operation was aborted.');
} else {
// on error, revert the icons to the default ones
let itemType = item.img.closest('.e').getAttribute('data-type');
if (itemType === 'directory')
item.img.src = "http://localhost:5012/images/icons/Lyra/directory.svg";
else if (itemType === 'file')
item.img.src = "http://localhost:5012/images/icons/Lyra/file.svg";
console.error('Error processing item:', error);
}
}
}
/**
* Makes an API call to retrieve a thumbnail for the given item.
* @param {string} path - The path of the item for which the thumbnail needs to be fetched.
* @returns {Promise<object>} - Returns a Promise resolving to an object containing base64Data and mimeType.
* @throws {Error} - Throws an error if the API call fails.
*/
async function getThumbnailApiCall(path, quality) {
// fetch the thumbnail for the given item from the server
const response = await fetch('http://localhost:5214/api/v1/thumbnails/get-thumbnail?path=' + encodeURIComponent(path) + '&quality=' + quality, {
signal: abortController.signal // use the abort signal
});
if (!response.ok)
throw new Error('Failed to fetch the thumbnail');
// convert the response to a JSON object
const blob = await response.blob();
const base64Data = await blobToBase64(blob);
const mimeType = response.headers.get('Content-Type');
return {
base64Data: base64Data,
mimeType: mimeType
};
}
/**
* Initiates the processing of visible items. Processing is batched based on thumbnailsRetrievalBatchSize. *
* @param {Array} visibleItemsList - List of visible items to be processed.
*/
async function processVisibleItems(visibleItemsList) {
const visibleItems = [...visibleItemsList];
abortController = new AbortController(); // create a new AbortController
// process items in batches determined by thumbnailsRetrievalBatchSize
for (let i = 0; i < Math.min(thumbnailsRetrievalBatchSize, visibleItems.length); i++) {
const item = visibleItems.shift();
processItem(item, visibleItems);
}
}
// =================== window functions ===================
/**
* Attaches a click event listener to the window, invoking a .NET method when the window is clicked.
* @param {any} dotnetHelper - .NET object to invoke methods asynchronously.
*/
function windowClickHandler(dotnetHelper) {
window.addEventListener('click', (e) => {
dotnetHelper.invokeMethodAsync('OnWindowClickAsync', {
x: e.clientX,
y: e.clientY,
sender: e.target.getAttribute('id')
});
});
}
/**
* Attaches a keydown event listener to the given element, invoking a .NET method when 'Escape' is pressed.
* @param {HTMLElement} element - The HTML element to attach the keydown listener to.
* @param {any} dotnetHelper - .NET object to invoke methods asynchronously.
*/
function windowKeyDownHandler(element, dotnetHelper) {
element.addEventListener('keydown', (e) => {
if (e.key === 'Escape') {
e.preventDefault();
dotnetHelper.invokeMethodAsync('EscapePressed');
}
});
}
/**
* Handles the window resize event.
*/
window.addEventListener('resize', function () {
adjustDropdownHeight();
handleFileSystemBrowserResizeEvent();
// update all dropdowns' positions on resize
const dropdown = document.getElementById('navigatorDropdown');
if (dropdown) {
const pathSegmentId = dropdown.getAttribute('data-path-segment-id');
if (pathSegmentId)
updateDropdownPosition(pathSegmentId);
}
});