[plugin] lz-string (string compression)

Post your work in progress addons and get feedback

Post » Sat Jul 26, 2014 6:03 am

Document , plugin and sample capx included.

Reference - Lz string compression
B
110
S
28
G
280
Posts: 4,488
Reputation: 156,568

Post » Sun Jul 27, 2014 4:30 am

Does it improve performance if we use big characters for CPU cycle?

What's difference bewteen Base32k viewtopic.php?t=73288&start=0 and Lz string?
B
99
S
35
G
29
Posts: 3,139
Reputation: 28,421

Post » Sun Jul 27, 2014 6:10 am

@Joannesalfa

It's just save the space of data saved in webstorage.
B
110
S
28
G
280
Posts: 4,488
Reputation: 156,568

Post » Wed Jul 30, 2014 4:38 pm

Update

Add "Action:Set local value" and "Expression:LocalValue" to save compressed string to webstorage / load decompressed string from webstorage.
B
110
S
28
G
280
Posts: 4,488
Reputation: 156,568

Post » Sat Aug 27, 2016 12:07 pm

@rexrainbow - firstly I wish to thank you for making this plugin - it's really useful.

-rest deleted - not a bug! -
A big fan of JavaScript.
B
76
S
20
G
76
Posts: 2,285
Reputation: 47,554

Post » Sun Sep 18, 2016 4:09 pm

Hi Rex, I have a possible bug to report - when importing data string into NWjs the decompression fails with the following message:

Code: Select all
preview_prelude.js:30 Assertion failure: Calling expvalue.set_string without string type

Stack trace:
Error
    at Error (native)
    at assert2 (http://localhost:50000/preview_prelude.js:16:10)
    at ExpValue.set_string (http://localhost:50000/expressions.js:906:3)
    at Exps.Decompress (http://localhost:50000/Rex_Lzstring_plugin.js:123:10)
    at ExpNode.eval_object_exp (http://localhost:50000/expressions.js:347:27)
    at Parameter.get_exp_str (http://localhost:50000/eveng.js:2068:19)
    at Action.run_object (http://localhost:50000/eveng.js:1817:32)
    at EventBlock.run_actions_and_subevents (http://localhost:50000/eveng.js:931:38)
    at EventBlock.run (http://localhost:50000/eveng.js:888:9)
    at Runtime.executeSingleTrigger (http://localhost:50000/preview.js:4945:10)



Here is a capx to reproduce. Run the layout with group 1 enabled to save a .txt data file, then run the layout with group 1 disabled and group 2 enabled, to import the same file (this saves and imports a compressed dictionary.json string). Hope this helps and is an easy fix. Cheers.
A big fan of JavaScript.
B
76
S
20
G
76
Posts: 2,285
Reputation: 47,554

Post » Mon Sep 19, 2016 3:43 pm

@Colludium

It is an interested bug.
I found that official Ajax plugin will cut some characters which represent windows style line endings. It is a sweet design for users.
But... lz-string will use that kind of character to store data, they are not meaningless. Therefor the decompression is failed.
B
110
S
28
G
280
Posts: 4,488
Reputation: 156,568

Post » Mon Sep 19, 2016 11:50 pm

Update

- Feature of saving/loading from webstroage directly had been deprecated (removed).
- Add "Encoding" (None/Base64/UTF16/URI) to encode the compression result.


@Colludium
Try the new "Encoding" feature, and set "Encoding" to "UTF16" (or "URI", "Base64").
It is not perfect for your case, just a workaround solution.
B
110
S
28
G
280
Posts: 4,488
Reputation: 156,568

Post » Tue Sep 20, 2016 6:25 pm

@rexrainbow - that is excellent! I bow down to your mastery of c2 plugin creation. Thank you so much!!
A big fan of JavaScript.
B
76
S
20
G
76
Posts: 2,285
Reputation: 47,554


Return to Work in Progress Addons

Who is online

Users browsing this forum: No registered users and 0 guests