Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
manav-sharma69 authored Jul 25, 2024
2 parents f75eded + 878a5da commit 136fa69
Show file tree
Hide file tree
Showing 28 changed files with 61 additions and 44 deletions.
15 changes: 12 additions & 3 deletions pointer-lock/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,18 @@ canvasDraw();

canvas.addEventListener("click", async () => {
if(!document.pointerLockElement) {
await canvas.requestPointerLock({
unadjustedMovement: true,
});
try {
await canvas.requestPointerLock({
unadjustedMovement: true,
});
} catch (error) {
if (error.name === "NotSupportedError") {
// Some platforms may not support unadjusted movement.
await canvas.requestPointerLock();
} else {
throw error;
}
}
}
});

Expand Down
2 changes: 1 addition & 1 deletion web-crypto/derive-bits/ecdh.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
sharedSecretValue.classList.add("fade-in");
sharedSecretValue.addEventListener("animationend", () => {
sharedSecretValue.classList.remove("fade-in");
});
}, { once: true });
sharedSecretValue.textContent = `${buffer}...[${sharedSecret.byteLength} bytes total]`;
}

Expand Down
2 changes: 1 addition & 1 deletion web-crypto/derive-bits/pbkdf2.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
derivedBitsValue.classList.add("fade-in");
derivedBitsValue.addEventListener("animationend", () => {
derivedBitsValue.classList.remove("fade-in");
});
}, { once: true });
derivedBitsValue.textContent = `${buffer}...[${derivedBits.byteLength} bytes total]`;
}

Expand Down
4 changes: 2 additions & 2 deletions web-crypto/derive-key/ecdh.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
ciphertextValue.classList.add("fade-in");
ciphertextValue.addEventListener("animationend", () => {
ciphertextValue.classList.remove("fade-in");
});
}, { once: true });
ciphertextValue.textContent = `${buffer}...[${ciphertext.byteLength} bytes total]`;
}

Expand Down Expand Up @@ -69,7 +69,7 @@
decryptedValue.classList.add("fade-in");
decryptedValue.addEventListener("animationend", () => {
decryptedValue.classList.remove("fade-in");
});
}, { once: true });
decryptedValue.textContent = dec.decode(decrypted);
} catch (e) {
decryptedValue.classList.add("error");
Expand Down
4 changes: 2 additions & 2 deletions web-crypto/derive-key/pbkdf2.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
ciphertextValue.classList.add("fade-in");
ciphertextValue.addEventListener("animationend", () => {
ciphertextValue.classList.remove("fade-in");
});
}, { once: true });
ciphertextValue.textContent = `${buffer}...[${ciphertext.byteLength} bytes total]`;
}

Expand Down Expand Up @@ -114,7 +114,7 @@
decryptedValue.classList.add("fade-in");
decryptedValue.addEventListener("animationend", () => {
decryptedValue.classList.remove("fade-in");
});
}, { once: true });
decryptedValue.textContent = dec.decode(decrypted);
} catch (e) {
decryptedValue.classList.add("error");
Expand Down
4 changes: 2 additions & 2 deletions web-crypto/encrypt-decrypt/aes-cbc.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
ciphertextValue.classList.add('fade-in');
ciphertextValue.addEventListener('animationend', () => {
ciphertextValue.classList.remove('fade-in');
});
}, { once: true });
ciphertextValue.textContent = `${buffer}...[${ciphertext.byteLength} bytes total]`;
}

Expand All @@ -62,7 +62,7 @@
decryptedValue.classList.add('fade-in');
decryptedValue.addEventListener('animationend', () => {
decryptedValue.classList.remove('fade-in');
});
}, { once: true });
decryptedValue.textContent = dec.decode(decrypted);
}

Expand Down
4 changes: 2 additions & 2 deletions web-crypto/encrypt-decrypt/aes-ctr.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
ciphertextValue.classList.add('fade-in');
ciphertextValue.addEventListener('animationend', () => {
ciphertextValue.classList.remove('fade-in');
});
}, { once: true });
ciphertextValue.textContent = `${buffer}...[${ciphertext.byteLength} bytes total]`;
}

Expand All @@ -64,7 +64,7 @@
decryptedValue.classList.add('fade-in');
decryptedValue.addEventListener('animationend', () => {
decryptedValue.classList.remove('fade-in');
});
}, { once: true });
decryptedValue.textContent = dec.decode(decrypted);
}

Expand Down
4 changes: 2 additions & 2 deletions web-crypto/encrypt-decrypt/aes-gcm.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
ciphertextValue.classList.add('fade-in');
ciphertextValue.addEventListener('animationend', () => {
ciphertextValue.classList.remove('fade-in');
});
}, { once: true });
ciphertextValue.textContent = `${buffer}...[${ciphertext.byteLength} bytes total]`;
}

Expand All @@ -62,7 +62,7 @@
decryptedValue.classList.add('fade-in');
decryptedValue.addEventListener('animationend', () => {
decryptedValue.classList.remove('fade-in');
});
}, { once: true });
decryptedValue.textContent = dec.decode(decrypted);
}

Expand Down
4 changes: 2 additions & 2 deletions web-crypto/encrypt-decrypt/rsa-oaep.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
ciphertextValue.classList.add('fade-in');
ciphertextValue.addEventListener('animationend', () => {
ciphertextValue.classList.remove('fade-in');
});
}, { once: true });
ciphertextValue.textContent = `${buffer}...[${ciphertext.byteLength} bytes total]`;
}

Expand All @@ -57,7 +57,7 @@
decryptedValue.classList.add('fade-in');
decryptedValue.addEventListener('animationend', () => {
decryptedValue.classList.remove('fade-in');
});
}, { once: true });
decryptedValue.textContent = dec.decode(decrypted);
}

Expand Down
2 changes: 1 addition & 1 deletion web-crypto/export-key/jwk.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
exportKeyOutput.classList.add("fade-in");
exportKeyOutput.addEventListener("animationend", () => {
exportKeyOutput.classList.remove("fade-in");
});
}, { once: true });
exportKeyOutput.textContent = JSON.stringify(exported, null, " ");
}

Expand Down
2 changes: 1 addition & 1 deletion web-crypto/export-key/pkcs8.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
exportKeyOutput.classList.add("fade-in");
exportKeyOutput.addEventListener("animationend", () => {
exportKeyOutput.classList.remove("fade-in");
});
}, { once: true });
exportKeyOutput.textContent = pemExported;
}

Expand Down
2 changes: 1 addition & 1 deletion web-crypto/export-key/raw.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
exportKeyOutput.classList.add("fade-in");
exportKeyOutput.addEventListener("animationend", () => {
exportKeyOutput.classList.remove("fade-in");
});
}, { once: true });
exportKeyOutput.textContent = `[${exportedKeyBuffer}]`;
}

Expand Down
2 changes: 1 addition & 1 deletion web-crypto/export-key/spki.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
exportKeyOutput.classList.add("fade-in");
exportKeyOutput.addEventListener("animationend", () => {
exportKeyOutput.classList.remove("fade-in");
});
}, { once: true });
exportKeyOutput.textContent = pemExported;
}

Expand Down
4 changes: 2 additions & 2 deletions web-crypto/import-key/jwk.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
signatureValue.classList.add('fade-in');
signatureValue.addEventListener('animationend', () => {
signatureValue.classList.remove('fade-in');
});
}, { once: true });
const buffer = new Uint8Array(signature, 0, 5);
signatureValue.textContent = `${buffer}...[${signature.byteLength} bytes total]`;
}
Expand All @@ -77,7 +77,7 @@
signButton.classList.add('fade-in');
signButton.addEventListener('animationend', () => {
signButton.classList.remove('fade-in');
});
}, { once: true });
signButton.removeAttribute("disabled");
signButton.classList.remove("hidden");
}
Expand Down
4 changes: 2 additions & 2 deletions web-crypto/import-key/pkcs8.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDD0tPV/du2vftjvXj1t/gXTK39sNBV
signatureValue.classList.add('fade-in');
signatureValue.addEventListener('animationend', () => {
signatureValue.classList.remove('fade-in');
});
}, { once: true });
const buffer = new Uint8Array(signature, 0, 5);
signatureValue.textContent = `${buffer}...[${signature.byteLength} bytes total]`;
}
Expand All @@ -96,7 +96,7 @@ MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDD0tPV/du2vftjvXj1t/gXTK39sNBV
signButton.classList.add('fade-in');
signButton.addEventListener('animationend', () => {
signButton.classList.remove('fade-in');
});
}, { once: true });
signButton.removeAttribute("disabled");
signButton.classList.remove("hidden");
}
Expand Down
4 changes: 2 additions & 2 deletions web-crypto/import-key/raw.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
ciphertextValue.classList.add('fade-in');
ciphertextValue.addEventListener('animationend', () => {
ciphertextValue.classList.remove('fade-in');
});
}, { once: true });
ciphertextValue.textContent = `${buffer}...[${ciphertext.byteLength} bytes total]`;
}

Expand All @@ -68,7 +68,7 @@
encryptButton.classList.add('fade-in');
encryptButton.addEventListener('animationend', () => {
encryptButton.classList.remove('fade-in');
});
}, { once: true });
encryptButton.removeAttribute("disabled");
encryptButton.classList.remove("hidden");
}
Expand Down
4 changes: 2 additions & 2 deletions web-crypto/import-key/spki.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAy3Xo3U13dc+xojwQYWoJLCbOQ5fOVY8Llnqc
ciphertextValue.classList.add('fade-in');
ciphertextValue.addEventListener('animationend', () => {
ciphertextValue.classList.remove('fade-in');
});
}, { once: true });
ciphertextValue.textContent = `${buffer}...[${ciphertext.byteLength} bytes total]`;
}

Expand All @@ -92,7 +92,7 @@ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAy3Xo3U13dc+xojwQYWoJLCbOQ5fOVY8Llnqc
encryptButton.classList.add('fade-in');
encryptButton.addEventListener('animationend', () => {
encryptButton.classList.remove('fade-in');
});
}, { once: true });
encryptButton.removeAttribute("disabled");
encryptButton.classList.remove("hidden");
}
Expand Down
2 changes: 1 addition & 1 deletion web-crypto/sign-verify/ecdsa.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
signatureValue.classList.add('fade-in');
signatureValue.addEventListener('animationend', () => {
signatureValue.classList.remove('fade-in');
});
}, { once: true });
let buffer = new Uint8Array(signature, 0, 5);
signatureValue.textContent = `${buffer}...[${signature.byteLength} bytes total]`;
}
Expand Down
2 changes: 1 addition & 1 deletion web-crypto/sign-verify/hmac.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
signatureValue.classList.add('fade-in');
signatureValue.addEventListener('animationend', () => {
signatureValue.classList.remove('fade-in');
});
}, { once: true });
let buffer = new Uint8Array(signature, 0, 5);
signatureValue.textContent = `${buffer}...[${signature.byteLength} bytes total]`;
}
Expand Down
2 changes: 1 addition & 1 deletion web-crypto/sign-verify/rsa-pss.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
signatureValue.classList.add('fade-in');
signatureValue.addEventListener('animationend', () => {
signatureValue.classList.remove('fade-in');
});
}, { once: true });
let buffer = new Uint8Array(signature, 0, 5);
signatureValue.textContent = `${buffer}...[${signature.byteLength} bytes total]`;
}
Expand Down
2 changes: 1 addition & 1 deletion web-crypto/sign-verify/rsassa-pkcs1.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
signatureValue.classList.add('fade-in');
signatureValue.addEventListener('animationend', () => {
signatureValue.classList.remove('fade-in');
});
}, { once: true });
let buffer = new Uint8Array(signature, 0, 5);
signatureValue.textContent = `${buffer}...[${signature.byteLength} bytes total]`;
}
Expand Down
4 changes: 2 additions & 2 deletions web-crypto/unwrap-key/pkcs8.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
signatureValue.classList.add('fade-in');
signatureValue.addEventListener('animationend', () => {
signatureValue.classList.remove('fade-in');
});
}, { once: true });
const buffer = new Uint8Array(signature, 0, 5);
signatureValue.textContent = `${buffer}...[${signature.byteLength} bytes total]`;
}
Expand All @@ -218,7 +218,7 @@
signButton.classList.add('fade-in');
signButton.addEventListener('animationend', () => {
signButton.classList.remove('fade-in');
});
}, { once: true });
signButton.removeAttribute("disabled");
signButton.classList.remove("hidden");
}
Expand Down
4 changes: 2 additions & 2 deletions web-crypto/unwrap-key/raw.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
ciphertextValue.classList.add('fade-in');
ciphertextValue.addEventListener('animationend', () => {
ciphertextValue.classList.remove('fade-in');
});
}, { once: true });
ciphertextValue.textContent = `${buffer}...[${ciphertext.byteLength} bytes total]`;
}

Expand All @@ -147,7 +147,7 @@
encryptButton.classList.add('fade-in');
encryptButton.addEventListener('animationend', () => {
encryptButton.classList.remove('fade-in');
});
}, { once: true });
encryptButton.removeAttribute("disabled");
encryptButton.classList.remove("hidden");
}
Expand Down
2 changes: 1 addition & 1 deletion web-crypto/wrap-key/jwk.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
wrappedKeyOutput.classList.add("fade-in");
wrappedKeyOutput.addEventListener("animationend", () => {
wrappedKeyOutput.classList.remove("fade-in");
});
}, { once: true });
wrappedKeyOutput.textContent = `[${wrappedKeyBuffer}]`;
}

Expand Down
2 changes: 1 addition & 1 deletion web-crypto/wrap-key/pkcs8.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
wrappedKeyOutput.classList.add("fade-in");
wrappedKeyOutput.addEventListener("animationend", () => {
wrappedKeyOutput.classList.remove("fade-in");
});
}, { once: true });
wrappedKeyOutput.textContent = `[${wrappedKeyBuffer}]`;
}

Expand Down
2 changes: 1 addition & 1 deletion web-crypto/wrap-key/raw.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
wrappedKeyOutput.classList.add("fade-in");
wrappedKeyOutput.addEventListener("animationend", () => {
wrappedKeyOutput.classList.remove("fade-in");
});
}, { once: true });
wrappedKeyOutput.textContent = `[${wrappedKeyBuffer}]`;
}

Expand Down
2 changes: 1 addition & 1 deletion web-crypto/wrap-key/spki.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
wrappedKeyOutput.classList.add("fade-in");
wrappedKeyOutput.addEventListener("animationend", () => {
wrappedKeyOutput.classList.remove("fade-in");
});
}, { once: true });
wrappedKeyOutput.textContent = `[${wrappedKeyBuffer}]`;
}

Expand Down
14 changes: 11 additions & 3 deletions web-share/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,26 @@ <h1>Sharing MDN</h1>
title: 'MDN',
text: 'Learn web development on MDN!',
url: 'https://developer.mozilla.org',
}
};

const btn = document.querySelector('button');
const resultPara = document.querySelector('.result');

btn.addEventListener('click', () => {
if (!navigator.canShare) {
resultPara.textContent = 'Web Share API not available';
return;
}
if (!navigator.canShare(shareData)) {
resultPara.textContent = 'Share data unsupported, disallowed, or invalid';
return;
}
navigator.share(shareData)
.then(() =>
resultPara.textContent = 'MDN shared successfully'
resultPara.textContent = 'MDN shared successfully';
)
.catch((e) =>
resultPara.textContent = 'Error: ' + e
resultPara.textContent = 'Error: ' + e;
)
});
</script>
Expand Down

0 comments on commit 136fa69

Please sign in to comment.