Skip to content

Commit

Permalink
feat: added query preset sharing
Browse files Browse the repository at this point in the history
added presests to previews in readme
increased version
  • Loading branch information
IPdotSetAF committed Apr 12, 2024
1 parent 0fcddb5 commit 2b04770
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 9 deletions.
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ This is a highly customizable animated Matrix wallpaper for Wallpaper Engine (We

## Preview [(Web Demo)](https://ipdotsetaf.github.io/NeoMatrix/)

Click on each preview to watch live

<p>
<img src="preview.gif" width=270px height=270px/>
<img src="images/preview2.gif" width=270px height=270px/>
<img src="images/preview3.gif" width=270px height=270px/>
<a href="https://ipdotsetaf.github.io/NeoMatrix/?preset=eyJjb250cm9sbGVycyI6e30sImZvbGRlcnMiOnsiUmFpbiI6eyJjb250cm9sbGVycyI6eyJNYXRyaXggU3BlZWQiOjI0LCJUcmFpbCBMZW5ndGgiOjAuODYsIkRyb3AgQ291bnQvQ29sdW1uIjoxLCJJbml0aWFsIEFuaW1hdGlvbiI6IjEifSwiZm9sZGVycyI6e319LCJDb2xvciI6eyJjb250cm9sbGVycyI6eyJDb2xvciBNb2RlIjoiMiIsIk1hdHJpeCBDb2xvciI6IiMwMGZmMDAiLCJDb2xvciBBbmltYXRpb24gU3BlZWQiOjAuNSwiSGlnaGxpZ2h0IEZpcnN0IENoYXJhY3RlciI6dHJ1ZX0sImZvbGRlcnMiOnt9fSwiQ2hhcmFjdGVycyI6eyJjb250cm9sbGVycyI6eyJDaGFyIHNldCI6IjQiLCJDdXN0b20gQ2hhciBTZXQiOiIwMTIzNDU2Nzg5QUJDREVGIn0sImZvbGRlcnMiOnt9fSwiRm9udCI6eyJjb250cm9sbGVycyI6eyJGb250IFNpemUiOjE1LCJGb250IjoiMSIsIkN1c3RvbSBGb250IjoibW9ub3NwYWNlIn0sImZvbGRlcnMiOnt9fSwiQXVkaW8gKG5vdCBhdmFpbGFibGUgaW4gd2ViIHZlcnNpb24pIjp7ImNvbnRyb2xsZXJzIjp7fSwiZm9sZGVycyI6e319LCJMb2dvIjp7ImNvbnRyb2xsZXJzIjp7IkxvZ28iOiIwIiwiQ3VzdG9tIExvZ28gVVJMIChTVkcpIjoiIiwiUHJlc2VydmUgTG9nbyBDb2xvciI6ZmFsc2UsIlNjYWxlIjoxfSwiZm9sZGVycyI6eyJQb3NpdGlvbiI6eyJjb250cm9sbGVycyI6eyJYIjowLCJZIjowfSwiZm9sZGVycyI6e319fX0sIkNsb2NrIjp7ImNvbnRyb2xsZXJzIjp7IkNsb2NrIjoiMCIsIjI0IEhvdXIgZm9ybWF0Ijp0cnVlLCJEYXktbGlnaHQgU2F2aW5nIjowLCJTY2FsZSI6MX0sImZvbGRlcnMiOnsiUG9zaXRpb24iOnsiY29udHJvbGxlcnMiOnsiWCI6MCwiWSI6MH0sImZvbGRlcnMiOnt9fX19LCJNZXNzYWdlIjp7ImNvbnRyb2xsZXJzIjp7Ik1lc3NhZ2UiOiIwIiwiTWVzc2FnZSBUZXh0IjoiVEhFIE1BVFJJWCIsIlNjYWxlIjoxfSwiZm9sZGVycyI6eyJQb3NpdGlvbiI6eyJjb250cm9sbGVycyI6eyJYIjowLCJZIjowfSwiZm9sZGVycyI6e319fX0sIk90aGVyIjp7ImNvbnRyb2xsZXJzIjp7IkNvZGVzIChDb21tYSBzZXBhcmF0ZWQpIjoiVEhFIE1BVFJJWCJ9LCJmb2xkZXJzIjp7fX19fQ%3D%3D"><img src="preview.gif" width=270px height=270px/></a>
<a href="https://ipdotsetaf.github.io/NeoMatrix/?preset=eyJjb250cm9sbGVycyI6e30sImZvbGRlcnMiOnsiUmFpbiI6eyJjb250cm9sbGVycyI6eyJNYXRyaXggU3BlZWQiOjI0LCJUcmFpbCBMZW5ndGgiOjAuODYsIkRyb3AgQ291bnQvQ29sdW1uIjoxLCJJbml0aWFsIEFuaW1hdGlvbiI6IjEifSwiZm9sZGVycyI6e319LCJDb2xvciI6eyJjb250cm9sbGVycy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ImNvbnRyb2xsZXJzIjp7IlgiOjAsIlkiOjB9LCJmb2xkZXJzIjp7fX19fSwiT3RoZXIiOnsiY29udHJvbGxlcnMiOnsiQ29kZXMgKENvbW1hIHNlcGFyYXRlZCkiOiJUSEUgTUFUUklYLEtBTEkifSwiZm9sZGVycyI6e319fX0%3D"><img src="images/preview2.gif" width=270px height=270px/></a>
<a href="https://ipdotsetaf.github.io/NeoMatrix/?preset=eyJjb250cm9sbGVycyI6e30sImZvbGRlcnMiOnsiUmFpbiI6eyJjb250cm9sbGVycyI6eyJNYXRyaXggU3BlZWQiOjI0LCJUcmFpbCBMZW5ndGgiOjAuODYsIkRyb3AgQ291bnQvQ29sdW1uIjoxLCJJbml0aWFsIEFuaW1hdGlvbiI6IjEifSwiZm9sZGVycyI6e319LCJDb2xvciI6eyJjb250cm9sbGVycyI6eyJDb2xvciBNb2RlIjoiMCIsIk1hdHJpeCBDb2xvciI6IiMwMGZmMDAiLCJDb2xvciBBbmltYXRpb24gU3BlZWQiOjAuNSwiSGlnaGxpZ2h0IEZpcnN0IENoYXJhY3RlciI6dHJ1ZX0sImZvbGRlcnMiOnt9fSwiQ2hhcmFjdGVycyI6eyJjb250cm9sbGVycyI6eyJDaGFyIHNldCI6IjQiLCJDdXN0b20gQ2hhciBTZXQiOiIwMTIzNDU2Nzg5QUJDREVGIn0sImZvbGRlcnMiOnt9fSwiRm9udCI6eyJjb250cm9sbGVycyI6eyJGb250IFNpemUiOjE3LCJGb250IjoiMSIsIkN1c3RvbSBGb250IjoibW9ub3NwYWNlIn0sImZvbGRlcnMiOnt9fSwiQXVkaW8gKG5vdCBhdmFpbGFibGUgaW4gd2ViIHZlcnNpb24pIjp7ImNvbnRyb2xsZXJzIjp7fSwiZm9sZGVycyI6e319LCJMb2dvIjp7ImNvbnRyb2xsZXJzIjp7IkxvZ28iOiIwIiwiQ3VzdG9tIExvZ28gVVJMIChTVkcpIjoiIiwiUHJlc2VydmUgTG9nbyBDb2xvciI6ZmFsc2UsIlNjYWxlIjoxfSwiZm9sZGVycyI6eyJQb3NpdGlvbiI6eyJjb250cm9sbGVycyI6eyJYIjowLCJZIjowfSwiZm9sZGVycyI6e319fX0sIkNsb2NrIjp7ImNvbnRyb2xsZXJzIjp7IkNsb2NrIjoiMCIsIjI0IEhvdXIgZm9ybWF0Ijp0cnVlLCJEYXktbGlnaHQgU2F2aW5nIjowLCJTY2FsZSI6MX0sImZvbGRlcnMiOnsiUG9zaXRpb24iOnsiY29udHJvbGxlcnMiOnsiWCI6MCwiWSI6MH0sImZvbGRlcnMiOnt9fX19LCJNZXNzYWdlIjp7ImNvbnRyb2xsZXJzIjp7Ik1lc3NhZ2UiOiIwIiwiTWVzc2FnZSBUZXh0IjoiVEhFIE1BVFJJWCIsIlNjYWxlIjoxfSwiZm9sZGVycyI6eyJQb3NpdGlvbiI6eyJjb250cm9sbGVycyI6eyJYIjowLCJZIjowfSwiZm9sZGVycyI6e319fX0sIk90aGVyIjp7ImNvbnRyb2xsZXJzIjp7IkNvZGVzIChDb21tYSBzZXBhcmF0ZWQpIjoiVEhFIE1BVFJJWCJ9LCJmb2xkZXJzIjp7fX19fQ%3D%3D"><img src="images/preview3.gif" width=270px height=270px/></a>
</p>
<p>
<img src="images/preview4.gif" width=270px height=270px/>
<img src="images/preview5.gif" width=270px height=270px/>
<img src="images/preview6.gif" width=270px height=270px/>
<a href="https://ipdotsetaf.github.io/NeoMatrix/?preset=eyJjb250cm9sbGVycyI6e30sImZvbGRlcnMiOnsiUmFpbiI6eyJjb250cm9sbGVycyI6eyJNYXRyaXggU3BlZWQiOjI0LCJUcmFpbCBMZW5ndGgiOjAuODYsIkRyb3AgQ291bnQvQ29sdW1uIjoxLCJJbml0aWFsIEFuaW1hdGlvbiI6IjEifSwiZm9sZGVycyI6e319LCJDb2xvciI6eyJjb250cm9sbGVycyI6eyJDb2xvciBNb2RlIjoiMCIsIk1hdHJpeCBDb2xvciI6IiMwMGZmMDAiLCJDb2xvciBBbmltYXRpb24gU3Bl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Y29udHJvbGxlcnMiOnsiQ29kZXMgKENvbW1hIHNlcGFyYXRlZCkiOiJUSEUgTUFUUklYIn0sImZvbGRlcnMiOnt9fX19"><img src="images/preview4.gif" width=270px height=270px/></a>
<a href="https://ipdotsetaf.github.io/NeoMatrix/?preset=eyJjb250cm9sbGVycyI6e30sImZvbGRlcnMiOnsiUmFpbiI6eyJjb250cm9sbGVycyI6eyJNYXRyaXggU3BlZWQiOjI0LCJUcmFpbCBMZW5ndGgiOjAuODYsIkRyb3AgQ291bnQvQ29sdW1uIjoxLCJJbml0aWFsIEFuaW1hdGlvbiI6IjIifSwiZm9sZGVycyI6e319LCJDb2xvciI6eyJjb250cm9sbGVycyI6eyJDb2xvciBNb2RlIjoiMSIsIk1hdHJpeCBDb2xvciI6IiMwMGZmMDAiLCJDb2xvciBBbmltYXRpb24gU3BlZWQiOjAuMDcsIkhpZ2hsaWdodCBGaXJzdCBDaGFyYWN0ZXIiOnRydWV9LCJmb2xkZXJzIjp7fX0sIkNoYXJhY3RlcnMiOnsiY29udHJvbGxlcnMiOnsiQ2hhciBzZXQiOiIzIiwiQ3VzdG9tIENoYXIgU2V0IjoiMDEyMzQ1Njc4OUFCQ0RFRiJ9LCJmb2xkZXJzIjp7fX0sIkZvbnQiOnsiY29udHJvbGxlcnMiOnsiRm9udCBTaXplIjoxNSwiRm9udCI6IjMiLCJDdXN0b20gRm9udCI6Im1vbm9zcGFjZSJ9LCJmb2xkZXJzIjp7fX0sIkF1ZGlvIChub3QgYXZhaWxhYmxlIGluIHdlYiB2ZXJzaW9uKSI6eyJjb250cm9sbGVycyI6e30sImZvbGRlcnMiOnt9fSwiTG9nbyI6eyJjb250cm9sbGVycyI6eyJMb2dvIjoiMiIsIkN1c3RvbSBMb2dvIFVSTCAoU1ZHKSI6IiIsIlByZXNlcnZlIExvZ28gQ29sb3IiOmZhbHNlLCJTY2FsZSI6MX0sImZvbGRlcnMiOnsiUG9zaXRpb24iOnsiY29udHJvbGxlcnMiOnsiWCI6MTU2LCJZIjowfSwiZm9sZGVycyI6e319fX0sIkNsb2NrIjp7ImNvbnRyb2xsZXJzIjp7IkNsb2NrIjoiNCIsIjI0IEhvdXIgZm9ybWF0Ijp0cnVlLCJEYXktbGlnaHQgU2F2aW5nIjowLCJTY2FsZSI6MX0sImZvbGRlcnMiOnsiUG9zaXRpb24iOnsiY29udHJvbGxlcnMiOnsiWCI6LTEzLCJZIjowfSwiZm9sZGVycyI6e319fX0sIk1lc3NhZ2UiOnsiY29udHJvbGxlcnMiOnsiTWVzc2FnZSI6IjAiLCJNZXNzYWdlIFRleHQiOiJUSEUgTUFUUklYIiwiU2NhbGUiOjF9LCJmb2xkZXJzIjp7IlBvc2l0aW9uIjp7ImNvbnRyb2xsZXJzIjp7IlgiOjAsIlkiOjB9LCJmb2xkZXJzIjp7fX19fSwiT3RoZXIiOnsiY29udHJvbGxlcnMiOnsiQ29kZXMgKENvbW1hIHNlcGFyYXRlZCkiOiJUSEUgTUFUUklYIn0sImZvbGRlcnMiOnt9fX19"><img src="images/preview5.gif" width=270px height=270px/></a>
<a href="https://ipdotsetaf.github.io/NeoMatrix/?preset=eyJjb250cm9sbGVycyI6e30sImZvbGRlcnMiOnsiUmFpbiI6eyJjb250cm9sbGVycyI6eyJNYXRyaXggU3BlZWQiOjI0LCJUcmFpbCBMZW5ndGgiOjAuODYsIkRyb3AgQ291bnQvQ29sdW1uIjoxLCJJbml0aWFsIEFuaW1hdGlvbiI6IjEifSwiZm9sZGVycyI6e319LCJDb2xvciI6eyJjb250cm9sbGVycyI6eyJDb2xvciBNb2RlIjoiMCIsIk1hdHJpeCBDb2xvciI6IiMwMGZmMDAiLCJDb2xvciBBbmltYXRpb24gU3BlZWQiOjAuNSwiSGlnaGxpZ2h0IEZpcnN0IENoYXJhY3RlciI6ZmFsc2V9LCJmb2xkZXJzIjp7fX0sIkNoYXJhY3RlcnMiOnsiY29udHJvbGxlcnMiOnsiQ2hhciBzZXQiOiI0IiwiQ3VzdG9tIENoYXIg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124,11 @@ This is a highly customizable animated Matrix wallpaper for Wallpaper Engine (We
- Codes (these will be shown as decrypted Messages)

### ✔️ Web Browser Compatible
- Preset save/load
- Preset
- Share (URL)
- Save
- Load
- Reset

## Are you ready to be free?

Expand Down
63 changes: 61 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
window.onload = function () {
//MARK: Update
const version = "v5.0.0";
const version = "v5.1.0";

checkForUpdates = async () => {
const url = 'https://api.github.com/repos/IPdotSetAF/NeoMatrix/tags';
Expand All @@ -15,6 +15,7 @@ window.onload = function () {

//MARK: Options
var gui;
var defaultOptions;
var options = {
ui_rain_matrixSpeed: 24,
fpsInterval: calculateFpsInterval(24),
Expand Down Expand Up @@ -56,6 +57,10 @@ window.onload = function () {
ui_message_scale: 1,
ui_message_positionX: 0,
ui_message_positionY: 0,
Share() {
copyToClipboard(paramsToUrl({ preset: btoa(JSON.stringify(gui.save())) }, {}, []));
Log("Copied Preset URL to clipboard.");
},
Save() {
window.localStorage.setItem("preset", JSON.stringify(gui.save()));
Log("Saved preset.");
Expand All @@ -71,6 +76,14 @@ window.onload = function () {
Reset() {
gui.reset();
Log("Settings reset to default.");
},
LoadFrom(params) {
let preset = gui.load(JSON.parse(atob(params.preset)));
if (preset) {
gui.load(preset);
Log("Loaded preset from URL.");
} else
Log("Preset URl is not correct.");
}
}

Expand All @@ -83,6 +96,9 @@ window.onload = function () {

//MARK: GUI
function drawGui() {
defaultOptions = JSON.parse(JSON.stringify(options));
const params = getUrlParams();

readProjectConfig().then((config) => {
gui = new lil.GUI({ autoPlace: false, width: 300 });

Expand Down Expand Up @@ -156,14 +172,18 @@ window.onload = function () {
initialAnimation();
});

gui.add(options, "Share");
gui.add(options, "Save");
gui.add(options, "Load");
gui.add(options, "Reset");

customContainer = document.getElementById('gui');
customContainer.appendChild(gui.domElement);

options.Load();
if (params)
options.LoadFrom(params);
else
options.Load();
});
}

Expand Down Expand Up @@ -707,5 +727,44 @@ window.onload = function () {
return acc;
}, {});
}

function paramsToUrl(urlParams, paramDefaults, filter) {
var defaults = new URLSearchParams(paramDefaults)
var params = new URLSearchParams(urlParams)

filter.forEach(key => {
params.delete(key);
defaults.delete(key);
});

defaults.forEach((value, key) => {
if (params.get(key) === value)
params.delete(key);
});

return window.location.protocol + "//" + window.location.host + "/?" + params.toString();
}

function copyToClipboard(text) {
const el = document.createElement('textarea');
el.value = text;
el.setAttribute('readonly', '');
document.body.appendChild(el);
el.select();
document.execCommand('copy');
document.body.removeChild(el);
}

function getUrlParams() {
urlParams = new URLSearchParams(window.location.search);
if (urlParams.size == 0)
return null;

params = {};
for (const [key, value] of urlParams)
params[key] = value;

return params;
}
};

0 comments on commit 2b04770

Please sign in to comment.