Skip to content

Commit

Permalink
Merge pull request #44 from Javran/master
Browse files Browse the repository at this point in the history
support loading from lz-string encoded data
  • Loading branch information
fourinone41 authored Dec 18, 2017
2 parents b9c1ba7 + a7f0af6 commit ad75273
Show file tree
Hide file tree
Showing 3 changed files with 516 additions and 2 deletions.
3 changes: 2 additions & 1 deletion battleplayer.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<script src="js/howler.min.js"></script>
<script src="js/URI.js"></script>
<script type="text/javascript" src="reader/steganography.js"></script>
<script type="text/javascript" src="reader/lz-string.js"></script>
<script src="js/battleText/playertext-table.js"></script>
<script type="text/javascript">
function loadImage(file) {
Expand Down Expand Up @@ -325,4 +326,4 @@

</body>

</html>
</html>
14 changes: 13 additions & 1 deletion js/battleplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,18 @@ var uri = new URI(window.location.href);
var qs = uri.search(true);
if (qs.fromImg) {
loadImgURL(qs.fromImg);
} else if (qs.fromLZString) {
/*
- LZString.compressToEncodedURIComponent(str) to encode strings
- LZString.decompressFromEncodedURIComponent(str) to decode from LZString-encoded strings
*/
try {
var decompressed = LZString.decompressFromEncodedURIComponent(qs.fromLZString);
document.getElementById('code').value = decompressed;
loadCode();
} catch (e) {
console.error('error while processing lz-string data', e)
}
} else if (window.location.hash.length > 5) {
document.getElementById('code').value = decodeURIComponent(window.location.hash.substr(1));
loadCode();
Expand All @@ -196,4 +208,4 @@ $('#textimgurl').on('keypress', function (e) {

$('#rad'+(localStorage.replay_lang || 'EN')).prop('checked',true);

if (renderer instanceof PIXI.CanvasRenderer) $('#warningwebgl').show();
if (renderer instanceof PIXI.CanvasRenderer) $('#warningwebgl').show();
Loading

0 comments on commit ad75273

Please sign in to comment.