80 lines
2.6 KiB
HTML
80 lines
2.6 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Toy Cat Creator</title>
|
|
<meta charset="UTF-8" />
|
|
<link href="beleth.css" rel="stylesheet" type="text/css" media="all" />
|
|
<script>
|
|
|
|
function utf8_to_b64(str) {
|
|
return window.btoa(unescape(encodeURIComponent(str)));
|
|
}
|
|
|
|
function b64_to_utf8(str) {
|
|
return decodeURIComponent(escape(window.atob(str)));
|
|
}
|
|
|
|
function updateLink(h) {
|
|
/* h is an array of integers - convert it to a string */
|
|
console.log("UpdateLink: " + h);
|
|
var strBuffer = "";
|
|
for (var i = 0; i < h.length; ++i) {
|
|
strBuffer += String.fromCharCode(h[i]);
|
|
}
|
|
/* Convert the string into a base64 string */
|
|
var encoded = utf8_to_b64(strBuffer);
|
|
document.getElementById('preset.link').innerHTML='<a href="#' + encoded + '">Link to current selection</a>';
|
|
}
|
|
|
|
function hashToIntegers(h) {
|
|
/* Convert back to an array of integers */
|
|
var arr = [];
|
|
if (h) {
|
|
var encoded = h.substr(1);
|
|
var strBuffer = b64_to_utf8(encoded);
|
|
if (strBuffer) {
|
|
for (var i = 0; i < strBuffer.length; ++i) {
|
|
arr.push(strBuffer.charCodeAt(i));
|
|
}
|
|
}
|
|
}
|
|
return arr;
|
|
}
|
|
|
|
function initToyCatCreator() {
|
|
console.log("initToyCatCreator");
|
|
var svgDoc = document.getElementById('toy.cat.creator').getSVGDocument();
|
|
console.log(svgDoc);
|
|
var svgWin = svgDoc.defaultView;
|
|
console.log(svgWin);
|
|
console.log(svgWin.imageColors);
|
|
console.log(svgWin.addChangeStateCallback);
|
|
console.log(svgWin.notifiers);
|
|
console.log(svgWin.notifiers.push(updateLink));
|
|
console.log(svgWin.notifiers);
|
|
|
|
svgWin.addChangeStateCallback(updateLink);
|
|
svgWin.initFromState(hashToIntegers(location.hash));
|
|
console.log(svgWin.notifiers);
|
|
}
|
|
</script>
|
|
</head>
|
|
<body onload="initToyCatCreator();">
|
|
<article>
|
|
<section>
|
|
<p id="preset.link"><a href="#">Link to current selection</a></p>
|
|
</section>
|
|
<section>
|
|
<p><object id="toy.cat.creator" data="toy-cat-creator.svg" type="image/svg+xml"> </object></p>
|
|
</section>
|
|
<section>
|
|
<h2>About</h2>
|
|
<p>The Toy Cat Creator is a small dress up game made by <a href="http://feufochmar.fr">Feufochmar</a> starring the toy cat demon <a href="http://floraverse.com/comic/references/289-character-profile-commander-beleth/">Beleth</a> from <a href="http://floraverse.com">Floraverse</a>. <br/>
|
|
The game is contained inside an SVG image and is made under Inkscape. <br/>
|
|
The image is released under the <a href="https://creativecommons.org/licenses/by-sa/3.0/fr/">Creative Commons Attribution Share-Alike CC BY-SA</a>. </p>
|
|
<p><a href="toy-cat-creator.svg">Direct link</a> to SVG image. </p>
|
|
</section>
|
|
</article>
|
|
</body>
|
|
</html>
|