Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Edwards committed Apr 21, 2024
1 parent 784e9d6 commit ae2bded
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 45 deletions.
4 changes: 4 additions & 0 deletions Crypter.Web/Crypter.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@
<ProjectReference Include="..\Crypter.Crypto.Providers.Browser\Crypter.Crypto.Providers.Browser.csproj" />
</ItemGroup>

<ItemGroup>
<Content Include="wwwroot\js\initServiceWorker.js" />
</ItemGroup>

</Project>
31 changes: 2 additions & 29 deletions Crypter.Web/wwwroot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,35 +76,8 @@ <h2>Loading...</h2>
<script src="js/scripts.js"></script>
<script src="lib/bootstrap-5.2.3-dist/js/bootstrap.bundle.min.js"></script>
<script src="_framework/blazor.webassembly.js" autostart="false"></script>
<script>
Blazor.start({
environment: window.location.hostname === "localhost"
? "Development"
: "Production"
});
</script>

<script>
if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("/service-worker.js")
.then(function (registration) {
console.log("Service Worker registered with scope:", registration.scope);
})
.catch(function (error) {
console.error("Failed to register Service Worker:", error);
});
}
</script>

<script>
async function sendStreamToServiceWorker(fileName, stream) {
const registration = await navigator.serviceWorker.getRegistration();
if (registration) {
// Send the stream to the service worker
registration.active.postMessage({ fileName, stream }, [stream]);
}
}
</script>
<script src="js/blazorStartup.js"></script>
<script src="js/initServiceWorker.js"></script>
</body>

</html>
5 changes: 5 additions & 0 deletions Crypter.Web/wwwroot/js/blazorStartup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Blazor.start({
environment: window.location.hostname === "localhost"
? "Development"
: "Production"
});
12 changes: 6 additions & 6 deletions Crypter.Web/wwwroot/js/downloadFileModule.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var _downloadBlob = null;
var _downloadLink = null;
var _downloadUrl = "";
var _fileName = "";
let _downloadBlob = null;
let _downloadLink = null;
let _downloadUrl = "";
let _fileName = "";

export function createBlob(fileName, contentType, fileBytes) {
_fileName = fileName;
Expand All @@ -25,7 +25,7 @@ export function reset() {
URL.revokeObjectURL(_downloadUrl);
document.body.removeChild(_downloadLink);
} catch { }
_downloadBlob = null;
_downloadLink = null;
_downloadBlob = null;
_downloadLink = null;
_downloadUrl = "";
}
17 changes: 17 additions & 0 deletions Crypter.Web/wwwroot/js/initServiceWorker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("/serviceWorker.js")
.then(function (registration) {
console.log("Service Worker registered with scope:", registration.scope);
})
.catch(function (error) {
console.error("Failed to register Service Worker:", error);
});
}

async function sendStreamToServiceWorker(fileName, stream) {
const registration = await navigator.serviceWorker.getRegistration();
if (registration) {
// Send the stream to the service worker
registration.active.postMessage({ fileName, stream }, [stream]);
}
}
20 changes: 10 additions & 10 deletions Crypter.Web/wwwroot/js/scripts.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
window.Crypter = {
CopyToClipboard: function (text) {
const animationTiming = {
duration: 500,
iterations: 1
duration: 500,
iterations: 1
};

navigator.clipboard.writeText(text).then(() => {
Expand All @@ -14,17 +14,17 @@
setTimeout(() => {
document.querySelector('.toolTipText').animate([{ opacity: 1 }, { opacity: 0 }], animationTiming)
.onfinish = (e) => {
document.querySelector('.toolTipText').style.display = 'none';
}
}, 500);
document.querySelector('.toolTipText').style.display = 'none';
}
}, 500);
}
});
},

SetActivePage: function (page) {
var pages = document.getElementsByClassName('page');
for (var i = 0; i < pages.length; i++) {
if (pages[i].textContent == page) {
let pages = document.getElementsByClassName('page');
for (let i = 0; i < pages.length; i++) {
if (pages[i].textContent === page) {
pages[i].classList.add('active');
}
}
Expand All @@ -35,7 +35,7 @@
},

CollapseNavBar: function () {
var nav = document.getElementById('mainNavigation');
nav.classList.remove('show');
let nav = document.getElementById('mainNavigation');
nav.classList.remove('show');
}
}
File renamed without changes.

0 comments on commit ae2bded

Please sign in to comment.