Fix other domains (#7)
* Make main compressor capable of other domains * Fix missing bracket * Domain needs to contain port as well * Add decode functionality for other domains --------- Co-authored-by: p2r3 <41925384+p2r3@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
b609b3acf7
commit
2f7e26b02b
@@ -5,6 +5,15 @@ import {
|
||||
outputAlphabetEmoji
|
||||
} from "./alphabets.js";
|
||||
|
||||
let domain = window.location.hostname;
|
||||
if (domain !== "ha.mr" && domain !== "www.ha.mr") {
|
||||
console.log(`This page is intended to be used on the ha.mr domain. You are currently on ${domain}.`);
|
||||
}
|
||||
const webPort = window.location.port;
|
||||
if (webPort && webPort !== "80" && webPort !== "443") {
|
||||
domain += `:${webPort}`;
|
||||
}
|
||||
|
||||
var settings = {
|
||||
emoji: false,
|
||||
qr: false
|
||||
@@ -116,8 +125,8 @@ function updateOutput () {
|
||||
outputRatioElement.textContent = "Output is the same length as the input";
|
||||
outputRatioElement.style.color = "gray";
|
||||
}
|
||||
outputLinkElement.textContent = `http://ha.mr#${output}`;
|
||||
outputLinkElement.href = `http://ha.mr#${output}`;
|
||||
outputLinkElement.textContent = `http://${domain}#${output}`;
|
||||
outputLinkElement.href = `http://${domain}#${output}`;
|
||||
outputLinkElement.style.color = "";
|
||||
if (settings.qr) {
|
||||
const correctionLevels = ["L", "M", "Q", "H"];
|
||||
@@ -125,7 +134,8 @@ function updateOutput () {
|
||||
qrCodeImage.style.display = "inline";
|
||||
qrCodeCorrectionLevelContainer.style.display = "inline";
|
||||
|
||||
const qrCodeLink = `HTTP://HA.MR/${compress(input, outputAlphabetQR)}`;
|
||||
const qrCodeDomain = domain.toUpperCase();
|
||||
const qrCodeLink = `HTTP://${qrCodeDomain}/${compress(input, outputAlphabetQR)}`;
|
||||
|
||||
if (!qrCorrectionManuallySet) {
|
||||
const optimalLevel = getOptimalErrorCorrectionLevel(qrCodeLink);
|
||||
|
||||
Reference in New Issue
Block a user