Permalink
Browse files

Demo the non-Web Workers version.

  • Loading branch information...
1 parent aae9567 commit 420911a68268ab04c24849a327a65959b6a07ff0 @nmrugg committed Jan 20, 2013
Showing with 40 additions and 0 deletions.
  1. +40 −0 demos/simple_demo_without_web_workers.html
@@ -0,0 +1,40 @@
+<head>
+ <title>Simple Demo (Without Web Workers)</title>
+ <meta http-equive="Content-Type" content="text/html; charset=utf-8">
+</head>
+<body>
+<p>This is a very simple demonstration of <a href="http://github.com/nmrugg/LZMA-JS/">LZMA.JS</a>,
+a browser-based implementation of the LZMA compression algorithm.</p>
+<p>You can find a more advanced demo <a href="advanced_demo.html">here</a>.</p>
+
+<textarea id=compression_el>Hello, world.</textarea><br>
+<button id=go>Go</button>
+<script src="../src/lzma_worker.js"></script>
+<script>
+
+var compression_mode = 1,
+ /// lzma_worker.js creates a global LZMA object. We store it as a new variable just to match simple_demo.html.
+ my_lzma = LZMA;
+
+document.getElementById("go").onclick = function () {
+ /// First, let's compress it.
+ my_lzma.compress(document.getElementById("compression_el").value, compression_mode, function (result) {
+ alert("Compressed: " + result);
+
+ /// Now, let's try to decompress it to make sure it works both ways.
+ my_lzma.decompress(result, function (result) {
+ alert("Decompressed: " + result);
+ }, function (percent) {
+ /// Decompressing progress code goes here.
+ document.title = "Decompressing: " + (percent * 100) + "%";
+ });
+ }, function (percent) {
+ /// Compressing progress code goes here.
+ document.title = "Compressing: " + (percent * 100) + "%";
+ });
+}
+
+
+
+</script>
+</body>

0 comments on commit 420911a

Please sign in to comment.