From 709d211297e32ac213beaf2245295e05e6d3b4b6 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Tue, 23 Apr 2024 23:26:13 +0200 Subject: [PATCH 1/4] rename eye part image file This totally isnt because Windows can't handle this file name and because this is annoying when using a shell which interprets the less and greater than signs as input/output redirection. --- parts.json | 2 +- parts/{eyes_><.png => eyes_squint.png} | Bin 2 files changed, 1 insertion(+), 1 deletion(-) rename parts/{eyes_><.png => eyes_squint.png} (100%) diff --git a/parts.json b/parts.json index c19dcb0..944efbd 100644 --- a/parts.json +++ b/parts.json @@ -13,7 +13,7 @@ {"name": "devil", "url": "/parts/eyes_devil.png"}, {"name": "drowsy", "url": "/parts/eyes_drowsy.png"}, {"name": "evil", "url": "/parts/eyes_evil.png"}, - {"name": ">_<", "url": "/parts/eyes_><.png"}, + {"name": ">_<", "url": "/parts/eyes_squint.png"}, {"name": "cry", "url": "/parts/eyes_cry.png"}, {"name": "owo", "url": "/parts/eyes_owo.png"}, {"name": "sad", "url": "/parts/eyes_sad.png"}, diff --git a/parts/eyes_><.png b/parts/eyes_squint.png similarity index 100% rename from parts/eyes_><.png rename to parts/eyes_squint.png From 4cc1f0d7ca0c73fbcd2207e89243419b4049f8ee Mon Sep 17 00:00:00 2001 From: Johann150 Date: Tue, 23 Apr 2024 23:01:28 +0200 Subject: [PATCH 2/4] fix spacing --- index.html | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index ce7eaa7..6a5d09a 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,6 @@ Neomojimixer (BETA) -

Neomojimixer (BETA)

@@ -39,11 +38,9 @@
  • Neoredpanda by Ente
  • Sourcecode on Codeberg: Neomojimixer -

    This work is licensed under CC BY-NC-SA 4.0

    - +

    This work is licensed under CC BY-NC-SA 4.0

    + - + - - From 2bd7ec3818e35c56b490fc689e2efb0859f86f01 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Tue, 23 Apr 2024 23:02:23 +0200 Subject: [PATCH 3/4] direct link ability This allows to link directly to one variant of an emoji by using the URL fragment, which will in turn be selected from the available boxes. --- neomojimixer.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/neomojimixer.js b/neomojimixer.js index 6a50a50..c237290 100644 --- a/neomojimixer.js +++ b/neomojimixer.js @@ -224,6 +224,14 @@ const NeomojiMixer = (function(NeomojiMixer) { //Randomize initial view randomize(); + // If there was a hash, restore as a direct permalink. + if (document.location.hash != "") { + loadFromHash(document.location.hash); + } + window.addEventListener("hashchange", () => { + loadFromHash(document.location.hash); + }); + //Show little statistic var sum = 0; var variety = 1; @@ -243,6 +251,26 @@ const NeomojiMixer = (function(NeomojiMixer) { } + function loadFromHash(hash) { + let parts = hash + .slice(1) // the first character is always the '#' sign + .split('+'); + + // define a constant order for the parts to appear in the hash + const parts_order = ["body", "eyes", "mouth", "arms"]; + + if (parts.length == parts_order.length) { + // convert the part names to part indices + parts = parts.map((name, i) => + Array.from(part_handlers[parts_order[i]].name_element.options).findIndex(x => x.value === name) + ); + if (parts.every(x => x != -1)) { + // all part names were found + parts.forEach((part_index, i) => part_handlers[parts_order[i]].setIndex(part_index)); + } + } + } + function randomize() { //Randomize which parts are shown for (const i in part_handlers) { part_handlers[i].randomize(); From 90d156e3f291a57d3a9385a88556e507afade59b Mon Sep 17 00:00:00 2001 From: Johann150 Date: Tue, 23 Apr 2024 23:04:54 +0200 Subject: [PATCH 4/4] output direct link for export --- index.html | 2 +- neomojimixer.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 6a5d09a..927fc39 100644 --- a/index.html +++ b/index.html @@ -28,7 +28,7 @@ - +

    Neomojis are from the following sources:

    • Neofox by Volpeon
    • diff --git a/neomojimixer.js b/neomojimixer.js index c237290..ea518b2 100644 --- a/neomojimixer.js +++ b/neomojimixer.js @@ -282,7 +282,9 @@ const NeomojiMixer = (function(NeomojiMixer) { ctx.clearRect(0, 0, canvas.width, canvas.height); - neomoji_name.value = part_handlers.body.getSelectedEntry()[0] + "_" + part_handlers.eyes.getSelectedEntry()[0] + "_" + part_handlers.mouth.getSelectedEntry()[0] + "_" + part_handlers.arms.getSelectedEntry()[0]; //Set name for the emoji to use as the image name and to show as shortcode + //Set name for the emoji to use as the image name and to show as shortcode + neomoji_name.innerText = part_handlers.body.getSelectedEntry()[0] + "_" + part_handlers.eyes.getSelectedEntry()[0] + "_" + part_handlers.mouth.getSelectedEntry()[0] + "_" + part_handlers.arms.getSelectedEntry()[0]; + neomoji_name.href = new URL("#" + part_handlers.body.getSelectedEntry()[0] + "+" + part_handlers.eyes.getSelectedEntry()[0] + "+" + part_handlers.mouth.getSelectedEntry()[0] + "+" + part_handlers.arms.getSelectedEntry()[0], document.location.href) let export_layers = [ part_handlers.body.createExportImage(),