diff --git a/Moonlight/App/Services/Interop/ClipboardService.cs b/Moonlight/App/Services/Interop/ClipboardService.cs index a7c806c..6a70228 100644 --- a/Moonlight/App/Services/Interop/ClipboardService.cs +++ b/Moonlight/App/Services/Interop/ClipboardService.cs @@ -10,14 +10,9 @@ public class ClipboardService { JsRuntime = jsRuntime; } - - public async Task CopyToClipboard(string data) - { - await JsRuntime.InvokeVoidAsync("copyTextToClipboard", data); - } + public async Task Copy(string data) { - await JsRuntime.InvokeVoidAsync("copyTextToClipboard", data); + await JsRuntime.InvokeVoidAsync("moonlight.clipboard.copy", data); } - } \ No newline at end of file diff --git a/Moonlight/App/Services/Interop/ToastService.cs b/Moonlight/App/Services/Interop/ToastService.cs index 5e1839d..af66d12 100644 --- a/Moonlight/App/Services/Interop/ToastService.cs +++ b/Moonlight/App/Services/Interop/ToastService.cs @@ -13,36 +13,36 @@ public class ToastService public async Task Info(string message) { - await JsRuntime.InvokeVoidAsync("showInfoToast", message); + await JsRuntime.InvokeVoidAsync("moonlight.toasts.info", message); } public async Task Error(string message) { - await JsRuntime.InvokeVoidAsync("showErrorToast", message); + await JsRuntime.InvokeVoidAsync("moonlight.toasts.error", message); } public async Task Warning(string message) { - await JsRuntime.InvokeVoidAsync("showWarningToast", message); + await JsRuntime.InvokeVoidAsync("moonlight.toasts.warning", message); } public async Task Success(string message) { - await JsRuntime.InvokeVoidAsync("showSuccessToast", message); + await JsRuntime.InvokeVoidAsync("moonlight.toasts.success", message); } public async Task CreateProcessToast(string id, string text) { - await JsRuntime.InvokeVoidAsync("createToast", id, text); + await JsRuntime.InvokeVoidAsync("moonlight.toasts.create", id, text); } public async Task UpdateProcessToast(string id, string text) { - await JsRuntime.InvokeVoidAsync("modifyToast", id, text); + await JsRuntime.InvokeVoidAsync("moonlight.toasts.modify", id, text); } public async Task RemoveProcessToast(string id) { - await JsRuntime.InvokeVoidAsync("removeToast", id); + await JsRuntime.InvokeVoidAsync("moonlight.toasts.remove", id); } } \ No newline at end of file diff --git a/Moonlight/Pages/_Layout.cshtml b/Moonlight/Pages/_Layout.cshtml index ef045fa..a5d7476 100644 --- a/Moonlight/Pages/_Layout.cshtml +++ b/Moonlight/Pages/_Layout.cshtml @@ -100,25 +100,14 @@ - - - - - - - - - - - - + diff --git a/Moonlight/Shared/Components/FileManagerPartials/FileEditor.razor b/Moonlight/Shared/Components/FileManagerPartials/FileEditor.razor index 9af01b0..0c58499 100644 --- a/Moonlight/Shared/Components/FileManagerPartials/FileEditor.razor +++ b/Moonlight/Shared/Components/FileManagerPartials/FileEditor.razor @@ -71,7 +71,7 @@ { if (firstRender) { - await JsRuntime.InvokeVoidAsync("initMonacoTheme"); + await JsRuntime.InvokeVoidAsync("moonlight.loading.loadMonaco"); Editor.OnDidInit = new EventCallback(this, async () => { diff --git a/Moonlight/Shared/Components/Partials/ThemeSwitcher.razor b/Moonlight/Shared/Components/Partials/ThemeSwitcher.razor index 8b85866..3895beb 100644 --- a/Moonlight/Shared/Components/Partials/ThemeSwitcher.razor +++ b/Moonlight/Shared/Components/Partials/ThemeSwitcher.razor @@ -47,6 +47,6 @@ private async void TriggerFlashbang() { - await JsRuntime.InvokeVoidAsync("flashbang"); + await JsRuntime.InvokeVoidAsync("moonlight.flashbang.run"); } } \ No newline at end of file diff --git a/Moonlight/Shared/Components/ServerControl/ServerBackups.razor b/Moonlight/Shared/Components/ServerControl/ServerBackups.razor index d0e76fa..5c8453f 100644 --- a/Moonlight/Shared/Components/ServerControl/ServerBackups.razor +++ b/Moonlight/Shared/Components/ServerControl/ServerBackups.razor @@ -208,7 +208,7 @@ { var url = await ServerService.DownloadBackup(CurrentServer, serverBackup); - await ClipboardService.CopyToClipboard(url); + await ClipboardService.Copy(url); await AlertService.Success( SmartTranslateService.Translate("Success"), SmartTranslateService.Translate("Backup URL successfully copied to your clipboard")); diff --git a/Moonlight/Shared/Components/Xterm/Terminal.razor b/Moonlight/Shared/Components/Xterm/Terminal.razor index 6a1c693..6d8e2a6 100644 --- a/Moonlight/Shared/Components/Xterm/Terminal.razor +++ b/Moonlight/Shared/Components/Xterm/Terminal.razor @@ -16,7 +16,7 @@ [Parameter] public Action RunOnFirstRender { get; set; } - private TerminalOptions TerminalOptions = new TerminalOptions + private TerminalOptions TerminalOptions = new() { CursorBlink = false, CursorStyle = CursorStyle.Underline, @@ -33,6 +33,7 @@ } catch (Exception) { + // ignored } } @@ -50,6 +51,7 @@ } catch (Exception) { + // ignored } } } \ No newline at end of file diff --git a/Moonlight/Shared/Layouts/MainLayout.razor b/Moonlight/Shared/Layouts/MainLayout.razor index 46017b5..064fd5c 100644 --- a/Moonlight/Shared/Layouts/MainLayout.razor +++ b/Moonlight/Shared/Layouts/MainLayout.razor @@ -160,7 +160,7 @@ await JsRuntime.InvokeVoidAsync("KTMenu.createInstances"); await JsRuntime.InvokeVoidAsync("KTDrawer.createInstances"); - //await JsRuntime.InvokeVoidAsync("createSnow"); + await JsRuntime.InvokeVoidAsync("moonlight.loading.registerXterm"); await SessionService.Register(); diff --git a/Moonlight/wwwroot/assets/js/alertUtils.js b/Moonlight/wwwroot/assets/js/alertUtils.js deleted file mode 100644 index 5e46f3b..0000000 --- a/Moonlight/wwwroot/assets/js/alertUtils.js +++ /dev/null @@ -1,68 +0,0 @@ -window.showAlertInfo = function (title, description) -{ - Swal.fire( - title, - description, - 'info' - ) -} - -window.showAlertSuccess = function (title, description) -{ - Swal.fire( - title, - description, - 'success' - ) -} - -window.showAlertWarning = function (title, description) -{ - Swal.fire( - title, - description, - 'warning' - ) -} - -window.showAlertError = function (title, description) -{ - Swal.fire( - title, - description, - 'error' - ) -} - -window.showAlertYesNo = function (title, yesText, noText) -{ - return Swal.fire({ - title: title, - showDenyButton: true, - confirmButtonText: yesText, - denyButtonText: noText, - }).then((result) => { - if (result.isConfirmed) { - return true; - } else if (result.isDenied) { - return false; - } - }) -} - -window.showAlertText = function (title, description) { - const {value: text} = Swal.fire({ - title: title, - input: 'text', - inputLabel: description, - inputValue: "", - showCancelButton: false, - inputValidator: (value) => { - if (!value) { - return 'Es muss ein Wert angegeben werden' - } - } - }) - - return text; -} \ No newline at end of file diff --git a/Moonlight/wwwroot/assets/js/clipboard.js b/Moonlight/wwwroot/assets/js/clipboard.js deleted file mode 100644 index 22b3a49..0000000 --- a/Moonlight/wwwroot/assets/js/clipboard.js +++ /dev/null @@ -1,32 +0,0 @@ -function fallbackCopyTextToClipboard(text) { - var textArea = document.createElement("textarea"); - textArea.value = text; - - // Avoid scrolling to bottom - textArea.style.top = "0"; - textArea.style.left = "0"; - textArea.style.position = "fixed"; - - document.body.appendChild(textArea); - textArea.focus(); - textArea.select(); - - try { - var successful = document.execCommand('copy'); - var msg = successful ? 'successful' : 'unsuccessful'; - } catch (err) { - console.error('Fallback: Oops, unable to copy', err); - } - - document.body.removeChild(textArea); -} -function copyTextToClipboard(text) { - if (!navigator.clipboard) { - fallbackCopyTextToClipboard(text); - return; - } - navigator.clipboard.writeText(text).then(function() { - }, function(err) { - console.error('Async: Could not copy text: ', err); - }); -} \ No newline at end of file diff --git a/Moonlight/wwwroot/assets/js/consoleUtils.js b/Moonlight/wwwroot/assets/js/consoleUtils.js deleted file mode 100644 index 14c1cf3..0000000 --- a/Moonlight/wwwroot/assets/js/consoleUtils.js +++ /dev/null @@ -1,143 +0,0 @@ -window.initConsolePlugins = function () { - window.XtermBlazor.registerAddon("xterm-addon-fit", new window.FitAddon.FitAddon()); - - addEventListener('resize', (event) => { - //XtermBlazor.invokeAddonFunction() - }); -}; - -window.initGraphs = function () { - -}; - -window.initCpu = function () { - var element = document.getElementById('cpuchart'); - - var height = parseInt(KTUtil.css(element, 'height')); - var labelColor = KTUtil.getCssVariableValue('--kt-gray-500'); - var borderColor = KTUtil.getCssVariableValue('--kt-gray-200'); - var baseColor = KTUtil.getCssVariableValue('--kt-info'); - var lightColor = KTUtil.getCssVariableValue('--kt-info-light'); - - if (!element) { - return; - } - - var options = { - series: [{ - name: 'CPU Auslastung', - data: [0, 0, 0, 0, 0, 0, 0] - }], - chart: { - fontFamily: 'inherit', - type: 'area', - height: height, - toolbar: { - show: false - } - }, - plotOptions: {}, - legend: { - show: false - }, - dataLabels: { - enabled: false - }, - fill: { - type: 'solid', - opacity: 1 - }, - stroke: { - curve: 'smooth', - show: true, - width: 3, - colors: [baseColor] - }, - xaxis: { - categories: [], - axisBorder: { - show: false, - }, - axisTicks: { - show: false - }, - labels: { - style: { - colors: labelColor, - fontSize: '12px' - } - }, - crosshairs: { - position: 'front', - stroke: { - color: baseColor, - width: 1, - dashArray: 3 - } - }, - tooltip: { - enabled: false, - formatter: undefined, - offsetY: 0, - style: { - fontSize: '12px' - } - } - }, - yaxis: { - labels: { - style: { - colors: labelColor, - fontSize: '12px' - } - } - }, - states: { - normal: { - filter: { - type: 'none', - value: 0 - } - }, - hover: { - filter: { - type: 'none', - value: 0 - } - }, - active: { - allowMultipleDataPointsSelection: false, - filter: { - type: 'none', - value: 0 - } - } - }, - colors: [lightColor], - grid: { - borderColor: borderColor, - strokeDashArray: 4, - yaxis: { - lines: { - show: true - } - } - }, - markers: { - strokeColor: baseColor, - strokeWidth: 3 - } - }; - - var chart = new ApexCharts(element, options); - chart.render(); - - window.console.cpuchart = chart; -}; - -window.updateCpu = function (value) { - window.console.cpuchart.appendSeries({ - name: 'CPU Auslastung', - data: value - }); -}; \ No newline at end of file diff --git a/Moonlight/wwwroot/assets/js/cookieUtils.js b/Moonlight/wwwroot/assets/js/cookieUtils.js deleted file mode 100644 index f64894f..0000000 --- a/Moonlight/wwwroot/assets/js/cookieUtils.js +++ /dev/null @@ -1,26 +0,0 @@ -window.setCookie = function (key, value, days) { - const d = new Date(); - d.setTime(d.getTime() + (days * 24 * 60 * 60 * 1000)); - let expires = "expires=" + d.toUTCString(); - document.cookie = key + "=" + value + ";" + expires + ";path=/"; -} - -window.deleteCookie = function (key) { - window.setCookie(key, "", 0); -} - -window.getCookie = function (cname) { - let name = cname + "="; - let decodedCookie = decodeURIComponent(document.cookie); - let ca = decodedCookie.split(';'); - for (let i = 0; i < ca.length; i++) { - let c = ca[i]; - while (c.charAt(0) == ' ') { - c = c.substring(1); - } - if (c.indexOf(name) == 0) { - return c.substring(name.length, c.length); - } - } - return ""; -} \ No newline at end of file diff --git a/Moonlight/wwwroot/assets/js/flashbang.js b/Moonlight/wwwroot/assets/js/flashbang.js deleted file mode 100644 index 44f1996..0000000 --- a/Moonlight/wwwroot/assets/js/flashbang.js +++ /dev/null @@ -1,12 +0,0 @@ -function flashbang() { - const light = document.getElementById("flashbang"); - light.style.boxShadow = "0 0 10000px 10000px white, 0 0 250px 10px #FFFFFF"; - light.style.animation = "flashbang 5s linear forwards"; - light.onanimationend = clearFlashbang; -} - -function clearFlashbang() { - const light = document.getElementById("flashbang"); - light.style.animation = ""; - light.style.opacity = "0"; -} \ No newline at end of file diff --git a/Moonlight/wwwroot/assets/js/loggingUtils.js b/Moonlight/wwwroot/assets/js/loggingUtils.js deleted file mode 100644 index 9a82f50..0000000 --- a/Moonlight/wwwroot/assets/js/loggingUtils.js +++ /dev/null @@ -1,51 +0,0 @@ -window.logInfo = function (prefix, message) -{ - console.log( - '%c[%cINFO%c] [%c' + prefix + '%c] %c' + message, - 'color: white', // [ - 'color: aqua', // INFO - 'color: white', // ] - 'color: purple', // {prefix} - 'color: white', // ] - 'color: lightgray' // {message} - ); -}; - -window.logWarn = function (prefix, message) -{ - console.log( - '%c[%cWARN%c] [%c' + prefix + '%c] %c' + message, - 'color: white', // [ - 'color: orange', // WARN - 'color: white', // ] - 'color: purple', // {prefix} - 'color: white', // ] - 'color: lightgray' // {message} - ); -}; - -window.logError = function (prefix, message) -{ - console.log( - '%c[%cERROR%c] [%c' + prefix + '%c] %c' + message, - 'color: white', // [ - 'color: red', // ERROR - 'color: white', // ] - 'color: purple', // {prefix} - 'color: white', // ] - 'color: lightgray' // {message} - ); -}; - -window.logDebug = function (prefix, message) -{ - console.log( - '%c[%cDEBUG%c] [%c' + prefix + '%c] %c' + message, - 'color: white', // [ - 'color: green', // DEBUG - 'color: white', // ] - 'color: purple', // {prefix} - 'color: white', // ] - 'color: lightgray' // {message} - ); -}; \ No newline at end of file diff --git a/Moonlight/wwwroot/assets/js/monacoTheme.js b/Moonlight/wwwroot/assets/js/monacoTheme.js deleted file mode 100644 index 168437a..0000000 --- a/Moonlight/wwwroot/assets/js/monacoTheme.js +++ /dev/null @@ -1,12 +0,0 @@ -window.initMonacoTheme = function () -{ - monaco.editor.defineTheme('moonlight-theme', { - base: 'vs-dark', - inherit: true, - rules: [ - ], - colors: { - 'editor.background': '#000000' - } - }); -} \ No newline at end of file diff --git a/Moonlight/wwwroot/assets/js/moonlight.js b/Moonlight/wwwroot/assets/js/moonlight.js index 55e11d6..a167554 100644 --- a/Moonlight/wwwroot/assets/js/moonlight.js +++ b/Moonlight/wwwroot/assets/js/moonlight.js @@ -1,13 +1,338 @@ -window.moonlight = -{ - modals: { - show: function (name) - { - $('#' + name).modal('show'); +window.moonlight = + { + modals: { + show: function (name) { + $('#' + name).modal('show'); + }, + hide: function (name) { + $('#' + name).modal('hide'); + } }, - hide: function (name) - { - $('#' + name).modal('hide'); + alerts: { + info: function (title, description) { + Swal.fire( + title, + description, + 'info' + ) + }, + success: function (title, description) { + Swal.fire( + title, + description, + 'success' + ) + }, + warning: function (title, description) { + Swal.fire( + title, + description, + 'warning' + ) + }, + error: function (title, description) { + Swal.fire( + title, + description, + 'error' + ) + }, + yesno: function (title, yesText, noText) { + return Swal.fire({ + title: title, + showDenyButton: true, + confirmButtonText: yesText, + denyButtonText: noText, + }).then((result) => { + if (result.isConfirmed) { + return true; + } else if (result.isDenied) { + return false; + } + }) + }, + text: function (title, description) { + const {value: text} = Swal.fire({ + title: title, + input: 'text', + inputLabel: description, + inputValue: "", + showCancelButton: false, + inputValidator: (value) => { + if (!value) { + return 'You need to enter a value' + } + } + }) + + return text; + } + }, + clipboard: { + copy: function (text) { + if (!navigator.clipboard) { + var textArea = document.createElement("textarea"); + textArea.value = text; + + // Avoid scrolling to bottom + textArea.style.top = "0"; + textArea.style.left = "0"; + textArea.style.position = "fixed"; + + document.body.appendChild(textArea); + textArea.focus(); + textArea.select(); + + try { + var successful = document.execCommand('copy'); + var msg = successful ? 'successful' : 'unsuccessful'; + } catch (err) { + console.error('Fallback: Oops, unable to copy', err); + } + + document.body.removeChild(textArea); + return; + } + navigator.clipboard.writeText(text).then(function () { + }, + function (err) { + console.error('Async: Could not copy text: ', err); + } + ); + } + }, + recaptcha: { + render: function (id, sitekey, page) { + return grecaptcha.render(id, { + 'sitekey': sitekey, + 'callback': (response) => { + page.invokeMethodAsync('CallbackOnSuccess', response); + }, + 'expired-callback': () => { + page.invokeMethodAsync('CallbackOnExpired'); + } + }); + } + }, + snow: { + create: function () { + (function () { + var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || + function (callback) { + window.setTimeout(callback, 1000 / 60); + }; + window.requestAnimationFrame = requestAnimationFrame; + })(); + + + var flakes = [], + canvas = document.getElementById("snow"), + ctx = canvas.getContext("2d"), + flakeCount = 200, + mX = -100, + mY = -100 + + canvas.width = window.innerWidth; + canvas.height = window.innerHeight; + + function snow() { + ctx.clearRect(0, 0, canvas.width, canvas.height); + + for (var i = 0; i < flakeCount; i++) { + var flake = flakes[i], + x = mX, + y = mY, + minDist = 150, + x2 = flake.x, + y2 = flake.y; + + var dist = Math.sqrt((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y)), + dx = x2 - x, + dy = y2 - y; + + if (dist < minDist) { + var force = minDist / (dist * dist), + xcomp = (x - x2) / dist, + ycomp = (y - y2) / dist, + deltaV = force / 2; + + flake.velX -= deltaV * xcomp; + flake.velY -= deltaV * ycomp; + + } else { + flake.velX *= .98; + if (flake.velY <= flake.speed) { + flake.velY = flake.speed + } + flake.velX += Math.cos(flake.step += .05) * flake.stepSize; + } + + ctx.fillStyle = "rgba(255,255,255," + flake.opacity + ")"; + flake.y += flake.velY; + flake.x += flake.velX; + + if (flake.y >= canvas.height || flake.y <= 0) { + reset(flake); + } + + + if (flake.x >= canvas.width || flake.x <= 0) { + reset(flake); + } + + ctx.beginPath(); + ctx.arc(flake.x, flake.y, flake.size, 0, Math.PI * 2); + ctx.fill(); + } + requestAnimationFrame(snow); + }; + + function reset(flake) { + flake.x = Math.floor(Math.random() * canvas.width); + flake.y = 0; + flake.size = (Math.random() * 3) + 2; + flake.speed = (Math.random() * 1) + 0.5; + flake.velY = flake.speed; + flake.velX = 0; + flake.opacity = (Math.random() * 0.5) + 0.3; + } + + function init() { + for (var i = 0; i < flakeCount; i++) { + var x = Math.floor(Math.random() * canvas.width), + y = Math.floor(Math.random() * canvas.height), + size = (Math.random() * 3) + 2, + speed = (Math.random() * 1) + 0.5, + opacity = (Math.random() * 0.5) + 0.3; + + flakes.push({ + speed: speed, + velY: speed, + velX: 0, + x: x, + y: y, + size: size, + stepSize: (Math.random()) / 30, + step: 0, + opacity: opacity + }); + } + + snow(); + }; + + canvas.addEventListener("mousemove", function (e) { + mX = e.clientX, + mY = e.clientY + }); + + window.addEventListener("resize", function () { + canvas.width = window.innerWidth; + canvas.height = window.innerHeight; + }) + + init(); + } + }, + toasts: { + info: function (msg) { + toastr['info'](msg); + }, + error: function (msg) { + toastr['error'](msg); + }, + success: function (msg) { + toastr['success'](msg); + }, + warning: function (msg) { + toastr['warning'](msg); + }, + create: function (id, text) { + var toast = toastr.success(text, '', + { + closeButton: true, + progressBar: false, + tapToDismiss: false, + timeOut: 0, + extendedTimeOut: 0, + positionClass: "toastr-bottom-right", + preventDuplicates: false, + onclick: function () { + toastr.clear(toast); + } + }); + var toastElement = toast[0]; + toastElement.setAttribute('data-toast-id', id); + toastElement.classList.add("bg-secondary"); + }, + modify: function (id, newText) { + var toast = document.querySelector('[data-toast-id="' + id + '"]'); + + if (toast) { + var toastMessage = toast.lastChild; + if (toastMessage) { + toastMessage.innerHTML = newText; + } + } + }, + remove: function (id) { + var toast = document.querySelector('[data-toast-id="' + id + '"]'); + if (toast) { + toast.childNodes.item(1).click(); + } + } + }, + utils: { + scrollToElement: function (id) + { + let e = document.getElementById(id); + e.scrollTop = e.scrollHeight; + }, + triggerResizeEvent: function () + { + window.dispatchEvent(new Event('resize')); + }, + showNotification: function (title, text, img) { + let notification = new Notification(title, { body: text, icon: img }); + } + }, + loading: { + registerXterm: function() + { + console.log("Registering xterm addons"); + + window.XtermBlazor.registerAddon("xterm-addon-fit", new window.FitAddon.FitAddon()); + window.XtermBlazor.registerAddon("xterm-addon-search", new window.SearchAddon.SearchAddon()); + window.XtermBlazor.registerAddon("xterm-addon-web-links", new window.WebLinksAddon.WebLinksAddon()); + }, + loadMonaco: function () + { + console.log("Loading monaco"); + + monaco.editor.defineTheme('moonlight-theme', { + base: 'vs-dark', + inherit: true, + rules: [ + ], + colors: { + 'editor.background': '#000000' + } + }); + } + }, + flashbang: { + run: function() + { + const light = document.getElementById("flashbang"); + light.style.boxShadow = "0 0 10000px 10000px white, 0 0 250px 10px #FFFFFF"; + light.style.animation = "flashbang 5s linear forwards"; + light.onanimationend = moonlight.flashbang.clean; + }, + clean: function() + { + const light = document.getElementById("flashbang"); + light.style.animation = ""; + light.style.opacity = "0"; + } } - } -}; \ No newline at end of file + }; \ No newline at end of file diff --git a/Moonlight/wwwroot/assets/js/recaptcha.js b/Moonlight/wwwroot/assets/js/recaptcha.js deleted file mode 100644 index b19f5fc..0000000 --- a/Moonlight/wwwroot/assets/js/recaptcha.js +++ /dev/null @@ -1,9 +0,0 @@ -window.recaptcha = new Object(); -window.recaptcha.render = function (id, sitekey, page) -{ - return grecaptcha.render(id, { - 'sitekey': sitekey, - 'callback': (response) => { page.invokeMethodAsync('CallbackOnSuccess', response); }, - 'expired-callback': () => { page.invokeMethodAsync('CallbackOnExpired'); } - }); -} \ No newline at end of file diff --git a/Moonlight/wwwroot/assets/js/snow.js b/Moonlight/wwwroot/assets/js/snow.js deleted file mode 100644 index 389e86e..0000000 --- a/Moonlight/wwwroot/assets/js/snow.js +++ /dev/null @@ -1,118 +0,0 @@ -window.createSnow = function () { - (function () { - var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || - function (callback) { - window.setTimeout(callback, 1000 / 60); - }; - window.requestAnimationFrame = requestAnimationFrame; - })(); - - - var flakes = [], - canvas = document.getElementById("snow"), - ctx = canvas.getContext("2d"), - flakeCount = 200, - mX = -100, - mY = -100 - - canvas.width = window.innerWidth; - canvas.height = window.innerHeight; - - function snow() { - ctx.clearRect(0, 0, canvas.width, canvas.height); - - for (var i = 0; i < flakeCount; i++) { - var flake = flakes[i], - x = mX, - y = mY, - minDist = 150, - x2 = flake.x, - y2 = flake.y; - - var dist = Math.sqrt((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y)), - dx = x2 - x, - dy = y2 - y; - - if (dist < minDist) { - var force = minDist / (dist * dist), - xcomp = (x - x2) / dist, - ycomp = (y - y2) / dist, - deltaV = force / 2; - - flake.velX -= deltaV * xcomp; - flake.velY -= deltaV * ycomp; - - } else { - flake.velX *= .98; - if (flake.velY <= flake.speed) { - flake.velY = flake.speed - } - flake.velX += Math.cos(flake.step += .05) * flake.stepSize; - } - - ctx.fillStyle = "rgba(255,255,255," + flake.opacity + ")"; - flake.y += flake.velY; - flake.x += flake.velX; - - if (flake.y >= canvas.height || flake.y <= 0) { - reset(flake); - } - - - if (flake.x >= canvas.width || flake.x <= 0) { - reset(flake); - } - - ctx.beginPath(); - ctx.arc(flake.x, flake.y, flake.size, 0, Math.PI * 2); - ctx.fill(); - } - requestAnimationFrame(snow); - }; - - function reset(flake) { - flake.x = Math.floor(Math.random() * canvas.width); - flake.y = 0; - flake.size = (Math.random() * 3) + 2; - flake.speed = (Math.random() * 1) + 0.5; - flake.velY = flake.speed; - flake.velX = 0; - flake.opacity = (Math.random() * 0.5) + 0.3; - } - - function init() { - for (var i = 0; i < flakeCount; i++) { - var x = Math.floor(Math.random() * canvas.width), - y = Math.floor(Math.random() * canvas.height), - size = (Math.random() * 3) + 2, - speed = (Math.random() * 1) + 0.5, - opacity = (Math.random() * 0.5) + 0.3; - - flakes.push({ - speed: speed, - velY: speed, - velX: 0, - x: x, - y: y, - size: size, - stepSize: (Math.random()) / 30, - step: 0, - opacity: opacity - }); - } - - snow(); - }; - - canvas.addEventListener("mousemove", function (e) { - mX = e.clientX, - mY = e.clientY - }); - - window.addEventListener("resize", function () { - canvas.width = window.innerWidth; - canvas.height = window.innerHeight; - }) - - init(); -} \ No newline at end of file diff --git a/Moonlight/wwwroot/assets/js/toastUtils.js b/Moonlight/wwwroot/assets/js/toastUtils.js deleted file mode 100644 index cbccb04..0000000 --- a/Moonlight/wwwroot/assets/js/toastUtils.js +++ /dev/null @@ -1,52 +0,0 @@ -window.showInfoToast = function (msg) { - toastr['info'](msg); -} - -window.showErrorToast = function (msg) { - toastr['error'](msg); -} - -window.showSuccessToast = function (msg) { - toastr['success'](msg); -} - -window.showWarningToast = function (msg) { - toastr['warning'](msg); -} - -window.createToast = function (id, text) { - var toast = toastr.success(text, '', - { - closeButton: true, - progressBar: false, - tapToDismiss: false, - timeOut: 0, - extendedTimeOut: 0, - positionClass: "toastr-bottom-right", - preventDuplicates: false, - onclick: function () { - toastr.clear(toast); - } - }); - var toastElement = toast[0]; - toastElement.setAttribute('data-toast-id', id); - toastElement.classList.add("bg-secondary"); -} - -window.modifyToast = function (id, newText) { - var toast = document.querySelector('[data-toast-id="' + id + '"]'); - - if (toast) { - var toastMessage = toast.lastChild; - if (toastMessage) { - toastMessage.innerHTML = newText; - } - } -} - -window.removeToast = function (id) { - var toast = document.querySelector('[data-toast-id="' + id + '"]'); - if (toast) { - toast.childNodes.item(1).click(); - } -} \ No newline at end of file diff --git a/Moonlight/wwwroot/assets/js/utils.js b/Moonlight/wwwroot/assets/js/utils.js deleted file mode 100644 index d584c0c..0000000 --- a/Moonlight/wwwroot/assets/js/utils.js +++ /dev/null @@ -1,42 +0,0 @@ -window.scrollToElement = function (id) -{ - let e = document.getElementById(id); - e.scrollTop = e.scrollHeight; -}; - -window.showModal = function (name) -{ - $('#' + name).modal('show'); -} - -window.hideModal = function (name) -{ - $('#' + name).modal('hide'); -} - -window.attachFileUploadWebkit = function (id) -{ - document.getElementById(id).addEventListener("change", function(e) { - var files = []; - - Array.from(e.target.files).forEach(file => { - files.push(file.webkitRelativePath); - }); - - window.webkitStorage = files; - }); -}; - -window.getWebkitStorage = function () -{ - return window.webkitStorage; -}; - -window.triggerResizeEvent = function () -{ - window.dispatchEvent(new Event('resize')); -} - -window.showNotification = function (title, text, img) { - let notification = new Notification(title, { body: text, icon: img }); -} \ No newline at end of file diff --git a/Moonlight/wwwroot/assets/js/xtermAddons.js b/Moonlight/wwwroot/assets/js/xtermAddons.js deleted file mode 100644 index c8fe21c..0000000 --- a/Moonlight/wwwroot/assets/js/xtermAddons.js +++ /dev/null @@ -1,3 +0,0 @@ -window.XtermBlazor.registerAddon("xterm-addon-fit", new window.FitAddon.FitAddon()); -window.XtermBlazor.registerAddon("xterm-addon-search", new window.SearchAddon.SearchAddon()); -window.XtermBlazor.registerAddon("xterm-addon-web-links", new window.WebLinksAddon.WebLinksAddon()); \ No newline at end of file