mirror of
https://github.com/velocitatem/garlic.git
synced 2026-05-31 08:43:36 +00:00
Restruct
This commit is contained in:
@@ -29,6 +29,14 @@ function App() {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Go to `index.js` or anywhere before render. Add the following line of code:
|
||||||
|
|
||||||
|
```js
|
||||||
|
Garlic.peal(document);
|
||||||
|
```
|
||||||
|
|
||||||
|
And all is done!
|
||||||
|
|
||||||
## Astro
|
## Astro
|
||||||
Coming soon :)
|
Coming soon :)
|
||||||
|
|
||||||
|
|||||||
@@ -40,12 +40,25 @@ class Garlic {
|
|||||||
static encode(string) {
|
static encode(string) {
|
||||||
return btoa(string+this.salt);
|
return btoa(string+this.salt);
|
||||||
}
|
}
|
||||||
|
static decodeBase64(root) {
|
||||||
|
for (let i = 0; i < root.childNodes.length; i++) {
|
||||||
|
const child = root.childNodes[i];
|
||||||
|
if (child.childNodes.length === 1 && child.childNodes[0].nodeType === 3) {
|
||||||
|
const decoded = atob(child.childNodes[0].nodeValue).split("_yummy_")[0];
|
||||||
|
child.innerHTML = decoded;
|
||||||
|
console.log(child);
|
||||||
|
} else {
|
||||||
|
this.decodeBase64(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static peal(document) {
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
Garlic.decodeBase64(document.getElementById("root"));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export default Garlic;
|
export default Garlic;
|
||||||
/*
|
|
||||||
|
|
||||||
<script>
|
|
||||||
|
|
||||||
</script>
|
|
||||||
*/
|
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
function decodeBase64(root) {
|
|
||||||
for (let i = 0; i < root.childNodes.length; i++) {
|
|
||||||
const child = root.childNodes[i];
|
|
||||||
if (child.childNodes.length === 1 && child.childNodes[0].nodeType === 3) {
|
|
||||||
const decoded = atob(child.childNodes[0].nodeValue).split("_yummy_")[0]
|
|
||||||
child.innerHTML = decoded;
|
|
||||||
console.log(child);
|
|
||||||
} else {
|
|
||||||
decodeBase64(child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// when document is ready, decode the base64
|
|
||||||
document.addEventListener("DOMContentLoaded", function(event) {
|
|
||||||
decodeBase64(document.getElementById("root"));
|
|
||||||
});
|
|
||||||
|
|||||||
Reference in New Issue
Block a user